@codiac.io/codiac-cli 1.3.236 → 1.3.238

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.
@@ -16758,3 +16758,65 @@ export type CabinetRestoreRequest = {
16758
16758
  enterprise?: string;
16759
16759
  skipCabinets?: boolean;
16760
16760
  };
16761
+ export type AgentFrameworkKind = "openclaw" | "hermes" | "byoa";
16762
+ export type HostNamingSpec = {
16763
+ strategy: string;
16764
+ domain?: string;
16765
+ };
16766
+ export type AiAgentProvisionRequest = {
16767
+ enterprise: string;
16768
+ cabinet: string;
16769
+ framework: AgentFrameworkKind;
16770
+ name?: string;
16771
+ hasIngress?: boolean;
16772
+ model?: string;
16773
+ hostNaming?: HostNamingSpec;
16774
+ overrides?: Record<string, any>;
16775
+ inputs?: Record<string, string>;
16776
+ correlationId?: string;
16777
+ socketId?: string;
16778
+ };
16779
+ export type StepResult = {
16780
+ step: string;
16781
+ status: "done" | "skipped" | "autoResolved" | "blocked" | "failed";
16782
+ detail?: string;
16783
+ };
16784
+ export type InputField = {
16785
+ name: string;
16786
+ label: string;
16787
+ type?: string;
16788
+ secret?: boolean;
16789
+ };
16790
+ export type ResolvedBy = {
16791
+ kind: string;
16792
+ cliCommand?: string;
16793
+ frontendRoute?: string;
16794
+ params?: Record<string, any>;
16795
+ needs?: Array<InputField>;
16796
+ };
16797
+ export type Remediation = {
16798
+ step: string;
16799
+ code: string;
16800
+ reason: string;
16801
+ resolvedBy: ResolvedBy;
16802
+ reattempt: boolean;
16803
+ };
16804
+ export type ProvisionedAgent = {
16805
+ name: string;
16806
+ cabinet: string;
16807
+ namespace?: string;
16808
+ service?: string;
16809
+ url?: string;
16810
+ };
16811
+ export type ProvisionError = {
16812
+ message: string;
16813
+ step?: string;
16814
+ cause?: string;
16815
+ };
16816
+ export type AiAgentProvisionResult = {
16817
+ status: "ok" | "needs_action" | "failed";
16818
+ steps: Array<StepResult>;
16819
+ nextAction?: Remediation;
16820
+ agent?: ProvisionedAgent;
16821
+ error?: ProvisionError;
16822
+ };
@@ -0,0 +1,73 @@
1
+ import { AtLeast } from '@codiac.io/codiac-common/contracts';
2
+ import { CommandBaseExec, IEnterpriseEntity } from '../../../command-base-exec';
3
+ import { RootMap } from '../../../apis/codiac-api/contracts';
4
+ export type AgentType = 'openclaw' | 'hermes' | 'byoa';
5
+ export interface IAgentInstallRequest extends IEnterpriseEntity {
6
+ enterprise: string;
7
+ cabinet: string;
8
+ type: AgentType;
9
+ name: string;
10
+ hasIngress: boolean;
11
+ /** Host-naming strategy to apply to the ingress host (pass-through only; strategy UX lands separately). */
12
+ naming?: string;
13
+ /** Domain paired with the naming strategy for the ingress host (pass-through only; strategy UX lands separately). */
14
+ domain?: string;
15
+ }
16
+ export default class AiAgentInstall extends CommandBaseExec<IAgentInstallRequest> {
17
+ static description: string;
18
+ static examples: {
19
+ description: string;
20
+ command: string;
21
+ }[];
22
+ static flags: {
23
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
24
+ enterpriseCode: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
25
+ type: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
26
+ cabinet: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
27
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
28
+ ingress: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
29
+ naming: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
30
+ domain: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
31
+ input: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
32
+ "take-defaults": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
33
+ silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
34
+ echo: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
35
+ "to-script": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
36
+ };
37
+ static args: {};
38
+ protected adminOnly: boolean;
39
+ captureArgs(): Promise<[
40
+ partial: Partial<IAgentInstallRequest>,
41
+ takeDefaults: boolean,
42
+ explicit?: Partial<IAgentInstallRequest>
43
+ ]>;
44
+ buildCandidate_silently(partial: AtLeast<IAgentInstallRequest, "enterprise">, _rootMap: RootMap, _explicit?: Partial<IAgentInstallRequest>): Promise<IAgentInstallRequest | undefined>;
45
+ buildCandidate_interactively(partial: AtLeast<IAgentInstallRequest, "enterprise">, rootMap: RootMap, takeDefaults: boolean, explicit?: Partial<IAgentInstallRequest>): Promise<IAgentInstallRequest | undefined>;
46
+ private setType;
47
+ private setName;
48
+ private setHasIngress;
49
+ /** Resolves `partial.naming` (and `partial.domain` when the strategy needs one) for the
50
+ * WebTerminal ingress host. Mutates `partial` in place. Returns `false` on a clean user
51
+ * cancel (caller must then return `undefined` from `buildCandidate_interactively`).
52
+ *
53
+ * Read-only: only ever calls `ScopedHostNameConfig.readMany` (best-effort, for the "use an
54
+ * existing mapping" list). Never calls `executeDomainUpsert` or any relay mutation — the
55
+ * actual host-map upsert happens during Task 9's provisioning. */
56
+ private setHostNamingStrategy;
57
+ buildCommandString(candidate: IAgentInstallRequest, cmd: string[]): string[];
58
+ executeTask(candidate: IAgentInstallRequest): Promise<void>;
59
+ /** Maps the resolved candidate (plus any remediation inputs gathered so far) to the
60
+ * `post.ai-agent-provision` request shape. */
61
+ private toProvisionRequest;
62
+ /** One line per step: `<step>: <status>` (+ detail when present). */
63
+ private printStepResults;
64
+ /** Best-effort, informational-only WebTerminal access note — never blocks or fails the
65
+ * command. Prefers the server-resolved `agent.url` when present; falls back to describing
66
+ * the requested strategy since the exact resolved host depends on the host-map's own logic. */
67
+ private printAccessInfo;
68
+ /** Silent mode disables all prompting (the base lifecycle rebinds `_ui` to a throwing
69
+ * provider) — mirrors the same detection `CommandBaseExec.runAsync()` uses, so a
70
+ * `needs_action` response can fail fast with a clear message instead of a raw
71
+ * "cannot acquire input" error. */
72
+ private isSilentMode;
73
+ }
@@ -0,0 +1,417 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const _ = require("lodash");
6
+ const host_name_strategy_enum_1 = require("@codiac.io/codiac-domain/host-name-strategy-enum");
7
+ const command_base_exec_1 = require("../../../command-base-exec");
8
+ const framework_spec_1 = require("../../../uilogic/framework-spec");
9
+ const AGENT_TYPES = ['openclaw', 'hermes', 'byoa'];
10
+ /** Validates a user-supplied strategy against the enum's VALUE form (snake_case wire
11
+ * values), not its KEY form. `host/map.ts` uses `naming in HostNameStrategyEnum`, which
12
+ * checks object KEYS (camelCase) — a latent quirk there we deliberately do not replicate. */
13
+ const isValidStrategy = (s) => Object.values(host_name_strategy_enum_1.HostNameStrategyEnum).includes(s);
14
+ /** MVP heuristic: a strategy needs a paired domain when its wire value mentions "domain".
15
+ * Every current strategy value fits this rule except `shared_ingress_ip`. If a future
16
+ * strategy is added that breaks the pattern, this heuristic will need to become explicit. */
17
+ const strategyNeedsDomain = (s) => s.includes("domain");
18
+ class AiAgentInstall extends command_base_exec_1.CommandBaseExec {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.adminOnly = true;
22
+ }
23
+ captureArgs() {
24
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
+ const { flags } = yield this.parse(AiAgentInstall);
26
+ let partial = {};
27
+ let explicit = {};
28
+ if (flags.enterpriseCode)
29
+ partial.enterprise = flags.enterpriseCode;
30
+ if (flags.type) {
31
+ partial.type = flags.type;
32
+ explicit.type = partial.type;
33
+ }
34
+ if (flags.cabinet) {
35
+ partial.cabinet = flags.cabinet;
36
+ explicit.cabinet = partial.cabinet;
37
+ }
38
+ if (flags.name) {
39
+ partial.name = flags.name.trim();
40
+ explicit.name = partial.name;
41
+ }
42
+ // Boolean switch: oclif always supplies a value (default: true), so explicit-vs-default
43
+ // cannot be distinguished here. Per the brief, mirror only to partial and skip the
44
+ // explicit snapshot for this flag.
45
+ partial.hasIngress = flags.ingress;
46
+ if (flags.naming) {
47
+ partial.naming = flags.naming;
48
+ explicit.naming = partial.naming;
49
+ }
50
+ if (flags.domain) {
51
+ partial.domain = flags.domain;
52
+ explicit.domain = partial.domain;
53
+ }
54
+ const takeDefaults = flags['take-defaults'];
55
+ return [partial, takeDefaults, explicit];
56
+ });
57
+ }
58
+ buildCandidate_silently(partial, _rootMap, _explicit) {
59
+ var _a, _b;
60
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
61
+ if (partial.type == undefined)
62
+ throw new Error("Must specify agent type (--type openclaw|hermes|byoa).");
63
+ if (!AGENT_TYPES.includes(partial.type))
64
+ throw new Error(`Invalid agent type [${partial.type}]; must be one of: openclaw, hermes, byoa.`);
65
+ const spec = (0, framework_spec_1.resolveFrameworkSpec)(partial.type);
66
+ if (!spec.supported)
67
+ throw new Error((_a = spec.comingSoon) !== null && _a !== void 0 ? _a : `Agent type [${partial.type}] is not yet supported.`);
68
+ // NOTE: presence-only validation here. Cross-checking the cabinet against the rootMap
69
+ // (existence, cluster assignment, etc.) is deferred to Task 9's real provisioning logic.
70
+ if (partial.cabinet == undefined || _.isEmpty(partial.cabinet))
71
+ throw new Error("Must specify cabinet.");
72
+ const name = partial.name && !_.isEmpty(partial.name) ? partial.name : spec.defaultName;
73
+ const hasIngress = (_b = partial.hasIngress) !== null && _b !== void 0 ? _b : true;
74
+ if (hasIngress) {
75
+ if (partial.naming == undefined || _.isEmpty(partial.naming))
76
+ throw new Error("A host-naming strategy is required when the agent has ingress (pass --naming, or use --no-ingress). Example: --naming svc_dot_cab_dot_domain.");
77
+ if (!isValidStrategy(partial.naming))
78
+ throw new Error(`Invalid host-naming strategy [${partial.naming}]. Valid values: ${Object.values(host_name_strategy_enum_1.HostNameStrategyEnum).join(", ")}.`);
79
+ if (strategyNeedsDomain(partial.naming) && (partial.domain == undefined || _.isEmpty(partial.domain)))
80
+ throw new Error(`Strategy [${partial.naming}] requires a domain (pass --domain, e.g. --domain oncodiac.io).`);
81
+ }
82
+ return Object.assign(Object.assign({ enterprise: partial.enterprise, cabinet: partial.cabinet, type: partial.type, name,
83
+ hasIngress }, (partial.naming ? { naming: partial.naming } : {})), (partial.domain ? { domain: partial.domain } : {}));
84
+ });
85
+ }
86
+ buildCandidate_interactively(partial, rootMap, takeDefaults, explicit) {
87
+ var _a;
88
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
89
+ const overrides = [];
90
+ // --- type -----------------------------------------------------------
91
+ partial.type = yield this.setType(partial.type, takeDefaults, overrides);
92
+ const spec = (0, framework_spec_1.resolveFrameworkSpec)(partial.type);
93
+ if (!spec.supported) {
94
+ this._ui.userMessage(this._styler.colorWarning((_a = spec.comingSoon) !== null && _a !== void 0 ? _a : `Agent type [${partial.type}] is not yet supported.`));
95
+ return undefined; // clean cancel — lifecycle prints "Operation cancelled. No work was done."
96
+ }
97
+ // --- cabinet ----------------------------------------------------------
98
+ // Reuse the existing rootMapUtils cabinet picker rather than hand-rolling
99
+ // selection/validation/confirmation logic (it already implements Rules 1-3).
100
+ const [cabinet] = yield this.rootMapUtils.promptForCabinet(partial.enterprise, rootMap, partial.cabinet, takeDefaults, undefined, explicit === null || explicit === void 0 ? void 0 : explicit.cabinet);
101
+ partial.cabinet = cabinet.name;
102
+ // --- name ---------------------------------------------------------------
103
+ partial.name = yield this.setName(partial.name, partial.type, takeDefaults, explicit === null || explicit === void 0 ? void 0 : explicit.name);
104
+ // --- hasIngress -----------------------------------------------------------
105
+ partial.hasIngress = yield this.setHasIngress(partial.hasIngress, takeDefaults);
106
+ // --- naming/domain (host-map for the WebTerminal ingress) -----------------
107
+ // Pure resolution + validation only — no relay/API mutation here. The actual
108
+ // host-map upsert happens during Task 9's provisioning.
109
+ if (partial.hasIngress) {
110
+ const proceeded = yield this.setHostNamingStrategy(partial, explicit);
111
+ if (!proceeded)
112
+ return undefined; // clean cancel — lifecycle prints "Operation cancelled. No work was done."
113
+ }
114
+ if (overrides.length > 0) {
115
+ this._ui.userMessage(this._styler.colorWarning("One or more provided values were invalid and have been replaced:"));
116
+ for (const o of overrides) {
117
+ this._ui.userMessage(` ${o.param}: ${this._styler.colorWarning(o.given)} → ${this._styler.hilite(o.using)}`);
118
+ }
119
+ const confirmed = yield this._ui.promptConfirm("confirmOverrides", "Proceed with the above substitutions?", true);
120
+ if (!confirmed)
121
+ return undefined;
122
+ }
123
+ return yield this.buildCandidate_silently(partial, rootMap, explicit);
124
+ });
125
+ }
126
+ setType(userInput, takeDefaults, overrides) {
127
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
128
+ let invalidInput = false;
129
+ if (userInput != undefined && !AGENT_TYPES.includes(userInput)) {
130
+ invalidInput = true;
131
+ overrides.push({ param: 'type', given: String(userInput), using: '(to be selected)' });
132
+ userInput = undefined;
133
+ }
134
+ if (userInput != undefined) {
135
+ this._ui.userMessage(`Agent type: ${this._styler.hilite(userInput)}`);
136
+ return userInput;
137
+ }
138
+ if (invalidInput) {
139
+ this._ui.userMessage(this._styler.colorWarning("Provided agent type was not valid; please select from the list below."));
140
+ }
141
+ const selected = yield this._ui.promptSelect('type', 'Select agent type to install:', AGENT_TYPES, false, false);
142
+ const resolved = selected !== null && selected !== void 0 ? selected : AGENT_TYPES[0];
143
+ if (invalidInput) {
144
+ overrides[overrides.length - 1].using = resolved;
145
+ }
146
+ return resolved;
147
+ });
148
+ }
149
+ setName(userInput, type, takeDefaults, userSuppliedValue) {
150
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
151
+ if (userInput && !_.isEmpty(userInput)) {
152
+ if (userSuppliedValue == userInput) {
153
+ this._ui.userMessage(`Agent name: ${this._styler.hilite(userInput)}`);
154
+ return userInput;
155
+ }
156
+ }
157
+ const defaultName = (0, framework_spec_1.resolveFrameworkSpec)(type).defaultName;
158
+ if (takeDefaults) {
159
+ this._ui.userMessage(`Agent name: ${this._styler.hilite(defaultName)}`);
160
+ return defaultName;
161
+ }
162
+ const confirmed = yield this._ui.promptConfirm('name', `Agent name: ${this._styler.hilite(defaultName)} `, true);
163
+ if (confirmed)
164
+ return defaultName;
165
+ const typed = yield this._ui.prompt('name', 'Enter agent name:', true, defaultName);
166
+ return (typed && !_.isEmpty(typed)) ? typed : defaultName;
167
+ });
168
+ }
169
+ setHasIngress(userInput, takeDefaults) {
170
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
171
+ const defaultValue = userInput !== null && userInput !== void 0 ? userInput : true;
172
+ if (takeDefaults) {
173
+ this._ui.userMessage(`Expose via ingress: ${this._styler.hilite(String(defaultValue))}`);
174
+ return defaultValue;
175
+ }
176
+ return yield this._ui.promptConfirm('hasIngress', `Expose the agent web terminal through an ingress host? `, defaultValue);
177
+ });
178
+ }
179
+ /** Resolves `partial.naming` (and `partial.domain` when the strategy needs one) for the
180
+ * WebTerminal ingress host. Mutates `partial` in place. Returns `false` on a clean user
181
+ * cancel (caller must then return `undefined` from `buildCandidate_interactively`).
182
+ *
183
+ * Read-only: only ever calls `ScopedHostNameConfig.readMany` (best-effort, for the "use an
184
+ * existing mapping" list). Never calls `executeDomainUpsert` or any relay mutation — the
185
+ * actual host-map upsert happens during Task 9's provisioning. */
186
+ setHostNamingStrategy(partial, explicit) {
187
+ var _a, _b, _c, _d;
188
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
189
+ // 1. Explicit, valid --naming already given: accept it (Rule 2 — do not re-prompt).
190
+ if ((explicit === null || explicit === void 0 ? void 0 : explicit.naming) != undefined) {
191
+ if (isValidStrategy(explicit.naming)) {
192
+ this._ui.userMessage(`Host naming strategy: ${this._styler.hilite(explicit.naming)}`);
193
+ if (strategyNeedsDomain(explicit.naming) && (partial.domain == undefined || _.isEmpty(partial.domain))) {
194
+ partial.domain = (_a = (yield this._ui.prompt("domain", "Domain (e.g. oncodiac.io): "))) === null || _a === void 0 ? void 0 : _a.trim();
195
+ }
196
+ return true;
197
+ }
198
+ this._ui.userMessage(this._styler.colorWarning(`Provided host-naming strategy [${explicit.naming}] is not valid; please select from the list below.`));
199
+ }
200
+ // 2. Best-effort fetch of existing host mappings on this enterprise.
201
+ let existing = [];
202
+ try {
203
+ existing = (_b = yield this._codiacApi.ScopedHostNameConfig.readMany({ enterprise: partial.enterprise })) !== null && _b !== void 0 ? _b : [];
204
+ }
205
+ catch (err) {
206
+ this.logger.detail(`Could not load existing host mappings: ${(_c = err === null || err === void 0 ? void 0 : err.message) !== null && _c !== void 0 ? _c : err}`);
207
+ }
208
+ // 3. Offer "use an existing mapping" vs "create a new one" when mappings already exist.
209
+ if (existing.length > 0) {
210
+ const choice = yield this._ui.promptSelect("useExisting", "Use an existing host mapping, or create a new one?", [
211
+ { name: "Use an existing host mapping", value: "existing" },
212
+ { name: "Create a new one", value: "new" },
213
+ ]);
214
+ if (!choice)
215
+ return false; // clean cancel
216
+ if (choice === "existing") {
217
+ const mappingChoices = existing.map((m, i) => ({ name: `${m.strategy} — ${m.domainName}`, value: String(i) }));
218
+ const selectedIdx = yield this._ui.promptSelect("existingMapping", "Select an existing host mapping:", mappingChoices);
219
+ if (selectedIdx == undefined)
220
+ return false; // clean cancel
221
+ const selected = existing[Number(selectedIdx)];
222
+ partial.naming = selected.strategy;
223
+ partial.domain = selected.domainName;
224
+ return true;
225
+ }
226
+ // "new" falls through to step 4 below.
227
+ }
228
+ // 4. New mapping: select a strategy (mirrors host/map's display transform), then a domain
229
+ // when the chosen strategy needs one.
230
+ const strategies = Object.values(host_name_strategy_enum_1.HostNameStrategyEnum).sort()
231
+ .map(x => ({ value: x, name: x.replace(/_dot_/g, ".").replace(/_slash_/g, "/") }));
232
+ const chosen = yield this._ui.promptSelect("naming", "Host naming strategy", strategies);
233
+ if (!chosen)
234
+ return false; // clean cancel
235
+ partial.naming = chosen;
236
+ if (strategyNeedsDomain(partial.naming) && (partial.domain == undefined || _.isEmpty(partial.domain))) {
237
+ partial.domain = (_d = (yield this._ui.prompt("domain", "Domain (e.g. oncodiac.io): "))) === null || _d === void 0 ? void 0 : _d.trim();
238
+ }
239
+ return true;
240
+ });
241
+ }
242
+ buildCommandString(candidate, cmd) {
243
+ cmd.push("-e", candidate.enterprise);
244
+ cmd.push("-t", candidate.type);
245
+ cmd.push("-c", candidate.cabinet);
246
+ cmd.push("-n", candidate.name);
247
+ cmd.push(candidate.hasIngress ? "--ingress" : "--no-ingress");
248
+ if (candidate.naming)
249
+ cmd.push("--naming", candidate.naming);
250
+ if (candidate.domain)
251
+ cmd.push("--domain", candidate.domain);
252
+ cmd.push("--silent");
253
+ return cmd;
254
+ }
255
+ // NOTE: thin client over `post.ai-agent-provision` — all provisioning logic (operator,
256
+ // asset deploy, host-map) lives server-side in the relay. This method only builds the
257
+ // request, calls the endpoint, and drives the needs_action remediation loop.
258
+ executeTask(candidate) {
259
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
260
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
261
+ // Seed inputs from any --input key=value flags so a needs_action requiring those
262
+ // values (e.g. inline secrets) resolves on the first call — the headless/silent path.
263
+ const inputs = {};
264
+ const { flags } = yield this.parse(AiAgentInstall);
265
+ for (const kv of ((_a = flags.input) !== null && _a !== void 0 ? _a : [])) {
266
+ const eq = kv.indexOf('=');
267
+ if (eq > 0)
268
+ inputs[kv.slice(0, eq)] = kv.slice(eq + 1);
269
+ }
270
+ const attemptedCodes = new Set();
271
+ while (true) {
272
+ const request = this.toProvisionRequest(candidate, inputs);
273
+ const result = yield this.genRelayClient.Call.aiAgentProvision(request);
274
+ if (result.error || !result.output) {
275
+ const msg = `Error provisioning agent [${candidate.name}]: ${(_b = result.message) !== null && _b !== void 0 ? _b : ''} ${(_d = (_c = result.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : ''}`.trimEnd();
276
+ this.logger.error(msg, result.error);
277
+ this._ui.userMessage(`${this._styler.colorCritical('ERROR!')} ${msg}`);
278
+ throw (_e = result.error) !== null && _e !== void 0 ? _e : new Error(msg);
279
+ }
280
+ const out = result.output;
281
+ this.printStepResults(out.steps);
282
+ if (out.status === 'ok') {
283
+ this.printAccessInfo(candidate, out.agent);
284
+ return;
285
+ }
286
+ if (out.status === 'failed') {
287
+ const msg = `Failed provisioning agent [${candidate.name}]: ${(_g = (_f = out.error) === null || _f === void 0 ? void 0 : _f.message) !== null && _g !== void 0 ? _g : ''}`.trimEnd();
288
+ this.logger.notice(msg, out);
289
+ this._ui.userMessage(`${this._styler.colorCritical('FAILED!')} ${msg}`);
290
+ throw new Error(msg);
291
+ }
292
+ // status === 'needs_action'
293
+ const rem = out.nextAction;
294
+ const needs = (_j = (_h = rem.resolvedBy) === null || _h === void 0 ? void 0 : _h.needs) !== null && _j !== void 0 ? _j : [];
295
+ if (this.isSilentMode()) {
296
+ const missing = needs.map(f => f.name).join(', ');
297
+ const hint = ((_k = rem.resolvedBy) === null || _k === void 0 ? void 0 : _k.cliCommand) ? ` Resolve with: ${rem.resolvedBy.cliCommand}` : '';
298
+ throw new Error(`Cannot proceed in --silent mode: ${rem.reason}${missing ? ` (missing: ${missing})` : ''}.${hint}`);
299
+ }
300
+ if (needs.length > 0) {
301
+ for (const f of needs) {
302
+ const value = f.secret
303
+ ? yield this._ui.promptPassword(f.name, `${rem.reason}\n${f.label}:`)
304
+ : yield this._ui.prompt(f.name, `${rem.reason}\n${f.label}:`, true);
305
+ if (value != undefined)
306
+ inputs[f.name] = value;
307
+ }
308
+ }
309
+ else {
310
+ this._ui.userMessage(this._styler.colorWarning(`Action needed (${rem.code}): ${rem.reason}`));
311
+ if ((_l = rem.resolvedBy) === null || _l === void 0 ? void 0 : _l.cliCommand)
312
+ this._ui.userMessage(`Resolve with: ${this._styler.hilite(rem.resolvedBy.cliCommand)}`);
313
+ const proceed = yield this._ui.promptConfirm('recheck', "Re-check after you've resolved this?", true);
314
+ if (!proceed)
315
+ return;
316
+ }
317
+ // Loop guard: if we come back with the SAME remediation code AND gathered no new
318
+ // inputs, abort — prevents spinning forever on a condition that never clears.
319
+ if (attemptedCodes.has(rem.code) && needs.length === 0) {
320
+ const msg = `Still blocked on [${rem.code}]: ${rem.reason}`;
321
+ this._ui.userMessage(this._styler.colorCritical(msg));
322
+ throw new Error(msg);
323
+ }
324
+ attemptedCodes.add(rem.code);
325
+ }
326
+ });
327
+ }
328
+ /** Maps the resolved candidate (plus any remediation inputs gathered so far) to the
329
+ * `post.ai-agent-provision` request shape. */
330
+ toProvisionRequest(candidate, inputs) {
331
+ return {
332
+ enterprise: candidate.enterprise,
333
+ cabinet: candidate.cabinet,
334
+ framework: candidate.type,
335
+ name: candidate.name,
336
+ hasIngress: candidate.hasIngress,
337
+ hostNaming: candidate.hasIngress ? { strategy: candidate.naming, domain: candidate.domain } : undefined,
338
+ inputs,
339
+ };
340
+ }
341
+ /** One line per step: `<step>: <status>` (+ detail when present). */
342
+ printStepResults(steps) {
343
+ for (const s of steps) {
344
+ const line = s.detail ? `${s.step}: ${s.status} — ${s.detail}` : `${s.step}: ${s.status}`;
345
+ if (s.status === 'failed')
346
+ this._ui.userMessage(this._styler.colorCritical(line));
347
+ else if (s.status === 'blocked')
348
+ this._ui.userMessage(this._styler.colorWarning(line));
349
+ else
350
+ this._ui.userMessage(this._styler.colorGood(line));
351
+ }
352
+ }
353
+ /** Best-effort, informational-only WebTerminal access note — never blocks or fails the
354
+ * command. Prefers the server-resolved `agent.url` when present; falls back to describing
355
+ * the requested strategy since the exact resolved host depends on the host-map's own logic. */
356
+ printAccessInfo(candidate, agent) {
357
+ var _a;
358
+ if (agent === null || agent === void 0 ? void 0 : agent.url) {
359
+ this._ui.userMessage(`${this._styler.colorGood('READY')} WebTerminal ingress: ${this._styler.hilite(agent.url)}`);
360
+ }
361
+ else if (candidate.hasIngress && candidate.domain) {
362
+ this._ui.userMessage(`${this._styler.colorGood('READY')} WebTerminal ingress: ${this._styler.hilite(candidate.domain)} (strategy ${candidate.naming})`);
363
+ this._ui.userMessage(` Exact host resolves from the [${candidate.naming}] host-map strategy; see host mappings for the final URL.`);
364
+ }
365
+ else if (candidate.hasIngress) {
366
+ this._ui.userMessage(`${this._styler.colorGood('READY')} WebTerminal ingress mapped via strategy ${this._styler.hilite((_a = candidate.naming) !== null && _a !== void 0 ? _a : '')}.`);
367
+ }
368
+ else {
369
+ this._ui.userMessage(`${this._styler.colorGood('READY')} Agent [${candidate.name}] is reachable only in-cluster (no ingress requested).`);
370
+ }
371
+ }
372
+ /** Silent mode disables all prompting (the base lifecycle rebinds `_ui` to a throwing
373
+ * provider) — mirrors the same detection `CommandBaseExec.runAsync()` uses, so a
374
+ * `needs_action` response can fail fast with a clear message instead of a raw
375
+ * "cannot acquire input" error. */
376
+ isSilentMode() {
377
+ return this.argv.includes('--silent') || this.pipedInput != undefined;
378
+ }
379
+ }
380
+ exports.default = AiAgentInstall;
381
+ AiAgentInstall.description = 'Provisions a stateful Codiac agent workload (openclaw, hermes, or byoa) into an enterprise cabinet.';
382
+ AiAgentInstall.examples = [
383
+ {
384
+ description: 'Install a Hermes agent into the dev cabinet of the ben enterprise.',
385
+ command: '<%= config.bin %> <%= command.id %> -e ben -t hermes -c dev',
386
+ },
387
+ {
388
+ description: 'Non-interactive (scripted) invocation. Ingress defaults on, so a host-naming strategy must be given explicitly; shared_ingress_ip needs no --domain.',
389
+ command: '<%= config.bin %> <%= command.id %> -e ben -t hermes -c dev --silent --naming shared_ingress_ip',
390
+ },
391
+ {
392
+ description: 'Renders the equivalent silent command and then executes.',
393
+ command: '<%= config.bin %> <%= command.id %> -e ben -t hermes -c dev --echo',
394
+ },
395
+ {
396
+ description: 'Renders the equivalent silent command without executing.',
397
+ command: '<%= config.bin %> <%= command.id %> -e ben -t hermes -c dev --to-script',
398
+ },
399
+ ];
400
+ AiAgentInstall.flags = {
401
+ help: core_1.Flags.help({ char: 'h' }),
402
+ enterpriseCode: core_1.Flags.string({ char: 'e', required: false, description: 'Code name identifying the target enterprise.' }),
403
+ type: core_1.Flags.string({ char: 't', options: ['openclaw', 'hermes', 'byoa'], description: 'Agent framework to install: openclaw, hermes, or byoa (bring-your-own-agent).' }),
404
+ cabinet: core_1.Flags.string({ char: 'c', description: 'Cabinet (environment) into which the agent workload is deployed.' }),
405
+ name: core_1.Flags.string({ char: 'n', description: 'Asset name for the agent workload (defaults to <type>-agent).' }),
406
+ ingress: core_1.Flags.boolean({ char: 'g', allowNo: true, default: true, description: 'Expose the agent web terminal through an ingress host (use --no-ingress to keep it cluster-internal).' }),
407
+ naming: core_1.Flags.string({ description: 'Host-naming strategy to use for the ingress host (prompted during install when omitted).' }),
408
+ domain: core_1.Flags.string({ description: 'Domain to use with the host-naming strategy for the ingress host.' }),
409
+ input: core_1.Flags.string({ multiple: true, description: 'Pre-supply a needs_action input as key=value (repeatable), e.g. --input openRouterKey=sk-... . Lets --silent/headless runs resolve secret/decision prompts without interaction.' }),
410
+ // Interaction mode flags (TODO: will eventually move to base class)
411
+ "take-defaults": core_1.Flags.boolean({ exclusive: ["silent"], description: "Prevents prompting for confirmation on parameters that were passed in or were automatically set to default values (Irrelevant in --silent mode). This behavior does NOT apply to scenarios where the command needs to override invalid user input; such cases will always prompt for confirmation." }),
412
+ silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Executes without any user interaction; fails on missing or invalid arguments.' }),
413
+ echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Renders the equivalent non-interactive command for future use before executing.' }),
414
+ "to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Renders the equivalent non-interactive command without executing it.' }),
415
+ };
416
+ AiAgentInstall.args = {};
417
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../../src/commands/ai/agent/install.ts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-75,21 +75,25 @@ class CspLogin extends command_base_exec_tenant_1.CommandBaseExecTenant {
75
75
  const cspTenant = yield this.cspContextualizer.ensureCspTenantContext(this._codiacApi, partial.providerCode, partial.providerSubscription, partial.providerTenant, true);
76
76
  partial.providerSubscription = cspTenant.subscriptionId;
77
77
  partial.providerTenant = cspTenant.tenantId;
78
- let candidate;
79
- if (partial.proprietaryInput) {
80
- candidate = this.cspContextualizer.assembleLoginRequest(this.ioc, partial.providerCode, partial.username, partial.secret, cspTenant.subscriptionId, partial.proprietaryInput);
78
+ // Pass the RAW secret through. The downstream login flow
79
+ // (AwsResourceConfigurator.promptToLogin -> assembleLoginRequest ->
80
+ // crunchForTransport) base64-encodes the secret exactly once. Previously the
81
+ // proprietaryInput (AWS session-token) branch pre-crunched the secret HERE via
82
+ // assembleLoginRequest, so it got base64-encoded a SECOND time downstream. The
83
+ // server decoded once and received a mangled secret -> "SignatureDoesNotMatch"
84
+ // for every `--silent -p ... --aws-session-token ...` login (cod exits 0 on
85
+ // failure, so CI never noticed). Build the candidate uniformly with the raw
86
+ // secret and let the single downstream crunch happen.
87
+ let candidate = {
88
+ providerCode: partial.providerCode,
89
+ username: partial.username,
90
+ secret: partial.secret,
91
+ providerSubscription: partial.providerSubscription,
92
+ };
93
+ if (partial.providerTenant)
94
+ candidate.providerTenant = partial.providerTenant;
95
+ if (partial.proprietaryInput)
81
96
  candidate.proprietaryInput = partial.proprietaryInput;
82
- }
83
- else {
84
- candidate = {
85
- providerCode: partial.providerCode,
86
- username: partial.username,
87
- secret: partial.secret,
88
- providerSubscription: partial.providerSubscription,
89
- };
90
- if (partial.providerTenant)
91
- candidate.providerTenant = partial.providerTenant;
92
- }
93
97
  if (partial.credsType)
94
98
  candidate.credsType = partial.credsType;
95
99
  return candidate;