clawdex-mobile 5.1.3-internal.9 → 5.2.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +6 -55
  3. package/bin/clawdex.js +2 -2
  4. package/docs/setup-and-operations.md +13 -100
  5. package/docs/troubleshooting.md +2 -71
  6. package/package.json +17 -6
  7. package/scripts/setup-secure-dev.sh +5 -79
  8. package/scripts/setup-wizard.sh +37 -87
  9. package/scripts/start-bridge-secure.js +9 -269
  10. package/services/cursor-app-server/README.md +39 -0
  11. package/services/cursor-app-server/dist/appServer.d.ts +52 -0
  12. package/services/cursor-app-server/dist/appServer.js +780 -0
  13. package/services/cursor-app-server/dist/appServer.js.map +1 -0
  14. package/services/cursor-app-server/dist/cursorWorkspace.d.ts +7 -0
  15. package/services/cursor-app-server/dist/cursorWorkspace.js +126 -0
  16. package/services/cursor-app-server/dist/cursorWorkspace.js.map +1 -0
  17. package/services/cursor-app-server/dist/index.d.ts +4 -0
  18. package/services/cursor-app-server/dist/index.js +4 -0
  19. package/services/cursor-app-server/dist/index.js.map +1 -0
  20. package/services/cursor-app-server/dist/input.d.ts +27 -0
  21. package/services/cursor-app-server/dist/input.js +143 -0
  22. package/services/cursor-app-server/dist/input.js.map +1 -0
  23. package/services/cursor-app-server/dist/jsonRpc.d.ts +15 -0
  24. package/services/cursor-app-server/dist/jsonRpc.js +93 -0
  25. package/services/cursor-app-server/dist/jsonRpc.js.map +1 -0
  26. package/services/cursor-app-server/dist/projection.d.ts +8 -0
  27. package/services/cursor-app-server/dist/projection.js +507 -0
  28. package/services/cursor-app-server/dist/projection.js.map +1 -0
  29. package/services/cursor-app-server/dist/sdkDriver.d.ts +50 -0
  30. package/services/cursor-app-server/dist/sdkDriver.js +166 -0
  31. package/services/cursor-app-server/dist/sdkDriver.js.map +1 -0
  32. package/services/cursor-app-server/dist/stdio.d.ts +2 -0
  33. package/services/cursor-app-server/dist/stdio.js +7 -0
  34. package/services/cursor-app-server/dist/stdio.js.map +1 -0
  35. package/services/cursor-app-server/dist/types.d.ts +218 -0
  36. package/services/cursor-app-server/dist/types.js +2 -0
  37. package/services/cursor-app-server/dist/types.js.map +1 -0
  38. package/services/cursor-app-server/package.json +43 -0
  39. package/services/rust-bridge/Cargo.lock +1 -1
  40. package/services/rust-bridge/Cargo.toml +1 -1
  41. package/services/rust-bridge/src/main.rs +1703 -353
  42. package/vendor/bridge-binaries/darwin-arm64/codex-rust-bridge +0 -0
  43. package/vendor/bridge-binaries/darwin-x64/codex-rust-bridge +0 -0
  44. package/vendor/bridge-binaries/linux-arm64/codex-rust-bridge +0 -0
  45. package/vendor/bridge-binaries/linux-armv7l/codex-rust-bridge +0 -0
  46. package/vendor/bridge-binaries/linux-x64/codex-rust-bridge +0 -0
  47. package/vendor/bridge-binaries/win32-x64/codex-rust-bridge.exe +0 -0
  48. package/scripts/codespaces-bootstrap.js +0 -297
