aiterm-steer-delivery 0.4.0 → 0.4.1

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1
4
+
5
+ 0.4.0の「寝ている会話を起こす見張り」の、3つの直しです。
6
+
7
+ - **Linuxでは見張りを起こさない。** 0.4.0は、画面のあるLinuxで`xdg-open`を使うと書いていた。実物(Linuxのアプリ、Codex 0.162.0-alpha.2)で、同じリンクを開かせても会話が載らず、キューは動かなかった。動く形を確かめるまで、Linuxでは何も開かない(今までどおり、会話が開かれた時に届く)。CodexがMCP serverへ渡す環境には`DISPLAY`も`WAYLAND_DISPLAY`も無いので、0.4.0でも製品の本番の道では起きていなかった。
8
+ - **リンクを開く命令を、場所を決めて呼ぶ。** macOSは`/usr/bin/open`、Windowsは`ComSpec`(無ければ`%SystemRoot%\\System32\\cmd.exe`)。CodexがMCP serverへ渡す環境は細く、`PATH`に頼ると見つからない事がある。
9
+ - 文書の、Linuxで動くという記述を直す。
10
+
3
11
  ## 0.4.0
4
12
 
5
13
  Codexの寝ている会話へ入れた文が、人がその会話を開くまで動かなかったのを直します。今までのAPIの返りは変わりません。
@@ -7,11 +15,11 @@ Codexの寝ている会話へ入れた文が、人がその会話を開くまで
7
15
  - **起きていた事。** Codexが公式キューの文を番にするのは、その会話を載せている(loaded)Codexのprocessだけ。Codexのアプリは、見ている接続が居なくなって動きの無い会話を60秒で下ろす(`thread_unload_delay_secs`。Codex 0.153.0までは30分)。下ろされた会話のキューは、人がその会話を開くまで誰も見ない。番の途中へ入れる道(hook)と、載っている会話の止まっている所へ届く道は、今までどおり通っていた。
8
16
  - **`submitCodexParentAnswer`が、入れた後に「寝ていたら起こす見張り」を別のprocessで起こす。** 約15秒後にキューを見直す。
9
17
  - 文がもう無い(会話が載っていて受け取った、hookが番の途中へ入れた): 何もしない。
10
- - 文が残っていて、アプリの会話(`source`が`vscode`)で、最後の番が普通に終わっている(または番が1つも無い): OSの口で`codex://threads/<会話>`を開かせる。アプリが会話を載せ、公式キューが番を始める。アプリの画面はその会話へ切り替わる(macOSは`open -g`で、アプリを前面へは出さない。Windowsは`cmd /c start`、Linuxは`xdg-open`)。Windowsでは、人の画面のあるsessionの時だけ開く(サービスやsshのsessionから開いたリンクは、人の画面のアプリへ届かない)。
18
+ - 文が残っていて、アプリの会話(`source`が`vscode`)で、最後の番が普通に終わっている(または番が1つも無い): OSの口で`codex://threads/<会話>`を開かせる。アプリが会話を載せ、公式キューが番を始める。アプリの画面はその会話へ切り替わる(macOSは`open -g`で、アプリを前面へは出さない。Windowsは`cmd /c start`。Linuxは0.4.1で外した)。Windowsでは、人の画面のあるsessionの時だけ開く(サービスやsshのsessionから開いたリンクは、人の画面のアプリへ届かない)。
11
19
  - 番の途中、最後の番が途中で止められている(人が止めた、ほかの製品が作業を別の会話へ移した)、アプリの会話でない(CLIの席)、会話の記録を読めない: 起こさない。途中で止められた会話は、人が次の文を送るまでCodexがキューを動かさない。
12
20
  - 同じ会話へ続けて届いた時は、30秒の間は開き直さない。
13
21
  - **結果を残す。** `<config_root>/codex-parent-hooks/wake/<配送ID>.json`に3日間。`readCodexWakeResult(profile, deliveryId)`で読める(`delivered`・`running`・`interrupted`・`not_app_thread`・`unknown_state`・`no_opener`・`open_failed`・`woken`・`opened_still_queued`)。受付の返り(`queued_submission_id`)は、見張りの成否で変わらない。
