@youdie006/prodex 0.40.17 → 0.40.18
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 +4 -2
- package/SECURITY.md +45 -0
- package/dist/bridge-gitignore.js +47 -0
- package/dist/browser-handoff.js +29 -16
- package/dist/browser-process.js +196 -0
- package/dist/chatgpt-browser.js +51 -63
- package/dist/cli-args.js +8 -2
- package/dist/cli-pro.js +19 -4
- package/dist/cli.js +2 -4
- package/dist/config.js +13 -25
- package/dist/repo.js +9 -2
- package/dist/safe-file.js +57 -13
- package/dist/store-writer.js +20 -5
- package/dist/store.js +19 -26
- package/dist/tui-run.js +1 -1
- package/docs/cli-reference.md +3 -1
- package/docs/platform-verification.md +164 -0
- package/package.json +7 -2
- package/prodex.mjs +11 -0
- package/scripts/npm-command.mjs +71 -0
- package/scripts/release-check.mjs +18 -11
- package/scripts/release-pack.mjs +13 -4
package/dist/cli.js
CHANGED
|
@@ -14,6 +14,7 @@ import { getTokenExpiryStatus, loadLocalConfig, resolveProdexCwd } from "./confi
|
|
|
14
14
|
import { startHttpMcpServer } from "./http-mcp.js";
|
|
15
15
|
import { createMcpToolHandlers } from "./mcp-tools.js";
|
|
16
16
|
import { runMcpServer } from "./mcp.js";
|
|
17
|
+
import { execNpm } from "../scripts/npm-command.mjs";
|
|
17
18
|
import { BridgeStore } from "./store.js";
|
|
18
19
|
import { printHelpIfRequested, assertNoExtraArgs, assertOnlyOptions, formatCliCommand, formatSourceCliOption, isHelpSubcommand, readFlag, resolveCwdFlag, resolveExistingPathFlag, resolveOptionalFileFlag, shellQuote, unknownSubcommandError, unknownTopLevelCommandError } from "./cli-args.js";
|
|
19
20
|
import { listRawResultsForInspection, listTasksForInspection, runReceiptsCommand, runResultsCommand, runSessionsCommand, runTasksCommand } from "./cli-ledger.js";
|
|
@@ -711,7 +712,7 @@ async function readReleasePackageJson(packageJsonPath) {
|
|
|
711
712
|
}
|
|
712
713
|
async function readReleasePackStatus(cwd, packageJson, sourceCli, releaseHintCwd) {
|
|
713
714
|
try {
|
|
714
|
-
const { stdout } = await
|
|
715
|
+
const { stdout } = await execNpm(["pack", "--json", "--dry-run", "--ignore-scripts"], {
|
|
715
716
|
cwd,
|
|
716
717
|
timeout: 120_000,
|
|
717
718
|
maxBuffer: 20 * 1024 * 1024
|
|
@@ -872,9 +873,6 @@ function writeCommandOutput(output, write) {
|
|
|
872
873
|
for (const line of trimmed.split(/\r?\n/))
|
|
873
874
|
write(line);
|
|
874
875
|
}
|
|
875
|
-
function commandForPlatform(command) {
|
|
876
|
-
return process.platform === "win32" && command === "npm" ? "npm.cmd" : command;
|
|
877
|
-
}
|
|
878
876
|
function firstErrorLine(error) {
|
|
879
877
|
const failed = typeof error === "object" && error !== null ? error : {};
|
|
880
878
|
const stderr = firstOutputLine(failed.stderr);
|
package/dist/config.js
CHANGED
|
@@ -5,6 +5,7 @@ import { isIP } from "node:net";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { SCHEMA_VERSION } from "./schema.js";
|
|
8
|
+
import { ensureBridgeGitignore } from "./bridge-gitignore.js";
|
|
8
9
|
import { readVerifiedUtf8File, writeVerifiedUtf8File } from "./safe-file.js";
|
|
9
10
|
const BRIDGE_DIRECTORY_MODE = 0o700;
|
|
10
11
|
const BrowserDefaultsSchema = z.object({
|
|
@@ -329,30 +330,7 @@ async function ensureBridgeLocalFiles(cwd) {
|
|
|
329
330
|
const bridgeDir = path.join(cwd, ".bridge");
|
|
330
331
|
await ensurePrivateBridgeDirectory(cwd);
|
|
331
332
|
const ignorePath = path.join(bridgeDir, ".gitignore");
|
|
332
|
-
|
|
333
|
-
try {
|
|
334
|
-
current = await readVerifiedUtf8File(ignorePath, () => assertBridgeGitignoreTargetSafe(cwd));
|
|
335
|
-
}
|
|
336
|
-
catch (error) {
|
|
337
|
-
if (!isMissingFileError(error))
|
|
338
|
-
throw error;
|
|
339
|
-
}
|
|
340
|
-
const required = [
|
|
341
|
-
"tasks/*.json",
|
|
342
|
-
"results/*.json",
|
|
343
|
-
"sessions/*.json",
|
|
344
|
-
"receipts/*.json",
|
|
345
|
-
"artifacts/*",
|
|
346
|
-
"config.local.json",
|
|
347
|
-
"receipt-key.local",
|
|
348
|
-
"!.gitignore"
|
|
349
|
-
];
|
|
350
|
-
const lines = new Set(current.split(/\r?\n/).filter(Boolean));
|
|
351
|
-
for (const line of required)
|
|
352
|
-
lines.add(line);
|
|
353
|
-
await writeVerifiedUtf8File(ignorePath, `${Array.from(lines).join("\n")}\n`, () => assertBridgeGitignoreTargetSafe(cwd), {
|
|
354
|
-
create: true
|
|
355
|
-
});
|
|
333
|
+
await ensureBridgeGitignore(ignorePath, () => assertBridgeGitignoreTargetSafe(cwd));
|
|
356
334
|
}
|
|
357
335
|
async function ensurePrivateBridgeDirectory(cwd) {
|
|
358
336
|
await mkdir(path.join(cwd, ".bridge"), { recursive: true, mode: BRIDGE_DIRECTORY_MODE });
|
|
@@ -362,7 +340,9 @@ async function chmodPrivateBridgeDirectory(cwd) {
|
|
|
362
340
|
const bridgeDir = path.join(cwd, ".bridge");
|
|
363
341
|
const handle = await openNoFollowDirectory(bridgeDir, ".bridge");
|
|
364
342
|
try {
|
|
365
|
-
|
|
343
|
+
// Windows uses inherited ACLs; POSIX modes do not restrict Windows access.
|
|
344
|
+
if (process.platform !== "win32")
|
|
345
|
+
await handle.chmod(BRIDGE_DIRECTORY_MODE);
|
|
366
346
|
await assertDirectoryHandle(handle, ".bridge");
|
|
367
347
|
}
|
|
368
348
|
finally {
|
|
@@ -421,9 +401,17 @@ async function openNoFollowDirectory(dirPath, label) {
|
|
|
421
401
|
const noFollowFlag = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
|
|
422
402
|
const directoryFlag = typeof constants.O_DIRECTORY === "number" ? constants.O_DIRECTORY : 0;
|
|
423
403
|
try {
|
|
404
|
+
const before = await lstat(dirPath, { bigint: true });
|
|
405
|
+
if (before.isSymbolicLink() || !before.isDirectory()) {
|
|
406
|
+
throw new Error(`${label} must be a real directory and must not be a symlink`);
|
|
407
|
+
}
|
|
424
408
|
const handle = await open(dirPath, constants.O_RDONLY | directoryFlag | noFollowFlag);
|
|
425
409
|
try {
|
|
426
410
|
await assertDirectoryHandle(handle, label);
|
|
411
|
+
const opened = await handle.stat({ bigint: true });
|
|
412
|
+
if (opened.dev !== before.dev || opened.ino !== before.ino) {
|
|
413
|
+
throw new Error(`${label} changed while opening the directory`);
|
|
414
|
+
}
|
|
427
415
|
return handle;
|
|
428
416
|
}
|
|
429
417
|
catch (error) {
|
package/dist/repo.js
CHANGED
|
@@ -10,6 +10,7 @@ const execFileAsync = promisify(execFile);
|
|
|
10
10
|
export function findRipgrep(env = process.env, exists = existsSync) {
|
|
11
11
|
const pathDirs = (env.PATH ?? "").split(path.delimiter).filter(Boolean);
|
|
12
12
|
const home = env.HOME ?? env.USERPROFILE ?? "";
|
|
13
|
+
const executable = process.platform === "win32" ? "rg.exe" : "rg";
|
|
13
14
|
const fallbackDirs = [
|
|
14
15
|
"/usr/bin",
|
|
15
16
|
"/usr/local/bin",
|
|
@@ -20,7 +21,7 @@ export function findRipgrep(env = process.env, exists = existsSync) {
|
|
|
20
21
|
...(home ? [path.join(home, ".cargo", "bin"), path.join(home, ".local", "bin")] : [])
|
|
21
22
|
];
|
|
22
23
|
for (const dir of [...pathDirs, ...fallbackDirs]) {
|
|
23
|
-
const candidate = path.join(dir,
|
|
24
|
+
const candidate = path.join(dir, executable);
|
|
24
25
|
try {
|
|
25
26
|
if (exists(candidate))
|
|
26
27
|
return candidate;
|
|
@@ -47,6 +48,9 @@ export function assertRepoRelativePath(repoPath) {
|
|
|
47
48
|
if (path.isAbsolute(repoPath)) {
|
|
48
49
|
throw new Error("Path must be repo-relative, not absolute");
|
|
49
50
|
}
|
|
51
|
+
if (process.platform === "win32" && repoPath.includes(":")) {
|
|
52
|
+
throw new Error("Path must not use a Windows alternate data stream");
|
|
53
|
+
}
|
|
50
54
|
const normalized = path.posix.normalize(repoPath.replaceAll("\\", "/"));
|
|
51
55
|
if (normalized === "." || normalized.startsWith("../") || normalized === "..") {
|
|
52
56
|
throw new Error("Path must stay inside the repo-relative root");
|
|
@@ -191,11 +195,14 @@ function parseRipgrepJsonMatch(line) {
|
|
|
191
195
|
if (!isRipgrepJsonMatch(event))
|
|
192
196
|
return undefined;
|
|
193
197
|
return {
|
|
194
|
-
path: event.data.path.text
|
|
198
|
+
path: normalizeRipgrepMatchPath(event.data.path.text),
|
|
195
199
|
line: event.data.line_number,
|
|
196
200
|
text: stripOneTrailingLineEnding(event.data.lines.text)
|
|
197
201
|
};
|
|
198
202
|
}
|
|
203
|
+
function normalizeRipgrepMatchPath(matchPath) {
|
|
204
|
+
return matchPath.split(path.sep).join("/").replace(/^\.\//, "");
|
|
205
|
+
}
|
|
199
206
|
function isRipgrepJsonMatch(value) {
|
|
200
207
|
if (!isRecord(value) || value.type !== "match" || !isRecord(value.data))
|
|
201
208
|
return false;
|
package/dist/safe-file.js
CHANGED
|
@@ -74,6 +74,7 @@ export async function readVerifiedUtf8File(filePath, validate, options = {}) {
|
|
|
74
74
|
const content = await readHandleUtf8(handle, filePath, options.maxBytes);
|
|
75
75
|
if (options.mode !== undefined) {
|
|
76
76
|
await testHooks.beforeChmod?.(filePath, "read");
|
|
77
|
+
await assertSafeOpenFile(handle, filePath, "read");
|
|
77
78
|
await handle.chmod(options.mode);
|
|
78
79
|
}
|
|
79
80
|
await validate();
|
|
@@ -108,6 +109,7 @@ export async function writeVerifiedUtf8File(filePath, content, validate, options
|
|
|
108
109
|
await testHooks.afterWrite?.(filePath, "write");
|
|
109
110
|
if (options.mode !== undefined) {
|
|
110
111
|
await testHooks.beforeChmod?.(filePath, "write");
|
|
112
|
+
await assertSafeOpenFile(handle, filePath, "write");
|
|
111
113
|
await handle.chmod(options.mode);
|
|
112
114
|
}
|
|
113
115
|
await validate();
|
|
@@ -131,16 +133,17 @@ export async function replaceVerifiedUtf8File(filePath, content, validate, verif
|
|
|
131
133
|
const latestContent = await readHandleUtf8(handle, filePath, options.maxBytes);
|
|
132
134
|
await verifyCurrentContent(latestContent);
|
|
133
135
|
await testHooks.beforeWrite?.(filePath, "write");
|
|
134
|
-
await replaceByVerifiedTempFile(filePath, content, validate, options, {
|
|
135
|
-
beforeOpenAlreadyRan: true,
|
|
136
|
-
beforeWriteAlreadyRan: true,
|
|
137
|
-
parentSnapshot,
|
|
138
|
-
skipExistingTargetCheck: true
|
|
139
|
-
});
|
|
140
136
|
}
|
|
141
137
|
finally {
|
|
142
138
|
await handle.close();
|
|
143
139
|
}
|
|
140
|
+
// Windows cannot replace some files while their verification handle is open.
|
|
141
|
+
await replaceByVerifiedTempFile(filePath, content, validate, options, {
|
|
142
|
+
beforeOpenAlreadyRan: true,
|
|
143
|
+
beforeWriteAlreadyRan: true,
|
|
144
|
+
parentSnapshot,
|
|
145
|
+
skipExistingTargetCheck: true
|
|
146
|
+
});
|
|
144
147
|
}
|
|
145
148
|
async function replaceByVerifiedTempFile(filePath, content, validate, options = {}, hookState = {}) {
|
|
146
149
|
await validate();
|
|
@@ -159,6 +162,7 @@ async function replaceByVerifiedTempFile(filePath, content, validate, options =
|
|
|
159
162
|
await writeHandleUtf8(tmpHandle, tmpPath, content);
|
|
160
163
|
if (options.mode !== undefined) {
|
|
161
164
|
await testHooks.beforeChmod?.(filePath, "write");
|
|
165
|
+
await assertSafeOpenFile(tmpHandle, tmpPath, "write");
|
|
162
166
|
await tmpHandle.chmod(options.mode);
|
|
163
167
|
}
|
|
164
168
|
}
|
|
@@ -182,6 +186,7 @@ async function replaceByVerifiedTempFile(filePath, content, validate, options =
|
|
|
182
186
|
}
|
|
183
187
|
}
|
|
184
188
|
async function readHandleUtf8(handle, filePath, maxBytes) {
|
|
189
|
+
await assertOpenFileMatchesPath(handle, filePath, "read");
|
|
185
190
|
const stat = await handle.stat();
|
|
186
191
|
if (!stat.isFile()) {
|
|
187
192
|
throw new Error("Target path is not a regular file");
|
|
@@ -205,7 +210,7 @@ async function readHandleUtf8(handle, filePath, maxBytes) {
|
|
|
205
210
|
}
|
|
206
211
|
async function writeHandleUtf8(handle, filePath, content) {
|
|
207
212
|
const replacement = Buffer.from(content, "utf8");
|
|
208
|
-
await assertSafeOpenFile(handle, filePath);
|
|
213
|
+
await assertSafeOpenFile(handle, filePath, "write");
|
|
209
214
|
await handle.truncate(0);
|
|
210
215
|
let offset = 0;
|
|
211
216
|
while (offset < replacement.length) {
|
|
@@ -216,11 +221,36 @@ async function writeHandleUtf8(handle, filePath, content) {
|
|
|
216
221
|
offset += bytesWritten;
|
|
217
222
|
}
|
|
218
223
|
}
|
|
219
|
-
async function
|
|
220
|
-
const
|
|
221
|
-
if (!
|
|
224
|
+
async function assertOpenFileMatchesPath(handle, filePath, operation) {
|
|
225
|
+
const handleStat = await handle.stat({ bigint: true });
|
|
226
|
+
if (!handleStat.isFile()) {
|
|
227
|
+
throw new Error("Target path is not a regular file");
|
|
228
|
+
}
|
|
229
|
+
let pathStat;
|
|
230
|
+
try {
|
|
231
|
+
pathStat = await lstat(filePath, { bigint: true });
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
if (isMissingFileError(error)) {
|
|
235
|
+
throw new Error(`Target path changed during ${operation} file operation`);
|
|
236
|
+
}
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
if (pathStat.isSymbolicLink()) {
|
|
240
|
+
throw new Error(`Target path is a symlink or changed during ${operation} file operation`);
|
|
241
|
+
}
|
|
242
|
+
if (!pathStat.isFile()) {
|
|
222
243
|
throw new Error("Target path is not a regular file");
|
|
223
244
|
}
|
|
245
|
+
const handleIdentity = { dev: BigInt(handleStat.dev), ino: BigInt(handleStat.ino) };
|
|
246
|
+
const pathIdentity = { dev: BigInt(pathStat.dev), ino: BigInt(pathStat.ino) };
|
|
247
|
+
if (!sameFileIdentity(handleIdentity, pathIdentity)) {
|
|
248
|
+
throw new Error(`Target path changed during ${operation} file operation`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async function assertSafeOpenFile(handle, filePath, operation) {
|
|
252
|
+
await assertOpenFileMatchesPath(handle, filePath, operation);
|
|
253
|
+
const stat = await handle.stat();
|
|
224
254
|
assertNotHardLinked(filePath, stat.nlink);
|
|
225
255
|
}
|
|
226
256
|
function assertNotHardLinked(filePath, linkCount) {
|
|
@@ -271,8 +301,10 @@ async function captureParentSnapshot(filePath) {
|
|
|
271
301
|
};
|
|
272
302
|
}
|
|
273
303
|
async function openStableNoFollow(filePath, flags, operation, parentSnapshot, mode) {
|
|
274
|
-
if (!parentSnapshot)
|
|
275
|
-
|
|
304
|
+
if (!parentSnapshot) {
|
|
305
|
+
const handle = await openNoFollow(filePath, flags, operation, mode);
|
|
306
|
+
return verifyOpenedHandle(handle, filePath, operation);
|
|
307
|
+
}
|
|
276
308
|
if (process.platform !== "linux") {
|
|
277
309
|
const actualParentBeforeOpen = await realpath(parentSnapshot.path);
|
|
278
310
|
if (actualParentBeforeOpen !== parentSnapshot.realPath) {
|
|
@@ -284,6 +316,7 @@ async function openStableNoFollow(filePath, flags, operation, parentSnapshot, mo
|
|
|
284
316
|
if (actualParentAfterOpen !== parentSnapshot.realPath) {
|
|
285
317
|
throw new Error(`Parent directory changed during ${operation} file operation`);
|
|
286
318
|
}
|
|
319
|
+
await assertOpenFileMatchesPath(handle, filePath, operation);
|
|
287
320
|
return handle;
|
|
288
321
|
}
|
|
289
322
|
catch (error) {
|
|
@@ -298,12 +331,23 @@ async function openStableNoFollow(filePath, flags, operation, parentSnapshot, mo
|
|
|
298
331
|
if (actualParent !== parentSnapshot.realPath) {
|
|
299
332
|
throw new Error(`Parent directory changed during ${operation} file operation`);
|
|
300
333
|
}
|
|
301
|
-
|
|
334
|
+
const handle = await openNoFollow(path.join(parentFdPath, path.basename(filePath)), flags, operation, mode);
|
|
335
|
+
return await verifyOpenedHandle(handle, filePath, operation);
|
|
302
336
|
}
|
|
303
337
|
finally {
|
|
304
338
|
await parentHandle.close();
|
|
305
339
|
}
|
|
306
340
|
}
|
|
341
|
+
async function verifyOpenedHandle(handle, filePath, operation) {
|
|
342
|
+
try {
|
|
343
|
+
await assertOpenFileMatchesPath(handle, filePath, operation);
|
|
344
|
+
return handle;
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
await handle.close().catch(() => undefined);
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
307
351
|
async function openNoFollowDirectory(dirPath, operation) {
|
|
308
352
|
const noFollowFlag = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
|
|
309
353
|
const directoryFlag = typeof constants.O_DIRECTORY === "number" ? constants.O_DIRECTORY : 0;
|
package/dist/store-writer.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
//
|
|
17
17
|
// Everything after the anchoring uses the same helpers the in-process path uses,
|
|
18
18
|
// on relative names.
|
|
19
|
-
import { closeSync, constants, fstatSync, openSync } from "node:fs";
|
|
19
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync } from "node:fs";
|
|
20
20
|
import { pathToFileURL } from "node:url";
|
|
21
21
|
import { link, lstat, readdir, rename, rm } from "node:fs/promises";
|
|
22
22
|
import { randomUUID } from "node:crypto";
|
|
@@ -34,7 +34,22 @@ function sameIdentity(a, b) {
|
|
|
34
34
|
function openDirectoryHere(name) {
|
|
35
35
|
const directoryFlag = typeof constants.O_DIRECTORY === "number" ? constants.O_DIRECTORY : 0;
|
|
36
36
|
const noFollowFlag = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
|
|
37
|
-
|
|
37
|
+
const before = lstatSync(name, { bigint: true });
|
|
38
|
+
if (before.isSymbolicLink() || !before.isDirectory()) {
|
|
39
|
+
throw new Error("Anchored writer expected a real directory, not a symlink");
|
|
40
|
+
}
|
|
41
|
+
const fd = openSync(name, constants.O_RDONLY | directoryFlag | noFollowFlag);
|
|
42
|
+
try {
|
|
43
|
+
const opened = fstatSync(fd, { bigint: true });
|
|
44
|
+
if (opened.dev !== before.dev || opened.ino !== before.ino || !opened.isDirectory()) {
|
|
45
|
+
throw new Error("Anchored writer directory changed while opening");
|
|
46
|
+
}
|
|
47
|
+
return fd;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
closeSync(fd);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
38
53
|
}
|
|
39
54
|
function currentDirectoryIdentity() {
|
|
40
55
|
const fd = openDirectoryHere(".");
|
|
@@ -55,10 +70,10 @@ export function anchorCurrentDirectory(anchor, segments) {
|
|
|
55
70
|
throw new Error("Anchored writer was not started in the directory the caller validated");
|
|
56
71
|
}
|
|
57
72
|
for (const segment of segments) {
|
|
58
|
-
if (segment.length === 0 || segment === "." || segment === ".." || segment.includes("
|
|
73
|
+
if (segment.length === 0 || segment === "." || segment === ".." || /[\\/]/.test(segment) || (process.platform === "win32" && segment.includes(":"))) {
|
|
59
74
|
throw new Error(`Anchored writer refuses to descend into ${JSON.stringify(segment)}`);
|
|
60
75
|
}
|
|
61
|
-
//
|
|
76
|
+
// The no-follow/identity checks reject symlinks and Windows junctions, and
|
|
62
77
|
// the identity check after chdir proves we landed on that same directory
|
|
63
78
|
// and not on something swapped in between the two calls.
|
|
64
79
|
const fd = openDirectoryHere(segment);
|
|
@@ -100,7 +115,7 @@ export async function runAnchoredJob(job) {
|
|
|
100
115
|
}
|
|
101
116
|
};
|
|
102
117
|
const { fileName } = job;
|
|
103
|
-
if (fileName.length === 0 || fileName.includes("
|
|
118
|
+
if (fileName.length === 0 || /[\\/]/.test(fileName) || (process.platform === "win32" && fileName.includes(":")) || fileName === "." || fileName === "..") {
|
|
104
119
|
throw new Error(`Anchored writer refuses the file name ${JSON.stringify(fileName)}`);
|
|
105
120
|
}
|
|
106
121
|
if (job.op === "deleteIfPresent") {
|
package/dist/store.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { registerBridgeRoot } from "./registry.js";
|
|
4
|
+
import { ensureBridgeGitignore } from "./bridge-gitignore.js";
|
|
4
5
|
import { closeSync, constants, existsSync, openSync, readdirSync } from "node:fs";
|
|
5
6
|
import { tmpdir } from "node:os";
|
|
6
7
|
import { link, lstat, mkdir, open, readdir, realpath, rename, rm, stat } from "node:fs/promises";
|
|
@@ -841,31 +842,7 @@ export class BridgeStore {
|
|
|
841
842
|
}
|
|
842
843
|
async ensureBridgeGitignore() {
|
|
843
844
|
const ignorePath = path.join(this.bridgeDir, ".gitignore");
|
|
844
|
-
|
|
845
|
-
try {
|
|
846
|
-
current = await readVerifiedUtf8File(ignorePath, () => this.assertBridgeGitignoreTargetSafe());
|
|
847
|
-
}
|
|
848
|
-
catch (error) {
|
|
849
|
-
if (!isErrorCode(error, "ENOENT"))
|
|
850
|
-
throw error;
|
|
851
|
-
}
|
|
852
|
-
const required = [
|
|
853
|
-
"tasks/*.json",
|
|
854
|
-
"results/*.json",
|
|
855
|
-
"sessions/*.json",
|
|
856
|
-
"receipts/*.json",
|
|
857
|
-
"artifacts/*",
|
|
858
|
-
"config.local.json",
|
|
859
|
-
"receipt-key.local",
|
|
860
|
-
"last-browser-send",
|
|
861
|
-
"!.gitignore"
|
|
862
|
-
];
|
|
863
|
-
const lines = new Set(current.split(/\r?\n/).filter(Boolean));
|
|
864
|
-
for (const line of required)
|
|
865
|
-
lines.add(line);
|
|
866
|
-
await writeVerifiedUtf8File(ignorePath, `${Array.from(lines).join("\n")}\n`, () => this.assertBridgeGitignoreTargetSafe(), {
|
|
867
|
-
create: true
|
|
868
|
-
});
|
|
845
|
+
await ensureBridgeGitignore(ignorePath, () => this.assertBridgeGitignoreTargetSafe());
|
|
869
846
|
}
|
|
870
847
|
async hasReadyBridgeStorageReadOnly() {
|
|
871
848
|
try {
|
|
@@ -1025,6 +1002,12 @@ export class BridgeStore {
|
|
|
1025
1002
|
throw new Error(`Bridge record path must stay under .bridge/${kind}`);
|
|
1026
1003
|
}
|
|
1027
1004
|
await this.assertStorageDirIsRealDirectory(kind);
|
|
1005
|
+
if (job.op === "cleanupTempHardLinks") {
|
|
1006
|
+
await storeTestHooks.beforeRecordTempCleanup?.(kind, filePath);
|
|
1007
|
+
}
|
|
1008
|
+
else if (job.op === "writeByRename" || job.op === "linkIfAbsent") {
|
|
1009
|
+
await storeTestHooks.beforeRecordRename?.(kind, filePath);
|
|
1010
|
+
}
|
|
1028
1011
|
const outcome = await runAnchoredWrite(this.bridgeDir, [kind], {
|
|
1029
1012
|
...job,
|
|
1030
1013
|
fileName: path.basename(filePath),
|
|
@@ -1549,9 +1532,17 @@ async function openNoFollowDirectory(dirPath, label) {
|
|
|
1549
1532
|
const noFollowFlag = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
|
|
1550
1533
|
const directoryFlag = typeof constants.O_DIRECTORY === "number" ? constants.O_DIRECTORY : 0;
|
|
1551
1534
|
try {
|
|
1535
|
+
const before = await lstat(dirPath, { bigint: true });
|
|
1536
|
+
if (before.isSymbolicLink() || !before.isDirectory()) {
|
|
1537
|
+
throw new Error(`${label} must be a real directory and must not be a symlink`);
|
|
1538
|
+
}
|
|
1552
1539
|
const handle = await open(dirPath, constants.O_RDONLY | directoryFlag | noFollowFlag);
|
|
1553
1540
|
try {
|
|
1554
1541
|
await assertOpenDirectoryHandle(handle);
|
|
1542
|
+
const opened = await handle.stat({ bigint: true });
|
|
1543
|
+
if (opened.dev !== before.dev || opened.ino !== before.ino) {
|
|
1544
|
+
throw new Error(`${label} changed while opening the directory`);
|
|
1545
|
+
}
|
|
1555
1546
|
return handle;
|
|
1556
1547
|
}
|
|
1557
1548
|
catch (error) {
|
|
@@ -1574,7 +1565,9 @@ async function ensurePrivateDirectory(dirPath, label) {
|
|
|
1574
1565
|
async function chmodPrivateDirectory(dirPath, label) {
|
|
1575
1566
|
const handle = await openNoFollowDirectory(dirPath, label);
|
|
1576
1567
|
try {
|
|
1577
|
-
|
|
1568
|
+
// Windows uses inherited ACLs; fchmod on a read-only directory is EPERM.
|
|
1569
|
+
if (process.platform !== "win32")
|
|
1570
|
+
await handle.chmod(BRIDGE_DIRECTORY_MODE);
|
|
1578
1571
|
await assertOpenDirectoryHandle(handle);
|
|
1579
1572
|
}
|
|
1580
1573
|
finally {
|
package/dist/tui-run.js
CHANGED
package/docs/cli-reference.md
CHANGED
|
@@ -33,7 +33,9 @@ Not implemented:
|
|
|
33
33
|
|
|
34
34
|
This section connects coding agents (Claude, Codex, ChatGPT Projects) to the bridge over MCP. It is not required for the standalone terminal flow above — if you only want Pro answers in your terminal, the [Quickstart](#quickstart-a-pro-second-opinion-from-your-terminal) is complete on its own.
|
|
35
35
|
|
|
36
|
-
Requires Node.js 20 or newer, `git`, and `ripgrep` (`rg`) on PATH. The optional
|
|
36
|
+
Requires Node.js 20 or newer, `git`, and `ripgrep` (`rg`) on PATH. The optional browser adapter probes PATH binaries (`google-chrome`, `chromium`, `chromium-browser`, `microsoft-edge`, `brave-browser`), native macOS app bundles, and native Windows Program Files/LOCALAPPDATA installs. Set `PRODEX_CHROME` for another executable. WSL uses Linux browser paths, not automatic Windows-host browser discovery. Do not share one profile between native Windows Chrome and Linux Chrome. See [platform verification](platform-verification.md) and [local storage permissions](../SECURITY.md#local-storage-permissions).
|
|
37
|
+
|
|
38
|
+
Native Windows command examples use PowerShell quoting, including doubled apostrophes inside single-quoted arguments. Use PowerShell 7 for compound examples containing `&&`; these examples are not `cmd.exe` commands. Internal CLI/MCP child processes receive literal argument arrays without a shell.
|
|
37
39
|
|
|
38
40
|
Install from npm — **note the scope**. The unscoped `prodex` on npm is an unrelated third-party package; do **not** install it. Use the scoped name:
|
|
39
41
|
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Platform Verification
|
|
2
|
+
|
|
3
|
+
Open source does not mean every operating system, architecture, filesystem, or
|
|
4
|
+
browser version has been tested. This record distinguishes configured CI jobs,
|
|
5
|
+
completed checks, installed versions, and live account-dependent behavior.
|
|
6
|
+
|
|
7
|
+
## 0.40.18 verification
|
|
8
|
+
|
|
9
|
+
Branch: `fix/cross-platform-verification`.
|
|
10
|
+
Tracking PR: <https://github.com/youdie006/prodex/pull/6>.
|
|
11
|
+
Verified runtime commit: `ba9551be75586b7ab603964a6cbf117483578766`.
|
|
12
|
+
Completed six-job CI: <https://github.com/youdie006/prodex/actions/runs/34980308069>.
|
|
13
|
+
Final release/publication and machine installation records are kept in the
|
|
14
|
+
version-specific GitHub Release; this source verification is not an installation
|
|
15
|
+
or an existing-client reconnection claim.
|
|
16
|
+
|
|
17
|
+
| Environment | Completed result at verified runtime commit | Scope |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| Ubuntu 24.04 x64, Node 20/22/24 | PASS | Each job: 1,614 passed, 0 failed, 3 platform exclusions; full release verification and headless smoke |
|
|
20
|
+
| macOS 15 ARM, Node 22 | PASS | 1,613 passed, 0 failed, 4 platform exclusions; full release verification and headless smoke |
|
|
21
|
+
| macOS 15 Intel, Node 22 | PASS | 1,613 passed, 0 failed, 4 platform exclusions; full release verification and headless smoke |
|
|
22
|
+
| Windows Server 2025 x64, Node 22 | PASS | 1,615 passed, 0 failed, 4 platform exclusions; metadata, installed-package verification and headless smoke |
|
|
23
|
+
| Windows 11 x64, Node 22.22.0 | Partial native verification | Actual installed command and fresh MCP passed; 42 CLI/product checks and 7 service-error checks passed. Local full security fixtures require file-symlink privileges and are not claimed as passed |
|
|
24
|
+
| WSL Linux x64, Node 22.22.0 | PASS | Full release verification: 1,614 passed, 0 failed, 3 platform exclusions; earlier real headless browser smoke also passed |
|
|
25
|
+
| Physical M3 macOS ARM, Node 22.22.3 | PASS | Full release verification: 1,613 passed, 0 failed, 4 platform exclusions; earlier real headless browser smoke also passed |
|
|
26
|
+
|
|
27
|
+
## Earlier attempts
|
|
28
|
+
|
|
29
|
+
Initial matrix commit: `37b1684795271f69afdca492562d99aa9c203e6d`.
|
|
30
|
+
CI run: <https://github.com/youdie006/prodex/actions/runs/34964947086>.
|
|
31
|
+
Integrated compatibility commit: `8569391d525e15e16e67665dbc19e04da53ee042`.
|
|
32
|
+
Integrated CI run: <https://github.com/youdie006/prodex/actions/runs/34970055803>.
|
|
33
|
+
Candidate commit: `33646bd4cdffca376f332f103f3c5a00932cf767`.
|
|
34
|
+
Candidate CI run: <https://github.com/youdie006/prodex/actions/runs/34974010179>.
|
|
35
|
+
Follow-up commit: `afec42d3e7f9f4e82601db6fe553dd742664f54d`.
|
|
36
|
+
Follow-up CI run: <https://github.com/youdie006/prodex/actions/runs/34976162000>.
|
|
37
|
+
|
|
38
|
+
The Windows initialization and junction regressions failed before correction and
|
|
39
|
+
passed afterward. Additional native checks reproduced file replacement and
|
|
40
|
+
concurrent initialization failures; their six focused regressions now pass.
|
|
41
|
+
The additional concurrent gitignore replacement regression passed on native
|
|
42
|
+
Windows after both initializers adopted the same verified, idempotent write path.
|
|
43
|
+
The later 48-test Windows run also passed the original concurrent follow-up
|
|
44
|
+
reservation test, npm credential-isolated dry runs, and anchored writer checks.
|
|
45
|
+
M3's first integrated command incorrectly exported `PRODEX_NO_AUTO_LOGIN=1`,
|
|
46
|
+
which disabled five mocked recovery tests. The complete release-verification
|
|
47
|
+
command passed after removing that conflicting harness override. No account
|
|
48
|
+
browser or login profile was used by those mocked tests.
|
|
49
|
+
The initial Windows suite also lacks file-symlink creation privileges on this
|
|
50
|
+
machine. This is recorded separately from product failures; no security test is
|
|
51
|
+
declared passed by ignoring an `EPERM` error. Directory-junction checks can run
|
|
52
|
+
without granting administrator privileges or changing Windows Developer Mode.
|
|
53
|
+
|
|
54
|
+
Candidate 0.40.18 uses the unique root bin `prodex.mjs`: native npm produced
|
|
55
|
+
archive modes 0755 for that bin and 0644 for `dist/cli.js` and `LICENSE`.
|
|
56
|
+
The native metadata check and independent tar-header inspection passed. An
|
|
57
|
+
initial root name `cli.js` was rejected because npm also marked the same-named
|
|
58
|
+
nested compiled file executable. Strict release checks were not relaxed.
|
|
59
|
+
WSL's installed-package smoke passed for the corrected 0.40.18 candidate.
|
|
60
|
+
At that point, final candidate CI and installation checks were still pending.
|
|
61
|
+
Native Windows focused reruns passed the 11 CLI regressions, two browser-send
|
|
62
|
+
and profile cases, and all 21 release-pack tests. The candidate package smoke
|
|
63
|
+
passed its formerly failing archive-mode check, then stopped at a real file
|
|
64
|
+
symlink creation `EPERM`; that run is partial, not a package-smoke pass.
|
|
65
|
+
The three link-swap regressions now assert their fixture was actually installed,
|
|
66
|
+
so an unsupported symlink operation cannot masquerade as a rejected attack.
|
|
67
|
+
|
|
68
|
+
One local staging attempt began before its source archive finished writing and
|
|
69
|
+
failed with a truncated TypeScript file. That invalid snapshot was discarded;
|
|
70
|
+
the complete archive was extracted and source hashes checked before rerunning.
|
|
71
|
+
This was a verification setup failure, not accepted product evidence.
|
|
72
|
+
|
|
73
|
+
The candidate Windows CI failure was reproduced locally by inheriting uppercase
|
|
74
|
+
`NPM_EXECPATH`. It silently displaced explicit lowercase overrides, causing real
|
|
75
|
+
npm to run instead of the intended fixture. After normalizing environment names
|
|
76
|
+
before subprocess creation, the native npm/release suites passed 54 tests with
|
|
77
|
+
one POSIX-only exclusion; their two file-symlink cases still failed with `EPERM`.
|
|
78
|
+
The matching WSL checks passed 91 tests with one Windows-only exclusion.
|
|
79
|
+
Follow-up changes also canonicalize Windows temporary paths, retain private-mode
|
|
80
|
+
assertions only where POSIX modes apply, bound Windows file concurrency to four,
|
|
81
|
+
and give the four-consult approval-renewal test a separate 60-second deadline.
|
|
82
|
+
Those corrections required the subsequent complete matrix before publication.
|
|
83
|
+
|
|
84
|
+
Follow-up commit `afec42d3e7f9f4e82601db6fe553dd742664f54d` was tested in
|
|
85
|
+
<https://github.com/youdie006/prodex/actions/runs/34976162000>. Ubuntu Node
|
|
86
|
+
20/22/24 and macOS ARM passed. Windows passed 1,597 tests with 8 failures and
|
|
87
|
+
4 platform exclusions: every failure was an unhandled process-inspection error
|
|
88
|
+
in product diagnostics. The strict Windows identity parser correctly refused
|
|
89
|
+
incomplete process records, but diagnostics incorrectly aborted the rest of the
|
|
90
|
+
report. The new regression reproduced that crash before correction. The fix
|
|
91
|
+
reports an unknown-identity blocker without login/reset guidance, keeps shutdown
|
|
92
|
+
ownership checks strict, and isolates refused-connection fixtures from the host's
|
|
93
|
+
real process table. Focused checks passed on native Windows (42 tests) and WSL
|
|
94
|
+
(49 tests); typecheck and the npm-helper declaration type probe also passed.
|
|
95
|
+
macOS Intel passed 1,600 tests with 4 exclusions and three 30-second timeouts:
|
|
96
|
+
the paired project-warning cases, paired terminal-state cases, and eight-task
|
|
97
|
+
concurrent creation. The independent cases are now separate tests, and the
|
|
98
|
+
concurrent case retains all eight tasks with a dedicated 60-second deadline.
|
|
99
|
+
All five affected cases passed on WSL after this test-only correction. The
|
|
100
|
+
subsequent complete matrix passed; no global or production timeout was raised.
|
|
101
|
+
The two affected storage/send files also passed all 178 tests on physical M3.
|
|
102
|
+
|
|
103
|
+
The user subsequently reported a rendered Cloudflare 502 page. Seven focused
|
|
104
|
+
regressions verify service-error classification, exclusion of ordinary chat
|
|
105
|
+
content, genuine authentication/protection precedence, and no automatic resend
|
|
106
|
+
after submission on both WSL and native Windows. The full affected browser,
|
|
107
|
+
process and product-check files passed 173 tests on WSL; typecheck passed.
|
|
108
|
+
The page error itself is upstream; these
|
|
109
|
+
simulated checks do not establish restored ChatGPT availability or a new live
|
|
110
|
+
Pro answer, and no visible login window or account profile reset was attempted.
|
|
111
|
+
|
|
112
|
+
The same `afec42d` snapshot passed full `CI=1 npm run release:verify` on WSL
|
|
113
|
+
(1,604 tests, 3 platform exclusions) and physical M3 (1,603 tests, 4 exclusions),
|
|
114
|
+
including installed-package checks. Native Windows installed the candidate into
|
|
115
|
+
a temporary consumer path containing spaces; its actual `prodex.cmd` launched a
|
|
116
|
+
fresh non-tmux MCP, reported 0.40.18 and 20 tools, and read the intended explicit
|
|
117
|
+
working-directory fixture. The transport exited and left no matching child
|
|
118
|
+
process. These are isolated candidate installs, not global deployment or public
|
|
119
|
+
publication. Existing account browsers and the attached MCP were not restarted.
|
|
120
|
+
|
|
121
|
+
## What each check proves
|
|
122
|
+
|
|
123
|
+
- Unit/integration tests: local ledger, routing, path policy, and simulated UI.
|
|
124
|
+
- Package smoke: installed CLI and MCP transports against disposable local data.
|
|
125
|
+
- Browser launch smoke: a fresh headless profile with `about:blank`, CDP readiness,
|
|
126
|
+
script evaluation, owned-process shutdown, and cleanup. No ChatGPT login.
|
|
127
|
+
- Live Pro verification: a separate, manually triggered account test with request
|
|
128
|
+
identity, model evidence, and saved result validation. None of the checks above
|
|
129
|
+
substitutes for this test.
|
|
130
|
+
|
|
131
|
+
## Limits and prerequisites
|
|
132
|
+
|
|
133
|
+
- Node 20+, Git, ripgrep, and a supported Chromium-family browser are prerequisites.
|
|
134
|
+
- Virtual display requires Linux/WSL, Xvfb and xauth. Native macOS and Windows do
|
|
135
|
+
not support this mode; they must report that limitation without opening a window.
|
|
136
|
+
- WSL uses a Linux browser/profile. Native Windows browser discovery is not WSL
|
|
137
|
+
cross-host browser support.
|
|
138
|
+
- Native Windows storage inherits Windows ACLs. See [SECURITY.md](../SECURITY.md#local-storage-permissions).
|
|
139
|
+
- Generated native Windows commands target PowerShell, not `cmd.exe`; compound
|
|
140
|
+
examples with `&&` require PowerShell 7. Internal subprocesses use literal argv.
|
|
141
|
+
- Authentication, CAPTCHA, Cloudflare, permissions, and usage limits remain
|
|
142
|
+
explicit blockers. No automatic visible fallback or protection bypass is tested.
|
|
143
|
+
- ARM Windows, Linux ARM, BSD, containers without browser dependencies, and every
|
|
144
|
+
historical OS/browser version are not covered by this matrix.
|
|
145
|
+
|
|
146
|
+
## Installation and running processes
|
|
147
|
+
|
|
148
|
+
At the start of this work WSL and M3 had CLI 0.40.17 installed. The MCP attached to
|
|
149
|
+
the existing Codex client still had 0.40.16 loaded. Updating a package on disk does
|
|
150
|
+
not reconnect that MCP or change an already-running browser's mode. No client
|
|
151
|
+
restart has been performed in this verification task.
|
|
152
|
+
|
|
153
|
+
The previously verified WSL no-desktop-window session uses ordinary headed Chrome
|
|
154
|
+
on a private virtual display. It is not pure headless Chrome. M3's prior pure
|
|
155
|
+
headless ChatGPT check stopped at Cloudflare. Neither installing this branch nor
|
|
156
|
+
passing a no-account browser launch test removes that account-dependent blocker.
|
|
157
|
+
|
|
158
|
+
After the reported 502, bounded read-only probes on 2026-09-15 at approximately
|
|
159
|
+
14:38 UTC used the tested candidate adapter against the existing dedicated
|
|
160
|
+
browsers. WSL was reachable with saved-login signals and a composer, with no
|
|
161
|
+
blocker. M3 was reachable but returned `cloudflare_check`, not a 502. Neither
|
|
162
|
+
probe opened a browser, changed profiles, reloaded a page, logged in, or sent a
|
|
163
|
+
prompt. WSL readiness does not prove the upstream error's cause or a new Pro
|
|
164
|
+
answer; M3 authenticated pure-headless access remains blocked.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youdie006/prodex",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.18",
|
|
4
4
|
"description": "Local receipt bus for coordinating Codex execution with ChatGPT Pro/Projects consultation.",
|
|
5
5
|
"author": "youdie006",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,18 +26,22 @@
|
|
|
26
26
|
],
|
|
27
27
|
"type": "module",
|
|
28
28
|
"bin": {
|
|
29
|
-
"prodex": "
|
|
29
|
+
"prodex": "prodex.mjs"
|
|
30
30
|
},
|
|
31
31
|
"exports": {},
|
|
32
32
|
"files": [
|
|
33
|
+
"prodex.mjs",
|
|
33
34
|
"dist",
|
|
34
35
|
"LICENSE",
|
|
35
36
|
"README.md",
|
|
37
|
+
"SECURITY.md",
|
|
36
38
|
"docs/claude.md",
|
|
37
39
|
"docs/clients.md",
|
|
38
40
|
"docs/http-mcp.md",
|
|
39
41
|
"docs/releasing.md",
|
|
40
42
|
"docs/cli-reference.md",
|
|
43
|
+
"docs/platform-verification.md",
|
|
44
|
+
"scripts/npm-command.mjs",
|
|
41
45
|
"scripts/release-check.mjs",
|
|
42
46
|
"scripts/release-pack.mjs"
|
|
43
47
|
],
|
|
@@ -49,6 +53,7 @@
|
|
|
49
53
|
"release:pack": "node scripts/release-pack.mjs",
|
|
50
54
|
"release:verify": "node scripts/release-check.mjs --verification-only",
|
|
51
55
|
"smoke:package": "node scripts/package-smoke.mjs",
|
|
56
|
+
"smoke:browser": "node scripts/browser-launch-smoke.mjs",
|
|
52
57
|
"test": "vitest run",
|
|
53
58
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
54
59
|
"prepack": "npm run build",
|