dexto 1.14.6 → 2.0.0-beta.1
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/agents/coding-agent/coding-agent.yml +0 -2
- package/dist/cli/agent-audit.d.ts +12 -0
- package/dist/cli/agent-audit.d.ts.map +1 -0
- package/dist/cli/agent-audit.js +52 -0
- 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 +107 -0
- package/dist/cli/cloud/command.d.ts.map +1 -0
- package/dist/cli/cloud/command.js +154 -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 +129 -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 +526 -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/artifacts.d.ts +3 -0
- package/dist/cli/cloud/commands/artifacts.d.ts.map +1 -0
- package/dist/cli/cloud/commands/artifacts.js +267 -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 +233 -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 +204 -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 +55 -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 +225 -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 +321 -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 +284 -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 +250 -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 +120 -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 +139 -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 +266 -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 +111 -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 +203 -0
- package/dist/cli/cloud/commands/traces.d.ts +3 -0
- package/dist/cli/cloud/commands/traces.d.ts.map +1 -0
- package/dist/cli/cloud/commands/traces.js +142 -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 +657 -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 +281 -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 +109 -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 +77 -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 +36 -0
- package/dist/cli/cloud/v1.d.ts +20 -0
- package/dist/cli/cloud/v1.d.ts.map +1 -0
- package/dist/cli/cloud/v1.js +66 -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 +248 -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 +44 -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.d.ts.map +1 -1
- package/dist/cli/commands/run/headless.js +57 -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/run/step-log.d.ts +11 -0
- package/dist/cli/commands/run/step-log.d.ts.map +1 -0
- package/dist/cli/commands/run/step-log.js +42 -0
- 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/failure.d.ts +29 -0
- package/dist/cli/failure.d.ts.map +1 -0
- package/dist/cli/failure.js +31 -0
- 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/import/claude-code.d.ts +10 -0
- package/dist/cli/import/claude-code.d.ts.map +1 -0
- package/dist/cli/import/claude-code.js +131 -0
- package/dist/cli/import/codex.d.ts +27 -0
- package/dist/cli/import/codex.d.ts.map +1 -0
- package/dist/cli/import/codex.js +148 -0
- package/dist/cli/import/git.d.ts +19 -0
- package/dist/cli/import/git.d.ts.map +1 -0
- package/dist/cli/import/git.js +95 -0
- package/dist/cli/import/local-chats.d.ts +28 -0
- package/dist/cli/import/local-chats.d.ts.map +1 -0
- package/dist/cli/import/local-chats.js +129 -0
- package/dist/cli/import/redaction.d.ts +37 -0
- package/dist/cli/import/redaction.d.ts.map +1 -0
- package/dist/cli/import/redaction.js +148 -0
- package/dist/cli/import/test-utils.d.ts +16 -0
- package/dist/cli/import/test-utils.d.ts.map +1 -0
- package/dist/cli/import/test-utils.js +223 -0
- package/dist/cli/import/transcript.d.ts +75 -0
- package/dist/cli/import/transcript.d.ts.map +1 -0
- package/dist/cli/import/transcript.js +123 -0
- package/dist/cli/interaction.d.ts +18 -0
- package/dist/cli/interaction.d.ts.map +1 -0
- package/dist/cli/interaction.js +30 -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/output.d.ts +9 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +6 -0
- 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 +44 -65
- package/dist/webui/assets/index-D9xiOs62.js +1649 -0
- package/dist/webui/index.html +1 -1
- package/package.json +15 -14
- 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
- package/dist/webui/assets/index-DEfRFmFT.js +0 -1667
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// `dexto login`, `logout`, `whoami` and `accounts`: signing in to Dexto and the saved profiles.
|
|
2
|
+
import { CommandFailure } from '../../failure.js';
|
|
3
|
+
import { dextoAccounts } from '@dexto/agent-management';
|
|
4
|
+
import { UsageError } from '../../cloud/command.js';
|
|
5
|
+
const { DEFAULT_PROFILE, forgetLogin, listAccounts: readAccounts, profileNameFor, readCurrentProfile, readLogin, requireProfileName, resolveCredential, resolveProfile, writeCurrentProfile, writeLogin, } = dextoAccounts;
|
|
6
|
+
export async function login(context, options) {
|
|
7
|
+
const named = options.profile ?? nonEmpty(context.environment.DEXTO_PROFILE);
|
|
8
|
+
// --org names the profile and switches to it, unless --profile or DEXTO_PROFILE chose one.
|
|
9
|
+
const switches = options.org !== null && named === null;
|
|
10
|
+
const profile = options.org !== null && switches
|
|
11
|
+
? profileNameFor(options.org)
|
|
12
|
+
: await resolveProfile(context.dir, named, {});
|
|
13
|
+
const saved = await readLogin(context.dir, profile);
|
|
14
|
+
if (options.apiKey !== null) {
|
|
15
|
+
if (options.org !== null)
|
|
16
|
+
throw new UsageError('An API key acts as itself; --org is for signing in.');
|
|
17
|
+
await saveApiKey(context, profile, options.apiKey);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const previous = saved?.kind === 'oauth' ? saved : null;
|
|
21
|
+
const input = {
|
|
22
|
+
appUrl: previous?.appUrl ?? context.appUrl,
|
|
23
|
+
apiBaseUrl: previous?.apiBaseUrl ?? context.apiBaseUrl,
|
|
24
|
+
// Signing in again starts at the organization the profile was signed in for.
|
|
25
|
+
organization: options.org ?? previous?.signedInAs?.organization.id ?? null,
|
|
26
|
+
// ...and keeps the permissions granted before.
|
|
27
|
+
extraScopes: [...(previous?.scopes ?? []), ...options.scopes.flatMap(splitList)],
|
|
28
|
+
};
|
|
29
|
+
// A browser elsewhere can't reach this machine's loopback redirect, so use a code instead.
|
|
30
|
+
const device = options.device || (options.browser && !context.canOpenBrowser);
|
|
31
|
+
if (device && !options.device)
|
|
32
|
+
context.note('No browser here, so sign in with a code on any device.');
|
|
33
|
+
const signedIn = device
|
|
34
|
+
? await context.dexto.signInWithDevice(input)
|
|
35
|
+
: await context.dexto.signInWithBrowser({ ...input, openBrowser: options.browser });
|
|
36
|
+
// A name made from --org can match another organization's profile: keep that sign-in.
|
|
37
|
+
const savedOrganization = previous?.signedInAs?.organization ?? null;
|
|
38
|
+
const newOrganization = signedIn.signedInAs?.organization ?? null;
|
|
39
|
+
if (switches &&
|
|
40
|
+
savedOrganization !== null &&
|
|
41
|
+
newOrganization !== null &&
|
|
42
|
+
savedOrganization.id !== newOrganization.id)
|
|
43
|
+
throw new UsageError(`The profile ${profile} already signs in to ${savedOrganization.name}. Sign in to ${newOrganization.name} with --profile <name> to keep both.`);
|
|
44
|
+
const withProject = {
|
|
45
|
+
...signedIn,
|
|
46
|
+
cloudProject: chooseProject(await context.dexto.listProjects(signedIn), previous?.cloudProject ?? null),
|
|
47
|
+
};
|
|
48
|
+
await writeLogin(context.dir, profile, withProject);
|
|
49
|
+
if (switches)
|
|
50
|
+
await writeCurrentProfile(context.dir, profile);
|
|
51
|
+
const current = (await resolveProfile(context.dir, null, context.environment)) === profile;
|
|
52
|
+
context.result({
|
|
53
|
+
profile,
|
|
54
|
+
current,
|
|
55
|
+
account: signedIn.signedInAs?.account ?? null,
|
|
56
|
+
organization: signedIn.signedInAs?.organization ?? null,
|
|
57
|
+
cloud_project: withProject.cloudProject,
|
|
58
|
+
scopes: withProject.scopes,
|
|
59
|
+
}, [
|
|
60
|
+
`Signed in${describeSignedInAs(signedIn.signedInAs)}${profile === DEFAULT_PROFILE ? '' : ` (profile ${profile})`}.`,
|
|
61
|
+
withProject.cloudProject === null
|
|
62
|
+
? 'This organization has no Cloud project for Dexto models to bill.'
|
|
63
|
+
: `Dexto models bill Cloud project ${withProject.cloudProject.name}.`,
|
|
64
|
+
...(current
|
|
65
|
+
? []
|
|
66
|
+
: [
|
|
67
|
+
`Other commands still use another profile: pass --profile ${profile}, or run dexto accounts use ${profile}.`,
|
|
68
|
+
]),
|
|
69
|
+
].join(' '));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The project chosen before while it is still live, so signing in again doesn't move anyone;
|
|
73
|
+
* otherwise the organization's default project.
|
|
74
|
+
*/
|
|
75
|
+
function chooseProject(projects, previous) {
|
|
76
|
+
const chosen = projects.find((project) => project.id === previous?.id && !project.archived) ??
|
|
77
|
+
projects.find((project) => project.isDefault && !project.archived) ??
|
|
78
|
+
null;
|
|
79
|
+
return chosen === null ? null : { id: chosen.id, name: chosen.name };
|
|
80
|
+
}
|
|
81
|
+
async function saveApiKey(context, profile, apiKey) {
|
|
82
|
+
if (!(await context.dexto.acceptsApiKey(context.apiBaseUrl, apiKey)))
|
|
83
|
+
throw new CommandFailure('needs_sign_in', 'Dexto refused this API key.', null);
|
|
84
|
+
await writeLogin(context.dir, profile, {
|
|
85
|
+
kind: 'api_key',
|
|
86
|
+
apiKey,
|
|
87
|
+
apiBaseUrl: context.apiBaseUrl,
|
|
88
|
+
savedAt: new Date().toISOString(),
|
|
89
|
+
});
|
|
90
|
+
context.result({ profile, key: maskApiKey(apiKey) }, `Saved API key ${maskApiKey(apiKey)}${profile === DEFAULT_PROFILE ? '' : ` (profile ${profile})`}.`);
|
|
91
|
+
}
|
|
92
|
+
/** Who the current profile acts as, in a few words, or null when signed out. */
|
|
93
|
+
export async function describeSignIn(context) {
|
|
94
|
+
const environmentKey = nonEmpty(context.environment.DEXTO_API_KEY);
|
|
95
|
+
if (environmentKey !== null)
|
|
96
|
+
return `API key ${maskApiKey(environmentKey)} from DEXTO_API_KEY`;
|
|
97
|
+
const profile = await resolveProfile(context.dir, null, context.environment);
|
|
98
|
+
const saved = await readLogin(context.dir, profile);
|
|
99
|
+
if (saved === null)
|
|
100
|
+
return null;
|
|
101
|
+
const suffix = profile === DEFAULT_PROFILE ? '' : ` (profile ${profile})`;
|
|
102
|
+
if (saved.kind === 'api_key')
|
|
103
|
+
return `API key ${maskApiKey(saved.apiKey)}${suffix}`;
|
|
104
|
+
const who = saved.signedInAs === null
|
|
105
|
+
? saved.appUrl
|
|
106
|
+
: `${saved.signedInAs.account.email} in ${saved.signedInAs.organization.name}`;
|
|
107
|
+
return `${who}${suffix}`;
|
|
108
|
+
}
|
|
109
|
+
export async function logout(context, options) {
|
|
110
|
+
const profile = await resolveProfile(context.dir, options.profile, context.environment);
|
|
111
|
+
const removed = await logOutProfile(context, profile);
|
|
112
|
+
const named = profile === DEFAULT_PROFILE ? '' : ` for profile ${profile}`;
|
|
113
|
+
context.result({ profile, logged_out: removed }, removed ? `Logged out${named}.` : `No saved sign-in${named}.`);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Ends a profile's sign-in on its server, then forgets it here. A sign-in the server didn't end
|
|
117
|
+
* keeps working until it expires, so a note says where to end it.
|
|
118
|
+
*/
|
|
119
|
+
async function logOutProfile(context, profile) {
|
|
120
|
+
const saved = await readLogin(context.dir, profile);
|
|
121
|
+
if (saved?.kind === 'oauth') {
|
|
122
|
+
const ended = await context.dexto.endSignIn(saved);
|
|
123
|
+
if (ended.status === 'failed')
|
|
124
|
+
context.note(`Couldn't end the sign-in on ${saved.appUrl} (${ended.reason}). Sign it out at ${new URL('/settings/sign-ins', saved.appUrl).href}, or it keeps working until it expires.`);
|
|
125
|
+
}
|
|
126
|
+
return await forgetLogin(context.dir, profile);
|
|
127
|
+
}
|
|
128
|
+
export async function whoami(context, options) {
|
|
129
|
+
const credential = await resolveCredential({
|
|
130
|
+
dir: context.dir,
|
|
131
|
+
apiKey: options.apiKey,
|
|
132
|
+
profile: options.profile,
|
|
133
|
+
environment: context.environment,
|
|
134
|
+
refresh: context.dexto.refreshSignIn,
|
|
135
|
+
});
|
|
136
|
+
if (credential === null)
|
|
137
|
+
throw new CommandFailure('needs_sign_in', 'Not signed in.', 'dexto login');
|
|
138
|
+
if (credential.kind === 'api_key') {
|
|
139
|
+
const from = credential.source === 'flag'
|
|
140
|
+
? ' (from --api-key)'
|
|
141
|
+
: credential.source === 'environment'
|
|
142
|
+
? ' (from DEXTO_API_KEY)'
|
|
143
|
+
: `, profile ${credential.profile}`;
|
|
144
|
+
context.result({ as: 'api_key', key: maskApiKey(credential.token), source: credential.source }, field('api key', `${maskApiKey(credential.token)}${from}`));
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const { login: saved } = credential;
|
|
148
|
+
context.result({
|
|
149
|
+
as: 'person',
|
|
150
|
+
profile: credential.profile,
|
|
151
|
+
account: saved.signedInAs?.account ?? null,
|
|
152
|
+
organization: saved.signedInAs?.organization ?? null,
|
|
153
|
+
app_url: saved.appUrl,
|
|
154
|
+
cloud_project: saved.cloudProject,
|
|
155
|
+
scopes: saved.scopes,
|
|
156
|
+
}, [
|
|
157
|
+
field('profile', credential.profile),
|
|
158
|
+
field('account', saved.signedInAs?.account.email ?? 'unknown'),
|
|
159
|
+
field('organization', saved.signedInAs === null
|
|
160
|
+
? 'unknown'
|
|
161
|
+
: `${saved.signedInAs.organization.name} (${saved.signedInAs.organization.slug})`),
|
|
162
|
+
field('app', saved.appUrl),
|
|
163
|
+
field('scopes', saved.scopes.join(' ')),
|
|
164
|
+
].join('\n'));
|
|
165
|
+
}
|
|
166
|
+
export async function listAccounts(context, options) {
|
|
167
|
+
const inUse = await resolveProfile(context.dir, options.profile, context.environment);
|
|
168
|
+
const accounts = (await readAccounts(context.dir)).map(({ name, login: saved }) => ({
|
|
169
|
+
profile: name,
|
|
170
|
+
current: name === inUse,
|
|
171
|
+
kind: saved.kind,
|
|
172
|
+
account: saved.kind === 'oauth' ? (saved.signedInAs?.account ?? null) : null,
|
|
173
|
+
organization: saved.kind === 'oauth' ? (saved.signedInAs?.organization ?? null) : null,
|
|
174
|
+
key: saved.kind === 'api_key' ? maskApiKey(saved.apiKey) : null,
|
|
175
|
+
url: saved.kind === 'oauth' ? saved.appUrl : saved.apiBaseUrl,
|
|
176
|
+
}));
|
|
177
|
+
const rows = accounts.map((account) => [
|
|
178
|
+
`${account.current ? '*' : ' '} ${account.profile}`,
|
|
179
|
+
account.key !== null ? `API key ${account.key}` : (account.account?.email ?? account.url),
|
|
180
|
+
account.organization?.name ?? '',
|
|
181
|
+
]);
|
|
182
|
+
context.result({ data: accounts }, rows.length === 0 ? 'No saved sign-ins. Run dexto login.' : table(rows));
|
|
183
|
+
}
|
|
184
|
+
export async function useAccount(context, wanted) {
|
|
185
|
+
const { name, login: saved } = await requireSaved(context, wanted);
|
|
186
|
+
await writeCurrentProfile(context.dir, name);
|
|
187
|
+
const overridden = (await resolveProfile(context.dir, null, context.environment)) !== name;
|
|
188
|
+
context.result({ current: name }, `Now using ${describeProfile(name, saved)}.${overridden ? ' DEXTO_PROFILE still chooses another profile here.' : ''}`);
|
|
189
|
+
}
|
|
190
|
+
export async function removeAccount(context, wanted, options) {
|
|
191
|
+
const { name, login: saved } = await requireSaved(context, wanted);
|
|
192
|
+
const question = saved.kind === 'oauth'
|
|
193
|
+
? `Log ${describeProfile(name, saved)} out and forget it on this machine?`
|
|
194
|
+
: `Forget ${describeProfile(name, saved)} on this machine?`;
|
|
195
|
+
if (!options.yes && !(await context.confirm(question)))
|
|
196
|
+
throw new CommandFailure('needs_confirmation', `${question} Pass --yes once your person has agreed.`, `dexto accounts remove ${name} --yes`);
|
|
197
|
+
const wasCurrent = (await readCurrentProfile(context.dir)) === name;
|
|
198
|
+
await logOutProfile(context, name);
|
|
199
|
+
if (wasCurrent)
|
|
200
|
+
await writeCurrentProfile(context.dir, DEFAULT_PROFILE);
|
|
201
|
+
context.result({ removed: name, current: wasCurrent ? DEFAULT_PROFILE : null }, `Removed ${name}.${wasCurrent && name !== DEFAULT_PROFILE ? ` Now using ${DEFAULT_PROFILE}.` : ''}`);
|
|
202
|
+
}
|
|
203
|
+
async function requireSaved(context, wanted) {
|
|
204
|
+
const name = requireProfileName(wanted);
|
|
205
|
+
const saved = await readLogin(context.dir, name);
|
|
206
|
+
if (saved === null)
|
|
207
|
+
throw new CommandFailure('not_found', `No saved sign-in is named ${name}.`, `dexto login --profile ${name}`);
|
|
208
|
+
return { name, login: saved };
|
|
209
|
+
}
|
|
210
|
+
/** `work (ada@example.com in Acme)`, or the key or app a profile signs in with. */
|
|
211
|
+
function describeProfile(name, saved) {
|
|
212
|
+
if (saved.kind === 'api_key')
|
|
213
|
+
return `${name} (API key ${maskApiKey(saved.apiKey)})`;
|
|
214
|
+
return saved.signedInAs === null
|
|
215
|
+
? `${name} (${saved.appUrl})`
|
|
216
|
+
: `${name} (${saved.signedInAs.account.email} in ${saved.signedInAs.organization.name})`;
|
|
217
|
+
}
|
|
218
|
+
/** ` as ada@example.com in Acme`, or nothing when the server didn't say. */
|
|
219
|
+
function describeSignedInAs(signedInAs) {
|
|
220
|
+
return signedInAs === null
|
|
221
|
+
? ''
|
|
222
|
+
: ` as ${signedInAs.account.email} in ${signedInAs.organization.name}`;
|
|
223
|
+
}
|
|
224
|
+
/** `dxt_123…abcd`: enough to recognize a key without showing it. */
|
|
225
|
+
function maskApiKey(apiKey) {
|
|
226
|
+
return apiKey.length <= 12 ? '…' : `${apiKey.slice(0, 7)}…${apiKey.slice(-4)}`;
|
|
227
|
+
}
|
|
228
|
+
function field(name, value) {
|
|
229
|
+
return `${name.padEnd(13)} ${value}`;
|
|
230
|
+
}
|
|
231
|
+
function table(rows) {
|
|
232
|
+
const widths = rows[0]?.map((_, column) => Math.max(...rows.map((row) => row[column]?.length ?? 0)));
|
|
233
|
+
return rows
|
|
234
|
+
.map((row) => row
|
|
235
|
+
.map((cell, column) => column === row.length - 1 ? cell : cell.padEnd(widths?.[column] ?? 0))
|
|
236
|
+
.join(' ')
|
|
237
|
+
.trimEnd())
|
|
238
|
+
.join('\n');
|
|
239
|
+
}
|
|
240
|
+
function splitList(value) {
|
|
241
|
+
return value
|
|
242
|
+
.split(/[\s,]+/u)
|
|
243
|
+
.map((each) => each.trim())
|
|
244
|
+
.filter((each) => each.length > 0);
|
|
245
|
+
}
|
|
246
|
+
function nonEmpty(value) {
|
|
247
|
+
return value === undefined || value.length === 0 ? null : value;
|
|
248
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SignInContext } from './sign-in-commands.js';
|
|
2
|
+
/** Where results and notes go, and what cancels a sign-in; the terminal's by default. */
|
|
3
|
+
export interface SignInIo {
|
|
4
|
+
readonly result: (value: unknown, text: string) => void;
|
|
5
|
+
readonly note: (text: string) => void;
|
|
6
|
+
/** Asks the person; false when there is no one to ask. */
|
|
7
|
+
readonly confirm: (question: string) => Promise<boolean>;
|
|
8
|
+
readonly signal: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Carries this machine's earlier sign-ins into ~/.dexto/accounts, once: the `dexto-cloud` preview
|
|
12
|
+
* CLI's, else dexto 1.x's saved API key.
|
|
13
|
+
*/
|
|
14
|
+
export declare function carryOverEarlierSignIns(): Promise<void>;
|
|
15
|
+
export declare function nodeSignInContext(io?: SignInIo): Promise<SignInContext>;
|
|
16
|
+
//# sourceMappingURL=sign-in-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in-context.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/auth/sign-in-context.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,yFAAyF;AACzF,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;CAChC;AAmBD;;;GAGG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ7D;AAED,wBAAsB,iBAAiB,CAAC,EAAE,GAAE,QAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAiCvF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The sign-in context for this machine: ~/.dexto/accounts, Dexto's OAuth server and the browser.
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import * as p from '@clack/prompts';
|
|
5
|
+
import { dextoAccounts, dextoCloud, dextoSignIn } from '@dexto/agent-management';
|
|
6
|
+
import { getDextoGlobalPath } from '@dexto/core';
|
|
7
|
+
import { shouldAttemptBrowserLaunch } from '../../auth/browser-launch.js';
|
|
8
|
+
import { DEXTO_PLATFORM_URL, DEXTO_PUBLIC_API_URL } from '../../auth/constants.js';
|
|
9
|
+
import { nodeSignInRuntime } from '../../auth/sign-in-runtime.js';
|
|
10
|
+
const TERMINAL = {
|
|
11
|
+
result: (_value, text) => process.stdout.write(`${text}\n`),
|
|
12
|
+
note: (text) => process.stderr.write(`${text}\n`),
|
|
13
|
+
confirm: async (question) => {
|
|
14
|
+
if (!process.stdin.isTTY)
|
|
15
|
+
return false;
|
|
16
|
+
const answer = await p.confirm({ message: question, initialValue: false });
|
|
17
|
+
return answer === true;
|
|
18
|
+
},
|
|
19
|
+
signal: new AbortController().signal,
|
|
20
|
+
};
|
|
21
|
+
/** The folder the internal `dexto-cloud` CLI saved its sign-ins in. */
|
|
22
|
+
function cloudCliDirectory() {
|
|
23
|
+
const configHome = process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), '.config');
|
|
24
|
+
return path.join(configHome, 'dexto-cloud');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Carries this machine's earlier sign-ins into ~/.dexto/accounts, once: the `dexto-cloud` preview
|
|
28
|
+
* CLI's, else dexto 1.x's saved API key.
|
|
29
|
+
*/
|
|
30
|
+
export async function carryOverEarlierSignIns() {
|
|
31
|
+
const dir = getDextoGlobalPath('accounts');
|
|
32
|
+
await dextoAccounts.carryOverCloudCliLogins(dir, cloudCliDirectory());
|
|
33
|
+
await dextoAccounts.carryOverDexto1ApiKey(dir, getDextoGlobalPath('', 'auth.json'), DEXTO_PUBLIC_API_URL);
|
|
34
|
+
}
|
|
35
|
+
export async function nodeSignInContext(io = TERMINAL) {
|
|
36
|
+
const dir = getDextoGlobalPath('accounts');
|
|
37
|
+
await carryOverEarlierSignIns();
|
|
38
|
+
const runtime = { ...nodeSignInRuntime(io.signal), note: io.note };
|
|
39
|
+
return {
|
|
40
|
+
dir,
|
|
41
|
+
environment: process.env,
|
|
42
|
+
appUrl: DEXTO_PLATFORM_URL,
|
|
43
|
+
apiBaseUrl: DEXTO_PUBLIC_API_URL,
|
|
44
|
+
result: io.result,
|
|
45
|
+
note: io.note,
|
|
46
|
+
confirm: io.confirm,
|
|
47
|
+
canOpenBrowser: shouldAttemptBrowserLaunch(),
|
|
48
|
+
dexto: {
|
|
49
|
+
signInWithBrowser: (input) => dextoSignIn.signInWithBrowser(runtime, input),
|
|
50
|
+
signInWithDevice: (input) => dextoSignIn.signInWithDevice(runtime, input),
|
|
51
|
+
endSignIn: (login) => dextoSignIn.endSignIn(runtime, login),
|
|
52
|
+
refreshSignIn: (login) => dextoSignIn.refreshSignIn(runtime, login),
|
|
53
|
+
listProjects: (login) => dextoCloud.listCloudProjects(runtime.fetch, login.apiBaseUrl, login.accessToken),
|
|
54
|
+
acceptsApiKey: async (apiBaseUrl, apiKey) => {
|
|
55
|
+
const response = await fetch(`${apiBaseUrl}/v1/models`, {
|
|
56
|
+
headers: { authorization: `Bearer ${apiKey}` },
|
|
57
|
+
signal: AbortSignal.timeout(10_000),
|
|
58
|
+
});
|
|
59
|
+
await response.body?.cancel();
|
|
60
|
+
if (response.status === 401)
|
|
61
|
+
return false;
|
|
62
|
+
if (!response.ok)
|
|
63
|
+
throw new Error(`Couldn't check the API key: HTTP ${response.status}.`);
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* These words run on the cloud command engine, which reads its own arguments and global options
|
|
4
|
+
* (--json, --api-key, --profile, --project). Analytics records only the command name, never its
|
|
5
|
+
* arguments, which can hold a key.
|
|
6
|
+
*/
|
|
2
7
|
export declare function registerCloudCommand(program: Command): void;
|
|
3
8
|
//# sourceMappingURL=register.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/cloud/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/cloud/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBzC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuB3D"}
|
|
@@ -1,27 +1,47 @@
|
|
|
1
1
|
import { withAnalytics, safeExit } from '../../../analytics/wrapper.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/** The top-level words the cloud command engine owns, and what each is for. */
|
|
3
|
+
const ENGINE_WORDS = {
|
|
4
|
+
login: 'Sign in to Dexto with your browser or a device code, or save an API key for CI',
|
|
5
|
+
logout: 'End the sign-in on the server and forget it here',
|
|
6
|
+
whoami: 'Show who Dexto commands act as',
|
|
7
|
+
accounts: 'List, switch and remove saved sign-ins, one per account and organization',
|
|
8
|
+
models: 'Models Dexto serves on your sign-in',
|
|
9
|
+
billing: "Show the organization's credit balance and recent spending",
|
|
10
|
+
cloud: 'Build in Dexto Cloud: projects, agents, files, sandboxes and more',
|
|
11
|
+
workspace: 'Use your Dexto workspace as yourself: its apps and tools, over the Dexto MCP',
|
|
12
|
+
find: 'Find the command for something you want to do in Dexto',
|
|
13
|
+
publish: 'Publish a file, folder or .zip as a link anyone with it can open',
|
|
14
|
+
profile: 'Show and change your Dexto profile: handle, name, bio and who can see it',
|
|
15
|
+
skills: 'Push a local Skill folder into your Dexto Skills library',
|
|
16
|
+
trace: "List your run traces and show one run's trace from Dexto",
|
|
17
|
+
span: "List one run's spans from Dexto",
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* These words run on the cloud command engine, which reads its own arguments and global options
|
|
21
|
+
* (--json, --api-key, --profile, --project). Analytics records only the command name, never its
|
|
22
|
+
* arguments, which can hold a key.
|
|
23
|
+
*/
|
|
7
24
|
export function registerCloudCommand(program) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
for (const [word, description] of Object.entries(ENGINE_WORDS))
|
|
26
|
+
program
|
|
27
|
+
.command(word)
|
|
28
|
+
.description(description)
|
|
29
|
+
.helpOption(false)
|
|
30
|
+
.passThroughOptions()
|
|
31
|
+
.allowUnknownOption()
|
|
32
|
+
.allowExcessArguments()
|
|
33
|
+
.argument('[args...]')
|
|
34
|
+
.action(async (args) => {
|
|
35
|
+
await withAnalytics(word, async () => {
|
|
36
|
+
const [{ runCloud }, { nodeCloudHost }] = await Promise.all([
|
|
37
|
+
import('../../cloud/run.js'),
|
|
38
|
+
import('../../cloud/host.js'),
|
|
39
|
+
]);
|
|
40
|
+
const code = await runCloud(nodeCloudHost(new AbortController().signal), [
|
|
41
|
+
word,
|
|
42
|
+
...args,
|
|
43
|
+
]);
|
|
44
|
+
safeExit(word, code);
|
|
45
|
+
})();
|
|
46
|
+
});
|
|
27
47
|
}
|
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import * as p from '@clack/prompts';
|
|
5
5
|
import { selectOrExit } from '../utils/prompt-helpers.js';
|
|
6
|
-
import { promptForProjectName, createProjectDirectory, setupGitRepo, createGitignore, initPackageJson, createTsconfigForApp, installDependencies, createEnvExample, ensureDirectory,
|
|
6
|
+
import { promptForProjectName, createProjectDirectory, setupGitRepo, createGitignore, initPackageJson, createTsconfigForApp, installDependencies, createEnvExample, ensureDirectory, dextoPackageRange, } from '../utils/scaffolding-utils.js';
|
|
7
7
|
import { generateIndexForCodeFirstDI, generateWebServerIndexForCodeFirstDI, generateWebAppHTML, generateWebAppJS, generateWebAppCSS, generateAppReadme, } from '../utils/template-engine.js';
|
|
8
8
|
import { getExecutionContext } from '@dexto/agent-management';
|
|
9
9
|
/**
|
|
@@ -115,18 +115,17 @@ async function scaffoldCodeFirstDI(projectPath, projectName, appType, spinner) {
|
|
|
115
115
|
spinner.message('Installing dependencies...');
|
|
116
116
|
const executionContext = getExecutionContext();
|
|
117
117
|
const isDextoSource = executionContext === 'dexto-source';
|
|
118
|
-
const
|
|
119
|
-
const dextoDependencyVersion = isDextoSource ? 'workspace:*' : versionRange;
|
|
118
|
+
const dexto = (name) => `${name}@${isDextoSource ? 'workspace:*' : dextoPackageRange(name)}`;
|
|
120
119
|
const dependencies = [
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
dexto('@dexto/core'),
|
|
121
|
+
dexto('@dexto/storage'),
|
|
123
122
|
// Intentionally omit tool packs in the scaffold to keep the onboarding example minimal.
|
|
124
123
|
// TODO: Revisit adding a default tool pack once tool IDs no longer require manual qualification.
|
|
125
124
|
'dotenv',
|
|
126
125
|
'tsx',
|
|
127
126
|
];
|
|
128
127
|
if (appType === 'webapp') {
|
|
129
|
-
dependencies.push(
|
|
128
|
+
dependencies.push(dexto('@dexto/server'));
|
|
130
129
|
}
|
|
131
130
|
await installDependencies(projectPath, {
|
|
132
131
|
dependencies,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-image.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/create-image.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-image.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/create-image.ts"],"names":[],"mappings":"AA2BA;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuOhE"}
|
|
@@ -2,7 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import * as p from '@clack/prompts';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { selectOrExit, textOrExit } from '../utils/prompt-helpers.js';
|
|
5
|
-
import { promptForProjectName, createProjectDirectory, setupGitRepo, createGitignore, initPackageJson, createTsconfigForImage,
|
|
5
|
+
import { promptForProjectName, createProjectDirectory, setupGitRepo, createGitignore, initPackageJson, createTsconfigForImage, dextoPackageRange, dextoPeerRange, installDependencies, pinDextoPackageIfUnversioned, ensureDirectory, } from '../utils/scaffolding-utils.js';
|
|
6
6
|
import { generateDextoImageFile, generateImageReadme, generateExampleTool, generateExampleHook, generateExampleCompaction, } from '../utils/template-engine.js';
|
|
7
7
|
import fs from 'fs-extra';
|
|
8
8
|
import { getExecutionContext } from '@dexto/agent-management';
|
|
@@ -133,23 +133,22 @@ export async function createImage(name) {
|
|
|
133
133
|
// Detect if we're in dexto source - use workspace protocol for local development
|
|
134
134
|
const executionContext = getExecutionContext();
|
|
135
135
|
const isDextoSource = executionContext === 'dexto-source';
|
|
136
|
-
const
|
|
137
|
-
const
|
|
136
|
+
const dextoRange = (name) => isDextoSource ? 'workspace:*' : dextoPackageRange(name);
|
|
137
|
+
const dexto = (name) => `${name}@${dextoRange(name)}`;
|
|
138
138
|
// Determine dependencies based on whether extending
|
|
139
139
|
const dependencies = [
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
'zod
|
|
140
|
+
dexto('@dexto/core'),
|
|
141
|
+
dexto('@dexto/agent-config'),
|
|
142
|
+
dexto('@dexto/storage'),
|
|
143
|
+
`zod@${dextoPeerRange('zod')}`,
|
|
144
144
|
];
|
|
145
145
|
const devDependencies = [
|
|
146
146
|
'typescript@^5.0.0',
|
|
147
147
|
'@types/node@^20.0.0',
|
|
148
|
-
|
|
148
|
+
dexto('@dexto/image-bundler'),
|
|
149
149
|
];
|
|
150
150
|
if (baseImage) {
|
|
151
|
-
|
|
152
|
-
dependencies.push(baseImageDependency);
|
|
151
|
+
dependencies.push(pinDextoPackageIfUnversioned(baseImage, dextoRange));
|
|
153
152
|
}
|
|
154
153
|
// Install dependencies (use pnpm in dexto source for workspace protocol support)
|
|
155
154
|
await installDependencies(projectPath, {
|
|
@@ -12,7 +12,5 @@ export { handleListAgentsCommand, type ListAgentsCommandOptions, type ListAgents
|
|
|
12
12
|
export { handleWhichCommand, type WhichCommandOptions } from './which.js';
|
|
13
13
|
export { handleSyncAgentsCommand, shouldPromptForSync, type SyncAgentsCommandOptions, } from './agents/sync.js';
|
|
14
14
|
export { handleImageInstallCommand, handleImageListCommand, handleImageUseCommand, handleImageRemoveCommand, handleImageDoctorCommand, type ImageInstallCommandOptions, type ImageInstallCommandOptionsInput, } from './image.js';
|
|
15
|
-
export { handleLoginCommand, handleLogoutCommand, handleStatusCommand } from './auth/index.js';
|
|
16
|
-
export { handleBillingStatusCommand } from './billing/index.js';
|
|
17
15
|
export { handlePluginListCommand, handlePluginInstallCommand, handlePluginUninstallCommand, handlePluginValidateCommand, handleMarketplaceAddCommand, handleMarketplaceRemoveCommand, handleMarketplaceUpdateCommand, handleMarketplaceListCommand, handleMarketplacePluginsCommand, handleMarketplaceInstallCommand, type PluginListCommandOptions, type PluginListCommandOptionsInput, type PluginInstallCommandOptions, type PluginInstallCommandOptionsInput, type PluginUninstallCommandOptions, type PluginUninstallCommandOptionsInput, type PluginValidateCommandOptions, type PluginValidateCommandOptionsInput, type MarketplaceAddCommandOptionsInput, type MarketplaceRemoveCommandOptionsInput, type MarketplaceUpdateCommandOptionsInput, type MarketplaceListCommandOptionsInput, type MarketplaceInstallCommandOptionsInput, } from './plugin.js';
|
|
18
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACH,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,0BAA0B,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErF,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,EAAE,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EACH,uBAAuB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,GACrC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EACH,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,wBAAwB,GAChC,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACH,yBAAyB,EACzB,sBAAsB,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B,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,GACvC,MAAM,YAAY,CAAC;AAOpB,OAAO,EACH,uBAAuB,EACvB,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAE3B,2BAA2B,EAC3B,8BAA8B,EAC9B,8BAA8B,EAC9B,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAChC,KAAK,gCAAgC,EACrC,KAAK,6BAA6B,EAClC,KAAK,kCAAkC,EACvC,KAAK,4BAA4B,EACjC,KAAK,iCAAiC,EAEtC,KAAK,iCAAiC,EACtC,KAAK,oCAAoC,EACzC,KAAK,oCAAoC,EACzC,KAAK,kCAAkC,EACvC,KAAK,qCAAqC,GAC7C,MAAM,aAAa,CAAC"}
|
|
@@ -16,9 +16,7 @@ export { handleSyncAgentsCommand, shouldPromptForSync, } from './agents/sync.js'
|
|
|
16
16
|
// Image commands
|
|
17
17
|
export { handleImageInstallCommand, handleImageListCommand, handleImageUseCommand, handleImageRemoveCommand, handleImageDoctorCommand, } from './image.js';
|
|
18
18
|
// Auth commands
|
|
19
|
-
export { handleLoginCommand, handleLogoutCommand, handleStatusCommand } from './auth/index.js';
|
|
20
19
|
// Billing commands
|
|
21
|
-
export { handleBillingStatusCommand } from './billing/index.js';
|
|
22
20
|
// Plugin commands
|
|
23
21
|
export { handlePluginListCommand, handlePluginInstallCommand, handlePluginUninstallCommand, handlePluginValidateCommand,
|
|
24
22
|
// Marketplace handlers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAgBzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;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