@nowcrew/daemon 0.6.6 → 0.6.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/README.md +26 -18
- package/dist/agent-memory/bridge.js +9 -6
- package/dist/agent-memory/client.js +2 -2
- package/dist/computer-service.js +9 -1
- package/dist/execution-protocol.js +1 -0
- package/dist/execution-runner.js +2 -2
- package/dist/machine-info.js +1 -0
- package/dist/main.js +0 -0
- package/dist/prompt.js +15 -10
- package/dist/workspace.js +30 -13
- package/package.json +8 -9
- package/dist/remote/claude-bridge.js +0 -558
- package/dist/remote/claude-channel.js +0 -164
- package/dist/remote/codex-client.js +0 -451
- package/dist/remote/codex-runtime.js +0 -77
- package/dist/remote/config.js +0 -135
- package/dist/remote/gateway.js +0 -879
- package/dist/remote/identity.js +0 -39
- package/dist/remote/owner.js +0 -77
- package/dist/remote/protocol.js +0 -211
- package/dist/remote/remote-cli.js +0 -254
- package/dist/remote/runtime-probe.js +0 -182
- package/dist/remote/session-discovery.js +0 -249
- package/dist/remote/wrapper.js +0 -40
- package/dist/remote-web/assets/index-B_6VM_tw.js +0 -94
- package/dist/remote-web/assets/index-L6EiQbJn.css +0 -1
- package/dist/remote-web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/dist/remote-web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/dist/remote-web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/dist/remote-web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/dist/remote-web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/dist/remote-web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/dist/remote-web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/dist/remote-web/icons/nowwork-192.png +0 -0
- package/dist/remote-web/icons/nowwork-512.png +0 -0
- package/dist/remote-web/icons/nowwork.svg +0 -7
- package/dist/remote-web/index.html +0 -20
- package/dist/remote-web/manifest.webmanifest +0 -13
- package/dist/remote-web/sw.js +0 -12
package/dist/remote/config.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from "node:crypto";
|
|
2
|
-
import { link, mkdir, open, readFile, rename, unlink } from "node:fs/promises";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
const RemoteConfigFileSchema = z.object({
|
|
7
|
-
version: z.literal(1),
|
|
8
|
-
host: z.string().min(1),
|
|
9
|
-
port: z.number().int().min(1).max(65_535),
|
|
10
|
-
allowedOrigins: z.array(z.string().url()).max(16),
|
|
11
|
-
}).strict();
|
|
12
|
-
const RemoteOwnerLockSchema = z.object({
|
|
13
|
-
version: z.literal(1),
|
|
14
|
-
gatewayId: z.string().uuid(),
|
|
15
|
-
pid: z.number().int().positive(),
|
|
16
|
-
host: z.string().min(1),
|
|
17
|
-
port: z.number().int().min(1).max(65_535),
|
|
18
|
-
startedAt: z.string().datetime(),
|
|
19
|
-
identityKey: z.string().regex(/^[A-Za-z0-9_-]{43}$/).optional(),
|
|
20
|
-
}).strict();
|
|
21
|
-
export function remotePaths(root = process.env.NOWCREW_REMOTE_HOME ?? join(homedir(), ".nowcrew", "remote")) {
|
|
22
|
-
return {
|
|
23
|
-
root,
|
|
24
|
-
config: join(root, "config.json"),
|
|
25
|
-
token: join(root, "token"),
|
|
26
|
-
lock: join(root, "gateway.lock.json"),
|
|
27
|
-
codexSocket: join(root, "codex", "app-server.sock"),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
async function readOptional(path) {
|
|
31
|
-
try {
|
|
32
|
-
return await readFile(path, "utf8");
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
if (error.code === "ENOENT")
|
|
36
|
-
return null;
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async function writeOwnerOnly(path, contents) {
|
|
41
|
-
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
42
|
-
const tmp = `${path}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
43
|
-
const file = await open(tmp, "wx", 0o600);
|
|
44
|
-
try {
|
|
45
|
-
await file.writeFile(contents, "utf8");
|
|
46
|
-
await file.sync();
|
|
47
|
-
}
|
|
48
|
-
finally {
|
|
49
|
-
await file.close();
|
|
50
|
-
}
|
|
51
|
-
await rename(tmp, path);
|
|
52
|
-
}
|
|
53
|
-
export async function loadOrCreateRemoteConfig(overrides = {}) {
|
|
54
|
-
const paths = remotePaths(overrides.root);
|
|
55
|
-
await mkdir(paths.root, { recursive: true, mode: 0o700 });
|
|
56
|
-
const existingConfig = await readOptional(paths.config);
|
|
57
|
-
const parsed = existingConfig === null
|
|
58
|
-
? { version: 1, host: "127.0.0.1", port: 4317, allowedOrigins: [] }
|
|
59
|
-
: RemoteConfigFileSchema.parse(JSON.parse(existingConfig));
|
|
60
|
-
const fileConfig = RemoteConfigFileSchema.parse({
|
|
61
|
-
...parsed,
|
|
62
|
-
...(overrides.host === undefined ? {} : { host: overrides.host }),
|
|
63
|
-
...(overrides.port === undefined ? {} : { port: overrides.port }),
|
|
64
|
-
});
|
|
65
|
-
if (existingConfig === null || fileConfig.host !== parsed.host || fileConfig.port !== parsed.port) {
|
|
66
|
-
await writeOwnerOnly(paths.config, `${JSON.stringify(fileConfig, null, 2)}\n`);
|
|
67
|
-
}
|
|
68
|
-
const existingToken = (await readOptional(paths.token))?.trim();
|
|
69
|
-
const token = existingToken && /^[A-Za-z0-9_-]{43}$/.test(existingToken)
|
|
70
|
-
? existingToken
|
|
71
|
-
: randomBytes(32).toString("base64url");
|
|
72
|
-
if (token !== existingToken)
|
|
73
|
-
await writeOwnerOnly(paths.token, `${token}\n`);
|
|
74
|
-
return { ...fileConfig, token, paths };
|
|
75
|
-
}
|
|
76
|
-
export async function updateRemoteBinding(config, input) {
|
|
77
|
-
const next = RemoteConfigFileSchema.parse({
|
|
78
|
-
version: 1,
|
|
79
|
-
host: input.host,
|
|
80
|
-
port: input.port,
|
|
81
|
-
allowedOrigins: input.allowedOrigins ?? config.allowedOrigins,
|
|
82
|
-
});
|
|
83
|
-
await writeOwnerOnly(config.paths.config, `${JSON.stringify(next, null, 2)}\n`);
|
|
84
|
-
return { ...next, token: config.token, paths: config.paths };
|
|
85
|
-
}
|
|
86
|
-
export async function acquireRemoteOwnerLock(path, value) {
|
|
87
|
-
const parsed = RemoteOwnerLockSchema.parse(value);
|
|
88
|
-
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
89
|
-
const tmp = `${path}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
90
|
-
const file = await open(tmp, "wx", 0o600);
|
|
91
|
-
try {
|
|
92
|
-
await file.writeFile(`${JSON.stringify(parsed, null, 2)}\n`, "utf8");
|
|
93
|
-
await file.sync();
|
|
94
|
-
}
|
|
95
|
-
finally {
|
|
96
|
-
await file.close();
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
await link(tmp, path);
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
if (error.code === "EEXIST")
|
|
104
|
-
return false;
|
|
105
|
-
throw error;
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
await unlink(tmp).catch((error) => {
|
|
109
|
-
if (error.code !== "ENOENT")
|
|
110
|
-
throw error;
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
export async function readRemoteOwnerLock(path) {
|
|
115
|
-
const contents = await readOptional(path);
|
|
116
|
-
return contents === null ? null : RemoteOwnerLockSchema.parse(JSON.parse(contents));
|
|
117
|
-
}
|
|
118
|
-
export async function releaseRemoteOwnerLock(path, gatewayId) {
|
|
119
|
-
const current = await readRemoteOwnerLock(path);
|
|
120
|
-
if (!current || current.gatewayId !== gatewayId)
|
|
121
|
-
return false;
|
|
122
|
-
try {
|
|
123
|
-
await unlink(path);
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
if (error.code === "ENOENT")
|
|
128
|
-
return false;
|
|
129
|
-
throw error;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
// Exported for tests that verify atomic replacement without duplicating filesystem logic.
|
|
133
|
-
export async function writeRemoteConfigForTest(path, contents) {
|
|
134
|
-
await writeOwnerOnly(path, contents);
|
|
135
|
-
}
|