@btatum5/codex-bridge 0.1.0 → 1.3.3
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 +473 -23
- package/bin/codex-bridge.js +136 -100
- package/bin/phodex.js +8 -0
- package/bin/remodex.js +8 -0
- package/package.json +38 -24
- package/src/bridge.js +622 -0
- package/src/codex-desktop-refresher.js +776 -0
- package/src/codex-transport.js +238 -0
- package/src/daemon-state.js +170 -0
- package/src/desktop-handler.js +407 -0
- package/src/git-handler.js +1267 -0
- package/src/index.js +35 -0
- package/src/macos-launch-agent.js +457 -0
- package/src/notifications-handler.js +95 -0
- package/src/push-notification-completion-dedupe.js +147 -0
- package/src/push-notification-service-client.js +151 -0
- package/src/push-notification-tracker.js +688 -0
- package/src/qr.js +19 -0
- package/src/rollout-live-mirror.js +730 -0
- package/src/rollout-watch.js +853 -0
- package/src/scripts/codex-handoff.applescript +100 -0
- package/src/scripts/codex-refresh.applescript +51 -0
- package/src/secure-device-state.js +430 -0
- package/src/secure-transport.js +738 -0
- package/src/session-state.js +62 -0
- package/src/thread-context-handler.js +80 -0
- package/src/workspace-handler.js +464 -0
- package/server.mjs +0 -290
package/bin/codex-bridge.js
CHANGED
|
@@ -1,105 +1,141 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
process.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// FILE: codex-bridge.js
|
|
3
|
+
// Purpose: CLI surface for foreground bridge runs, pairing reset, thread resume, and macOS service control.
|
|
4
|
+
// Layer: CLI binary
|
|
5
|
+
// Exports: none
|
|
6
|
+
// Depends on: ../src
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
printMacOSBridgePairingQr,
|
|
10
|
+
printMacOSBridgeServiceStatus,
|
|
11
|
+
readBridgeConfig,
|
|
12
|
+
resetMacOSBridgePairing,
|
|
13
|
+
runMacOSBridgeService,
|
|
14
|
+
startBridge,
|
|
15
|
+
startMacOSBridgeService,
|
|
16
|
+
stopMacOSBridgeService,
|
|
17
|
+
resetBridgePairing,
|
|
18
|
+
openLastActiveThread,
|
|
19
|
+
watchThreadRollout,
|
|
20
|
+
} = require("../src");
|
|
21
|
+
const { version } = require("../package.json");
|
|
22
|
+
|
|
23
|
+
const command = process.argv[2] || "up";
|
|
24
|
+
|
|
25
|
+
void main();
|
|
26
|
+
|
|
27
|
+
// ─── ENTRY POINT ─────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
async function main() {
|
|
30
|
+
if (isVersionCommand(command)) {
|
|
31
|
+
console.log(version);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (command === "up") {
|
|
36
|
+
if (process.platform === "darwin") {
|
|
37
|
+
const result = await startMacOSBridgeService({
|
|
38
|
+
waitForPairing: true,
|
|
39
|
+
});
|
|
40
|
+
printMacOSBridgePairingQr({
|
|
41
|
+
pairingSession: result.pairingSession,
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
startBridge();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (command === "run") {
|
|
51
|
+
startBridge();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (command === "run-service") {
|
|
56
|
+
runMacOSBridgeService();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (command === "start") {
|
|
61
|
+
assertMacOSCommand(command);
|
|
62
|
+
readBridgeConfig();
|
|
63
|
+
await startMacOSBridgeService({
|
|
64
|
+
waitForPairing: false,
|
|
65
|
+
});
|
|
66
|
+
console.log("[codex-bridge] macOS bridge service is running.");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (command === "stop") {
|
|
71
|
+
assertMacOSCommand(command);
|
|
72
|
+
stopMacOSBridgeService();
|
|
73
|
+
console.log("[codex-bridge] macOS bridge service stopped.");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (command === "status") {
|
|
78
|
+
assertMacOSCommand(command);
|
|
79
|
+
printMacOSBridgeServiceStatus();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (command === "reset-pairing") {
|
|
84
|
+
try {
|
|
85
|
+
if (process.platform === "darwin") {
|
|
86
|
+
resetMacOSBridgePairing();
|
|
87
|
+
console.log("[codex-bridge] Stopped the macOS bridge service and cleared the saved pairing state. Run `codex-bridge up` to pair again.");
|
|
88
|
+
} else {
|
|
89
|
+
resetBridgePairing();
|
|
90
|
+
console.log("[codex-bridge] Cleared the saved pairing state. Run `codex-bridge up` to pair again.");
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error(`[codex-bridge] ${(error && error.message) || "Failed to clear the saved pairing state."}`);
|
|
94
|
+
process.exit(1);
|
|
53
95
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (command === "resume") {
|
|
100
|
+
try {
|
|
101
|
+
const state = openLastActiveThread();
|
|
102
|
+
console.log(
|
|
103
|
+
`[codex-bridge] Opened last active thread: ${state.threadId} (${state.source || "unknown"})`
|
|
104
|
+
);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.error(`[codex-bridge] ${(error && error.message) || "Failed to reopen the last thread."}`);
|
|
107
|
+
process.exit(1);
|
|
59
108
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (command === "watch") {
|
|
113
|
+
try {
|
|
114
|
+
watchThreadRollout(process.argv[3] || "");
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.error(`[codex-bridge] ${(error && error.message) || "Failed to watch the thread rollout."}`);
|
|
117
|
+
process.exit(1);
|
|
64
118
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
switch (firstArg) {
|
|
76
|
-
case "help":
|
|
77
|
-
case "--help":
|
|
78
|
-
case "-h":
|
|
79
|
-
return "help";
|
|
80
|
-
case "version":
|
|
81
|
-
case "--version":
|
|
82
|
-
case "-v":
|
|
83
|
-
return "version";
|
|
84
|
-
default:
|
|
85
|
-
return firstArg.startsWith("-") ? "up" : firstArg;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function printHelp(exitCode = 0) {
|
|
90
|
-
const lines = [
|
|
91
|
-
"Usage:",
|
|
92
|
-
" codex-bridge up [--host 127.0.0.1] [--port 8787]",
|
|
93
|
-
" codex-bridge start [--host 127.0.0.1] [--port 8787]",
|
|
94
|
-
" codex-bridge help",
|
|
95
|
-
" codex-bridge version"
|
|
96
|
-
];
|
|
97
|
-
|
|
98
|
-
const stream = exitCode === 0 ? process.stdout : process.stderr;
|
|
99
|
-
stream.write(`${lines.join("\n")}\n`);
|
|
100
|
-
process.exit(exitCode);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
console.error(`Unknown command: ${command}`);
|
|
123
|
+
console.error(
|
|
124
|
+
"Usage: codex-bridge up | codex-bridge run | codex-bridge start | codex-bridge stop | codex-bridge status | "
|
|
125
|
+
+ "codex-bridge reset-pairing | codex-bridge resume | codex-bridge watch [threadId] | codex-bridge --version"
|
|
126
|
+
);
|
|
127
|
+
process.exit(1);
|
|
101
128
|
}
|
|
102
|
-
|
|
103
|
-
function
|
|
104
|
-
process.
|
|
129
|
+
|
|
130
|
+
function assertMacOSCommand(name) {
|
|
131
|
+
if (process.platform === "darwin") {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
console.error(`[codex-bridge] \`${name}\` is only available on macOS. Use \`codex-bridge up\` or \`codex-bridge run\` for the foreground bridge on this OS.`);
|
|
136
|
+
process.exit(1);
|
|
105
137
|
}
|
|
138
|
+
|
|
139
|
+
function isVersionCommand(value) {
|
|
140
|
+
return value === "-v" || value === "--v" || value === "-V" || value === "--version" || value === "version";
|
|
141
|
+
}
|
package/bin/phodex.js
ADDED
package/bin/remodex.js
ADDED
package/package.json
CHANGED
|
@@ -1,24 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@btatum5/codex-bridge",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
],
|
|
15
|
-
"publishConfig": {
|
|
16
|
-
"access": "public"
|
|
17
|
-
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
}
|
|
24
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@btatum5/codex-bridge",
|
|
3
|
+
"version": "1.3.3",
|
|
4
|
+
"description": "Local bridge between Codex and the Codex mobile app. Run `codex-bridge up` to start.",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"codex-bridge": "bin/codex-bridge.js",
|
|
8
|
+
"remodex": "bin/codex-bridge.js",
|
|
9
|
+
"phodex": "bin/phodex.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/",
|
|
13
|
+
"src/"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"start": "node ./bin/codex-bridge.js up",
|
|
20
|
+
"test": "node --test ./test/*.test.js",
|
|
21
|
+
"prepack": "node ./scripts/prepare-private-defaults.js",
|
|
22
|
+
"postpack": "node ./scripts/cleanup-private-defaults.js"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"codex-bridge",
|
|
26
|
+
"remodex",
|
|
27
|
+
"codex",
|
|
28
|
+
"bridge",
|
|
29
|
+
"cli"
|
|
30
|
+
],
|
|
31
|
+
"author": "Emanuele Di Pietro",
|
|
32
|
+
"license": "ISC",
|
|
33
|
+
"type": "commonjs",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"qrcode-terminal": "^0.12.0",
|
|
36
|
+
"ws": "^8.19.0"
|
|
37
|
+
}
|
|
38
|
+
}
|