14
- - **見張りを起こすのは、リンクを開く口のある環境だけ。** macOS、Windows、画面のあるLinux(`DISPLAY`か`WAYLAND_DISPLAY`があり、`codex`のリンクの受け手が登録されている)。サーバーやコンテナでは何も起こさない。止める時は環境変数`AITERM_STEER_CODEX_WAKE=0`。
22
+ - **見張りを起こすのは、リンクを開く口のある環境だけ。** macOSとWindows(Linuxは0.4.1で外した)。サーバーやコンテナでは何も起こさない。止める時は環境変数`AITERM_STEER_CODEX_WAKE=0`。
15
23
  - **公開した物。** `wakeCodexParentIfAsleep(profile, parent, deliveryId, options?)`(今すぐ見直して起こす)、`startCodexWakeWatch`、`readCodexWakeResult`、`readCodexTurnTail`、`codexThreadUrl`、`codexThreadOpener`、`codexWakeWatchEnabled`、`codexWakeDirectory`。`CodexReceiverRuntime`に`wake`(`runtime`を渡す呼び出しでは、`true`の時だけ見張りを起こす)。
16
24
  - **CLI。** `codex submit`は今までどおりすぐ返り、見張りを残す。`codex state`の返りは、見張りが結果を残した後だけ`wake`が付く(それまでは今までと同じ形)。`codex wake --thread --delivery [--delay-ms]`を足す。
17
25
  - **Aitermへ頼む入口。** `codexDeliveryDetailViaAiterm`の返りは、Aiterm(0.58.0以上)が見張りの結果を返した時だけ`wake`が付く。
package/README.md CHANGED
@@ -175,7 +175,7 @@ Codex starts a queued message only in a conversation that some running Codex pro
175
175
 
176
176
  The outcome is saved under `<config_root>/codex-parent-hooks/wake/<delivery id>.json` for three days and can be read with `readCodexWakeResult(PROFILE, deliveryId)`: `delivered`, `running`, `interrupted`, `not_app_thread`, `unknown_state`, `no_opener`, `open_failed`, `woken`, or `opened_still_queued`. The acceptance returned by `submitCodexParentAnswer` does not depend on the watcher.
177
177
 
178
- The watcher runs only where a link can be opened: macOS, Windows, and Linux with a display and a registered `codex` link handler. On Windows the link is opened only from an interactive session (a link opened from a service or an SSH session never reaches the app on the desktop; the outcome is `no_opener`). On servers and in containers nothing is started. Set `AITERM_STEER_CODEX_WAKE=0` to turn it off. To check and wake right now from your own process, call `wakeCodexParentIfAsleep(PROFILE, parent, deliveryId, { delay_ms: 0 })`.
178
+ The watcher runs on macOS and Windows. On Windows the link is opened only from an interactive session (a link opened from a service or an SSH session never reaches the app on the desktop; the outcome is `no_opener`). On Linux nothing is started yet: asking the Linux app to open the same link did not load the conversation in our tests, so a reply to a sleeping conversation still waits there until the conversation is opened. On servers and in containers nothing is started. Set `AITERM_STEER_CODEX_WAKE=0` to turn it off. To check and wake right now from your own process, call `wakeCodexParentIfAsleep(PROFILE, parent, deliveryId, { delay_ms: 0 })`.
179
179
 
