dexto 1.6.11 → 1.6.13
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/README.md +10 -2
- package/dist/analytics/events.d.ts +1 -1
- package/dist/analytics/events.d.ts.map +1 -1
- package/dist/cli/auth/api-client.d.ts +0 -2
- package/dist/cli/auth/api-client.d.ts.map +1 -1
- package/dist/cli/auth/api-client.js +7 -11
- package/dist/cli/auth/constants.d.ts +4 -4
- package/dist/cli/auth/constants.js +4 -4
- package/dist/cli/commands/agents/install.d.ts.map +1 -0
- package/dist/cli/commands/{install.js → agents/install.js} +4 -4
- package/dist/cli/commands/{list-agents.d.ts → agents/list.d.ts} +1 -1
- package/dist/cli/commands/agents/list.d.ts.map +1 -0
- package/dist/cli/commands/{list-agents.js → agents/list.js} +2 -2
- package/dist/cli/commands/agents/register.js +5 -5
- package/dist/cli/commands/{sync-agents.d.ts → agents/sync.d.ts} +10 -2
- package/dist/cli/commands/agents/sync.d.ts.map +1 -0
- package/dist/cli/commands/{sync-agents.js → agents/sync.js} +54 -5
- package/dist/cli/commands/agents/uninstall.d.ts +18 -0
- package/dist/cli/commands/agents/uninstall.d.ts.map +1 -0
- package/dist/cli/commands/agents/uninstall.js +141 -0
- package/dist/cli/commands/deploy/client.d.ts +44 -0
- package/dist/cli/commands/deploy/client.d.ts.map +1 -0
- package/dist/cli/commands/deploy/client.js +232 -0
- package/dist/cli/commands/deploy/config.d.ts +81 -0
- package/dist/cli/commands/deploy/config.d.ts.map +1 -0
- package/dist/cli/commands/deploy/config.js +144 -0
- package/dist/cli/commands/deploy/entry-agent.d.ts +3 -0
- package/dist/cli/commands/deploy/entry-agent.d.ts.map +1 -0
- package/dist/cli/commands/deploy/entry-agent.js +22 -0
- package/dist/cli/commands/deploy/index.d.ts +9 -0
- package/dist/cli/commands/deploy/index.d.ts.map +1 -0
- package/dist/cli/commands/deploy/index.js +204 -0
- package/dist/cli/commands/deploy/links.d.ts +3 -0
- package/dist/cli/commands/deploy/links.d.ts.map +1 -0
- package/dist/cli/commands/deploy/links.js +53 -0
- package/dist/cli/commands/deploy/register.d.ts +6 -0
- package/dist/cli/commands/deploy/register.d.ts.map +1 -0
- package/dist/cli/commands/deploy/register.js +75 -0
- package/dist/cli/commands/deploy/snapshot.d.ts +12 -0
- package/dist/cli/commands/deploy/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/deploy/snapshot.js +76 -0
- package/dist/cli/commands/deploy/state.d.ts +21 -0
- package/dist/cli/commands/deploy/state.d.ts.map +1 -0
- package/dist/cli/commands/deploy/state.js +122 -0
- package/dist/cli/commands/index.d.ts +6 -4
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +6 -4
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +304 -31
- package/dist/cli/commands/uninstall.d.ts +9 -12
- package/dist/cli/commands/uninstall.d.ts.map +1 -1
- package/dist/cli/commands/uninstall.js +99 -113
- package/dist/cli/commands/upgrade.d.ts +15 -0
- package/dist/cli/commands/upgrade.d.ts.map +1 -0
- package/dist/cli/commands/upgrade.js +106 -0
- package/dist/cli/modes/cli.d.ts.map +1 -1
- package/dist/cli/modes/cli.js +0 -12
- package/dist/cli/utils/config-validation.d.ts.map +1 -1
- package/dist/cli/utils/config-validation.js +34 -20
- package/dist/cli/utils/self-management.d.ts +93 -0
- package/dist/cli/utils/self-management.d.ts.map +1 -0
- package/dist/cli/utils/self-management.js +423 -0
- package/dist/cli/utils/version-check.d.ts +1 -1
- package/dist/cli/utils/version-check.d.ts.map +1 -1
- package/dist/cli/utils/version-check.js +53 -19
- package/dist/index-main.js +59 -2
- package/dist/webui/assets/{index-CNiOYnOb.js → index-UDAdxmci.js} +187 -187
- package/dist/webui/index.html +1 -1
- package/package.json +13 -11
- package/dist/cli/commands/install.d.ts.map +0 -1
- package/dist/cli/commands/list-agents.d.ts.map +0 -1
- package/dist/cli/commands/sync-agents.d.ts.map +0 -1
- /package/dist/cli/commands/{install.d.ts → agents/install.d.ts} +0 -0
|
@@ -1,137 +1,123 @@
|
|
|
1
|
-
|
|
1
|
+
import path from 'path';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
// Zod schema for uninstall command validation
|
|
6
|
-
const UninstallCommandSchema = z
|
|
3
|
+
import { createLegacyNpmUninstallCommand, detectInstallMethod, executeManagedCommand, getDefaultNativeBinaryPath, getDextoHomePath, pathExists, removePath, scheduleDeferredWindowsRemoval, } from '../utils/self-management.js';
|
|
4
|
+
const UninstallCliCommandSchema = z
|
|
7
5
|
.object({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
force: z.boolean().default(false),
|
|
6
|
+
purge: z.boolean().default(false),
|
|
7
|
+
dryRun: z.boolean().default(false),
|
|
11
8
|
})
|
|
12
9
|
.strict();
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
async function validateUninstallCommand(agents, options) {
|
|
17
|
-
// Basic structure validation
|
|
18
|
-
const validated = UninstallCommandSchema.parse({
|
|
19
|
-
...options,
|
|
20
|
-
agents,
|
|
21
|
-
});
|
|
22
|
-
// Business logic validation
|
|
23
|
-
const installedAgents = await listInstalledAgents();
|
|
24
|
-
if (installedAgents.length === 0) {
|
|
25
|
-
throw new Error('No agents are currently installed.');
|
|
26
|
-
}
|
|
27
|
-
if (!validated.all && validated.agents.length === 0) {
|
|
28
|
-
throw new Error(`No agents specified. Use agent names or --all flag. Installed agents: ${installedAgents.join(', ')}`);
|
|
10
|
+
function printMultiInstallWarning(warning) {
|
|
11
|
+
if (!warning) {
|
|
12
|
+
return;
|
|
29
13
|
}
|
|
30
|
-
|
|
14
|
+
console.warn(`⚠️ ${warning}`);
|
|
31
15
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
16
|
+
async function removeTargets(targets, dryRun) {
|
|
17
|
+
const removed = [];
|
|
18
|
+
for (const target of targets) {
|
|
19
|
+
if (!(await pathExists(target))) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (dryRun) {
|
|
23
|
+
console.log(`[dry-run] remove ${target}`);
|
|
24
|
+
removed.push(target);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
await removePath(target);
|
|
28
|
+
removed.push(target);
|
|
39
29
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
return removed;
|
|
31
|
+
}
|
|
32
|
+
function normalizeRuntimePath(targetPath) {
|
|
33
|
+
const normalized = path.normalize(targetPath);
|
|
34
|
+
return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
|
|
35
|
+
}
|
|
36
|
+
function isCurrentExecutable(binaryPath) {
|
|
37
|
+
return normalizeRuntimePath(binaryPath) === normalizeRuntimePath(process.execPath);
|
|
38
|
+
}
|
|
39
|
+
function buildProjectLocalInstallMessage(binaryPath, action) {
|
|
40
|
+
const resolvedPath = binaryPath ?? 'node_modules/.bin/dexto';
|
|
41
|
+
return [
|
|
42
|
+
`Project-local install detected at ${resolvedPath}.`,
|
|
43
|
+
`Self-${action} is only available for native installs and legacy global npm installs.`,
|
|
44
|
+
'Use the owning project package manager instead.',
|
|
45
|
+
].join(' ');
|
|
46
|
+
}
|
|
47
|
+
export async function handleUninstallCliCommand(options) {
|
|
48
|
+
const validated = UninstallCliCommandSchema.parse(options);
|
|
49
|
+
const detection = await detectInstallMethod();
|
|
50
|
+
printMultiInstallWarning(detection.multipleInstallWarning);
|
|
51
|
+
if (detection.method === 'project-local') {
|
|
52
|
+
throw new Error(buildProjectLocalInstallMessage(detection.installedPath, 'uninstall'));
|
|
45
53
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
const dextoHomePath = getDextoHomePath();
|
|
55
|
+
let managedUninstallError = null;
|
|
56
|
+
let binaryRemovalError = null;
|
|
57
|
+
let homeRemovalDeferred = false;
|
|
58
|
+
if (detection.method === 'npm') {
|
|
59
|
+
const command = createLegacyNpmUninstallCommand();
|
|
60
|
+
console.log('🧹 Uninstalling CLI via npm...');
|
|
61
|
+
try {
|
|
62
|
+
await executeManagedCommand(command, { dryRun: validated.dryRun });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
managedUninstallError = error instanceof Error ? error : new Error(String(error));
|
|
66
|
+
console.warn(`⚠️ Package-manager uninstall failed: ${managedUninstallError.message}`);
|
|
53
67
|
}
|
|
54
68
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
let errorCount = 0;
|
|
58
|
-
const errors = [];
|
|
59
|
-
const uninstalled = [];
|
|
60
|
-
const failed = [];
|
|
61
|
-
// Uninstall each agent
|
|
62
|
-
for (const agentName of agentsToUninstall) {
|
|
69
|
+
else {
|
|
70
|
+
const binaryPath = detection.installedPath ?? getDefaultNativeBinaryPath();
|
|
63
71
|
try {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
72
|
+
if (process.platform === 'win32' &&
|
|
73
|
+
isCurrentExecutable(binaryPath) &&
|
|
74
|
+
!validated.dryRun) {
|
|
75
|
+
const deferredTargets = validated.purge
|
|
76
|
+
? [binaryPath, dextoHomePath]
|
|
77
|
+
: [binaryPath];
|
|
78
|
+
await scheduleDeferredWindowsRemoval(deferredTargets);
|
|
79
|
+
homeRemovalDeferred = validated.purge;
|
|
80
|
+
console.log('🗑️ Scheduled CLI binary removal after exit.');
|
|
81
|
+
if (validated.purge) {
|
|
82
|
+
console.log(`🗑️ Scheduled ${dextoHomePath} removal after exit.`);
|
|
83
|
+
}
|
|
76
84
|
}
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
else {
|
|
86
|
+
const removedBinaryPaths = await removeTargets([binaryPath], validated.dryRun);
|
|
87
|
+
if (removedBinaryPaths.length > 0) {
|
|
88
|
+
console.log(`🗑️ Removed CLI binary: ${removedBinaryPaths.join(', ')}`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
console.log('ℹ️ CLI binary was not found at expected path.');
|
|
92
|
+
}
|
|
79
93
|
}
|
|
80
94
|
}
|
|
81
95
|
catch (error) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
errors.push(errorMsg);
|
|
85
|
-
failed.push(agentName);
|
|
86
|
-
console.error(`❌ ${errorMsg}`);
|
|
87
|
-
// Per-agent analytics for failed uninstall
|
|
88
|
-
try {
|
|
89
|
-
capture('dexto_uninstall_agent', {
|
|
90
|
-
agent: agentName,
|
|
91
|
-
status: 'failed',
|
|
92
|
-
error_message: error instanceof Error ? error.message : String(error),
|
|
93
|
-
force: validated.force,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
// Analytics failures should not block CLI execution.
|
|
98
|
-
}
|
|
96
|
+
binaryRemovalError = error instanceof Error ? error : new Error(String(error));
|
|
97
|
+
console.warn(`⚠️ Binary removal failed: ${binaryRemovalError.message}`);
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
errorCount,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
// Analytics failures should not block CLI execution.
|
|
113
|
-
}
|
|
114
|
-
// For single agent operations, throw error if it failed (after emitting analytics)
|
|
115
|
-
if (agentsToUninstall.length === 1) {
|
|
116
|
-
if (errorCount > 0) {
|
|
117
|
-
throw new Error(errors[0]);
|
|
100
|
+
if (validated.purge && !homeRemovalDeferred) {
|
|
101
|
+
const removedHomePaths = await removeTargets([dextoHomePath], validated.dryRun);
|
|
102
|
+
if (removedHomePaths.length > 0) {
|
|
103
|
+
console.log(`🗑️ Removed ${dextoHomePath}.`);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
console.log(`ℹ️ ${dextoHomePath} was not found.`);
|
|
118
107
|
}
|
|
119
|
-
return;
|
|
120
108
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
console.log(`✅ Successfully uninstalled: ${successCount}`);
|
|
124
|
-
if (errorCount > 0) {
|
|
125
|
-
console.log(`❌ Failed to uninstall: ${errorCount}`);
|
|
126
|
-
errors.forEach((error) => console.log(` • ${error}`));
|
|
109
|
+
else if (!validated.purge) {
|
|
110
|
+
console.log(`ℹ️ Keeping ${dextoHomePath}.`);
|
|
127
111
|
}
|
|
128
|
-
if (
|
|
129
|
-
|
|
112
|
+
if (validated.dryRun) {
|
|
113
|
+
console.log('✅ Dry run completed. No files were deleted.');
|
|
114
|
+
return;
|
|
130
115
|
}
|
|
131
|
-
|
|
132
|
-
|
|
116
|
+
if (managedUninstallError) {
|
|
117
|
+
throw managedUninstallError;
|
|
133
118
|
}
|
|
134
|
-
|
|
135
|
-
|
|
119
|
+
if (binaryRemovalError) {
|
|
120
|
+
throw binaryRemovalError;
|
|
136
121
|
}
|
|
122
|
+
console.log('✅ Dexto CLI uninstall completed.');
|
|
137
123
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const UpgradeCommandSchema: z.ZodObject<{
|
|
3
|
+
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
4
|
+
force: z.ZodDefault<z.ZodBoolean>;
|
|
5
|
+
}, "strict", z.ZodTypeAny, {
|
|
6
|
+
force: boolean;
|
|
7
|
+
dryRun: boolean;
|
|
8
|
+
}, {
|
|
9
|
+
force?: boolean | undefined;
|
|
10
|
+
dryRun?: boolean | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export type UpgradeCommandOptions = z.output<typeof UpgradeCommandSchema>;
|
|
13
|
+
export declare function handleUpgradeCommand(versionArg: string | undefined, options: Partial<UpgradeCommandOptions>): Promise<void>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=upgrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,QAAA,MAAM,oBAAoB;;;;;;;;;EAKb,CAAC;AAEd,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AA+D1E,wBAAsB,oBAAoB,CACtC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,OAAO,CAAC,qBAAqB,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CAqEf"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createLegacyNpmUninstallCommand, createNativeInstallCommand, detectInstallMethod, detectUnsupportedPackageManagerFromPath, executeManagedCommand, normalizeRequestedVersion, } from '../utils/self-management.js';
|
|
3
|
+
const UpgradeCommandSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
dryRun: z.boolean().default(false),
|
|
6
|
+
force: z.boolean().default(false),
|
|
7
|
+
})
|
|
8
|
+
.strict();
|
|
9
|
+
function printMultiInstallWarning(warning) {
|
|
10
|
+
if (!warning) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
console.warn(`⚠️ ${warning}`);
|
|
14
|
+
}
|
|
15
|
+
async function runNativeUpgrade(version, installDir, options) {
|
|
16
|
+
const nativeCommand = createNativeInstallCommand({
|
|
17
|
+
version,
|
|
18
|
+
installDir,
|
|
19
|
+
force: options.force,
|
|
20
|
+
});
|
|
21
|
+
console.log('⬆️ Upgrading Dexto via native installer...');
|
|
22
|
+
await executeManagedCommand(nativeCommand, { dryRun: options.dryRun });
|
|
23
|
+
}
|
|
24
|
+
async function runHardMigrationToNative(version, options) {
|
|
25
|
+
console.log('🔁 Detected npm global install. Migrating to native installer...');
|
|
26
|
+
await runNativeUpgrade(version, null, options);
|
|
27
|
+
const uninstallCommand = createLegacyNpmUninstallCommand();
|
|
28
|
+
console.log('🧹 Removing legacy npm global install...');
|
|
29
|
+
try {
|
|
30
|
+
await executeManagedCommand(uninstallCommand, { dryRun: options.dryRun });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
34
|
+
console.warn(`⚠️ Automatic npm uninstall failed: ${message}`);
|
|
35
|
+
console.warn(`Run this command manually: ${uninstallCommand.displayCommand}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function getUnsupportedCleanupHint(manager) {
|
|
39
|
+
if (manager === 'pnpm') {
|
|
40
|
+
return 'pnpm unlink --global dexto (linked/source) or pnpm remove -g dexto (global package)';
|
|
41
|
+
}
|
|
42
|
+
return 'bun remove -g dexto';
|
|
43
|
+
}
|
|
44
|
+
function buildProjectLocalInstallMessage(binaryPath) {
|
|
45
|
+
const resolvedPath = binaryPath ?? 'node_modules/.bin/dexto';
|
|
46
|
+
return [
|
|
47
|
+
`Project-local install detected at ${resolvedPath}.`,
|
|
48
|
+
'Self-upgrade is only available for native installs and legacy global npm installs.',
|
|
49
|
+
'Use the owning project package manager instead.',
|
|
50
|
+
].join(' ');
|
|
51
|
+
}
|
|
52
|
+
export async function handleUpgradeCommand(versionArg, options) {
|
|
53
|
+
const validated = UpgradeCommandSchema.parse(options);
|
|
54
|
+
const version = normalizeRequestedVersion(versionArg);
|
|
55
|
+
const detection = await detectInstallMethod();
|
|
56
|
+
printMultiInstallWarning(detection.multipleInstallWarning);
|
|
57
|
+
if (version) {
|
|
58
|
+
console.log(`🎯 Target version: ${version}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.log('🎯 Target version: latest');
|
|
62
|
+
}
|
|
63
|
+
switch (detection.method) {
|
|
64
|
+
case 'native':
|
|
65
|
+
await runNativeUpgrade(version, detection.installDir, validated);
|
|
66
|
+
break;
|
|
67
|
+
case 'npm':
|
|
68
|
+
await runHardMigrationToNative(version, validated);
|
|
69
|
+
break;
|
|
70
|
+
case 'project-local':
|
|
71
|
+
throw new Error(buildProjectLocalInstallMessage(detection.installedPath));
|
|
72
|
+
case 'unknown':
|
|
73
|
+
default:
|
|
74
|
+
if (detection.installedPath) {
|
|
75
|
+
const unsupportedManager = detectUnsupportedPackageManagerFromPath(detection.installedPath);
|
|
76
|
+
if (unsupportedManager) {
|
|
77
|
+
console.warn(`⚠️ Active binary appears to come from ${unsupportedManager}. ` +
|
|
78
|
+
'Dexto only auto-migrates npm installs.');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
console.warn('⚠️ Could not determine install method. Falling back to native installer upgrade.');
|
|
82
|
+
await runNativeUpgrade(version, null, validated);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
const postDetection = await detectInstallMethod();
|
|
86
|
+
printMultiInstallWarning(postDetection.multipleInstallWarning);
|
|
87
|
+
if (postDetection.method !== 'native' && postDetection.installedPath) {
|
|
88
|
+
const unsupportedManager = detectUnsupportedPackageManagerFromPath(postDetection.installedPath);
|
|
89
|
+
const followUp = unsupportedManager
|
|
90
|
+
? `Run ${getUnsupportedCleanupHint(unsupportedManager)}, then run dexto upgrade again.`
|
|
91
|
+
: 'Remove the stale binary from PATH, then run dexto upgrade again.';
|
|
92
|
+
const message = `Upgrade completed, but active binary is still non-native: ${postDetection.installedPath}. ` +
|
|
93
|
+
followUp;
|
|
94
|
+
if (validated.dryRun) {
|
|
95
|
+
console.warn(`⚠️ ${message}`);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
throw new Error(message);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (validated.dryRun) {
|
|
102
|
+
console.log('✅ Dry run completed. No changes were made.');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
console.log('✅ Dexto upgrade completed.');
|
|
106
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli/modes/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli/modes/cli.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAsBpD,wBAAsB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAwKxE"}
|
package/dist/cli/modes/cli.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as p from '@clack/prompts';
|
|
2
1
|
import chalk from 'chalk';
|
|
3
2
|
import { logger } from '@dexto/core';
|
|
4
3
|
import { safeExit, ExitSignal } from '../../analytics/wrapper.js';
|
|
@@ -78,17 +77,6 @@ export async function runCliMode(context) {
|
|
|
78
77
|
cliSessionId = session.id;
|
|
79
78
|
}
|
|
80
79
|
const cliUpdateInfo = await getVersionCheckResult();
|
|
81
|
-
const { shouldPromptForSync, handleSyncAgentsCommand } = await import('../commands/sync-agents.js');
|
|
82
|
-
const needsSync = await shouldPromptForSync();
|
|
83
|
-
if (needsSync) {
|
|
84
|
-
const shouldSync = await p.confirm({
|
|
85
|
-
message: 'Agent config updates available. Sync now?',
|
|
86
|
-
initialValue: true,
|
|
87
|
-
});
|
|
88
|
-
if (!p.isCancel(shouldSync) && shouldSync) {
|
|
89
|
-
await handleSyncAgentsCommand({ force: true, quiet: true });
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
80
|
const originalConsole = {
|
|
93
81
|
log: console.log,
|
|
94
82
|
error: console.error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-validation.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/config-validation.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,oBAAoB,EAC5B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"config-validation.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/config-validation.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,oBAAoB,EAC5B,MAAM,qBAAqB,CAAC;AAc7B,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;CAClD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,WAAW,EACnB,WAAW,GAAE,OAAe,EAC5B,OAAO,CAAC,EAAE,iBAAiB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAsC3B;AAuMD;;GAEG"}
|
|
@@ -3,7 +3,7 @@ import * as p from '@clack/prompts';
|
|
|
3
3
|
import { AgentConfigSchema, } from '@dexto/agent-config';
|
|
4
4
|
import { getPrimaryApiKeyEnvVar, logger, requiresApiKey, requiresBaseURL, resolveApiKeyForProvider, } from '@dexto/core';
|
|
5
5
|
import { getGlobalPreferencesPath } from '@dexto/agent-management';
|
|
6
|
-
import { handleSyncAgentsCommand } from '../commands/sync
|
|
6
|
+
import { getBundledSyncTargetForAgentPath, handleSyncAgentsCommand, } from '../commands/agents/sync.js';
|
|
7
7
|
/**
|
|
8
8
|
* Validates agent config with optional interactive fixes for user experience.
|
|
9
9
|
* Uses schema parsing for structural validation and performs targeted credential checks.
|
|
@@ -91,39 +91,53 @@ function showCredentialWarnings(warnings) {
|
|
|
91
91
|
* Handle non-API-key validation errors interactively
|
|
92
92
|
*/
|
|
93
93
|
async function handleOtherErrors(errors, options) {
|
|
94
|
+
const syncTarget = options?.agentPath
|
|
95
|
+
? getBundledSyncTargetForAgentPath(options.agentPath)
|
|
96
|
+
: null;
|
|
94
97
|
console.log(chalk.rgb(255, 165, 0)('\n⚠️ Configuration issues detected:\n'));
|
|
95
98
|
for (const error of errors) {
|
|
96
99
|
console.log(chalk.red(` • ${error}`));
|
|
97
100
|
}
|
|
98
101
|
console.log('');
|
|
102
|
+
const selectOptions = [
|
|
103
|
+
...(syncTarget
|
|
104
|
+
? [
|
|
105
|
+
{
|
|
106
|
+
value: 'sync',
|
|
107
|
+
label: 'Sync agent config',
|
|
108
|
+
hint: `Update bundled agent '${syncTarget.agentId}' from the registry`,
|
|
109
|
+
},
|
|
110
|
+
]
|
|
111
|
+
: []),
|
|
112
|
+
{
|
|
113
|
+
value: 'skip',
|
|
114
|
+
label: 'Continue anyway',
|
|
115
|
+
hint: 'Try to start despite errors (may fail)',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
value: 'edit',
|
|
119
|
+
label: 'Edit configuration manually',
|
|
120
|
+
hint: 'Show file path and instructions',
|
|
121
|
+
},
|
|
122
|
+
];
|
|
99
123
|
const action = await p.select({
|
|
100
124
|
message: 'How would you like to proceed?',
|
|
101
|
-
options:
|
|
102
|
-
{
|
|
103
|
-
value: 'sync',
|
|
104
|
-
label: 'Sync agent config',
|
|
105
|
-
hint: 'Update from bundled registry (recommended)',
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
value: 'skip',
|
|
109
|
-
label: 'Continue anyway',
|
|
110
|
-
hint: 'Try to start despite errors (may fail)',
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
value: 'edit',
|
|
114
|
-
label: 'Edit configuration manually',
|
|
115
|
-
hint: 'Show file path and instructions',
|
|
116
|
-
},
|
|
117
|
-
],
|
|
125
|
+
options: selectOptions,
|
|
118
126
|
});
|
|
119
127
|
if (p.isCancel(action)) {
|
|
120
128
|
showNextSteps();
|
|
121
129
|
return { success: false, errors, skipped: true };
|
|
122
130
|
}
|
|
123
131
|
if (action === 'sync') {
|
|
132
|
+
if (!syncTarget) {
|
|
133
|
+
return { success: false, errors, skipped: true };
|
|
134
|
+
}
|
|
124
135
|
try {
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
await handleSyncAgentsCommand({
|
|
137
|
+
force: true,
|
|
138
|
+
quiet: false,
|
|
139
|
+
agentIds: [syncTarget.agentId],
|
|
140
|
+
});
|
|
127
141
|
// Exit after sync - user needs to restart dexto
|
|
128
142
|
p.outro(chalk.gray('Run dexto to start Dexto'));
|
|
129
143
|
process.exit(0);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export type InstallMethod = 'native' | 'npm' | 'project-local' | 'unknown';
|
|
3
|
+
export type UnsupportedPackageManager = 'pnpm' | 'bun';
|
|
4
|
+
declare const InstallMetadataSchema: z.ZodObject<{
|
|
5
|
+
schemaVersion: z.ZodDefault<z.ZodNumber>;
|
|
6
|
+
method: z.ZodEnum<["native", "npm"]>;
|
|
7
|
+
installedPath: z.ZodString;
|
|
8
|
+
installedAt: z.ZodString;
|
|
9
|
+
version: z.ZodString;
|
|
10
|
+
sourceUrl: z.ZodOptional<z.ZodString>;
|
|
11
|
+
releaseTag: z.ZodOptional<z.ZodString>;
|
|
12
|
+
platform: z.ZodOptional<z.ZodString>;
|
|
13
|
+
arch: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, "strict", z.ZodTypeAny, {
|
|
15
|
+
method: "npm" | "native";
|
|
16
|
+
version: string;
|
|
17
|
+
schemaVersion: number;
|
|
18
|
+
installedPath: string;
|
|
19
|
+
installedAt: string;
|
|
20
|
+
sourceUrl?: string | undefined;
|
|
21
|
+
releaseTag?: string | undefined;
|
|
22
|
+
platform?: string | undefined;
|
|
23
|
+
arch?: string | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
method: "npm" | "native";
|
|
26
|
+
version: string;
|
|
27
|
+
installedPath: string;
|
|
28
|
+
installedAt: string;
|
|
29
|
+
schemaVersion?: number | undefined;
|
|
30
|
+
sourceUrl?: string | undefined;
|
|
31
|
+
releaseTag?: string | undefined;
|
|
32
|
+
platform?: string | undefined;
|
|
33
|
+
arch?: string | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
export type InstallMetadata = z.output<typeof InstallMetadataSchema>;
|
|
36
|
+
interface InstallDetectionResult {
|
|
37
|
+
method: InstallMethod;
|
|
38
|
+
source: 'metadata' | 'heuristic';
|
|
39
|
+
metadata: InstallMetadata | null;
|
|
40
|
+
installedPath: string | null;
|
|
41
|
+
installDir: string | null;
|
|
42
|
+
allDetectedPaths: string[];
|
|
43
|
+
multipleInstallWarning: string | null;
|
|
44
|
+
}
|
|
45
|
+
interface DetectInstallMethodDeps {
|
|
46
|
+
readMetadata: () => Promise<InstallMetadata | null>;
|
|
47
|
+
getPathEntries: () => Promise<string[]>;
|
|
48
|
+
detectNodeManager: (binaryPath: string) => Promise<InstallMethod | null>;
|
|
49
|
+
pathExists: (targetPath: string) => Promise<boolean>;
|
|
50
|
+
}
|
|
51
|
+
interface CommandExecutionResult {
|
|
52
|
+
code: number;
|
|
53
|
+
stdout: string;
|
|
54
|
+
stderr: string;
|
|
55
|
+
}
|
|
56
|
+
interface ExecuteCommandOptions {
|
|
57
|
+
cwd?: string;
|
|
58
|
+
env?: NodeJS.ProcessEnv;
|
|
59
|
+
stdio?: 'pipe' | 'inherit';
|
|
60
|
+
}
|
|
61
|
+
interface ExecutableCommand {
|
|
62
|
+
command: string;
|
|
63
|
+
args: string[];
|
|
64
|
+
env?: NodeJS.ProcessEnv;
|
|
65
|
+
displayCommand: string;
|
|
66
|
+
}
|
|
67
|
+
export declare function executeCommand(command: string, args: string[], options?: ExecuteCommandOptions): Promise<CommandExecutionResult>;
|
|
68
|
+
export declare function executeManagedCommand(commandSpec: ExecutableCommand, options: {
|
|
69
|
+
dryRun: boolean;
|
|
70
|
+
cwd?: string;
|
|
71
|
+
}): Promise<void>;
|
|
72
|
+
export declare function getDextoHomePath(): string;
|
|
73
|
+
export declare function readInstallMetadata(): Promise<InstallMetadata | null>;
|
|
74
|
+
export declare function isProjectLocalBinaryPath(binaryPath: string): boolean;
|
|
75
|
+
export declare function detectUnsupportedPackageManagerFromPath(binaryPath: string): UnsupportedPackageManager | null;
|
|
76
|
+
export declare function buildMultipleInstallWarning(allDetectedPaths: string[], activePath: string | null): string | null;
|
|
77
|
+
export declare function detectInstallMethod(): Promise<InstallDetectionResult>;
|
|
78
|
+
export declare function detectInstallMethodWithDeps(deps?: Partial<DetectInstallMethodDeps>): Promise<InstallDetectionResult>;
|
|
79
|
+
export declare function commandDisplayWithEnvPosix(command: string, envOverrides: Record<string, string>): string;
|
|
80
|
+
export declare function commandDisplayWithEnvPowerShell(command: string, envOverrides: Record<string, string>): string;
|
|
81
|
+
export declare function createNativeInstallCommand(options: {
|
|
82
|
+
version: string | null;
|
|
83
|
+
installDir: string | null;
|
|
84
|
+
force: boolean;
|
|
85
|
+
}): ExecutableCommand;
|
|
86
|
+
export declare function createLegacyNpmUninstallCommand(): ExecutableCommand;
|
|
87
|
+
export declare function normalizeRequestedVersion(version: string | null | undefined): string | null;
|
|
88
|
+
export declare function scheduleDeferredWindowsRemoval(targetPaths: string[]): Promise<void>;
|
|
89
|
+
export declare function pathExists(targetPath: string): Promise<boolean>;
|
|
90
|
+
export declare function removePath(targetPath: string): Promise<void>;
|
|
91
|
+
export declare function getDefaultNativeBinaryPath(): string;
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=self-management.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-management.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/self-management.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,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