aiterm-steer-delivery 0.1.7 → 0.1.9
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 +6 -0
- package/README.md +2 -0
- package/dist/cursor-receive.d.ts +11 -2
- package/dist/cursor-receive.js +19 -2
- package/dist/hook-main.d.ts +7 -3
- package/dist/hook-main.js +12 -2
- 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,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.9
|
|
4
|
+
|
|
5
|
+
- `waitProcessCommandLine`を公開する(Aitermから移した)。`cursorReceiveProcess`・`channelReceiveProcess`の起動情報を、親のshellへ書ける1行にする(POSIXはsh、Windowsは既定のPowerShell)。Cursor CLIのmodelはtool結果のstructuredContentを読まないので、Cursor・Grokの親には背景で受信を起動するコマンドをtool結果の本文に書く必要がある(ラプラス氏の依頼、決裁箱のコネクタで使う)。
|
|
6
|
+
## 0.1.8
|
|
7
|
+
|
|
8
|
+
- `runCursorHookMain`・`runCursorReceiveMain`・`runCursorReceive`が置き場を複数受け取れる。Cursor CLIはMCPを削った環境(XDG_RUNTIME_DIR・TMPDIR等が無い)で起動し、hookと背景processは画面側の環境で起動する。環境から置き場を決める製品(Aiterm)はMCPとhookで置き場が割れ、hookが配送記録を見つけられずに何もしていなかった(rabbit・macbookで確認)。hookは渡した置き場それぞれで結び付けと差し込みを行い、受信は配送記録のある置き場で待つ。配送記録の無い置き場には何も作らない。
|
|
3
9
|
## 0.1.7
|
|
4
10
|
|
|
5
11
|
- WindowsのCursor(cursor-agent 2026.09.28)はhookのstdinのJSONの先頭にBOM(U+FEFF)を付ける。`handleCursorHook`がそのまま読んで失敗し、会話への結び付けも作業中の差し込みも起きず、配送は`sending`のまま止まっていた(紅蓮氏の報告、foxで確認)。hook入口の読み取り(Codex・Claude Code・Cursor共通)と`handleCursorHook`で先頭のBOMを落とす。`withoutBom`も公開する。
|
package/README.md
CHANGED
|
@@ -38,6 +38,8 @@ steer.channelDeliveryState(PROFILE, channel.channel_id, id); // queued | sending
|
|
|
38
38
|
|
|
39
39
|
Claude Code re-arms its waiter at every `Stop`. Cursor binds the channel with `steer.channelMarker(channel)` placed in your tool result, and idle Cursor/Grok parents run `steer.channelReceiveProcess(...)` in the background; each result carries `next_wait_process` to re-arm.
|
|
40
40
|
|
|
41
|
+
Put both the marker and the receiver command in the **text** of your tool result, not only in `structuredContent`: the Cursor CLI model does not read structured content. `steer.waitProcessCommandLine(steer.channelReceiveProcess(script, channel.channel_id))` gives the command as one shell line (POSIX sh, or PowerShell on Windows).
|
|
42
|
+
|
|
41
43
|
## Product profile
|
|
42
44
|
|
|
43
45
|
Everything product-specific lives in one object. The delivery mechanism is the same for every product.
|
package/dist/cursor-receive.d.ts
CHANGED
|
@@ -5,5 +5,14 @@ export interface WaitProcess {
|
|
|
5
5
|
}
|
|
6
6
|
/** 親の背景process APIへそのまま渡す起動情報。scriptは製品のCursor受信入口の絶対path。 */
|
|
7
7
|
export declare function cursorReceiveProcess(script: string, deliveryId: string, executable?: string): WaitProcess;
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* 背景processの起動情報を、親のshellへ書ける1行にする(Windowsの既定shellはPowerShell)。
|
|
10
|
+
* Cursor CLIのmodelはtool結果のstructuredContentを読まないので、起動情報は本文にこの行で書く。
|
|
11
|
+
*/
|
|
12
|
+
export declare function waitProcessCommandLine(wait: {
|
|
13
|
+
executable: string;
|
|
14
|
+
args: readonly string[];
|
|
15
|
+
}, platform?: NodeJS.Platform): string;
|
|
16
|
+
/** 受信入口の本体。結果を1行のJSONでstdoutへ出し、exit codeを返す(0=受取、3=期限切れ、1=誤り)。
|
|
17
|
+
* hookRootを複数渡すと、配送記録のある置き場で待つ(runCursorHookMainと同じ理由)。どこにも無ければ先頭の置き場で誤りを返す。 */
|
|
18
|
+
export declare function runCursorReceive(hookRoot: string | readonly string[], argv: string[], emit?: (value: unknown) => void, usage?: string): Promise<number>;
|
package/dist/cursor-receive.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Cursor親がidleのとき、背景で起動して回答本文の到着を待つ受け口。
|
|
2
2
|
// 起動するファイルは製品が同梱する入口で、そこからrunCursorReceiveを呼ぶ。
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as path from "node:path";
|
|
3
5
|
import { receiveCursorAnswer } from "./cursor-receiver.js";
|
|
4
6
|
import { windowsStartProcessArgumentList } from "./windows.js";
|
|
5
7
|
/** 親の背景process APIへそのまま渡す起動情報。scriptは製品のCursor受信入口の絶対path。 */
|
|
@@ -11,13 +13,28 @@ export function cursorReceiveProcess(script, deliveryId, executable = process.ex
|
|
|
11
13
|
windows_start_process_argument_list: process.platform === "win32" ? windowsStartProcessArgumentList(args) : null,
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* 背景processの起動情報を、親のshellへ書ける1行にする(Windowsの既定shellはPowerShell)。
|
|
18
|
+
* Cursor CLIのmodelはtool結果のstructuredContentを読まないので、起動情報は本文にこの行で書く。
|
|
19
|
+
*/
|
|
20
|
+
export function waitProcessCommandLine(wait, platform = process.platform) {
|
|
21
|
+
const values = [wait.executable, ...wait.args];
|
|
22
|
+
if (platform === "win32")
|
|
23
|
+
return `& ${values.map(value => `'${value.replace(/'/g, "''")}'`).join(" ")}`;
|
|
24
|
+
return values.map(value => `'${value.replace(/'/g, "'\\''")}'`).join(" ");
|
|
25
|
+
}
|
|
26
|
+
/** 受信入口の本体。結果を1行のJSONでstdoutへ出し、exit codeを返す(0=受取、3=期限切れ、1=誤り)。
|
|
27
|
+
* hookRootを複数渡すと、配送記録のある置き場で待つ(runCursorHookMainと同じ理由)。どこにも無ければ先頭の置き場で誤りを返す。 */
|
|
15
28
|
export async function runCursorReceive(hookRoot, argv, emit = value => { process.stdout.write(JSON.stringify(value) + "\n"); }, usage = "usage: cursor-parent-receive --delivery <uuid>") {
|
|
16
29
|
if (argv.length !== 2 || argv[0] !== "--delivery" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(argv[1])) {
|
|
17
30
|
emit({ ok: false, code: "CURSOR_PARENT_RECEIVE_USAGE", message: usage });
|
|
18
31
|
return 1;
|
|
19
32
|
}
|
|
20
|
-
const
|
|
33
|
+
const roots = typeof hookRoot === "string" ? [hookRoot] : [...hookRoot];
|
|
34
|
+
const root = roots.find(each => fs.existsSync(path.join(each, "deliveries", argv[1]))) ?? roots[0];
|
|
35
|
+
if (root === undefined)
|
|
36
|
+
throw new Error("受信の置き場がありません");
|
|
37
|
+
const result = await receiveCursorAnswer(root, argv[1]);
|
|
21
38
|
if (result.outcome === "timeout") {
|
|
22
39
|
emit({ delivery_id: argv[1], outcome: "timeout" });
|
|
23
40
|
return 3;
|
package/dist/hook-main.d.ts
CHANGED
|
@@ -3,10 +3,14 @@ import { type ProductProfile } from "./profile.js";
|
|
|
3
3
|
export declare function runCodexHookMain(profile: ProductProfile, directory?: string | undefined): Promise<void>;
|
|
4
4
|
/** Claude Codeが直接起動する公式hook(PreToolUse/PostToolUse/SessionEnd)。本文はstderrへ返す。 */
|
|
5
5
|
export declare function runClaudeHookMain(profile: ProductProfile, root?: string): Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Cursorが起動する公式hook。差し込み文をstdoutのJSONへ返す。
|
|
8
|
+
* rootを複数渡すと、各置き場で結び付けと差し込みを行う。Cursor CLIはMCPを削った環境で起動し、hookは画面側の環境で起動するため、
|
|
9
|
+
* 環境から置き場を決める製品はMCPとhookで置き場が割れる。配送記録の無い置き場では何もしない。
|
|
10
|
+
*/
|
|
11
|
+
export declare function runCursorHookMain(profile: ProductProfile, root?: string | readonly string[]): Promise<void>;
|
|
8
12
|
/** Cursor親の背景受信。 */
|
|
9
|
-
export declare function runCursorReceiveMain(profile: ProductProfile, argv?: string[], root?: string): Promise<void>;
|
|
13
|
+
export declare function runCursorReceiveMain(profile: ProductProfile, argv?: string[], root?: string | readonly string[]): Promise<void>;
|
|
10
14
|
/**
|
|
11
15
|
* channelの背景受信(Cursorのidle時、Grok等)。受け取った本文を1行のJSONで出して終わる(0=受取、3=期限切れ、4=閉鎖、1=誤り)。
|
|
12
16
|
* 受取と期限切れの結果には、同じ受信を張り直すための next_wait_process を付ける。
|
package/dist/hook-main.js
CHANGED
|
@@ -63,11 +63,21 @@ export async function runClaudeHookMain(profile, root = claudeHookRoot(profile))
|
|
|
63
63
|
process.exitCode = 2;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Cursorが起動する公式hook。差し込み文をstdoutのJSONへ返す。
|
|
68
|
+
* rootを複数渡すと、各置き場で結び付けと差し込みを行う。Cursor CLIはMCPを削った環境で起動し、hookは画面側の環境で起動するため、
|
|
69
|
+
* 環境から置き場を決める製品はMCPとhookで置き場が割れる。配送記録の無い置き場では何もしない。
|
|
70
|
+
*/
|
|
67
71
|
export async function runCursorHookMain(profile, root = cursorHookRoot(profile)) {
|
|
68
72
|
try {
|
|
69
73
|
const input = await readStdin();
|
|
70
|
-
const result =
|
|
74
|
+
const result = {};
|
|
75
|
+
for (const each of typeof root === "string" ? [root] : [...new Set(root)]) {
|
|
76
|
+
const found = await handleCursorHook(profile, input.length > 0 ? input : "{}", each);
|
|
77
|
+
if (typeof found.additional_context === "string") {
|
|
78
|
+
result.additional_context = typeof result.additional_context === "string" ? `${result.additional_context}\n\n${found.additional_context}` : found.additional_context;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
71
81
|
if (profile.channels) {
|
|
72
82
|
let event = null;
|
|
73
83
|
try {
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { runCodexResultHook } from "./codex-hooks.js";
|
|
|
11
11
|
export { codexHookCommand, processCodexHome, mergeCodexParentHooks, planCodexParentHooks, writeCodexHookPlan, applyCodexHookPlan, verifyCodexHookRegistration, configureCodexSteer, type CodexHookMove, type CodexHookPlan, type CodexSteerAction, type CodexSteerResult, type CodexSteerRuntime, } from "./codex-setup.js";
|
|
12
12
|
export { claudeParentSchema, prepareClaudeHookRequest, claudeParentFromRequest, verifyClaudeParent, bindClaudeParentDelivery, closeClaudeParentSession, submitClaudeParentAnswer, runClaudeResultHook, type ClaudeParent, } from "./claude-receiver.js";
|
|
13
13
|
export { cursorParentSchema, isCursorMcpClient, cursorHooksFile, cursorParentHooksRegistered, verifyCursorParent, cursorParentFromRequest, prepareCursorDelivery, submitCursorParentAnswer, handleCursorHook, receiveCursorAnswer, type CursorParent, type CursorReceiveResult, } from "./cursor-receiver.js";
|
|
14
|
-
export { cursorReceiveProcess, runCursorReceive, type WaitProcess } from "./cursor-receive.js";
|
|
14
|
+
export { cursorReceiveProcess, runCursorReceive, waitProcessCommandLine, type WaitProcess } from "./cursor-receive.js";
|
|
15
15
|
export { claudeParentHookEntries, mergeClaudeParentHooks, removeClaudeParentHooks, cursorParentHookCommand, mergeCursorParentHooks, removeCursorParentHooks, type HookRuntime, } from "./hook-setup.js";
|
|
16
16
|
export { runCodexHookMain, runClaudeHookMain, runCursorHookMain, runCursorReceiveMain, isDirectExecution } from "./hook-main.js";
|
|
17
17
|
export { runChannelReceiveMain } from "./hook-main.js";
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { runCodexResultHook } from "./codex-hooks.js";
|
|
|
13
13
|
export { codexHookCommand, processCodexHome, mergeCodexParentHooks, planCodexParentHooks, writeCodexHookPlan, applyCodexHookPlan, verifyCodexHookRegistration, configureCodexSteer, } from "./codex-setup.js";
|
|
14
14
|
export { claudeParentSchema, prepareClaudeHookRequest, claudeParentFromRequest, verifyClaudeParent, bindClaudeParentDelivery, closeClaudeParentSession, submitClaudeParentAnswer, runClaudeResultHook, } from "./claude-receiver.js";
|
|
15
15
|
export { cursorParentSchema, isCursorMcpClient, cursorHooksFile, cursorParentHooksRegistered, verifyCursorParent, cursorParentFromRequest, prepareCursorDelivery, submitCursorParentAnswer, handleCursorHook, receiveCursorAnswer, } from "./cursor-receiver.js";
|
|
16
|
-
export { cursorReceiveProcess, runCursorReceive } from "./cursor-receive.js";
|
|
16
|
+
export { cursorReceiveProcess, runCursorReceive, waitProcessCommandLine } from "./cursor-receive.js";
|
|
17
17
|
export { claudeParentHookEntries, mergeClaudeParentHooks, removeClaudeParentHooks, cursorParentHookCommand, mergeCursorParentHooks, removeCursorParentHooks, } from "./hook-setup.js";
|
|
18
18
|
export { runCodexHookMain, runClaudeHookMain, runCursorHookMain, runCursorReceiveMain, isDirectExecution } from "./hook-main.js";
|
|
19
19
|
export { runChannelReceiveMain } from "./hook-main.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.9",
|
|
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",
|