180
180
  **Many messages to one conversation** (channels, e.g. Peertable's room messages to the parent):
181
181
 
@@ -21,8 +21,9 @@ export interface CodexThreadOpener {
21
21
  export declare function windowsInteractiveSession(env?: NodeJS.ProcessEnv, sessionId?: () => string): boolean;
22
22
  /**
23
23
  * OSの口で、Codexのアプリにリンクを開かせる関数を返す。口の無い環境ではnull。
24
- * macOSは`open -g`(アプリを前面へ出さない)、Windowsは`cmd /c start`(人の画面のあるsessionの時だけ)。
25
- * Linuxは、画面のあるsessionで、リンクの受け手が登録されている時だけ`xdg-open`。
24
+ * macOSは`/usr/bin/open -g`(アプリを前面へ出さない)、Windowsは`cmd /c start`(人の画面のあるsessionの時だけ)。
25
+ * Linuxのアプリは、まだ起こせない(`xdg-open`で開かせても会話が載らなかった。実物で確かめた後に足す)。
26
+ * 命令は場所を決めて呼ぶ。CodexがMCP serverへ渡す環境は細く、PATHに頼ると見つからない事がある。
26
27
  */
27
28
  export declare function codexThreadOpener(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv, interactive?: () => boolean): CodexThreadOpener | null;
28
29
  export type CodexWakeOutcome =
@@ -76,7 +77,7 @@ export declare function readCodexWakeResult(profile: ProductProfile, deliveryId:
76
77
  * 起こすのは、アプリの会話(sourceがvscode)で、最後の番が普通に終わっている(または番が1つも無い)時だけ。
77
78
  */
78
79
  export declare function wakeCodexParentIfAsleep(profile: ProductProfile, parent: CodexParent, deliveryId: string, options?: CodexWakeOptions): Promise<CodexWakeResult>;
79
- /** 見張りを別のprocessで起こすかどうか。口の無い環境(画面の無いLinuxなど)では、何も起こさない。 */
80
+ /** 見張りを別のprocessで起こすかどうか。リンクを開く口の無いOS(Linuxなど)では、何も起こさない。 */
80
81
  export declare function codexWakeWatchEnabled(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): boolean;
81
82
  export declare const CODEX_WAKE_PAYLOAD_ENV = "AITERM_STEER_CODEX_WAKE_PAYLOAD";
82
83
  /** 見張りのprocessへ渡す、関数を含まない製品の識別情報。 */
@@ -88,8 +88,9 @@ export function windowsInteractiveSession(env = process.env, sessionId = () => w
88
88
  }
89
89
  /**
90
90
  * OSの口で、Codexのアプリにリンクを開かせる関数を返す。口の無い環境ではnull。
91
- * macOSは`open -g`(アプリを前面へ出さない)、Windowsは`cmd /c start`(人の画面のあるsessionの時だけ)。
92
- * Linuxは、画面のあるsessionで、リンクの受け手が登録されている時だけ`xdg-open`。
91
+ * macOSは`/usr/bin/open -g`(アプリを前面へ出さない)、Windowsは`cmd /c start`(人の画面のあるsessionの時だけ)。
92
+ * Linuxのアプリは、まだ起こせない(`xdg-open`で開かせても会話が載らなかった。実物で確かめた後に足す)。
93
+ * 命令は場所を決めて呼ぶ。CodexがMCP serverへ渡す環境は細く、PATHに頼ると見つからない事がある。
93
94
  */
94
95
  export function codexThreadOpener(platform = process.platform, env = process.env, interactive = () => windowsInteractiveSession(env)) {
95
96
  const run = (command, args) => () => {
@@ -99,16 +100,13 @@ export function codexThreadOpener(platform = process.platform, env = process.env
99
100
  return result.status === 0 ? { ok: true } : { ok: false, detail: `exit=${result.status} ${String(result.stderr ?? "").trim().slice(0, 200)}`.trim() };
100
101
  };
101
102
  if (platform === "darwin")
102
- return url => run("open", ["-g", url])();
103
- if (platform === "win32")
104
- return interactive() ? url => run("cmd.exe", ["/d", "/c", "start", "", url])() : null;
105
- if (platform === "linux") {
106
- if (!env.DISPLAY && !env.WAYLAND_DISPLAY)
103
+ return url => run("/usr/bin/open", ["-g", url])();
104
+ if (platform === "win32") {
105
+ if (!interactive())
107
106
  return null;
108
- const handler = spawnSync("xdg-mime", ["query", "default", "x-scheme-handler/codex"], { encoding: "utf8", timeout: 5_000, stdio: ["ignore", "pipe", "ignore"], env });
109
- if (handler.error || handler.status !== 0 || !String(handler.stdout ?? "").trim())
110
- return null;
111
- return url => run("xdg-open", [url])();
107
+ const key = (name) => Object.keys(env).find(candidate => candidate.toLowerCase() === name);
108
+ const comspec = env[key("comspec") ?? "ComSpec"] ?? path.win32.join(env[key("systemroot") ?? "SystemRoot"] ?? "C:\\Windows", "System32", "cmd.exe");
109
+ return url => run(comspec, ["/d", "/c", "start", "", url])();
112
110
  }
113
111
  return null;
114
112
  }
@@ -243,13 +241,11 @@ export async function wakeCodexParentIfAsleep(profile, parent, deliveryId, optio
243
241
  catch { /* 結果を残せなくても、起こした事は変わらない */ }
244
242
  return result;
245
243
  }
246
- /** 見張りを別のprocessで起こすかどうか。口の無い環境(画面の無いLinuxなど)では、何も起こさない。 */
244
+ /** 見張りを別のprocessで起こすかどうか。リンクを開く口の無いOS(Linuxなど)では、何も起こさない。 */
247
245
  export function codexWakeWatchEnabled(platform = process.platform, env = process.env) {
248
246
  if (env.AITERM_STEER_CODEX_WAKE === "0")
249
247
  return false;
250
- if (platform === "darwin" || platform === "win32")
251
- return true;
252
- return platform === "linux" && Boolean(env.DISPLAY || env.WAYLAND_DISPLAY);
248
+ return platform === "darwin" || platform === "win32";
253
249
  }
254
250
  export const CODEX_WAKE_PAYLOAD_ENV = "AITERM_STEER_CODEX_WAKE_PAYLOAD";
255
251
  /** 見張りのprocessへ渡す、関数を含まない製品の識別情報。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-steer-delivery",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
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",