@dhruv2mars/offdex 0.0.7 → 0.0.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/README.md +2 -1
- package/bin/offdex.js +107 -52
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -28,7 +28,8 @@ Common usage:
|
|
|
28
28
|
offdex
|
|
29
29
|
offdex help
|
|
30
30
|
offdex start --host 0.0.0.0 --port 42420
|
|
31
|
-
offdex start --control-plane-url https://control.offdex.app
|
|
32
31
|
offdex status
|
|
33
32
|
offdex stop
|
|
34
33
|
```
|
|
34
|
+
|
|
35
|
+
Remote pairing is enabled by default through the managed Offdex relay. Use `OFFDEX_CONTROL_PLANE_URL` only to override it for development.
|
package/bin/offdex.js
CHANGED
|
@@ -13,68 +13,112 @@ import {
|
|
|
13
13
|
} from "./offdex-lib.js";
|
|
14
14
|
|
|
15
15
|
const args = process.argv.slice(2);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
offdex
|
|
46
|
-
|
|
16
|
+
const colorEnabled =
|
|
17
|
+
Boolean(process.stdout.isTTY) &&
|
|
18
|
+
process.env.NO_COLOR !== "1" &&
|
|
19
|
+
process.env.NO_COLOR !== "true" &&
|
|
20
|
+
process.env.TERM !== "dumb";
|
|
21
|
+
const paint = (code, text) => colorEnabled ? `\u001b[${code}m${text}\u001b[0m` : text;
|
|
22
|
+
const green = (text) => paint("38;2;16;163;127", text);
|
|
23
|
+
const muted = (text) => paint("38;2;156;163;160", text);
|
|
24
|
+
const bold = (text) => paint("1", text);
|
|
25
|
+
const command = (text) => paint("38;2;225;229;226", text);
|
|
26
|
+
const link = (text) => paint("38;2;203;255;229", text);
|
|
27
|
+
const controlPlaneUrl = "https://offdex-control-plane.dhruv-sharma10102005.workers.dev";
|
|
28
|
+
|
|
29
|
+
function onboardingText() {
|
|
30
|
+
return [
|
|
31
|
+
bold(green("Offdex")),
|
|
32
|
+
muted("Codex mobile app."),
|
|
33
|
+
"",
|
|
34
|
+
"Use Codex from your phone while the real Codex session keeps running on this Mac.",
|
|
35
|
+
"",
|
|
36
|
+
green("Get started"),
|
|
37
|
+
` 1. Run ${command("offdex start")}`,
|
|
38
|
+
" 2. Open Offdex on your phone.",
|
|
39
|
+
" 3. Scan the QR from this terminal.",
|
|
40
|
+
" 4. Send a prompt and watch Codex reply live.",
|
|
41
|
+
"",
|
|
42
|
+
green("Core commands"),
|
|
43
|
+
` ${command("offdex help")} Commands, docs, GitHub, feedback.`,
|
|
44
|
+
` ${command("offdex start")} Start the bridge and show the QR.`,
|
|
45
|
+
` ${command("offdex status")} Show bridge, Codex, and client status.`,
|
|
46
|
+
` ${command("offdex stop")} Stop the local bridge.`,
|
|
47
|
+
"",
|
|
48
|
+
`Docs: ${link("https://offdexapp.vercel.app")}`,
|
|
49
|
+
].join("\n");
|
|
50
|
+
}
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
function helpText() {
|
|
53
|
+
return [
|
|
54
|
+
bold(green("Offdex help")),
|
|
55
|
+
muted("Codex mobile app."),
|
|
56
|
+
"",
|
|
57
|
+
green("Commands"),
|
|
58
|
+
` ${command("offdex")}`,
|
|
59
|
+
" Open the Offdex home screen.",
|
|
60
|
+
"",
|
|
61
|
+
` ${command("offdex help")}`,
|
|
62
|
+
" Show commands, docs, and support links.",
|
|
63
|
+
"",
|
|
64
|
+
` ${command("offdex start")} ${muted("[options]")}`,
|
|
65
|
+
" Start the bridge and show the pairing QR.",
|
|
66
|
+
"",
|
|
67
|
+
` ${command("offdex status")} ${muted("[options]")}`,
|
|
68
|
+
" Show bridge, Codex, client, and remote status.",
|
|
69
|
+
"",
|
|
70
|
+
` ${command("offdex stop")} ${muted("[options]")}`,
|
|
71
|
+
" Stop the local bridge started by Offdex.",
|
|
72
|
+
"",
|
|
73
|
+
green("Start options"),
|
|
74
|
+
` ${command("--host <host>")} Default: 0.0.0.0`,
|
|
75
|
+
` ${command("--port <port>")} Default: 42420`,
|
|
76
|
+
` ${command("--mode <codex|demo>")} Default: codex`,
|
|
77
|
+
` ${command("--control-plane-url <url>")} Override managed remote pairing.`,
|
|
78
|
+
"",
|
|
79
|
+
green("Environment fallbacks"),
|
|
80
|
+
` ${command("OFFDEX_BRIDGE_HOST")}`,
|
|
81
|
+
` ${command("OFFDEX_BRIDGE_PORT")}`,
|
|
82
|
+
` ${command("OFFDEX_BRIDGE_MODE")}`,
|
|
83
|
+
` ${command("OFFDEX_CONTROL_PLANE_URL")} Default: ${controlPlaneUrl}`,
|
|
84
|
+
"",
|
|
85
|
+
green("Links"),
|
|
86
|
+
` Docs: ${link("https://offdexapp.vercel.app")}`,
|
|
87
|
+
` GitHub: ${link("https://github.com/Dhruv2mars/offdex")}`,
|
|
88
|
+
` Feedback: ${link("https://github.com/Dhruv2mars/offdex/issues")}`,
|
|
89
|
+
].join("\n");
|
|
90
|
+
}
|
|
50
91
|
|
|
51
|
-
|
|
52
|
-
|
|
92
|
+
function offlineText() {
|
|
93
|
+
return [
|
|
94
|
+
bold("Offdex is not running"),
|
|
95
|
+
`Start it with: ${command("offdex start")}`,
|
|
96
|
+
].join("\n");
|
|
97
|
+
}
|
|
53
98
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
--mode <codex|demo> Default: codex
|
|
58
|
-
--control-plane-url <url> Enable managed remote pairing.
|
|
99
|
+
function commandName(argv) {
|
|
100
|
+
return argv[0] ?? "onboarding";
|
|
101
|
+
}
|
|
59
102
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
103
|
+
function canAnswerWithoutRuntime(argv) {
|
|
104
|
+
const name = commandName(argv);
|
|
105
|
+
return (
|
|
106
|
+
argv.length === 0 ||
|
|
107
|
+
name === "help" ||
|
|
108
|
+
name === "--help" ||
|
|
109
|
+
name === "-h" ||
|
|
110
|
+
name === "status" ||
|
|
111
|
+
name === "stop"
|
|
112
|
+
);
|
|
113
|
+
}
|
|
65
114
|
|
|
66
|
-
Links:
|
|
67
|
-
Docs: https://offdexapp.vercel.app
|
|
68
|
-
GitHub: https://github.com/Dhruv2mars/offdex
|
|
69
|
-
Feedback: https://github.com/Dhruv2mars/offdex/issues
|
|
70
|
-
`;
|
|
71
115
|
const installedBin = resolveInstalledBin(process.env, process.platform);
|
|
72
116
|
const packageVersion = readPackageVersion();
|
|
73
117
|
const currentInstalledVersion = installedVersion(process.env);
|
|
74
118
|
const workspaceBridgeCli = resolveWorkspaceBridgeCli();
|
|
75
119
|
|
|
76
120
|
if (!existsSync(installedBin) && args.length === 0) {
|
|
77
|
-
console.log(
|
|
121
|
+
console.log(onboardingText());
|
|
78
122
|
process.exit(0);
|
|
79
123
|
}
|
|
80
124
|
|
|
@@ -82,7 +126,7 @@ if (
|
|
|
82
126
|
!existsSync(installedBin) &&
|
|
83
127
|
(args[0] === "help" || args[0] === "--help" || args[0] === "-h")
|
|
84
128
|
) {
|
|
85
|
-
console.log(
|
|
129
|
+
console.log(helpText());
|
|
86
130
|
process.exit(0);
|
|
87
131
|
}
|
|
88
132
|
|
|
@@ -94,7 +138,18 @@ if (workspaceBridgeCli && !existsSync(installedBin)) {
|
|
|
94
138
|
process.exit(result.status ?? 1);
|
|
95
139
|
}
|
|
96
140
|
|
|
141
|
+
if (!existsSync(installedBin) && args[0] === "status") {
|
|
142
|
+
console.log(offlineText());
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!existsSync(installedBin) && args[0] === "stop") {
|
|
147
|
+
console.log(offlineText());
|
|
148
|
+
process.exit(0);
|
|
149
|
+
}
|
|
150
|
+
|
|
97
151
|
if (
|
|
152
|
+
!canAnswerWithoutRuntime(args) &&
|
|
98
153
|
shouldInstallBinary({
|
|
99
154
|
binExists: existsSync(installedBin),
|
|
100
155
|
installedVersion: currentInstalledVersion,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhruv2mars/offdex",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Codex mobile bridge CLI for Offdex",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"offdex": "node bin/offdex.js",
|
|
17
|
-
"postinstall": "node bin/install.js",
|
|
18
17
|
"build": "node -e \"process.exit(0)\"",
|
|
19
18
|
"check": "node --check bin/offdex.js && node --check bin/offdex-lib.js && node --check bin/install.js && node --check bin/install-lib.js && node --test test/*.test.js",
|
|
20
19
|
"test": "node --test test/*.test.js"
|