@aopslabs/aops 0.2.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/LICENSE +19 -0
- package/NOTICE +7 -0
- package/README.md +203 -0
- package/assets/agent-assets/core/SKILL.md +49 -0
- package/assets/agent-assets/core/references/agentspace/SKILL.md +78 -0
- package/assets/agent-assets/core/references/aops-cli-core/SKILL.md +108 -0
- package/assets/agent-assets/core/references/chatv3/SKILL.md +48 -0
- package/assets/agent-assets/core/references/collaborative-work/SKILL.md +85 -0
- package/assets/agent-assets/core/references/discuss/SKILL.md +66 -0
- package/assets/agent-assets/core/references/docman/SKILL.md +69 -0
- package/assets/agent-assets/core/references/hosted-chat/SKILL.md +64 -0
- package/assets/agent-assets/core/references/mission/SKILL.md +54 -0
- package/assets/agent-assets/core/references/projectman/SKILL.md +86 -0
- package/assets/agent-assets/core/references/sys/SKILL.md +36 -0
- package/assets/agent-assets/core/references/view/SKILL.md +58 -0
- package/assets/agent-assets/core/references/working-disciplines/SKILL.md +69 -0
- package/assets/agent-assets/core/user-guides/agent-assets.md +81 -0
- package/assets/agent-assets/core/user-guides/agentspace.md +1098 -0
- package/assets/agent-assets/core/user-guides/aops-cli.md +1107 -0
- package/assets/agent-assets/core/user-guides/aops-system.md +63 -0
- package/assets/agent-assets/core/user-guides/chatv3.md +113 -0
- package/assets/agent-assets/core/user-guides/docman.md +162 -0
- package/assets/agent-assets/core/user-guides/projectman.md +212 -0
- package/assets/agent-assets/core/user-guides/sys.md +94 -0
- package/assets/agent-assets/core/user-guides/working-disciplines.md +588 -0
- package/assets/agent-assets/gateway/aops/SKILL.md +14 -0
- package/assets/r6-remote-session-baseline.json +19 -0
- package/assets/skills/aops-install/SKILL.md +231 -0
- package/assets/skills/aops-install/agents/openai.yaml +4 -0
- package/dist/commands/activity.js +352 -0
- package/dist/commands/agent-profile.js +653 -0
- package/dist/commands/agent.js +710 -0
- package/dist/commands/agents-md.js +125 -0
- package/dist/commands/api.js +84 -0
- package/dist/commands/archive.js +873 -0
- package/dist/commands/artifact.js +535 -0
- package/dist/commands/assets.js +1414 -0
- package/dist/commands/auth/device-login.js +1 -0
- package/dist/commands/auth/legacy-export.js +177 -0
- package/dist/commands/auth/login.js +426 -0
- package/dist/commands/chat.js +1363 -0
- package/dist/commands/chatv3.js +1684 -0
- package/dist/commands/checkpoint.js +549 -0
- package/dist/commands/commercial-artifact.js +475 -0
- package/dist/commands/commercial-license.js +594 -0
- package/dist/commands/community-auth.js +62 -0
- package/dist/commands/community-cockpit.js +185 -0
- package/dist/commands/community-console.js +109 -0
- package/dist/commands/community-doctor.js +335 -0
- package/dist/commands/community-server.js +2062 -0
- package/dist/commands/community-setup.js +284 -0
- package/dist/commands/discuss.js +1448 -0
- package/dist/commands/doc.js +5219 -0
- package/dist/commands/experience.js +922 -0
- package/dist/commands/host.js +1127 -0
- package/dist/commands/init.js +118 -0
- package/dist/commands/memory.js +3129 -0
- package/dist/commands/mission.js +562 -0
- package/dist/commands/official-catalog.js +134 -0
- package/dist/commands/plan.js +84 -0
- package/dist/commands/playbook.js +415 -0
- package/dist/commands/pm/context.js +6 -0
- package/dist/commands/pm/index.js +701 -0
- package/dist/commands/pm/projectman.js +6266 -0
- package/dist/commands/project.js +1080 -0
- package/dist/commands/prompt.js +1024 -0
- package/dist/commands/repo-sync.js +1907 -0
- package/dist/commands/resource.js +527 -0
- package/dist/commands/skill.js +1211 -0
- package/dist/commands/start-disciplines.js +510 -0
- package/dist/commands/start.js +1343 -0
- package/dist/commands/target.js +309 -0
- package/dist/commands/version.js +42 -0
- package/dist/commands/view.js +1852 -0
- package/dist/launchers/cockpit.js +28 -0
- package/dist/launchers/options.js +74 -0
- package/dist/launchers/server.js +41 -0
- package/dist/lib/agent-assets/envelope.js +83 -0
- package/dist/lib/agent-assets/gateway.js +15 -0
- package/dist/lib/agent-assets/guards.js +23 -0
- package/dist/lib/agent-assets/hosted-discovery.js +148 -0
- package/dist/lib/agent-assets/hosted-package-input.js +154 -0
- package/dist/lib/agent-assets/legacy-pointer-migration.js +677 -0
- package/dist/lib/agent-assets/native-fs.js +589 -0
- package/dist/lib/agent-assets/package-manifest.js +324 -0
- package/dist/lib/agent-assets/portable-path.js +67 -0
- package/dist/lib/agent-assets/release-input.js +177 -0
- package/dist/lib/agent-assets/roots.js +45 -0
- package/dist/lib/agent-assets/runtime-binding-reader.js +545 -0
- package/dist/lib/agent-assets/runtime-targets.js +50 -0
- package/dist/lib/agent-assets/store-reader.js +1212 -0
- package/dist/lib/agent-assets/store-types.js +1 -0
- package/dist/lib/agent-assets/store-writer.js +1484 -0
- package/dist/lib/agent-assets/types.js +1 -0
- package/dist/lib/agent-assets/unicode-case-folding-v15-1.generated.js +1548 -0
- package/dist/lib/commercial-final-readiness.js +504 -0
- package/dist/lib/commercial-lifecycle-smoke-isolation.js +236 -0
- package/dist/lib/commercial-managed-postgres-docker-adapter.js +274 -0
- package/dist/lib/commercial-setup-readiness-adapter.js +179 -0
- package/dist/lib/community-client-contract.js +164 -0
- package/dist/lib/community-cockpit-lifecycle.js +601 -0
- package/dist/lib/community-command-abort.js +59 -0
- package/dist/lib/community-diagnostic.js +237 -0
- package/dist/lib/community-docker-adapter.js +498 -0
- package/dist/lib/community-home.js +31 -0
- package/dist/lib/community-instance-contract.js +148 -0
- package/dist/lib/community-instance-layout.js +97 -0
- package/dist/lib/community-lifecycle.js +1631 -0
- package/dist/lib/community-migration-snapshot.js +770 -0
- package/dist/lib/community-native-application-recovery.js +425 -0
- package/dist/lib/community-native-child.js +240 -0
- package/dist/lib/community-native-database-recovery.js +456 -0
- package/dist/lib/community-native-lifecycle.js +2458 -0
- package/dist/lib/community-native-migration.js +339 -0
- package/dist/lib/community-native-postgres.js +596 -0
- package/dist/lib/community-operation-journal.js +773 -0
- package/dist/lib/community-operation-lock.js +596 -0
- package/dist/lib/community-release-resolver.js +291 -0
- package/dist/lib/community-release-verifier.js +475 -0
- package/dist/lib/community-repo-discovery.js +252 -0
- package/dist/lib/community-setup-server-env.js +203 -0
- package/dist/lib/external-url.js +110 -0
- package/dist/lib/official-catalog-gateway.js +108 -0
- package/dist/lib/official-catalog.js +364 -0
- package/dist/lib/server-bootstrap.js +240 -0
- package/dist/lib/setup-agent-assets-bridge.js +176 -0
- package/dist/lib/setup-agent-assets-release.js +52 -0
- package/dist/lib/setup-external-postgres.js +108 -0
- package/dist/lib/setup-init-orchestrator.js +990 -0
- package/dist/lib/setup-install-guide.js +52 -0
- package/dist/lib/setup-installer-release.js +47 -0
- package/dist/lib/setup-local-postgres.js +329 -0
- package/dist/lib/setup-official-catalog-bridge.js +148 -0
- package/dist/lib/setup-readiness.js +888 -0
- package/dist/lib/tui-launcher.js +59 -0
- package/dist/main.js +150 -0
- package/dist/seeds/agents-md.js +54 -0
- package/dist/utils/agent-gateway.js +275 -0
- package/dist/utils/agents-md.js +281 -0
- package/dist/utils/api.js +255 -0
- package/dist/utils/chatv3-session-store.js +185 -0
- package/dist/utils/command.js +67 -0
- package/dist/utils/community-host-runtime.js +376 -0
- package/dist/utils/config.js +1015 -0
- package/dist/utils/discussion-workspace.js +552 -0
- package/dist/utils/experience-workspace.js +326 -0
- package/dist/utils/guide-paths.js +67 -0
- package/dist/utils/hosted-sugar.js +56 -0
- package/dist/utils/hosted-workspace.js +229 -0
- package/dist/utils/memory-workspace.js +537 -0
- package/dist/utils/operator-runtime.js +199 -0
- package/dist/utils/password-crypto.js +39 -0
- package/dist/utils/playbook-workspace.js +479 -0
- package/dist/utils/project-context.js +255 -0
- package/dist/utils/prompts.js +70 -0
- package/dist/utils/refresh-race.js +28 -0
- package/dist/utils/repo-config.js +109 -0
- package/dist/utils/repo-first-projectman.js +194 -0
- package/dist/utils/repo-first-storage.js +13 -0
- package/dist/utils/repo-first-view.js +305 -0
- package/dist/utils/session-guidance.js +278 -0
- package/dist/utils/session-state.js +137 -0
- package/dist/utils/table.js +39 -0
- package/dist/utils/transient-fs.js +49 -0
- package/dist/utils/workspace-root.js +1 -0
- package/launchers/aops-cockpit.ps1 +15 -0
- package/launchers/aops-cockpit.sh +16 -0
- package/launchers/aops-server.ps1 +15 -0
- package/launchers/aops-server.sh +16 -0
- package/native/tui/win32-x64/aops-tui.exe +0 -0
- package/package.json +81 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { getActiveApiTarget, getApiTarget, listApiTargets, isRemoteSessionAuthProvider, normalizeApiTargetAuthProvider, normalizeApiTargetName, removeApiTarget, setApiTarget, useApiTarget, validateApiTarget, } from '../utils/config.js';
|
|
3
|
+
import { createCliApiClientFromOptions, fetchCliPublicJson } from '../utils/api.js';
|
|
4
|
+
import { evaluateCommunityCompatibility, resolveCommunityCliIdentity, } from '../lib/community-client-contract.js';
|
|
5
|
+
function output(value, json = false) {
|
|
6
|
+
if (json)
|
|
7
|
+
console.log(JSON.stringify(value, null, 2));
|
|
8
|
+
else if (typeof value === 'string')
|
|
9
|
+
console.log(value);
|
|
10
|
+
else
|
|
11
|
+
console.log(JSON.stringify(value, null, 2));
|
|
12
|
+
}
|
|
13
|
+
export async function runTargetAdd(options) {
|
|
14
|
+
const name = normalizeApiTargetName(options.name);
|
|
15
|
+
const target = validateApiTarget(options);
|
|
16
|
+
if (!options.apply) {
|
|
17
|
+
const result = {
|
|
18
|
+
status: 'preview',
|
|
19
|
+
mutationFree: true,
|
|
20
|
+
action: 'target-add',
|
|
21
|
+
target: { name, ...target, active: options.use === true },
|
|
22
|
+
next: 'Re-run with --apply to persist this target.',
|
|
23
|
+
};
|
|
24
|
+
options.resultSink?.(result);
|
|
25
|
+
if (!options.quiet)
|
|
26
|
+
output(result, options.json);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const result = setApiTarget({ ...options, name, activate: options.use });
|
|
30
|
+
const payload = { status: 'target-saved', target: result };
|
|
31
|
+
options.resultSink?.(payload);
|
|
32
|
+
if (!options.quiet)
|
|
33
|
+
output(payload, options.json);
|
|
34
|
+
}
|
|
35
|
+
export async function runTargetUse(name, options) {
|
|
36
|
+
const normalized = normalizeApiTargetName(name);
|
|
37
|
+
const target = getApiTarget(normalized);
|
|
38
|
+
if (!target)
|
|
39
|
+
throw new Error(`aops_target_not_found:${normalized}`);
|
|
40
|
+
if (!options.apply) {
|
|
41
|
+
output({
|
|
42
|
+
status: 'preview',
|
|
43
|
+
mutationFree: true,
|
|
44
|
+
action: 'target-use',
|
|
45
|
+
target: { ...target, active: true },
|
|
46
|
+
next: 'Re-run with --apply to select this target.',
|
|
47
|
+
}, options.json);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
output({ status: 'target-selected', target: useApiTarget(normalized) }, options.json);
|
|
51
|
+
}
|
|
52
|
+
export async function runTargetList(options) {
|
|
53
|
+
const targets = listApiTargets();
|
|
54
|
+
if (options.json)
|
|
55
|
+
output({ status: 'ok', targets }, true);
|
|
56
|
+
else if (targets.length === 0)
|
|
57
|
+
output('No targets configured.');
|
|
58
|
+
else
|
|
59
|
+
for (const target of targets) {
|
|
60
|
+
output(`${target.active ? '*' : ' '} ${target.name} ${target.apiBaseUrl} ${target.authProvider} credentials=${target.hasCredentials ? 'stored' : 'none'}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export async function runTargetShow(name, options) {
|
|
64
|
+
const target = name ? getApiTarget(name) : getActiveApiTarget();
|
|
65
|
+
if (!target)
|
|
66
|
+
throw new Error(name ? `aops_target_not_found:${name}` : 'aops_target_active_missing');
|
|
67
|
+
output({ status: 'ok', target }, options.json);
|
|
68
|
+
}
|
|
69
|
+
export async function runTargetRemove(name, options) {
|
|
70
|
+
const normalized = normalizeApiTargetName(name);
|
|
71
|
+
const target = getApiTarget(normalized);
|
|
72
|
+
if (!target)
|
|
73
|
+
throw new Error(`aops_target_not_found:${normalized}`);
|
|
74
|
+
if (!options.apply) {
|
|
75
|
+
output({
|
|
76
|
+
status: 'preview',
|
|
77
|
+
mutationFree: true,
|
|
78
|
+
action: 'target-remove',
|
|
79
|
+
target,
|
|
80
|
+
credentialsWillBeRemoved: target.hasCredentials,
|
|
81
|
+
next: 'Re-run with --apply --confirm to remove the target and its stored credentials.',
|
|
82
|
+
}, options.json);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!options.confirm)
|
|
86
|
+
throw new Error('aops_target_remove_confirmation_required:use_--confirm');
|
|
87
|
+
removeApiTarget(normalized);
|
|
88
|
+
output({ status: 'target-removed', name: normalized }, options.json);
|
|
89
|
+
}
|
|
90
|
+
export async function inspectTargetDoctor(name, options = {}) {
|
|
91
|
+
const target = name ? getApiTarget(name) : getActiveApiTarget();
|
|
92
|
+
if (!target)
|
|
93
|
+
throw new Error(name ? `aops_target_not_found:${name}` : 'aops_target_active_missing');
|
|
94
|
+
const cli = resolveCommunityCliIdentity();
|
|
95
|
+
const api = await createCliApiClientFromOptions({ targetName: target.name, timeoutMs: options.timeoutMs });
|
|
96
|
+
let discovery;
|
|
97
|
+
try {
|
|
98
|
+
discovery = await fetchCliPublicJson(api, '/api-info.json', {
|
|
99
|
+
timeoutMs: options.timeoutMs,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
return {
|
|
104
|
+
status: 'unavailable',
|
|
105
|
+
mutationFree: false,
|
|
106
|
+
networkMutationFree: true,
|
|
107
|
+
localConfigMigrationPossible: true,
|
|
108
|
+
target,
|
|
109
|
+
endpointSource: api.endpointSource,
|
|
110
|
+
serverIdentity: null,
|
|
111
|
+
bootstrap: null,
|
|
112
|
+
session: {
|
|
113
|
+
state: 'unavailable',
|
|
114
|
+
authenticated: null,
|
|
115
|
+
credentialsStored: target.hasCredentials,
|
|
116
|
+
principal: null,
|
|
117
|
+
httpStatus: null,
|
|
118
|
+
},
|
|
119
|
+
compatibility: {
|
|
120
|
+
status: 'incompatible',
|
|
121
|
+
compatible: false,
|
|
122
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
123
|
+
cli,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const compatibility = evaluateCommunityCompatibility(discovery?.clientCompatibility, cli);
|
|
128
|
+
let healthResponse;
|
|
129
|
+
try {
|
|
130
|
+
healthResponse = await api.client.requestXfJson('/api/health', { method: 'GET' }, { auth: false, retry401: false, timeoutMs: options.timeoutMs });
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
return {
|
|
134
|
+
status: 'unavailable',
|
|
135
|
+
mutationFree: false,
|
|
136
|
+
networkMutationFree: true,
|
|
137
|
+
localConfigMigrationPossible: true,
|
|
138
|
+
target,
|
|
139
|
+
endpointSource: api.endpointSource,
|
|
140
|
+
serverIdentity: compatibility.server ?? null,
|
|
141
|
+
bootstrap: null,
|
|
142
|
+
session: {
|
|
143
|
+
state: 'unavailable',
|
|
144
|
+
authenticated: null,
|
|
145
|
+
credentialsStored: target.hasCredentials,
|
|
146
|
+
principal: null,
|
|
147
|
+
httpStatus: null,
|
|
148
|
+
},
|
|
149
|
+
compatibility,
|
|
150
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const healthData = healthResponse.result?.data;
|
|
154
|
+
const bootstrap = healthData?.bootstrap;
|
|
155
|
+
const rawObservedProvider = bootstrap?.authProvider ?? bootstrap?.auth?.provider;
|
|
156
|
+
const observedProvider = normalizeApiTargetAuthProvider(rawObservedProvider) ?? null;
|
|
157
|
+
const observedAuthRequired = typeof bootstrap?.authRequired === 'boolean' ? bootstrap.authRequired : null;
|
|
158
|
+
const expectedAuthRequired = isRemoteSessionAuthProvider(target.authProvider);
|
|
159
|
+
const healthContractKnown = observedProvider !== null && observedAuthRequired !== null;
|
|
160
|
+
const providerMatches = observedProvider === target.authProvider;
|
|
161
|
+
const authRequiredMatches = observedAuthRequired === expectedAuthRequired;
|
|
162
|
+
const healthContractMatches = healthContractKnown && providerMatches && authRequiredMatches;
|
|
163
|
+
let session;
|
|
164
|
+
try {
|
|
165
|
+
const response = await api.client.requestXfJson('/api/auth/me', { method: 'GET' }, {
|
|
166
|
+
retry401: false,
|
|
167
|
+
timeoutMs: options.timeoutMs,
|
|
168
|
+
});
|
|
169
|
+
const responseData = response.result?.data;
|
|
170
|
+
const principal = responseData?.principal;
|
|
171
|
+
const principalUserId = typeof principal?.userId === 'string' ? principal.userId.trim() : '';
|
|
172
|
+
const principalResponseOk = response.status === 200 && response.result?.ok === true && Boolean(principalUserId);
|
|
173
|
+
const sessionProvider = normalizeApiTargetAuthProvider(responseData?.authProvider) ?? null;
|
|
174
|
+
const sessionAuthRequired = typeof responseData?.authRequired === 'boolean' ? responseData.authRequired : null;
|
|
175
|
+
const sessionContractKnown = !principalResponseOk || (sessionProvider !== null && sessionAuthRequired !== null);
|
|
176
|
+
const sessionProviderMatches = !principalResponseOk || sessionProvider === target.authProvider;
|
|
177
|
+
const sessionAuthRequiredMatches = !principalResponseOk || sessionAuthRequired === expectedAuthRequired;
|
|
178
|
+
const sessionContractMatches = sessionContractKnown && sessionProviderMatches && sessionAuthRequiredMatches;
|
|
179
|
+
const authenticated = principalResponseOk && sessionContractMatches;
|
|
180
|
+
const directError = response.result?.error;
|
|
181
|
+
const reason = typeof directError === 'string'
|
|
182
|
+
? directError
|
|
183
|
+
: response.result?.messages?.map((message) => message.messageText).filter(Boolean).join('; ') || null;
|
|
184
|
+
session = {
|
|
185
|
+
state: principalResponseOk && !sessionContractKnown
|
|
186
|
+
? 'auth-contract-unknown'
|
|
187
|
+
: principalResponseOk && !sessionContractMatches
|
|
188
|
+
? 'auth-provider-mismatch'
|
|
189
|
+
: authenticated
|
|
190
|
+
? expectedAuthRequired ? 'authenticated' : 'trusted-local'
|
|
191
|
+
: 'authentication-required',
|
|
192
|
+
authenticated,
|
|
193
|
+
credentialsStored: target.hasCredentials,
|
|
194
|
+
authProvider: sessionProvider,
|
|
195
|
+
authRequired: sessionAuthRequired,
|
|
196
|
+
contractKnown: sessionContractKnown,
|
|
197
|
+
providerMatches: sessionProviderMatches,
|
|
198
|
+
authRequiredMatches: sessionAuthRequiredMatches,
|
|
199
|
+
principal: authenticated
|
|
200
|
+
? {
|
|
201
|
+
userId: principalUserId,
|
|
202
|
+
...(typeof principal?.email === 'string' ? { email: principal.email } : {}),
|
|
203
|
+
...(typeof principal?.fullName === 'string' ? { fullName: principal.fullName } : {}),
|
|
204
|
+
...(Array.isArray(principal?.roles) ? { roles: principal.roles } : {}),
|
|
205
|
+
...(Array.isArray(principal?.capabilities) ? { capabilities: principal.capabilities } : {}),
|
|
206
|
+
}
|
|
207
|
+
: null,
|
|
208
|
+
httpStatus: response.status,
|
|
209
|
+
reason,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
session = {
|
|
214
|
+
state: 'unavailable',
|
|
215
|
+
authenticated: null,
|
|
216
|
+
credentialsStored: target.hasCredentials,
|
|
217
|
+
principal: null,
|
|
218
|
+
httpStatus: null,
|
|
219
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const authenticated = session.authenticated === true;
|
|
223
|
+
const status = !compatibility.compatible
|
|
224
|
+
? 'incompatible'
|
|
225
|
+
: healthResponse.status < 200 || healthResponse.status >= 300
|
|
226
|
+
? 'bootstrap-action-required'
|
|
227
|
+
: !healthContractKnown || session.state === 'auth-contract-unknown'
|
|
228
|
+
? 'auth-contract-unknown'
|
|
229
|
+
: !healthContractMatches || session.state === 'auth-provider-mismatch'
|
|
230
|
+
? 'auth-provider-mismatch'
|
|
231
|
+
: expectedAuthRequired && !authenticated
|
|
232
|
+
? 'authentication-required'
|
|
233
|
+
: compatibility.status;
|
|
234
|
+
return {
|
|
235
|
+
status,
|
|
236
|
+
mutationFree: false,
|
|
237
|
+
networkMutationFree: true,
|
|
238
|
+
localConfigMigrationPossible: true,
|
|
239
|
+
target,
|
|
240
|
+
endpointSource: api.endpointSource,
|
|
241
|
+
serverIdentity: compatibility.server ?? null,
|
|
242
|
+
health: {
|
|
243
|
+
httpStatus: healthResponse.status,
|
|
244
|
+
status: healthData?.status ?? null,
|
|
245
|
+
service: healthData?.service ?? null,
|
|
246
|
+
},
|
|
247
|
+
bootstrap: {
|
|
248
|
+
authProvider: observedProvider,
|
|
249
|
+
authRequired: observedAuthRequired,
|
|
250
|
+
configOk: bootstrap?.configOk ?? null,
|
|
251
|
+
loginSupported: bootstrap?.auth?.loginSupported ?? null,
|
|
252
|
+
storagePolicyOk: bootstrap?.auth?.storagePolicyOk ?? null,
|
|
253
|
+
firstAdminState: bootstrap?.auth?.firstAdminState ?? null,
|
|
254
|
+
userCount: bootstrap?.auth?.userCount ?? null,
|
|
255
|
+
adminUserCount: bootstrap?.auth?.adminUserCount ?? null,
|
|
256
|
+
expectedAuthProvider: target.authProvider,
|
|
257
|
+
expectedAuthRequired,
|
|
258
|
+
contractKnown: healthContractKnown,
|
|
259
|
+
providerMatches,
|
|
260
|
+
authRequiredMatches,
|
|
261
|
+
},
|
|
262
|
+
session,
|
|
263
|
+
compatibility,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
export async function runTargetDoctor(name, options) {
|
|
267
|
+
const result = await inspectTargetDoctor(name, options);
|
|
268
|
+
output(result, options.json);
|
|
269
|
+
if (result.status === 'incompatible' ||
|
|
270
|
+
result.status === 'unavailable' ||
|
|
271
|
+
result.status === 'auth-contract-unknown' ||
|
|
272
|
+
result.status === 'auth-provider-mismatch' ||
|
|
273
|
+
result.status === 'bootstrap-action-required' ||
|
|
274
|
+
result.status === 'authentication-required')
|
|
275
|
+
process.exitCode = 1;
|
|
276
|
+
}
|
|
277
|
+
export function makeTargetCommand() {
|
|
278
|
+
const command = new Command('target').description('Manage named local or remote AOPS server targets');
|
|
279
|
+
command.command('add')
|
|
280
|
+
.requiredOption('--name <name>', 'Stable local target name')
|
|
281
|
+
.requiredOption('--api-base-url <url>', 'Server base URL without credentials or a path')
|
|
282
|
+
.option('--auth-provider <trusted-local|remote-session>', 'Authentication policy; authv2-jwt-session remains a one-release alias')
|
|
283
|
+
.option('--tls-policy <loopback-http|system-ca>', 'Transport trust policy')
|
|
284
|
+
.option('--use', 'Select this target after it is saved')
|
|
285
|
+
.option('--apply', 'Persist the target; default is a mutation-free preview')
|
|
286
|
+
.option('--json', 'Output JSON')
|
|
287
|
+
.action(runTargetAdd);
|
|
288
|
+
command.command('use <name>')
|
|
289
|
+
.option('--apply', 'Persist the active target; default is a mutation-free preview')
|
|
290
|
+
.option('--json', 'Output JSON')
|
|
291
|
+
.action(runTargetUse);
|
|
292
|
+
command.command('list').option('--json', 'Output JSON').action(runTargetList);
|
|
293
|
+
command.command('show [name]').option('--json', 'Output JSON').action(runTargetShow);
|
|
294
|
+
command.command('remove <name>')
|
|
295
|
+
.option('--apply', 'Remove the target; default is a mutation-free preview')
|
|
296
|
+
.option('--confirm', 'Confirm removal of the target and its credentials')
|
|
297
|
+
.option('--json', 'Output JSON')
|
|
298
|
+
.action(runTargetRemove);
|
|
299
|
+
command.command('doctor [name]')
|
|
300
|
+
.option('--timeout-ms <ms>', 'Request timeout', (value) => Number.parseInt(value, 10))
|
|
301
|
+
.option('--json', 'Output JSON')
|
|
302
|
+
.action(runTargetDoctor)
|
|
303
|
+
.addHelpText('after', `
|
|
304
|
+
Plain HTTP is accepted only for loopback trusted-local targets. Every
|
|
305
|
+
remote-session target, including Tailscale addresses, must use HTTPS with the
|
|
306
|
+
system CA policy.
|
|
307
|
+
`);
|
|
308
|
+
return command;
|
|
309
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { getActiveApiTarget } from '../utils/config.js';
|
|
3
|
+
import { inspectCommunityInstall } from '../lib/community-lifecycle.js';
|
|
4
|
+
import { resolveCommunityCliIdentity } from '../lib/community-client-contract.js';
|
|
5
|
+
export async function runVersion(options = {}) {
|
|
6
|
+
const identity = resolveCommunityCliIdentity();
|
|
7
|
+
if (!options.verbose) {
|
|
8
|
+
if (options.json)
|
|
9
|
+
console.log(JSON.stringify(identity, null, 2));
|
|
10
|
+
else
|
|
11
|
+
console.log(identity.version);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const target = getActiveApiTarget();
|
|
15
|
+
const install = inspectCommunityInstall({ instanceName: options.instance, dataRoot: options.dataRoot });
|
|
16
|
+
const result = {
|
|
17
|
+
cli: identity,
|
|
18
|
+
selectedTarget: target ?? null,
|
|
19
|
+
localInstance: install.status === 'installed'
|
|
20
|
+
? {
|
|
21
|
+
status: install.status,
|
|
22
|
+
instance: install.state.instanceName,
|
|
23
|
+
runtime: 'oci',
|
|
24
|
+
releaseVersion: install.state.activeRelease.releaseVersion,
|
|
25
|
+
}
|
|
26
|
+
: { status: install.status, instanceRoot: install.paths.instanceRoot },
|
|
27
|
+
compatibility: target?.compatibility ?? null,
|
|
28
|
+
};
|
|
29
|
+
if (options.json)
|
|
30
|
+
console.log(JSON.stringify(result, null, 2));
|
|
31
|
+
else
|
|
32
|
+
console.log(JSON.stringify(result, null, 2));
|
|
33
|
+
}
|
|
34
|
+
export function makeVersionCommand() {
|
|
35
|
+
return new Command('version')
|
|
36
|
+
.description('Show immutable CLI identity and optional target/runtime context')
|
|
37
|
+
.option('--verbose', 'Include selected target, local instance, and last observed compatibility')
|
|
38
|
+
.option('--instance <name>', 'Local instance name used by --verbose', 'default')
|
|
39
|
+
.option('--data-root <path>', 'Local instance data-root override')
|
|
40
|
+
.option('--json', 'Output JSON')
|
|
41
|
+
.action(runVersion);
|
|
42
|
+
}
|