@@ -1,297 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- const { spawnSync } = require("node:child_process");
5
- const fs = require("node:fs");
6
- const path = require("node:path");
7
-
8
- function resolveRootDir() {
9
- return path.resolve(__dirname, "..");
10
- }
11
-
12
- function resolveWorkspaceDir() {
13
- const candidates = [
14
- process.env.CLAWDEX_WORKSPACE_ROOT,
15
- process.env.INIT_CWD,
16
- process.cwd(),
17
- ];
18
-
19
- for (const candidate of candidates) {
20
- if (typeof candidate !== "string" || !candidate.trim()) {
21
- continue;
22
- }
23
- return path.resolve(candidate);
24
- }
25
-
26
- return resolveRootDir();
27
- }
28
-
29
- function readEnvFile(filePath) {
30
- const contents = fs.readFileSync(filePath, "utf8");
31
- const nextEnv = {};
32
-
33
- for (const rawLine of contents.split(/\r?\n/)) {
34
- const line = rawLine.trim();
35
- if (!line || line.startsWith("#")) {
36
- continue;
37
- }
38
-
39
- const match = line.match(/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
40
- if (!match) {
41
- continue;
42
- }
43
-
44
- const [, key, rawValue] = match;
45
- let value = rawValue;
46
- if (
47
- (value.startsWith('"') && value.endsWith('"')) ||
48
- (value.startsWith("'") && value.endsWith("'"))
49
- ) {
50
- value = value.slice(1, -1);
51
- }
52
- nextEnv[key] = value;
53
- }
54
-
55
- return nextEnv;
56
- }
57
-
58
- function readNonEmptyEnv(env, key) {
59
- const value = env[key];
60
- return typeof value === "string" && value.trim() ? value.trim() : "";
61
- }
62
-
63
- function runCommand(command, args, options = {}) {
64
- return spawnSync(command, args, {
65
- stdio: "inherit",
66
- ...options,
67
- });
68
- }
69
-
70
- function commandExists(command) {
71
- if (typeof command === "string" && command.includes(path.sep)) {
72
- try {
73
- fs.accessSync(command, fs.constants.X_OK);
74
- return true;
75
- } catch {
76
- return false;
77
- }
78
- }
79
-
80
- const checker = process.platform === "win32" ? "where" : "which";
81
- const result = spawnSync(checker, [command], { stdio: "ignore" });
82
- return result.status === 0;
83
- }
84
-
85
- function parseArgs(argv) {
86
- return {
87
- noStart: argv.includes("--no-start"),
88
- prepareOnly: argv.includes("--prepare-only"),
89
- force: argv.includes("--force"),
90
- };
91
- }
92
-
93
- function parseEngineList(value) {
94
- const raw = typeof value === "string" && value.trim() ? value : "codex";
95
- const engines = [];
96
- for (const entry of raw.split(",")) {
97
- const engine = entry.trim().toLowerCase();
98
- if (!engine) {
99
- continue;
100
- }
101
- if (!["codex", "opencode", "cursor"].includes(engine)) {
102
- console.error(`error: unsupported Codespaces engine '${engine}'. Use codex, opencode, or cursor.`);
103
- process.exit(1);
104
- }
105
- if (!engines.includes(engine)) {
106
- engines.push(engine);
107
- }
108
- }
109
- return engines.length > 0 ? engines : ["codex"];
110
- }
111
-
112
- function ensureCodespacesContext({ force }) {
113
- if (force) {
114
- return;
115
- }
116
-
117
- if (String(process.env.CODESPACES || "").trim().toLowerCase() === "true") {
118
- return;
119
- }
120
-
121
- console.log("Codespaces bootstrap skipped because this shell is not running inside GitHub Codespaces.");
122
- process.exit(0);
123
- }
124
-
125
- function runSetup(rootDir, workspaceDir) {
126
- const enabledEngines = parseEngineList(
127
- process.env.CLAWDEX_CODESPACES_ENGINES || process.env.BRIDGE_ENABLED_ENGINES || "codex"
128
- );
129
- const setupEnv = {
130
- ...process.env,
131
- };
132
-
133
- delete setupEnv.BRIDGE_NETWORK_MODE;
134
- delete setupEnv.BRIDGE_HOST_OVERRIDE;
135
- delete setupEnv.BRIDGE_ACTIVE_ENGINE;
136
- delete setupEnv.BRIDGE_ENABLED_ENGINES;
137
-
138
- setupEnv.INIT_CWD = rootDir;
139
- setupEnv.CLAWDEX_WORKSPACE_ROOT = workspaceDir;
140
- setupEnv.BRIDGE_NETWORK_MODE = "codespaces";
141
- setupEnv.BRIDGE_HOST_OVERRIDE = "127.0.0.1";
142
- setupEnv.BRIDGE_ACTIVE_ENGINE = enabledEngines[0];
143
- setupEnv.BRIDGE_ENABLED_ENGINES = enabledEngines.join(",");
144
-
145
- console.log(`Preparing .env.secure for GitHub Codespaces (${setupEnv.BRIDGE_ENABLED_ENGINES})...`);
146
- const result = runCommand(path.join(rootDir, "scripts", "setup-secure-dev.sh"), [], {
147
- cwd: workspaceDir,
148
- env: setupEnv,
149
- shell: false,
150
- });
151
-
152
- if ((result.status ?? 1) !== 0) {
153
- process.exit(result.status ?? 1);
154
- }
155
- }
156
-
157
- function ensureCodexCliInstalled(secureEnv) {
158
- const codexBinary = readNonEmptyEnv(secureEnv, "CODEX_CLI_BIN") || "codex";
159
- if (commandExists(codexBinary)) {
160
- return;
161
- }
162
-
163
- console.log("Codex CLI not found in this codespace. Installing via npm...");
164
- const installResult = runCommand("npm", ["install", "-g", "@openai/codex"], {
165
- cwd: resolveWorkspaceDir(),
166
- env: process.env,
167
- });
168
- if ((installResult.status ?? 1) !== 0) {
169
- console.error("error: failed to install Codex CLI automatically.");
170
- process.exit(installResult.status ?? 1);
171
- }
172
-
173
- if (!commandExists(codexBinary)) {
174
- console.error(`error: Codex CLI still not found after install attempt: ${codexBinary}`);
175
- process.exit(1);
176
- }
177
-
178
- console.log("Codex CLI installed.");
179
- }
180
-
181
- function ensureNpmGlobalBinary({ binary, packageName, label }) {
182
- if (commandExists(binary)) {
183
- return;
184
- }
185
-
186
- console.log(`${label} not found in this codespace. Installing via npm...`);
187
- const installResult = runCommand("npm", ["install", "-g", packageName], {
188
- cwd: resolveWorkspaceDir(),
189
- env: process.env,
190
- });
191
- if ((installResult.status ?? 1) !== 0) {
192
- console.error(`error: failed to install ${label} automatically.`);
193
- process.exit(installResult.status ?? 1);
194
- }
195
-
196
- if (!commandExists(binary)) {
197
- console.error(`error: ${label} still not found after install attempt: ${binary}`);
198
- process.exit(1);
199
- }
200
-
201
- console.log(`${label} installed.`);
202
- }
203
-
204
- function ensureSelectedEngineTools(secureEnv) {
205
- const enabledEngines = parseEngineList(readNonEmptyEnv(secureEnv, "BRIDGE_ENABLED_ENGINES") || "codex");
206
- if (enabledEngines.includes("codex")) {
207
- ensureCodexCliInstalled(secureEnv);
208
- }
209
- if (enabledEngines.includes("opencode")) {
210
- ensureNpmGlobalBinary({
211
- binary: readNonEmptyEnv(secureEnv, "OPENCODE_CLI_BIN") || "opencode",
212
- packageName: "opencode-ai",
213
- label: "OpenCode CLI",
214
- });
215
- }
216
- if (enabledEngines.includes("cursor")) {
217
- ensureNpmGlobalBinary({
218
- binary: readNonEmptyEnv(secureEnv, "CURSOR_APP_SERVER_BIN") || "cursor-app-server",
219
- packageName: "@clawdex/cursor-app-server",
220
- label: "Cursor app server",
221
- });
222
- }
223
- }
224
-
225
- function prepareBridgeBinary(rootDir, workspaceDir, secureEnv) {
226
- console.log("Prebuilding bridge binary for faster Codespaces startup...");
227
- const prepareEnv = {
228
- ...process.env,
229
- ...secureEnv,
230
- CLAWDEX_WORKSPACE_ROOT: workspaceDir,
231
- INIT_CWD: process.env.INIT_CWD || workspaceDir,
232
- };
233
- const result = runCommand(
234
- process.execPath,
235
- [path.join(rootDir, "scripts", "start-bridge-secure.js"), "--prepare-only"],
236
- {
237
- cwd: workspaceDir,
238
- env: prepareEnv,
239
- }
240
- );
241
-
242
- if ((result.status ?? 1) !== 0) {
243
- process.exit(result.status ?? 1);
244
- }
245
- }
246
-
247
- function startBridge(rootDir, workspaceDir) {
248
- console.log("Starting bridge in background for this codespace...");
249
- const result = runCommand(
250
- process.execPath,
251
- [path.join(rootDir, "scripts", "start-bridge-secure.js"), "--background"],
252
- {
253
- cwd: workspaceDir,
254
- env: {
255
- ...process.env,
256
- CLAWDEX_WORKSPACE_ROOT: workspaceDir,
257
- INIT_CWD: process.env.INIT_CWD || workspaceDir,
258
- },
259
- }
260
- );
261
-
262
- if ((result.status ?? 1) !== 0) {
263
- process.exit(result.status ?? 1);
264
- }
265
- }
266
-
267
- function main() {
268
- const options = parseArgs(process.argv.slice(2));
269
- ensureCodespacesContext(options);
270
-
271
- const rootDir = resolveRootDir();
272
- const workspaceDir = resolveWorkspaceDir();
273
- const secureEnvPath = path.join(workspaceDir, ".env.secure");
274
-
275
- runSetup(rootDir, workspaceDir);
276
-
277
- if (!fs.existsSync(secureEnvPath)) {
278
- console.error(`error: expected secure env at ${secureEnvPath}`);
279
- process.exit(1);
280
- }
281
-
282
- const secureEnv = readEnvFile(secureEnvPath);
283
- if (options.noStart || String(process.env.CLAWDEX_CODESPACES_SKIP_START || "").trim().toLowerCase() === "true") {
284
- console.log("Codespaces bootstrap configured bridge env only. Bridge auto-start skipped.");
285
- return;
286
- }
287
-
288
- ensureSelectedEngineTools(secureEnv);
289
- if (options.prepareOnly) {
290
- prepareBridgeBinary(rootDir, workspaceDir, secureEnv);
291
- console.log("Codespaces bootstrap prepared Codex and the bridge binary without starting the bridge.");
292
- return;
293
- }
294
- startBridge(rootDir, workspaceDir);
295
- }
296
-
297
- main();