dexto 1.14.4 → 2.0.0-beta.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/dist/cli/auth/billing.d.ts +0 -6
- package/dist/cli/auth/billing.d.ts.map +1 -1
- package/dist/cli/auth/billing.js +0 -23
- package/dist/cli/auth/constants.d.ts +3 -31
- package/dist/cli/auth/constants.d.ts.map +1 -1
- package/dist/cli/auth/constants.js +9 -33
- package/dist/cli/auth/index.d.ts +2 -9
- package/dist/cli/auth/index.d.ts.map +1 -1
- package/dist/cli/auth/index.js +2 -7
- package/dist/cli/auth/sign-in-runtime.d.ts +12 -0
- package/dist/cli/auth/sign-in-runtime.d.ts.map +1 -0
- package/dist/cli/auth/sign-in-runtime.js +59 -0
- package/dist/cli/cloud/app-scopes.d.ts +4 -0
- package/dist/cli/cloud/app-scopes.d.ts.map +1 -0
- package/dist/cli/cloud/app-scopes.js +19 -0
- package/dist/cli/cloud/command.d.ts +143 -0
- package/dist/cli/cloud/command.d.ts.map +1 -0
- package/dist/cli/cloud/command.js +202 -0
- package/dist/cli/cloud/commands/account.d.ts +11 -0
- package/dist/cli/cloud/commands/account.d.ts.map +1 -0
- package/dist/cli/cloud/commands/account.js +128 -0
- package/dist/cli/cloud/commands/agents.d.ts +3 -0
- package/dist/cli/cloud/commands/agents.d.ts.map +1 -0
- package/dist/cli/cloud/commands/agents.js +524 -0
- package/dist/cli/cloud/commands/api.d.ts +3 -0
- package/dist/cli/cloud/commands/api.d.ts.map +1 -0
- package/dist/cli/cloud/commands/api.js +26 -0
- package/dist/cli/cloud/commands/app-files.d.ts +29 -0
- package/dist/cli/cloud/commands/app-files.d.ts.map +1 -0
- package/dist/cli/cloud/commands/app-files.js +72 -0
- package/dist/cli/cloud/commands/automations.d.ts +3 -0
- package/dist/cli/cloud/commands/automations.d.ts.map +1 -0
- package/dist/cli/cloud/commands/automations.js +232 -0
- package/dist/cli/cloud/commands/chats.d.ts +3 -0
- package/dist/cli/cloud/commands/chats.d.ts.map +1 -0
- package/dist/cli/cloud/commands/chats.js +189 -0
- package/dist/cli/cloud/commands/data-deletions.d.ts +3 -0
- package/dist/cli/cloud/commands/data-deletions.d.ts.map +1 -0
- package/dist/cli/cloud/commands/data-deletions.js +54 -0
- package/dist/cli/cloud/commands/deploys.d.ts +10 -0
- package/dist/cli/cloud/commands/deploys.d.ts.map +1 -0
- package/dist/cli/cloud/commands/deploys.js +223 -0
- package/dist/cli/cloud/commands/drive.d.ts +12 -0
- package/dist/cli/cloud/commands/drive.d.ts.map +1 -0
- package/dist/cli/cloud/commands/drive.js +320 -0
- package/dist/cli/cloud/commands/files.d.ts +24 -0
- package/dist/cli/cloud/commands/files.d.ts.map +1 -0
- package/dist/cli/cloud/commands/files.js +282 -0
- package/dist/cli/cloud/commands/find.d.ts +3 -0
- package/dist/cli/cloud/commands/find.d.ts.map +1 -0
- package/dist/cli/cloud/commands/find.js +63 -0
- package/dist/cli/cloud/commands/models.d.ts +3 -0
- package/dist/cli/cloud/commands/models.d.ts.map +1 -0
- package/dist/cli/cloud/commands/models.js +248 -0
- package/dist/cli/cloud/commands/profile.d.ts +3 -0
- package/dist/cli/cloud/commands/profile.d.ts.map +1 -0
- package/dist/cli/cloud/commands/profile.js +119 -0
- package/dist/cli/cloud/commands/projects.d.ts +5 -0
- package/dist/cli/cloud/commands/projects.d.ts.map +1 -0
- package/dist/cli/cloud/commands/projects.js +66 -0
- package/dist/cli/cloud/commands/publish.d.ts +3 -0
- package/dist/cli/cloud/commands/publish.d.ts.map +1 -0
- package/dist/cli/cloud/commands/publish.js +138 -0
- package/dist/cli/cloud/commands/sandboxes.d.ts +3 -0
- package/dist/cli/cloud/commands/sandboxes.d.ts.map +1 -0
- package/dist/cli/cloud/commands/sandboxes.js +265 -0
- package/dist/cli/cloud/commands/secrets.d.ts +3 -0
- package/dist/cli/cloud/commands/secrets.d.ts.map +1 -0
- package/dist/cli/cloud/commands/secrets.js +110 -0
- package/dist/cli/cloud/commands/skills.d.ts +3 -0
- package/dist/cli/cloud/commands/skills.d.ts.map +1 -0
- package/dist/cli/cloud/commands/skills.js +202 -0
- package/dist/cli/cloud/commands/web.d.ts +3 -0
- package/dist/cli/cloud/commands/web.d.ts.map +1 -0
- package/dist/cli/cloud/commands/web.js +53 -0
- package/dist/cli/cloud/commands/workspace-apps.d.ts +58 -0
- package/dist/cli/cloud/commands/workspace-apps.d.ts.map +1 -0
- package/dist/cli/cloud/commands/workspace-apps.js +656 -0
- package/dist/cli/cloud/commands/workspace.d.ts +36 -0
- package/dist/cli/cloud/commands/workspace.d.ts.map +1 -0
- package/dist/cli/cloud/commands/workspace.js +279 -0
- package/dist/cli/cloud/connection.d.ts +33 -0
- package/dist/cli/cloud/connection.d.ts.map +1 -0
- package/dist/cli/cloud/connection.js +38 -0
- package/dist/cli/cloud/events.d.ts +63 -0
- package/dist/cli/cloud/events.d.ts.map +1 -0
- package/dist/cli/cloud/events.js +72 -0
- package/dist/cli/cloud/host.d.ts +9 -0
- package/dist/cli/cloud/host.d.ts.map +1 -0
- package/dist/cli/cloud/host.js +105 -0
- package/dist/cli/cloud/local-chats.d.ts +73 -0
- package/dist/cli/cloud/local-chats.d.ts.map +1 -0
- package/dist/cli/cloud/local-chats.js +441 -0
- package/dist/cli/cloud/output.d.ts +34 -0
- package/dist/cli/cloud/output.d.ts.map +1 -0
- package/dist/cli/cloud/output.js +76 -0
- package/dist/cli/cloud/run.d.ts +26 -0
- package/dist/cli/cloud/run.d.ts.map +1 -0
- package/dist/cli/cloud/run.js +444 -0
- package/dist/cli/cloud/runtime.d.ts +33 -0
- package/dist/cli/cloud/runtime.d.ts.map +1 -0
- package/dist/cli/cloud/runtime.js +86 -0
- package/dist/cli/cloud/tar.d.ts +9 -0
- package/dist/cli/cloud/tar.d.ts.map +1 -0
- package/dist/cli/cloud/tar.js +69 -0
- package/dist/cli/cloud/transfer.d.ts +13 -0
- package/dist/cli/cloud/transfer.d.ts.map +1 -0
- package/dist/cli/cloud/transfer.js +35 -0
- package/dist/cli/cloud/v1.d.ts +19 -0
- package/dist/cli/cloud/v1.d.ts.map +1 -0
- package/dist/cli/cloud/v1.js +65 -0
- package/dist/cli/cloud/zip.d.ts +8 -0
- package/dist/cli/cloud/zip.d.ts.map +1 -0
- package/dist/cli/cloud/zip.js +66 -0
- package/dist/cli/commands/auth/sign-in-commands.d.ts +62 -0
- package/dist/cli/commands/auth/sign-in-commands.d.ts.map +1 -0
- package/dist/cli/commands/auth/sign-in-commands.js +247 -0
- package/dist/cli/commands/auth/sign-in-context.d.ts +16 -0
- package/dist/cli/commands/auth/sign-in-context.d.ts.map +1 -0
- package/dist/cli/commands/auth/sign-in-context.js +68 -0
- package/dist/cli/commands/cloud/register.d.ts +5 -0
- package/dist/cli/commands/cloud/register.d.ts.map +1 -1
- package/dist/cli/commands/cloud/register.js +42 -24
- package/dist/cli/commands/create-app.js +5 -6
- package/dist/cli/commands/create-image.d.ts.map +1 -1
- package/dist/cli/commands/create-image.js +9 -10
- package/dist/cli/commands/index.d.ts +0 -2
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +0 -2
- package/dist/cli/commands/init.d.ts +0 -2
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +5 -26
- package/dist/cli/commands/run/headless.js +2 -2
- package/dist/cli/commands/run/output.d.ts +29 -10
- package/dist/cli/commands/run/output.d.ts.map +1 -1
- package/dist/cli/commands/run/output.js +44 -22
- package/dist/cli/commands/run/register.d.ts.map +1 -1
- package/dist/cli/commands/run/register.js +21 -9
- package/dist/cli/commands/session/register.d.ts.map +1 -1
- package/dist/cli/commands/session/register.js +51 -21
- package/dist/cli/commands/session-commands.js +1 -1
- package/dist/cli/commands/setup.js +17 -14
- package/dist/cli/help-json.d.ts +22 -0
- package/dist/cli/help-json.d.ts.map +1 -0
- package/dist/cli/help-json.js +20 -0
- package/dist/cli/modes/cli.d.ts.map +1 -1
- package/dist/cli/modes/cli.js +42 -9
- package/dist/cli/modes/server.js +8 -8
- package/dist/cli/modes/web.js +3 -3
- package/dist/cli/utils/dexto-auth-check.d.ts +1 -1
- package/dist/cli/utils/dexto-auth-check.d.ts.map +1 -1
- package/dist/cli/utils/dexto-auth-check.js +4 -5
- package/dist/cli/utils/dexto-setup.d.ts +4 -5
- package/dist/cli/utils/dexto-setup.d.ts.map +1 -1
- package/dist/cli/utils/dexto-setup.js +17 -14
- package/dist/cli/utils/provider-setup.js +1 -1
- package/dist/cli/utils/scaffolding-utils.d.ts +9 -3
- package/dist/cli/utils/scaffolding-utils.d.ts.map +1 -1
- package/dist/cli/utils/scaffolding-utils.js +48 -40
- package/dist/cli/utils/version-check.d.ts.map +1 -1
- package/dist/cli/utils/version-check.js +2 -1
- package/dist/index-main.js +33 -65
- package/package.json +8 -7
- package/dist/cli/auth/api-client.d.ts +0 -125
- package/dist/cli/auth/api-client.d.ts.map +0 -1
- package/dist/cli/auth/api-client.js +0 -585
- package/dist/cli/auth/device.d.ts +0 -14
- package/dist/cli/auth/device.d.ts.map +0 -1
- package/dist/cli/auth/device.js +0 -84
- package/dist/cli/auth/dexto-api-key.d.ts +0 -34
- package/dist/cli/auth/dexto-api-key.d.ts.map +0 -1
- package/dist/cli/auth/dexto-api-key.js +0 -160
- package/dist/cli/auth/login-persistence.d.ts +0 -15
- package/dist/cli/auth/login-persistence.d.ts.map +0 -1
- package/dist/cli/auth/login-persistence.js +0 -72
- package/dist/cli/auth/oauth.d.ts +0 -39
- package/dist/cli/auth/oauth.d.ts.map +0 -1
- package/dist/cli/auth/oauth.js +0 -434
- package/dist/cli/auth/service.d.ts +0 -24
- package/dist/cli/auth/service.d.ts.map +0 -1
- package/dist/cli/auth/service.js +0 -161
- package/dist/cli/auth/types.d.ts +0 -11
- package/dist/cli/auth/types.d.ts.map +0 -1
- package/dist/cli/auth/types.js +0 -1
- package/dist/cli/cloud-chat.d.ts +0 -18
- package/dist/cli/cloud-chat.d.ts.map +0 -1
- package/dist/cli/cloud-chat.js +0 -734
- package/dist/cli/commands/auth/index.d.ts +0 -4
- package/dist/cli/commands/auth/index.d.ts.map +0 -1
- package/dist/cli/commands/auth/index.js +0 -4
- package/dist/cli/commands/auth/login.d.ts +0 -12
- package/dist/cli/commands/auth/login.d.ts.map +0 -1
- package/dist/cli/commands/auth/login.js +0 -153
- package/dist/cli/commands/auth/logout.d.ts +0 -5
- package/dist/cli/commands/auth/logout.d.ts.map +0 -1
- package/dist/cli/commands/auth/logout.js +0 -81
- package/dist/cli/commands/auth/register.d.ts +0 -3
- package/dist/cli/commands/auth/register.d.ts.map +0 -1
- package/dist/cli/commands/auth/register.js +0 -96
- package/dist/cli/commands/auth/status.d.ts +0 -2
- package/dist/cli/commands/auth/status.d.ts.map +0 -1
- package/dist/cli/commands/auth/status.js +0 -22
- package/dist/cli/commands/billing/index.d.ts +0 -2
- package/dist/cli/commands/billing/index.d.ts.map +0 -1
- package/dist/cli/commands/billing/index.js +0 -2
- package/dist/cli/commands/billing/register.d.ts +0 -3
- package/dist/cli/commands/billing/register.d.ts.map +0 -1
- package/dist/cli/commands/billing/register.js +0 -20
- package/dist/cli/commands/billing/status.d.ts +0 -8
- package/dist/cli/commands/billing/status.d.ts.map +0 -1
- package/dist/cli/commands/billing/status.js +0 -71
- package/dist/cli/commands/cloud/discovery.d.ts +0 -17
- package/dist/cli/commands/cloud/discovery.d.ts.map +0 -1
- package/dist/cli/commands/cloud/discovery.js +0 -88
- package/dist/cli/commands/deploy/client.d.ts +0 -113
- package/dist/cli/commands/deploy/client.d.ts.map +0 -1
- package/dist/cli/commands/deploy/client.js +0 -519
- package/dist/cli/commands/deploy/config.d.ts +0 -37
- package/dist/cli/commands/deploy/config.d.ts.map +0 -1
- package/dist/cli/commands/deploy/config.js +0 -144
- package/dist/cli/commands/deploy/entry-agent.d.ts +0 -3
- package/dist/cli/commands/deploy/entry-agent.d.ts.map +0 -1
- package/dist/cli/commands/deploy/entry-agent.js +0 -70
- package/dist/cli/commands/deploy/index.d.ts +0 -12
- package/dist/cli/commands/deploy/index.d.ts.map +0 -1
- package/dist/cli/commands/deploy/index.js +0 -370
- package/dist/cli/commands/deploy/links.d.ts +0 -3
- package/dist/cli/commands/deploy/links.d.ts.map +0 -1
- package/dist/cli/commands/deploy/links.js +0 -53
- package/dist/cli/commands/deploy/register.d.ts +0 -6
- package/dist/cli/commands/deploy/register.d.ts.map +0 -1
- package/dist/cli/commands/deploy/register.js +0 -128
- package/dist/cli/commands/deploy/snapshot.d.ts +0 -12
- package/dist/cli/commands/deploy/snapshot.d.ts.map +0 -1
- package/dist/cli/commands/deploy/snapshot.js +0 -76
- package/dist/cli/commands/deploy/state.d.ts +0 -13
- package/dist/cli/commands/deploy/state.d.ts.map +0 -1
- package/dist/cli/commands/deploy/state.js +0 -122
- package/dist/cli/commands/span/register.d.ts +0 -6
- package/dist/cli/commands/span/register.d.ts.map +0 -1
- package/dist/cli/commands/span/register.js +0 -25
- package/dist/cli/commands/trace/client.d.ts +0 -98
- package/dist/cli/commands/trace/client.d.ts.map +0 -1
- package/dist/cli/commands/trace/client.js +0 -150
- package/dist/cli/commands/trace/format.d.ts +0 -5
- package/dist/cli/commands/trace/format.d.ts.map +0 -1
- package/dist/cli/commands/trace/format.js +0 -58
- package/dist/cli/commands/trace/index.d.ts +0 -21
- package/dist/cli/commands/trace/index.d.ts.map +0 -1
- package/dist/cli/commands/trace/index.js +0 -49
- package/dist/cli/commands/trace/register.d.ts +0 -6
- package/dist/cli/commands/trace/register.d.ts.map +0 -1
- package/dist/cli/commands/trace/register.js +0 -71
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { existsSync, promises as fs } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
export const DEPLOY_CONFIG_RELATIVE_PATH = path.join('.dexto', 'deploy.json');
|
|
5
|
-
export const DEFAULT_DEPLOY_EXCLUDES = [
|
|
6
|
-
'.git',
|
|
7
|
-
'node_modules',
|
|
8
|
-
'dist',
|
|
9
|
-
'.next',
|
|
10
|
-
'.turbo',
|
|
11
|
-
'.env*',
|
|
12
|
-
];
|
|
13
|
-
export function normalizeWorkspaceRelativePath(value) {
|
|
14
|
-
const trimmed = value.trim().replace(/\\/g, '/');
|
|
15
|
-
if (trimmed.length === 0) {
|
|
16
|
-
throw new Error('Path must not be empty');
|
|
17
|
-
}
|
|
18
|
-
if (path.posix.isAbsolute(trimmed)) {
|
|
19
|
-
throw new Error('Path must be relative to the workspace root');
|
|
20
|
-
}
|
|
21
|
-
const normalized = path.posix.normalize(trimmed);
|
|
22
|
-
if (normalized === '.' || normalized.length === 0) {
|
|
23
|
-
throw new Error('Path must point to a file inside the workspace');
|
|
24
|
-
}
|
|
25
|
-
if (normalized === '..' || normalized.startsWith('../')) {
|
|
26
|
-
throw new Error('Path must stay inside the workspace');
|
|
27
|
-
}
|
|
28
|
-
return normalized;
|
|
29
|
-
}
|
|
30
|
-
const WorkspaceRelativePathSchema = z
|
|
31
|
-
.string()
|
|
32
|
-
.trim()
|
|
33
|
-
.min(1)
|
|
34
|
-
.transform((value, ctx) => {
|
|
35
|
-
try {
|
|
36
|
-
return normalizeWorkspaceRelativePath(value);
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
ctx.addIssue({
|
|
40
|
-
code: z.ZodIssueCode.custom,
|
|
41
|
-
message: error instanceof Error ? error.message : 'Invalid workspace-relative path',
|
|
42
|
-
});
|
|
43
|
-
return z.NEVER;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const CloudDefaultDeployAgentSchema = z
|
|
47
|
-
.object({
|
|
48
|
-
type: z.literal('cloud-default'),
|
|
49
|
-
})
|
|
50
|
-
.strict();
|
|
51
|
-
const WorkspaceDeployAgentSchema = z
|
|
52
|
-
.object({
|
|
53
|
-
type: z.literal('workspace'),
|
|
54
|
-
path: WorkspaceRelativePathSchema.describe('Repo-relative path to the agent YAML that should boot in cloud'),
|
|
55
|
-
})
|
|
56
|
-
.strict();
|
|
57
|
-
export const DeployAgentSchema = z.discriminatedUnion('type', [
|
|
58
|
-
CloudDefaultDeployAgentSchema,
|
|
59
|
-
WorkspaceDeployAgentSchema,
|
|
60
|
-
]);
|
|
61
|
-
export const DeployConfigSchema = z
|
|
62
|
-
.object({
|
|
63
|
-
version: z.literal(1).default(1),
|
|
64
|
-
agent: DeployAgentSchema,
|
|
65
|
-
exclude: z.array(z.string().trim().min(1)).default([...DEFAULT_DEPLOY_EXCLUDES]),
|
|
66
|
-
})
|
|
67
|
-
.strict();
|
|
68
|
-
const LegacyDeployConfigSchema = z
|
|
69
|
-
.object({
|
|
70
|
-
version: z.literal(1).default(1),
|
|
71
|
-
entryAgent: WorkspaceRelativePathSchema.describe('Repo-relative path to the agent YAML that should boot in cloud'),
|
|
72
|
-
exclude: z.array(z.string().trim().min(1)).default([...DEFAULT_DEPLOY_EXCLUDES]),
|
|
73
|
-
})
|
|
74
|
-
.strict();
|
|
75
|
-
export function getDeployConfigPath(workspaceRoot) {
|
|
76
|
-
return path.join(workspaceRoot, DEPLOY_CONFIG_RELATIVE_PATH);
|
|
77
|
-
}
|
|
78
|
-
export async function loadDeployConfig(workspaceRoot) {
|
|
79
|
-
const configPath = getDeployConfigPath(workspaceRoot);
|
|
80
|
-
if (!existsSync(configPath)) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
const raw = await fs.readFile(configPath, 'utf8');
|
|
84
|
-
let parsed;
|
|
85
|
-
try {
|
|
86
|
-
parsed = JSON.parse(raw);
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
throw new Error(`Failed to parse deploy config at ${configPath}: ${error instanceof Error ? error.message : 'Invalid JSON'}`);
|
|
90
|
-
}
|
|
91
|
-
return parseDeployConfig(parsed);
|
|
92
|
-
}
|
|
93
|
-
export async function saveDeployConfig(workspaceRoot, config) {
|
|
94
|
-
const normalized = DeployConfigSchema.parse(config);
|
|
95
|
-
const configPath = getDeployConfigPath(workspaceRoot);
|
|
96
|
-
await fs.mkdir(path.dirname(configPath), { recursive: true });
|
|
97
|
-
await fs.writeFile(configPath, `${JSON.stringify(normalized, null, 2)}\n`, 'utf8');
|
|
98
|
-
return normalized;
|
|
99
|
-
}
|
|
100
|
-
function parseDeployConfig(value) {
|
|
101
|
-
const parsed = DeployConfigSchema.safeParse(value);
|
|
102
|
-
if (parsed.success) {
|
|
103
|
-
return parsed.data;
|
|
104
|
-
}
|
|
105
|
-
const legacyParsed = LegacyDeployConfigSchema.safeParse(value);
|
|
106
|
-
if (legacyParsed.success) {
|
|
107
|
-
return createWorkspaceDeployConfig(legacyParsed.data.entryAgent, legacyParsed.data.exclude);
|
|
108
|
-
}
|
|
109
|
-
throw parsed.error;
|
|
110
|
-
}
|
|
111
|
-
export function createCloudDefaultDeployConfig(exclude = DEFAULT_DEPLOY_EXCLUDES) {
|
|
112
|
-
return DeployConfigSchema.parse({
|
|
113
|
-
version: 1,
|
|
114
|
-
agent: {
|
|
115
|
-
type: 'cloud-default',
|
|
116
|
-
},
|
|
117
|
-
exclude: [...exclude],
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
export function createWorkspaceDeployConfig(agentPath, exclude = DEFAULT_DEPLOY_EXCLUDES) {
|
|
121
|
-
return DeployConfigSchema.parse({
|
|
122
|
-
version: 1,
|
|
123
|
-
agent: {
|
|
124
|
-
type: 'workspace',
|
|
125
|
-
path: agentPath,
|
|
126
|
-
},
|
|
127
|
-
exclude: [...exclude],
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
export function isWorkspaceDeployAgent(agent) {
|
|
131
|
-
return agent.type === 'workspace';
|
|
132
|
-
}
|
|
133
|
-
export function resolveWorkspaceDeployAgentPath(workspaceRoot, agentPath) {
|
|
134
|
-
const normalizedAgentPath = normalizeWorkspaceRelativePath(agentPath);
|
|
135
|
-
const resolvedPath = path.resolve(workspaceRoot, normalizedAgentPath);
|
|
136
|
-
const relativeToWorkspace = path.relative(path.resolve(workspaceRoot), resolvedPath);
|
|
137
|
-
if (relativeToWorkspace.length === 0 ||
|
|
138
|
-
relativeToWorkspace === '..' ||
|
|
139
|
-
relativeToWorkspace.startsWith(`..${path.sep}`) ||
|
|
140
|
-
path.isAbsolute(relativeToWorkspace)) {
|
|
141
|
-
throw new Error(`Workspace agent path must stay inside the workspace: ${agentPath}`);
|
|
142
|
-
}
|
|
143
|
-
return resolvedPath;
|
|
144
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry-agent.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy/entry-agent.ts"],"names":[],"mappings":"AAiFA,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAsB,6BAA6B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAuBjG"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { findProjectRegistryPath, getDefaultProjectRegistryEntry, readProjectRegistry, } from '@dexto/agent-management';
|
|
2
|
-
import { existsSync, promises as fs } from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { normalizeWorkspaceRelativePath } from './config.js';
|
|
5
|
-
const PRIMARY_WORKSPACE_AGENT_PATHS = [
|
|
6
|
-
path.join('agents', 'coding-agent', 'coding-agent.yml'),
|
|
7
|
-
path.join('agents', 'coding-agent', 'coding-agent.yaml'),
|
|
8
|
-
path.join('agents', 'coding-agent.yml'),
|
|
9
|
-
path.join('agents', 'coding-agent.yaml'),
|
|
10
|
-
];
|
|
11
|
-
async function loadWorkspaceProjectRegistry(workspaceRoot) {
|
|
12
|
-
const registryPath = await findProjectRegistryPath(workspaceRoot);
|
|
13
|
-
if (!registryPath) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const registry = await readProjectRegistry(registryPath);
|
|
17
|
-
const defaultEntry = getDefaultProjectRegistryEntry(registry, registryPath);
|
|
18
|
-
if (!defaultEntry) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
registryPath,
|
|
23
|
-
defaultConfigPath: await resolveWorkspaceRegistryConfigPath(workspaceRoot, registryPath, defaultEntry.configPath, defaultEntry.id),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
async function resolveWorkspaceRegistryConfigPath(workspaceRoot, registryPath, configPath, agentId) {
|
|
27
|
-
const normalizedPath = normalizeWorkspaceRelativePath(configPath);
|
|
28
|
-
const absolutePath = path.resolve(path.dirname(registryPath), normalizedPath);
|
|
29
|
-
const relativeToWorkspace = path.relative(workspaceRoot, absolutePath);
|
|
30
|
-
if (relativeToWorkspace.startsWith('..') ||
|
|
31
|
-
path.isAbsolute(relativeToWorkspace) ||
|
|
32
|
-
relativeToWorkspace === '') {
|
|
33
|
-
throw new Error(`Agent '${agentId}' in ${registryPath} has invalid configPath '${configPath}': path must stay inside the workspace root.`);
|
|
34
|
-
}
|
|
35
|
-
let stat;
|
|
36
|
-
try {
|
|
37
|
-
stat = await fs.stat(absolutePath);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
if (error.code === 'ENOENT') {
|
|
41
|
-
throw new Error(`Agent '${agentId}' in ${registryPath} has invalid configPath '${configPath}': file does not exist.`);
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
if (!stat.isFile()) {
|
|
46
|
-
throw new Error(`Agent '${agentId}' in ${registryPath} has invalid configPath '${configPath}': path must point to a file.`);
|
|
47
|
-
}
|
|
48
|
-
return absolutePath;
|
|
49
|
-
}
|
|
50
|
-
export function isAgentYamlPath(filePath) {
|
|
51
|
-
return /\.(ya?ml)$/i.test(filePath);
|
|
52
|
-
}
|
|
53
|
-
export async function discoverPrimaryWorkspaceAgent(workspaceRoot) {
|
|
54
|
-
const loadedRegistry = await loadWorkspaceProjectRegistry(workspaceRoot);
|
|
55
|
-
if (loadedRegistry) {
|
|
56
|
-
return normalizeWorkspaceRelativePath(path.relative(workspaceRoot, loadedRegistry.defaultConfigPath).replace(/\\/g, '/'));
|
|
57
|
-
}
|
|
58
|
-
for (const relativePath of PRIMARY_WORKSPACE_AGENT_PATHS) {
|
|
59
|
-
const absolutePath = path.join(workspaceRoot, relativePath);
|
|
60
|
-
if (!existsSync(absolutePath)) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
const stat = await fs.stat(absolutePath);
|
|
64
|
-
if (!stat.isFile()) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
return normalizeWorkspaceRelativePath(relativePath);
|
|
68
|
-
}
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface InteractiveOptions {
|
|
2
|
-
interactive?: boolean;
|
|
3
|
-
}
|
|
4
|
-
export declare function handleDeployCommand(options?: InteractiveOptions): Promise<void>;
|
|
5
|
-
export declare function handleDeployListCommand(): Promise<void>;
|
|
6
|
-
export declare function handleDeployOpenCommand(): Promise<void>;
|
|
7
|
-
export declare function handleDeployStatusCommand(): Promise<void>;
|
|
8
|
-
export declare function handleDeployStopCommand(): Promise<void>;
|
|
9
|
-
export declare function handleDeployDeleteCommand(options?: InteractiveOptions): Promise<void>;
|
|
10
|
-
export declare function handleDeployChatCommand(cloudAgentId?: string): Promise<void>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy/index.ts"],"names":[],"mappings":"AA6BA,UAAU,kBAAkB;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AA4MD,wBAAsB,mBAAmB,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8ErF;AAED,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiD7D;AAED,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAqB7D;AAED,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAkB/D;AAED,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4B7D;AAED,wBAAsB,yBAAyB,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2C3F;AAED,wBAAsB,uBAAuB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOlF"}
|
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import * as p from '@clack/prompts';
|
|
4
|
-
import { findDextoProjectRoot, loadAgentConfig } from '@dexto/agent-management';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import open from 'open';
|
|
7
|
-
import { confirmOrExit } from '../../utils/prompt-helpers.js';
|
|
8
|
-
import { validateAgentConfig } from '../../utils/config-validation.js';
|
|
9
|
-
import { createCloudDefaultDeployConfig, createWorkspaceDeployConfig, getDeployConfigPath, isWorkspaceDeployAgent, loadDeployConfig, resolveWorkspaceDeployAgentPath, saveDeployConfig, } from './config.js';
|
|
10
|
-
import { createDeployClient } from './client.js';
|
|
11
|
-
import { discoverPrimaryWorkspaceAgent, isAgentYamlPath } from './entry-agent.js';
|
|
12
|
-
import { getCloudAgentDashboardUrl } from './links.js';
|
|
13
|
-
import { loadWorkspaceDeployLink, removeWorkspaceDeployLink, saveWorkspaceDeployLink, } from './state.js';
|
|
14
|
-
import { createWorkspaceSnapshot } from './snapshot.js';
|
|
15
|
-
import { startCloudChatCli } from '../../cloud-chat.js';
|
|
16
|
-
function isInteractive(options) {
|
|
17
|
-
return options?.interactive !== false;
|
|
18
|
-
}
|
|
19
|
-
function describeDeployAgent(config) {
|
|
20
|
-
if (isWorkspaceDeployAgent(config.agent)) {
|
|
21
|
-
return `workspace agent (${config.agent.path})`;
|
|
22
|
-
}
|
|
23
|
-
return 'default cloud agent';
|
|
24
|
-
}
|
|
25
|
-
function formatCloudAgentSummary(input) {
|
|
26
|
-
return [
|
|
27
|
-
`Cloud agent: ${input.cloudAgentId}`,
|
|
28
|
-
`Status: ${input.status}`,
|
|
29
|
-
`Agent URL: ${input.agentUrl}`,
|
|
30
|
-
`Dashboard: ${getCloudAgentDashboardUrl(input.cloudAgentId)}`,
|
|
31
|
-
].join('\n');
|
|
32
|
-
}
|
|
33
|
-
function getErrorMessage(error) {
|
|
34
|
-
return error instanceof Error ? error.message : String(error);
|
|
35
|
-
}
|
|
36
|
-
function formatCloudAgentStatus(status) {
|
|
37
|
-
switch (status) {
|
|
38
|
-
case 'ready':
|
|
39
|
-
return chalk.green(status);
|
|
40
|
-
case 'stopped':
|
|
41
|
-
return chalk.yellow(status);
|
|
42
|
-
case 'failed':
|
|
43
|
-
case 'deleted':
|
|
44
|
-
return chalk.red(status);
|
|
45
|
-
default:
|
|
46
|
-
return chalk.cyan(status);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function formatCloudAgentListItem(cloudAgent, linkedToWorkspace) {
|
|
50
|
-
const prefix = linkedToWorkspace ? chalk.green('→') : ' ';
|
|
51
|
-
const trimmedName = cloudAgent.name?.trim();
|
|
52
|
-
const heading = trimmedName && trimmedName !== cloudAgent.cloudAgentId
|
|
53
|
-
? `${chalk.cyan(trimmedName)} ${chalk.gray(`(${cloudAgent.cloudAgentId})`)}`
|
|
54
|
-
: chalk.cyan(cloudAgent.cloudAgentId);
|
|
55
|
-
const status = `${chalk.gray('[')}${formatCloudAgentStatus(cloudAgent.state.status)}${chalk.gray(']')}`;
|
|
56
|
-
const lines = [`${prefix} ${heading} ${status}`];
|
|
57
|
-
if (linkedToWorkspace) {
|
|
58
|
-
lines.push(` ${chalk.green('Linked to this workspace')}`);
|
|
59
|
-
}
|
|
60
|
-
return lines.join('\n');
|
|
61
|
-
}
|
|
62
|
-
function formatCloudAgentSelectionLabel(cloudAgent) {
|
|
63
|
-
const trimmedName = cloudAgent.name?.trim();
|
|
64
|
-
const heading = trimmedName && trimmedName !== cloudAgent.cloudAgentId
|
|
65
|
-
? `${trimmedName} (${cloudAgent.cloudAgentId})`
|
|
66
|
-
: cloudAgent.cloudAgentId;
|
|
67
|
-
return `${heading} ${chalk.gray('[')}${formatCloudAgentStatus(cloudAgent.state.status)}${chalk.gray(']')}`;
|
|
68
|
-
}
|
|
69
|
-
function sortCloudAgentsForChat(cloudAgents, linkedCloudAgentId) {
|
|
70
|
-
return cloudAgents.slice().sort((left, right) => {
|
|
71
|
-
const leftIsLinked = linkedCloudAgentId !== null && left.cloudAgentId === linkedCloudAgentId;
|
|
72
|
-
const rightIsLinked = linkedCloudAgentId !== null && right.cloudAgentId === linkedCloudAgentId;
|
|
73
|
-
if (leftIsLinked !== rightIsLinked) {
|
|
74
|
-
return leftIsLinked ? -1 : 1;
|
|
75
|
-
}
|
|
76
|
-
const leftReady = left.state.status === 'ready';
|
|
77
|
-
const rightReady = right.state.status === 'ready';
|
|
78
|
-
if (leftReady !== rightReady) {
|
|
79
|
-
return leftReady ? -1 : 1;
|
|
80
|
-
}
|
|
81
|
-
const leftName = (left.name?.trim() || left.cloudAgentId).toLowerCase();
|
|
82
|
-
const rightName = (right.name?.trim() || right.cloudAgentId).toLowerCase();
|
|
83
|
-
return leftName.localeCompare(rightName);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
async function selectCloudAgentForChat(workspaceRoot) {
|
|
87
|
-
const deployLink = await loadWorkspaceDeployLink(workspaceRoot);
|
|
88
|
-
const spinner = p.spinner();
|
|
89
|
-
spinner.start('Loading cloud agents...');
|
|
90
|
-
const client = createDeployClient();
|
|
91
|
-
let cloudAgents;
|
|
92
|
-
try {
|
|
93
|
-
cloudAgents = await client.listCloudAgents();
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
spinner.stop(chalk.red('✗ Failed to load cloud agents'));
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
spinner.stop(chalk.green('✓ Cloud agents loaded'));
|
|
100
|
-
if (cloudAgents.length === 0) {
|
|
101
|
-
throw new Error('No cloud agents available yet. Run `dexto deploy` first, or pass a cloud agent ID explicitly.');
|
|
102
|
-
}
|
|
103
|
-
const linkedCloudAgentId = deployLink?.cloudAgentId ?? null;
|
|
104
|
-
const sortedCloudAgents = sortCloudAgentsForChat(cloudAgents, linkedCloudAgentId);
|
|
105
|
-
const selected = await p.select({
|
|
106
|
-
message: 'Choose a cloud agent to chat with',
|
|
107
|
-
options: sortedCloudAgents.map((cloudAgent) => {
|
|
108
|
-
const isLinked = linkedCloudAgentId !== null && cloudAgent.cloudAgentId === linkedCloudAgentId;
|
|
109
|
-
const hintParts = [cloudAgent.agentUrl];
|
|
110
|
-
if (isLinked) {
|
|
111
|
-
hintParts.unshift('Linked to this workspace');
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
value: cloudAgent.cloudAgentId,
|
|
115
|
-
label: formatCloudAgentSelectionLabel(cloudAgent),
|
|
116
|
-
hint: hintParts.join(' • '),
|
|
117
|
-
};
|
|
118
|
-
}),
|
|
119
|
-
});
|
|
120
|
-
if (p.isCancel(selected)) {
|
|
121
|
-
p.cancel('Cloud chat cancelled');
|
|
122
|
-
process.exit(0);
|
|
123
|
-
}
|
|
124
|
-
return selected;
|
|
125
|
-
}
|
|
126
|
-
function resolveWorkspaceRoot() {
|
|
127
|
-
return findDextoProjectRoot(process.cwd()) ?? process.cwd();
|
|
128
|
-
}
|
|
129
|
-
async function resolveDeployConfig(workspaceRoot) {
|
|
130
|
-
const existingConfig = await loadDeployConfig(workspaceRoot);
|
|
131
|
-
if (existingConfig) {
|
|
132
|
-
return existingConfig;
|
|
133
|
-
}
|
|
134
|
-
const primaryWorkspaceAgent = await discoverPrimaryWorkspaceAgent(workspaceRoot);
|
|
135
|
-
const nextConfig = primaryWorkspaceAgent
|
|
136
|
-
? createWorkspaceDeployConfig(primaryWorkspaceAgent)
|
|
137
|
-
: createCloudDefaultDeployConfig();
|
|
138
|
-
await saveDeployConfig(workspaceRoot, nextConfig);
|
|
139
|
-
p.note(`${describeDeployAgent(nextConfig)}\n${path.relative(workspaceRoot, getDeployConfigPath(workspaceRoot))}`, 'Saved deploy config');
|
|
140
|
-
return nextConfig;
|
|
141
|
-
}
|
|
142
|
-
function ensureWorkspaceAgentExists(workspaceRoot, config) {
|
|
143
|
-
if (!isWorkspaceDeployAgent(config.agent)) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
const entryAgentPath = resolveWorkspaceDeployAgentPath(workspaceRoot, config.agent.path);
|
|
147
|
-
if (!existsSync(entryAgentPath)) {
|
|
148
|
-
throw new Error(`Workspace agent not found: ${config.agent.path}. Update ${path.relative(workspaceRoot, getDeployConfigPath(workspaceRoot))} before deploying.`);
|
|
149
|
-
}
|
|
150
|
-
if (!isAgentYamlPath(config.agent.path)) {
|
|
151
|
-
throw new Error(`Workspace agent must be a .yml or .yaml file: ${config.agent.path}`);
|
|
152
|
-
}
|
|
153
|
-
return entryAgentPath;
|
|
154
|
-
}
|
|
155
|
-
async function validateWorkspaceAgent(entryAgentPath, workspaceAgentPath) {
|
|
156
|
-
const config = await loadAgentConfig(entryAgentPath);
|
|
157
|
-
const validation = await validateAgentConfig(config, false, {
|
|
158
|
-
agentPath: workspaceAgentPath,
|
|
159
|
-
credentialPolicy: 'error',
|
|
160
|
-
});
|
|
161
|
-
if (!validation.success) {
|
|
162
|
-
throw new Error(`Workspace agent validation failed for ${workspaceAgentPath}. Fix the issues above before deploying.`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
export async function handleDeployCommand(options) {
|
|
166
|
-
void options;
|
|
167
|
-
p.intro(chalk.inverse('Deploy Workspace'));
|
|
168
|
-
const workspaceRoot = resolveWorkspaceRoot();
|
|
169
|
-
const deployConfig = await resolveDeployConfig(workspaceRoot);
|
|
170
|
-
const entryAgentPath = ensureWorkspaceAgentExists(workspaceRoot, deployConfig);
|
|
171
|
-
if (entryAgentPath && isWorkspaceDeployAgent(deployConfig.agent)) {
|
|
172
|
-
await validateWorkspaceAgent(entryAgentPath, deployConfig.agent.path);
|
|
173
|
-
}
|
|
174
|
-
const deployLink = await loadWorkspaceDeployLink(workspaceRoot);
|
|
175
|
-
const spinner = p.spinner();
|
|
176
|
-
const client = createDeployClient();
|
|
177
|
-
const workspaceSnapshotInput = isWorkspaceDeployAgent(deployConfig.agent)
|
|
178
|
-
? {
|
|
179
|
-
workspaceRoot,
|
|
180
|
-
workspaceAgentPath: deployConfig.agent.path,
|
|
181
|
-
exclude: deployConfig.exclude,
|
|
182
|
-
}
|
|
183
|
-
: {
|
|
184
|
-
workspaceRoot,
|
|
185
|
-
exclude: deployConfig.exclude,
|
|
186
|
-
};
|
|
187
|
-
let snapshot = null;
|
|
188
|
-
try {
|
|
189
|
-
spinner.start('Packaging workspace snapshot...');
|
|
190
|
-
snapshot = await createWorkspaceSnapshot({
|
|
191
|
-
...workspaceSnapshotInput,
|
|
192
|
-
});
|
|
193
|
-
spinner.message('Uploading workspace and provisioning sandbox...');
|
|
194
|
-
const deployed = await client.deployWorkspace({
|
|
195
|
-
agent: deployConfig.agent,
|
|
196
|
-
snapshotPath: snapshot.archivePath,
|
|
197
|
-
...(deployLink?.cloudAgentId ? { cloudAgentId: deployLink.cloudAgentId } : {}),
|
|
198
|
-
});
|
|
199
|
-
let linkSyncError = null;
|
|
200
|
-
try {
|
|
201
|
-
await saveWorkspaceDeployLink(workspaceRoot, {
|
|
202
|
-
cloudAgentId: deployed.cloudAgentId,
|
|
203
|
-
agentUrl: deployed.agentUrl,
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
catch (error) {
|
|
207
|
-
linkSyncError = error;
|
|
208
|
-
}
|
|
209
|
-
spinner.stop(chalk.green('✓ Workspace deployed'));
|
|
210
|
-
p.outro([
|
|
211
|
-
formatCloudAgentSummary({
|
|
212
|
-
cloudAgentId: deployed.cloudAgentId,
|
|
213
|
-
status: deployed.state.status,
|
|
214
|
-
agentUrl: deployed.agentUrl,
|
|
215
|
-
}),
|
|
216
|
-
...(linkSyncError
|
|
217
|
-
? [
|
|
218
|
-
'',
|
|
219
|
-
`Warning: deployment succeeded, but failed to save local link state (${getErrorMessage(linkSyncError)})`,
|
|
220
|
-
'Run `dexto deploy` again in this workspace to re-link.',
|
|
221
|
-
]
|
|
222
|
-
: []),
|
|
223
|
-
'',
|
|
224
|
-
'Next steps:',
|
|
225
|
-
`- Open the dashboard to inspect and interact with the deployment`,
|
|
226
|
-
`- Run \`dexto deploy status\` from this workspace`,
|
|
227
|
-
].join('\n'));
|
|
228
|
-
}
|
|
229
|
-
catch (error) {
|
|
230
|
-
spinner.stop(chalk.red('✗ Deploy failed'));
|
|
231
|
-
throw error;
|
|
232
|
-
}
|
|
233
|
-
finally {
|
|
234
|
-
if (snapshot) {
|
|
235
|
-
await snapshot.cleanup();
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
export async function handleDeployListCommand() {
|
|
240
|
-
const workspaceRoot = resolveWorkspaceRoot();
|
|
241
|
-
const deployLink = await loadWorkspaceDeployLink(workspaceRoot);
|
|
242
|
-
const client = createDeployClient();
|
|
243
|
-
const cloudAgents = await client.listCloudAgents();
|
|
244
|
-
if (cloudAgents.length === 0) {
|
|
245
|
-
p.outro('No cloud deployments found.\nRun `dexto deploy` from this workspace to create one.');
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const linkedCloudAgentId = deployLink?.cloudAgentId ?? null;
|
|
249
|
-
const sortedCloudAgents = [...cloudAgents].sort((left, right) => {
|
|
250
|
-
if (left.cloudAgentId === linkedCloudAgentId && right.cloudAgentId !== linkedCloudAgentId) {
|
|
251
|
-
return -1;
|
|
252
|
-
}
|
|
253
|
-
if (right.cloudAgentId === linkedCloudAgentId && left.cloudAgentId !== linkedCloudAgentId) {
|
|
254
|
-
return 1;
|
|
255
|
-
}
|
|
256
|
-
return 0;
|
|
257
|
-
});
|
|
258
|
-
const linkedVisible = linkedCloudAgentId !== null &&
|
|
259
|
-
sortedCloudAgents.some((cloudAgent) => cloudAgent.cloudAgentId === linkedCloudAgentId);
|
|
260
|
-
const lines = [
|
|
261
|
-
'Cloud deployments',
|
|
262
|
-
'',
|
|
263
|
-
...sortedCloudAgents.flatMap((cloudAgent, index) => {
|
|
264
|
-
const entry = formatCloudAgentListItem(cloudAgent, cloudAgent.cloudAgentId === linkedCloudAgentId);
|
|
265
|
-
return index === 0 ? [entry] : ['', entry];
|
|
266
|
-
}),
|
|
267
|
-
];
|
|
268
|
-
if (linkedCloudAgentId && !linkedVisible) {
|
|
269
|
-
lines.push('', chalk.yellow(`This workspace is linked to ${linkedCloudAgentId}, but that deployment was not returned by the cloud API.`));
|
|
270
|
-
}
|
|
271
|
-
p.outro(lines.join('\n'));
|
|
272
|
-
}
|
|
273
|
-
export async function handleDeployOpenCommand() {
|
|
274
|
-
const workspaceRoot = resolveWorkspaceRoot();
|
|
275
|
-
const deployLink = await loadWorkspaceDeployLink(workspaceRoot);
|
|
276
|
-
if (!deployLink) {
|
|
277
|
-
throw new Error('This workspace is not linked to a cloud deployment yet. Run `dexto deploy` first.');
|
|
278
|
-
}
|
|
279
|
-
const dashboardUrl = getCloudAgentDashboardUrl(deployLink.cloudAgentId);
|
|
280
|
-
try {
|
|
281
|
-
await open(dashboardUrl);
|
|
282
|
-
p.outro(`Opened dashboard for ${deployLink.cloudAgentId}\n${dashboardUrl}`);
|
|
283
|
-
}
|
|
284
|
-
catch (error) {
|
|
285
|
-
p.outro([
|
|
286
|
-
`Unable to open the dashboard automatically (${getErrorMessage(error)})`,
|
|
287
|
-
dashboardUrl,
|
|
288
|
-
].join('\n'));
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
export async function handleDeployStatusCommand() {
|
|
292
|
-
const workspaceRoot = resolveWorkspaceRoot();
|
|
293
|
-
const deployLink = await loadWorkspaceDeployLink(workspaceRoot);
|
|
294
|
-
if (!deployLink) {
|
|
295
|
-
throw new Error('This workspace is not linked to a cloud deployment yet. Run `dexto deploy` first.');
|
|
296
|
-
}
|
|
297
|
-
const client = createDeployClient();
|
|
298
|
-
const status = await client.getCloudAgent(deployLink.cloudAgentId);
|
|
299
|
-
p.outro(formatCloudAgentSummary({
|
|
300
|
-
cloudAgentId: status.cloudAgentId,
|
|
301
|
-
status: status.state.status,
|
|
302
|
-
agentUrl: status.agentUrl,
|
|
303
|
-
}));
|
|
304
|
-
}
|
|
305
|
-
export async function handleDeployStopCommand() {
|
|
306
|
-
const workspaceRoot = resolveWorkspaceRoot();
|
|
307
|
-
const deployLink = await loadWorkspaceDeployLink(workspaceRoot);
|
|
308
|
-
if (!deployLink) {
|
|
309
|
-
throw new Error('This workspace is not linked to a cloud deployment yet. Run `dexto deploy` first.');
|
|
310
|
-
}
|
|
311
|
-
const spinner = p.spinner();
|
|
312
|
-
spinner.start('Stopping cloud sandbox...');
|
|
313
|
-
try {
|
|
314
|
-
const client = createDeployClient();
|
|
315
|
-
const result = await client.stopCloudAgent(deployLink.cloudAgentId);
|
|
316
|
-
spinner.stop(chalk.green('✓ Cloud sandbox stopped'));
|
|
317
|
-
p.outro([
|
|
318
|
-
`Cloud agent: ${result.cloudAgentId}`,
|
|
319
|
-
`Stopped: ${result.stopped ? 'yes' : 'no'}`,
|
|
320
|
-
`Already stopped: ${result.alreadyStopped ? 'yes' : 'no'}`,
|
|
321
|
-
`Snapshot status: ${result.snapshotStatus}`,
|
|
322
|
-
].join('\n'));
|
|
323
|
-
}
|
|
324
|
-
catch (error) {
|
|
325
|
-
spinner.stop(chalk.red('✗ Stop failed'));
|
|
326
|
-
throw error;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
export async function handleDeployDeleteCommand(options) {
|
|
330
|
-
const workspaceRoot = resolveWorkspaceRoot();
|
|
331
|
-
const deployLink = await loadWorkspaceDeployLink(workspaceRoot);
|
|
332
|
-
if (!deployLink) {
|
|
333
|
-
throw new Error('This workspace is not linked to a cloud deployment yet. Run `dexto deploy` first.');
|
|
334
|
-
}
|
|
335
|
-
if (isInteractive(options)) {
|
|
336
|
-
await confirmOrExit({
|
|
337
|
-
message: `Delete cloud deployment ${deployLink.cloudAgentId}?`,
|
|
338
|
-
initialValue: false,
|
|
339
|
-
}, 'Delete cancelled');
|
|
340
|
-
}
|
|
341
|
-
const spinner = p.spinner();
|
|
342
|
-
spinner.start('Deleting cloud deployment...');
|
|
343
|
-
try {
|
|
344
|
-
const client = createDeployClient();
|
|
345
|
-
const result = await client.deleteCloudAgent(deployLink.cloudAgentId);
|
|
346
|
-
let linkRemoveError = null;
|
|
347
|
-
try {
|
|
348
|
-
await removeWorkspaceDeployLink(workspaceRoot);
|
|
349
|
-
}
|
|
350
|
-
catch (error) {
|
|
351
|
-
linkRemoveError = error;
|
|
352
|
-
}
|
|
353
|
-
spinner.stop(chalk.green('✓ Cloud deployment deleted'));
|
|
354
|
-
p.outro(linkRemoveError
|
|
355
|
-
? `Deleted ${result.cloudAgentId}\nWarning: failed to remove local deploy link state (${getErrorMessage(linkRemoveError)})`
|
|
356
|
-
: `Deleted ${result.cloudAgentId}`);
|
|
357
|
-
}
|
|
358
|
-
catch (error) {
|
|
359
|
-
spinner.stop(chalk.red('✗ Delete failed'));
|
|
360
|
-
throw error;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
export async function handleDeployChatCommand(cloudAgentId) {
|
|
364
|
-
const workspaceRoot = resolveWorkspaceRoot();
|
|
365
|
-
const selectedCloudAgentId = cloudAgentId ?? (await selectCloudAgentForChat(workspaceRoot));
|
|
366
|
-
await startCloudChatCli({
|
|
367
|
-
cloudAgentId: selectedCloudAgentId,
|
|
368
|
-
workspaceRoot,
|
|
369
|
-
});
|
|
370
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy/links.ts"],"names":[],"mappings":"AAgCA,wBAAgB,uBAAuB,IAAI,MAAM,CA2BhD;AAED,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEtE"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const APP_URL_ENV_VAR = 'DEXTO_APP_URL';
|
|
2
|
-
const SANDBOX_URL_ENV_VAR = 'DEXTO_SANDBOX_URL';
|
|
3
|
-
const DEFAULT_APP_URL = 'https://app.dexto.ai';
|
|
4
|
-
const LOCAL_DASHBOARD_URL = 'http://localhost:5173';
|
|
5
|
-
function normalizeBaseUrl(value) {
|
|
6
|
-
const trimmed = value?.trim();
|
|
7
|
-
if (!trimmed) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
try {
|
|
11
|
-
const url = new URL(trimmed);
|
|
12
|
-
url.pathname = '';
|
|
13
|
-
url.search = '';
|
|
14
|
-
url.hash = '';
|
|
15
|
-
return url.toString().replace(/\/$/, '');
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function isLocalHostUrl(value) {
|
|
22
|
-
const normalized = normalizeBaseUrl(value);
|
|
23
|
-
if (!normalized) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const hostname = new URL(normalized).hostname;
|
|
27
|
-
return hostname === 'localhost' || hostname === '127.0.0.1';
|
|
28
|
-
}
|
|
29
|
-
export function resolveDashboardBaseUrl() {
|
|
30
|
-
const explicitAppUrl = normalizeBaseUrl(process.env[APP_URL_ENV_VAR]);
|
|
31
|
-
if (explicitAppUrl) {
|
|
32
|
-
return explicitAppUrl;
|
|
33
|
-
}
|
|
34
|
-
if (isLocalHostUrl(process.env[SANDBOX_URL_ENV_VAR]) ||
|
|
35
|
-
isLocalHostUrl(process.env.DEXTO_API_URL)) {
|
|
36
|
-
return LOCAL_DASHBOARD_URL;
|
|
37
|
-
}
|
|
38
|
-
const normalizedApiUrl = normalizeBaseUrl(process.env.DEXTO_API_URL);
|
|
39
|
-
if (normalizedApiUrl) {
|
|
40
|
-
const apiUrl = new URL(normalizedApiUrl);
|
|
41
|
-
if (apiUrl.hostname === 'api.dexto.ai') {
|
|
42
|
-
return DEFAULT_APP_URL;
|
|
43
|
-
}
|
|
44
|
-
if (apiUrl.hostname.startsWith('api.')) {
|
|
45
|
-
apiUrl.hostname = `app.${apiUrl.hostname.slice('api.'.length)}`;
|
|
46
|
-
return apiUrl.toString().replace(/\/$/, '');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return DEFAULT_APP_URL;
|
|
50
|
-
}
|
|
51
|
-
export function getCloudAgentDashboardUrl(cloudAgentId) {
|
|
52
|
-
return `${resolveDashboardBaseUrl()}/dashboard/cloud-agents/${encodeURIComponent(cloudAgentId)}`;
|
|
53
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,WAAW,4BAA4B;IACzC,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,qBAAqB,CAAC,EAAE,OAAO,EAAE,EAAE,4BAA4B,GAAG,IAAI,CA4IrF"}
|