@open-agent-toolkit/cli 0.2.9 → 0.2.10
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/assets/public-package-versions.json +4 -4
- package/dist/app/global-cli-installer.d.ts +16 -0
- package/dist/app/global-cli-installer.d.ts.map +1 -0
- package/dist/app/global-cli-installer.js +111 -0
- package/dist/app/tool-bundle-update-guard.d.ts.map +1 -1
- package/dist/app/tool-bundle-update-guard.js +10 -22
- package/dist/app/update-notifier.d.ts.map +1 -1
- package/dist/app/update-notifier.js +4 -3
- package/package.json +2 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type GlobalCliPackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
2
|
+
export interface GlobalCliInstallerOptions {
|
|
3
|
+
argv: string[];
|
|
4
|
+
env: NodeJS.ProcessEnv;
|
|
5
|
+
platform: NodeJS.Platform;
|
|
6
|
+
nodeExecutable: string;
|
|
7
|
+
fileExists: (path: string) => boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface GlobalCliInstallerInvocation {
|
|
10
|
+
file: string;
|
|
11
|
+
args: string[];
|
|
12
|
+
}
|
|
13
|
+
export declare function detectGlobalCliPackageManager(argv: string[], env: NodeJS.ProcessEnv): GlobalCliPackageManager;
|
|
14
|
+
export declare function formatGlobalCliInstallCommand(packageSpec: string, argv: string[], env: NodeJS.ProcessEnv): string;
|
|
15
|
+
export declare function resolveGlobalCliInstallerInvocation(packageSpec: string, options: GlobalCliInstallerOptions): GlobalCliInstallerInvocation | null;
|
|
16
|
+
//# sourceMappingURL=global-cli-installer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-cli-installer.d.ts","sourceRoot":"","sources":["../../src/app/global-cli-installer.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAEtE,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACvC;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAqCD,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,uBAAuB,CAyBzB;AA0ED,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,MAAM,CAYR;AAED,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,yBAAyB,GACjC,4BAA4B,GAAG,IAAI,CAUrC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { win32 } from 'node:path';
|
|
2
|
+
function normalizePathForDetection(path) {
|
|
3
|
+
return path.replaceAll('\\', '/').toLowerCase().replace(/\/+$/, '');
|
|
4
|
+
}
|
|
5
|
+
function isUnderNormalizedPath(normalizedCandidate, normalizedHome) {
|
|
6
|
+
return (normalizedCandidate === normalizedHome ||
|
|
7
|
+
normalizedCandidate.startsWith(`${normalizedHome}/`));
|
|
8
|
+
}
|
|
9
|
+
function detectFromPath(normalizedPath) {
|
|
10
|
+
if (normalizedPath.includes('/pnpm/') || normalizedPath.includes('/.pnpm/')) {
|
|
11
|
+
return 'pnpm';
|
|
12
|
+
}
|
|
13
|
+
if (normalizedPath.includes('/.bun/') ||
|
|
14
|
+
normalizedPath.includes('/bun/install/')) {
|
|
15
|
+
return 'bun';
|
|
16
|
+
}
|
|
17
|
+
if (normalizedPath.includes('/.yarn/') ||
|
|
18
|
+
normalizedPath.includes('/yarn/global/')) {
|
|
19
|
+
return 'yarn';
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
export function detectGlobalCliPackageManager(argv, env) {
|
|
24
|
+
const candidates = argv.slice(0, 2).filter(Boolean);
|
|
25
|
+
for (const candidate of candidates) {
|
|
26
|
+
const detected = detectFromPath(normalizePathForDetection(candidate));
|
|
27
|
+
if (detected) {
|
|
28
|
+
return detected;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const pnpmHome = env.PNPM_HOME?.trim();
|
|
32
|
+
if (pnpmHome) {
|
|
33
|
+
const normalizedHome = normalizePathForDetection(pnpmHome);
|
|
34
|
+
for (const candidate of candidates) {
|
|
35
|
+
if (isUnderNormalizedPath(normalizePathForDetection(candidate), normalizedHome)) {
|
|
36
|
+
return 'pnpm';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return 'npm';
|
|
41
|
+
}
|
|
42
|
+
function installArgsForManager(manager, packageSpec) {
|
|
43
|
+
switch (manager) {
|
|
44
|
+
case 'npm':
|
|
45
|
+
return ['install', '--global', packageSpec];
|
|
46
|
+
case 'pnpm':
|
|
47
|
+
return ['add', '-g', packageSpec];
|
|
48
|
+
case 'yarn':
|
|
49
|
+
return ['global', 'add', packageSpec];
|
|
50
|
+
case 'bun':
|
|
51
|
+
return ['install', '-g', packageSpec];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function executableForManager(manager) {
|
|
55
|
+
return manager;
|
|
56
|
+
}
|
|
57
|
+
function resolveWindowsManagerInvocation(manager, packageSpec, options) {
|
|
58
|
+
if (manager === 'npm') {
|
|
59
|
+
return resolveNpmWindowsInvocation(packageSpec, options);
|
|
60
|
+
}
|
|
61
|
+
const comspec = options.env.ComSpec?.trim() || 'cmd.exe';
|
|
62
|
+
return {
|
|
63
|
+
file: comspec,
|
|
64
|
+
args: [
|
|
65
|
+
'/d',
|
|
66
|
+
'/s',
|
|
67
|
+
'/c',
|
|
68
|
+
manager,
|
|
69
|
+
...installArgsForManager(manager, packageSpec),
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function resolveNpmWindowsInvocation(packageSpec, options) {
|
|
74
|
+
const npmArgs = installArgsForManager('npm', packageSpec);
|
|
75
|
+
const environmentPath = options.env.npm_execpath?.trim();
|
|
76
|
+
const standardPath = win32.join(win32.dirname(options.nodeExecutable), 'node_modules', 'npm', 'bin', 'npm-cli.js');
|
|
77
|
+
const npmCliPath = [environmentPath, standardPath].find((candidate) => candidate !== undefined &&
|
|
78
|
+
win32.isAbsolute(candidate) &&
|
|
79
|
+
win32.basename(candidate).toLowerCase() === 'npm-cli.js' &&
|
|
80
|
+
options.fileExists(candidate));
|
|
81
|
+
if (!npmCliPath) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
file: options.nodeExecutable,
|
|
86
|
+
args: [npmCliPath, ...npmArgs],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export function formatGlobalCliInstallCommand(packageSpec, argv, env) {
|
|
90
|
+
const manager = detectGlobalCliPackageManager(argv, env);
|
|
91
|
+
switch (manager) {
|
|
92
|
+
case 'npm':
|
|
93
|
+
return `npm install --global ${packageSpec}`;
|
|
94
|
+
case 'pnpm':
|
|
95
|
+
return `pnpm add -g ${packageSpec}`;
|
|
96
|
+
case 'yarn':
|
|
97
|
+
return `yarn global add ${packageSpec}`;
|
|
98
|
+
case 'bun':
|
|
99
|
+
return `bun install -g ${packageSpec}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export function resolveGlobalCliInstallerInvocation(packageSpec, options) {
|
|
103
|
+
const manager = detectGlobalCliPackageManager(options.argv, options.env);
|
|
104
|
+
if (options.platform === 'win32') {
|
|
105
|
+
return resolveWindowsManagerInvocation(manager, packageSpec, options);
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
file: executableForManager(manager),
|
|
109
|
+
args: installArgsForManager(manager, packageSpec),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-bundle-update-guard.d.ts","sourceRoot":"","sources":["../../src/app/tool-bundle-update-guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-bundle-update-guard.d.ts","sourceRoot":"","sources":["../../src/app/tool-bundle-update-guard.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAI/D,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,aAAa,GAAG,YAAY,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,mBAAmB,CAAC;CACnC;AAED,UAAU,gBAAgB;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,iCAAiC;IAChD,yBAAyB,EAAE,CACzB,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5B,aAAa,EAAE,CACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;QAAE,WAAW,EAAE,OAAO,CAAA;KAAE,KAC9B,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,UAAU,EAAE,CACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,gBAAgB,KACtB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACvC;AA6CD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAE1D;AAgBD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,mBAAmB,CAOrB;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAMtE;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,4BAA4B,EACrC,SAAS,GAAE,OAAO,CAAC,iCAAiC,CAAM,GACzD,OAAO,CAAC,OAAO,CAAC,CA6ElB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
|
-
import {
|
|
3
|
+
import { formatGlobalCliInstallCommand, resolveGlobalCliInstallerInvocation, } from './global-cli-installer.js';
|
|
4
4
|
import { resolveUpdateAvailability } from './update-notifier.js';
|
|
5
5
|
import { confirmAction } from '../commands/shared/shared.prompts.js';
|
|
6
6
|
import { CliError } from '../errors/index.js';
|
|
@@ -67,25 +67,6 @@ export function isBundledToolMutationCommand(command) {
|
|
|
67
67
|
}
|
|
68
68
|
return path[0] === 'tools' && (path[1] === 'install' || path[1] === 'update');
|
|
69
69
|
}
|
|
70
|
-
function resolveInstallerInvocation(options, dependencies, packageVersion) {
|
|
71
|
-
const npmArgs = ['install', '--global', packageVersion];
|
|
72
|
-
if (dependencies.platform !== 'win32') {
|
|
73
|
-
return { file: 'npm', args: npmArgs };
|
|
74
|
-
}
|
|
75
|
-
const environmentPath = options.env.npm_execpath?.trim();
|
|
76
|
-
const standardPath = win32.join(win32.dirname(dependencies.nodeExecutable), 'node_modules', 'npm', 'bin', 'npm-cli.js');
|
|
77
|
-
const npmCliPath = [environmentPath, standardPath].find((candidate) => candidate !== undefined &&
|
|
78
|
-
win32.isAbsolute(candidate) &&
|
|
79
|
-
win32.basename(candidate).toLowerCase() === 'npm-cli.js' &&
|
|
80
|
-
dependencies.fileExists(candidate));
|
|
81
|
-
if (!npmCliPath) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
file: dependencies.nodeExecutable,
|
|
86
|
-
args: [npmCliPath, ...npmArgs],
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
70
|
export async function guardBundledToolMutation(options, overrides = {}) {
|
|
90
71
|
if (options.dryRun) {
|
|
91
72
|
return false;
|
|
@@ -99,7 +80,8 @@ export async function guardBundledToolMutation(options, overrides = {}) {
|
|
|
99
80
|
`bundled with the currently running CLI ${options.currentVersion}, which ` +
|
|
100
81
|
'can only install its own bundled tool versions. The available CLI may ' +
|
|
101
82
|
'bundle newer tool versions.');
|
|
102
|
-
const
|
|
83
|
+
const packageSpec = `${CLI_PACKAGE}@${availableVersion}`;
|
|
84
|
+
const installCommand = formatGlobalCliInstallCommand(packageSpec, options.argv, options.env);
|
|
103
85
|
let accepted = false;
|
|
104
86
|
try {
|
|
105
87
|
accepted = await dependencies.confirmAction(`Update the OAT CLI to ${availableVersion} before running ${options.commandPath}?`, { interactive: options.interactive });
|
|
@@ -113,7 +95,13 @@ export async function guardBundledToolMutation(options, overrides = {}) {
|
|
|
113
95
|
'versions may be older than those bundled with the available CLI.');
|
|
114
96
|
return false;
|
|
115
97
|
}
|
|
116
|
-
const invocation =
|
|
98
|
+
const invocation = resolveGlobalCliInstallerInvocation(packageSpec, {
|
|
99
|
+
argv: options.argv,
|
|
100
|
+
env: options.env,
|
|
101
|
+
platform: dependencies.platform,
|
|
102
|
+
nodeExecutable: dependencies.nodeExecutable,
|
|
103
|
+
fileExists: dependencies.fileExists,
|
|
104
|
+
});
|
|
117
105
|
if (!invocation) {
|
|
118
106
|
throw new CliError('Could not locate npm-cli.js for a shell-free Windows update. ' +
|
|
119
107
|
`No tools were changed. Run this command manually: ${installCommand}`, 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-notifier.d.ts","sourceRoot":"","sources":["../../src/app/update-notifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update-notifier.d.ts","sourceRoot":"","sources":["../../src/app/update-notifier.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAa5C,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,cAAc,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/D,KAAK,EAAE,CACL,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAC7B,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvB,mBAAmB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,WAAW,CAAC;CACzD;AAuRD,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,qBAAqB,EAC9B,SAAS,GAAE,OAAO,CAAC,0BAA0B,CAAM,GAClD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWxB;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,qBAAqB,EAC9B,SAAS,GAAE,OAAO,CAAC,0BAA0B,CAAM,GAClD,OAAO,CAAC,IAAI,CAAC,CAmCf"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFile as readFileDefault } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { formatGlobalCliInstallCommand } from './global-cli-installer.js';
|
|
3
4
|
import { readUserConfig } from '../config/oat-config.js';
|
|
4
5
|
import { atomicWriteJson } from '../fs/io.js';
|
|
5
6
|
const CHECK_TTL_MS = 24 * 60 * 60 * 1000;
|
|
@@ -145,9 +146,9 @@ function shouldNotify(cache, latestVersion, nowMs) {
|
|
|
145
146
|
return (cache.lastNotifiedVersion !== latestVersion ||
|
|
146
147
|
!isTtlFresh(cache.lastNotifiedAt, nowMs, NOTICE_TTL_MS));
|
|
147
148
|
}
|
|
148
|
-
function formatNotice(currentVersion, latestVersion) {
|
|
149
|
+
function formatNotice(currentVersion, latestVersion, argv, env) {
|
|
149
150
|
return (`Update available: ${currentVersion} → ${latestVersion}\n` +
|
|
150
|
-
|
|
151
|
+
`Run: ${formatGlobalCliInstallCommand('@open-agent-toolkit/cli@latest', argv, env)}`);
|
|
151
152
|
}
|
|
152
153
|
async function resolveUpdateAvailabilityState(options, overrides) {
|
|
153
154
|
if (!isStaticallyEligible(options)) {
|
|
@@ -230,7 +231,7 @@ export async function maybeNotifyAboutUpdate(options, overrides = {}) {
|
|
|
230
231
|
if (state.latestVersion &&
|
|
231
232
|
shouldNotify(state.cache, state.latestVersion, state.nowMs)) {
|
|
232
233
|
try {
|
|
233
|
-
options.logger.warn(formatNotice(options.currentVersion, state.latestVersion));
|
|
234
|
+
options.logger.warn(formatNotice(options.currentVersion, state.latestVersion, options.argv, options.env));
|
|
234
235
|
state.cache = {
|
|
235
236
|
...state.cache,
|
|
236
237
|
lastNotifiedAt: state.nowTimestamp,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-agent-toolkit/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Open Agent Toolkit CLI",
|
|
6
6
|
"homepage": "https://github.com/voxmedia/open-agent-toolkit/tree/main/packages/cli",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"ora": "^9.0.0",
|
|
35
35
|
"yaml": "2.8.2",
|
|
36
36
|
"zod": "^3.25.76",
|
|
37
|
-
"@open-agent-toolkit/control-plane": "0.2.
|
|
37
|
+
"@open-agent-toolkit/control-plane": "0.2.10"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^22.10.0",
|