@nowcrew/daemon 0.5.26 → 0.5.27
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/dist/execution-supervisor.js +19 -5
- package/dist/remote/claude-bridge.js +402 -0
- package/dist/remote/claude-channel.js +164 -0
- package/dist/remote/codex-client.js +408 -0
- package/dist/remote/codex-runtime.js +77 -0
- package/dist/remote/config.js +83 -0
- package/dist/remote/gateway.js +572 -0
- package/dist/remote/protocol.js +178 -0
- package/dist/remote/remote-cli.js +233 -0
- package/dist/remote/session-discovery.js +249 -0
- package/dist/remote/wrapper.js +40 -0
- package/dist/runtimes/codex-app-server-runner.js +5 -1
- package/package.json +2 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
3
|
+
function optionValue(args, long, short) {
|
|
4
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
5
|
+
const value = args[index];
|
|
6
|
+
if (value.startsWith(`${long}=`))
|
|
7
|
+
return value.slice(long.length + 1);
|
|
8
|
+
if (value === long || (short && value === short)) {
|
|
9
|
+
const next = args[index + 1];
|
|
10
|
+
return next && !next.startsWith("-") ? next : null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
export function resolveClaudeWrapperSession(args, createId = randomUUID) {
|
|
16
|
+
if (args.includes("--continue") || args.includes("-c")) {
|
|
17
|
+
throw new Error("NowCrew remote requires an explicit session ID; use --resume <session-id> instead of --continue");
|
|
18
|
+
}
|
|
19
|
+
if (args.includes("--fork-session")) {
|
|
20
|
+
throw new Error("NowCrew remote cannot identify a fork chosen inside Claude; start a new session or resume without --fork-session");
|
|
21
|
+
}
|
|
22
|
+
const sessionId = optionValue(args, "--session-id") ?? optionValue(args, "--resume", "-r") ?? createId();
|
|
23
|
+
if (!UUID.test(sessionId)) {
|
|
24
|
+
throw new Error("Claude remote sessions require a UUID in --session-id or --resume");
|
|
25
|
+
}
|
|
26
|
+
const hasSessionSelector = args.some((value) => value === "--session-id" || value.startsWith("--session-id=")
|
|
27
|
+
|| value === "--resume" || value.startsWith("--resume=") || value === "-r");
|
|
28
|
+
return {
|
|
29
|
+
sessionId,
|
|
30
|
+
args: hasSessionSelector ? [...args] : ["--session-id", sessionId, ...args],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function buildCodexWrappedInvocation(userArgs, socketPath = "") {
|
|
34
|
+
const hasRemote = userArgs.some((value) => value === "--remote" || value.startsWith("--remote="));
|
|
35
|
+
return {
|
|
36
|
+
bin: "codex",
|
|
37
|
+
args: hasRemote ? [...userArgs] : ["--remote", socketPath ? `unix://${socketPath}` : "unix://", ...userArgs],
|
|
38
|
+
env: process.env,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -16,7 +16,11 @@ const RunnerInputSchema = z.object({
|
|
|
16
16
|
resume: z.boolean(),
|
|
17
17
|
}).strict();
|
|
18
18
|
const RPC_TIMEOUT_MS = 30_000;
|
|
19
|
+
const INITIALIZE_RPC_TIMEOUT_MS = 60_000;
|
|
19
20
|
const ERROR_MESSAGE_CAP = 2_000;
|
|
21
|
+
export function codexRpcTimeoutMs(method) {
|
|
22
|
+
return method === "initialize" ? INITIALIZE_RPC_TIMEOUT_MS : RPC_TIMEOUT_MS;
|
|
23
|
+
}
|
|
20
24
|
function safeErrorMessage(error, secrets) {
|
|
21
25
|
let message = error instanceof Error ? error.message : String(error);
|
|
22
26
|
for (const secret of secrets) {
|
|
@@ -106,7 +110,7 @@ class CodexRpcClient {
|
|
|
106
110
|
this.close(new Error(`Codex app-server exited: code=${code} signal=${signal}`));
|
|
107
111
|
});
|
|
108
112
|
}
|
|
109
|
-
request(method, params, timeoutMs =
|
|
113
|
+
request(method, params, timeoutMs = codexRpcTimeoutMs(method)) {
|
|
110
114
|
if (this.closedError !== null)
|
|
111
115
|
return Promise.reject(this.closedError);
|
|
112
116
|
const id = this.nextId++;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nowcrew/daemon",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "crew daemon — 运行在用户机器:拉起/管理 agent 进程,注入 crew CLI,归一化 runtime 事件",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"cross-spawn": "^7.0.6",
|
|
22
22
|
"ws": "^8",
|
|
23
23
|
"zod": "^3.23.0",
|
|
24
|
-
"@nowcrew/cli": "^0.4.
|
|
24
|
+
"@nowcrew/cli": "^0.4.6"
|
|
25
25
|
},
|
|
26
26
|
"optionalDependencies": {
|
|
27
27
|
"koffi": "^2.9.0"
|