@experiture/xyra-cli 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/administrationSession.js +25 -0
- package/dist/auth/administrationSession.js.map +1 -0
- package/dist/auth/oauthClient.js +1 -1
- package/dist/auth/oauthClient.js.map +1 -1
- package/dist/auth/session.js +11 -0
- package/dist/auth/session.js.map +1 -1
- package/dist/chat/runtimeChatClient.js +128 -13
- package/dist/chat/runtimeChatClient.js.map +3 -3
- package/dist/commands/chat.js +30 -0
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/generatedCommandRegistry.js +17 -2
- package/dist/commands/generatedCommandRegistry.js.map +1 -1
- package/dist/commands/login.js +5 -4
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/mcpContext.js +2 -2
- package/dist/commands/mcpContext.js.map +1 -1
- package/dist/commands/session.js +7 -5
- package/dist/commands/session.js.map +1 -1
- package/dist/config/configStore.js +665 -106
- package/dist/config/configStore.js.map +7 -1
- package/dist/config/environments.js.map +1 -1
- package/dist/index.js +36 -22
- package/dist/index.js.map +1 -1
- package/dist/mcp/mcpClient.js +274 -129
- package/dist/mcp/mcpClient.js.map +7 -1
- package/package.json +3 -3
|
@@ -1,126 +1,685 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../libs/xyra-types/dist/xyra-administration.js
|
|
34
|
+
var require_xyra_administration = __commonJS({
|
|
35
|
+
"../../libs/xyra-types/dist/xyra-administration.js"(exports2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
38
|
+
exports2.parseXyraAdministrationTargetV1 = parseXyraAdministrationTargetV12;
|
|
39
|
+
exports2.xyraAdministrationTargetKeyV1 = xyraAdministrationTargetKeyV1;
|
|
40
|
+
exports2.parseXyraAdministrationResolvedTargetV1 = parseXyraAdministrationResolvedTargetV1;
|
|
41
|
+
exports2.parseXyraAdministrationDecisionV1 = parseXyraAdministrationDecisionV1;
|
|
42
|
+
var identifier = (value) => typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,49}$/.test(value);
|
|
43
|
+
var guid = (value) => typeof value === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(value) && value !== "00000000-0000-0000-0000-000000000000";
|
|
44
|
+
var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
45
|
+
var exact = (value, keys) => Object.keys(value).length === keys.length && keys.every((key) => Object.prototype.hasOwnProperty.call(value, key));
|
|
46
|
+
function parseXyraAdministrationTargetV12(value) {
|
|
47
|
+
if (!record(value))
|
|
48
|
+
return null;
|
|
49
|
+
if (value.targetKind === "global-resource" && exact(value, ["targetKind", "managedProductId"]) && value.managedProductId === "xyra-ai") {
|
|
50
|
+
return { targetKind: "global-resource", managedProductId: "xyra-ai" };
|
|
51
|
+
}
|
|
52
|
+
if (value.targetKind === "configuration-owner" && exact(value, ["targetKind", "configurationTenantId", "managedProductId"]) && identifier(value.configurationTenantId) && identifier(value.managedProductId)) {
|
|
53
|
+
return {
|
|
54
|
+
targetKind: "configuration-owner",
|
|
55
|
+
configurationTenantId: value.configurationTenantId,
|
|
56
|
+
managedProductId: value.managedProductId
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (value.targetKind === "customer-resource" && exact(value, ["targetKind", "targetTenantId", "activeProductId"]) && identifier(value.targetTenantId) && identifier(value.activeProductId)) {
|
|
60
|
+
return { targetKind: "customer-resource", targetTenantId: value.targetTenantId, activeProductId: value.activeProductId };
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
16
63
|
}
|
|
17
|
-
|
|
18
|
-
|
|
64
|
+
function xyraAdministrationTargetKeyV1(target) {
|
|
65
|
+
return JSON.stringify(target.targetKind === "global-resource" ? [target.targetKind, target.managedProductId] : target.targetKind === "configuration-owner" ? [target.targetKind, target.configurationTenantId, target.managedProductId] : [target.targetKind, target.targetTenantId, target.activeProductId]);
|
|
19
66
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
67
|
+
function parseXyraAdministrationResolvedTargetV1(value, target) {
|
|
68
|
+
if (!record(value) || value.targetKind !== target.targetKind)
|
|
69
|
+
return null;
|
|
70
|
+
const managedProductId = target.targetKind === "customer-resource" ? "xyra-ai" : target.managedProductId;
|
|
71
|
+
if (value.managedProductId !== managedProductId)
|
|
72
|
+
return null;
|
|
73
|
+
if (target.targetKind === "global-resource") {
|
|
74
|
+
return exact(value, ["targetKind", "managedProductId", "relationshipKind"]) && value.relationshipKind === "global-resource" ? { targetKind: "global-resource", managedProductId: "xyra-ai", relationshipKind: "global-resource" } : null;
|
|
75
|
+
}
|
|
76
|
+
const base = ["targetKind", "managedProductId", "relationshipKind", "activeProductId", "actualTenantId", "licensedProductId", "commercialState"];
|
|
77
|
+
const embedded = ["licenseSourceProductId", "licenseOwnerTenantId", "bindingId", "entitlementId", "sourceEntitlementId"];
|
|
78
|
+
const isNative = value.relationshipKind === "native-product-tenant";
|
|
79
|
+
if (!isNative && value.relationshipKind !== "embedded-product-entitlement" || !exact(value, isNative ? base : [...base, ...embedded]) || value.licensedProductId !== "xyra-ai" || !base.filter((key) => !["targetKind", "relationshipKind"].includes(key)).every((key) => identifier(value[key])) || (isNative ? value.activeProductId !== "xyra-ai" : !embedded.every((key) => identifier(value[key]))) || value.actualTenantId !== (target.targetKind === "customer-resource" ? target.targetTenantId : target.configurationTenantId) || target.targetKind === "customer-resource" && value.activeProductId !== target.activeProductId || target.targetKind === "configuration-owner" && value.activeProductId !== target.managedProductId || !isNative && (value.licenseSourceProductId !== value.activeProductId || !["bindingId", "entitlementId", "sourceEntitlementId"].every((key) => guid(value[key])) || target.targetKind === "configuration-owner" && value.licenseOwnerTenantId !== target.configurationTenantId))
|
|
80
|
+
return null;
|
|
81
|
+
return { ...value };
|
|
23
82
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
83
|
+
function parseXyraAdministrationDecisionV1(value, request, purpose) {
|
|
84
|
+
if (!record(value) || !exact(value, [
|
|
85
|
+
"operationId",
|
|
86
|
+
"purpose",
|
|
87
|
+
"accessPurpose",
|
|
88
|
+
"allowed",
|
|
89
|
+
"code",
|
|
90
|
+
"productId",
|
|
91
|
+
"operatorTenantId",
|
|
92
|
+
"targetTenantId",
|
|
93
|
+
"grantId",
|
|
94
|
+
"target",
|
|
95
|
+
"resolvedTarget"
|
|
96
|
+
]) || value.operationId !== request.operationId || value.purpose !== purpose || value.accessPurpose !== "administration" || value.productId !== "xyra-ai" || typeof value.allowed !== "boolean" || typeof value.code !== "string" || !/^[A-Z0-9_.]{1,160}$/.test(value.code) || !(value.operatorTenantId === null || identifier(value.operatorTenantId)) || !(value.grantId === null || guid(value.grantId)))
|
|
97
|
+
return null;
|
|
98
|
+
const target = parseXyraAdministrationTargetV12(value.target);
|
|
99
|
+
if (!target || xyraAdministrationTargetKeyV1(target) !== xyraAdministrationTargetKeyV1(request.target) || value.targetTenantId !== (target.targetKind === "global-resource" ? null : target.targetKind === "configuration-owner" ? target.configurationTenantId : target.targetTenantId))
|
|
100
|
+
return null;
|
|
101
|
+
const resolvedTarget = parseXyraAdministrationResolvedTargetV1(value.resolvedTarget, target);
|
|
102
|
+
if (value.allowed) {
|
|
103
|
+
if (!resolvedTarget || (value.code === "AUTHORIZATION.ALLOWED.SUPER_USER" ? value.operatorTenantId !== null || value.grantId !== null : !["AUTHORIZATION.ALLOWED", "AUTHORIZATION.ALLOWED.LICENSEE"].includes(value.code) || value.operatorTenantId === null || value.grantId === null))
|
|
104
|
+
return null;
|
|
105
|
+
if (value.code === "AUTHORIZATION.ALLOWED.LICENSEE" && (target.targetKind === "global-resource" || resolvedTarget.relationshipKind !== "embedded-product-entitlement" || resolvedTarget.licenseOwnerTenantId !== value.operatorTenantId || resolvedTarget.activeProductId === "xyra-ai"))
|
|
106
|
+
return null;
|
|
107
|
+
} else if (value.code.startsWith("AUTHORIZATION.ALLOWED") || value.resolvedTarget !== null)
|
|
108
|
+
return null;
|
|
109
|
+
return { ...value, target, resolvedTarget };
|
|
29
110
|
}
|
|
30
|
-
|
|
31
|
-
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// ../../libs/xyra-types/dist/canonical-runtime-json.js
|
|
115
|
+
var require_canonical_runtime_json = __commonJS({
|
|
116
|
+
"../../libs/xyra-types/dist/canonical-runtime-json.js"(exports2) {
|
|
117
|
+
"use strict";
|
|
118
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
119
|
+
exports2.MAXIMUM_BOUNDED_RUNTIME_JSON_BYTES_V1 = exports2.BoundedRuntimeJsonErrorV1 = exports2.CanonicalRuntimeJsonErrorV1 = void 0;
|
|
120
|
+
exports2.canonicalRuntimeJsonV1 = canonicalRuntimeJsonV1;
|
|
121
|
+
exports2.canonicalRuntimeUtf8BytesV1 = canonicalRuntimeUtf8BytesV1;
|
|
122
|
+
exports2.canonicalRuntimeUtf8ByteLengthV1 = canonicalRuntimeUtf8ByteLengthV1;
|
|
123
|
+
exports2.boundedRuntimeDataV1 = boundedRuntimeDataV1;
|
|
124
|
+
exports2.boundedRuntimeJsonDataV1 = boundedRuntimeJsonDataV1;
|
|
125
|
+
exports2.parseBoundedRuntimeJsonV1 = parseBoundedRuntimeJsonV12;
|
|
126
|
+
var CanonicalRuntimeJsonErrorV1 = class extends TypeError {
|
|
127
|
+
constructor(reason, path) {
|
|
128
|
+
super(`Canonical runtime JSON rejected ${reason} at ${path}.`);
|
|
129
|
+
this.reason = reason;
|
|
130
|
+
this.path = path;
|
|
131
|
+
this.code = "XYRA.RUNTIME.CANONICAL_JSON_INVALID";
|
|
132
|
+
this.name = "CanonicalRuntimeJsonErrorV1";
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
exports2.CanonicalRuntimeJsonErrorV1 = CanonicalRuntimeJsonErrorV1;
|
|
136
|
+
function invalid(reason, path) {
|
|
137
|
+
throw new CanonicalRuntimeJsonErrorV1(reason, path);
|
|
32
138
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const allowedProtocol = parsed.protocol === 'https:' || (parsed.protocol === 'http:' && (isLocalhost || isTestDomain));
|
|
36
|
-
if (!allowedProtocol || parsed.username || parsed.password || parsed.search || parsed.hash
|
|
37
|
-
|| (parsed.pathname !== '/' && parsed.pathname !== '')) {
|
|
38
|
-
throw new CliError_1.CliError(CliError_1.CliErrorCodes.ConfigInvalid, `Environment '${name}' must be an HTTP(S) origin without credentials, path, query, or fragment.`);
|
|
139
|
+
function compareOrdinal(left, right) {
|
|
140
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
39
141
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
142
|
+
function objectPath(parent, key) {
|
|
143
|
+
return `${parent}[${JSON.stringify(key)}]`;
|
|
144
|
+
}
|
|
145
|
+
function assertCanonicalString(value, path) {
|
|
146
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
147
|
+
const codeUnit = value.charCodeAt(index);
|
|
148
|
+
if (codeUnit === 0)
|
|
149
|
+
invalid("invalid_unicode", path);
|
|
150
|
+
if (codeUnit >= 55296 && codeUnit <= 56319) {
|
|
151
|
+
const next = value.charCodeAt(index + 1);
|
|
152
|
+
if (!(next >= 56320 && next <= 57343))
|
|
153
|
+
invalid("invalid_unicode", path);
|
|
154
|
+
index += 1;
|
|
155
|
+
} else if (codeUnit >= 56320 && codeUnit <= 57343) {
|
|
156
|
+
invalid("invalid_unicode", path);
|
|
49
157
|
}
|
|
50
|
-
|
|
158
|
+
}
|
|
51
159
|
}
|
|
52
|
-
|
|
53
|
-
|
|
160
|
+
function isPlainJsonObject(value) {
|
|
161
|
+
const prototype = Object.getPrototypeOf(value);
|
|
162
|
+
return prototype === Object.prototype || prototype === null;
|
|
54
163
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
164
|
+
function canonicalize(value, path, ancestors) {
|
|
165
|
+
if (value === null || typeof value === "boolean")
|
|
166
|
+
return value;
|
|
167
|
+
if (typeof value === "string") {
|
|
168
|
+
assertCanonicalString(value, path);
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
if (typeof value === "number") {
|
|
172
|
+
if (!Number.isFinite(value))
|
|
173
|
+
invalid("non_finite_number", path);
|
|
174
|
+
return value;
|
|
175
|
+
}
|
|
176
|
+
if (typeof value !== "object")
|
|
177
|
+
invalid("unsupported_value", path);
|
|
178
|
+
if (ancestors.has(value))
|
|
179
|
+
invalid("cyclic_value", path);
|
|
180
|
+
ancestors.add(value);
|
|
181
|
+
try {
|
|
182
|
+
if (Array.isArray(value)) {
|
|
183
|
+
if (Object.getOwnPropertySymbols(value).length > 0)
|
|
184
|
+
invalid("symbol_key", path);
|
|
185
|
+
const ownKeys = Object.keys(value);
|
|
186
|
+
if (ownKeys.length !== value.length)
|
|
187
|
+
invalid("sparse_array", path);
|
|
188
|
+
const result2 = [];
|
|
189
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
190
|
+
if (!Object.prototype.hasOwnProperty.call(value, index))
|
|
191
|
+
invalid("sparse_array", `${path}[${index}]`);
|
|
192
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
193
|
+
if (!descriptor || descriptor.get || descriptor.set)
|
|
194
|
+
invalid("accessor_property", `${path}[${index}]`);
|
|
195
|
+
result2.push(canonicalize(descriptor.value, `${path}[${index}]`, ancestors));
|
|
196
|
+
}
|
|
197
|
+
return result2;
|
|
198
|
+
}
|
|
199
|
+
if (!isPlainJsonObject(value))
|
|
200
|
+
invalid("non_plain_object", path);
|
|
201
|
+
if (Object.getOwnPropertySymbols(value).length > 0)
|
|
202
|
+
invalid("symbol_key", path);
|
|
203
|
+
const result = {};
|
|
204
|
+
for (const key of Object.keys(value).sort(compareOrdinal)) {
|
|
205
|
+
assertCanonicalString(key, objectPath(path, key));
|
|
206
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
207
|
+
if (!descriptor || descriptor.get || descriptor.set) {
|
|
208
|
+
invalid("accessor_property", objectPath(path, key));
|
|
209
|
+
}
|
|
210
|
+
result[key] = canonicalize(descriptor.value, objectPath(path, key), ancestors);
|
|
211
|
+
}
|
|
212
|
+
return result;
|
|
213
|
+
} finally {
|
|
214
|
+
ancestors.delete(value);
|
|
215
|
+
}
|
|
58
216
|
}
|
|
59
|
-
|
|
60
|
-
|
|
217
|
+
function canonicalRuntimeJsonV1(value) {
|
|
218
|
+
return JSON.stringify(canonicalize(value, "$", /* @__PURE__ */ new Set()));
|
|
61
219
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
220
|
+
function canonicalRuntimeUtf8BytesV1(value) {
|
|
221
|
+
return new TextEncoder().encode(canonicalRuntimeJsonV1(value));
|
|
222
|
+
}
|
|
223
|
+
function canonicalRuntimeUtf8ByteLengthV1(value) {
|
|
224
|
+
return canonicalRuntimeUtf8BytesV1(value).byteLength;
|
|
225
|
+
}
|
|
226
|
+
var BoundedRuntimeJsonErrorV1 = class extends SyntaxError {
|
|
227
|
+
constructor(reason) {
|
|
228
|
+
super(`Bounded runtime JSON rejected ${reason}.`);
|
|
229
|
+
this.reason = reason;
|
|
230
|
+
this.name = "BoundedRuntimeJsonErrorV1";
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
exports2.BoundedRuntimeJsonErrorV1 = BoundedRuntimeJsonErrorV1;
|
|
234
|
+
var boundedInvalid = (reason) => {
|
|
235
|
+
throw new BoundedRuntimeJsonErrorV1(reason);
|
|
236
|
+
};
|
|
237
|
+
exports2.MAXIMUM_BOUNDED_RUNTIME_JSON_BYTES_V1 = 2097152;
|
|
238
|
+
function boundedLimits(limits) {
|
|
239
|
+
const maximumBytes = limits.maximumBytes ?? 1048576;
|
|
240
|
+
const maximumDepth = limits.maximumDepth ?? 16;
|
|
241
|
+
if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1 || maximumBytes > exports2.MAXIMUM_BOUNDED_RUNTIME_JSON_BYTES_V1 || !Number.isSafeInteger(maximumDepth) || maximumDepth < 1 || maximumDepth > 24)
|
|
242
|
+
boundedInvalid("limits");
|
|
243
|
+
return { maximumBytes, maximumDepth };
|
|
244
|
+
}
|
|
245
|
+
function boundedUnicode(value) {
|
|
246
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
247
|
+
const unit = value.charCodeAt(index);
|
|
248
|
+
if (unit >= 55296 && unit <= 56319) {
|
|
249
|
+
const next = value.charCodeAt(++index);
|
|
250
|
+
if (!(next >= 56320 && next <= 57343))
|
|
251
|
+
return false;
|
|
252
|
+
} else if (unit >= 56320 && unit <= 57343)
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
function copyBoundedRuntimeData(input, maximumBytes, maximumDepth, jsonOnly, preserveKeyOrder = false) {
|
|
258
|
+
let nodes = 0;
|
|
259
|
+
let characters = 0;
|
|
260
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
261
|
+
function copy(value, depth) {
|
|
262
|
+
if (++nodes > (jsonOnly ? 2e5 : 1e5) || depth > maximumDepth)
|
|
263
|
+
boundedInvalid("shape");
|
|
264
|
+
if (value === null || typeof value === "boolean" || !jsonOnly && value === void 0)
|
|
265
|
+
return value;
|
|
266
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
267
|
+
return value;
|
|
268
|
+
if (typeof value === "string") {
|
|
269
|
+
characters += value.length;
|
|
270
|
+
if (jsonOnly ? characters > maximumBytes || !boundedUnicode(value) : value.length > 1048576 || characters > 16777216)
|
|
271
|
+
boundedInvalid("text");
|
|
272
|
+
return value;
|
|
76
273
|
}
|
|
77
|
-
|
|
274
|
+
if (!value || typeof value !== "object" || ancestors.has(value))
|
|
275
|
+
boundedInvalid("shape");
|
|
276
|
+
const objectValue = value;
|
|
277
|
+
const array = Array.isArray(objectValue);
|
|
278
|
+
const prototype = Object.getPrototypeOf(objectValue);
|
|
279
|
+
const arrayLength = array ? objectValue.length : 0;
|
|
280
|
+
if (array ? prototype !== Array.prototype && (jsonOnly || prototype !== null) : prototype !== Object.prototype && prototype !== null)
|
|
281
|
+
boundedInvalid("shape");
|
|
282
|
+
const keys = Reflect.ownKeys(objectValue);
|
|
283
|
+
if (keys.length > 10001 || keys.some((key) => typeof key !== "string"))
|
|
284
|
+
boundedInvalid("shape");
|
|
285
|
+
if (array && keys.length !== arrayLength + 1)
|
|
286
|
+
boundedInvalid("array");
|
|
287
|
+
const seen = /* @__PURE__ */ new Set();
|
|
288
|
+
const result = array ? [] : {};
|
|
289
|
+
ancestors.add(objectValue);
|
|
78
290
|
try {
|
|
79
|
-
|
|
291
|
+
for (const key of jsonOnly || array || preserveKeyOrder ? keys : keys.sort()) {
|
|
292
|
+
if (array && key === "length")
|
|
293
|
+
continue;
|
|
294
|
+
const descriptor = Object.getOwnPropertyDescriptor(objectValue, key);
|
|
295
|
+
if (!descriptor.enumerable || !("value" in descriptor) || key.length > (jsonOnly ? 160 : 256) || jsonOnly && seen.has(key.toLowerCase()) || array && (!/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= arrayLength))
|
|
296
|
+
boundedInvalid("shape");
|
|
297
|
+
seen.add(key.toLowerCase());
|
|
298
|
+
Object.defineProperty(result, key, { enumerable: true, writable: true, configurable: true, value: copy(descriptor.value, depth + 1) });
|
|
299
|
+
}
|
|
300
|
+
} finally {
|
|
301
|
+
ancestors.delete(objectValue);
|
|
80
302
|
}
|
|
81
|
-
|
|
82
|
-
|
|
303
|
+
return result;
|
|
304
|
+
}
|
|
305
|
+
return copy(input, 0);
|
|
306
|
+
}
|
|
307
|
+
function boundedRuntimeDataV1(input, preserveKeyOrder = false) {
|
|
308
|
+
return copyBoundedRuntimeData(input, 16777216, 24, false, preserveKeyOrder);
|
|
309
|
+
}
|
|
310
|
+
function boundedRuntimeJsonDataV1(input, limits = {}) {
|
|
311
|
+
const { maximumBytes, maximumDepth } = boundedLimits(limits);
|
|
312
|
+
const value = copyBoundedRuntimeData(input, maximumBytes, maximumDepth, true);
|
|
313
|
+
if (canonicalRuntimeUtf8ByteLengthV1(value) > maximumBytes)
|
|
314
|
+
boundedInvalid("bytes");
|
|
315
|
+
return value;
|
|
316
|
+
}
|
|
317
|
+
function parseBoundedRuntimeJsonV12(source, limits = {}) {
|
|
318
|
+
const { maximumBytes, maximumDepth } = boundedLimits(limits);
|
|
319
|
+
if (typeof source !== "string" || source.length > maximumBytes || !boundedUnicode(source) || new TextEncoder().encode(source).byteLength > maximumBytes)
|
|
320
|
+
boundedInvalid("bytes");
|
|
321
|
+
let index = 0;
|
|
322
|
+
let nodes = 0;
|
|
323
|
+
const whitespace = () => {
|
|
324
|
+
while (/[\x20\t\r\n]/.test(source[index] ?? "\0"))
|
|
325
|
+
index += 1;
|
|
326
|
+
};
|
|
327
|
+
function string() {
|
|
328
|
+
const start = index;
|
|
329
|
+
if (source[index++] !== '"')
|
|
330
|
+
boundedInvalid("string");
|
|
331
|
+
while (index < source.length) {
|
|
332
|
+
const char = source[index++];
|
|
333
|
+
if (char === "\\") {
|
|
334
|
+
index += 1;
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (char === '"') {
|
|
338
|
+
try {
|
|
339
|
+
const parsed = JSON.parse(source.slice(start, index));
|
|
340
|
+
if (!boundedUnicode(parsed))
|
|
341
|
+
boundedInvalid("unicode");
|
|
342
|
+
return parsed;
|
|
343
|
+
} catch (error) {
|
|
344
|
+
if (error instanceof BoundedRuntimeJsonErrorV1)
|
|
345
|
+
throw error;
|
|
346
|
+
boundedInvalid("string");
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return boundedInvalid("string");
|
|
351
|
+
}
|
|
352
|
+
function value(depth) {
|
|
353
|
+
if (++nodes > 2e5 || depth > maximumDepth)
|
|
354
|
+
boundedInvalid("shape");
|
|
355
|
+
whitespace();
|
|
356
|
+
const char = source[index];
|
|
357
|
+
if (char === '"') {
|
|
358
|
+
string();
|
|
359
|
+
return;
|
|
83
360
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
361
|
+
if (char === "{") {
|
|
362
|
+
index += 1;
|
|
363
|
+
whitespace();
|
|
364
|
+
const seen = /* @__PURE__ */ new Set();
|
|
365
|
+
if (source[index] === "}") {
|
|
366
|
+
index += 1;
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
for (; ; ) {
|
|
370
|
+
const item = string().toLowerCase();
|
|
371
|
+
if (seen.has(item))
|
|
372
|
+
boundedInvalid("duplicate_key");
|
|
373
|
+
seen.add(item);
|
|
374
|
+
whitespace();
|
|
375
|
+
if (source[index++] !== ":")
|
|
376
|
+
boundedInvalid("object");
|
|
377
|
+
value(depth + 1);
|
|
378
|
+
whitespace();
|
|
379
|
+
const end = source[index++];
|
|
380
|
+
if (end === "}")
|
|
381
|
+
return;
|
|
382
|
+
if (end !== ",")
|
|
383
|
+
boundedInvalid("object");
|
|
384
|
+
whitespace();
|
|
385
|
+
}
|
|
109
386
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
387
|
+
if (char === "[") {
|
|
388
|
+
index += 1;
|
|
389
|
+
whitespace();
|
|
390
|
+
if (source[index] === "]") {
|
|
391
|
+
index += 1;
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
let count = 0;
|
|
395
|
+
for (; ; ) {
|
|
396
|
+
if (++count > 1e4)
|
|
397
|
+
boundedInvalid("array");
|
|
398
|
+
value(depth + 1);
|
|
399
|
+
whitespace();
|
|
400
|
+
const end = source[index++];
|
|
401
|
+
if (end === "]")
|
|
402
|
+
return;
|
|
403
|
+
if (end !== ",")
|
|
404
|
+
boundedInvalid("array");
|
|
405
|
+
whitespace();
|
|
406
|
+
}
|
|
118
407
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
408
|
+
const token = /^(?:true|false|null|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)/.exec(source.slice(index));
|
|
409
|
+
if (!token)
|
|
410
|
+
boundedInvalid("value");
|
|
411
|
+
const tokenText = token[0];
|
|
412
|
+
if (/^-?\d/.test(tokenText)) {
|
|
413
|
+
const numeric = Number(tokenText);
|
|
414
|
+
if (!Number.isFinite(numeric))
|
|
415
|
+
boundedInvalid("number");
|
|
416
|
+
if (Number.isInteger(numeric)) {
|
|
417
|
+
if (!Number.isSafeInteger(numeric))
|
|
418
|
+
boundedInvalid("number");
|
|
419
|
+
const parts = /^(-?)(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/.exec(tokenText);
|
|
420
|
+
let digits = (parts[2] + (parts[3] ?? "")).replace(/^0+/, "");
|
|
421
|
+
let power = Number(parts[4] ?? 0) - (parts[3]?.length ?? 0);
|
|
422
|
+
if (digits) {
|
|
423
|
+
const trimmed = digits.replace(/0+$/, "");
|
|
424
|
+
power += digits.length - trimmed.length;
|
|
425
|
+
digits = trimmed;
|
|
426
|
+
if (power < 0 || digits.length + power > 16 || Number(digits + "0".repeat(power)) !== Math.abs(numeric))
|
|
427
|
+
boundedInvalid("number");
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
index += tokenText.length;
|
|
432
|
+
}
|
|
433
|
+
value(0);
|
|
434
|
+
whitespace();
|
|
435
|
+
if (index !== source.length)
|
|
436
|
+
boundedInvalid("trailing");
|
|
437
|
+
try {
|
|
438
|
+
return boundedRuntimeJsonDataV1(JSON.parse(source), limits);
|
|
439
|
+
} catch (error) {
|
|
440
|
+
if (error instanceof BoundedRuntimeJsonErrorV1)
|
|
441
|
+
throw error;
|
|
442
|
+
return boundedInvalid("json");
|
|
443
|
+
}
|
|
123
444
|
}
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
// src/config/configStore.ts
|
|
449
|
+
var configStore_exports = {};
|
|
450
|
+
__export(configStore_exports, {
|
|
451
|
+
ConfigStore: () => ConfigStore,
|
|
452
|
+
validateEnvironment: () => validateEnvironment
|
|
453
|
+
});
|
|
454
|
+
module.exports = __toCommonJS(configStore_exports);
|
|
455
|
+
var import_node_fs = require("node:fs");
|
|
456
|
+
var import_node_os = require("node:os");
|
|
457
|
+
var import_node_path = require("node:path");
|
|
458
|
+
|
|
459
|
+
// src/errors/CliError.ts
|
|
460
|
+
var CliError = class extends Error {
|
|
461
|
+
code;
|
|
462
|
+
hint;
|
|
463
|
+
httpStatus;
|
|
464
|
+
constructor(code, message, hint, httpStatus) {
|
|
465
|
+
super(message);
|
|
466
|
+
this.name = "CliError";
|
|
467
|
+
this.code = code;
|
|
468
|
+
this.hint = hint;
|
|
469
|
+
this.httpStatus = httpStatus;
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
var CliErrorCodes = {
|
|
473
|
+
ConfigInvalid: "XYRA.CLI.CONFIG_INVALID",
|
|
474
|
+
EnvironmentNotFound: "XYRA.CLI.ENVIRONMENT_NOT_FOUND",
|
|
475
|
+
NotAuthenticated: "XYRA.CLI.NOT_AUTHENTICATED",
|
|
476
|
+
OAuthStateMismatch: "XYRA.CLI.OAUTH_STATE_MISMATCH",
|
|
477
|
+
OAuthCallbackError: "XYRA.CLI.OAUTH_CALLBACK_ERROR",
|
|
478
|
+
TokenStoreUnavailable: "XYRA.CLI.TOKEN_STORE_UNAVAILABLE",
|
|
479
|
+
TokenExchangeFailed: "XYRA.CLI.TOKEN_EXCHANGE_FAILED",
|
|
480
|
+
InsufficientScope: "XYRA.CLI.INSUFFICIENT_SCOPE",
|
|
481
|
+
McpProtocolError: "XYRA.CLI.MCP_PROTOCOL_ERROR",
|
|
482
|
+
ToolCallFailed: "XYRA.CLI.TOOL_CALL_FAILED",
|
|
483
|
+
ChatRequestFailed: "XYRA.CLI.CHAT_REQUEST_FAILED",
|
|
484
|
+
InvalidArguments: "XYRA.CLI.INVALID_ARGUMENTS",
|
|
485
|
+
ConfirmationRequired: "XYRA.CLI.CONFIRMATION_REQUIRED",
|
|
486
|
+
AmbiguousAlias: "XYRA.CLI.AMBIGUOUS_ALIAS"
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
// src/config/configStore.ts
|
|
490
|
+
var import_xyra_administration = __toESM(require_xyra_administration());
|
|
491
|
+
var import_canonical_runtime_json = __toESM(require_canonical_runtime_json());
|
|
492
|
+
|
|
493
|
+
// src/config/environments.ts
|
|
494
|
+
var DEFAULT_ENVIRONMENTS = {
|
|
495
|
+
dev: {
|
|
496
|
+
name: "dev",
|
|
497
|
+
mcpUrl: "https://mcp.dev.experiture.ai/mcp",
|
|
498
|
+
orchestratorUrl: "https://orchestrator.dev.experiture.ai",
|
|
499
|
+
oauthResource: "https://mcp.dev.experiture.ai/mcp",
|
|
500
|
+
authorizationEndpoint: "https://dev.app.experiture.ai/api/auth/oauth/authorize",
|
|
501
|
+
tokenEndpoint: "https://dev.app.experiture.ai/api/auth/oauth/token",
|
|
502
|
+
clientId: "experiture-xyra-mcp-delegated",
|
|
503
|
+
redirectPath: "/callback/QYfSVwRg9okE",
|
|
504
|
+
scopes: ["openid", "profile", "email", "offline_access"]
|
|
505
|
+
},
|
|
506
|
+
staging: {
|
|
507
|
+
name: "staging",
|
|
508
|
+
mcpUrl: "https://mcp.staging.experiture.ai/mcp",
|
|
509
|
+
orchestratorUrl: "https://app.experiture.ai",
|
|
510
|
+
oauthResource: "https://mcp.staging.experiture.ai/mcp",
|
|
511
|
+
authorizationEndpoint: "https://app.experiture.ai/api/auth/oauth/authorize",
|
|
512
|
+
tokenEndpoint: "https://app.experiture.ai/api/auth/oauth/token",
|
|
513
|
+
clientId: "experiture-xyra-mcp-delegated",
|
|
514
|
+
redirectPath: "/callback/QYfSVwRg9okE",
|
|
515
|
+
scopes: ["openid", "profile", "email", "offline_access"]
|
|
516
|
+
},
|
|
517
|
+
local: {
|
|
518
|
+
name: "local",
|
|
519
|
+
mcpUrl: "https://app.experiture.test/mcp",
|
|
520
|
+
orchestratorUrl: "http://localhost:8000",
|
|
521
|
+
oauthResource: "https://mcp.dev.experiture.ai/mcp",
|
|
522
|
+
authorizationEndpoint: "https://app.experiture.test/api/auth/oauth/authorize",
|
|
523
|
+
tokenEndpoint: "https://app.experiture.test/api/auth/oauth/token",
|
|
524
|
+
clientId: "experiture-xyra-mcp-delegated",
|
|
525
|
+
redirectPath: "/callback/QYfSVwRg9okE",
|
|
526
|
+
scopes: ["openid", "profile", "email", "offline_access"]
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
var DEFAULT_ENVIRONMENT_NAME = "dev";
|
|
530
|
+
|
|
531
|
+
// src/config/configStore.ts
|
|
532
|
+
var CONFIG_DIR = process.env.XYRA_CLI_CONFIG_DIR ?? (0, import_node_path.join)((0, import_node_os.homedir)(), ".config", "xyra");
|
|
533
|
+
var CONFIG_PATH = (0, import_node_path.join)(CONFIG_DIR, "config.json");
|
|
534
|
+
function requireHttpsOrTest(name, url) {
|
|
535
|
+
let parsed;
|
|
536
|
+
try {
|
|
537
|
+
parsed = new URL(url);
|
|
538
|
+
} catch {
|
|
539
|
+
throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${name}' has an invalid URL: ${url}`);
|
|
540
|
+
}
|
|
541
|
+
const isTestDomain = parsed.hostname.endsWith(".test");
|
|
542
|
+
if (parsed.protocol !== "https:" && !isTestDomain) {
|
|
543
|
+
throw new CliError(
|
|
544
|
+
CliErrorCodes.ConfigInvalid,
|
|
545
|
+
`Environment '${name}' must use https (got ${parsed.protocol}//${parsed.host}).`
|
|
546
|
+
);
|
|
547
|
+
}
|
|
124
548
|
}
|
|
125
|
-
|
|
126
|
-
|
|
549
|
+
function requireHttpOrigin(name, url) {
|
|
550
|
+
let parsed;
|
|
551
|
+
try {
|
|
552
|
+
parsed = new URL(url);
|
|
553
|
+
} catch {
|
|
554
|
+
throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${name}' has an invalid URL: ${url}`);
|
|
555
|
+
}
|
|
556
|
+
const isLocalhost = parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
|
|
557
|
+
const isTestDomain = parsed.hostname.endsWith(".test");
|
|
558
|
+
const allowedProtocol = parsed.protocol === "https:" || parsed.protocol === "http:" && (isLocalhost || isTestDomain);
|
|
559
|
+
if (!allowedProtocol || parsed.username || parsed.password || parsed.search || parsed.hash || parsed.pathname !== "/" && parsed.pathname !== "") {
|
|
560
|
+
throw new CliError(
|
|
561
|
+
CliErrorCodes.ConfigInvalid,
|
|
562
|
+
`Environment '${name}' must be an HTTP(S) origin without credentials, path, query, or fragment.`
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
function validateEnvironment(env) {
|
|
567
|
+
for (const [field, url] of [
|
|
568
|
+
["mcpUrl", env.mcpUrl],
|
|
569
|
+
["authorizationEndpoint", env.authorizationEndpoint],
|
|
570
|
+
["tokenEndpoint", env.tokenEndpoint]
|
|
571
|
+
]) {
|
|
572
|
+
if (!url) {
|
|
573
|
+
throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${env.name}' is missing ${field}.`);
|
|
574
|
+
}
|
|
575
|
+
requireHttpsOrTest(`${env.name}.${field}`, url);
|
|
576
|
+
}
|
|
577
|
+
if (!env.orchestratorUrl) {
|
|
578
|
+
throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${env.name}' is missing orchestratorUrl.`);
|
|
579
|
+
}
|
|
580
|
+
requireHttpOrigin(`${env.name}.orchestratorUrl`, env.orchestratorUrl);
|
|
581
|
+
if (!env.clientId) {
|
|
582
|
+
throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${env.name}' is missing clientId.`);
|
|
583
|
+
}
|
|
584
|
+
if (!env.redirectPath.startsWith("/")) {
|
|
585
|
+
throw new CliError(CliErrorCodes.ConfigInvalid, `Environment '${env.name}' redirectPath must start with '/'.`);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
var ConfigStore = class {
|
|
589
|
+
constructor(path = CONFIG_PATH, activeEnvironmentOverride, accessPurposeOverride, administrationTargetOverride, sessionNameOverride) {
|
|
590
|
+
this.path = path;
|
|
591
|
+
this.activeEnvironmentOverride = activeEnvironmentOverride;
|
|
592
|
+
this.accessPurposeOverride = accessPurposeOverride;
|
|
593
|
+
this.administrationTargetOverride = administrationTargetOverride;
|
|
594
|
+
this.sessionNameOverride = sessionNameOverride;
|
|
595
|
+
}
|
|
596
|
+
getSessionName() {
|
|
597
|
+
return this.sessionNameOverride;
|
|
598
|
+
}
|
|
599
|
+
load() {
|
|
600
|
+
if (!(0, import_node_fs.existsSync)(this.path)) {
|
|
601
|
+
return {
|
|
602
|
+
activeEnvironment: this.activeEnvironmentOverride ?? DEFAULT_ENVIRONMENT_NAME,
|
|
603
|
+
environments: { ...DEFAULT_ENVIRONMENTS }
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
let raw;
|
|
607
|
+
try {
|
|
608
|
+
raw = JSON.parse((0, import_node_fs.readFileSync)(this.path, "utf8"));
|
|
609
|
+
} catch {
|
|
610
|
+
throw new CliError(CliErrorCodes.ConfigInvalid, `Config file at ${this.path} is not valid JSON.`);
|
|
611
|
+
}
|
|
612
|
+
const environments = Object.fromEntries(
|
|
613
|
+
Object.entries({ ...DEFAULT_ENVIRONMENTS, ...raw.environments ?? {} }).map(([name, env]) => [
|
|
614
|
+
name,
|
|
615
|
+
DEFAULT_ENVIRONMENTS[name] ? { ...DEFAULT_ENVIRONMENTS[name], ...env } : env
|
|
616
|
+
])
|
|
617
|
+
);
|
|
618
|
+
const activeEnvironment = this.activeEnvironmentOverride ?? raw.activeEnvironment ?? DEFAULT_ENVIRONMENT_NAME;
|
|
619
|
+
return { activeEnvironment, environments };
|
|
620
|
+
}
|
|
621
|
+
save(config) {
|
|
622
|
+
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(this.path), { recursive: true });
|
|
623
|
+
(0, import_node_fs.writeFileSync)(this.path, `${JSON.stringify(config, null, 2)}
|
|
624
|
+
`, { mode: 384 });
|
|
625
|
+
}
|
|
626
|
+
listEnvironments() {
|
|
627
|
+
const config = this.load();
|
|
628
|
+
return Object.keys(config.environments).sort().map((name) => ({ name, active: name === config.activeEnvironment }));
|
|
629
|
+
}
|
|
630
|
+
getActiveEnvironment() {
|
|
631
|
+
const config = this.load();
|
|
632
|
+
const env = config.environments[config.activeEnvironment];
|
|
633
|
+
if (!env) {
|
|
634
|
+
throw new CliError(
|
|
635
|
+
CliErrorCodes.EnvironmentNotFound,
|
|
636
|
+
`Active environment '${config.activeEnvironment}' is not defined. Run 'xyra env use <name>'.`
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
validateEnvironment(env);
|
|
640
|
+
if (env.accessPurpose !== void 0 || env.administrationTarget !== void 0) throw new CliError(
|
|
641
|
+
CliErrorCodes.ConfigInvalid,
|
|
642
|
+
"Purpose and selected administration target are invocation-only, not stored environment or actor fields."
|
|
643
|
+
);
|
|
644
|
+
const purpose = this.accessPurposeOverride ?? "runtime";
|
|
645
|
+
if (!["runtime", "administration"].includes(purpose) || purpose === "runtime" && this.administrationTargetOverride !== void 0)
|
|
646
|
+
throw new CliError(CliErrorCodes.InvalidArguments, "Select runtime or administration; a maintenance target requires administration purpose.");
|
|
647
|
+
if (purpose === "runtime") return env;
|
|
648
|
+
const profile = env.administrationOAuth;
|
|
649
|
+
if (!profile || !profile.clientId || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,99}$/.test(profile.clientId) || profile.clientId === env.clientId || env.mcpUrl !== env.oauthResource || !Array.isArray(profile.scopes) || profile.scopes.length > 100 || !profile.scopes.includes("openid") || !profile.scopes.includes("offline_access") || profile.scopes.some((scope) => typeof scope !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(scope)) || !profile.redirectPath || !/^\/callback\/[A-Za-z0-9_-]+$/.test(profile.redirectPath))
|
|
650
|
+
throw new CliError(
|
|
651
|
+
CliErrorCodes.ConfigInvalid,
|
|
652
|
+
`Environment '${env.name}' needs its registered Xyra-owned public administration CLI profile.`,
|
|
653
|
+
"Configure administrationOAuth with its separate native client, approved loopback callback path and delegated scopes; do not reuse the runtime or HTTPS connector client."
|
|
654
|
+
);
|
|
655
|
+
let selected;
|
|
656
|
+
try {
|
|
657
|
+
selected = this.administrationTargetOverride === void 0 ? { targetKind: "global-resource", managedProductId: "xyra-ai" } : (0, import_canonical_runtime_json.parseBoundedRuntimeJsonV1)(this.administrationTargetOverride, { maximumBytes: 8192, maximumDepth: 4 });
|
|
658
|
+
} catch {
|
|
659
|
+
throw new CliError(CliErrorCodes.InvalidArguments, "The administration target must be one bounded JSON object without repeated fields.");
|
|
660
|
+
}
|
|
661
|
+
const target = (0, import_xyra_administration.parseXyraAdministrationTargetV1)(selected);
|
|
662
|
+
if (!target) throw new CliError(CliErrorCodes.InvalidArguments, "Select one complete global, configuration-owner or customer administration target.");
|
|
663
|
+
return { ...env, clientId: profile.clientId, redirectPath: profile.redirectPath, scopes: [...profile.scopes], accessPurpose: "administration", administrationTarget: target };
|
|
664
|
+
}
|
|
665
|
+
useEnvironment(name) {
|
|
666
|
+
const config = this.load();
|
|
667
|
+
const env = config.environments[name];
|
|
668
|
+
if (!env) {
|
|
669
|
+
throw new CliError(
|
|
670
|
+
CliErrorCodes.EnvironmentNotFound,
|
|
671
|
+
`Environment '${name}' is not defined. Known: ${Object.keys(config.environments).join(", ")}.`
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
validateEnvironment(env);
|
|
675
|
+
config.activeEnvironment = name;
|
|
676
|
+
this.save({ ...config, activeEnvironment: name });
|
|
677
|
+
return env;
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
681
|
+
0 && (module.exports = {
|
|
682
|
+
ConfigStore,
|
|
683
|
+
validateEnvironment
|
|
684
|
+
});
|
|
685
|
+
//# sourceMappingURL=configStore.js.map
|