@copado/agentia-cli 1.0.0-beta.0 → 1.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/CHANGELOG.md +9 -0
- package/README.md +232 -232
- package/dist/commands/auth/get.js +45 -136
- package/dist/commands/auth/set.js +3 -3
- package/dist/lib/ai-config.js +2 -1
- package/dist/lib/auth-status-format.js +6 -0
- package/dist/lib/runtime.js +1 -1
- package/oclif.manifest.json +5250 -5250
- package/package.json +1 -1
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
1
|
+
import { Flags, ux } from '@oclif/core';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { AgentiaCommand } from '../../lib/agentia-command.js';
|
|
4
|
-
import { getCrtAuthStatus } from '../../lib/auth-config.js';
|
|
4
|
+
import { getAiAuthStatus, getCicdAuthStatus, getCrtAuthStatus } from '../../lib/auth-config.js';
|
|
5
5
|
import { readAuthProfile } from '../../lib/auth-profile.js';
|
|
6
|
-
import {
|
|
6
|
+
import { formatAiStatusLine, formatCicdStatusLine, formatCrtStatusLine } from '../../lib/auth-status-format.js';
|
|
7
|
+
import { ALL_CREDENTIAL_TYPES, credentialLabel, } from '../../lib/credential-store.js';
|
|
7
8
|
import { getDefaultsStorePaths } from '../../lib/defaults-store.js';
|
|
8
|
-
import { normalizeLocalGatewayBaseUrl, readLocalGatewayConfig } from '../../lib/local-gateway-config.js';
|
|
9
|
-
import { formatTestingConfigurationFieldList, } from '../../lib/testing-config.js';
|
|
10
9
|
export default class AuthGet extends AgentiaCommand {
|
|
11
|
-
static description = 'Show stored authentication credentials
|
|
10
|
+
static description = 'Show stored authentication credentials and their configured endpoints and scopes';
|
|
12
11
|
static examples = [
|
|
13
12
|
'<%= config.bin %> <%= command.id %>',
|
|
14
13
|
'<%= config.bin %> <%= command.id %> --ai',
|
|
@@ -42,55 +41,32 @@ export default class AuthGet extends AgentiaCommand {
|
|
|
42
41
|
}
|
|
43
42
|
const selectedTypes = types.length > 0 ? types : ALL_CREDENTIAL_TYPES;
|
|
44
43
|
const credentials = selectedTypes.map((type) => this.buildCredentialResult(type));
|
|
44
|
+
this.display(() => {
|
|
45
|
+
for (const type of ['cicd', 'ai', 'crt']) {
|
|
46
|
+
if (!selectedTypes.includes(type))
|
|
47
|
+
continue;
|
|
48
|
+
const scopes = this.hasLocalAuthentication(type) ? ['global', 'local'] : [undefined];
|
|
49
|
+
this.log('');
|
|
50
|
+
this.log(ux.colorize('cyan', `${type.toUpperCase()} authentication`));
|
|
51
|
+
for (const [index, scope] of scopes.entries()) {
|
|
52
|
+
if (index > 0)
|
|
53
|
+
this.log('');
|
|
54
|
+
this.log(this.formatCredentialLine(this.buildCredentialResult(type, scope)));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
45
58
|
const configFiles = this.buildConfigFileResults();
|
|
46
|
-
for (const credential of credentials) {
|
|
47
|
-
this.log(this.formatCredentialLine(credential));
|
|
48
|
-
}
|
|
49
|
-
for (const configFile of configFiles) {
|
|
50
|
-
this.log(this.formatConfigFileLine(configFile));
|
|
51
|
-
}
|
|
52
59
|
return { configFiles, credentials };
|
|
53
60
|
}
|
|
54
|
-
buildCicdCredentialResult() {
|
|
55
|
-
const
|
|
56
|
-
const label = credentialLabel('cicd');
|
|
57
|
-
const localProfile = readAuthProfile('local');
|
|
58
|
-
const profile = localProfile?.cicd ?? readAuthProfile('global')?.cicd;
|
|
59
|
-
if (localConfig.enabled) {
|
|
60
|
-
const apiKey = localConfig.apiKey || (localProfile?.cicd === undefined ? getCredential('cicd') : getCredentialForKey('cicd', localProfile.keychainId));
|
|
61
|
-
if (apiKey === null || apiKey.trim().length === 0) {
|
|
62
|
-
return {
|
|
63
|
-
baseUrl: normalizeLocalGatewayBaseUrl(localConfig.url),
|
|
64
|
-
label,
|
|
65
|
-
local: true,
|
|
66
|
-
set: false,
|
|
67
|
-
type: 'cicd',
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
baseUrl: normalizeLocalGatewayBaseUrl(localConfig.url),
|
|
72
|
-
label,
|
|
73
|
-
local: true,
|
|
74
|
-
masked: maskSecret(apiKey),
|
|
75
|
-
set: true,
|
|
76
|
-
source: 'local',
|
|
77
|
-
type: 'cicd',
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const credential = localProfile?.cicd === undefined ? getCredential('cicd') : getCredentialForKey('cicd', localProfile.keychainId);
|
|
81
|
-
if (credential === null) {
|
|
82
|
-
return {
|
|
83
|
-
label,
|
|
84
|
-
set: false,
|
|
85
|
-
type: 'cicd',
|
|
86
|
-
};
|
|
87
|
-
}
|
|
61
|
+
buildCicdCredentialResult(scope) {
|
|
62
|
+
const status = getCicdAuthStatus(scope);
|
|
88
63
|
return {
|
|
89
|
-
baseUrl:
|
|
90
|
-
label,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
64
|
+
baseUrl: status.baseUrl,
|
|
65
|
+
label: credentialLabel('cicd'),
|
|
66
|
+
local: status.local,
|
|
67
|
+
masked: status.masked,
|
|
68
|
+
set: status.set,
|
|
69
|
+
source: status.source,
|
|
94
70
|
type: 'cicd',
|
|
95
71
|
};
|
|
96
72
|
}
|
|
@@ -101,38 +77,25 @@ export default class AuthGet extends AgentiaCommand {
|
|
|
101
77
|
{ exists: existsSync(userPath), label: 'User config', path: userPath, scope: 'user' },
|
|
102
78
|
];
|
|
103
79
|
}
|
|
104
|
-
buildCredentialResult(type) {
|
|
80
|
+
buildCredentialResult(type, scope) {
|
|
105
81
|
if (type === 'cicd') {
|
|
106
|
-
return this.buildCicdCredentialResult();
|
|
82
|
+
return this.buildCicdCredentialResult(scope);
|
|
107
83
|
}
|
|
108
84
|
if (type === 'ai') {
|
|
109
|
-
const
|
|
110
|
-
const metadata = local?.ai ?? readAuthProfile('global')?.ai;
|
|
111
|
-
const credential = local?.ai === undefined ? getCredential(type) : getCredentialForKey(type, local.keychainId);
|
|
112
|
-
if (credential === null) {
|
|
113
|
-
return {
|
|
114
|
-
domain: metadata?.domain ?? getAiDomain(),
|
|
115
|
-
gatewayUrl: metadata?.gatewayUrl ?? getAiGatewayUrl(),
|
|
116
|
-
label: credentialLabel(type),
|
|
117
|
-
orgId: metadata?.orgId ?? getAiOrgId(),
|
|
118
|
-
set: false,
|
|
119
|
-
type,
|
|
120
|
-
workspaceId: metadata?.workspaceId ?? getAiWorkspaceId(),
|
|
121
|
-
};
|
|
122
|
-
}
|
|
85
|
+
const status = getAiAuthStatus(scope);
|
|
123
86
|
return {
|
|
124
|
-
domain:
|
|
125
|
-
gatewayUrl:
|
|
87
|
+
domain: status.domain,
|
|
88
|
+
gatewayUrl: status.gatewayUrl,
|
|
126
89
|
label: credentialLabel(type),
|
|
127
|
-
masked:
|
|
128
|
-
orgId:
|
|
129
|
-
set:
|
|
130
|
-
source:
|
|
90
|
+
masked: status.masked,
|
|
91
|
+
orgId: status.orgId,
|
|
92
|
+
set: status.set,
|
|
93
|
+
source: status.source,
|
|
131
94
|
type,
|
|
132
|
-
workspaceId:
|
|
95
|
+
workspaceId: status.workspaceId,
|
|
133
96
|
};
|
|
134
97
|
}
|
|
135
|
-
const status = getCrtAuthStatus();
|
|
98
|
+
const status = getCrtAuthStatus(scope);
|
|
136
99
|
return {
|
|
137
100
|
domain: status.domain,
|
|
138
101
|
issues: status.issues,
|
|
@@ -146,74 +109,20 @@ export default class AuthGet extends AgentiaCommand {
|
|
|
146
109
|
type,
|
|
147
110
|
};
|
|
148
111
|
}
|
|
149
|
-
formatConfigFileLine(configFile) {
|
|
150
|
-
return `${configFile.label}: ${configFile.path} (${configFile.exists ? 'found' : 'not found'})`;
|
|
151
|
-
}
|
|
152
112
|
formatCredentialLine(credential) {
|
|
153
|
-
if (credential.type === 'crt') {
|
|
154
|
-
return this.formatCrtCredentialLine(credential);
|
|
155
|
-
}
|
|
156
|
-
if (!credential.set) {
|
|
157
|
-
if (credential.type === 'cicd' && credential.local && credential.baseUrl) {
|
|
158
|
-
return `${credential.label}: not set (endpoint: ${credential.baseUrl}, local)`;
|
|
159
|
-
}
|
|
160
|
-
if (credential.type === 'ai') {
|
|
161
|
-
const domain = credential.domain === null || credential.domain === undefined ? 'not set' : credential.domain;
|
|
162
|
-
const orgId = credential.orgId === null || credential.orgId === undefined ? 'not set' : credential.orgId;
|
|
163
|
-
const workspaceId = credential.workspaceId === null || credential.workspaceId === undefined ? 'not set' : credential.workspaceId;
|
|
164
|
-
const gatewayUrl = credential.gatewayUrl === null || credential.gatewayUrl === undefined ? 'derived' : credential.gatewayUrl;
|
|
165
|
-
return `${credential.label}: not set (domain: ${domain}, org: ${orgId}, workspace: ${workspaceId}, gateway: ${gatewayUrl})`;
|
|
166
|
-
}
|
|
167
|
-
return `${credential.label}: not set`;
|
|
168
|
-
}
|
|
169
113
|
if (credential.type === 'cicd') {
|
|
170
|
-
|
|
171
|
-
const localSuffix = credential.local ? ', local' : '';
|
|
172
|
-
const sourceSuffix = credential.source === undefined ? '' : `, source: ${credential.source}`;
|
|
173
|
-
return `${credential.label}: ${credential.masked} (endpoint: ${endpointLabel}${localSuffix}${sourceSuffix})`;
|
|
114
|
+
return formatCicdStatusLine(credential);
|
|
174
115
|
}
|
|
175
116
|
if (credential.type === 'ai') {
|
|
176
|
-
|
|
177
|
-
const orgId = credential.orgId === null || credential.orgId === undefined ? 'not set' : credential.orgId;
|
|
178
|
-
const workspaceId = credential.workspaceId === null || credential.workspaceId === undefined ? 'not set' : credential.workspaceId;
|
|
179
|
-
const gatewayUrl = credential.gatewayUrl === null || credential.gatewayUrl === undefined ? 'derived' : credential.gatewayUrl;
|
|
180
|
-
const sourceSuffix = credential.source === undefined ? '' : `, source: ${credential.source}`;
|
|
181
|
-
return `${credential.label}: ${credential.masked} (domain: ${domain}, org: ${orgId}, workspace: ${workspaceId}, gateway: ${gatewayUrl}${sourceSuffix})`;
|
|
117
|
+
return formatAiStatusLine(credential);
|
|
182
118
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
formatCrtCredentialLine(credential) {
|
|
186
|
-
const domain = credential.domain === null || credential.domain === undefined ? 'not set' : credential.domain;
|
|
187
|
-
const orgId = credential.orgId === null || credential.orgId === undefined ? 'not set' : credential.orgId;
|
|
188
|
-
const ready = credential.ready ?? credential.set;
|
|
189
|
-
if (!ready) {
|
|
190
|
-
const pak = credential.masked ?? 'not set';
|
|
191
|
-
const details = this.formatCrtIssueDetails(credential);
|
|
192
|
-
return `${credential.label}: incomplete (PAK: ${pak}, domain: ${domain}, org: ${orgId}${details})`;
|
|
119
|
+
if (credential.type === 'crt') {
|
|
120
|
+
return formatCrtStatusLine(credential);
|
|
193
121
|
}
|
|
194
|
-
|
|
195
|
-
return `${credential.label}: ${credential.masked} (domain: ${domain}, org: ${orgId}${sourceSuffix})`;
|
|
122
|
+
return '';
|
|
196
123
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const missing = issues.filter((issue) => issue.kind === 'missing').map((issue) => issue.field);
|
|
200
|
-
const invalid = issues.filter((issue) => issue.kind === 'invalid');
|
|
201
|
-
const details = [];
|
|
202
|
-
if (missing.length > 0) {
|
|
203
|
-
details.push(`missing: ${formatTestingConfigurationFieldList(missing)}`);
|
|
204
|
-
}
|
|
205
|
-
if (invalid.length > 0) {
|
|
206
|
-
details.push(`invalid: ${invalid
|
|
207
|
-
.map((issue) => {
|
|
208
|
-
const label = formatTestingConfigurationFieldList([issue.field]);
|
|
209
|
-
return issue.message === undefined ? label : `${label} (${issue.message})`;
|
|
210
|
-
})
|
|
211
|
-
.join(', ')}`);
|
|
212
|
-
}
|
|
213
|
-
if (details.length === 0 && credential.missing !== undefined && credential.missing.length > 0) {
|
|
214
|
-
details.push(`missing: ${formatTestingConfigurationFieldList(credential.missing)}`);
|
|
215
|
-
}
|
|
216
|
-
return details.length === 0 ? '' : `; ${details.join('; ')}`;
|
|
124
|
+
hasLocalAuthentication(type) {
|
|
125
|
+
return readAuthProfile('local')?.[type] !== undefined;
|
|
217
126
|
}
|
|
218
127
|
}
|
|
219
128
|
//# sourceMappingURL=get.js.map
|
|
@@ -6,13 +6,13 @@ export default class AuthSet extends AgentiaCommand {
|
|
|
6
6
|
static description = 'Store authentication credentials securely in the system keychain';
|
|
7
7
|
static examples = [
|
|
8
8
|
'<%= config.bin %> <%= command.id %> --ai <pak> --ai-domain robotic.copado.com --ai-org 42888',
|
|
9
|
+
'<%= config.bin %> <%= command.id %> --ai <pak> --ai-org 42888',
|
|
9
10
|
'<%= config.bin %> <%= command.id %> --ai <pak> --ai-domain robotic.copado.com --ai-org 42888 --ai-workspace 42d0b908-37b7-4565-9ec9-86eda40c9782',
|
|
10
11
|
'<%= config.bin %> <%= command.id %> --ai <pak> --ai-gateway-url http://localhost:8080/organizations/42888',
|
|
11
12
|
'<%= config.bin %> <%= command.id %> --ai-workspace 42d0b908-37b7-4565-9ec9-86eda40c9782',
|
|
12
13
|
'<%= config.bin %> <%= command.id %> --cicd <copado-api-key> --region na',
|
|
13
14
|
'<%= config.bin %> <%= command.id %> --cicd <copado-api-key> --custom-url https://dev.api.copado.com',
|
|
14
15
|
'<%= config.bin %> <%= command.id %> --cicd <copado-api-key>',
|
|
15
|
-
'<%= config.bin %> <%= command.id %> --crt <pak>',
|
|
16
16
|
'<%= config.bin %> <%= command.id %> --crt <pak> --crt-org <crt-org-id>',
|
|
17
17
|
'<%= config.bin %> <%= command.id %> --crt <pak> --crt-domain robotic.copado.com --crt-org <crt-org-id>',
|
|
18
18
|
'<%= config.bin %> <%= command.id %> --cicd <copado-api-key> --region na --crt <pak>',
|
|
@@ -21,7 +21,7 @@ export default class AuthSet extends AgentiaCommand {
|
|
|
21
21
|
static flags = {
|
|
22
22
|
ai: Flags.string({ description: 'PAK for Copado AI authentication' }),
|
|
23
23
|
'ai-domain': Flags.string({
|
|
24
|
-
description: 'Copado AI domain hostname
|
|
24
|
+
description: 'Optional Copado AI domain hostname; omit to auto-discover from the PAK and organization ID',
|
|
25
25
|
}),
|
|
26
26
|
'ai-gateway-url': Flags.string({
|
|
27
27
|
description: 'Full Copado AI gateway base URL used instead of deriving from domain and organization; HTTP is allowed for local testing',
|
|
@@ -35,7 +35,7 @@ export default class AuthSet extends AgentiaCommand {
|
|
|
35
35
|
cicd: Flags.string({
|
|
36
36
|
description: 'Copado API key for CICD authentication',
|
|
37
37
|
}),
|
|
38
|
-
crt: Flags.string({ description: 'PAK for CRT authentication' }),
|
|
38
|
+
crt: Flags.string({ description: 'PAK for CRT authentication (requires --crt-org)' }),
|
|
39
39
|
'crt-domain': Flags.string({
|
|
40
40
|
description: 'CRT domain hostname for robotic testing commands',
|
|
41
41
|
}),
|
package/dist/lib/ai-config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {modules} from './runtime.js';
|
|
2
2
|
const AI_DEFAULT_TIMEOUT_MS = modules["ai-config.js"]["AI_DEFAULT_TIMEOUT_MS"]
|
|
3
3
|
const AI_DEFAULT_WORKSPACE_NAME = modules["ai-config.js"]["AI_DEFAULT_WORKSPACE_NAME"]
|
|
4
|
+
const AI_DISCOVERY_DOMAINS = modules["ai-config.js"]["AI_DISCOVERY_DOMAINS"]
|
|
4
5
|
const AI_GATEWAY_HOST_PREFIX = modules["ai-config.js"]["AI_GATEWAY_HOST_PREFIX"]
|
|
5
6
|
const aiBaseUrl = modules["ai-config.js"]["aiBaseUrl"]
|
|
6
7
|
const normalizeAiDialogueId = modules["ai-config.js"]["normalizeAiDialogueId"]
|
|
@@ -10,4 +11,4 @@ const normalizeAiOrgId = modules["ai-config.js"]["normalizeAiOrgId"]
|
|
|
10
11
|
const normalizeAiUuid = modules["ai-config.js"]["normalizeAiUuid"]
|
|
11
12
|
const normalizeAiWorkspaceId = modules["ai-config.js"]["normalizeAiWorkspaceId"]
|
|
12
13
|
const resolveAiCredentials = modules["ai-config.js"]["resolveAiCredentials"]
|
|
13
|
-
export {AI_DEFAULT_TIMEOUT_MS, AI_DEFAULT_WORKSPACE_NAME, AI_GATEWAY_HOST_PREFIX, aiBaseUrl, normalizeAiDialogueId, normalizeAiDomain, normalizeAiGatewayUrl, normalizeAiOrgId, normalizeAiUuid, normalizeAiWorkspaceId, resolveAiCredentials};
|
|
14
|
+
export {AI_DEFAULT_TIMEOUT_MS, AI_DEFAULT_WORKSPACE_NAME, AI_DISCOVERY_DOMAINS, AI_GATEWAY_HOST_PREFIX, aiBaseUrl, normalizeAiDialogueId, normalizeAiDomain, normalizeAiGatewayUrl, normalizeAiOrgId, normalizeAiUuid, normalizeAiWorkspaceId, resolveAiCredentials};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {modules} from './runtime.js';
|
|
2
|
+
const formatAiStatusLine = modules["auth-status-format.js"]["formatAiStatusLine"]
|
|
3
|
+
const formatAuthScope = modules["auth-status-format.js"]["formatAuthScope"]
|
|
4
|
+
const formatCicdStatusLine = modules["auth-status-format.js"]["formatCicdStatusLine"]
|
|
5
|
+
const formatCrtStatusLine = modules["auth-status-format.js"]["formatCrtStatusLine"]
|
|
6
|
+
export {formatAiStatusLine, formatAuthScope, formatCicdStatusLine, formatCrtStatusLine};
|