huaweicloud-devkit 2.0.0-next.1 → 2.0.0-next.2
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/README.md +2 -0
- package/package.json +1 -1
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.hermes-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/dist/agents/codearts-work.js +4 -0
- package/plugins/huaweicloud-core/dist/agents/codearts.js +4 -0
- package/plugins/huaweicloud-core/dist/auth/s1-store.js +43 -22
- package/plugins/huaweicloud-core/dist/lib/approval-tokens.js +3 -3
- package/plugins/huaweicloud-core/dist/lib/pack-state.js +23 -19
- package/plugins/huaweicloud-core/dist/lib/param-warnings.js +70 -0
- package/plugins/huaweicloud-core/dist/lib/state-dir.js +125 -0
- package/plugins/huaweicloud-core/dist/mcp-server.js +763 -567
- package/plugins/huaweicloud-core/dist/mcp-server.js.map +4 -4
- package/plugins/huaweicloud-core/dist/setup-cli.js +16 -0
- package/plugins/huaweicloud-core/dist/tool-schemas.js +15 -0
- package/plugins/huaweicloud-core/dist/tools.js +36 -4
- package/plugins/huaweicloud-core/dist/update-skip.js +5 -6
- package/plugins/huaweicloud-core/openclaw.plugin.json +1 -1
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +78 -2
- package/plugins/huaweicloud-core/src/agents/codearts-work.ts +3 -0
- package/plugins/huaweicloud-core/src/agents/codearts.ts +4 -0
- package/plugins/huaweicloud-core/src/auth/s1-store.ts +41 -20
- package/plugins/huaweicloud-core/src/lib/approval-tokens.ts +3 -3
- package/plugins/huaweicloud-core/src/lib/pack-state.ts +23 -20
- package/plugins/huaweicloud-core/src/lib/param-warnings.ts +69 -0
- package/plugins/huaweicloud-core/src/lib/state-dir.ts +128 -0
- package/plugins/huaweicloud-core/src/setup-cli.ts +21 -0
- package/plugins/huaweicloud-core/src/tool-schemas.ts +16 -0
- package/plugins/huaweicloud-core/src/tools.ts +39 -4
- package/plugins/huaweicloud-core/src/update-skip.ts +5 -6
|
@@ -8539,7 +8539,7 @@ function isRef(value) {
|
|
|
8539
8539
|
function cloneIssues(issues) {
|
|
8540
8540
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
8541
8541
|
}
|
|
8542
|
-
function isRecursive(inst, stack,
|
|
8542
|
+
function isRecursive(inst, stack, resolve10) {
|
|
8543
8543
|
const cached2 = recursive.get(inst);
|
|
8544
8544
|
if (cached2 !== void 0)
|
|
8545
8545
|
return cached2 ? PROVEN : NONE;
|
|
@@ -8549,7 +8549,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
8549
8549
|
let result = NONE;
|
|
8550
8550
|
const check2 = (child) => {
|
|
8551
8551
|
if (result !== PROVEN && child?._zod) {
|
|
8552
|
-
const answer = isRecursive(child, stack,
|
|
8552
|
+
const answer = isRecursive(child, stack, resolve10);
|
|
8553
8553
|
if (answer > result)
|
|
8554
8554
|
result = answer;
|
|
8555
8555
|
}
|
|
@@ -8560,7 +8560,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
8560
8560
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
8561
8561
|
if (spread && !desc.enumerable)
|
|
8562
8562
|
continue;
|
|
8563
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
8563
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve10) : NONE;
|
|
8564
8564
|
if (child > answer)
|
|
8565
8565
|
answer = child;
|
|
8566
8566
|
}
|
|
@@ -8624,7 +8624,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
8624
8624
|
break;
|
|
8625
8625
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
8626
8626
|
case "lazy": {
|
|
8627
|
-
const inner = def._cachedInner ?? (
|
|
8627
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
8628
8628
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
8629
8629
|
break;
|
|
8630
8630
|
}
|
|
@@ -28419,7 +28419,7 @@ var init_protocol = __esm({
|
|
|
28419
28419
|
return;
|
|
28420
28420
|
}
|
|
28421
28421
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
28422
|
-
await new Promise((
|
|
28422
|
+
await new Promise((resolve10) => setTimeout(resolve10, pollInterval));
|
|
28423
28423
|
options?.signal?.throwIfAborted();
|
|
28424
28424
|
}
|
|
28425
28425
|
} catch (error62) {
|
|
@@ -28436,7 +28436,7 @@ var init_protocol = __esm({
|
|
|
28436
28436
|
*/
|
|
28437
28437
|
request(request, resultSchema, options) {
|
|
28438
28438
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
28439
|
-
return new Promise((
|
|
28439
|
+
return new Promise((resolve10, reject) => {
|
|
28440
28440
|
const earlyReject = (error62) => {
|
|
28441
28441
|
reject(error62);
|
|
28442
28442
|
};
|
|
@@ -28514,7 +28514,7 @@ var init_protocol = __esm({
|
|
|
28514
28514
|
if (!parseResult.success) {
|
|
28515
28515
|
reject(parseResult.error);
|
|
28516
28516
|
} else {
|
|
28517
|
-
|
|
28517
|
+
resolve10(parseResult.data);
|
|
28518
28518
|
}
|
|
28519
28519
|
} catch (error62) {
|
|
28520
28520
|
reject(error62);
|
|
@@ -28776,12 +28776,12 @@ var init_protocol = __esm({
|
|
|
28776
28776
|
}
|
|
28777
28777
|
} catch {
|
|
28778
28778
|
}
|
|
28779
|
-
return new Promise((
|
|
28779
|
+
return new Promise((resolve10, reject) => {
|
|
28780
28780
|
if (signal.aborted) {
|
|
28781
28781
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
28782
28782
|
return;
|
|
28783
28783
|
}
|
|
28784
|
-
const timeoutId = setTimeout(
|
|
28784
|
+
const timeoutId = setTimeout(resolve10, interval);
|
|
28785
28785
|
signal.addEventListener("abort", () => {
|
|
28786
28786
|
clearTimeout(timeoutId);
|
|
28787
28787
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -31808,7 +31808,7 @@ var require_compile = __commonJS({
|
|
|
31808
31808
|
const schOrFunc = root.refs[ref];
|
|
31809
31809
|
if (schOrFunc)
|
|
31810
31810
|
return schOrFunc;
|
|
31811
|
-
let _sch =
|
|
31811
|
+
let _sch = resolve10.call(this, root, ref);
|
|
31812
31812
|
if (_sch === void 0) {
|
|
31813
31813
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
31814
31814
|
const { schemaId } = this.opts;
|
|
@@ -31835,7 +31835,7 @@ var require_compile = __commonJS({
|
|
|
31835
31835
|
function sameSchemaEnv(s1, s2) {
|
|
31836
31836
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
31837
31837
|
}
|
|
31838
|
-
function
|
|
31838
|
+
function resolve10(root, ref) {
|
|
31839
31839
|
let sch;
|
|
31840
31840
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
31841
31841
|
ref = sch;
|
|
@@ -32699,7 +32699,7 @@ var require_fast_uri = __commonJS({
|
|
|
32699
32699
|
}
|
|
32700
32700
|
return uri;
|
|
32701
32701
|
}
|
|
32702
|
-
function
|
|
32702
|
+
function resolve10(baseURI, relativeURI, options) {
|
|
32703
32703
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
32704
32704
|
const {
|
|
32705
32705
|
parsed: baseParsed,
|
|
@@ -33090,7 +33090,7 @@ var require_fast_uri = __commonJS({
|
|
|
33090
33090
|
var fastUri = {
|
|
33091
33091
|
SCHEMES,
|
|
33092
33092
|
normalize,
|
|
33093
|
-
resolve:
|
|
33093
|
+
resolve: resolve10,
|
|
33094
33094
|
resolveComponent,
|
|
33095
33095
|
equal,
|
|
33096
33096
|
serialize,
|
|
@@ -38881,7 +38881,7 @@ var require_compile2 = __commonJS({
|
|
|
38881
38881
|
const schOrFunc = root.refs[ref];
|
|
38882
38882
|
if (schOrFunc)
|
|
38883
38883
|
return schOrFunc;
|
|
38884
|
-
let _sch =
|
|
38884
|
+
let _sch = resolve10.call(this, root, ref);
|
|
38885
38885
|
if (_sch === void 0) {
|
|
38886
38886
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
38887
38887
|
const { schemaId } = this.opts;
|
|
@@ -38908,7 +38908,7 @@ var require_compile2 = __commonJS({
|
|
|
38908
38908
|
function sameSchemaEnv(s1, s2) {
|
|
38909
38909
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
38910
38910
|
}
|
|
38911
|
-
function
|
|
38911
|
+
function resolve10(root, ref) {
|
|
38912
38912
|
let sch;
|
|
38913
38913
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
38914
38914
|
ref = sch;
|
|
@@ -42943,7 +42943,7 @@ var init_mcp = __esm({
|
|
|
42943
42943
|
let task = createTaskResult.task;
|
|
42944
42944
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
42945
42945
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
42946
|
-
await new Promise((
|
|
42946
|
+
await new Promise((resolve10) => setTimeout(resolve10, pollInterval));
|
|
42947
42947
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
42948
42948
|
if (!updatedTask) {
|
|
42949
42949
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -44470,13 +44470,13 @@ function windowsScriptArgAtRaw(args, idx) {
|
|
|
44470
44470
|
return null;
|
|
44471
44471
|
const payloadOf = (j2, glued) => {
|
|
44472
44472
|
const strip = (s) => s.replace(/^['"]|['"]$/g, "");
|
|
44473
|
-
const
|
|
44473
|
+
const resolve10 = (s) => s.replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
44474
44474
|
const rest = args.slice(j2 + 1).map(String);
|
|
44475
44475
|
if (glued !== null) {
|
|
44476
44476
|
const g = strip(glued);
|
|
44477
|
-
return
|
|
44477
|
+
return resolve10(rest.length ? `${g} ${rest.join(" ")}` : g);
|
|
44478
44478
|
}
|
|
44479
|
-
return rest.length ?
|
|
44479
|
+
return rest.length ? resolve10(rest.join(" ")) : null;
|
|
44480
44480
|
};
|
|
44481
44481
|
if (isCmd) {
|
|
44482
44482
|
for (let j2 = idx + 1; j2 < args.length; j2++) {
|
|
@@ -44502,8 +44502,8 @@ function windowsScriptArgAtRaw(args, idx) {
|
|
|
44502
44502
|
return payloadOf(j2, null);
|
|
44503
44503
|
const attached = m[2].replace(/^['"]|['"]$/g, "");
|
|
44504
44504
|
const rest = args.slice(j2 + 1).map(String);
|
|
44505
|
-
const
|
|
44506
|
-
return
|
|
44505
|
+
const resolve10 = (s) => s.replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
44506
|
+
return resolve10(rest.length ? `${attached} ${rest.join(" ")}` : attached);
|
|
44507
44507
|
}
|
|
44508
44508
|
}
|
|
44509
44509
|
let j = idx + 1;
|
|
@@ -47384,6 +47384,187 @@ var init_invoke_value = __esm({
|
|
|
47384
47384
|
}
|
|
47385
47385
|
});
|
|
47386
47386
|
|
|
47387
|
+
// plugins/huaweicloud-core/dist.new/lib/state-dir.js
|
|
47388
|
+
import { existsSync as existsSync9, lstatSync, mkdirSync as mkdirSync3, rmSync as rmSync2 } from "node:fs";
|
|
47389
|
+
import { homedir as homedir8 } from "node:os";
|
|
47390
|
+
import { dirname as dirname7, isAbsolute, join as join9, resolve } from "node:path";
|
|
47391
|
+
function huaweiConfigBase(env = process.env) {
|
|
47392
|
+
return resolve(env.HUAWEICLOUD_HOME || homedir8(), ".config", "huaweicloud");
|
|
47393
|
+
}
|
|
47394
|
+
function agentHomeBase(env) {
|
|
47395
|
+
return resolve(env.HUAWEICLOUD_HOME || homedir8());
|
|
47396
|
+
}
|
|
47397
|
+
function nearestExisting(path) {
|
|
47398
|
+
let current = resolve(path);
|
|
47399
|
+
for (; ; ) {
|
|
47400
|
+
try {
|
|
47401
|
+
lstatSync(current);
|
|
47402
|
+
return current;
|
|
47403
|
+
} catch {
|
|
47404
|
+
const parent = dirname7(current);
|
|
47405
|
+
if (parent === current)
|
|
47406
|
+
return null;
|
|
47407
|
+
current = parent;
|
|
47408
|
+
}
|
|
47409
|
+
}
|
|
47410
|
+
}
|
|
47411
|
+
function probeWritableDir(path) {
|
|
47412
|
+
const anchor2 = nearestExisting(path);
|
|
47413
|
+
if (!anchor2)
|
|
47414
|
+
return false;
|
|
47415
|
+
const probe = join9(anchor2, `.devkit-write-probe-${process.pid}-${Math.random().toString(36).slice(2)}`);
|
|
47416
|
+
try {
|
|
47417
|
+
mkdirSync3(probe, { mode: 448 });
|
|
47418
|
+
return true;
|
|
47419
|
+
} catch {
|
|
47420
|
+
return false;
|
|
47421
|
+
} finally {
|
|
47422
|
+
try {
|
|
47423
|
+
rmSync2(probe, { recursive: true, force: true });
|
|
47424
|
+
} catch {
|
|
47425
|
+
}
|
|
47426
|
+
}
|
|
47427
|
+
}
|
|
47428
|
+
function codeArtsStateBase(env) {
|
|
47429
|
+
const home = agentHomeBase(env);
|
|
47430
|
+
for (const marker of AGENT_STATE_MARKERS) {
|
|
47431
|
+
const root = join9(home, marker);
|
|
47432
|
+
if (!existsSync9(root) || !probeWritableDir(root))
|
|
47433
|
+
continue;
|
|
47434
|
+
return join9(root, "devkit-state");
|
|
47435
|
+
}
|
|
47436
|
+
return null;
|
|
47437
|
+
}
|
|
47438
|
+
function explicitStateBase(env) {
|
|
47439
|
+
const value = (env[STATE_DIR_ENV] ?? "").trim();
|
|
47440
|
+
if (value === "")
|
|
47441
|
+
return null;
|
|
47442
|
+
if (!isAbsolute(value)) {
|
|
47443
|
+
throw new Error(`${STATE_DIR_ENV} must be an absolute path (got "${value}"): the CLI and the MCP server resolve relative paths against different working directories.`);
|
|
47444
|
+
}
|
|
47445
|
+
return resolve(value);
|
|
47446
|
+
}
|
|
47447
|
+
function devkitStateBase(env = process.env) {
|
|
47448
|
+
const explicit = explicitStateBase(env);
|
|
47449
|
+
if (explicit)
|
|
47450
|
+
return explicit;
|
|
47451
|
+
const configBase2 = huaweiConfigBase(env);
|
|
47452
|
+
const cached2 = stateBaseCache.get(configBase2);
|
|
47453
|
+
if (cached2)
|
|
47454
|
+
return cached2;
|
|
47455
|
+
const stateBase = probeWritableDir(configBase2) ? configBase2 : codeArtsStateBase(env) ?? configBase2;
|
|
47456
|
+
stateBaseCache.set(configBase2, stateBase);
|
|
47457
|
+
return stateBase;
|
|
47458
|
+
}
|
|
47459
|
+
var STATE_DIR_ENV, AGENT_STATE_MARKERS, stateBaseCache;
|
|
47460
|
+
var init_state_dir = __esm({
|
|
47461
|
+
"plugins/huaweicloud-core/dist.new/lib/state-dir.js"() {
|
|
47462
|
+
"use strict";
|
|
47463
|
+
STATE_DIR_ENV = "HUAWEICLOUD_STATE_DIR";
|
|
47464
|
+
AGENT_STATE_MARKERS = [".codearts", ".codeartswork", ".codeartsdoer"];
|
|
47465
|
+
stateBaseCache = /* @__PURE__ */ new Map();
|
|
47466
|
+
}
|
|
47467
|
+
});
|
|
47468
|
+
|
|
47469
|
+
// plugins/huaweicloud-core/dist.new/lib/pack-state.js
|
|
47470
|
+
import { chmodSync, lstatSync as lstatSync2, mkdirSync as mkdirSync4, realpathSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
47471
|
+
import { tmpdir } from "node:os";
|
|
47472
|
+
import { basename as basename2, dirname as dirname8, join as join10, resolve as resolve2, sep } from "node:path";
|
|
47473
|
+
function packStateDir(packId, env = process.env) {
|
|
47474
|
+
return join10(devkitStateBase(env), "packs", packId);
|
|
47475
|
+
}
|
|
47476
|
+
function ensurePackState(packId, fileNames, env = process.env) {
|
|
47477
|
+
const dir = packStateDir(packId, env);
|
|
47478
|
+
try {
|
|
47479
|
+
mkdirSync4(dir, { recursive: true, mode: 448 });
|
|
47480
|
+
chmodSync(dir, 448);
|
|
47481
|
+
} catch (error62) {
|
|
47482
|
+
throw new Error(`cannot provision pack state directory "${dir}": ${error62 instanceof Error ? error62.message : String(error62)}. Fix the permissions, or point HUAWEICLOUD_HOME at a writable location.`, { cause: error62 });
|
|
47483
|
+
}
|
|
47484
|
+
const files = {};
|
|
47485
|
+
for (const name of fileNames) {
|
|
47486
|
+
const path = join10(dir, name);
|
|
47487
|
+
try {
|
|
47488
|
+
try {
|
|
47489
|
+
writeFileSync3(path, "", { flag: "wx", mode: 384 });
|
|
47490
|
+
} catch (error62) {
|
|
47491
|
+
if (error62.code !== "EEXIST")
|
|
47492
|
+
throw error62;
|
|
47493
|
+
}
|
|
47494
|
+
chmodSync(path, 384);
|
|
47495
|
+
files[name] = path;
|
|
47496
|
+
} catch (error62) {
|
|
47497
|
+
throw new Error(`cannot provision pack state file "${path}": ${error62 instanceof Error ? error62.message : String(error62)}.`, { cause: error62 });
|
|
47498
|
+
}
|
|
47499
|
+
}
|
|
47500
|
+
return { dir, files };
|
|
47501
|
+
}
|
|
47502
|
+
function isRefusedByGuard(target) {
|
|
47503
|
+
if (process.platform === "win32" && /^[a-zA-Z]:[^\\/]/.test(target))
|
|
47504
|
+
return true;
|
|
47505
|
+
return target.split(/[\\/]/).includes("..");
|
|
47506
|
+
}
|
|
47507
|
+
function resolveForWrite(target) {
|
|
47508
|
+
const absolute = resolve2(tmpdir(), target);
|
|
47509
|
+
const tail = [];
|
|
47510
|
+
let current = absolute;
|
|
47511
|
+
for (; ; ) {
|
|
47512
|
+
try {
|
|
47513
|
+
lstatSync2(current);
|
|
47514
|
+
break;
|
|
47515
|
+
} catch {
|
|
47516
|
+
tail.unshift(basename2(current));
|
|
47517
|
+
const parent = dirname8(current);
|
|
47518
|
+
if (parent === current)
|
|
47519
|
+
break;
|
|
47520
|
+
current = parent;
|
|
47521
|
+
}
|
|
47522
|
+
}
|
|
47523
|
+
try {
|
|
47524
|
+
const real = realpathSync(current);
|
|
47525
|
+
return tail.length === 0 ? real : join10(real, ...tail);
|
|
47526
|
+
} catch {
|
|
47527
|
+
return null;
|
|
47528
|
+
}
|
|
47529
|
+
}
|
|
47530
|
+
function protectedTreeRoots(env = process.env) {
|
|
47531
|
+
const candidates = [huaweiConfigBase(env), devkitStateBase(env)];
|
|
47532
|
+
for (const key of ["HUAWEICLOUD_MCP_POLICY_FILE", "HUAWEICLOUD_MCP_AUDIT_FILE"]) {
|
|
47533
|
+
const value = (env[key] ?? "").trim();
|
|
47534
|
+
if (value !== "")
|
|
47535
|
+
candidates.push(value);
|
|
47536
|
+
}
|
|
47537
|
+
const roots = [];
|
|
47538
|
+
const seen = /* @__PURE__ */ new Set();
|
|
47539
|
+
for (const candidate of candidates) {
|
|
47540
|
+
const resolved = resolveForWrite(candidate);
|
|
47541
|
+
if (resolved === null)
|
|
47542
|
+
return null;
|
|
47543
|
+
if (seen.has(resolved))
|
|
47544
|
+
continue;
|
|
47545
|
+
seen.add(resolved);
|
|
47546
|
+
roots.push(resolved);
|
|
47547
|
+
}
|
|
47548
|
+
return roots;
|
|
47549
|
+
}
|
|
47550
|
+
function isInsideProtectedTree(target, env = process.env) {
|
|
47551
|
+
if (isRefusedByGuard(target))
|
|
47552
|
+
return true;
|
|
47553
|
+
const roots = protectedTreeRoots(env);
|
|
47554
|
+
if (roots === null)
|
|
47555
|
+
return true;
|
|
47556
|
+
const resolved = resolveForWrite(target);
|
|
47557
|
+
if (resolved === null)
|
|
47558
|
+
return true;
|
|
47559
|
+
return roots.some((root) => resolved === root || resolved.startsWith(root + sep));
|
|
47560
|
+
}
|
|
47561
|
+
var init_pack_state = __esm({
|
|
47562
|
+
"plugins/huaweicloud-core/dist.new/lib/pack-state.js"() {
|
|
47563
|
+
"use strict";
|
|
47564
|
+
init_state_dir();
|
|
47565
|
+
}
|
|
47566
|
+
});
|
|
47567
|
+
|
|
47387
47568
|
// plugins/huaweicloud-core/dist.new/lib/pack-types.js
|
|
47388
47569
|
var PACK_IDS;
|
|
47389
47570
|
var init_pack_types = __esm({
|
|
@@ -47496,14 +47677,14 @@ var init_dependency_model = __esm({
|
|
|
47496
47677
|
});
|
|
47497
47678
|
|
|
47498
47679
|
// plugins/huaweicloud-core/dist.new/dep/receipts.js
|
|
47499
|
-
import { existsSync as
|
|
47500
|
-
import { homedir as
|
|
47501
|
-
import { join as
|
|
47502
|
-
function receiptDir(base = process.env.HUAWEICLOUD_HOME ||
|
|
47503
|
-
return
|
|
47680
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync5, readdirSync, readFileSync as readFileSync10, renameSync as renameSync2, rmSync as rmSync3, statSync as statSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
47681
|
+
import { homedir as homedir9 } from "node:os";
|
|
47682
|
+
import { join as join11 } from "node:path";
|
|
47683
|
+
function receiptDir(base = process.env.HUAWEICLOUD_HOME || homedir9()) {
|
|
47684
|
+
return join11(base, ".config", "huaweicloud", "deps");
|
|
47504
47685
|
}
|
|
47505
47686
|
function lockDirPath(dir) {
|
|
47506
|
-
return
|
|
47687
|
+
return join11(dir, LOCK_DIR_NAME);
|
|
47507
47688
|
}
|
|
47508
47689
|
function isPidAlive(pid) {
|
|
47509
47690
|
if (process.platform === "linux") {
|
|
@@ -47525,10 +47706,10 @@ function sleepSync(ms) {
|
|
|
47525
47706
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
47526
47707
|
}
|
|
47527
47708
|
function readHolderPid(dir) {
|
|
47528
|
-
return readPidAt(
|
|
47709
|
+
return readPidAt(join11(lockDirPath(dir), LOCK_PID_FILE));
|
|
47529
47710
|
}
|
|
47530
47711
|
function readStashHolderPid(stashDir) {
|
|
47531
|
-
return readPidAt(
|
|
47712
|
+
return readPidAt(join11(stashDir, LOCK_PID_FILE));
|
|
47532
47713
|
}
|
|
47533
47714
|
function readPidAt(pidFile) {
|
|
47534
47715
|
try {
|
|
@@ -47542,22 +47723,22 @@ function sweepStaleStashes(dir) {
|
|
|
47542
47723
|
try {
|
|
47543
47724
|
for (const entry of readdirSync(dir)) {
|
|
47544
47725
|
if (entry.startsWith(`${LOCK_DIR_NAME}.`) && (entry.endsWith(".takeover") || entry.endsWith(".release"))) {
|
|
47545
|
-
|
|
47726
|
+
rmSync3(join11(dir, entry), { recursive: true, force: true });
|
|
47546
47727
|
}
|
|
47547
47728
|
}
|
|
47548
47729
|
} catch {
|
|
47549
47730
|
}
|
|
47550
47731
|
}
|
|
47551
47732
|
function acquireLock(dir, takeoverMs = LOCK_TAKEOVER_MS) {
|
|
47552
|
-
|
|
47733
|
+
mkdirSync5(dir, { recursive: true });
|
|
47553
47734
|
sweepStaleStashes(dir);
|
|
47554
47735
|
const lock = lockDirPath(dir);
|
|
47555
47736
|
const deadline = Date.now() + takeoverMs;
|
|
47556
47737
|
for (; ; ) {
|
|
47557
47738
|
try {
|
|
47558
|
-
|
|
47739
|
+
mkdirSync5(lock);
|
|
47559
47740
|
const claimed = statSync2(lock);
|
|
47560
|
-
|
|
47741
|
+
writeFileSync4(join11(lock, LOCK_PID_FILE), `${process.pid}
|
|
47561
47742
|
`);
|
|
47562
47743
|
const rechecked = statSync2(lock);
|
|
47563
47744
|
if (rechecked.ino !== claimed.ino || rechecked.birthtimeMs !== claimed.birthtimeMs) {
|
|
@@ -47574,7 +47755,7 @@ function acquireLock(dir, takeoverMs = LOCK_TAKEOVER_MS) {
|
|
|
47574
47755
|
if (holder !== null && isPidAlive(holder)) {
|
|
47575
47756
|
let claimIsFresh = true;
|
|
47576
47757
|
try {
|
|
47577
|
-
claimIsFresh = Date.now() - statSync2(
|
|
47758
|
+
claimIsFresh = Date.now() - statSync2(join11(lock, LOCK_PID_FILE)).mtimeMs < takeoverMs;
|
|
47578
47759
|
} catch {
|
|
47579
47760
|
}
|
|
47580
47761
|
if (claimIsFresh) {
|
|
@@ -47607,7 +47788,7 @@ function acquireLock(dir, takeoverMs = LOCK_TAKEOVER_MS) {
|
|
|
47607
47788
|
sleepSync(LOCK_POLL_MS);
|
|
47608
47789
|
continue;
|
|
47609
47790
|
}
|
|
47610
|
-
|
|
47791
|
+
rmSync3(uniqueStash, { recursive: true, force: true });
|
|
47611
47792
|
}
|
|
47612
47793
|
}
|
|
47613
47794
|
function releaseLock(dir) {
|
|
@@ -47619,7 +47800,7 @@ function releaseLock(dir) {
|
|
|
47619
47800
|
return;
|
|
47620
47801
|
}
|
|
47621
47802
|
if (readStashHolderPid(stash) === process.pid) {
|
|
47622
|
-
|
|
47803
|
+
rmSync3(stash, { recursive: true, force: true });
|
|
47623
47804
|
} else {
|
|
47624
47805
|
try {
|
|
47625
47806
|
renameSync2(stash, lock);
|
|
@@ -47724,12 +47905,12 @@ var init_refs = __esm({
|
|
|
47724
47905
|
|
|
47725
47906
|
// plugins/huaweicloud-core/dist.new/lib/secret-vault/custody.js
|
|
47726
47907
|
import { spawnSync } from "node:child_process";
|
|
47727
|
-
import { existsSync as
|
|
47728
|
-
import { join as
|
|
47729
|
-
import { homedir as
|
|
47908
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync6, readFileSync as readFileSync11, readdirSync as readdirSync2, renameSync as renameSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
47909
|
+
import { join as join12 } from "node:path";
|
|
47910
|
+
import { homedir as homedir10 } from "node:os";
|
|
47730
47911
|
import { randomBytes } from "node:crypto";
|
|
47731
47912
|
function defaultSecretsRoot() {
|
|
47732
|
-
return
|
|
47913
|
+
return join12(process.env.HUAWEICLOUD_HOME || homedir10(), ".config", "huaweicloud", "secrets");
|
|
47733
47914
|
}
|
|
47734
47915
|
function rootOf(options) {
|
|
47735
47916
|
return options?.root ?? defaultSecretsRoot();
|
|
@@ -47738,7 +47919,7 @@ function spawnerOf(options) {
|
|
|
47738
47919
|
return options?.spawnImpl ?? spawnSync;
|
|
47739
47920
|
}
|
|
47740
47921
|
function keyfilePath(root) {
|
|
47741
|
-
return
|
|
47922
|
+
return join12(root, ".master-key");
|
|
47742
47923
|
}
|
|
47743
47924
|
function masterKeyFromEnv() {
|
|
47744
47925
|
const raw = process.env.HW_VAULT_MASTER_KEY;
|
|
@@ -47932,7 +48113,7 @@ function keychainTierName() {
|
|
|
47932
48113
|
}
|
|
47933
48114
|
function readKeyfile(root) {
|
|
47934
48115
|
const file2 = keyfilePath(root);
|
|
47935
|
-
if (!
|
|
48116
|
+
if (!existsSync11(file2))
|
|
47936
48117
|
return null;
|
|
47937
48118
|
const key = decodeMasterKeyB64(readFileSync11(file2, "utf8"));
|
|
47938
48119
|
if (!key) {
|
|
@@ -47969,10 +48150,10 @@ function resolveMasterKey(options) {
|
|
|
47969
48150
|
return null;
|
|
47970
48151
|
}
|
|
47971
48152
|
function writeKeyfile(root, key) {
|
|
47972
|
-
|
|
48153
|
+
mkdirSync6(root, { recursive: true });
|
|
47973
48154
|
const file2 = keyfilePath(root);
|
|
47974
48155
|
const tmp = `${file2}.${process.pid}.${Date.now()}.tmp`;
|
|
47975
|
-
|
|
48156
|
+
writeFileSync5(tmp, key.toString("base64"), { encoding: "utf8", mode: 384 });
|
|
47976
48157
|
renameSync3(tmp, file2);
|
|
47977
48158
|
const readBack = decodeMasterKeyB64(readFileSync11(file2, "utf8"));
|
|
47978
48159
|
if (!readBack || !readBack.equals(key)) {
|
|
@@ -47984,7 +48165,7 @@ function storeHasRecords(root) {
|
|
|
47984
48165
|
for (const entry of readdirSync2(root, { withFileTypes: true })) {
|
|
47985
48166
|
if (!entry.isDirectory())
|
|
47986
48167
|
continue;
|
|
47987
|
-
if (readdirSync2(
|
|
48168
|
+
if (readdirSync2(join12(root, entry.name)).some((file2) => file2.endsWith(".json")))
|
|
47988
48169
|
return true;
|
|
47989
48170
|
}
|
|
47990
48171
|
} catch {
|
|
@@ -48060,16 +48241,16 @@ var init_custody = __esm({
|
|
|
48060
48241
|
|
|
48061
48242
|
// plugins/huaweicloud-core/dist.new/lib/secret-vault/store.js
|
|
48062
48243
|
import { createCipheriv, createDecipheriv, createHmac, randomBytes as randomBytes2 } from "node:crypto";
|
|
48063
|
-
import { existsSync as
|
|
48064
|
-
import { join as
|
|
48244
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync7, readdirSync as readdirSync3, readFileSync as readFileSync12, renameSync as renameSync4, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "node:fs";
|
|
48245
|
+
import { join as join13 } from "node:path";
|
|
48065
48246
|
function rootOf2(options) {
|
|
48066
48247
|
return options?.root ?? defaultSecretsRoot();
|
|
48067
48248
|
}
|
|
48068
48249
|
function scopeDir(root, scope) {
|
|
48069
|
-
return
|
|
48250
|
+
return join13(root, scope);
|
|
48070
48251
|
}
|
|
48071
48252
|
function secretFile(root, ref) {
|
|
48072
|
-
return
|
|
48253
|
+
return join13(scopeDir(root, ref.scope), `${ref.name}.json`);
|
|
48073
48254
|
}
|
|
48074
48255
|
function fingerprintOf(masterKey, value) {
|
|
48075
48256
|
return createHmac("sha256", masterKey).update(value, "utf8").digest("hex").slice(0, 16);
|
|
@@ -48096,7 +48277,7 @@ function decrypt(masterKey, ref, record2) {
|
|
|
48096
48277
|
}
|
|
48097
48278
|
}
|
|
48098
48279
|
function readRecord(path) {
|
|
48099
|
-
if (!
|
|
48280
|
+
if (!existsSync12(path))
|
|
48100
48281
|
return null;
|
|
48101
48282
|
let parsed;
|
|
48102
48283
|
try {
|
|
@@ -48138,10 +48319,10 @@ function readRecord(path) {
|
|
|
48138
48319
|
}
|
|
48139
48320
|
function writeRecord(root, ref, record2) {
|
|
48140
48321
|
const dir = scopeDir(root, ref.scope);
|
|
48141
|
-
|
|
48322
|
+
mkdirSync7(dir, { recursive: true });
|
|
48142
48323
|
const file2 = secretFile(root, ref);
|
|
48143
48324
|
const tmp = `${file2}.${process.pid}.${Date.now()}.tmp`;
|
|
48144
|
-
|
|
48325
|
+
writeFileSync6(tmp, JSON.stringify(record2, null, 2), { encoding: "utf8", mode: 384 });
|
|
48145
48326
|
renameSync4(tmp, file2);
|
|
48146
48327
|
}
|
|
48147
48328
|
function masterKeyForRead(options) {
|
|
@@ -48207,9 +48388,9 @@ function vaultDelete(refInput, options) {
|
|
|
48207
48388
|
const root = rootOf2(options);
|
|
48208
48389
|
return withDepLock(() => {
|
|
48209
48390
|
const file2 = secretFile(root, ref);
|
|
48210
|
-
if (!
|
|
48391
|
+
if (!existsSync12(file2))
|
|
48211
48392
|
return { removed: 0 };
|
|
48212
|
-
|
|
48393
|
+
rmSync4(file2, { force: true });
|
|
48213
48394
|
return { removed: 1 };
|
|
48214
48395
|
}, root);
|
|
48215
48396
|
}
|
|
@@ -48220,7 +48401,7 @@ function vaultList(scope, options) {
|
|
|
48220
48401
|
}
|
|
48221
48402
|
const scopes = [];
|
|
48222
48403
|
if (scope === void 0) {
|
|
48223
|
-
if (!
|
|
48404
|
+
if (!existsSync12(root))
|
|
48224
48405
|
return [];
|
|
48225
48406
|
for (const entry of readdirSync3(root, { withFileTypes: true })) {
|
|
48226
48407
|
if (!entry.isDirectory())
|
|
@@ -48235,13 +48416,13 @@ function vaultList(scope, options) {
|
|
|
48235
48416
|
const out = [];
|
|
48236
48417
|
for (const scopeName of scopes) {
|
|
48237
48418
|
const dir = scopeDir(root, scopeName);
|
|
48238
|
-
if (!
|
|
48419
|
+
if (!existsSync12(dir))
|
|
48239
48420
|
continue;
|
|
48240
48421
|
for (const entry of readdirSync3(dir).sort((a, b) => a.localeCompare(b))) {
|
|
48241
48422
|
if (!entry.endsWith(".json") || !isValidNameSegment(entry.slice(0, -".json".length)))
|
|
48242
48423
|
continue;
|
|
48243
48424
|
const name = entry.slice(0, -".json".length);
|
|
48244
|
-
const record2 = readRecord(
|
|
48425
|
+
const record2 = readRecord(join13(dir, entry));
|
|
48245
48426
|
if (!record2)
|
|
48246
48427
|
continue;
|
|
48247
48428
|
out.push({
|
|
@@ -48278,14 +48459,13 @@ var init_store = __esm({
|
|
|
48278
48459
|
});
|
|
48279
48460
|
|
|
48280
48461
|
// plugins/huaweicloud-core/dist.new/auth/s1-store.js
|
|
48281
|
-
import { chmodSync, copyFileSync, existsSync as
|
|
48282
|
-
import { dirname as
|
|
48283
|
-
import { homedir as homedir10 } from "node:os";
|
|
48462
|
+
import { chmodSync as chmodSync2, copyFileSync, existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync13, statSync as statSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
48463
|
+
import { dirname as dirname9, join as join14 } from "node:path";
|
|
48284
48464
|
function ensurePrivateMode(path) {
|
|
48285
48465
|
if (process.platform === "win32")
|
|
48286
48466
|
return;
|
|
48287
48467
|
try {
|
|
48288
|
-
|
|
48468
|
+
chmodSync2(path, 384);
|
|
48289
48469
|
} catch {
|
|
48290
48470
|
}
|
|
48291
48471
|
try {
|
|
@@ -48299,15 +48479,14 @@ function ensurePrivateMode(path) {
|
|
|
48299
48479
|
} catch {
|
|
48300
48480
|
}
|
|
48301
48481
|
}
|
|
48302
|
-
function baseHome2() {
|
|
48303
|
-
return process.env.HUAWEICLOUD_HOME || homedir10();
|
|
48304
|
-
}
|
|
48305
48482
|
function globalCredentialsPath() {
|
|
48306
|
-
return
|
|
48483
|
+
return join14(devkitStateBase(), "credentials.json");
|
|
48307
48484
|
}
|
|
48308
|
-
function
|
|
48309
|
-
|
|
48310
|
-
|
|
48485
|
+
function legacyGlobalCredentialsPath() {
|
|
48486
|
+
return join14(huaweiConfigBase(), "credentials.json");
|
|
48487
|
+
}
|
|
48488
|
+
function readJsonObject(path) {
|
|
48489
|
+
if (!existsSync13(path))
|
|
48311
48490
|
return null;
|
|
48312
48491
|
try {
|
|
48313
48492
|
const parsed = JSON.parse(readFileSync13(path, "utf8"));
|
|
@@ -48316,6 +48495,18 @@ function readGlobalCredentials() {
|
|
|
48316
48495
|
return null;
|
|
48317
48496
|
}
|
|
48318
48497
|
}
|
|
48498
|
+
function readGlobalCredentials() {
|
|
48499
|
+
const primary = globalCredentialsPath();
|
|
48500
|
+
const stored = readJsonObject(primary);
|
|
48501
|
+
if (stored)
|
|
48502
|
+
return stored;
|
|
48503
|
+
if (!existsSync13(primary)) {
|
|
48504
|
+
const legacy = legacyGlobalCredentialsPath();
|
|
48505
|
+
if (legacy !== primary)
|
|
48506
|
+
return readJsonObject(legacy);
|
|
48507
|
+
}
|
|
48508
|
+
return null;
|
|
48509
|
+
}
|
|
48319
48510
|
function resolveStoredRefs(stored) {
|
|
48320
48511
|
if (!stored)
|
|
48321
48512
|
return null;
|
|
@@ -48344,7 +48535,7 @@ function readGlobalCredentialsStrict() {
|
|
|
48344
48535
|
}
|
|
48345
48536
|
function writeGlobalCredentials(credentials = {}) {
|
|
48346
48537
|
const path = globalCredentialsPath();
|
|
48347
|
-
|
|
48538
|
+
mkdirSync8(dirname9(path), { recursive: true });
|
|
48348
48539
|
const payload = {
|
|
48349
48540
|
ak: asText(credentials.ak || ""),
|
|
48350
48541
|
sk: asText(credentials.sk || ""),
|
|
@@ -48352,7 +48543,7 @@ function writeGlobalCredentials(credentials = {}) {
|
|
|
48352
48543
|
region: asText(credentials.region || ""),
|
|
48353
48544
|
...credentials.configuredBySession === void 0 ? {} : { configuredBySession: Boolean(credentials.configuredBySession) }
|
|
48354
48545
|
};
|
|
48355
|
-
|
|
48546
|
+
writeFileSync7(path, JSON.stringify(payload, null, 2), { encoding: "utf8", mode: 384 });
|
|
48356
48547
|
ensurePrivateMode(path);
|
|
48357
48548
|
return path;
|
|
48358
48549
|
}
|
|
@@ -48362,37 +48553,43 @@ function setConfiguredBySession(flag) {
|
|
|
48362
48553
|
writeGlobalCredentials(next);
|
|
48363
48554
|
}
|
|
48364
48555
|
function lastSyncPath() {
|
|
48365
|
-
return
|
|
48556
|
+
return join14(devkitStateBase(), ".last_sync");
|
|
48557
|
+
}
|
|
48558
|
+
function readLastSyncFile(path) {
|
|
48559
|
+
return readJsonObject(path);
|
|
48366
48560
|
}
|
|
48367
48561
|
function readLastSync() {
|
|
48368
|
-
const
|
|
48369
|
-
|
|
48370
|
-
|
|
48371
|
-
|
|
48372
|
-
|
|
48373
|
-
|
|
48374
|
-
|
|
48375
|
-
|
|
48562
|
+
const primary = lastSyncPath();
|
|
48563
|
+
const stored = readLastSyncFile(primary);
|
|
48564
|
+
if (stored)
|
|
48565
|
+
return stored;
|
|
48566
|
+
if (!existsSync13(primary)) {
|
|
48567
|
+
const legacy = join14(huaweiConfigBase(), ".last_sync");
|
|
48568
|
+
if (legacy !== primary)
|
|
48569
|
+
return readLastSyncFile(legacy);
|
|
48376
48570
|
}
|
|
48571
|
+
return null;
|
|
48377
48572
|
}
|
|
48378
48573
|
function writeLastSync(metadata = {}) {
|
|
48379
48574
|
const path = lastSyncPath();
|
|
48380
|
-
|
|
48575
|
+
mkdirSync8(dirname9(path), { recursive: true });
|
|
48381
48576
|
const payload = {
|
|
48382
48577
|
ts: Date.now(),
|
|
48383
48578
|
...metadata.kooCliProfile ? { kooCliProfile: asText(metadata.kooCliProfile) } : {},
|
|
48384
48579
|
...metadata.s1Fingerprint ? { s1Fingerprint: asText(metadata.s1Fingerprint) } : {}
|
|
48385
48580
|
};
|
|
48386
|
-
|
|
48581
|
+
writeFileSync7(path, JSON.stringify(payload), { encoding: "utf8", mode: 384 });
|
|
48387
48582
|
ensurePrivateMode(path);
|
|
48388
48583
|
}
|
|
48389
48584
|
function backupGlobalCredentials() {
|
|
48390
|
-
const
|
|
48391
|
-
|
|
48585
|
+
const target = globalCredentialsPath();
|
|
48586
|
+
const source = existsSync13(target) ? target : legacyGlobalCredentialsPath();
|
|
48587
|
+
if (!existsSync13(source))
|
|
48392
48588
|
return null;
|
|
48393
|
-
const bakPath = `${
|
|
48589
|
+
const bakPath = `${target}.bak`;
|
|
48394
48590
|
try {
|
|
48395
|
-
|
|
48591
|
+
mkdirSync8(dirname9(bakPath), { recursive: true });
|
|
48592
|
+
copyFileSync(source, bakPath);
|
|
48396
48593
|
ensurePrivateMode(bakPath);
|
|
48397
48594
|
return bakPath;
|
|
48398
48595
|
} catch {
|
|
@@ -48403,6 +48600,7 @@ var init_s1_store = __esm({
|
|
|
48403
48600
|
"plugins/huaweicloud-core/dist.new/auth/s1-store.js"() {
|
|
48404
48601
|
"use strict";
|
|
48405
48602
|
init_as_text();
|
|
48603
|
+
init_pack_state();
|
|
48406
48604
|
init_store();
|
|
48407
48605
|
}
|
|
48408
48606
|
});
|
|
@@ -48435,8 +48633,8 @@ var init_credential_placeholder = __esm({
|
|
|
48435
48633
|
});
|
|
48436
48634
|
|
|
48437
48635
|
// plugins/huaweicloud-core/dist.new/auth/codearts-context.js
|
|
48438
|
-
import { existsSync as
|
|
48439
|
-
import { join as
|
|
48636
|
+
import { existsSync as existsSync14, readFileSync as readFileSync14, readlinkSync } from "node:fs";
|
|
48637
|
+
import { join as join15 } from "node:path";
|
|
48440
48638
|
import { homedir as homedir11 } from "node:os";
|
|
48441
48639
|
function pickDevkitMcpServer(mcpMap) {
|
|
48442
48640
|
const map2 = asRecord(mcpMap);
|
|
@@ -48484,7 +48682,7 @@ function getParentCwd() {
|
|
|
48484
48682
|
}
|
|
48485
48683
|
}
|
|
48486
48684
|
function isCodeArtsContext() {
|
|
48487
|
-
return
|
|
48685
|
+
return existsSync14(join15(process.cwd(), ".codeartsdoer")) || existsSync14(join15(homedir11(), ".codeartsdoer")) || existsSync14(join15(homedir11(), ".codeartswork")) || existsSync14(join15(homedir11(), ".codearts"));
|
|
48488
48686
|
}
|
|
48489
48687
|
function readCodeArtsCredentials() {
|
|
48490
48688
|
const parentCwd = getParentCwd();
|
|
@@ -48492,9 +48690,9 @@ function readCodeArtsCredentials() {
|
|
|
48492
48690
|
for (const dir of searchDirs) {
|
|
48493
48691
|
if (!dir)
|
|
48494
48692
|
continue;
|
|
48495
|
-
const path =
|
|
48693
|
+
const path = join15(dir, ".codeartsdoer", "mcp", "mcp_settings.json");
|
|
48496
48694
|
try {
|
|
48497
|
-
if (!
|
|
48695
|
+
if (!existsSync14(path))
|
|
48498
48696
|
continue;
|
|
48499
48697
|
const config2 = JSON.parse(readFileSync14(path, "utf8"));
|
|
48500
48698
|
const server = pickDevkitMcpServer(asRecord(config2).mcpServers);
|
|
@@ -48516,12 +48714,12 @@ function readCodeArtsCredentials() {
|
|
|
48516
48714
|
}
|
|
48517
48715
|
}
|
|
48518
48716
|
const workPaths = [
|
|
48519
|
-
|
|
48520
|
-
|
|
48717
|
+
join15(homedir11(), ".codearts", "mcp", "mcp_settings.json"),
|
|
48718
|
+
join15(homedir11(), ".codeartswork", "mcp", "mcp_settings.json")
|
|
48521
48719
|
];
|
|
48522
48720
|
for (const path of workPaths) {
|
|
48523
48721
|
try {
|
|
48524
|
-
if (!
|
|
48722
|
+
if (!existsSync14(path))
|
|
48525
48723
|
continue;
|
|
48526
48724
|
const config2 = JSON.parse(readFileSync14(path, "utf8"));
|
|
48527
48725
|
const entry = readWorkEnvironmentEntry(config2);
|
|
@@ -48600,7 +48798,7 @@ var init_sts_expiry = __esm({
|
|
|
48600
48798
|
|
|
48601
48799
|
// plugins/huaweicloud-core/dist.new/auth/error-table.js
|
|
48602
48800
|
import { homedir as homedir12 } from "node:os";
|
|
48603
|
-
import { join as
|
|
48801
|
+
import { join as join16 } from "node:path";
|
|
48604
48802
|
function buildOnboardingSteps(scenario, { codearts = false } = {}) {
|
|
48605
48803
|
switch (scenario) {
|
|
48606
48804
|
case 3: {
|
|
@@ -48611,7 +48809,7 @@ function buildOnboardingSteps(scenario, { codearts = false } = {}) {
|
|
|
48611
48809
|
{
|
|
48612
48810
|
order: 2,
|
|
48613
48811
|
action: "write-import",
|
|
48614
|
-
target:
|
|
48812
|
+
target: join16(homedir12(), ".config", "huaweicloud", "creds-import.json"),
|
|
48615
48813
|
label: "\u628A AK/SK \u5199\u5165 creds-import.json"
|
|
48616
48814
|
},
|
|
48617
48815
|
{
|
|
@@ -48718,11 +48916,11 @@ var init_error_table = __esm({
|
|
|
48718
48916
|
});
|
|
48719
48917
|
|
|
48720
48918
|
// plugins/huaweicloud-core/dist.new/auth/obs-config.js
|
|
48721
|
-
import { writeFileSync as
|
|
48722
|
-
import { join as
|
|
48919
|
+
import { writeFileSync as writeFileSync8 } from "node:fs";
|
|
48920
|
+
import { join as join17 } from "node:path";
|
|
48723
48921
|
import { homedir as homedir13 } from "node:os";
|
|
48724
48922
|
function obsConfigPath() {
|
|
48725
|
-
return process.env.HCLOUD_OBS_CONFIG_PATH ||
|
|
48923
|
+
return process.env.HCLOUD_OBS_CONFIG_PATH || join17(homedir13(), ".obsutilconfig");
|
|
48726
48924
|
}
|
|
48727
48925
|
function writeObsConfig(credentials = {}) {
|
|
48728
48926
|
const region = asText(credentials.region || "");
|
|
@@ -48739,7 +48937,7 @@ ak=${ak}
|
|
|
48739
48937
|
sk=${sk}${securityToken ? `
|
|
48740
48938
|
token=${securityToken}` : ""}
|
|
48741
48939
|
`;
|
|
48742
|
-
|
|
48940
|
+
writeFileSync8(path, content, { encoding: "utf8", mode: 384 });
|
|
48743
48941
|
ensurePrivateMode(path);
|
|
48744
48942
|
return { path, endpoint };
|
|
48745
48943
|
}
|
|
@@ -49279,10 +49477,10 @@ var init_update_semver = __esm({
|
|
|
49279
49477
|
|
|
49280
49478
|
// plugins/huaweicloud-core/dist.new/update-installed.js
|
|
49281
49479
|
import { readFileSync as readFileSync15 } from "node:fs";
|
|
49282
|
-
import { join as
|
|
49480
|
+
import { join as join18, dirname as dirname10, resolve as resolve3 } from "node:path";
|
|
49283
49481
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
49284
49482
|
function selfDir() {
|
|
49285
|
-
return
|
|
49483
|
+
return dirname10(fileURLToPath4(import.meta.url));
|
|
49286
49484
|
}
|
|
49287
49485
|
function readJsonVersion(file2) {
|
|
49288
49486
|
try {
|
|
@@ -49296,15 +49494,15 @@ function readJsonVersion(file2) {
|
|
|
49296
49494
|
}
|
|
49297
49495
|
}
|
|
49298
49496
|
function readInstalledVersion() {
|
|
49299
|
-
const pluginRoot =
|
|
49300
|
-
const packageRoot =
|
|
49497
|
+
const pluginRoot = resolve3(selfDir(), "..");
|
|
49498
|
+
const packageRoot = resolve3(pluginRoot, "..", "..");
|
|
49301
49499
|
for (const base of [pluginRoot, packageRoot]) {
|
|
49302
|
-
const version2 = readJsonVersion(
|
|
49500
|
+
const version2 = readJsonVersion(join18(base, "package.json"));
|
|
49303
49501
|
if (version2)
|
|
49304
49502
|
return version2;
|
|
49305
49503
|
}
|
|
49306
49504
|
for (const rel of VERSION_MANIFEST_RELS) {
|
|
49307
|
-
const version2 = readJsonVersion(
|
|
49505
|
+
const version2 = readJsonVersion(join18(pluginRoot, rel));
|
|
49308
49506
|
if (version2)
|
|
49309
49507
|
return version2;
|
|
49310
49508
|
}
|
|
@@ -49326,15 +49524,13 @@ var init_update_installed = __esm({
|
|
|
49326
49524
|
});
|
|
49327
49525
|
|
|
49328
49526
|
// plugins/huaweicloud-core/dist.new/update-skip.js
|
|
49329
|
-
import { existsSync as
|
|
49330
|
-
import { join as
|
|
49331
|
-
import { homedir as homedir14 } from "node:os";
|
|
49527
|
+
import { existsSync as existsSync15, readFileSync as readFileSync16, writeFileSync as writeFileSync9, renameSync as renameSync5, mkdirSync as mkdirSync9, rmSync as rmSync5 } from "node:fs";
|
|
49528
|
+
import { join as join19, dirname as dirname11, resolve as resolve4 } from "node:path";
|
|
49332
49529
|
function skipFilePath() {
|
|
49333
|
-
return
|
|
49530
|
+
return join19(resolve4(selfDir(), ".."), ".update-skip.json");
|
|
49334
49531
|
}
|
|
49335
49532
|
function fallbackSkipFilePath() {
|
|
49336
|
-
|
|
49337
|
-
return join17(base, ".config", "huaweicloud", "devkit-skip.json");
|
|
49533
|
+
return join19(devkitStateBase(), "devkit-skip.json");
|
|
49338
49534
|
}
|
|
49339
49535
|
function sanitizeSessionId(sessionId) {
|
|
49340
49536
|
return asText(sessionId || "").replace(/[^0-9a-zA-Z-]/g, "_");
|
|
@@ -49342,7 +49538,7 @@ function sanitizeSessionId(sessionId) {
|
|
|
49342
49538
|
function resolveSkipFilePath(sessionId = null) {
|
|
49343
49539
|
let base;
|
|
49344
49540
|
try {
|
|
49345
|
-
if (
|
|
49541
|
+
if (existsSync15(join19(dirname11(skipFilePath()), "package.json"))) {
|
|
49346
49542
|
base = skipFilePath();
|
|
49347
49543
|
} else {
|
|
49348
49544
|
base = fallbackSkipFilePath();
|
|
@@ -49355,7 +49551,7 @@ function resolveSkipFilePath(sessionId = null) {
|
|
|
49355
49551
|
return `${base}.${sanitizeSessionId(sessionId)}`;
|
|
49356
49552
|
}
|
|
49357
49553
|
function readSkipState(file2) {
|
|
49358
|
-
if (!
|
|
49554
|
+
if (!existsSync15(file2))
|
|
49359
49555
|
return null;
|
|
49360
49556
|
try {
|
|
49361
49557
|
const parsed = JSON.parse(readFileSync16(file2, "utf8"));
|
|
@@ -49380,13 +49576,13 @@ function writeSkipState(file2, dismissedVersion, { at = Date.now(), days = COOLD
|
|
|
49380
49576
|
dismissedAt: new Date(at).toISOString(),
|
|
49381
49577
|
expireAt: new Date(at + days * 24 * 60 * 60 * 1e3).toISOString()
|
|
49382
49578
|
};
|
|
49383
|
-
|
|
49579
|
+
mkdirSync9(dirname11(file2), { recursive: true });
|
|
49384
49580
|
const tmp = `${file2}.${process.pid}.${Date.now()}.tmp`;
|
|
49385
|
-
|
|
49581
|
+
writeFileSync9(tmp, JSON.stringify(state2, null, 2), "utf8");
|
|
49386
49582
|
try {
|
|
49387
49583
|
renameSync5(tmp, file2);
|
|
49388
49584
|
} catch (error62) {
|
|
49389
|
-
|
|
49585
|
+
rmSync5(tmp, { force: true });
|
|
49390
49586
|
throw error62;
|
|
49391
49587
|
}
|
|
49392
49588
|
return state2;
|
|
@@ -49396,6 +49592,7 @@ var init_update_skip = __esm({
|
|
|
49396
49592
|
"plugins/huaweicloud-core/dist.new/update-skip.js"() {
|
|
49397
49593
|
"use strict";
|
|
49398
49594
|
init_as_text();
|
|
49595
|
+
init_pack_state();
|
|
49399
49596
|
init_update_installed();
|
|
49400
49597
|
COOLDOWN_DAYS = 3;
|
|
49401
49598
|
}
|
|
@@ -49508,7 +49705,7 @@ function queryDistTags({ timeoutMs = 15e3, cwd } = {}) {
|
|
|
49508
49705
|
if (process.env.HUAWEICLOUD_NPM_REGISTRY) {
|
|
49509
49706
|
return queryDistTagsFetch({ timeoutMs });
|
|
49510
49707
|
}
|
|
49511
|
-
return new Promise((
|
|
49708
|
+
return new Promise((resolve10) => {
|
|
49512
49709
|
let child;
|
|
49513
49710
|
try {
|
|
49514
49711
|
child = spawn(`${NPM_BIN} view huaweicloud-devkit dist-tags --json`, {
|
|
@@ -49518,7 +49715,7 @@ function queryDistTags({ timeoutMs = 15e3, cwd } = {}) {
|
|
|
49518
49715
|
});
|
|
49519
49716
|
} catch (error62) {
|
|
49520
49717
|
debugLog2(`queryDistTags: ${errorMessage(error62) || String(error62)}`);
|
|
49521
|
-
|
|
49718
|
+
resolve10(null);
|
|
49522
49719
|
return;
|
|
49523
49720
|
}
|
|
49524
49721
|
const timer = setTimeout(() => {
|
|
@@ -49527,7 +49724,7 @@ function queryDistTags({ timeoutMs = 15e3, cwd } = {}) {
|
|
|
49527
49724
|
} catch {
|
|
49528
49725
|
}
|
|
49529
49726
|
debugLog2(`queryDistTags: timed out after ${timeoutMs}ms`);
|
|
49530
|
-
|
|
49727
|
+
resolve10(null);
|
|
49531
49728
|
}, timeoutMs);
|
|
49532
49729
|
let stdout = "";
|
|
49533
49730
|
child.stdout.on("data", (d) => {
|
|
@@ -49536,15 +49733,15 @@ function queryDistTags({ timeoutMs = 15e3, cwd } = {}) {
|
|
|
49536
49733
|
child.on("error", (error62) => {
|
|
49537
49734
|
clearTimeout(timer);
|
|
49538
49735
|
debugLog2(`queryDistTags: ${errorMessage(error62) || String(error62)}`);
|
|
49539
|
-
|
|
49736
|
+
resolve10(null);
|
|
49540
49737
|
});
|
|
49541
49738
|
child.on("close", (code) => {
|
|
49542
49739
|
clearTimeout(timer);
|
|
49543
49740
|
if (code === 0) {
|
|
49544
|
-
|
|
49741
|
+
resolve10(parseDistTagsOutput(stdout));
|
|
49545
49742
|
} else {
|
|
49546
49743
|
debugLog2(`queryDistTags: npm view exited with code ${code}`);
|
|
49547
|
-
|
|
49744
|
+
resolve10(null);
|
|
49548
49745
|
}
|
|
49549
49746
|
});
|
|
49550
49747
|
});
|
|
@@ -49641,17 +49838,17 @@ var init_update_cache = __esm({
|
|
|
49641
49838
|
|
|
49642
49839
|
// plugins/huaweicloud-core/dist.new/lib/dep-resolve.js
|
|
49643
49840
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
49644
|
-
import { existsSync as
|
|
49645
|
-
import { homedir as
|
|
49646
|
-
import { basename as
|
|
49841
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
49842
|
+
import { homedir as homedir14 } from "node:os";
|
|
49843
|
+
import { basename as basename3, join as join20 } from "node:path";
|
|
49647
49844
|
function platformHome(env) {
|
|
49648
|
-
return process.platform === "win32" ? env.USERPROFILE ||
|
|
49845
|
+
return process.platform === "win32" ? env.USERPROFILE || homedir14() : env.HOME || homedir14();
|
|
49649
49846
|
}
|
|
49650
49847
|
function pathLookupName(resolution) {
|
|
49651
49848
|
const candidates = process.platform === "win32" ? resolution.candidates.win32 : resolution.candidates.unix;
|
|
49652
49849
|
if (candidates.length === 0)
|
|
49653
49850
|
return null;
|
|
49654
|
-
const raw =
|
|
49851
|
+
const raw = basename3(candidates[0]);
|
|
49655
49852
|
return process.platform === "win32" && raw.endsWith(".exe") ? raw.slice(0, -4) : raw;
|
|
49656
49853
|
}
|
|
49657
49854
|
function lookupOnPath(name, env) {
|
|
@@ -49661,13 +49858,13 @@ function lookupOnPath(name, env) {
|
|
|
49661
49858
|
}
|
|
49662
49859
|
function resolveDependencyCommand(resolution, env = process.env) {
|
|
49663
49860
|
const envBin = env[resolution.envBin];
|
|
49664
|
-
if (envBin &&
|
|
49861
|
+
if (envBin && existsSync16(envBin))
|
|
49665
49862
|
return { command: envBin, argsPrefix: [], tier: "env" };
|
|
49666
49863
|
const home = platformHome(env);
|
|
49667
49864
|
const candidates = process.platform === "win32" ? resolution.candidates.win32 : resolution.candidates.unix;
|
|
49668
49865
|
for (const candidate of candidates) {
|
|
49669
|
-
const expanded = candidate.startsWith("~") ?
|
|
49670
|
-
if (
|
|
49866
|
+
const expanded = candidate.startsWith("~") ? join20(home, candidate.slice(1)) : candidate;
|
|
49867
|
+
if (existsSync16(expanded))
|
|
49671
49868
|
return { command: expanded, argsPrefix: [], tier: "candidate" };
|
|
49672
49869
|
}
|
|
49673
49870
|
const name = pathLookupName(resolution);
|
|
@@ -49676,8 +49873,8 @@ function resolveDependencyCommand(resolution, env = process.env) {
|
|
|
49676
49873
|
return { command: onPath, argsPrefix: [], tier: "path" };
|
|
49677
49874
|
if (resolution.fallback) {
|
|
49678
49875
|
const exeSuffix = process.platform === "win32" ? ".exe" : "";
|
|
49679
|
-
const localCandidate =
|
|
49680
|
-
const fallbackCommand =
|
|
49876
|
+
const localCandidate = join20(home, ".local", "bin", `${resolution.fallback.command}${exeSuffix}`);
|
|
49877
|
+
const fallbackCommand = existsSync16(localCandidate) ? localCandidate : lookupOnPath(resolution.fallback.command, env);
|
|
49681
49878
|
if (fallbackCommand) {
|
|
49682
49879
|
return { command: fallbackCommand, argsPrefix: resolution.fallback.argsPrefix, tier: "fallback" };
|
|
49683
49880
|
}
|
|
@@ -49693,10 +49890,10 @@ var init_dep_resolve = __esm({
|
|
|
49693
49890
|
// plugins/huaweicloud-core/dist.new/codex-probe.js
|
|
49694
49891
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
49695
49892
|
import { readFileSync as readFileSync17 } from "node:fs";
|
|
49696
|
-
import { dirname as
|
|
49893
|
+
import { dirname as dirname12, join as join21, resolve as resolve5 } from "node:path";
|
|
49697
49894
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
49698
49895
|
function getCodexPluginName() {
|
|
49699
|
-
const marketplacePath =
|
|
49896
|
+
const marketplacePath = join21(PACKAGE_ROOT, ".agents", "plugins", "marketplace.json");
|
|
49700
49897
|
try {
|
|
49701
49898
|
const marketplace = asRecord(JSON.parse(readFileSync17(marketplacePath, "utf8")));
|
|
49702
49899
|
const plugins = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
|
|
@@ -49705,7 +49902,7 @@ function getCodexPluginName() {
|
|
|
49705
49902
|
return pluginName;
|
|
49706
49903
|
} catch {
|
|
49707
49904
|
}
|
|
49708
|
-
const codexManifestPath =
|
|
49905
|
+
const codexManifestPath = join21(PLUGIN_ROOT, ".codex-plugin", "plugin.json");
|
|
49709
49906
|
try {
|
|
49710
49907
|
const manifest = asRecord(JSON.parse(readFileSync17(codexManifestPath, "utf8")));
|
|
49711
49908
|
if (typeof manifest.name === "string" && manifest.name)
|
|
@@ -49748,15 +49945,15 @@ var init_codex_probe = __esm({
|
|
|
49748
49945
|
"use strict";
|
|
49749
49946
|
init_dep_resolve();
|
|
49750
49947
|
init_as_record();
|
|
49751
|
-
__dirname3 =
|
|
49752
|
-
PLUGIN_ROOT =
|
|
49753
|
-
PACKAGE_ROOT =
|
|
49948
|
+
__dirname3 = dirname12(fileURLToPath5(import.meta.url));
|
|
49949
|
+
PLUGIN_ROOT = resolve5(__dirname3, "..");
|
|
49950
|
+
PACKAGE_ROOT = resolve5(PLUGIN_ROOT, "..", "..");
|
|
49754
49951
|
}
|
|
49755
49952
|
});
|
|
49756
49953
|
|
|
49757
49954
|
// plugins/huaweicloud-core/dist.new/officeace-paths.js
|
|
49758
|
-
import { join as
|
|
49759
|
-
import { homedir as
|
|
49955
|
+
import { join as join22, resolve as resolve6, dirname as dirname13 } from "node:path";
|
|
49956
|
+
import { homedir as homedir15, platform } from "node:os";
|
|
49760
49957
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
49761
49958
|
function readOfficeaceRegistryInstallDir() {
|
|
49762
49959
|
if (platform() !== "win32")
|
|
@@ -49779,18 +49976,18 @@ function readOfficeaceRegistryInstallDir() {
|
|
|
49779
49976
|
function probeOfficeaceSystemDirs(rootUsable) {
|
|
49780
49977
|
const regDir = readOfficeaceRegistryInstallDir();
|
|
49781
49978
|
if (regDir) {
|
|
49782
|
-
const dir =
|
|
49979
|
+
const dir = join22(regDir, ".office-claw");
|
|
49783
49980
|
if (rootUsable(dir))
|
|
49784
49981
|
return dir;
|
|
49785
49982
|
}
|
|
49786
49983
|
if (platform() === "win32") {
|
|
49787
49984
|
const bases = [process.env.ProgramFiles, "C:\\Program Files", "D:\\Program Files"];
|
|
49788
49985
|
if (process.env.LOCALAPPDATA)
|
|
49789
|
-
bases.push(
|
|
49986
|
+
bases.push(join22(process.env.LOCALAPPDATA, "Programs"));
|
|
49790
49987
|
for (const base of bases) {
|
|
49791
49988
|
if (!base)
|
|
49792
49989
|
continue;
|
|
49793
|
-
const dir =
|
|
49990
|
+
const dir = join22(base, "OfficeAce", ".office-claw");
|
|
49794
49991
|
if (rootUsable(dir))
|
|
49795
49992
|
return dir;
|
|
49796
49993
|
}
|
|
@@ -49804,22 +50001,22 @@ var init_officeace_paths = __esm({
|
|
|
49804
50001
|
});
|
|
49805
50002
|
|
|
49806
50003
|
// plugins/huaweicloud-core/dist.new/auth/agent-registration.js
|
|
49807
|
-
import { existsSync as
|
|
49808
|
-
import { isAbsolute, join as
|
|
49809
|
-
import { homedir as
|
|
50004
|
+
import { existsSync as existsSync17, readFileSync as readFileSync18 } from "node:fs";
|
|
50005
|
+
import { isAbsolute as isAbsolute2, join as join23, resolve as resolve7 } from "node:path";
|
|
50006
|
+
import { homedir as homedir16 } from "node:os";
|
|
49810
50007
|
import { createRequire } from "node:module";
|
|
49811
50008
|
function xdgConfigHome() {
|
|
49812
50009
|
const xdg = process.env.XDG_CONFIG_HOME;
|
|
49813
|
-
return xdg &&
|
|
50010
|
+
return xdg && isAbsolute2(xdg) ? xdg : join23(homedir16(), ".config");
|
|
49814
50011
|
}
|
|
49815
50012
|
function opencodeConfigFile() {
|
|
49816
|
-
const jsonc =
|
|
49817
|
-
if (
|
|
50013
|
+
const jsonc = join23(xdgConfigHome(), "opencode", "opencode.jsonc");
|
|
50014
|
+
if (existsSync17(jsonc))
|
|
49818
50015
|
return jsonc;
|
|
49819
|
-
return
|
|
50016
|
+
return join23(xdgConfigHome(), "opencode", "opencode.json");
|
|
49820
50017
|
}
|
|
49821
50018
|
function readJsonSafe(path) {
|
|
49822
|
-
if (!
|
|
50019
|
+
if (!existsSync17(path))
|
|
49823
50020
|
return null;
|
|
49824
50021
|
try {
|
|
49825
50022
|
return JSON.parse(readFileSync18(path, "utf8"));
|
|
@@ -49833,10 +50030,10 @@ function opencodeRegistered() {
|
|
|
49833
50030
|
return Boolean(asRecord(cfg.mcp)["huaweicloud-devkit"]);
|
|
49834
50031
|
}
|
|
49835
50032
|
function codexDesktopRegistered() {
|
|
49836
|
-
if (
|
|
50033
|
+
if (existsSync17(join23(homedir16(), "plugins", "huaweicloud-devkit", "dist", "mcp-server.js")))
|
|
49837
50034
|
return true;
|
|
49838
|
-
const legacyPath =
|
|
49839
|
-
if (!
|
|
50035
|
+
const legacyPath = join23(homedir16(), ".codex", "config.toml");
|
|
50036
|
+
if (!existsSync17(legacyPath))
|
|
49840
50037
|
return false;
|
|
49841
50038
|
try {
|
|
49842
50039
|
return readFileSync18(legacyPath, "utf8").includes("[mcp_servers.huaweicloud-devkit]");
|
|
@@ -49850,8 +50047,8 @@ function codexCliRegistered() {
|
|
|
49850
50047
|
}
|
|
49851
50048
|
function codeartsRegistered() {
|
|
49852
50049
|
const paths2 = [
|
|
49853
|
-
|
|
49854
|
-
|
|
50050
|
+
join23(homedir16(), ".codeartsdoer", "mcp", "mcp_settings.json"),
|
|
50051
|
+
join23(process.cwd(), ".codeartsdoer", "mcp", "mcp_settings.json")
|
|
49855
50052
|
];
|
|
49856
50053
|
return paths2.some((path) => {
|
|
49857
50054
|
const cfg = asRecord(readJsonSafe(path));
|
|
@@ -49859,20 +50056,20 @@ function codeartsRegistered() {
|
|
|
49859
50056
|
});
|
|
49860
50057
|
}
|
|
49861
50058
|
function codeartsWorkRegistered() {
|
|
49862
|
-
const path =
|
|
50059
|
+
const path = join23(homedir16(), ".codeartswork", "mcp", "mcp_settings.json");
|
|
49863
50060
|
const cfg = asRecord(readJsonSafe(path));
|
|
49864
50061
|
return Boolean(asRecord(cfg.mcp)["huaweicloud-devkit"]);
|
|
49865
50062
|
}
|
|
49866
50063
|
function workbuddyRegistered() {
|
|
49867
|
-
const cfg = asRecord(readJsonSafe(
|
|
50064
|
+
const cfg = asRecord(readJsonSafe(join23(homedir16(), ".workbuddy", "mcp.json")));
|
|
49868
50065
|
return Boolean(asRecord(cfg.mcpServers)["huaweicloud-devkit"]);
|
|
49869
50066
|
}
|
|
49870
50067
|
function dshRoot() {
|
|
49871
|
-
return process.env.DSH_HOME ||
|
|
50068
|
+
return process.env.DSH_HOME || join23(homedir16(), ".dsh");
|
|
49872
50069
|
}
|
|
49873
50070
|
function dshRegistered() {
|
|
49874
|
-
const patchPath =
|
|
49875
|
-
if (!
|
|
50071
|
+
const patchPath = join23(dshRoot(), "profiles", "web", "cordis.patch.yml");
|
|
50072
|
+
if (!existsSync17(patchPath))
|
|
49876
50073
|
return false;
|
|
49877
50074
|
try {
|
|
49878
50075
|
const patch = readFileSync18(patchPath, "utf8");
|
|
@@ -49883,16 +50080,16 @@ function dshRegistered() {
|
|
|
49883
50080
|
}
|
|
49884
50081
|
function officeaceCapabilitiesDir() {
|
|
49885
50082
|
const configRoot = process.env.OFFICE_CLAW_CONFIG_ROOT;
|
|
49886
|
-
if (configRoot &&
|
|
50083
|
+
if (configRoot && existsSync17(join23(configRoot, "capabilities.json")))
|
|
49887
50084
|
return configRoot;
|
|
49888
|
-
return probeOfficeaceSystemDirs((dir) =>
|
|
50085
|
+
return probeOfficeaceSystemDirs((dir) => existsSync17(join23(dir, "capabilities.json")));
|
|
49889
50086
|
}
|
|
49890
50087
|
function officeaceCapabilitiesDirSafe() {
|
|
49891
|
-
return officeaceCapabilitiesDir() ||
|
|
50088
|
+
return officeaceCapabilitiesDir() || join23(homedir16(), ".office-claw");
|
|
49892
50089
|
}
|
|
49893
50090
|
function officeaceSqlitePath() {
|
|
49894
50091
|
const capDir = officeaceCapabilitiesDirSafe();
|
|
49895
|
-
return
|
|
50092
|
+
return join23(resolve7(capDir, ".."), "data", "mcp-connectors.sqlite");
|
|
49896
50093
|
}
|
|
49897
50094
|
function toSqliteModule(value) {
|
|
49898
50095
|
if (!value || typeof value !== "object")
|
|
@@ -49903,7 +50100,7 @@ function toSqliteModule(value) {
|
|
|
49903
50100
|
function officeaceRegistered() {
|
|
49904
50101
|
let hasMcp = false;
|
|
49905
50102
|
const dbPath = officeaceSqlitePath();
|
|
49906
|
-
if (
|
|
50103
|
+
if (existsSync17(dbPath)) {
|
|
49907
50104
|
const nodeMajor = Number(process.versions.node.split(".")[0]);
|
|
49908
50105
|
if (nodeMajor >= 22) {
|
|
49909
50106
|
try {
|
|
@@ -49918,7 +50115,7 @@ function officeaceRegistered() {
|
|
|
49918
50115
|
}
|
|
49919
50116
|
}
|
|
49920
50117
|
}
|
|
49921
|
-
const capFile =
|
|
50118
|
+
const capFile = join23(officeaceCapabilitiesDirSafe(), "capabilities.json");
|
|
49922
50119
|
const cfg = asRecord(readJsonSafe(capFile));
|
|
49923
50120
|
const capabilities = Array.isArray(cfg.capabilities) ? cfg.capabilities : [];
|
|
49924
50121
|
const hasSkills = capabilities.some((c) => {
|
|
@@ -49928,10 +50125,10 @@ function officeaceRegistered() {
|
|
|
49928
50125
|
return hasMcp || hasSkills;
|
|
49929
50126
|
}
|
|
49930
50127
|
function atomcodeHome() {
|
|
49931
|
-
return process.env.ATOMCODE_HOME ||
|
|
50128
|
+
return process.env.ATOMCODE_HOME || join23(homedir16(), ".atomcode");
|
|
49932
50129
|
}
|
|
49933
50130
|
function atomcodeRegistered() {
|
|
49934
|
-
const cfg = asRecord(readJsonSafe(
|
|
50131
|
+
const cfg = asRecord(readJsonSafe(join23(atomcodeHome(), "mcp.json")));
|
|
49935
50132
|
return Boolean(asRecord(cfg.mcpServers)["huaweicloud-devkit"]);
|
|
49936
50133
|
}
|
|
49937
50134
|
function openclawMcpConfigured(cfg) {
|
|
@@ -49945,20 +50142,20 @@ function openclawMcpConfigured(cfg) {
|
|
|
49945
50142
|
return false;
|
|
49946
50143
|
}
|
|
49947
50144
|
function openclawRegistered() {
|
|
49948
|
-
const pluginCfg = readJsonSafe(
|
|
50145
|
+
const pluginCfg = readJsonSafe(join23(homedir16(), ".agents", "huaweicloud-plugins", ".mcp.json"));
|
|
49949
50146
|
if (openclawMcpConfigured(pluginCfg))
|
|
49950
50147
|
return true;
|
|
49951
|
-
const nativeCfg = readJsonSafe(
|
|
50148
|
+
const nativeCfg = readJsonSafe(join23(homedir16(), ".openclaw", "openclaw.json"));
|
|
49952
50149
|
return openclawMcpConfigured(nativeCfg);
|
|
49953
50150
|
}
|
|
49954
50151
|
function hermesHome() {
|
|
49955
50152
|
if (process.env.HERMES_HOME)
|
|
49956
50153
|
return process.env.HERMES_HOME;
|
|
49957
|
-
return
|
|
50154
|
+
return join23(homedir16(), ".hermes");
|
|
49958
50155
|
}
|
|
49959
50156
|
function hermesRegistered() {
|
|
49960
|
-
const configPath =
|
|
49961
|
-
if (!
|
|
50157
|
+
const configPath = join23(hermesHome(), "config.yaml");
|
|
50158
|
+
if (!existsSync17(configPath))
|
|
49962
50159
|
return false;
|
|
49963
50160
|
try {
|
|
49964
50161
|
const content = readFileSync18(configPath, "utf8");
|
|
@@ -50398,18 +50595,18 @@ var init_sandbox_output = __esm({
|
|
|
50398
50595
|
});
|
|
50399
50596
|
|
|
50400
50597
|
// plugins/huaweicloud-core/dist.new/sandbox/ws-exec-loader.js
|
|
50401
|
-
import { existsSync as
|
|
50402
|
-
import { dirname as
|
|
50598
|
+
import { existsSync as existsSync18 } from "node:fs";
|
|
50599
|
+
import { dirname as dirname14, join as join24 } from "node:path";
|
|
50403
50600
|
import { fileURLToPath as fileURLToPath6, pathToFileURL } from "node:url";
|
|
50404
50601
|
function firstExisting(...candidates) {
|
|
50405
50602
|
for (const candidate of candidates) {
|
|
50406
|
-
if (
|
|
50603
|
+
if (existsSync18(candidate))
|
|
50407
50604
|
return candidate;
|
|
50408
50605
|
}
|
|
50409
50606
|
return candidates[candidates.length - 1];
|
|
50410
50607
|
}
|
|
50411
50608
|
function resolveWsExecIndexUrl() {
|
|
50412
|
-
const barrel = firstExisting(
|
|
50609
|
+
const barrel = firstExisting(join24(__dirname4, "..", "ws-exec", "index.js"), join24(__dirname4, "ws-exec", "index.js"), join24(__dirname4, "..", "ws-exec", "index.ts"));
|
|
50413
50610
|
return pathToFileURL(barrel).href;
|
|
50414
50611
|
}
|
|
50415
50612
|
async function loadWsExec() {
|
|
@@ -50427,7 +50624,7 @@ var init_ws_exec_loader = __esm({
|
|
|
50427
50624
|
}
|
|
50428
50625
|
return path;
|
|
50429
50626
|
};
|
|
50430
|
-
__dirname4 =
|
|
50627
|
+
__dirname4 = dirname14(fileURLToPath6(import.meta.url));
|
|
50431
50628
|
}
|
|
50432
50629
|
});
|
|
50433
50630
|
|
|
@@ -50550,7 +50747,7 @@ async function createConnection(envId, ak, sk, securitytoken, { maxRetries = 3,
|
|
|
50550
50747
|
const wait2 = backoff[Math.min(attempt - 2, backoff.length - 1)] ?? 1e3;
|
|
50551
50748
|
process.stderr.write(`createConnection: retryable error (${lastFailure.kind}) \u2014 retry ${attempt - 1}/${maxRetries} in ${wait2}ms
|
|
50552
50749
|
`);
|
|
50553
|
-
await new Promise((
|
|
50750
|
+
await new Promise((resolve10) => setTimeout(resolve10, wait2));
|
|
50554
50751
|
}
|
|
50555
50752
|
const { status, data } = await apiPost(`/open-api-public/v1/devenvs/${envId}/connections`, { source: "CLI" }, ak, sk, securitytoken);
|
|
50556
50753
|
const payload = asRecord(data);
|
|
@@ -50594,7 +50791,7 @@ async function waitForConnection(connectionId, envId, ak, sk, securitytoken) {
|
|
|
50594
50791
|
source: extensions.source
|
|
50595
50792
|
};
|
|
50596
50793
|
}
|
|
50597
|
-
await new Promise((
|
|
50794
|
+
await new Promise((resolve10) => setTimeout(resolve10, 1e3));
|
|
50598
50795
|
}
|
|
50599
50796
|
throw new Error(`Timed out waiting for connection ${connectionId}`);
|
|
50600
50797
|
}
|
|
@@ -50657,7 +50854,7 @@ async function getSession(workspaceId2, username2, timeoutMs) {
|
|
|
50657
50854
|
async function createTunnelSession(workspaceId2, username2, timeoutMs = 3e4) {
|
|
50658
50855
|
const { wsUrl, source, WebSocketImpl, wsExec } = await openHwlinkConnection(workspaceId2);
|
|
50659
50856
|
const mux = new wsExec.HwlinkWebSocketMultiplexer(wsUrl, source, { WebSocketImpl, protocol: "devenv" });
|
|
50660
|
-
await new Promise((
|
|
50857
|
+
await new Promise((resolve10, reject) => {
|
|
50661
50858
|
const timer = setTimeout(() => {
|
|
50662
50859
|
clearInterval(interval);
|
|
50663
50860
|
reject(new Error("tunnel session WebSocket open timeout"));
|
|
@@ -50666,7 +50863,7 @@ async function createTunnelSession(workspaceId2, username2, timeoutMs = 3e4) {
|
|
|
50666
50863
|
if (mux.readyState === 1) {
|
|
50667
50864
|
clearTimeout(timer);
|
|
50668
50865
|
clearInterval(interval);
|
|
50669
|
-
|
|
50866
|
+
resolve10();
|
|
50670
50867
|
} else if (mux.readyState === 3) {
|
|
50671
50868
|
clearTimeout(timer);
|
|
50672
50869
|
clearInterval(interval);
|
|
@@ -50729,9 +50926,9 @@ var init_hwlink_connection = __esm({
|
|
|
50729
50926
|
});
|
|
50730
50927
|
|
|
50731
50928
|
// plugins/huaweicloud-core/dist.new/sandbox/upload-file.js
|
|
50732
|
-
import { existsSync as
|
|
50733
|
-
import { dirname as
|
|
50734
|
-
import { tmpdir } from "node:os";
|
|
50929
|
+
import { existsSync as existsSync19, readFileSync as readFileSync19, statSync as statSync4 } from "node:fs";
|
|
50930
|
+
import { dirname as dirname15 } from "node:path";
|
|
50931
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
50735
50932
|
import { createHash as createHash3 } from "node:crypto";
|
|
50736
50933
|
function splitBase64Chunks(base643, chunkSize = UPLOAD_CHUNK_SIZE) {
|
|
50737
50934
|
const chunks = [];
|
|
@@ -50743,7 +50940,7 @@ function splitBase64Chunks(base643, chunkSize = UPLOAD_CHUNK_SIZE) {
|
|
|
50743
50940
|
function classifyLocalUploadPath(localPath, kind = "file") {
|
|
50744
50941
|
const expected = kind === "directory" ? "directory" : "regular file";
|
|
50745
50942
|
const prefix = kind === "directory" ? "sandbox upload project" : "sandbox upload";
|
|
50746
|
-
if (
|
|
50943
|
+
if (existsSync19(localPath)) {
|
|
50747
50944
|
const stat = statSync4(localPath);
|
|
50748
50945
|
const matches = kind === "directory" ? stat.isDirectory() : stat.isFile();
|
|
50749
50946
|
if (!matches) {
|
|
@@ -50751,9 +50948,9 @@ function classifyLocalUploadPath(localPath, kind = "file") {
|
|
|
50751
50948
|
}
|
|
50752
50949
|
return null;
|
|
50753
50950
|
}
|
|
50754
|
-
const parent =
|
|
50755
|
-
if (!
|
|
50756
|
-
return new Error(`${prefix}: directory not found: ${parent}. The DevKit MCP server reads files from the machine it runs on. Verify the path, or first copy the ${expected} to the local temp directory (${
|
|
50951
|
+
const parent = dirname15(localPath);
|
|
50952
|
+
if (!existsSync19(parent)) {
|
|
50953
|
+
return new Error(`${prefix}: directory not found: ${parent}. The DevKit MCP server reads files from the machine it runs on. Verify the path, or first copy the ${expected} to the local temp directory (${tmpdir2()}) and upload from there.`);
|
|
50757
50954
|
}
|
|
50758
50955
|
return new Error(`${prefix}: local ${expected} not found: ${localPath}`);
|
|
50759
50956
|
}
|
|
@@ -50835,9 +51032,9 @@ var init_upload_file = __esm({
|
|
|
50835
51032
|
});
|
|
50836
51033
|
|
|
50837
51034
|
// plugins/huaweicloud-core/dist.new/sandbox/upload-diagnostics.js
|
|
50838
|
-
import { appendFileSync as appendFileSync3, existsSync as
|
|
50839
|
-
import { join as
|
|
50840
|
-
import { tmpdir as
|
|
51035
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync20, statSync as statSync5, unlinkSync as unlinkSync3 } from "node:fs";
|
|
51036
|
+
import { join as join25 } from "node:path";
|
|
51037
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
50841
51038
|
function errorMessage2(error62) {
|
|
50842
51039
|
if (error62 instanceof Error && error62.message)
|
|
50843
51040
|
return error62.message;
|
|
@@ -50860,7 +51057,7 @@ function uploadLog(message) {
|
|
|
50860
51057
|
}
|
|
50861
51058
|
function rotateUploadLog(maxBytes = 100 * 1024) {
|
|
50862
51059
|
try {
|
|
50863
|
-
if (
|
|
51060
|
+
if (existsSync20(UPLOAD_LOG_PATH)) {
|
|
50864
51061
|
const stat = statSync5(UPLOAD_LOG_PATH);
|
|
50865
51062
|
if (stat.size > maxBytes) {
|
|
50866
51063
|
unlinkSync3(UPLOAD_LOG_PATH);
|
|
@@ -50873,7 +51070,7 @@ var UPLOAD_LOG_PATH;
|
|
|
50873
51070
|
var init_upload_diagnostics = __esm({
|
|
50874
51071
|
"plugins/huaweicloud-core/dist.new/sandbox/upload-diagnostics.js"() {
|
|
50875
51072
|
"use strict";
|
|
50876
|
-
UPLOAD_LOG_PATH =
|
|
51073
|
+
UPLOAD_LOG_PATH = join25(tmpdir3(), "sandbox-upload.log");
|
|
50877
51074
|
}
|
|
50878
51075
|
});
|
|
50879
51076
|
|
|
@@ -50893,7 +51090,7 @@ async function uploadViaTunnel(localPort, archivePath, archiveSize, archiveRemot
|
|
|
50893
51090
|
"",
|
|
50894
51091
|
""
|
|
50895
51092
|
].join("\r\n");
|
|
50896
|
-
return new Promise((
|
|
51093
|
+
return new Promise((resolve10, reject) => {
|
|
50897
51094
|
let settled = false;
|
|
50898
51095
|
const done = (fn) => {
|
|
50899
51096
|
if (!settled) {
|
|
@@ -50920,7 +51117,7 @@ async function uploadViaTunnel(localPort, archivePath, archiveSize, archiveRemot
|
|
|
50920
51117
|
return;
|
|
50921
51118
|
}
|
|
50922
51119
|
try {
|
|
50923
|
-
|
|
51120
|
+
resolve10(asRecord(JSON.parse(body)));
|
|
50924
51121
|
} catch {
|
|
50925
51122
|
reject(new Error(`invalid JSON response: ${body.slice(0, 200)}`));
|
|
50926
51123
|
}
|
|
@@ -50966,13 +51163,13 @@ async function waitForServerReady(localPort) {
|
|
|
50966
51163
|
for (let i = 0; i < SERVER_HEALTH_MAX_RETRIES; i++) {
|
|
50967
51164
|
try {
|
|
50968
51165
|
uploadLog(`waitForServerReady: attempt ${i + 1}, checking http://localhost:${localPort}/health`);
|
|
50969
|
-
const ok = await new Promise((
|
|
51166
|
+
const ok = await new Promise((resolve10) => {
|
|
50970
51167
|
let settled = false;
|
|
50971
51168
|
const done = (val) => {
|
|
50972
51169
|
if (!settled) {
|
|
50973
51170
|
settled = true;
|
|
50974
51171
|
sock.destroy();
|
|
50975
|
-
|
|
51172
|
+
resolve10(val);
|
|
50976
51173
|
}
|
|
50977
51174
|
};
|
|
50978
51175
|
const sock = netConnect({ host: "127.0.0.1", port: localPort }, () => {
|
|
@@ -51014,7 +51211,7 @@ var init_tunnel_http = __esm({
|
|
|
51014
51211
|
// plugins/huaweicloud-core/dist.new/sandbox/upload-transport.js
|
|
51015
51212
|
import { readFileSync as readFileSync21, statSync as statSync6 } from "node:fs";
|
|
51016
51213
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
51017
|
-
import { dirname as
|
|
51214
|
+
import { dirname as dirname16, join as join26 } from "node:path";
|
|
51018
51215
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
51019
51216
|
function generateUploadToken() {
|
|
51020
51217
|
return randomBytes3(16).toString("hex");
|
|
@@ -51089,8 +51286,8 @@ var init_upload_transport = __esm({
|
|
|
51089
51286
|
init_ws_exec_loader();
|
|
51090
51287
|
init_upload_diagnostics();
|
|
51091
51288
|
init_tunnel_http();
|
|
51092
|
-
__dirname5 =
|
|
51093
|
-
SANDBOX_FILE_SERVER_SCRIPT = readFileSync21(firstExisting(
|
|
51289
|
+
__dirname5 = dirname16(fileURLToPath7(import.meta.url));
|
|
51290
|
+
SANDBOX_FILE_SERVER_SCRIPT = readFileSync21(firstExisting(join26(__dirname5, "sandbox-file-server.py"), join26(__dirname5, "sandbox", "sandbox-file-server.py")), "utf8");
|
|
51094
51291
|
TUNNEL_READY_TIMEOUT_MS = 3e4;
|
|
51095
51292
|
}
|
|
51096
51293
|
});
|
|
@@ -51098,10 +51295,10 @@ var init_upload_transport = __esm({
|
|
|
51098
51295
|
// plugins/huaweicloud-core/dist.new/sandbox/upload-project.js
|
|
51099
51296
|
import { execFile } from "node:child_process";
|
|
51100
51297
|
import { promisify } from "node:util";
|
|
51101
|
-
import { existsSync as
|
|
51298
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync10, rmSync as rmSync6, statSync as statSync7, createReadStream } from "node:fs";
|
|
51102
51299
|
import { createHash as createHash4 } from "node:crypto";
|
|
51103
|
-
import { basename as
|
|
51104
|
-
import { tmpdir as
|
|
51300
|
+
import { basename as basename4, dirname as dirname17, join as join27 } from "node:path";
|
|
51301
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
51105
51302
|
function errorLabel(error62) {
|
|
51106
51303
|
if (error62 && typeof error62 === "object" && !Array.isArray(error62)) {
|
|
51107
51304
|
const record2 = error62;
|
|
@@ -51115,18 +51312,18 @@ function errorLabel(error62) {
|
|
|
51115
51312
|
return "unknown";
|
|
51116
51313
|
}
|
|
51117
51314
|
async function createTarGz(localDir, exclude = []) {
|
|
51118
|
-
const archiveName = `${
|
|
51119
|
-
const archiveDir =
|
|
51120
|
-
|
|
51121
|
-
const archivePath =
|
|
51122
|
-
const hasGit =
|
|
51315
|
+
const archiveName = `${basename4(localDir)}.tar.gz`;
|
|
51316
|
+
const archiveDir = join27(tmpdir4(), `sandbox-upload-${Date.now()}`);
|
|
51317
|
+
mkdirSync10(archiveDir, { recursive: true });
|
|
51318
|
+
const archivePath = join27(archiveDir, archiveName);
|
|
51319
|
+
const hasGit = existsSync21(join27(localDir, ".git"));
|
|
51123
51320
|
if (hasGit) {
|
|
51124
51321
|
await execFileAsync("git", [
|
|
51125
51322
|
"-C",
|
|
51126
51323
|
localDir,
|
|
51127
51324
|
"archive",
|
|
51128
51325
|
"--format=tar.gz",
|
|
51129
|
-
`--prefix=${
|
|
51326
|
+
`--prefix=${basename4(localDir)}/`,
|
|
51130
51327
|
`--output=${archivePath}`,
|
|
51131
51328
|
"HEAD"
|
|
51132
51329
|
]);
|
|
@@ -51143,20 +51340,20 @@ async function createTarGz(localDir, exclude = []) {
|
|
|
51143
51340
|
args.push("--exclude", pattern);
|
|
51144
51341
|
}
|
|
51145
51342
|
}
|
|
51146
|
-
args.push("-czf", archivePath, "-C",
|
|
51343
|
+
args.push("-czf", archivePath, "-C", dirname17(localDir), basename4(localDir));
|
|
51147
51344
|
await execFileAsync("tar", args);
|
|
51148
51345
|
}
|
|
51149
51346
|
return archivePath;
|
|
51150
51347
|
}
|
|
51151
51348
|
async function computeMd5(filePath) {
|
|
51152
|
-
return new Promise((
|
|
51349
|
+
return new Promise((resolve10, reject) => {
|
|
51153
51350
|
const hash2 = createHash4("md5");
|
|
51154
|
-
createReadStream(filePath).on("data", (chunk) => hash2.update(chunk)).on("end", () =>
|
|
51351
|
+
createReadStream(filePath).on("data", (chunk) => hash2.update(chunk)).on("end", () => resolve10(hash2.digest("hex"))).on("error", reject);
|
|
51155
51352
|
});
|
|
51156
51353
|
}
|
|
51157
51354
|
function cleanupLocalArchive(archivePath) {
|
|
51158
51355
|
try {
|
|
51159
|
-
|
|
51356
|
+
rmSync6(dirname17(archivePath), { recursive: true, force: true });
|
|
51160
51357
|
} catch {
|
|
51161
51358
|
}
|
|
51162
51359
|
}
|
|
@@ -51169,7 +51366,7 @@ async function uploadProjectWithSession(workspaceId2, localDir, remoteDir, usern
|
|
|
51169
51366
|
throw localError;
|
|
51170
51367
|
}
|
|
51171
51368
|
rotateUploadLog();
|
|
51172
|
-
const projectName =
|
|
51369
|
+
const projectName = basename4(localDir);
|
|
51173
51370
|
const targetParentDir = remoteDir || "/workspace";
|
|
51174
51371
|
const archiveRemotePath = `${targetParentDir}/${projectName}.tar.gz`;
|
|
51175
51372
|
const archivePath = await createTarGz(localDir, options.exclude);
|
|
@@ -51714,14 +51911,14 @@ var init_session_manager = __esm({
|
|
|
51714
51911
|
});
|
|
51715
51912
|
|
|
51716
51913
|
// plugins/huaweicloud-core/dist.new/lib/hdkit/sandbox-pool.js
|
|
51717
|
-
import { readFileSync as readFileSync22, writeFileSync as
|
|
51718
|
-
import { join as
|
|
51719
|
-
import { homedir as
|
|
51914
|
+
import { readFileSync as readFileSync22, writeFileSync as writeFileSync10, mkdirSync as mkdirSync11, renameSync as renameSync6 } from "node:fs";
|
|
51915
|
+
import { join as join28, dirname as dirname18 } from "node:path";
|
|
51916
|
+
import { homedir as homedir17 } from "node:os";
|
|
51720
51917
|
function isPoolType(value) {
|
|
51721
51918
|
return POOL_TYPES.has(value);
|
|
51722
51919
|
}
|
|
51723
51920
|
function cachePath() {
|
|
51724
|
-
return process.env.HW_SANDBOX_POOL_CACHE_PATH ||
|
|
51921
|
+
return process.env.HW_SANDBOX_POOL_CACHE_PATH || join28(homedir17(), ".config", "huaweicloud", "sandbox-pools.json");
|
|
51725
51922
|
}
|
|
51726
51923
|
function validatePoolType(raw) {
|
|
51727
51924
|
if (raw === void 0 || raw === null || raw === "")
|
|
@@ -51789,17 +51986,17 @@ function persistCache() {
|
|
|
51789
51986
|
try {
|
|
51790
51987
|
ensureCacheLoaded();
|
|
51791
51988
|
const file2 = cachePath();
|
|
51792
|
-
|
|
51989
|
+
mkdirSync11(dirname18(file2), { recursive: true, mode: 448 });
|
|
51793
51990
|
const workspaces = {};
|
|
51794
51991
|
for (const [wsId, entry] of workspacePool)
|
|
51795
51992
|
workspaces[wsId] = entry;
|
|
51796
51993
|
const payload = JSON.stringify({ workspaces }, null, 2);
|
|
51797
51994
|
const tmp = `${file2}.tmp`;
|
|
51798
|
-
|
|
51995
|
+
writeFileSync10(tmp, payload, { mode: 384 });
|
|
51799
51996
|
try {
|
|
51800
51997
|
renameSync6(tmp, file2);
|
|
51801
51998
|
} catch {
|
|
51802
|
-
|
|
51999
|
+
writeFileSync10(file2, payload, { mode: 384 });
|
|
51803
52000
|
}
|
|
51804
52001
|
} catch {
|
|
51805
52002
|
}
|
|
@@ -53176,9 +53373,9 @@ var init_hdkitservice_api = __esm({
|
|
|
53176
53373
|
});
|
|
53177
53374
|
|
|
53178
53375
|
// plugins/huaweicloud-core/dist.new/sandbox/devbridge-key.js
|
|
53179
|
-
import { readFileSync as readFileSync23, writeFileSync as
|
|
53180
|
-
import { join as
|
|
53181
|
-
import { homedir as
|
|
53376
|
+
import { readFileSync as readFileSync23, writeFileSync as writeFileSync11, mkdirSync as mkdirSync12, existsSync as existsSync22, chmodSync as chmodSync3 } from "node:fs";
|
|
53377
|
+
import { join as join29, dirname as dirname19 } from "node:path";
|
|
53378
|
+
import { homedir as homedir18 } from "node:os";
|
|
53182
53379
|
import { createHash as createHash5 } from "node:crypto";
|
|
53183
53380
|
function keyNameForPool(poolType) {
|
|
53184
53381
|
if (poolType === "ephemeral" || poolType === "persistent")
|
|
@@ -53197,12 +53394,12 @@ function readCache() {
|
|
|
53197
53394
|
}
|
|
53198
53395
|
}
|
|
53199
53396
|
function writeCache(cache2) {
|
|
53200
|
-
const dir =
|
|
53201
|
-
if (!
|
|
53202
|
-
|
|
53203
|
-
|
|
53397
|
+
const dir = dirname19(CACHE_FILE);
|
|
53398
|
+
if (!existsSync22(dir))
|
|
53399
|
+
mkdirSync12(dir, { recursive: true });
|
|
53400
|
+
writeFileSync11(CACHE_FILE, JSON.stringify(cache2, null, 2), { mode: 384 });
|
|
53204
53401
|
try {
|
|
53205
|
-
|
|
53402
|
+
chmodSync3(CACHE_FILE, 384);
|
|
53206
53403
|
} catch {
|
|
53207
53404
|
}
|
|
53208
53405
|
}
|
|
@@ -53300,7 +53497,7 @@ var init_devbridge_key = __esm({
|
|
|
53300
53497
|
persistent: "devkit-persistent"
|
|
53301
53498
|
};
|
|
53302
53499
|
DEFAULT_POOL = "ephemeral";
|
|
53303
|
-
CACHE_FILE =
|
|
53500
|
+
CACHE_FILE = join29(homedir18(), ".config", "huaweicloud", "devbridge-api-keys.json");
|
|
53304
53501
|
}
|
|
53305
53502
|
});
|
|
53306
53503
|
|
|
@@ -53364,9 +53561,9 @@ var init_handlers_tunnel = __esm({
|
|
|
53364
53561
|
|
|
53365
53562
|
// plugins/huaweicloud-core/dist.new/packs/sandbox/git-transfer.js
|
|
53366
53563
|
import { execFile as execFile2 } from "node:child_process";
|
|
53367
|
-
import { tmpdir as
|
|
53368
|
-
import { mkdirSync as
|
|
53369
|
-
import { basename as
|
|
53564
|
+
import { tmpdir as tmpdir5 } from "node:os";
|
|
53565
|
+
import { mkdirSync as mkdirSync13, rmSync as rmSync7 } from "node:fs";
|
|
53566
|
+
import { basename as basename5, dirname as dirname20, join as join30 } from "node:path";
|
|
53370
53567
|
import { promisify as promisify2 } from "node:util";
|
|
53371
53568
|
async function isGitAvailable() {
|
|
53372
53569
|
try {
|
|
@@ -53377,9 +53574,9 @@ async function isGitAvailable() {
|
|
|
53377
53574
|
}
|
|
53378
53575
|
}
|
|
53379
53576
|
async function gitCloneToLocal(repoUrl, branch, targetBasename) {
|
|
53380
|
-
const tempRoot =
|
|
53381
|
-
const cloneDir =
|
|
53382
|
-
|
|
53577
|
+
const tempRoot = join30(tmpdir5(), `hw-sandbox-git-${Date.now()}`);
|
|
53578
|
+
const cloneDir = join30(tempRoot, targetBasename);
|
|
53579
|
+
mkdirSync13(tempRoot, { recursive: true });
|
|
53383
53580
|
const args = ["clone", "--depth", "1"];
|
|
53384
53581
|
if (branch)
|
|
53385
53582
|
args.push("-b", branch);
|
|
@@ -53404,10 +53601,10 @@ async function transferGitRepo(args, devStageId, connectResult) {
|
|
|
53404
53601
|
if (hasGit) {
|
|
53405
53602
|
let tempRoot = null;
|
|
53406
53603
|
try {
|
|
53407
|
-
const targetName =
|
|
53604
|
+
const targetName = basename5(target_path);
|
|
53408
53605
|
const { cloneDir, tempRoot: root } = await gitCloneToLocal(repo_url, repo_branch, targetName);
|
|
53409
53606
|
tempRoot = root;
|
|
53410
|
-
await uploadProjectWithSession(devStageId, cloneDir,
|
|
53607
|
+
await uploadProjectWithSession(devStageId, cloneDir, dirname20(target_path), "root", 3e5, {
|
|
53411
53608
|
extract: true,
|
|
53412
53609
|
exclude: [".git", "node_modules"]
|
|
53413
53610
|
});
|
|
@@ -53417,7 +53614,7 @@ async function transferGitRepo(args, devStageId, connectResult) {
|
|
|
53417
53614
|
} finally {
|
|
53418
53615
|
if (tempRoot) {
|
|
53419
53616
|
try {
|
|
53420
|
-
|
|
53617
|
+
rmSync7(tempRoot, { recursive: true, force: true });
|
|
53421
53618
|
} catch {
|
|
53422
53619
|
}
|
|
53423
53620
|
}
|
|
@@ -53623,7 +53820,7 @@ var init_credential_validator = __esm({
|
|
|
53623
53820
|
|
|
53624
53821
|
// plugins/huaweicloud-core/dist.new/koocli-version.js
|
|
53625
53822
|
import { readFileSync as readFileSync24 } from "node:fs";
|
|
53626
|
-
import { resolve as
|
|
53823
|
+
import { resolve as resolve8, dirname as dirname21 } from "node:path";
|
|
53627
53824
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
53628
53825
|
function getKooCliVersion() {
|
|
53629
53826
|
try {
|
|
@@ -53677,24 +53874,24 @@ var init_koocli_version = __esm({
|
|
|
53677
53874
|
"plugins/huaweicloud-core/dist.new/koocli-version.js"() {
|
|
53678
53875
|
"use strict";
|
|
53679
53876
|
init_as_text();
|
|
53680
|
-
__dirname6 =
|
|
53681
|
-
PACKAGE_JSON =
|
|
53877
|
+
__dirname6 = dirname21(fileURLToPath8(import.meta.url));
|
|
53878
|
+
PACKAGE_JSON = resolve8(__dirname6, "..", "..", "..", "package.json");
|
|
53682
53879
|
VERSION_RE = /\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?/;
|
|
53683
53880
|
KOOCLI_UPDATE_BANNER_PREFIX = /^\s*(?:可执行|可以执行|请执行)?\s*hcloud\s+update\s+(?:更新至|update to)\s*\d[\w.-]*[\s。!!]*/;
|
|
53684
53881
|
}
|
|
53685
53882
|
});
|
|
53686
53883
|
|
|
53687
53884
|
// plugins/huaweicloud-core/dist.new/lib/koocli-paths.js
|
|
53688
|
-
import { homedir as
|
|
53689
|
-
import { join as
|
|
53885
|
+
import { homedir as homedir19 } from "node:os";
|
|
53886
|
+
import { join as join31 } from "node:path";
|
|
53690
53887
|
function configBase() {
|
|
53691
|
-
return process.env.HUAWEICLOUD_HOME ||
|
|
53888
|
+
return process.env.HUAWEICLOUD_HOME || homedir19();
|
|
53692
53889
|
}
|
|
53693
53890
|
function kooCliInstallLogPath() {
|
|
53694
|
-
return
|
|
53891
|
+
return join31(configBase(), ".config", "huaweicloud", "logs", "koocli-install.log");
|
|
53695
53892
|
}
|
|
53696
53893
|
function kooCliInstallLockPath() {
|
|
53697
|
-
return
|
|
53894
|
+
return join31(configBase(), ".config", "huaweicloud", ".koocli-install.lock");
|
|
53698
53895
|
}
|
|
53699
53896
|
var init_koocli_paths = __esm({
|
|
53700
53897
|
"plugins/huaweicloud-core/dist.new/lib/koocli-paths.js"() {
|
|
@@ -53847,15 +54044,15 @@ __export(reconcile_exports, {
|
|
|
53847
54044
|
scanState: () => scanState
|
|
53848
54045
|
});
|
|
53849
54046
|
import { createHash as createHash6 } from "node:crypto";
|
|
53850
|
-
import { existsSync as
|
|
53851
|
-
import { join as
|
|
53852
|
-
import { homedir as
|
|
54047
|
+
import { existsSync as existsSync23, readFileSync as readFileSync25, statSync as statSync8 } from "node:fs";
|
|
54048
|
+
import { join as join32 } from "node:path";
|
|
54049
|
+
import { homedir as homedir20 } from "node:os";
|
|
53853
54050
|
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
53854
54051
|
function toLastSync(value) {
|
|
53855
54052
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
53856
54053
|
}
|
|
53857
54054
|
function kooCliConfigPath() {
|
|
53858
|
-
return process.env.HCLOUD_CONFIG_PATH ||
|
|
54055
|
+
return process.env.HCLOUD_CONFIG_PATH || join32(homedir20(), ".hcloud", "config.json");
|
|
53859
54056
|
}
|
|
53860
54057
|
function fingerprint(ak, sk) {
|
|
53861
54058
|
if (!ak || !sk)
|
|
@@ -53863,7 +54060,7 @@ function fingerprint(ak, sk) {
|
|
|
53863
54060
|
return createHash6("sha256").update(`${asText(ak)}${asText(sk)}`).digest("hex").slice(0, 8);
|
|
53864
54061
|
}
|
|
53865
54062
|
function isManualModified(path) {
|
|
53866
|
-
if (!
|
|
54063
|
+
if (!existsSync23(path))
|
|
53867
54064
|
return false;
|
|
53868
54065
|
const lastSyncRaw = readLastSync();
|
|
53869
54066
|
try {
|
|
@@ -53877,7 +54074,7 @@ function isManualModified(path) {
|
|
|
53877
54074
|
}
|
|
53878
54075
|
function readKooCliProfiles() {
|
|
53879
54076
|
const configPath = kooCliConfigPath();
|
|
53880
|
-
if (!
|
|
54077
|
+
if (!existsSync23(configPath)) {
|
|
53881
54078
|
const e = errorFromTable("HDKIT_KOOCLI_NOT_READY", "KooCLI config not found");
|
|
53882
54079
|
return { error: e.messageZh, code: e.code, messageZh: e.messageZh, action: e.action, nextStep: e.nextStep };
|
|
53883
54080
|
}
|
|
@@ -53957,7 +54154,7 @@ function scanState() {
|
|
|
53957
54154
|
const s2SyncedByDevkit = s1Fingerprint ? s2CurrentMatchesLastDevkitSync(kooCli, s1, s1Fingerprint) : false;
|
|
53958
54155
|
const effectiveCurrentFp = s2SyncedByDevkit ? s1Fingerprint : currentFp;
|
|
53959
54156
|
const envFingerprint = fingerprint(envAk, envSk);
|
|
53960
|
-
const s3 =
|
|
54157
|
+
const s3 = existsSync23(obsConfigPath()) ? parseS3ObsConfig(obsConfigPath()) : null;
|
|
53961
54158
|
const s3Fingerprint = s3 ? fingerprint(s3.ak, s3.sk) : null;
|
|
53962
54159
|
let hasRuntime = false;
|
|
53963
54160
|
let runtimeFingerprint = null;
|
|
@@ -54068,11 +54265,11 @@ var init_reconcile = __esm({
|
|
|
54068
54265
|
});
|
|
54069
54266
|
|
|
54070
54267
|
// plugins/huaweicloud-core/dist.new/auth/project-id.js
|
|
54071
|
-
import { existsSync as
|
|
54268
|
+
import { existsSync as existsSync24 } from "node:fs";
|
|
54072
54269
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
54073
54270
|
function hcloudCommand(args) {
|
|
54074
54271
|
const { executable, argsPrefix } = resolveHcloudCommand();
|
|
54075
|
-
if (/\.(mjs|cjs|js)$/i.test(executable) &&
|
|
54272
|
+
if (/\.(mjs|cjs|js)$/i.test(executable) && existsSync24(executable)) {
|
|
54076
54273
|
return { file: process.execPath, args: [executable, ...argsPrefix, ...args] };
|
|
54077
54274
|
}
|
|
54078
54275
|
return { file: executable, args: [...argsPrefix, ...args] };
|
|
@@ -54142,8 +54339,8 @@ var init_project_id = __esm({
|
|
|
54142
54339
|
});
|
|
54143
54340
|
|
|
54144
54341
|
// plugins/huaweicloud-core/dist.new/lib/credentials.js
|
|
54145
|
-
import { readFileSync as readFileSync26, existsSync as
|
|
54146
|
-
import { join as
|
|
54342
|
+
import { readFileSync as readFileSync26, existsSync as existsSync25, rmSync as rmSync8 } from "node:fs";
|
|
54343
|
+
import { join as join33, dirname as dirname22 } from "node:path";
|
|
54147
54344
|
function asCredentialRecord(value) {
|
|
54148
54345
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
54149
54346
|
return null;
|
|
@@ -54160,9 +54357,9 @@ function asCredentialRecord(value) {
|
|
|
54160
54357
|
return result;
|
|
54161
54358
|
}
|
|
54162
54359
|
function readImportFile() {
|
|
54163
|
-
const path =
|
|
54360
|
+
const path = join33(dirname22(globalCredentialsPath()), "creds-import.json");
|
|
54164
54361
|
try {
|
|
54165
|
-
if (!
|
|
54362
|
+
if (!existsSync25(path))
|
|
54166
54363
|
return null;
|
|
54167
54364
|
const data = JSON.parse(readFileSync26(path, "utf8"));
|
|
54168
54365
|
const record2 = asRecord(data);
|
|
@@ -54174,16 +54371,16 @@ function readImportFile() {
|
|
|
54174
54371
|
};
|
|
54175
54372
|
} catch {
|
|
54176
54373
|
try {
|
|
54177
|
-
|
|
54374
|
+
rmSync8(path, { force: true });
|
|
54178
54375
|
} catch {
|
|
54179
54376
|
}
|
|
54180
54377
|
return null;
|
|
54181
54378
|
}
|
|
54182
54379
|
}
|
|
54183
54380
|
function clearImportFile() {
|
|
54184
|
-
const path =
|
|
54381
|
+
const path = join33(dirname22(globalCredentialsPath()), "creds-import.json");
|
|
54185
54382
|
try {
|
|
54186
|
-
|
|
54383
|
+
rmSync8(path, { force: true });
|
|
54187
54384
|
} catch {
|
|
54188
54385
|
}
|
|
54189
54386
|
}
|
|
@@ -54551,7 +54748,7 @@ var init_pack2 = __esm({
|
|
|
54551
54748
|
});
|
|
54552
54749
|
|
|
54553
54750
|
// plugins/huaweicloud-core/dist.new/auth/service.js
|
|
54554
|
-
import { existsSync as
|
|
54751
|
+
import { existsSync as existsSync26 } from "node:fs";
|
|
54555
54752
|
function asCredentialRecord2(value) {
|
|
54556
54753
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
54557
54754
|
return null;
|
|
@@ -54730,7 +54927,7 @@ function getAuthStatus(target = "all") {
|
|
|
54730
54927
|
mcpSettingsSource: s4Creds ? "codearts" : null,
|
|
54731
54928
|
stsExpiry,
|
|
54732
54929
|
credentialPanel,
|
|
54733
|
-
obsConfigured:
|
|
54930
|
+
obsConfigured: existsSync26(obsConfigPath()),
|
|
54734
54931
|
obsConfigPath: obsConfigPath(),
|
|
54735
54932
|
kooCliInstalled: hcloud.installed,
|
|
54736
54933
|
kooCliStatus: hcloud.status,
|
|
@@ -54864,109 +55061,12 @@ var init_service = __esm({
|
|
|
54864
55061
|
}
|
|
54865
55062
|
});
|
|
54866
55063
|
|
|
54867
|
-
// plugins/huaweicloud-core/dist.new/lib/pack-state.js
|
|
54868
|
-
import { chmodSync as chmodSync3, lstatSync, mkdirSync as mkdirSync12, realpathSync, writeFileSync as writeFileSync11 } from "node:fs";
|
|
54869
|
-
import { homedir as homedir22, tmpdir as tmpdir5 } from "node:os";
|
|
54870
|
-
import { basename as basename5, dirname as dirname21, join as join32, resolve as resolve7, sep } from "node:path";
|
|
54871
|
-
function huaweiConfigBase(env = process.env) {
|
|
54872
|
-
return resolve7(env.HUAWEICLOUD_HOME || homedir22(), ".config", "huaweicloud");
|
|
54873
|
-
}
|
|
54874
|
-
function packStateDir(packId, env = process.env) {
|
|
54875
|
-
return join32(huaweiConfigBase(env), "packs", packId);
|
|
54876
|
-
}
|
|
54877
|
-
function ensurePackState(packId, fileNames, env = process.env) {
|
|
54878
|
-
const dir = packStateDir(packId, env);
|
|
54879
|
-
try {
|
|
54880
|
-
mkdirSync12(dir, { recursive: true, mode: 448 });
|
|
54881
|
-
chmodSync3(dir, 448);
|
|
54882
|
-
} catch (error62) {
|
|
54883
|
-
throw new Error(`cannot provision pack state directory "${dir}": ${error62 instanceof Error ? error62.message : String(error62)}. Fix the permissions, or point HUAWEICLOUD_HOME at a writable location.`, { cause: error62 });
|
|
54884
|
-
}
|
|
54885
|
-
const files = {};
|
|
54886
|
-
for (const name of fileNames) {
|
|
54887
|
-
const path = join32(dir, name);
|
|
54888
|
-
try {
|
|
54889
|
-
try {
|
|
54890
|
-
writeFileSync11(path, "", { flag: "wx", mode: 384 });
|
|
54891
|
-
} catch (error62) {
|
|
54892
|
-
if (error62.code !== "EEXIST")
|
|
54893
|
-
throw error62;
|
|
54894
|
-
}
|
|
54895
|
-
chmodSync3(path, 384);
|
|
54896
|
-
files[name] = path;
|
|
54897
|
-
} catch (error62) {
|
|
54898
|
-
throw new Error(`cannot provision pack state file "${path}": ${error62 instanceof Error ? error62.message : String(error62)}.`, { cause: error62 });
|
|
54899
|
-
}
|
|
54900
|
-
}
|
|
54901
|
-
return { dir, files };
|
|
54902
|
-
}
|
|
54903
|
-
function isRefusedByGuard(target) {
|
|
54904
|
-
if (process.platform === "win32" && /^[a-zA-Z]:[^\\/]/.test(target))
|
|
54905
|
-
return true;
|
|
54906
|
-
return target.split(/[\\/]/).includes("..");
|
|
54907
|
-
}
|
|
54908
|
-
function resolveForWrite(target) {
|
|
54909
|
-
const absolute = resolve7(tmpdir5(), target);
|
|
54910
|
-
const tail = [];
|
|
54911
|
-
let current = absolute;
|
|
54912
|
-
for (; ; ) {
|
|
54913
|
-
try {
|
|
54914
|
-
lstatSync(current);
|
|
54915
|
-
break;
|
|
54916
|
-
} catch {
|
|
54917
|
-
tail.unshift(basename5(current));
|
|
54918
|
-
const parent = dirname21(current);
|
|
54919
|
-
if (parent === current)
|
|
54920
|
-
break;
|
|
54921
|
-
current = parent;
|
|
54922
|
-
}
|
|
54923
|
-
}
|
|
54924
|
-
try {
|
|
54925
|
-
const real = realpathSync(current);
|
|
54926
|
-
return tail.length === 0 ? real : join32(real, ...tail);
|
|
54927
|
-
} catch {
|
|
54928
|
-
return null;
|
|
54929
|
-
}
|
|
54930
|
-
}
|
|
54931
|
-
function protectedTreeRoots(env = process.env) {
|
|
54932
|
-
const candidates = [huaweiConfigBase(env)];
|
|
54933
|
-
for (const key of ["HUAWEICLOUD_MCP_POLICY_FILE", "HUAWEICLOUD_MCP_AUDIT_FILE"]) {
|
|
54934
|
-
const value = (env[key] ?? "").trim();
|
|
54935
|
-
if (value !== "")
|
|
54936
|
-
candidates.push(value);
|
|
54937
|
-
}
|
|
54938
|
-
const roots = [];
|
|
54939
|
-
for (const candidate of candidates) {
|
|
54940
|
-
const resolved = resolveForWrite(candidate);
|
|
54941
|
-
if (resolved === null)
|
|
54942
|
-
return null;
|
|
54943
|
-
roots.push(resolved);
|
|
54944
|
-
}
|
|
54945
|
-
return roots;
|
|
54946
|
-
}
|
|
54947
|
-
function isInsideProtectedTree(target, env = process.env) {
|
|
54948
|
-
if (isRefusedByGuard(target))
|
|
54949
|
-
return true;
|
|
54950
|
-
const roots = protectedTreeRoots(env);
|
|
54951
|
-
if (roots === null)
|
|
54952
|
-
return true;
|
|
54953
|
-
const resolved = resolveForWrite(target);
|
|
54954
|
-
if (resolved === null)
|
|
54955
|
-
return true;
|
|
54956
|
-
return roots.some((root) => resolved === root || resolved.startsWith(root + sep));
|
|
54957
|
-
}
|
|
54958
|
-
var init_pack_state = __esm({
|
|
54959
|
-
"plugins/huaweicloud-core/dist.new/lib/pack-state.js"() {
|
|
54960
|
-
"use strict";
|
|
54961
|
-
}
|
|
54962
|
-
});
|
|
54963
|
-
|
|
54964
55064
|
// plugins/huaweicloud-core/dist.new/lib/approval-tokens.js
|
|
54965
55065
|
import { createHash as createHash7, createHmac as createHmac3, randomUUID as randomUUID2, timingSafeEqual } from "node:crypto";
|
|
54966
|
-
import { existsSync as
|
|
54967
|
-
import { dirname as
|
|
55066
|
+
import { existsSync as existsSync27, mkdirSync as mkdirSync14, readdirSync as readdirSync4, readFileSync as readFileSync27, renameSync as renameSync7, statSync as statSync9, unlinkSync as unlinkSync4, writeFileSync as writeFileSync12 } from "node:fs";
|
|
55067
|
+
import { dirname as dirname23, join as join34 } from "node:path";
|
|
54968
55068
|
function approvalFilePath() {
|
|
54969
|
-
return
|
|
55069
|
+
return join34(devkitStateBase(), "approvals.json");
|
|
54970
55070
|
}
|
|
54971
55071
|
function sha256Hex2(data) {
|
|
54972
55072
|
return createHash7("sha256").update(data).digest("hex");
|
|
@@ -55005,7 +55105,7 @@ function hashArgs(args) {
|
|
|
55005
55105
|
function readApprovals() {
|
|
55006
55106
|
try {
|
|
55007
55107
|
const path = approvalFilePath();
|
|
55008
|
-
if (!
|
|
55108
|
+
if (!existsSync27(path))
|
|
55009
55109
|
return {};
|
|
55010
55110
|
const parsed = JSON.parse(readFileSync27(path, "utf8"));
|
|
55011
55111
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
@@ -55048,7 +55148,7 @@ function isConfirmGrant(value) {
|
|
|
55048
55148
|
function writeApprovals(map2) {
|
|
55049
55149
|
try {
|
|
55050
55150
|
const path = approvalFilePath();
|
|
55051
|
-
|
|
55151
|
+
mkdirSync14(dirname23(path), { recursive: true });
|
|
55052
55152
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
55053
55153
|
writeFileSync12(tmp, JSON.stringify(map2), { encoding: "utf8", mode: 384 });
|
|
55054
55154
|
renameSync7(tmp, path);
|
|
@@ -55066,12 +55166,12 @@ function pruneStale(map2, now = Date.now()) {
|
|
|
55066
55166
|
return changed;
|
|
55067
55167
|
}
|
|
55068
55168
|
function consumedMarkerDir() {
|
|
55069
|
-
return
|
|
55169
|
+
return join34(devkitStateBase(), "approvals-consumed");
|
|
55070
55170
|
}
|
|
55071
55171
|
function claimSingleUse(token) {
|
|
55072
55172
|
try {
|
|
55073
|
-
|
|
55074
|
-
writeFileSync12(
|
|
55173
|
+
mkdirSync14(consumedMarkerDir(), { recursive: true, mode: 448 });
|
|
55174
|
+
writeFileSync12(join34(consumedMarkerDir(), `${token}.claimed`), "", { flag: "wx", mode: 384 });
|
|
55075
55175
|
return true;
|
|
55076
55176
|
} catch (error62) {
|
|
55077
55177
|
return error62.code !== "EEXIST";
|
|
@@ -55081,7 +55181,7 @@ function pruneConsumedMarkers(now = Date.now()) {
|
|
|
55081
55181
|
try {
|
|
55082
55182
|
const dir = consumedMarkerDir();
|
|
55083
55183
|
for (const name of readdirSync4(dir)) {
|
|
55084
|
-
const path =
|
|
55184
|
+
const path = join34(dir, name);
|
|
55085
55185
|
try {
|
|
55086
55186
|
if (now - statSync9(path).mtimeMs > APPROVAL_TTL_MS * 4)
|
|
55087
55187
|
unlinkSync4(path);
|
|
@@ -55707,14 +55807,14 @@ var init_hcloud_plan = __esm({
|
|
|
55707
55807
|
|
|
55708
55808
|
// plugins/huaweicloud-core/dist.new/hcloud-run-once.js
|
|
55709
55809
|
import { spawn as spawn2 } from "node:child_process";
|
|
55710
|
-
import { mkdirSync as
|
|
55711
|
-
import { join as
|
|
55810
|
+
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync13 } from "node:fs";
|
|
55811
|
+
import { join as join35 } from "node:path";
|
|
55712
55812
|
function saveLargeOutput(rawStdout) {
|
|
55713
55813
|
if (rawStdout.length <= LARGE_OUTPUT_THRESHOLD)
|
|
55714
55814
|
return null;
|
|
55715
55815
|
try {
|
|
55716
|
-
|
|
55717
|
-
const filePath =
|
|
55816
|
+
mkdirSync15(OUTPUT_DIR, { recursive: true });
|
|
55817
|
+
const filePath = join35(OUTPUT_DIR, `output-${Date.now()}.json`);
|
|
55718
55818
|
writeFileSync13(filePath, rawStdout, { encoding: "utf8" });
|
|
55719
55819
|
return filePath;
|
|
55720
55820
|
} catch {
|
|
@@ -55734,7 +55834,7 @@ function runHcloudOnce(plan, options) {
|
|
|
55734
55834
|
const childOptions = { ...options };
|
|
55735
55835
|
delete childOptions.metaDir;
|
|
55736
55836
|
const childEnv = { ...process.env, ...childOptions.env };
|
|
55737
|
-
return new Promise((
|
|
55837
|
+
return new Promise((resolve10) => {
|
|
55738
55838
|
const proxySettings = getProxySettings();
|
|
55739
55839
|
const proxyEnv = {};
|
|
55740
55840
|
if (proxySettings) {
|
|
@@ -55793,7 +55893,7 @@ function runHcloudOnce(plan, options) {
|
|
|
55793
55893
|
};
|
|
55794
55894
|
result.plan = redactedPlan;
|
|
55795
55895
|
}
|
|
55796
|
-
|
|
55896
|
+
resolve10(result);
|
|
55797
55897
|
}
|
|
55798
55898
|
const timer = setTimeout(() => {
|
|
55799
55899
|
timedOut = true;
|
|
@@ -55901,7 +56001,7 @@ var init_hcloud_run_once = __esm({
|
|
|
55901
56001
|
DEFAULT_TIMEOUT_MS = 6e4;
|
|
55902
56002
|
DEFAULT_FORCE_KILL_AFTER_MS = 2e3;
|
|
55903
56003
|
LARGE_OUTPUT_THRESHOLD = 5e4;
|
|
55904
|
-
OUTPUT_DIR =
|
|
56004
|
+
OUTPUT_DIR = join35("/tmp", "huaweicloud-devkit");
|
|
55905
56005
|
}
|
|
55906
56006
|
});
|
|
55907
56007
|
|
|
@@ -55982,7 +56082,7 @@ ${result.stderr || ""}`;
|
|
|
55982
56082
|
return /\[NETWORK_ERROR\]|connection timed out|ECONNRESET|ETIMEDOUT|temporary failure|TLS handshake timeout/i.test(text);
|
|
55983
56083
|
}
|
|
55984
56084
|
function wait(ms) {
|
|
55985
|
-
return new Promise((
|
|
56085
|
+
return new Promise((resolve10) => setTimeout(resolve10, ms));
|
|
55986
56086
|
}
|
|
55987
56087
|
var DEFAULT_MAX_RETRIES;
|
|
55988
56088
|
var init_hcloud_run = __esm({
|
|
@@ -56383,9 +56483,9 @@ var init_pack3 = __esm({
|
|
|
56383
56483
|
});
|
|
56384
56484
|
|
|
56385
56485
|
// plugins/huaweicloud-core/dist.new/packs/obs/tools.js
|
|
56386
|
-
import { existsSync as
|
|
56387
|
-
import { homedir as
|
|
56388
|
-
import { join as
|
|
56486
|
+
import { existsSync as existsSync28, writeFileSync as writeFileSync14 } from "node:fs";
|
|
56487
|
+
import { homedir as homedir21 } from "node:os";
|
|
56488
|
+
import { join as join36 } from "node:path";
|
|
56389
56489
|
import { createHash as createHash8, createHmac as createHmac4 } from "node:crypto";
|
|
56390
56490
|
function pickString(...values) {
|
|
56391
56491
|
for (const value of values) {
|
|
@@ -56424,8 +56524,8 @@ async function setupObsConfig(profile) {
|
|
|
56424
56524
|
return setupObsConfigFromHcloud(profile);
|
|
56425
56525
|
}
|
|
56426
56526
|
async function setupObsConfigFromHcloud(profile) {
|
|
56427
|
-
const obsConfigPath2 =
|
|
56428
|
-
if (
|
|
56527
|
+
const obsConfigPath2 = join36(homedir21(), ".obsutilconfig");
|
|
56528
|
+
if (existsSync28(obsConfigPath2)) {
|
|
56429
56529
|
return {
|
|
56430
56530
|
ok: true,
|
|
56431
56531
|
existed: true,
|
|
@@ -57104,7 +57204,7 @@ var init_search_market = __esm({
|
|
|
57104
57204
|
|
|
57105
57205
|
// plugins/huaweicloud-core/dist.new/icon-library.js
|
|
57106
57206
|
import { readFileSync as readFileSync28 } from "node:fs";
|
|
57107
|
-
import { join as
|
|
57207
|
+
import { join as join37, dirname as dirname24 } from "node:path";
|
|
57108
57208
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
57109
57209
|
function toIconLogo(value) {
|
|
57110
57210
|
const raw = asRecord(value);
|
|
@@ -57291,8 +57391,8 @@ var init_icon_library = __esm({
|
|
|
57291
57391
|
"use strict";
|
|
57292
57392
|
init_proxy_agent();
|
|
57293
57393
|
init_as_record();
|
|
57294
|
-
__dirname7 =
|
|
57295
|
-
SNAPSHOT_PATH =
|
|
57394
|
+
__dirname7 = dirname24(fileURLToPath9(import.meta.url));
|
|
57395
|
+
SNAPSHOT_PATH = join37(__dirname7, "data", "icons-manifest.v1.json");
|
|
57296
57396
|
MANIFEST_URL = "https://open.huaweicloud.com/openplatform/icons/manifest.v1.json";
|
|
57297
57397
|
ICONS_PAGE_URL = "https://open.huaweicloud.com/openplatform/icons.html";
|
|
57298
57398
|
HTTP_TIMEOUT_MS2 = 1e4;
|
|
@@ -57302,11 +57402,11 @@ var init_icon_library = __esm({
|
|
|
57302
57402
|
});
|
|
57303
57403
|
|
|
57304
57404
|
// plugins/huaweicloud-core/dist.new/detect-framework-pkg.js
|
|
57305
|
-
import { existsSync as
|
|
57306
|
-
import { join as
|
|
57405
|
+
import { existsSync as existsSync29, readFileSync as readFileSync29 } from "node:fs";
|
|
57406
|
+
import { join as join38 } from "node:path";
|
|
57307
57407
|
function readPkg(projectPath) {
|
|
57308
|
-
const pkgPath =
|
|
57309
|
-
if (!
|
|
57408
|
+
const pkgPath = join38(projectPath, "package.json");
|
|
57409
|
+
if (!existsSync29(pkgPath))
|
|
57310
57410
|
return null;
|
|
57311
57411
|
try {
|
|
57312
57412
|
const parsed = JSON.parse(readFileSync29(pkgPath, "utf8"));
|
|
@@ -57318,13 +57418,13 @@ function readPkg(projectPath) {
|
|
|
57318
57418
|
}
|
|
57319
57419
|
}
|
|
57320
57420
|
function detectPackageManager(projectPath, pkg) {
|
|
57321
|
-
if (
|
|
57421
|
+
if (existsSync29(join38(projectPath, "pnpm-lock.yaml")))
|
|
57322
57422
|
return "pnpm";
|
|
57323
|
-
if (
|
|
57423
|
+
if (existsSync29(join38(projectPath, "yarn.lock")))
|
|
57324
57424
|
return "yarn";
|
|
57325
|
-
if (
|
|
57425
|
+
if (existsSync29(join38(projectPath, "package-lock.json")))
|
|
57326
57426
|
return "npm";
|
|
57327
|
-
if (
|
|
57427
|
+
if (existsSync29(join38(projectPath, "bun.lockb")))
|
|
57328
57428
|
return "bun";
|
|
57329
57429
|
const declaredValue = pkg?.packageManager;
|
|
57330
57430
|
const declared = typeof declaredValue === "string" ? declaredValue.split("@")[0] : "";
|
|
@@ -57340,8 +57440,8 @@ function collectDeps(pkg) {
|
|
|
57340
57440
|
function readVitepressOutDir(projectPath) {
|
|
57341
57441
|
const configFiles = ["config.mts", "config.ts", "config.mjs", "config.js"];
|
|
57342
57442
|
for (const cf of configFiles) {
|
|
57343
|
-
const configPath =
|
|
57344
|
-
if (!
|
|
57443
|
+
const configPath = join38(projectPath, ".vitepress", cf);
|
|
57444
|
+
if (!existsSync29(configPath))
|
|
57345
57445
|
continue;
|
|
57346
57446
|
try {
|
|
57347
57447
|
const content = readFileSync29(configPath, "utf8");
|
|
@@ -57355,8 +57455,8 @@ function readVitepressOutDir(projectPath) {
|
|
|
57355
57455
|
}
|
|
57356
57456
|
function resolveAngularOutput(projectPath, pkg) {
|
|
57357
57457
|
try {
|
|
57358
|
-
const angularJson =
|
|
57359
|
-
if (
|
|
57458
|
+
const angularJson = join38(projectPath, "angular.json");
|
|
57459
|
+
if (existsSync29(angularJson)) {
|
|
57360
57460
|
const config2 = asRecord(JSON.parse(readFileSync29(angularJson, "utf8")));
|
|
57361
57461
|
const projects = asRecord(config2.projects);
|
|
57362
57462
|
const defaultProjectValue = config2.defaultProject;
|
|
@@ -57536,13 +57636,13 @@ var init_detect_framework_table = __esm({
|
|
|
57536
57636
|
});
|
|
57537
57637
|
|
|
57538
57638
|
// plugins/huaweicloud-core/dist.new/detect-framework-match.js
|
|
57539
|
-
import { existsSync as
|
|
57540
|
-
import { join as
|
|
57639
|
+
import { existsSync as existsSync30 } from "node:fs";
|
|
57640
|
+
import { join as join39 } from "node:path";
|
|
57541
57641
|
function matchFrameworkSpec(projectPath, pkg, deps) {
|
|
57542
|
-
if (
|
|
57642
|
+
if (existsSync30(join39(projectPath, "next.config.js")) || existsSync30(join39(projectPath, "next.config.mjs")) || existsSync30(join39(projectPath, "next.config.ts")) || existsSync30(join39(projectPath, "next.config.cjs"))) {
|
|
57543
57643
|
return FRAMEWORKS.nextjs;
|
|
57544
57644
|
}
|
|
57545
|
-
if (
|
|
57645
|
+
if (existsSync30(join39(projectPath, "nuxt.config.js")) || existsSync30(join39(projectPath, "nuxt.config.mjs")) || existsSync30(join39(projectPath, "nuxt.config.ts")) || existsSync30(join39(projectPath, "nuxt.config.cjs")) || existsSync30(join39(projectPath, "nuxt.config.mts"))) {
|
|
57546
57646
|
return FRAMEWORKS.nuxt;
|
|
57547
57647
|
}
|
|
57548
57648
|
if ("@tarojs/taro" in deps) {
|
|
@@ -57551,35 +57651,35 @@ function matchFrameworkSpec(projectPath, pkg, deps) {
|
|
|
57551
57651
|
if ("@dcloudio/uni-app" in deps || "uni-app" in deps) {
|
|
57552
57652
|
return FRAMEWORKS.uniapp;
|
|
57553
57653
|
}
|
|
57554
|
-
if (
|
|
57654
|
+
if (existsSync30(join39(projectPath, ".vitepress"))) {
|
|
57555
57655
|
const outDir = readVitepressOutDir(projectPath);
|
|
57556
57656
|
return outDir ? { ...FRAMEWORKS.vitepress, outputDir: outDir } : FRAMEWORKS.vitepress;
|
|
57557
57657
|
}
|
|
57558
|
-
if (
|
|
57658
|
+
if (existsSync30(join39(projectPath, "docusaurus.config.js")) || existsSync30(join39(projectPath, "docusaurus.config.ts")) || existsSync30(join39(projectPath, "docusaurus.config.mjs")) || existsSync30(join39(projectPath, "docusaurus.config.cjs"))) {
|
|
57559
57659
|
return FRAMEWORKS.docusaurus;
|
|
57560
57660
|
}
|
|
57561
|
-
if (
|
|
57661
|
+
if (existsSync30(join39(projectPath, "hugo.toml")) || existsSync30(join39(projectPath, "config.toml"))) {
|
|
57562
57662
|
return FRAMEWORKS.hugo;
|
|
57563
57663
|
}
|
|
57564
|
-
if (
|
|
57664
|
+
if (existsSync30(join39(projectPath, "_config.yml"))) {
|
|
57565
57665
|
return FRAMEWORKS.hexo;
|
|
57566
57666
|
}
|
|
57567
|
-
if (
|
|
57667
|
+
if (existsSync30(join39(projectPath, "angular.json"))) {
|
|
57568
57668
|
const outputDir = resolveAngularOutput(projectPath, pkg);
|
|
57569
57669
|
return { ...FRAMEWORKS.angular, outputDir };
|
|
57570
57670
|
}
|
|
57571
|
-
if (
|
|
57671
|
+
if (existsSync30(join39(projectPath, "vite.config.js")) || existsSync30(join39(projectPath, "vite.config.mjs")) || existsSync30(join39(projectPath, "vite.config.ts")) || existsSync30(join39(projectPath, "vite.config.cjs")) || existsSync30(join39(projectPath, "vite.config.mts"))) {
|
|
57572
57672
|
return FRAMEWORKS.vite;
|
|
57573
57673
|
}
|
|
57574
57674
|
if ("@vue/cli-service" in deps) {
|
|
57575
57675
|
return FRAMEWORKS.vueCli;
|
|
57576
57676
|
}
|
|
57577
57677
|
if ("react-scripts" in deps || "react" in deps || "@angular/core" in deps || "vue" in deps || "svelte" in deps || "solid-js" in deps) {
|
|
57578
|
-
if (
|
|
57678
|
+
if (existsSync30(join39(projectPath, "public", "index.html")) || existsSync30(join39(projectPath, "index.html"))) {
|
|
57579
57679
|
return FRAMEWORKS.cra;
|
|
57580
57680
|
}
|
|
57581
57681
|
}
|
|
57582
|
-
if (
|
|
57682
|
+
if (existsSync30(join39(projectPath, "index.html")) || existsSync30(join39(projectPath, "public", "index.html")) || existsSync30(join39(projectPath, "src", "index.html"))) {
|
|
57583
57683
|
return FRAMEWORKS.static;
|
|
57584
57684
|
}
|
|
57585
57685
|
if (pkg) {
|
|
@@ -57596,7 +57696,7 @@ function matchFrameworkSpec(projectPath, pkg, deps) {
|
|
|
57596
57696
|
"src/index.jsx",
|
|
57597
57697
|
"src/index.tsx"
|
|
57598
57698
|
];
|
|
57599
|
-
const hasEntry = entryPoints.some((p) =>
|
|
57699
|
+
const hasEntry = entryPoints.some((p) => existsSync30(join39(projectPath, p)));
|
|
57600
57700
|
if (hasEntry) {
|
|
57601
57701
|
if ("vue" in deps || "@vue/cli-service" in deps) {
|
|
57602
57702
|
return FRAMEWORKS.vueCli;
|
|
@@ -57620,20 +57720,20 @@ var init_detect_framework_match = __esm({
|
|
|
57620
57720
|
});
|
|
57621
57721
|
|
|
57622
57722
|
// plugins/huaweicloud-core/dist.new/detect-framework-scan.js
|
|
57623
|
-
import { existsSync as
|
|
57624
|
-
import { join as
|
|
57723
|
+
import { existsSync as existsSync31, readdirSync as readdirSync5 } from "node:fs";
|
|
57724
|
+
import { join as join40 } from "node:path";
|
|
57625
57725
|
function scanSubApps(projectPath) {
|
|
57626
57726
|
const apps = [];
|
|
57627
57727
|
for (const dir of ["apps", "packages"]) {
|
|
57628
|
-
const dirPath =
|
|
57629
|
-
if (!
|
|
57728
|
+
const dirPath = join40(projectPath, dir);
|
|
57729
|
+
if (!existsSync31(dirPath))
|
|
57630
57730
|
continue;
|
|
57631
57731
|
try {
|
|
57632
57732
|
const entries = readdirSync5(dirPath, { withFileTypes: true });
|
|
57633
57733
|
for (const entry of entries) {
|
|
57634
57734
|
if (!entry.isDirectory())
|
|
57635
57735
|
continue;
|
|
57636
|
-
const subPath =
|
|
57736
|
+
const subPath = join40(dirPath, entry.name);
|
|
57637
57737
|
const subPkg = readPkg(subPath);
|
|
57638
57738
|
if (!subPkg)
|
|
57639
57739
|
continue;
|
|
@@ -57681,12 +57781,12 @@ function detectFramework(projectPath) {
|
|
|
57681
57781
|
const pkg = readPkg(projectPath);
|
|
57682
57782
|
const deps = collectDeps(pkg);
|
|
57683
57783
|
const pm = detectPackageManager(projectPath, pkg);
|
|
57684
|
-
if (
|
|
57784
|
+
if (existsSync31(join40(projectPath, "pnpm-workspace.yaml")) || existsSync31(join40(projectPath, "turbo.json")) || existsSync31(join40(projectPath, "nx.json")) || existsSync31(join40(projectPath, "lerna.json"))) {
|
|
57685
57785
|
const monorepoSubApps = scanSubApps(projectPath);
|
|
57686
57786
|
return {
|
|
57687
57787
|
type: "monorepo",
|
|
57688
57788
|
framework: "Monorepo",
|
|
57689
|
-
monorepoTool:
|
|
57789
|
+
monorepoTool: existsSync31(join40(projectPath, "turbo.json")) ? "Turborepo" : existsSync31(join40(projectPath, "nx.json")) ? "Nx" : existsSync31(join40(projectPath, "lerna.json")) ? "Lerna" : "pnpm Workspace",
|
|
57690
57790
|
subApps: monorepoSubApps,
|
|
57691
57791
|
packageManager: pm,
|
|
57692
57792
|
rootDir: projectPath
|
|
@@ -58217,9 +58317,9 @@ var init_pack7 = __esm({
|
|
|
58217
58317
|
|
|
58218
58318
|
// plugins/huaweicloud-core/dist.new/packs/huaweicloud-open-mcp/sidecar.js
|
|
58219
58319
|
import { spawn as spawn3 } from "node:child_process";
|
|
58220
|
-
import { mkdtempSync, rmSync as
|
|
58320
|
+
import { mkdtempSync, rmSync as rmSync9 } from "node:fs";
|
|
58221
58321
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
58222
|
-
import { isAbsolute as
|
|
58322
|
+
import { isAbsolute as isAbsolute3, join as join41 } from "node:path";
|
|
58223
58323
|
function resolveGatewayCommand(env = process.env) {
|
|
58224
58324
|
const resolved = resolveDependencyCommand(DEPENDENCIES["open-mcp-gateway"].resolution, env);
|
|
58225
58325
|
if (!resolved)
|
|
@@ -58229,7 +58329,7 @@ function resolveGatewayCommand(env = process.env) {
|
|
|
58229
58329
|
function resolveGatewaySpawnArgs(env = process.env) {
|
|
58230
58330
|
for (const key of ["HUAWEICLOUD_MCP_POLICY_FILE", "HUAWEICLOUD_MCP_AUDIT_FILE"]) {
|
|
58231
58331
|
const value = (env[key] ?? "").trim();
|
|
58232
|
-
if (value !== "" && !
|
|
58332
|
+
if (value !== "" && !isAbsolute3(value)) {
|
|
58233
58333
|
throw new Error(`${key} must be an absolute path (got "${value}"): the gateway child, this server, and the protected-tree guard each resolve relative paths against different working directories.`);
|
|
58234
58334
|
}
|
|
58235
58335
|
}
|
|
@@ -58248,18 +58348,18 @@ function resolveGatewaySpawnArgs(env = process.env) {
|
|
|
58248
58348
|
let provision = null;
|
|
58249
58349
|
if (policyEnv === "") {
|
|
58250
58350
|
const dir = packStateDir("huaweicloud-open-mcp", env);
|
|
58251
|
-
provision = { dir, policyPath:
|
|
58351
|
+
provision = { dir, policyPath: join41(dir, POLICY_FILE) };
|
|
58252
58352
|
args.push("--policy", provision.policyPath);
|
|
58253
58353
|
}
|
|
58254
58354
|
if (!(env.HUAWEICLOUD_MCP_LOG_FILE ?? "").trim()) {
|
|
58255
|
-
args.push("--log-file",
|
|
58355
|
+
args.push("--log-file", join41(tmpdir6(), "huaweicloud-open-mcp.log"));
|
|
58256
58356
|
}
|
|
58257
58357
|
return { args, provision };
|
|
58258
58358
|
}
|
|
58259
58359
|
function removeScratchCwd(dir) {
|
|
58260
58360
|
scratchCwds.delete(dir);
|
|
58261
58361
|
try {
|
|
58262
|
-
|
|
58362
|
+
rmSync9(dir, { recursive: true, force: true });
|
|
58263
58363
|
} catch {
|
|
58264
58364
|
}
|
|
58265
58365
|
}
|
|
@@ -58272,7 +58372,7 @@ async function spawnSidecar() {
|
|
|
58272
58372
|
if (plan.provision) {
|
|
58273
58373
|
ensurePackState("huaweicloud-open-mcp", [POLICY_FILE]);
|
|
58274
58374
|
}
|
|
58275
|
-
const scratchCwd = mkdtempSync(
|
|
58375
|
+
const scratchCwd = mkdtempSync(join41(tmpdir6(), "openmcp-gw-"));
|
|
58276
58376
|
scratchCwds.add(scratchCwd);
|
|
58277
58377
|
if (!scratchExitSweepInstalled) {
|
|
58278
58378
|
scratchExitSweepInstalled = true;
|
|
@@ -58476,12 +58576,12 @@ var init_sidecar = __esm({
|
|
|
58476
58576
|
return Promise.reject(new Error("open-mcp gateway sidecar is dead; the next call respawns it"));
|
|
58477
58577
|
}
|
|
58478
58578
|
const id = this.nextId++;
|
|
58479
|
-
return new Promise((
|
|
58579
|
+
return new Promise((resolve10, reject) => {
|
|
58480
58580
|
const timer = setTimeout(() => {
|
|
58481
58581
|
this.pending.delete(id);
|
|
58482
58582
|
reject(new Error(`open-mcp gateway ${method} timed out after ${timeoutMs}ms`));
|
|
58483
58583
|
}, timeoutMs);
|
|
58484
|
-
this.pending.set(id, { resolve:
|
|
58584
|
+
this.pending.set(id, { resolve: resolve10, reject, timer });
|
|
58485
58585
|
this.child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
|
|
58486
58586
|
`);
|
|
58487
58587
|
});
|
|
@@ -58510,11 +58610,11 @@ var init_sidecar = __esm({
|
|
|
58510
58610
|
if (!this.alive)
|
|
58511
58611
|
return;
|
|
58512
58612
|
this.kill();
|
|
58513
|
-
await new Promise((
|
|
58514
|
-
const bound = setTimeout(
|
|
58613
|
+
await new Promise((resolve10) => {
|
|
58614
|
+
const bound = setTimeout(resolve10, 4500);
|
|
58515
58615
|
this.child.once("exit", () => {
|
|
58516
58616
|
clearTimeout(bound);
|
|
58517
|
-
|
|
58617
|
+
resolve10();
|
|
58518
58618
|
});
|
|
58519
58619
|
});
|
|
58520
58620
|
}
|
|
@@ -58540,18 +58640,18 @@ var init_sidecar = __esm({
|
|
|
58540
58640
|
});
|
|
58541
58641
|
|
|
58542
58642
|
// plugins/huaweicloud-core/dist.new/packs/huaweicloud-open-mcp/approval.js
|
|
58543
|
-
import { join as
|
|
58643
|
+
import { join as join42 } from "node:path";
|
|
58544
58644
|
function resolveApprovalMode(env = process.env) {
|
|
58545
58645
|
const value = (env.HUAWEICLOUD_OPENMCP_APPROVAL ?? "").trim();
|
|
58546
58646
|
if (value === "")
|
|
58547
58647
|
return;
|
|
58548
58648
|
const operatorPath = (env.HUAWEICLOUD_MCP_POLICY_FILE ?? "").trim();
|
|
58549
|
-
const policyFile = operatorPath !== "" ? operatorPath :
|
|
58649
|
+
const policyFile = operatorPath !== "" ? operatorPath : join42(packStateDir("huaweicloud-open-mcp", env), POLICY_FILE);
|
|
58550
58650
|
throw new Error(`HUAWEICLOUD_OPENMCP_APPROVAL is retired (was set to "${value}"): gateway tool approval is delegated to the gateway's own policy engine. Manage consent in the operator policy file (${policyFile}); it hot-reloads, so edits take effect without a restart. See docs/safety-model.md for the delegation contract and the floors this face still enforces.`);
|
|
58551
58651
|
}
|
|
58552
58652
|
function permanentGrantReason() {
|
|
58553
58653
|
const operatorPath = (process.env.HUAWEICLOUD_MCP_POLICY_FILE ?? "").trim();
|
|
58554
|
-
const path = operatorPath !== "" ? operatorPath :
|
|
58654
|
+
const path = operatorPath !== "" ? operatorPath : join42(packStateDir("huaweicloud-open-mcp"), POLICY_FILE);
|
|
58555
58655
|
return `permanent-scope grants are an operator gesture, not an agent action: edit the policy file directly (${path}); it hot-reloads, so the change takes effect without a restart`;
|
|
58556
58656
|
}
|
|
58557
58657
|
function classify(tool, toolArgs) {
|
|
@@ -59075,13 +59175,13 @@ var init_registry = __esm({
|
|
|
59075
59175
|
});
|
|
59076
59176
|
|
|
59077
59177
|
// plugins/huaweicloud-core/dist.new/lib/skill-tree.js
|
|
59078
|
-
import { existsSync as
|
|
59079
|
-
import { join as
|
|
59178
|
+
import { existsSync as existsSync32, readdirSync as readdirSync6, readFileSync as readFileSync31 } from "node:fs";
|
|
59179
|
+
import { join as join43 } from "node:path";
|
|
59080
59180
|
function listSkillDirs(root) {
|
|
59081
|
-
if (!
|
|
59181
|
+
if (!existsSync32(root))
|
|
59082
59182
|
return [];
|
|
59083
59183
|
try {
|
|
59084
|
-
return readdirSync6(root, { withFileTypes: true }).filter((d) => (d.isDirectory() || d.isSymbolicLink()) &&
|
|
59184
|
+
return readdirSync6(root, { withFileTypes: true }).filter((d) => (d.isDirectory() || d.isSymbolicLink()) && existsSync32(join43(root, d.name, "SKILL.md"))).map((d) => d.name);
|
|
59085
59185
|
} catch {
|
|
59086
59186
|
return [];
|
|
59087
59187
|
}
|
|
@@ -59092,8 +59192,74 @@ var init_skill_tree = __esm({
|
|
|
59092
59192
|
}
|
|
59093
59193
|
});
|
|
59094
59194
|
|
|
59195
|
+
// plugins/huaweicloud-core/dist.new/lib/param-warnings.js
|
|
59196
|
+
function levenshtein(a, b) {
|
|
59197
|
+
const rows = a.length + 1;
|
|
59198
|
+
const cols = b.length + 1;
|
|
59199
|
+
const previous = new Array(cols);
|
|
59200
|
+
const current = new Array(cols);
|
|
59201
|
+
for (let j = 0; j < cols; j++)
|
|
59202
|
+
previous[j] = j;
|
|
59203
|
+
for (let i = 1; i < rows; i++) {
|
|
59204
|
+
current[0] = i;
|
|
59205
|
+
for (let j = 1; j < cols; j++) {
|
|
59206
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
59207
|
+
current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + cost);
|
|
59208
|
+
}
|
|
59209
|
+
for (let j = 0; j < cols; j++)
|
|
59210
|
+
previous[j] = current[j];
|
|
59211
|
+
}
|
|
59212
|
+
return previous[cols - 1];
|
|
59213
|
+
}
|
|
59214
|
+
function suggestParam(key, knownKeys) {
|
|
59215
|
+
let best = null;
|
|
59216
|
+
let bestDistance = SUGGESTION_DISTANCE + 1;
|
|
59217
|
+
const lowerKey = key.toLowerCase();
|
|
59218
|
+
for (const candidate of knownKeys) {
|
|
59219
|
+
if (candidate === key)
|
|
59220
|
+
continue;
|
|
59221
|
+
const distance = levenshtein(lowerKey, candidate.toLowerCase());
|
|
59222
|
+
if (distance > SUGGESTION_DISTANCE)
|
|
59223
|
+
continue;
|
|
59224
|
+
if (distance < bestDistance || distance === bestDistance && best !== null && candidate < best) {
|
|
59225
|
+
best = candidate;
|
|
59226
|
+
bestDistance = distance;
|
|
59227
|
+
}
|
|
59228
|
+
}
|
|
59229
|
+
return best;
|
|
59230
|
+
}
|
|
59231
|
+
function unknownParamWarnings(args, knownKeys) {
|
|
59232
|
+
const unknown2 = Object.keys(args).filter((key) => !knownKeys.has(key)).sort((a, b) => a.localeCompare(b));
|
|
59233
|
+
return unknown2.slice(0, MAX_WARNINGS).map((key) => {
|
|
59234
|
+
const suggestion = suggestParam(key, knownKeys);
|
|
59235
|
+
return suggestion ? `Unknown parameter "${key}" was ignored. Did you mean "${suggestion}"?` : `Unknown parameter "${key}" was ignored (no matching parameter).`;
|
|
59236
|
+
});
|
|
59237
|
+
}
|
|
59238
|
+
function attachParamWarnings(result, warnings) {
|
|
59239
|
+
if (warnings.length === 0)
|
|
59240
|
+
return result;
|
|
59241
|
+
if (result === null || typeof result !== "object" || Array.isArray(result))
|
|
59242
|
+
return result;
|
|
59243
|
+
const record2 = result;
|
|
59244
|
+
if (Array.isArray(record2.warnings)) {
|
|
59245
|
+
return { ...record2, warnings: [...record2.warnings, ...warnings] };
|
|
59246
|
+
}
|
|
59247
|
+
if (record2.warnings === void 0) {
|
|
59248
|
+
return { ...record2, warnings };
|
|
59249
|
+
}
|
|
59250
|
+
return { ...record2, paramWarnings: warnings };
|
|
59251
|
+
}
|
|
59252
|
+
var MAX_WARNINGS, SUGGESTION_DISTANCE;
|
|
59253
|
+
var init_param_warnings = __esm({
|
|
59254
|
+
"plugins/huaweicloud-core/dist.new/lib/param-warnings.js"() {
|
|
59255
|
+
"use strict";
|
|
59256
|
+
MAX_WARNINGS = 5;
|
|
59257
|
+
SUGGESTION_DISTANCE = 2;
|
|
59258
|
+
}
|
|
59259
|
+
});
|
|
59260
|
+
|
|
59095
59261
|
// plugins/huaweicloud-core/dist.new/lib/call-trace.js
|
|
59096
|
-
import { appendFileSync as appendFileSync4, existsSync as
|
|
59262
|
+
import { appendFileSync as appendFileSync4, existsSync as existsSync33, writeFileSync as writeFileSync15 } from "node:fs";
|
|
59097
59263
|
function redactSupplemental(value) {
|
|
59098
59264
|
if (Array.isArray(value))
|
|
59099
59265
|
return value.map((item) => redactSupplemental(item));
|
|
@@ -59118,7 +59284,7 @@ function appendRecord(record2) {
|
|
|
59118
59284
|
try {
|
|
59119
59285
|
const line = `${JSON.stringify(record2)}
|
|
59120
59286
|
`;
|
|
59121
|
-
if (
|
|
59287
|
+
if (existsSync33(path)) {
|
|
59122
59288
|
appendFileSync4(path, line, "utf8");
|
|
59123
59289
|
} else {
|
|
59124
59290
|
writeFileSync15(path, line, { mode: 384, encoding: "utf8" });
|
|
@@ -59450,88 +59616,6 @@ var init_tool_definitions = __esm({
|
|
|
59450
59616
|
}
|
|
59451
59617
|
});
|
|
59452
59618
|
|
|
59453
|
-
// plugins/huaweicloud-core/dist.new/vendor-gate.js
|
|
59454
|
-
function vendorChallengeEnabled() {
|
|
59455
|
-
return process.env.HUAWEICLOUD_VENDOR_CHALLENGE !== "off";
|
|
59456
|
-
}
|
|
59457
|
-
function enforceVendorGate(args, opts) {
|
|
59458
|
-
const quote = args.vendorConfirmed;
|
|
59459
|
-
if (typeof quote !== "string" || quote.trim().length === 0) {
|
|
59460
|
-
throw new Error(VENDOR_GATE_MESSAGE);
|
|
59461
|
-
}
|
|
59462
|
-
const challengeKey = opts.sessionId || "default";
|
|
59463
|
-
if (vendorChallengeEnabled() && !vendorChallengeConsumed.get(challengeKey)) {
|
|
59464
|
-
vendorChallengeConsumed.set(challengeKey, true);
|
|
59465
|
-
throw new Error(VENDOR_CHALLENGE_MESSAGE);
|
|
59466
|
-
}
|
|
59467
|
-
}
|
|
59468
|
-
var VENDOR_GATED_TOOLS, VENDOR_GATE_MESSAGE, VENDOR_CHALLENGE_MESSAGE, vendorChallengeConsumed;
|
|
59469
|
-
var init_vendor_gate = __esm({
|
|
59470
|
-
"plugins/huaweicloud-core/dist.new/vendor-gate.js"() {
|
|
59471
|
-
"use strict";
|
|
59472
|
-
VENDOR_GATED_TOOLS = /* @__PURE__ */ new Set([
|
|
59473
|
-
"huaweicloud_auth_status",
|
|
59474
|
-
"huaweicloud_auth_init",
|
|
59475
|
-
"huaweicloud_auth_switch",
|
|
59476
|
-
"huaweicloud_check_cli",
|
|
59477
|
-
"huaweicloud_show_profile_redacted",
|
|
59478
|
-
"huaweicloud_list_operations",
|
|
59479
|
-
"huaweicloud_list_regions",
|
|
59480
|
-
"huaweicloud_run_readonly_command",
|
|
59481
|
-
"huaweicloud_plan_cli_command",
|
|
59482
|
-
"huaweicloud_run_approved_command",
|
|
59483
|
-
"huaweicloud_service_catalog",
|
|
59484
|
-
"huaweicloud_sandbox_connect",
|
|
59485
|
-
"huaweicloud_voucher_claim",
|
|
59486
|
-
"huaweicloud_competition_voucher_claim"
|
|
59487
|
-
]);
|
|
59488
|
-
VENDOR_GATE_MESSAGE = "Vendor gate: this tool operates on Huawei Cloud. Pass vendorConfirmed with the user's establishing words \u2014 the quote where they named Huawei Cloud, an hcloud artifact, a myhuaweicloud endpoint, a Huawei region ID, or an earlier confirmation. The devkit being installed is NOT confirmation. If you cannot quote the user, ask which cloud they mean, then retry once established.";
|
|
59489
|
-
VENDOR_CHALLENGE_MESSAGE = "Vendor challenge: first Huawei Cloud tool call this session \u2014 is the vendorConfirmed quote the user's actual words, or invented? An invented quote is a fabricated user statement. If invented, or the vendor was only assumed, ask which cloud they mean now. Retry the same call to proceed; this challenge appears once per session.";
|
|
59490
|
-
vendorChallengeConsumed = /* @__PURE__ */ new Map();
|
|
59491
|
-
}
|
|
59492
|
-
});
|
|
59493
|
-
|
|
59494
|
-
// plugins/huaweicloud-core/dist.new/packs/enable.js
|
|
59495
|
-
function setRuntimePacksOverride(raw) {
|
|
59496
|
-
const parsed = parseDevkitPacks(raw);
|
|
59497
|
-
if (!parsed.raw) {
|
|
59498
|
-
throw new Error("Runtime pack override cannot be blank. Clear it with reset instead.");
|
|
59499
|
-
}
|
|
59500
|
-
if (parsed.unknown.length > 0) {
|
|
59501
|
-
throw new Error(`Runtime pack override contains unknown pack id(s): ${parsed.unknown.join(", ")}. Valid pack ids: ${VALID_IDS.join(", ")}.`);
|
|
59502
|
-
}
|
|
59503
|
-
runtimeOverride = parsed;
|
|
59504
|
-
return parsed;
|
|
59505
|
-
}
|
|
59506
|
-
function clearRuntimePacksOverride() {
|
|
59507
|
-
runtimeOverride = null;
|
|
59508
|
-
}
|
|
59509
|
-
function runtimePacksOverride() {
|
|
59510
|
-
return runtimeOverride;
|
|
59511
|
-
}
|
|
59512
|
-
function resolveEnabledPacks(env = process.env) {
|
|
59513
|
-
if (runtimeOverride)
|
|
59514
|
-
return runtimeOverride.enabled;
|
|
59515
|
-
const raw = (env.DEVKIT_PACKS ?? "").trim();
|
|
59516
|
-
if (!raw)
|
|
59517
|
-
return new Set(PACK_IDS);
|
|
59518
|
-
const { unknown: unknown2, enabled } = parseDevkitPacks(raw);
|
|
59519
|
-
if (unknown2.length > 0) {
|
|
59520
|
-
throw new Error(`DEVKIT_PACKS contains unknown pack id(s): ${unknown2.join(", ")}. Valid pack ids: ${VALID_IDS.join(", ")}.`);
|
|
59521
|
-
}
|
|
59522
|
-
return enabled;
|
|
59523
|
-
}
|
|
59524
|
-
var VALID_IDS, runtimeOverride;
|
|
59525
|
-
var init_enable = __esm({
|
|
59526
|
-
"plugins/huaweicloud-core/dist.new/packs/enable.js"() {
|
|
59527
|
-
"use strict";
|
|
59528
|
-
init_pack_types();
|
|
59529
|
-
init_dependency_model();
|
|
59530
|
-
VALID_IDS = PACK_IDS;
|
|
59531
|
-
runtimeOverride = null;
|
|
59532
|
-
}
|
|
59533
|
-
});
|
|
59534
|
-
|
|
59535
59619
|
// plugins/huaweicloud-core/dist.new/tool-schemas.js
|
|
59536
59620
|
function getToolSchema(name) {
|
|
59537
59621
|
return TOOL_SCHEMAS[name];
|
|
@@ -59539,6 +59623,16 @@ function getToolSchema(name) {
|
|
|
59539
59623
|
function toolSchemaEntries() {
|
|
59540
59624
|
return Object.entries(TOOL_SCHEMAS);
|
|
59541
59625
|
}
|
|
59626
|
+
function toolArgKeys(name) {
|
|
59627
|
+
const cached2 = argKeyCache.get(name);
|
|
59628
|
+
if (cached2)
|
|
59629
|
+
return cached2;
|
|
59630
|
+
const def = TOOL_SCHEMAS[name]._zod?.def;
|
|
59631
|
+
const keys = new Set(Object.keys(def?.shape ?? {}));
|
|
59632
|
+
keys.add("vendorConfirmed");
|
|
59633
|
+
argKeyCache.set(name, keys);
|
|
59634
|
+
return keys;
|
|
59635
|
+
}
|
|
59542
59636
|
function assertConstructedSchemas() {
|
|
59543
59637
|
for (const [name, schema] of toolSchemaEntries()) {
|
|
59544
59638
|
const def = schema._zod?.def;
|
|
@@ -59547,7 +59641,7 @@ function assertConstructedSchemas() {
|
|
|
59547
59641
|
}
|
|
59548
59642
|
}
|
|
59549
59643
|
}
|
|
59550
|
-
var SCHEMA_DRIFT_IGNORED_KEYS, artifactsItem, TOOL_SCHEMAS;
|
|
59644
|
+
var SCHEMA_DRIFT_IGNORED_KEYS, artifactsItem, TOOL_SCHEMAS, argKeyCache;
|
|
59551
59645
|
var init_tool_schemas = __esm({
|
|
59552
59646
|
"plugins/huaweicloud-core/dist.new/tool-schemas.js"() {
|
|
59553
59647
|
"use strict";
|
|
@@ -59656,6 +59750,89 @@ var init_tool_schemas = __esm({
|
|
|
59656
59750
|
reset: external_exports.boolean().optional().describe("Drop the session override and return to the operator DEVKIT_PACKS posture.")
|
|
59657
59751
|
})
|
|
59658
59752
|
};
|
|
59753
|
+
argKeyCache = /* @__PURE__ */ new Map();
|
|
59754
|
+
}
|
|
59755
|
+
});
|
|
59756
|
+
|
|
59757
|
+
// plugins/huaweicloud-core/dist.new/vendor-gate.js
|
|
59758
|
+
function vendorChallengeEnabled() {
|
|
59759
|
+
return process.env.HUAWEICLOUD_VENDOR_CHALLENGE !== "off";
|
|
59760
|
+
}
|
|
59761
|
+
function enforceVendorGate(args, opts) {
|
|
59762
|
+
const quote = args.vendorConfirmed;
|
|
59763
|
+
if (typeof quote !== "string" || quote.trim().length === 0) {
|
|
59764
|
+
throw new Error(VENDOR_GATE_MESSAGE);
|
|
59765
|
+
}
|
|
59766
|
+
const challengeKey = opts.sessionId || "default";
|
|
59767
|
+
if (vendorChallengeEnabled() && !vendorChallengeConsumed.get(challengeKey)) {
|
|
59768
|
+
vendorChallengeConsumed.set(challengeKey, true);
|
|
59769
|
+
throw new Error(VENDOR_CHALLENGE_MESSAGE);
|
|
59770
|
+
}
|
|
59771
|
+
}
|
|
59772
|
+
var VENDOR_GATED_TOOLS, VENDOR_GATE_MESSAGE, VENDOR_CHALLENGE_MESSAGE, vendorChallengeConsumed;
|
|
59773
|
+
var init_vendor_gate = __esm({
|
|
59774
|
+
"plugins/huaweicloud-core/dist.new/vendor-gate.js"() {
|
|
59775
|
+
"use strict";
|
|
59776
|
+
VENDOR_GATED_TOOLS = /* @__PURE__ */ new Set([
|
|
59777
|
+
"huaweicloud_auth_status",
|
|
59778
|
+
"huaweicloud_auth_init",
|
|
59779
|
+
"huaweicloud_auth_switch",
|
|
59780
|
+
"huaweicloud_check_cli",
|
|
59781
|
+
"huaweicloud_show_profile_redacted",
|
|
59782
|
+
"huaweicloud_list_operations",
|
|
59783
|
+
"huaweicloud_list_regions",
|
|
59784
|
+
"huaweicloud_run_readonly_command",
|
|
59785
|
+
"huaweicloud_plan_cli_command",
|
|
59786
|
+
"huaweicloud_run_approved_command",
|
|
59787
|
+
"huaweicloud_service_catalog",
|
|
59788
|
+
"huaweicloud_sandbox_connect",
|
|
59789
|
+
"huaweicloud_voucher_claim",
|
|
59790
|
+
"huaweicloud_competition_voucher_claim"
|
|
59791
|
+
]);
|
|
59792
|
+
VENDOR_GATE_MESSAGE = "Vendor gate: this tool operates on Huawei Cloud. Pass vendorConfirmed with the user's establishing words \u2014 the quote where they named Huawei Cloud, an hcloud artifact, a myhuaweicloud endpoint, a Huawei region ID, or an earlier confirmation. The devkit being installed is NOT confirmation. If you cannot quote the user, ask which cloud they mean, then retry once established.";
|
|
59793
|
+
VENDOR_CHALLENGE_MESSAGE = "Vendor challenge: first Huawei Cloud tool call this session \u2014 is the vendorConfirmed quote the user's actual words, or invented? An invented quote is a fabricated user statement. If invented, or the vendor was only assumed, ask which cloud they mean now. Retry the same call to proceed; this challenge appears once per session.";
|
|
59794
|
+
vendorChallengeConsumed = /* @__PURE__ */ new Map();
|
|
59795
|
+
}
|
|
59796
|
+
});
|
|
59797
|
+
|
|
59798
|
+
// plugins/huaweicloud-core/dist.new/packs/enable.js
|
|
59799
|
+
function setRuntimePacksOverride(raw) {
|
|
59800
|
+
const parsed = parseDevkitPacks(raw);
|
|
59801
|
+
if (!parsed.raw) {
|
|
59802
|
+
throw new Error("Runtime pack override cannot be blank. Clear it with reset instead.");
|
|
59803
|
+
}
|
|
59804
|
+
if (parsed.unknown.length > 0) {
|
|
59805
|
+
throw new Error(`Runtime pack override contains unknown pack id(s): ${parsed.unknown.join(", ")}. Valid pack ids: ${VALID_IDS.join(", ")}.`);
|
|
59806
|
+
}
|
|
59807
|
+
runtimeOverride = parsed;
|
|
59808
|
+
return parsed;
|
|
59809
|
+
}
|
|
59810
|
+
function clearRuntimePacksOverride() {
|
|
59811
|
+
runtimeOverride = null;
|
|
59812
|
+
}
|
|
59813
|
+
function runtimePacksOverride() {
|
|
59814
|
+
return runtimeOverride;
|
|
59815
|
+
}
|
|
59816
|
+
function resolveEnabledPacks(env = process.env) {
|
|
59817
|
+
if (runtimeOverride)
|
|
59818
|
+
return runtimeOverride.enabled;
|
|
59819
|
+
const raw = (env.DEVKIT_PACKS ?? "").trim();
|
|
59820
|
+
if (!raw)
|
|
59821
|
+
return new Set(PACK_IDS);
|
|
59822
|
+
const { unknown: unknown2, enabled } = parseDevkitPacks(raw);
|
|
59823
|
+
if (unknown2.length > 0) {
|
|
59824
|
+
throw new Error(`DEVKIT_PACKS contains unknown pack id(s): ${unknown2.join(", ")}. Valid pack ids: ${VALID_IDS.join(", ")}.`);
|
|
59825
|
+
}
|
|
59826
|
+
return enabled;
|
|
59827
|
+
}
|
|
59828
|
+
var VALID_IDS, runtimeOverride;
|
|
59829
|
+
var init_enable = __esm({
|
|
59830
|
+
"plugins/huaweicloud-core/dist.new/packs/enable.js"() {
|
|
59831
|
+
"use strict";
|
|
59832
|
+
init_pack_types();
|
|
59833
|
+
init_dependency_model();
|
|
59834
|
+
VALID_IDS = PACK_IDS;
|
|
59835
|
+
runtimeOverride = null;
|
|
59659
59836
|
}
|
|
59660
59837
|
});
|
|
59661
59838
|
|
|
@@ -60238,8 +60415,8 @@ var init_skill_frontmatter = __esm({
|
|
|
60238
60415
|
});
|
|
60239
60416
|
|
|
60240
60417
|
// plugins/huaweicloud-core/dist.new/skill-disclosure.js
|
|
60241
|
-
import { readFileSync as readFileSync32, readdirSync as readdirSync7, existsSync as
|
|
60242
|
-
import { join as
|
|
60418
|
+
import { readFileSync as readFileSync32, readdirSync as readdirSync7, existsSync as existsSync34 } from "node:fs";
|
|
60419
|
+
import { join as join44, dirname as dirname25 } from "node:path";
|
|
60243
60420
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
60244
60421
|
function verifySkillTree(root = SKILLS_ROOT) {
|
|
60245
60422
|
const present2 = new Set(listSkillDirs(root));
|
|
@@ -60255,8 +60432,8 @@ function verifySkillTree(root = SKILLS_ROOT) {
|
|
|
60255
60432
|
}
|
|
60256
60433
|
}
|
|
60257
60434
|
function referenceFilenames(skillName) {
|
|
60258
|
-
const refDir =
|
|
60259
|
-
if (!
|
|
60435
|
+
const refDir = join44(SKILLS_ROOT, skillName, "references");
|
|
60436
|
+
if (!existsSync34(refDir))
|
|
60260
60437
|
return [];
|
|
60261
60438
|
return readdirSync7(refDir, { withFileTypes: true }).filter((entry) => entry.isFile() || entry.isSymbolicLink()).map((entry) => entry.name).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
60262
60439
|
}
|
|
@@ -60288,7 +60465,7 @@ function listSkills(pack, opts = {}) {
|
|
|
60288
60465
|
if (!enabled.has(entry.id))
|
|
60289
60466
|
continue;
|
|
60290
60467
|
for (const skillName of entry.skills) {
|
|
60291
|
-
const fm = parseSkillFrontmatter(readFileSync32(
|
|
60468
|
+
const fm = parseSkillFrontmatter(readFileSync32(join44(SKILLS_ROOT, skillName, "SKILL.md"), "utf8"));
|
|
60292
60469
|
skills.push({
|
|
60293
60470
|
name: skillName,
|
|
60294
60471
|
description: fm.description ?? "",
|
|
@@ -60316,8 +60493,8 @@ async function retrieveSkill(name, opts = {}) {
|
|
|
60316
60493
|
error: 'Invalid skill name "' + skillName + '". Skill names are lowercase letters, digits, and dashes.'
|
|
60317
60494
|
};
|
|
60318
60495
|
}
|
|
60319
|
-
const skillPath =
|
|
60320
|
-
if (!
|
|
60496
|
+
const skillPath = join44(SKILLS_ROOT, skillName, "SKILL.md");
|
|
60497
|
+
if (!existsSync34(skillPath)) {
|
|
60321
60498
|
const enabled = resolveEnabledPacks();
|
|
60322
60499
|
const dirs = listSkillDirs(SKILLS_ROOT).filter((dir) => {
|
|
60323
60500
|
const owner2 = SKILL_OWNER.get(dir);
|
|
@@ -60335,7 +60512,7 @@ async function retrieveSkill(name, opts = {}) {
|
|
|
60335
60512
|
const content = readFileSync32(skillPath, "utf8");
|
|
60336
60513
|
const references = [];
|
|
60337
60514
|
for (const filename of referenceFilenames(skillName)) {
|
|
60338
|
-
const refPath =
|
|
60515
|
+
const refPath = join44(SKILLS_ROOT, skillName, "references", filename);
|
|
60339
60516
|
const raw = readFileSync32(refPath, "utf8");
|
|
60340
60517
|
references.push({
|
|
60341
60518
|
filename,
|
|
@@ -60367,29 +60544,29 @@ var init_skill_disclosure = __esm({
|
|
|
60367
60544
|
init_skill_tree();
|
|
60368
60545
|
init_skill_frontmatter();
|
|
60369
60546
|
init_capability_catalog();
|
|
60370
|
-
__dirname8 =
|
|
60371
|
-
SKILLS_ROOT =
|
|
60547
|
+
__dirname8 = dirname25(fileURLToPath10(import.meta.url));
|
|
60548
|
+
SKILLS_ROOT = join44(__dirname8, "..", "skills");
|
|
60372
60549
|
REFERENCE_CAP = 4e3;
|
|
60373
60550
|
}
|
|
60374
60551
|
});
|
|
60375
60552
|
|
|
60376
60553
|
// plugins/huaweicloud-core/dist.new/search-docs.js
|
|
60377
|
-
import { readFileSync as readFileSync33, existsSync as
|
|
60378
|
-
import { join as
|
|
60554
|
+
import { readFileSync as readFileSync33, existsSync as existsSync35 } from "node:fs";
|
|
60555
|
+
import { join as join45 } from "node:path";
|
|
60379
60556
|
async function searchDocs(query, topic = "all") {
|
|
60380
60557
|
const q = String(query || "").toLowerCase();
|
|
60381
60558
|
const tokens = q.split(/\s+/).filter((t) => t.length > 0);
|
|
60382
60559
|
const enabled = resolveEnabledPacks();
|
|
60383
60560
|
const results = [];
|
|
60384
60561
|
try {
|
|
60385
|
-
if (
|
|
60562
|
+
if (existsSync35(SKILLS_ROOT)) {
|
|
60386
60563
|
const dirs = listSkillDirs(SKILLS_ROOT);
|
|
60387
60564
|
for (const dir of dirs) {
|
|
60388
60565
|
const owner = SKILL_OWNER.get(dir);
|
|
60389
60566
|
if (owner && !enabled.has(owner))
|
|
60390
60567
|
continue;
|
|
60391
|
-
const skillPath =
|
|
60392
|
-
if (!
|
|
60568
|
+
const skillPath = join45(SKILLS_ROOT, dir, "SKILL.md");
|
|
60569
|
+
if (!existsSync35(skillPath))
|
|
60393
60570
|
continue;
|
|
60394
60571
|
const content = readFileSync33(skillPath, "utf8");
|
|
60395
60572
|
const fm = parseSkillFrontmatter(content);
|
|
@@ -60454,12 +60631,13 @@ async function callTool(name, rawArgs = {}, opts = {}) {
|
|
|
60454
60631
|
const args = normalizeNumericArgs(rawArgs);
|
|
60455
60632
|
const toolValue = toolInvokeValue(name, args);
|
|
60456
60633
|
trackToolInvoke(name, toolValue);
|
|
60634
|
+
const paramWarnings = unknownParamWarnings(args, toolArgKeys(name));
|
|
60457
60635
|
if (!traceEnabled())
|
|
60458
|
-
return dispatchTool(name, args, opts);
|
|
60636
|
+
return attachParamWarnings(await dispatchTool(name, args, opts), paramWarnings);
|
|
60459
60637
|
try {
|
|
60460
60638
|
const result = await dispatchTool(name, args, opts);
|
|
60461
60639
|
recordToolCall(name, args, true);
|
|
60462
|
-
return result;
|
|
60640
|
+
return attachParamWarnings(result, paramWarnings);
|
|
60463
60641
|
} catch (error62) {
|
|
60464
60642
|
recordToolCall(name, args, false, error62);
|
|
60465
60643
|
throw error62;
|
|
@@ -60510,7 +60688,10 @@ function hookResult(result) {
|
|
|
60510
60688
|
ok: result.decision !== "deny",
|
|
60511
60689
|
decision: result.decision,
|
|
60512
60690
|
findings: result.findings,
|
|
60513
|
-
|
|
60691
|
+
// allow means "no rule matched", never "approved": make that explicit so
|
|
60692
|
+
// an agent cannot read a green advisory check as a safety verdict.
|
|
60693
|
+
...result.decision === "allow" ? { unmatched: true } : {},
|
|
60694
|
+
nextStep: result.decision === "deny" ? "Revise the command, artifact, or deployment plan before execution." : result.decision === "warn" ? "Review the warnings with the user before proceeding." : "No Huawei Cloud hook risk rule matched. This is not a safety verdict or an approval."
|
|
60514
60695
|
};
|
|
60515
60696
|
}
|
|
60516
60697
|
function withUnknownOperationWarn(command, result, classify2 = classifyTextCommand) {
|
|
@@ -60522,6 +60703,9 @@ function withUnknownOperationWarn(command, result, classify2 = classifyTextComma
|
|
|
60522
60703
|
} catch {
|
|
60523
60704
|
return { ...result, decision: "warn", findings: [unverifiedFinding(command)] };
|
|
60524
60705
|
}
|
|
60706
|
+
if (classification?.risk === "write" || classification?.risk === "execution") {
|
|
60707
|
+
return { ...result, decision: "warn", findings: [writeOperationFinding(command)] };
|
|
60708
|
+
}
|
|
60525
60709
|
if (classification?.risk !== "unknown_read")
|
|
60526
60710
|
return result;
|
|
60527
60711
|
const triage = triageUnknownService(classification.service);
|
|
@@ -60545,7 +60729,7 @@ function withUnknownOperationWarn(command, result, classify2 = classifyTextComma
|
|
|
60545
60729
|
}
|
|
60546
60730
|
return { ...result, decision: "warn", findings: [unknownOperationFinding(command)] };
|
|
60547
60731
|
}
|
|
60548
|
-
var NUMERIC_ARG_KEYS, unknownOperationFinding, unverifiedFinding;
|
|
60732
|
+
var NUMERIC_ARG_KEYS, unknownOperationFinding, unverifiedFinding, writeOperationFinding;
|
|
60549
60733
|
var init_tools10 = __esm({
|
|
60550
60734
|
"plugins/huaweicloud-core/dist.new/tools.js"() {
|
|
60551
60735
|
"use strict";
|
|
@@ -60558,8 +60742,10 @@ var init_tools10 = __esm({
|
|
|
60558
60742
|
init_availability();
|
|
60559
60743
|
init_registry();
|
|
60560
60744
|
init_skill_tree();
|
|
60745
|
+
init_param_warnings();
|
|
60561
60746
|
init_call_trace();
|
|
60562
60747
|
init_tool_definitions();
|
|
60748
|
+
init_tool_schemas();
|
|
60563
60749
|
init_vendor_gate();
|
|
60564
60750
|
init_capability_catalog();
|
|
60565
60751
|
init_packs_configure();
|
|
@@ -60594,6 +60780,16 @@ var init_tools10 = __esm({
|
|
|
60594
60780
|
source: "command",
|
|
60595
60781
|
evidence: command.slice(0, 240)
|
|
60596
60782
|
});
|
|
60783
|
+
writeOperationFinding = (command) => ({
|
|
60784
|
+
ruleId: "hwc-write-operation",
|
|
60785
|
+
title: "Write or execution operation",
|
|
60786
|
+
category: "approval",
|
|
60787
|
+
severity: "warn",
|
|
60788
|
+
message: "This command is classified as a write or execution operation. Raw shell execution is blocked; writes require a plan and explicit user approval.",
|
|
60789
|
+
remediation: "Plan the exact command with huaweicloud_plan_cli_command, show it to the user, obtain explicit approval, then run it with huaweicloud_run_approved_command and the approval token.",
|
|
60790
|
+
source: "command",
|
|
60791
|
+
evidence: command.slice(0, 240)
|
|
60792
|
+
});
|
|
60597
60793
|
}
|
|
60598
60794
|
});
|
|
60599
60795
|
|
|
@@ -61383,9 +61579,9 @@ data:
|
|
|
61383
61579
|
const initRequest = messages.find((m) => isInitializeRequest(m));
|
|
61384
61580
|
const clientProtocolVersion = initRequest ? initRequest.params.protocolVersion : req.headers.get("mcp-protocol-version") ?? DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
|
|
61385
61581
|
if (this._enableJsonResponse) {
|
|
61386
|
-
return new Promise((
|
|
61582
|
+
return new Promise((resolve10) => {
|
|
61387
61583
|
this._streamMapping.set(streamId, {
|
|
61388
|
-
resolveJson:
|
|
61584
|
+
resolveJson: resolve10,
|
|
61389
61585
|
cleanup: () => {
|
|
61390
61586
|
this._streamMapping.delete(streamId);
|
|
61391
61587
|
}
|
|
@@ -61810,8 +62006,8 @@ var init_mcp_server_remote = __esm({
|
|
|
61810
62006
|
});
|
|
61811
62007
|
|
|
61812
62008
|
// plugins/huaweicloud-core/dist.new/mcp-server.js
|
|
61813
|
-
import { rmSync as
|
|
61814
|
-
import { resolve as
|
|
62009
|
+
import { rmSync as rmSync11, existsSync as existsSync37 } from "node:fs";
|
|
62010
|
+
import { resolve as resolve9, dirname as dirname27 } from "node:path";
|
|
61815
62011
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
61816
62012
|
|
|
61817
62013
|
// plugins/huaweicloud-core/dist.new/mcp-stdio-transport.js
|
|
@@ -62000,15 +62196,15 @@ init_update_check();
|
|
|
62000
62196
|
init_hcloud_probe();
|
|
62001
62197
|
init_koocli_paths();
|
|
62002
62198
|
import { spawn as spawn4 } from "node:child_process";
|
|
62003
|
-
import { appendFileSync as appendFileSync5, closeSync, existsSync as
|
|
62004
|
-
import { dirname as
|
|
62199
|
+
import { appendFileSync as appendFileSync5, closeSync, existsSync as existsSync36, mkdirSync as mkdirSync16, openSync, readFileSync as readFileSync34, rmSync as rmSync10, statSync as statSync10, writeFileSync as writeFileSync16 } from "node:fs";
|
|
62200
|
+
import { dirname as dirname26, join as join46 } from "node:path";
|
|
62005
62201
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
62006
|
-
var __dirname9 =
|
|
62202
|
+
var __dirname9 = dirname26(fileURLToPath11(import.meta.url));
|
|
62007
62203
|
var INSTALL_LOCK_TTL_MS = 15 * 60 * 1e3;
|
|
62008
62204
|
var INSTALL_LOG_MAX_BYTES = 1024 * 1024;
|
|
62009
62205
|
var INSTALL_FAILURE_COOLDOWN_MS = 24 * 60 * 60 * 1e3;
|
|
62010
62206
|
function failureMarkerPath() {
|
|
62011
|
-
return
|
|
62207
|
+
return join46(dirname26(kooCliInstallLockPath()), ".koocli-install.failed");
|
|
62012
62208
|
}
|
|
62013
62209
|
function lockIsStale(body) {
|
|
62014
62210
|
const ts = Number(body.trim());
|
|
@@ -62018,7 +62214,7 @@ function lockIsStale(body) {
|
|
|
62018
62214
|
}
|
|
62019
62215
|
function acquireInstallLock(lockPath = kooCliInstallLockPath()) {
|
|
62020
62216
|
try {
|
|
62021
|
-
|
|
62217
|
+
mkdirSync16(dirname26(lockPath), { recursive: true });
|
|
62022
62218
|
let replace = false;
|
|
62023
62219
|
try {
|
|
62024
62220
|
replace = lockIsStale(String(readFileSync34(lockPath, "utf8")));
|
|
@@ -62026,7 +62222,7 @@ function acquireInstallLock(lockPath = kooCliInstallLockPath()) {
|
|
|
62026
62222
|
}
|
|
62027
62223
|
if (replace) {
|
|
62028
62224
|
try {
|
|
62029
|
-
|
|
62225
|
+
rmSync10(lockPath, { force: true });
|
|
62030
62226
|
} catch (error62) {
|
|
62031
62227
|
return { acquired: false, reason: `stale lock cleanup failed: ${error62.message}` };
|
|
62032
62228
|
}
|
|
@@ -62048,25 +62244,25 @@ function releaseInstallLock(lockPath = kooCliInstallLockPath(), ownedTs) {
|
|
|
62048
62244
|
if (body !== String(ownedTs))
|
|
62049
62245
|
return;
|
|
62050
62246
|
}
|
|
62051
|
-
|
|
62247
|
+
rmSync10(lockPath, { force: true });
|
|
62052
62248
|
} catch {
|
|
62053
62249
|
}
|
|
62054
62250
|
}
|
|
62055
62251
|
function openKooCliInstallLog(logPath = kooCliInstallLogPath()) {
|
|
62056
62252
|
try {
|
|
62057
|
-
const st =
|
|
62253
|
+
const st = existsSync36(logPath) ? statSync10(logPath) : null;
|
|
62058
62254
|
if (st && st.size > INSTALL_LOG_MAX_BYTES)
|
|
62059
|
-
|
|
62060
|
-
|
|
62255
|
+
rmSync10(logPath, { force: true });
|
|
62256
|
+
mkdirSync16(dirname26(logPath), { recursive: true });
|
|
62061
62257
|
} catch {
|
|
62062
62258
|
}
|
|
62063
62259
|
return openSync(logPath, "a", 384);
|
|
62064
62260
|
}
|
|
62065
62261
|
function resolvePreinstallCliEntry() {
|
|
62066
|
-
const compiled =
|
|
62067
|
-
if (
|
|
62262
|
+
const compiled = join46(__dirname9, "setup-cli.js");
|
|
62263
|
+
if (existsSync36(compiled))
|
|
62068
62264
|
return compiled;
|
|
62069
|
-
return
|
|
62265
|
+
return join46(__dirname9, "setup-cli.ts");
|
|
62070
62266
|
}
|
|
62071
62267
|
var spawnForTests = null;
|
|
62072
62268
|
var installStarted = false;
|
|
@@ -62080,7 +62276,7 @@ function maybePreinstallKooCli({ force = false } = {}) {
|
|
|
62080
62276
|
return { launched: false, reason: "already installed" };
|
|
62081
62277
|
}
|
|
62082
62278
|
try {
|
|
62083
|
-
if (
|
|
62279
|
+
if (existsSync36(failureMarkerPath())) {
|
|
62084
62280
|
const ts = Number(String(readFileSync34(failureMarkerPath(), "utf8")).trim());
|
|
62085
62281
|
if (Number.isFinite(ts) && Date.now() - ts < INSTALL_FAILURE_COOLDOWN_MS) {
|
|
62086
62282
|
return { launched: false, reason: "cooldown after an unsuccessful install attempt" };
|
|
@@ -62103,7 +62299,7 @@ function maybePreinstallKooCli({ force = false } = {}) {
|
|
|
62103
62299
|
const releaseOwned = () => releaseInstallLock(kooCliInstallLockPath(), ownedTs);
|
|
62104
62300
|
installStarted = true;
|
|
62105
62301
|
const entryPath = resolvePreinstallCliEntry();
|
|
62106
|
-
if (!
|
|
62302
|
+
if (!existsSync36(entryPath)) {
|
|
62107
62303
|
releaseOwned();
|
|
62108
62304
|
console.error(`[preflight] install entry missing: ${entryPath}`);
|
|
62109
62305
|
return { launched: false, reason: `install entry missing: ${entryPath}` };
|
|
@@ -62184,10 +62380,10 @@ try {
|
|
|
62184
62380
|
} catch {
|
|
62185
62381
|
}
|
|
62186
62382
|
try {
|
|
62187
|
-
const pluginDir =
|
|
62188
|
-
const marker =
|
|
62189
|
-
if (
|
|
62190
|
-
|
|
62383
|
+
const pluginDir = resolve9(dirname27(fileURLToPath12(import.meta.url)), "..");
|
|
62384
|
+
const marker = resolve9(pluginDir, ".installed");
|
|
62385
|
+
if (existsSync37(marker))
|
|
62386
|
+
rmSync11(marker, { force: true });
|
|
62191
62387
|
} catch {
|
|
62192
62388
|
}
|
|
62193
62389
|
if (transport === "remote") {
|