@fulldivevr/workcord-cli 3.0.4 → 3.0.5
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/dist/commands/machine.js +12 -25
- package/dist/machine/agents.js +8 -20
- package/package.json +1 -1
package/dist/commands/machine.js
CHANGED
|
@@ -8,7 +8,7 @@ import { deleteMachineFile, getMachineLockPath, getMachinePath, getMachineThread
|
|
|
8
8
|
import { normalizeBaseUrl } from "../http.js";
|
|
9
9
|
import { runClaude } from "../machine/adapters/claude.js";
|
|
10
10
|
import { binaryVersion, probeCodex, runCodex } from "../machine/adapters/codex.js";
|
|
11
|
-
import { ADAPTER_NAMES, childEnv,
|
|
11
|
+
import { ADAPTER_NAMES, childEnv, detectAdapters } from "../machine/agents.js";
|
|
12
12
|
import { handleTask, TaskContexts } from "../machine/handler.js";
|
|
13
13
|
import { pairComputer } from "../machine/pair.js";
|
|
14
14
|
import { nextRotationDelay, rotateMachineKey, ROTATE_EVERY_MS } from "../machine/rotate.js";
|
|
@@ -88,7 +88,7 @@ export function registerMachine(program) {
|
|
|
88
88
|
const detected = await detectAdapters();
|
|
89
89
|
pickAdapters(detected, opts.adapter, home);
|
|
90
90
|
// checkAdapters already narrowed the set to the chosen adapter.
|
|
91
|
-
const usable = await checkAdapters(detected, opts.adapter, home
|
|
91
|
+
const usable = await checkAdapters(detected, opts.adapter, home);
|
|
92
92
|
const adapters = pickAdapters(usable, "auto", home);
|
|
93
93
|
const baseUrl = credential.baseUrl || (await getBaseUrl());
|
|
94
94
|
const installationId = await readOrCreateInstallationId();
|
|
@@ -184,36 +184,23 @@ function collect(value, previous) {
|
|
|
184
184
|
}
|
|
185
185
|
const RUNNERS = { claude: runClaude, codex: runCodex };
|
|
186
186
|
/**
|
|
187
|
-
* Prints the binary each adapter uses. Codex
|
|
188
|
-
*
|
|
189
|
-
* a legacy Codex CLI cannot run tasks at all.
|
|
187
|
+
* Prints the binary each adapter uses. A Codex that cannot answer `app-server`
|
|
188
|
+
* fails the start, since a legacy Codex CLI cannot run tasks at all.
|
|
190
189
|
*/
|
|
191
|
-
export async function checkAdapters(installed, choice, home, log = (line) => process.stderr.write(line + "\n"), env = process.env
|
|
190
|
+
export async function checkAdapters(installed, choice, home, log = (line) => process.stderr.write(line + "\n"), env = process.env) {
|
|
192
191
|
const usable = {};
|
|
193
192
|
for (const [name, binary] of Object.entries(installed)) {
|
|
194
193
|
if (!binary || (choice !== "auto" && choice !== name))
|
|
195
194
|
continue;
|
|
196
195
|
if (name === "codex") {
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (probe.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
failed.push({ ...probe, binary: candidate });
|
|
205
|
-
}
|
|
206
|
-
if (!usable.codex) {
|
|
207
|
-
for (const probe of failed) {
|
|
208
|
-
log(`ERROR: ${probe.message}`);
|
|
209
|
-
if (probe.stderr)
|
|
210
|
-
log(`machine: codex said: ${probe.stderr.replace(/\s+/g, " ").slice(-300)}`);
|
|
211
|
-
}
|
|
212
|
-
throw new Error("codex is installed but none of its copies can run tasks, see the ERROR lines above.");
|
|
213
|
-
}
|
|
214
|
-
for (const probe of failed) {
|
|
215
|
-
log(`machine: warning: skipped codex at ${probe.binary} (version ${probe.version}), it cannot run "codex app-server"`);
|
|
196
|
+
const probe = await probeCodex(binary, env, home);
|
|
197
|
+
if (!probe.ok) {
|
|
198
|
+
log(`ERROR: ${probe.message}`);
|
|
199
|
+
if (probe.stderr)
|
|
200
|
+
log(`machine: codex said: ${probe.stderr.replace(/\s+/g, " ").slice(-300)}`);
|
|
201
|
+
throw new Error("codex cannot run tasks, see the ERROR line above.");
|
|
216
202
|
}
|
|
203
|
+
usable.codex = binary;
|
|
217
204
|
log(`machine: codex at ${usable.codex}`);
|
|
218
205
|
continue;
|
|
219
206
|
}
|
package/dist/machine/agents.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { access, constants
|
|
1
|
+
import { access, constants } from "node:fs/promises";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { delimiter, join } from "node:path";
|
|
4
4
|
export const ADAPTER_NAMES = ["claude", "codex"];
|
|
@@ -13,7 +13,7 @@ export function childEnv(env = process.env, home) {
|
|
|
13
13
|
return inherited;
|
|
14
14
|
return { ...inherited, HOME: home, CODEX_HOME: join(home, ".codex"), CLAUDE_CONFIG_DIR: join(home, ".claude") };
|
|
15
15
|
}
|
|
16
|
-
/** Codex desktop bundles a current codex that is not on PATH. */
|
|
16
|
+
/** Codex desktop bundles a current codex that is not on PATH; when one exists it is the codex, ahead of PATH. */
|
|
17
17
|
export function codexDesktopPaths(platform = process.platform, home = homedir()) {
|
|
18
18
|
if (platform !== "darwin")
|
|
19
19
|
return [];
|
|
@@ -26,21 +26,6 @@ const isExecutable = (path) => access(path, constants.X_OK).then(() => true, ()
|
|
|
26
26
|
function onPath(name, env) {
|
|
27
27
|
return String(env.PATH || "").split(delimiter).filter(Boolean).map((dir) => join(dir, name));
|
|
28
28
|
}
|
|
29
|
-
/** Every installed codex, PATH order first, then the desktop bundles, one per real file. */
|
|
30
|
-
export async function codexCandidates(env = process.env, desktop = codexDesktopPaths()) {
|
|
31
|
-
const seen = new Set();
|
|
32
|
-
const found = [];
|
|
33
|
-
for (const candidate of [...onPath("codex", env), ...desktop]) {
|
|
34
|
-
if (!(await isExecutable(candidate)))
|
|
35
|
-
continue;
|
|
36
|
-
const real = await realpath(candidate).catch(() => candidate);
|
|
37
|
-
if (seen.has(real))
|
|
38
|
-
continue;
|
|
39
|
-
seen.add(real);
|
|
40
|
-
found.push(candidate);
|
|
41
|
-
}
|
|
42
|
-
return found;
|
|
43
|
-
}
|
|
44
29
|
/** Absolute path of each installed agent CLI, found the way a shell would find it. */
|
|
45
30
|
export async function detectAdapters(env = process.env, codexDesktop = codexDesktopPaths()) {
|
|
46
31
|
const found = {};
|
|
@@ -50,9 +35,12 @@ export async function detectAdapters(env = process.env, codexDesktop = codexDesk
|
|
|
50
35
|
break;
|
|
51
36
|
}
|
|
52
37
|
}
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
for (const candidate of [...codexDesktop, ...onPath("codex", env)]) {
|
|
39
|
+
if (await isExecutable(candidate)) {
|
|
40
|
+
found.codex = candidate;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
56
44
|
return found;
|
|
57
45
|
}
|
|
58
46
|
//# sourceMappingURL=agents.js.map
|