@agentuity/cli 0.1.37 → 0.1.38
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/bin/cli.ts +20 -0
- package/dist/agent-detection.d.ts +71 -0
- package/dist/agent-detection.d.ts.map +1 -0
- package/dist/agent-detection.js +232 -0
- package/dist/agent-detection.js.map +1 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +1 -0
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/project-cache.d.ts +16 -0
- package/dist/cache/project-cache.d.ts.map +1 -0
- package/dist/cache/project-cache.js +36 -0
- package/dist/cache/project-cache.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -2
- package/dist/cli.js.map +1 -1
- package/dist/cmd/auth/index.d.ts.map +1 -1
- package/dist/cmd/auth/index.js +0 -2
- package/dist/cmd/auth/index.js.map +1 -1
- package/dist/cmd/auth/org/enroll.d.ts +2 -0
- package/dist/cmd/auth/org/enroll.d.ts.map +1 -0
- package/dist/cmd/auth/{machine/setup.js → org/enroll.js} +14 -14
- package/dist/cmd/auth/org/enroll.js.map +1 -0
- package/dist/cmd/auth/org/index.d.ts.map +1 -1
- package/dist/cmd/auth/org/index.js +53 -10
- package/dist/cmd/auth/org/index.js.map +1 -1
- package/dist/cmd/auth/org/status.d.ts +2 -0
- package/dist/cmd/auth/org/status.d.ts.map +1 -0
- package/dist/cmd/auth/org/status.js +60 -0
- package/dist/cmd/auth/org/status.js.map +1 -0
- package/dist/cmd/auth/org/unenroll.d.ts +2 -0
- package/dist/cmd/auth/org/unenroll.d.ts.map +1 -0
- package/dist/cmd/auth/org/unenroll.js +68 -0
- package/dist/cmd/auth/org/unenroll.js.map +1 -0
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +11 -4
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/project/reconcile.d.ts.map +1 -1
- package/dist/cmd/project/reconcile.js +15 -2
- package/dist/cmd/project/reconcile.js.map +1 -1
- package/dist/cmd/support/report.d.ts.map +1 -1
- package/dist/cmd/support/report.js.map +1 -1
- package/dist/cmd/support/system.d.ts.map +1 -1
- package/dist/cmd/support/system.js +5 -0
- package/dist/cmd/support/system.js.map +1 -1
- package/dist/internal-logger.d.ts +4 -0
- package/dist/internal-logger.d.ts.map +1 -1
- package/dist/internal-logger.js +18 -0
- package/dist/internal-logger.js.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +6 -6
- package/src/agent-detection.ts +262 -0
- package/src/cache/index.ts +2 -0
- package/src/cache/project-cache.ts +41 -0
- package/src/cli.ts +10 -2
- package/src/cmd/auth/index.ts +0 -2
- package/src/cmd/auth/{machine/setup.ts → org/enroll.ts} +13 -13
- package/src/cmd/auth/org/index.ts +54 -10
- package/src/cmd/auth/org/status.ts +64 -0
- package/src/cmd/auth/org/unenroll.ts +80 -0
- package/src/cmd/cloud/deploy.ts +11 -4
- package/src/cmd/project/reconcile.ts +15 -2
- package/src/cmd/support/report.ts +1 -3
- package/src/cmd/support/system.ts +6 -0
- package/src/internal-logger.ts +18 -0
- package/src/types.ts +13 -0
- package/dist/cmd/auth/machine/index.d.ts +0 -2
- package/dist/cmd/auth/machine/index.d.ts.map +0 -1
- package/dist/cmd/auth/machine/index.js +0 -16
- package/dist/cmd/auth/machine/index.js.map +0 -1
- package/dist/cmd/auth/machine/setup.d.ts +0 -2
- package/dist/cmd/auth/machine/setup.d.ts.map +0 -1
- package/dist/cmd/auth/machine/setup.js.map +0 -1
- package/src/cmd/auth/machine/index.ts +0 -16
|
@@ -4,6 +4,9 @@ import { getCommand } from '../../../command-prefix';
|
|
|
4
4
|
import { saveOrgId, clearOrgId } from '../../../config';
|
|
5
5
|
import * as tui from '../../../tui';
|
|
6
6
|
import { listOrganizations } from '@agentuity/server';
|
|
7
|
+
import { enrollSubcommand } from './enroll';
|
|
8
|
+
import { unenrollSubcommand } from './unenroll';
|
|
9
|
+
import { statusSubcommand } from './status';
|
|
7
10
|
|
|
8
11
|
const selectCommand = createSubcommand({
|
|
9
12
|
name: 'select',
|
|
@@ -75,7 +78,8 @@ const selectCommand = createSubcommand({
|
|
|
75
78
|
const unselectCommand = createSubcommand({
|
|
76
79
|
name: 'unselect',
|
|
77
80
|
description: 'Clear the default organization preference',
|
|
78
|
-
tags: ['fast'],
|
|
81
|
+
tags: ['fast', 'requires-auth'],
|
|
82
|
+
requires: { auth: true, apiClient: true },
|
|
79
83
|
examples: [
|
|
80
84
|
{ command: getCommand('auth org unselect'), description: 'Clear default organization' },
|
|
81
85
|
],
|
|
@@ -106,37 +110,77 @@ const unselectCommand = createSubcommand({
|
|
|
106
110
|
const currentCommand = createSubcommand({
|
|
107
111
|
name: 'current',
|
|
108
112
|
description: 'Show the current default organization',
|
|
109
|
-
tags: ['read-only', 'fast'],
|
|
113
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
110
114
|
idempotent: true,
|
|
115
|
+
requires: { auth: true, apiClient: true },
|
|
111
116
|
examples: [
|
|
112
|
-
{ command: getCommand('auth org current'), description: 'Show default organization' },
|
|
117
|
+
{ command: getCommand('auth org current'), description: 'Show default organization ID' },
|
|
118
|
+
{ command: getCommand('auth org current --name'), description: 'Show default organization name' },
|
|
113
119
|
{ command: getCommand('auth org current --json'), description: 'Show output in JSON format' },
|
|
114
120
|
],
|
|
115
121
|
schema: {
|
|
116
|
-
|
|
122
|
+
options: z.object({
|
|
123
|
+
name: z.boolean().optional().describe('Show organization name instead of ID'),
|
|
124
|
+
}),
|
|
125
|
+
response: z
|
|
126
|
+
.object({
|
|
127
|
+
id: z.string().nullable().describe('The current organization ID or null if not set'),
|
|
128
|
+
name: z.string().nullable().describe('The current organization name or null if not set or not found'),
|
|
129
|
+
})
|
|
130
|
+
.describe('The current organization details'),
|
|
117
131
|
},
|
|
118
132
|
|
|
119
133
|
async handler(ctx) {
|
|
120
|
-
const { options, config } = ctx;
|
|
134
|
+
const { options, config, apiClient, opts } = ctx;
|
|
121
135
|
const orgId = config?.preferences?.orgId || null;
|
|
122
136
|
|
|
137
|
+
let orgName: string | null = null;
|
|
138
|
+
|
|
139
|
+
// Fetch org name if we have an orgId and either --name or --json is requested
|
|
140
|
+
if (orgId && (opts.name || options.json)) {
|
|
141
|
+
const orgs = await listOrganizations(apiClient);
|
|
142
|
+
const org = orgs.find((o) => o.id === orgId);
|
|
143
|
+
orgName = org?.name ?? null;
|
|
144
|
+
}
|
|
145
|
+
|
|
123
146
|
if (!options.json) {
|
|
124
|
-
if (
|
|
125
|
-
|
|
147
|
+
if (opts.name) {
|
|
148
|
+
// --name flag: print only the org name
|
|
149
|
+
if (orgName) {
|
|
150
|
+
console.log(orgName);
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
// Default behavior: print only the org ID
|
|
154
|
+
if (orgId) {
|
|
155
|
+
console.log(orgId);
|
|
156
|
+
}
|
|
126
157
|
}
|
|
127
158
|
}
|
|
128
159
|
|
|
129
|
-
return orgId;
|
|
160
|
+
return { id: orgId, name: orgName };
|
|
130
161
|
},
|
|
131
162
|
});
|
|
132
163
|
|
|
133
164
|
export const orgSubcommand = createCommand({
|
|
134
165
|
name: 'org',
|
|
135
|
-
|
|
166
|
+
aliases: ['machine', 'organization'],
|
|
167
|
+
description: 'Manage organization preferences and machine authentication',
|
|
136
168
|
tags: ['fast'],
|
|
137
169
|
examples: [
|
|
138
170
|
{ command: getCommand('auth org select'), description: 'Set default organization' },
|
|
139
171
|
{ command: getCommand('auth org current'), description: 'Show current default' },
|
|
172
|
+
{
|
|
173
|
+
command: getCommand('auth org enroll --file ./public-key.pem'),
|
|
174
|
+
description: 'Enroll an organization',
|
|
175
|
+
},
|
|
176
|
+
{ command: getCommand('auth org status'), description: 'Show org auth status' },
|
|
177
|
+
],
|
|
178
|
+
subcommands: [
|
|
179
|
+
selectCommand,
|
|
180
|
+
unselectCommand,
|
|
181
|
+
currentCommand,
|
|
182
|
+
enrollSubcommand,
|
|
183
|
+
unenrollSubcommand,
|
|
184
|
+
statusSubcommand,
|
|
140
185
|
],
|
|
141
|
-
subcommands: [selectCommand, unselectCommand, currentCommand],
|
|
142
186
|
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { orgAuthStatus } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { ErrorCode } from '../../../errors';
|
|
7
|
+
|
|
8
|
+
const StatusResponseSchema = z.object({
|
|
9
|
+
publicKey: z.string().nullable().describe('The public key or null if not set'),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const statusSubcommand = createSubcommand({
|
|
13
|
+
name: 'status',
|
|
14
|
+
aliases: ['show'],
|
|
15
|
+
description: 'Get the current public key status for an organization',
|
|
16
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
17
|
+
examples: [
|
|
18
|
+
{
|
|
19
|
+
command: getCommand('auth org status'),
|
|
20
|
+
description: 'Show the current public key for the organization',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
command: getCommand('auth org show'),
|
|
24
|
+
description: 'Show the current public key (alias)',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
requires: { auth: true, apiClient: true, org: true },
|
|
28
|
+
idempotent: true,
|
|
29
|
+
schema: {
|
|
30
|
+
response: StatusResponseSchema,
|
|
31
|
+
},
|
|
32
|
+
async handler(ctx) {
|
|
33
|
+
const { apiClient, options, orgId } = ctx;
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const result = await tui.spinner({
|
|
37
|
+
type: 'simple',
|
|
38
|
+
message: 'Fetching organization authentication status...',
|
|
39
|
+
callback: () => orgAuthStatus(apiClient, orgId),
|
|
40
|
+
clearOnSuccess: true,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (!options.json) {
|
|
44
|
+
if (result.publicKey) {
|
|
45
|
+
tui.success('Organization authentication is configured');
|
|
46
|
+
tui.newline();
|
|
47
|
+
console.log(tui.bold('Public Key:'));
|
|
48
|
+
tui.newline();
|
|
49
|
+
console.log(result.publicKey);
|
|
50
|
+
} else {
|
|
51
|
+
tui.info('No public key is configured for this organization');
|
|
52
|
+
tui.newline();
|
|
53
|
+
tui.info(
|
|
54
|
+
`Use '${getCommand('auth org enroll --file ./public-key.pem')}' to set up machine authentication.`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return { publicKey: result.publicKey };
|
|
60
|
+
} catch (ex) {
|
|
61
|
+
tui.fatal(`Failed to get organization authentication status: ${ex}`, ErrorCode.API_ERROR);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createSubcommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { orgAuthUnenroll } from '@agentuity/server';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import { ErrorCode } from '../../../errors';
|
|
7
|
+
|
|
8
|
+
const UnenrollResponseSchema = z.object({
|
|
9
|
+
success: z.boolean().describe('Whether the unenrollment succeeded'),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const unenrollSubcommand = createSubcommand({
|
|
13
|
+
name: 'unenroll',
|
|
14
|
+
description: 'Remove the public key from the organization, disabling self-hosted infrastructure',
|
|
15
|
+
tags: ['mutating', 'destructive', 'slow', 'requires-auth'],
|
|
16
|
+
examples: [
|
|
17
|
+
{
|
|
18
|
+
command: getCommand('auth org unenroll'),
|
|
19
|
+
description: 'Remove the public key from the current organization (with confirmation)',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
command: getCommand('auth org unenroll --confirm'),
|
|
23
|
+
description: 'Remove the public key without confirmation prompt',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
requires: { auth: true, apiClient: true, org: true },
|
|
27
|
+
idempotent: true,
|
|
28
|
+
schema: {
|
|
29
|
+
options: z.object({
|
|
30
|
+
confirm: z.boolean().optional().default(false).describe('Skip confirmation prompt'),
|
|
31
|
+
}),
|
|
32
|
+
response: UnenrollResponseSchema,
|
|
33
|
+
},
|
|
34
|
+
async handler(ctx) {
|
|
35
|
+
const { apiClient, options, opts, orgId } = ctx;
|
|
36
|
+
|
|
37
|
+
if (!opts.confirm) {
|
|
38
|
+
if (process.stdin.isTTY) {
|
|
39
|
+
tui.newline();
|
|
40
|
+
tui.warning(
|
|
41
|
+
'Removing your public key will immediately stop all network traffic and routing to your machines and all further traffic will immediately fail.'
|
|
42
|
+
);
|
|
43
|
+
tui.newline();
|
|
44
|
+
|
|
45
|
+
const confirmed = await tui.confirm(
|
|
46
|
+
'Are you sure you want to remove organization authentication?',
|
|
47
|
+
false
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (!confirmed) {
|
|
51
|
+
tui.info('Unenrollment cancelled.');
|
|
52
|
+
return { success: false };
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
tui.error(
|
|
56
|
+
'Non-interactive sessions require --confirm flag to unenroll. Use: ' +
|
|
57
|
+
getCommand('auth org unenroll --confirm')
|
|
58
|
+
);
|
|
59
|
+
return { success: false };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
await tui.spinner({
|
|
65
|
+
type: 'simple',
|
|
66
|
+
message: 'Removing organization authentication...',
|
|
67
|
+
callback: () => orgAuthUnenroll(apiClient, orgId),
|
|
68
|
+
clearOnSuccess: true,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (!options.json) {
|
|
72
|
+
tui.success('Organization authentication removed');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return { success: true };
|
|
76
|
+
} catch (ex) {
|
|
77
|
+
tui.fatal(`Failed to unenroll organization: ${ex}`, ErrorCode.API_ERROR);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
});
|
package/src/cmd/cloud/deploy.ts
CHANGED
|
@@ -61,6 +61,7 @@ import { BuildReportCollector, setGlobalCollector, clearGlobalCollector } from '
|
|
|
61
61
|
import { runForkedDeploy } from './deploy-fork';
|
|
62
62
|
import { validateAptDependencies } from '../../utils/apt-validator';
|
|
63
63
|
import { extractDependencies } from '../../utils/deps';
|
|
64
|
+
import { getCachedProject, setCachedProject } from '../../cache';
|
|
64
65
|
|
|
65
66
|
const DeploymentCancelledError = StructuredError(
|
|
66
67
|
'DeploymentCancelled',
|
|
@@ -168,10 +169,16 @@ export const deploySubcommand = createSubcommand({
|
|
|
168
169
|
const hasTTY = process.stdin.isTTY && process.stdout.isTTY;
|
|
169
170
|
if (project.region) {
|
|
170
171
|
try {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
// Check cache first to avoid duplicate API calls
|
|
173
|
+
const profile = config?.name ?? 'default';
|
|
174
|
+
let serverProject = getCachedProject(profile, project.projectId);
|
|
175
|
+
if (!serverProject) {
|
|
176
|
+
serverProject = await projectGet(apiClient, {
|
|
177
|
+
id: project.projectId,
|
|
178
|
+
keys: false,
|
|
179
|
+
});
|
|
180
|
+
setCachedProject(profile, project.projectId, serverProject);
|
|
181
|
+
}
|
|
175
182
|
const serverRegion = serverProject.cloudRegion;
|
|
176
183
|
|
|
177
184
|
if (serverRegion && serverRegion !== project.region) {
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
splitEnvAndSecrets,
|
|
24
24
|
} from '../../env-util';
|
|
25
25
|
import { fetchRegionsWithCache } from '../../regions';
|
|
26
|
+
import { getCachedProject, setCachedProject } from '../../cache';
|
|
26
27
|
|
|
27
28
|
export interface ReconcileResult {
|
|
28
29
|
status: 'valid' | 'imported' | 'skipped' | 'error';
|
|
@@ -468,7 +469,13 @@ export async function reconcileProject(opts: ReconcileOptions): Promise<Reconcil
|
|
|
468
469
|
if (projectConfig) {
|
|
469
470
|
// 2. Validate access to existing project
|
|
470
471
|
try {
|
|
471
|
-
|
|
472
|
+
// Check cache first to avoid duplicate API calls
|
|
473
|
+
const profile = config?.name ?? 'default';
|
|
474
|
+
let project = getCachedProject(profile, projectConfig.projectId);
|
|
475
|
+
if (!project) {
|
|
476
|
+
project = await projectGet(apiClient, { id: projectConfig.projectId, keys: false });
|
|
477
|
+
setCachedProject(profile, projectConfig.projectId, project);
|
|
478
|
+
}
|
|
472
479
|
|
|
473
480
|
// 3. Check if orgId matches user's orgs
|
|
474
481
|
const userOrgs = await listOrganizations(apiClient);
|
|
@@ -542,7 +549,13 @@ export async function runProjectImport(opts: ReconcileOptions): Promise<Reconcil
|
|
|
542
549
|
|
|
543
550
|
if (projectConfig) {
|
|
544
551
|
try {
|
|
545
|
-
|
|
552
|
+
// Check cache first to avoid duplicate API calls
|
|
553
|
+
const profile = config?.name ?? 'default';
|
|
554
|
+
let project = getCachedProject(profile, projectConfig.projectId);
|
|
555
|
+
if (!project) {
|
|
556
|
+
project = await projectGet(apiClient, { id: projectConfig.projectId, keys: false });
|
|
557
|
+
setCachedProject(profile, projectConfig.projectId, project);
|
|
558
|
+
}
|
|
546
559
|
const userOrgs = await listOrganizations(apiClient);
|
|
547
560
|
const hasAccess = userOrgs.some((org) => org.id === project.orgId);
|
|
548
561
|
|
|
@@ -257,9 +257,7 @@ export default createSubcommand({
|
|
|
257
257
|
if (isJsonMode) {
|
|
258
258
|
console.log(JSON.stringify({ success: false, error: 'Description is required' }));
|
|
259
259
|
} else {
|
|
260
|
-
tui.error(
|
|
261
|
-
'Description is required. Use --description flag or pipe input via stdin.'
|
|
262
|
-
);
|
|
260
|
+
tui.error('Description is required. Use --description flag or pipe input via stdin.');
|
|
263
261
|
}
|
|
264
262
|
return;
|
|
265
263
|
}
|
|
@@ -7,6 +7,7 @@ import { getLatestLogSession } from '../../internal-logger';
|
|
|
7
7
|
import * as tui from '../../tui';
|
|
8
8
|
import { getVersion, getPackageName } from '../../version';
|
|
9
9
|
import { getAuth } from '../../config';
|
|
10
|
+
import { isExecutingFromAgent } from '../../agent-detection';
|
|
10
11
|
|
|
11
12
|
const argsSchema = z.object({});
|
|
12
13
|
|
|
@@ -75,6 +76,9 @@ export default createSubcommand({
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
// Get detected agent (if any)
|
|
80
|
+
const detectedAgent = await isExecutingFromAgent();
|
|
81
|
+
|
|
78
82
|
// Gather system information
|
|
79
83
|
const systemInfo = {
|
|
80
84
|
cli: {
|
|
@@ -100,6 +104,7 @@ export default createSubcommand({
|
|
|
100
104
|
user: {
|
|
101
105
|
userId: userId,
|
|
102
106
|
},
|
|
107
|
+
agent: detectedAgent || null,
|
|
103
108
|
};
|
|
104
109
|
|
|
105
110
|
if (isJsonMode) {
|
|
@@ -122,6 +127,7 @@ export default createSubcommand({
|
|
|
122
127
|
{ Property: 'Home Directory', Value: systemInfo.paths.home },
|
|
123
128
|
{ Property: 'Config Directory', Value: systemInfo.paths.configDir },
|
|
124
129
|
{ Property: 'User ID', Value: systemInfo.user.userId },
|
|
130
|
+
{ Property: 'Detected Agent', Value: systemInfo.agent || 'none' },
|
|
125
131
|
];
|
|
126
132
|
|
|
127
133
|
tui.table(tableData, ['Property', 'Value'], { layout: 'vertical' });
|
package/src/internal-logger.ts
CHANGED
|
@@ -388,6 +388,24 @@ export class InternalLogger implements Logger {
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
+
/**
|
|
392
|
+
* Update the session with detected agent name
|
|
393
|
+
*/
|
|
394
|
+
setDetectedAgent(agent: string): void {
|
|
395
|
+
if (!this.initialized || this.disabled) return;
|
|
396
|
+
|
|
397
|
+
try {
|
|
398
|
+
// Read existing session data
|
|
399
|
+
const existingData = JSON.parse(readFileSync(this.sessionFile, 'utf-8'));
|
|
400
|
+
existingData.detectedAgent = agent;
|
|
401
|
+
// Write updated session data
|
|
402
|
+
writeFileSync(this.sessionFile, JSON.stringify(existingData, null, 2));
|
|
403
|
+
} catch (err) {
|
|
404
|
+
// Ignore errors - this is a best-effort update
|
|
405
|
+
console.debug(`Failed to update detectedAgent in session: ${err}`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
391
409
|
/**
|
|
392
410
|
* Disable the internal logger (prevents init and logging)
|
|
393
411
|
*/
|
package/src/types.ts
CHANGED
|
@@ -422,6 +422,19 @@ export type CommandContextFromSpecs<
|
|
|
422
422
|
config: Config | null;
|
|
423
423
|
logger: Logger;
|
|
424
424
|
options: GlobalOptions;
|
|
425
|
+
/**
|
|
426
|
+
* Check if the CLI is being executed from a known coding agent.
|
|
427
|
+
* Returns the agent name if detected, undefined otherwise.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* const agent = await ctx.isExecutingFromAgent();
|
|
432
|
+
* if (agent) {
|
|
433
|
+
* logger.debug(`Running from agent: ${agent}`);
|
|
434
|
+
* }
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
isExecutingFromAgent: () => Promise<string | undefined>;
|
|
425
438
|
} & AddArgs<A> &
|
|
426
439
|
AddOpts<Op> &
|
|
427
440
|
AddAuth<AuthMode<R, O>> &
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cmd/auth/machine/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,sCAW5B,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createCommand } from '../../../types';
|
|
2
|
-
import { setupSubcommand } from './setup';
|
|
3
|
-
import { getCommand } from '../../../command-prefix';
|
|
4
|
-
export const machineSubcommand = createCommand({
|
|
5
|
-
name: 'machine',
|
|
6
|
-
description: 'Manage machine authentication for self-hosted infrastructure',
|
|
7
|
-
tags: ['fast', 'requires-auth'],
|
|
8
|
-
examples: [
|
|
9
|
-
{
|
|
10
|
-
command: getCommand('auth machine setup --file ./public-key.pem'),
|
|
11
|
-
description: 'Set up machine authentication with a public key',
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
subcommands: [setupSubcommand],
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cmd/auth/machine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;IAC9C,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,8DAA8D;IAC3E,IAAI,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC;IAC/B,QAAQ,EAAE;QACT;YACC,OAAO,EAAE,UAAU,CAAC,4CAA4C,CAAC;YACjE,WAAW,EAAE,iDAAiD;SAC9D;KACD;IACD,WAAW,EAAE,CAAC,eAAe,CAAC;CAC9B,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../../src/cmd/auth/machine/setup.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,eAAe,yCA0F1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../../src/cmd/auth/machine/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,GA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I,CAAC,SAAS,CAAC,QAAQ,CAAC,4BAA4B,CAAC,EAAE,CAAC;gBACvD,OAAO,MAAM,CAAC,KAAK,CAClB,2FAA2F,EAC3F,SAAS,CAAC,gBAAgB,CACjB,CAAC;YACZ,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC;gBAChC,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,sCAAsC;gBAC/C,QAAQ,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC;gBAC7D,cAAc,EAAE,IAAI;aACpB,CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBACnB,GAAG,CAAC,OAAO,CAAC,sDAAsD,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;gBAClF,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,GAAG,CAAC,IAAI,CACP,qFAAqF,CACrF,CAAC;YACH,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;QAC/C,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACb,GAAG,CAAC,KAAK,CAAC,4CAA4C,EAAE,EAAE,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAClF,CAAC;IACF,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createCommand } from '../../../types';
|
|
2
|
-
import { setupSubcommand } from './setup';
|
|
3
|
-
import { getCommand } from '../../../command-prefix';
|
|
4
|
-
|
|
5
|
-
export const machineSubcommand = createCommand({
|
|
6
|
-
name: 'machine',
|
|
7
|
-
description: 'Manage machine authentication for self-hosted infrastructure',
|
|
8
|
-
tags: ['fast', 'requires-auth'],
|
|
9
|
-
examples: [
|
|
10
|
-
{
|
|
11
|
-
command: getCommand('auth machine setup --file ./public-key.pem'),
|
|
12
|
-
description: 'Set up machine authentication with a public key',
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
subcommands: [setupSubcommand],
|
|
16
|
-
});
|