agent-dealer 0.1.13 → 0.3.0
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/bundle/server/dist/adapters/agent-health.js +28 -1
- package/bundle/server/dist/cli-env.js +16 -0
- package/bundle/server/dist/cli-env.test.js +14 -1
- package/bundle/server/dist/db/index.js +2 -1
- package/bundle/server/dist/queue/result-qa.js +1 -1
- package/bundle/server/dist/runners/claude.js +6 -87
- package/bundle/server/dist/runners/codex-args.js +59 -0
- package/bundle/server/dist/runners/codex-args.test.js +72 -0
- package/bundle/server/dist/runners/codex-jsonl.js +150 -0
- package/bundle/server/dist/runners/codex-jsonl.test.js +36 -0
- package/bundle/server/dist/runners/codex-resume.test.js +19 -0
- package/bundle/server/dist/runners/codex.js +46 -0
- package/bundle/server/dist/runners/models-codex.test.js +14 -0
- package/bundle/server/dist/runners/models.js +53 -1
- package/bundle/server/dist/runners/persist.js +4 -1
- package/bundle/server/dist/runners/qa.js +17 -1
- package/bundle/server/dist/runners/spawn-cli.js +90 -0
- package/bundle/server/package.json +2 -2
- package/bundle/server/static-ui/assets/index-DTcianAH.js +79 -0
- package/bundle/server/static-ui/index.html +1 -1
- package/bundle/shared/dist/agents.d.ts +18 -17
- package/bundle/shared/dist/agents.js +1 -0
- package/bundle/shared/dist/index.d.ts +83 -83
- package/bundle/shared/dist/runtime.d.ts +1 -1
- package/bundle/shared/dist/runtime.js +1 -1
- package/bundle/shared/package.json +1 -1
- package/dist/doctor.js +18 -0
- package/dist/index.js +14 -2
- package/dist/install.d.ts +8 -0
- package/dist/install.js +72 -0
- package/dist/managed/activate.d.ts +2 -0
- package/dist/managed/activate.js +49 -0
- package/dist/managed/activate.test.d.ts +1 -0
- package/dist/managed/activate.test.js +34 -0
- package/dist/managed/index.d.ts +8 -0
- package/dist/managed/index.js +8 -0
- package/dist/managed/install-kind.d.ts +5 -0
- package/dist/managed/install-kind.js +16 -0
- package/dist/managed/launcher.d.ts +1 -0
- package/dist/managed/launcher.js +19 -0
- package/dist/managed/npm-prefix-install.d.ts +16 -0
- package/dist/managed/npm-prefix-install.js +38 -0
- package/dist/managed/paths.d.ts +11 -0
- package/dist/managed/paths.js +45 -0
- package/dist/managed/semver.d.ts +2 -0
- package/dist/managed/semver.js +12 -0
- package/dist/managed/update-state.d.ts +7 -0
- package/dist/managed/update-state.js +22 -0
- package/dist/managed/updater.d.ts +21 -0
- package/dist/managed/updater.js +107 -0
- package/dist/update-check.d.ts +1 -0
- package/dist/update-check.js +25 -37
- package/dist/upgrade.d.ts +1 -0
- package/dist/upgrade.js +55 -6
- package/package.json +1 -1
- package/bundle/server/static-ui/assets/index-B_7S7xJb.js +0 -79
package/dist/update-check.js
CHANGED
|
@@ -1,32 +1,15 @@
|
|
|
1
|
+
import { detectInstallKind, runManagedCliEntryHooks } from "./managed/index.js";
|
|
2
|
+
import { installAgentDealerVersion } from "./upgrade.js";
|
|
3
|
+
import { fetchLatestPublishedVersion } from "./npm-registry.js";
|
|
4
|
+
import { getVersion } from "./version.js";
|
|
5
|
+
import { compareSemver } from "./managed/semver.js";
|
|
1
6
|
import fs from "node:fs";
|
|
2
7
|
import path from "node:path";
|
|
3
8
|
import readline from "node:readline";
|
|
4
9
|
import { prodHomeDir } from "./env.js";
|
|
5
|
-
import { getVersion } from "./version.js";
|
|
6
|
-
import { fetchLatestPublishedVersion } from "./npm-registry.js";
|
|
7
|
-
import { installAgentDealerVersion } from "./upgrade.js";
|
|
8
10
|
const PKG_NAME = "agent-dealer";
|
|
9
11
|
const CACHE_FILE = ".agent-dealer-update-check.json";
|
|
10
12
|
const CHECK_THROTTLE_MS = 24 * 60 * 60 * 1000;
|
|
11
|
-
function parseXyzVersion(v) {
|
|
12
|
-
const m = v.trim().match(/^(\d+)\.(\d+)\.(\d+)/);
|
|
13
|
-
if (!m)
|
|
14
|
-
return undefined;
|
|
15
|
-
return { major: Number(m[1]), minor: Number(m[2]), patch: Number(m[3]) };
|
|
16
|
-
}
|
|
17
|
-
function isNewer(latest, current) {
|
|
18
|
-
const a = parseXyzVersion(latest);
|
|
19
|
-
const b = parseXyzVersion(current);
|
|
20
|
-
if (!a || !b)
|
|
21
|
-
return false;
|
|
22
|
-
if (a.major !== b.major)
|
|
23
|
-
return a.major > b.major;
|
|
24
|
-
if (a.minor !== b.minor)
|
|
25
|
-
return a.minor > b.minor;
|
|
26
|
-
if (a.patch !== b.patch)
|
|
27
|
-
return a.patch > b.patch;
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
13
|
async function promptYesNo(message) {
|
|
31
14
|
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
32
15
|
return false;
|
|
@@ -36,16 +19,14 @@ async function promptYesNo(message) {
|
|
|
36
19
|
return answer.trim().toLowerCase().startsWith("y");
|
|
37
20
|
}
|
|
38
21
|
function cachePath() {
|
|
39
|
-
|
|
40
|
-
return path.join(home, CACHE_FILE);
|
|
22
|
+
return path.join(prodHomeDir(), CACHE_FILE);
|
|
41
23
|
}
|
|
42
24
|
function readCache() {
|
|
43
25
|
try {
|
|
44
26
|
const p = cachePath();
|
|
45
27
|
if (!fs.existsSync(p))
|
|
46
28
|
return undefined;
|
|
47
|
-
|
|
48
|
-
return JSON.parse(raw);
|
|
29
|
+
return JSON.parse(fs.readFileSync(p, "utf8"));
|
|
49
30
|
}
|
|
50
31
|
catch {
|
|
51
32
|
return undefined;
|
|
@@ -53,23 +34,34 @@ function readCache() {
|
|
|
53
34
|
}
|
|
54
35
|
function writeCache(next) {
|
|
55
36
|
try {
|
|
56
|
-
|
|
57
|
-
fs.mkdirSync(home, { recursive: true });
|
|
37
|
+
fs.mkdirSync(prodHomeDir(), { recursive: true });
|
|
58
38
|
fs.writeFileSync(cachePath(), JSON.stringify(next), "utf8");
|
|
59
39
|
}
|
|
60
40
|
catch {
|
|
61
|
-
//
|
|
41
|
+
// ignore
|
|
62
42
|
}
|
|
63
43
|
}
|
|
44
|
+
/** npm-global / unknown path — keep TTY prompt behavior. Managed uses hooks instead. */
|
|
64
45
|
export async function maybeCheckForUpdateOnRun() {
|
|
46
|
+
if (detectInstallKind() === "managed") {
|
|
47
|
+
const { activated } = runManagedCliEntryHooks({ allowActivate: true });
|
|
48
|
+
if (activated) {
|
|
49
|
+
console.log(`[agent-dealer] Activated managed version ${activated}`);
|
|
50
|
+
console.log("Re-run your command to use the new version.");
|
|
51
|
+
return { upgraded: true };
|
|
52
|
+
}
|
|
53
|
+
return { upgraded: false };
|
|
54
|
+
}
|
|
65
55
|
if (process.env.AGENT_DEALER_DISABLE_UPGRADE_CHECK === "1") {
|
|
66
56
|
return { upgraded: false };
|
|
67
57
|
}
|
|
58
|
+
if (process.env.AGENT_DEALER_DISABLE_AUTOUPDATER === "1") {
|
|
59
|
+
return { upgraded: false };
|
|
60
|
+
}
|
|
68
61
|
const current = getVersion();
|
|
69
62
|
const cache = readCache();
|
|
70
63
|
if (cache?.checkedAt && Date.now() - cache.checkedAt < CHECK_THROTTLE_MS) {
|
|
71
|
-
|
|
72
|
-
if (cache.latestVersion && isNewer(cache.latestVersion, current)) {
|
|
64
|
+
if (cache.latestVersion && compareSemver(cache.latestVersion, current) > 0) {
|
|
73
65
|
console.log(`Update available: ${current} -> ${cache.latestVersion}`);
|
|
74
66
|
const autoUpgrade = ["1", "true", "yes"].includes(process.env.AGENT_DEALER_AUTO_UPGRADE?.trim().toLowerCase() ?? "");
|
|
75
67
|
if (autoUpgrade) {
|
|
@@ -79,9 +71,9 @@ export async function maybeCheckForUpdateOnRun() {
|
|
|
79
71
|
const canPrompt = process.stdin.isTTY && process.stdout.isTTY;
|
|
80
72
|
if (!canPrompt) {
|
|
81
73
|
console.log(`Run: agent-dealer upgrade`);
|
|
74
|
+
console.log("Tip: agent-dealer install # managed auto-updates");
|
|
82
75
|
return { upgraded: false };
|
|
83
76
|
}
|
|
84
|
-
// Prompt at most once per throttle window to avoid nagging.
|
|
85
77
|
const promptAgeMs = cache.promptedAt ? Date.now() - cache.promptedAt : Infinity;
|
|
86
78
|
if (promptAgeMs >= CHECK_THROTTLE_MS) {
|
|
87
79
|
writeCache({ ...cache, promptedAt: Date.now() });
|
|
@@ -89,20 +81,16 @@ export async function maybeCheckForUpdateOnRun() {
|
|
|
89
81
|
if (!ok)
|
|
90
82
|
return { upgraded: false };
|
|
91
83
|
}
|
|
92
|
-
else {
|
|
93
|
-
// Recently prompted; do not prompt again.
|
|
94
|
-
}
|
|
95
84
|
const code = await installAgentDealerVersion(cache.latestVersion);
|
|
96
85
|
return { upgraded: code === 0 };
|
|
97
86
|
}
|
|
98
87
|
return { upgraded: false };
|
|
99
88
|
}
|
|
100
89
|
const latest = await fetchLatestPublishedVersion(PKG_NAME);
|
|
101
|
-
// Always write checkedAt so we don't hammer the registry on repeated failures.
|
|
102
90
|
writeCache({ checkedAt: Date.now(), latestVersion: latest, promptedAt: cache?.promptedAt });
|
|
103
91
|
if (!latest || latest === current)
|
|
104
92
|
return { upgraded: false };
|
|
105
|
-
if (
|
|
93
|
+
if (compareSemver(latest, current) <= 0)
|
|
106
94
|
return { upgraded: false };
|
|
107
95
|
const autoUpgrade = ["1", "true", "yes"].includes(process.env.AGENT_DEALER_AUTO_UPGRADE?.trim().toLowerCase() ?? "");
|
|
108
96
|
console.log(`Update available: ${current} -> ${latest}`);
|
package/dist/upgrade.d.ts
CHANGED
package/dist/upgrade.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import readline from "node:readline";
|
|
3
|
+
import { activateVersion, compareSemver, detectInstallKind, fetchLatestVersion, installCliVersionToPrefix, readCurrentManagedVersion, } from "./managed/index.js";
|
|
3
4
|
import { fetchLatestPublishedVersion } from "./npm-registry.js";
|
|
5
|
+
import { getVersion } from "./version.js";
|
|
4
6
|
const PKG_NAME = "agent-dealer";
|
|
5
7
|
export function printUpgradeHelp() {
|
|
6
8
|
console.log(`Usage:
|
|
7
|
-
agent-dealer upgrade [--to VERSION] [--yes]
|
|
9
|
+
agent-dealer upgrade [--to VERSION] [--yes] [--check]
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
Managed install: download into ~/.agent-dealer/versions and activate.
|
|
12
|
+
npm-global: npm install -g agent-dealer@VERSION.`);
|
|
10
13
|
}
|
|
11
14
|
function parseBooleanLike(s) {
|
|
12
15
|
const v = s?.trim().toLowerCase();
|
|
@@ -32,14 +35,53 @@ async function runNpmGlobalInstall(version) {
|
|
|
32
35
|
}
|
|
33
36
|
export async function runUpgrade(options = {}) {
|
|
34
37
|
const toVersion = options.toVersion?.trim();
|
|
38
|
+
if (detectInstallKind() === "managed") {
|
|
39
|
+
const current = readCurrentManagedVersion() ?? getVersion();
|
|
40
|
+
const latest = toVersion ?? (await fetchLatestVersion());
|
|
41
|
+
if (!latest) {
|
|
42
|
+
console.error(`Could not resolve latest version for ${PKG_NAME}.`);
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
console.log(`Current: ${current}`);
|
|
46
|
+
console.log(`Latest: ${latest}`);
|
|
47
|
+
console.log("Install: managed");
|
|
48
|
+
if (!toVersion && compareSemver(latest, current) <= 0) {
|
|
49
|
+
console.log("Already on the latest version.");
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
if (options.check) {
|
|
53
|
+
console.log("Update available. Run: agent-dealer upgrade");
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
console.log(`Upgrading managed install ${PKG_NAME} → ${latest} ...`);
|
|
57
|
+
const result = await installCliVersionToPrefix(latest);
|
|
58
|
+
if (!result.ok) {
|
|
59
|
+
console.error(`Upgrade failed: ${result.error}`);
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
activateVersion(latest);
|
|
63
|
+
console.log("Upgrade complete. Restart any running agent-dealer process.");
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
35
66
|
let version = toVersion ?? (await fetchLatestPublishedVersion(PKG_NAME));
|
|
36
67
|
if (!version) {
|
|
37
68
|
console.error(`Could not resolve latest version for ${PKG_NAME}.`);
|
|
38
69
|
return 1;
|
|
39
70
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
71
|
+
console.log(`Current: ${getVersion()}`);
|
|
72
|
+
console.log(`Latest: ${version}`);
|
|
73
|
+
console.log("Install: npm-global (or unknown)");
|
|
74
|
+
if (options.check) {
|
|
75
|
+
if (compareSemver(version, getVersion()) > 0) {
|
|
76
|
+
console.log("Update available. Run: agent-dealer upgrade");
|
|
77
|
+
console.log("Tip: agent-dealer install # managed auto-updates (data unchanged)");
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.log("Already on the latest version.");
|
|
81
|
+
}
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
const autoYes = options.yes ?? parseBooleanLike(process.env.AGENT_DEALER_UPGRADE_YES) ?? false;
|
|
43
85
|
if (!autoYes) {
|
|
44
86
|
const ok = await confirmPrompt(`Upgrade ${PKG_NAME} to ${version} via "npm install -g ${PKG_NAME}@${version}"? [y/N] `);
|
|
45
87
|
if (!ok) {
|
|
@@ -50,10 +92,17 @@ export async function runUpgrade(options = {}) {
|
|
|
50
92
|
const code = await runNpmGlobalInstall(version);
|
|
51
93
|
if (code === 0) {
|
|
52
94
|
console.log(`Upgraded to ${PKG_NAME}@${version}. Re-run your command to use the new version.`);
|
|
95
|
+
console.log("Tip: agent-dealer install # switch CLI to managed auto-updates (data unchanged)");
|
|
53
96
|
}
|
|
54
97
|
return code;
|
|
55
98
|
}
|
|
56
|
-
// Used by update-check: prompts happen elsewhere, so we only do the install.
|
|
57
99
|
export async function installAgentDealerVersion(version) {
|
|
100
|
+
if (detectInstallKind() === "managed") {
|
|
101
|
+
const result = await installCliVersionToPrefix(version);
|
|
102
|
+
if (!result.ok)
|
|
103
|
+
return 1;
|
|
104
|
+
activateVersion(version);
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
58
107
|
return runNpmGlobalInstall(version);
|
|
59
108
|
}
|