@commonlyai/cli 0.1.245 → 0.1.246
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/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Goose 1.54.0 wrapper. Public seats expose only the Commonly MCP extension. */
|
|
2
2
|
import { requireSeatModel } from './seat-model.js';
|
|
3
|
+
import { probeVersion } from './tested-version.js';
|
|
3
4
|
import { spawn as childSpawn, spawnSync } from 'node:child_process';
|
|
4
5
|
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
5
6
|
import { tmpdir } from 'node:os';
|
|
@@ -278,9 +279,12 @@ export default {
|
|
|
278
279
|
: 'goose');
|
|
279
280
|
if (isPublic && !isAbsolute(binary)) throw new Error('goose adapter: public seats require an absolute Goose executable');
|
|
280
281
|
// A cold first launch can take several seconds while macOS scans the binary.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
// Async and cached per binary (tested-version.js probeVersion): a
|
|
283
|
+
// synchronous probe stalled every other seat's provider proxy on the
|
|
284
|
+
// daemon's loop for as long as this cold start took.
|
|
285
|
+
const version = ctx._version || await probeVersion(binary, {
|
|
286
|
+
env: safeEnv(sourceEnv), timeoutMs: 30000, parse: versionOf,
|
|
287
|
+
});
|
|
284
288
|
if (!TESTED_GOOSE_VERSIONS.includes(version)) {
|
|
285
289
|
if (isPublic) throw new Error(`goose adapter: public seats refuse untested version ${version || 'unknown'}`);
|
|
286
290
|
// eslint-disable-next-line no-console
|
package/src/lib/adapters/pi.js
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
import { requireSeatModel } from './seat-model.js';
|
|
45
|
+
import { probeVersion } from './tested-version.js';
|
|
45
46
|
import { spawn as childSpawn, spawnSync } from 'child_process';
|
|
46
47
|
import { createHash, randomUUID } from 'crypto';
|
|
47
48
|
import { accessSync, constants as fsConstants, existsSync, readFileSync, realpathSync } from 'fs';
|
|
@@ -572,9 +573,11 @@ export default {
|
|
|
572
573
|
if (!packageRoot) {
|
|
573
574
|
throw new Error(`pi adapter: no ${PI_PACKAGE} package found behind ${binary}, so the sandbox cannot admit pi's code`);
|
|
574
575
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
576
|
+
// Async and cached per binary (tested-version.js): a synchronous probe
|
|
577
|
+
// stalled every other seat's proxy on the daemon's loop.
|
|
578
|
+
const version = ctx._version || await probeVersion(binary, {
|
|
579
|
+
env: safeEnv(baseEnv), timeoutMs: 30000, parse: versionOf,
|
|
580
|
+
});
|
|
578
581
|
if (!TESTED_PI_VERSIONS.includes(version)) {
|
|
579
582
|
throw new Error(`pi adapter: public seats refuse untested pi version ${version || 'unknown'}; smoke-tested: ${TESTED_PI_VERSIONS.join(', ')}`);
|
|
580
583
|
}
|
package/src/lib/adapters/qwen.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Qwen Code 0.25.1 and 0.26.2 wrapper. Public turns have fresh HOME, config and keys. */
|
|
2
2
|
import { requireSeatModel } from './seat-model.js';
|
|
3
|
-
import { isPatchAfterNewestTested } from './tested-version.js';
|
|
3
|
+
import { isPatchAfterNewestTested, probeVersion } from './tested-version.js';
|
|
4
|
+
import * as childProcess from 'child_process';
|
|
4
5
|
import { spawn as childSpawn, spawnSync } from 'child_process';
|
|
5
6
|
import { lstatSync, realpathSync } from 'fs';
|
|
6
7
|
import { chmod, mkdtemp, readFile, rm, writeFile } from 'fs/promises';
|
|
@@ -50,10 +51,13 @@ const parseVersion = (output) => {
|
|
|
50
51
|
return match ? match[1] : null;
|
|
51
52
|
};
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
// Async and cached per binary (tested-version.js probeVersion): a synchronous
|
|
55
|
+
// probe stalled every other seat's provider proxy on the daemon's loop. The
|
|
56
|
+
// namespace import is read at call time, so a suite that mocks child_process
|
|
57
|
+
// without execFile falls back to the real one.
|
|
58
|
+
const readVersion = (binary, env) => probeVersion(binary, {
|
|
59
|
+
env, timeoutMs: 5000, parse: parseVersion, execFileImpl: childProcess.execFile,
|
|
60
|
+
});
|
|
57
61
|
|
|
58
62
|
const resolvedBinary = (env) => {
|
|
59
63
|
const where = spawnSync('which', ['qwen'], { encoding: 'utf8', env });
|
|
@@ -75,7 +79,8 @@ const withProbeEnv = async (source, run) => {
|
|
|
75
79
|
env.QWEN_CODE_SYSTEM_SETTINGS_PATH = settingsPath;
|
|
76
80
|
env.QWEN_USAGE_STATISTICS_ENABLED = 'false';
|
|
77
81
|
for (const name of PROXY_ENV) env[name] = '';
|
|
78
|
-
|
|
82
|
+
// Awaited here, so the probe home outlives an async probe.
|
|
83
|
+
return await run(env);
|
|
79
84
|
} finally {
|
|
80
85
|
await rm(home, { recursive: true, force: true });
|
|
81
86
|
}
|
|
@@ -254,9 +259,9 @@ export default {
|
|
|
254
259
|
}
|
|
255
260
|
const keyFile = await this.validateEnvironment(ctx.environment, ctx.cwd);
|
|
256
261
|
const sourceEnv = ctx.env || process.env;
|
|
257
|
-
const { binary, version } = await withProbeEnv(sourceEnv, (probeEnv) => {
|
|
262
|
+
const { binary, version } = await withProbeEnv(sourceEnv, async (probeEnv) => {
|
|
258
263
|
const path = ctx._binaryPath || resolvedBinary(probeEnv);
|
|
259
|
-
return { binary: path, version: readVersion(path, probeEnv) };
|
|
264
|
+
return { binary: path, version: await readVersion(path, probeEnv) };
|
|
260
265
|
});
|
|
261
266
|
if (!TESTED_QWEN_VERSIONS.includes(version)) {
|
|
262
267
|
const versions = TESTED_QWEN_VERSIONS.join(', ');
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// A namespace import, read at call time: suites that mock child_process with
|
|
2
|
+
// only spawn/spawnSync still load this module.
|
|
3
|
+
import * as childProcess from 'node:child_process';
|
|
4
|
+
import { realpathSync, statSync } from 'node:fs';
|
|
5
|
+
|
|
1
6
|
// Public seats run only on a harness version smoke-tested in its sandbox, with
|
|
2
7
|
// one tolerance: a stable patch release after the newest tested one, on that
|
|
3
8
|
// same major.minor line. Harnesses ship patches every few days, and refusing
|
|
@@ -14,3 +19,36 @@ export const isPatchAfterNewestTested = (version, tested) => {
|
|
|
14
19
|
&& Number(installed[2]) === Number(newest[2])
|
|
15
20
|
&& Number(installed[3]) > Number(newest[3]);
|
|
16
21
|
};
|
|
22
|
+
|
|
23
|
+
// The harness's own `--version`, asked without blocking the event loop and
|
|
24
|
+
// remembered per binary. A daemon runs every seat in one process, beside the
|
|
25
|
+
// loopback provider proxies of other seats' live turns, so a synchronous probe
|
|
26
|
+
// stalled all of them while a cold harness started (up to its timeout).
|
|
27
|
+
//
|
|
28
|
+
// The cache key is the binary's real path; its mtime decides freshness, so a
|
|
29
|
+
// harness upgraded in place is probed again. Only a parsed version is kept: a
|
|
30
|
+
// failed or unparseable probe is asked again next turn, never remembered.
|
|
31
|
+
const versionCache = new Map();
|
|
32
|
+
|
|
33
|
+
export const probeVersion = async (binary, {
|
|
34
|
+
env, timeoutMs = 30000, parse, execFileImpl = childProcess.execFile, cache = versionCache,
|
|
35
|
+
} = {}) => {
|
|
36
|
+
let key = null;
|
|
37
|
+
let mtimeMs = null;
|
|
38
|
+
try {
|
|
39
|
+
key = realpathSync(binary);
|
|
40
|
+
mtimeMs = statSync(key).mtimeMs;
|
|
41
|
+
} catch {
|
|
42
|
+
key = null;
|
|
43
|
+
}
|
|
44
|
+
const hit = key ? cache.get(key) : null;
|
|
45
|
+
if (hit && hit.mtimeMs === mtimeMs) return hit.version;
|
|
46
|
+
const stdout = await new Promise((resolve) => {
|
|
47
|
+
execFileImpl(binary, ['--version'], { encoding: 'utf8', env, timeout: timeoutMs }, (error, out) => {
|
|
48
|
+
resolve(error ? null : out);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
const version = stdout === null ? null : parse(stdout);
|
|
52
|
+
if (version && key) cache.set(key, { mtimeMs, version });
|
|
53
|
+
return version;
|
|
54
|
+
};
|