huaweicloud-devkit 2.0.0-next.1 → 2.0.0-next.3
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 +3 -1
- 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/agents/opencode-config.js +73 -2
- package/plugins/huaweicloud-core/dist/agents/opencode.js +62 -1
- package/plugins/huaweicloud-core/dist/auth/s1-store.js +43 -22
- package/plugins/huaweicloud-core/dist/hcloud-plan.js +25 -5
- package/plugins/huaweicloud-core/dist/lib/approval-mode.js +30 -0
- package/plugins/huaweicloud-core/dist/lib/approval-tokens.js +3 -3
- package/plugins/huaweicloud-core/dist/lib/opencode-ask-rule.js +116 -0
- 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-protocol.js +20 -1
- package/plugins/huaweicloud-core/dist/mcp-server.js +849 -585
- package/plugins/huaweicloud-core/dist/mcp-server.js.map +4 -4
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/tools.js +74 -22
- package/plugins/huaweicloud-core/dist/setup-cli.js +22 -3
- 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/skills/huaweicloud-cli-and-auth/SKILL.md +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +8 -7
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/approvals.md +10 -0
- 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/agents/opencode-config.ts +82 -2
- package/plugins/huaweicloud-core/src/agents/opencode.ts +86 -1
- package/plugins/huaweicloud-core/src/auth/s1-store.ts +41 -20
- package/plugins/huaweicloud-core/src/hcloud-plan.ts +38 -6
- package/plugins/huaweicloud-core/src/lib/approval-mode.ts +32 -0
- package/plugins/huaweicloud-core/src/lib/approval-tokens.ts +3 -3
- package/plugins/huaweicloud-core/src/lib/opencode-ask-rule.ts +131 -0
- 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/mcp-protocol.ts +20 -1
- package/plugins/huaweicloud-core/src/mcp-server.ts +13 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-cli/tools.ts +81 -24
- package/plugins/huaweicloud-core/src/setup-cli.ts +27 -2
- 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);
|
|
@@ -55635,7 +55735,8 @@ function planHcloudCommand(args, options = {}) {
|
|
|
55635
55735
|
warnings.push(`${triage.message} ${triage.nextStep}`);
|
|
55636
55736
|
}
|
|
55637
55737
|
}
|
|
55638
|
-
const
|
|
55738
|
+
const approvalMode = options.approvalMode ?? "token";
|
|
55739
|
+
const approvalToken = approvalMode === "ask" || options.mintApprovalToken === false ? void 0 : createApprovalToken(normalizedArgs, {
|
|
55639
55740
|
secretsSubstitutable: secretsSubstitutable(normalizedArgs),
|
|
55640
55741
|
argsPinView: pinViewArgs(normalizedArgs)
|
|
55641
55742
|
});
|
|
@@ -55655,7 +55756,13 @@ function planHcloudCommand(args, options = {}) {
|
|
|
55655
55756
|
...approvalToken !== void 0 ? { approvalToken } : {},
|
|
55656
55757
|
// `command` exists only where a token was minted: a run-path plan stays
|
|
55657
55758
|
// silent rather than name a line for a token the run cannot offer.
|
|
55658
|
-
|
|
55759
|
+
// Ask mode names the posture instead — the confirmation happens at the
|
|
55760
|
+
// run call, and the note teaches exactly that.
|
|
55761
|
+
userConfirmation: needsConfirmation ? approvalMode === "ask" ? {
|
|
55762
|
+
needed: true,
|
|
55763
|
+
mode: "ask",
|
|
55764
|
+
note: "The harness client confirms this command with the user when huaweicloud_run_approved_command is called. Call it with the same args and approvedByUser: true. No terminal approval line or token is needed."
|
|
55765
|
+
} : {
|
|
55659
55766
|
needed: true,
|
|
55660
55767
|
...approvalToken !== void 0 ? { command: `npx huaweicloud-devkit approve ${approvalToken}` } : {}
|
|
55661
55768
|
} : { needed: false },
|
|
@@ -55707,14 +55814,14 @@ var init_hcloud_plan = __esm({
|
|
|
55707
55814
|
|
|
55708
55815
|
// plugins/huaweicloud-core/dist.new/hcloud-run-once.js
|
|
55709
55816
|
import { spawn as spawn2 } from "node:child_process";
|
|
55710
|
-
import { mkdirSync as
|
|
55711
|
-
import { join as
|
|
55817
|
+
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync13 } from "node:fs";
|
|
55818
|
+
import { join as join35 } from "node:path";
|
|
55712
55819
|
function saveLargeOutput(rawStdout) {
|
|
55713
55820
|
if (rawStdout.length <= LARGE_OUTPUT_THRESHOLD)
|
|
55714
55821
|
return null;
|
|
55715
55822
|
try {
|
|
55716
|
-
|
|
55717
|
-
const filePath =
|
|
55823
|
+
mkdirSync15(OUTPUT_DIR, { recursive: true });
|
|
55824
|
+
const filePath = join35(OUTPUT_DIR, `output-${Date.now()}.json`);
|
|
55718
55825
|
writeFileSync13(filePath, rawStdout, { encoding: "utf8" });
|
|
55719
55826
|
return filePath;
|
|
55720
55827
|
} catch {
|
|
@@ -55734,7 +55841,7 @@ function runHcloudOnce(plan, options) {
|
|
|
55734
55841
|
const childOptions = { ...options };
|
|
55735
55842
|
delete childOptions.metaDir;
|
|
55736
55843
|
const childEnv = { ...process.env, ...childOptions.env };
|
|
55737
|
-
return new Promise((
|
|
55844
|
+
return new Promise((resolve10) => {
|
|
55738
55845
|
const proxySettings = getProxySettings();
|
|
55739
55846
|
const proxyEnv = {};
|
|
55740
55847
|
if (proxySettings) {
|
|
@@ -55793,7 +55900,7 @@ function runHcloudOnce(plan, options) {
|
|
|
55793
55900
|
};
|
|
55794
55901
|
result.plan = redactedPlan;
|
|
55795
55902
|
}
|
|
55796
|
-
|
|
55903
|
+
resolve10(result);
|
|
55797
55904
|
}
|
|
55798
55905
|
const timer = setTimeout(() => {
|
|
55799
55906
|
timedOut = true;
|
|
@@ -55901,7 +56008,7 @@ var init_hcloud_run_once = __esm({
|
|
|
55901
56008
|
DEFAULT_TIMEOUT_MS = 6e4;
|
|
55902
56009
|
DEFAULT_FORCE_KILL_AFTER_MS = 2e3;
|
|
55903
56010
|
LARGE_OUTPUT_THRESHOLD = 5e4;
|
|
55904
|
-
OUTPUT_DIR =
|
|
56011
|
+
OUTPUT_DIR = join35("/tmp", "huaweicloud-devkit");
|
|
55905
56012
|
}
|
|
55906
56013
|
});
|
|
55907
56014
|
|
|
@@ -55982,7 +56089,7 @@ ${result.stderr || ""}`;
|
|
|
55982
56089
|
return /\[NETWORK_ERROR\]|connection timed out|ECONNRESET|ETIMEDOUT|temporary failure|TLS handshake timeout/i.test(text);
|
|
55983
56090
|
}
|
|
55984
56091
|
function wait(ms) {
|
|
55985
|
-
return new Promise((
|
|
56092
|
+
return new Promise((resolve10) => setTimeout(resolve10, ms));
|
|
55986
56093
|
}
|
|
55987
56094
|
var DEFAULT_MAX_RETRIES;
|
|
55988
56095
|
var init_hcloud_run = __esm({
|
|
@@ -56383,9 +56490,9 @@ var init_pack3 = __esm({
|
|
|
56383
56490
|
});
|
|
56384
56491
|
|
|
56385
56492
|
// plugins/huaweicloud-core/dist.new/packs/obs/tools.js
|
|
56386
|
-
import { existsSync as
|
|
56387
|
-
import { homedir as
|
|
56388
|
-
import { join as
|
|
56493
|
+
import { existsSync as existsSync28, writeFileSync as writeFileSync14 } from "node:fs";
|
|
56494
|
+
import { homedir as homedir21 } from "node:os";
|
|
56495
|
+
import { join as join36 } from "node:path";
|
|
56389
56496
|
import { createHash as createHash8, createHmac as createHmac4 } from "node:crypto";
|
|
56390
56497
|
function pickString(...values) {
|
|
56391
56498
|
for (const value of values) {
|
|
@@ -56424,8 +56531,8 @@ async function setupObsConfig(profile) {
|
|
|
56424
56531
|
return setupObsConfigFromHcloud(profile);
|
|
56425
56532
|
}
|
|
56426
56533
|
async function setupObsConfigFromHcloud(profile) {
|
|
56427
|
-
const obsConfigPath2 =
|
|
56428
|
-
if (
|
|
56534
|
+
const obsConfigPath2 = join36(homedir21(), ".obsutilconfig");
|
|
56535
|
+
if (existsSync28(obsConfigPath2)) {
|
|
56429
56536
|
return {
|
|
56430
56537
|
ok: true,
|
|
56431
56538
|
existed: true,
|
|
@@ -57104,7 +57211,7 @@ var init_search_market = __esm({
|
|
|
57104
57211
|
|
|
57105
57212
|
// plugins/huaweicloud-core/dist.new/icon-library.js
|
|
57106
57213
|
import { readFileSync as readFileSync28 } from "node:fs";
|
|
57107
|
-
import { join as
|
|
57214
|
+
import { join as join37, dirname as dirname24 } from "node:path";
|
|
57108
57215
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
57109
57216
|
function toIconLogo(value) {
|
|
57110
57217
|
const raw = asRecord(value);
|
|
@@ -57291,8 +57398,8 @@ var init_icon_library = __esm({
|
|
|
57291
57398
|
"use strict";
|
|
57292
57399
|
init_proxy_agent();
|
|
57293
57400
|
init_as_record();
|
|
57294
|
-
__dirname7 =
|
|
57295
|
-
SNAPSHOT_PATH =
|
|
57401
|
+
__dirname7 = dirname24(fileURLToPath9(import.meta.url));
|
|
57402
|
+
SNAPSHOT_PATH = join37(__dirname7, "data", "icons-manifest.v1.json");
|
|
57296
57403
|
MANIFEST_URL = "https://open.huaweicloud.com/openplatform/icons/manifest.v1.json";
|
|
57297
57404
|
ICONS_PAGE_URL = "https://open.huaweicloud.com/openplatform/icons.html";
|
|
57298
57405
|
HTTP_TIMEOUT_MS2 = 1e4;
|
|
@@ -57302,11 +57409,11 @@ var init_icon_library = __esm({
|
|
|
57302
57409
|
});
|
|
57303
57410
|
|
|
57304
57411
|
// plugins/huaweicloud-core/dist.new/detect-framework-pkg.js
|
|
57305
|
-
import { existsSync as
|
|
57306
|
-
import { join as
|
|
57412
|
+
import { existsSync as existsSync29, readFileSync as readFileSync29 } from "node:fs";
|
|
57413
|
+
import { join as join38 } from "node:path";
|
|
57307
57414
|
function readPkg(projectPath) {
|
|
57308
|
-
const pkgPath =
|
|
57309
|
-
if (!
|
|
57415
|
+
const pkgPath = join38(projectPath, "package.json");
|
|
57416
|
+
if (!existsSync29(pkgPath))
|
|
57310
57417
|
return null;
|
|
57311
57418
|
try {
|
|
57312
57419
|
const parsed = JSON.parse(readFileSync29(pkgPath, "utf8"));
|
|
@@ -57318,13 +57425,13 @@ function readPkg(projectPath) {
|
|
|
57318
57425
|
}
|
|
57319
57426
|
}
|
|
57320
57427
|
function detectPackageManager(projectPath, pkg) {
|
|
57321
|
-
if (
|
|
57428
|
+
if (existsSync29(join38(projectPath, "pnpm-lock.yaml")))
|
|
57322
57429
|
return "pnpm";
|
|
57323
|
-
if (
|
|
57430
|
+
if (existsSync29(join38(projectPath, "yarn.lock")))
|
|
57324
57431
|
return "yarn";
|
|
57325
|
-
if (
|
|
57432
|
+
if (existsSync29(join38(projectPath, "package-lock.json")))
|
|
57326
57433
|
return "npm";
|
|
57327
|
-
if (
|
|
57434
|
+
if (existsSync29(join38(projectPath, "bun.lockb")))
|
|
57328
57435
|
return "bun";
|
|
57329
57436
|
const declaredValue = pkg?.packageManager;
|
|
57330
57437
|
const declared = typeof declaredValue === "string" ? declaredValue.split("@")[0] : "";
|
|
@@ -57340,8 +57447,8 @@ function collectDeps(pkg) {
|
|
|
57340
57447
|
function readVitepressOutDir(projectPath) {
|
|
57341
57448
|
const configFiles = ["config.mts", "config.ts", "config.mjs", "config.js"];
|
|
57342
57449
|
for (const cf of configFiles) {
|
|
57343
|
-
const configPath =
|
|
57344
|
-
if (!
|
|
57450
|
+
const configPath = join38(projectPath, ".vitepress", cf);
|
|
57451
|
+
if (!existsSync29(configPath))
|
|
57345
57452
|
continue;
|
|
57346
57453
|
try {
|
|
57347
57454
|
const content = readFileSync29(configPath, "utf8");
|
|
@@ -57355,8 +57462,8 @@ function readVitepressOutDir(projectPath) {
|
|
|
57355
57462
|
}
|
|
57356
57463
|
function resolveAngularOutput(projectPath, pkg) {
|
|
57357
57464
|
try {
|
|
57358
|
-
const angularJson =
|
|
57359
|
-
if (
|
|
57465
|
+
const angularJson = join38(projectPath, "angular.json");
|
|
57466
|
+
if (existsSync29(angularJson)) {
|
|
57360
57467
|
const config2 = asRecord(JSON.parse(readFileSync29(angularJson, "utf8")));
|
|
57361
57468
|
const projects = asRecord(config2.projects);
|
|
57362
57469
|
const defaultProjectValue = config2.defaultProject;
|
|
@@ -57536,13 +57643,13 @@ var init_detect_framework_table = __esm({
|
|
|
57536
57643
|
});
|
|
57537
57644
|
|
|
57538
57645
|
// plugins/huaweicloud-core/dist.new/detect-framework-match.js
|
|
57539
|
-
import { existsSync as
|
|
57540
|
-
import { join as
|
|
57646
|
+
import { existsSync as existsSync30 } from "node:fs";
|
|
57647
|
+
import { join as join39 } from "node:path";
|
|
57541
57648
|
function matchFrameworkSpec(projectPath, pkg, deps) {
|
|
57542
|
-
if (
|
|
57649
|
+
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
57650
|
return FRAMEWORKS.nextjs;
|
|
57544
57651
|
}
|
|
57545
|
-
if (
|
|
57652
|
+
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
57653
|
return FRAMEWORKS.nuxt;
|
|
57547
57654
|
}
|
|
57548
57655
|
if ("@tarojs/taro" in deps) {
|
|
@@ -57551,35 +57658,35 @@ function matchFrameworkSpec(projectPath, pkg, deps) {
|
|
|
57551
57658
|
if ("@dcloudio/uni-app" in deps || "uni-app" in deps) {
|
|
57552
57659
|
return FRAMEWORKS.uniapp;
|
|
57553
57660
|
}
|
|
57554
|
-
if (
|
|
57661
|
+
if (existsSync30(join39(projectPath, ".vitepress"))) {
|
|
57555
57662
|
const outDir = readVitepressOutDir(projectPath);
|
|
57556
57663
|
return outDir ? { ...FRAMEWORKS.vitepress, outputDir: outDir } : FRAMEWORKS.vitepress;
|
|
57557
57664
|
}
|
|
57558
|
-
if (
|
|
57665
|
+
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
57666
|
return FRAMEWORKS.docusaurus;
|
|
57560
57667
|
}
|
|
57561
|
-
if (
|
|
57668
|
+
if (existsSync30(join39(projectPath, "hugo.toml")) || existsSync30(join39(projectPath, "config.toml"))) {
|
|
57562
57669
|
return FRAMEWORKS.hugo;
|
|
57563
57670
|
}
|
|
57564
|
-
if (
|
|
57671
|
+
if (existsSync30(join39(projectPath, "_config.yml"))) {
|
|
57565
57672
|
return FRAMEWORKS.hexo;
|
|
57566
57673
|
}
|
|
57567
|
-
if (
|
|
57674
|
+
if (existsSync30(join39(projectPath, "angular.json"))) {
|
|
57568
57675
|
const outputDir = resolveAngularOutput(projectPath, pkg);
|
|
57569
57676
|
return { ...FRAMEWORKS.angular, outputDir };
|
|
57570
57677
|
}
|
|
57571
|
-
if (
|
|
57678
|
+
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
57679
|
return FRAMEWORKS.vite;
|
|
57573
57680
|
}
|
|
57574
57681
|
if ("@vue/cli-service" in deps) {
|
|
57575
57682
|
return FRAMEWORKS.vueCli;
|
|
57576
57683
|
}
|
|
57577
57684
|
if ("react-scripts" in deps || "react" in deps || "@angular/core" in deps || "vue" in deps || "svelte" in deps || "solid-js" in deps) {
|
|
57578
|
-
if (
|
|
57685
|
+
if (existsSync30(join39(projectPath, "public", "index.html")) || existsSync30(join39(projectPath, "index.html"))) {
|
|
57579
57686
|
return FRAMEWORKS.cra;
|
|
57580
57687
|
}
|
|
57581
57688
|
}
|
|
57582
|
-
if (
|
|
57689
|
+
if (existsSync30(join39(projectPath, "index.html")) || existsSync30(join39(projectPath, "public", "index.html")) || existsSync30(join39(projectPath, "src", "index.html"))) {
|
|
57583
57690
|
return FRAMEWORKS.static;
|
|
57584
57691
|
}
|
|
57585
57692
|
if (pkg) {
|
|
@@ -57596,7 +57703,7 @@ function matchFrameworkSpec(projectPath, pkg, deps) {
|
|
|
57596
57703
|
"src/index.jsx",
|
|
57597
57704
|
"src/index.tsx"
|
|
57598
57705
|
];
|
|
57599
|
-
const hasEntry = entryPoints.some((p) =>
|
|
57706
|
+
const hasEntry = entryPoints.some((p) => existsSync30(join39(projectPath, p)));
|
|
57600
57707
|
if (hasEntry) {
|
|
57601
57708
|
if ("vue" in deps || "@vue/cli-service" in deps) {
|
|
57602
57709
|
return FRAMEWORKS.vueCli;
|
|
@@ -57620,20 +57727,20 @@ var init_detect_framework_match = __esm({
|
|
|
57620
57727
|
});
|
|
57621
57728
|
|
|
57622
57729
|
// plugins/huaweicloud-core/dist.new/detect-framework-scan.js
|
|
57623
|
-
import { existsSync as
|
|
57624
|
-
import { join as
|
|
57730
|
+
import { existsSync as existsSync31, readdirSync as readdirSync5 } from "node:fs";
|
|
57731
|
+
import { join as join40 } from "node:path";
|
|
57625
57732
|
function scanSubApps(projectPath) {
|
|
57626
57733
|
const apps = [];
|
|
57627
57734
|
for (const dir of ["apps", "packages"]) {
|
|
57628
|
-
const dirPath =
|
|
57629
|
-
if (!
|
|
57735
|
+
const dirPath = join40(projectPath, dir);
|
|
57736
|
+
if (!existsSync31(dirPath))
|
|
57630
57737
|
continue;
|
|
57631
57738
|
try {
|
|
57632
57739
|
const entries = readdirSync5(dirPath, { withFileTypes: true });
|
|
57633
57740
|
for (const entry of entries) {
|
|
57634
57741
|
if (!entry.isDirectory())
|
|
57635
57742
|
continue;
|
|
57636
|
-
const subPath =
|
|
57743
|
+
const subPath = join40(dirPath, entry.name);
|
|
57637
57744
|
const subPkg = readPkg(subPath);
|
|
57638
57745
|
if (!subPkg)
|
|
57639
57746
|
continue;
|
|
@@ -57681,12 +57788,12 @@ function detectFramework(projectPath) {
|
|
|
57681
57788
|
const pkg = readPkg(projectPath);
|
|
57682
57789
|
const deps = collectDeps(pkg);
|
|
57683
57790
|
const pm = detectPackageManager(projectPath, pkg);
|
|
57684
|
-
if (
|
|
57791
|
+
if (existsSync31(join40(projectPath, "pnpm-workspace.yaml")) || existsSync31(join40(projectPath, "turbo.json")) || existsSync31(join40(projectPath, "nx.json")) || existsSync31(join40(projectPath, "lerna.json"))) {
|
|
57685
57792
|
const monorepoSubApps = scanSubApps(projectPath);
|
|
57686
57793
|
return {
|
|
57687
57794
|
type: "monorepo",
|
|
57688
57795
|
framework: "Monorepo",
|
|
57689
|
-
monorepoTool:
|
|
57796
|
+
monorepoTool: existsSync31(join40(projectPath, "turbo.json")) ? "Turborepo" : existsSync31(join40(projectPath, "nx.json")) ? "Nx" : existsSync31(join40(projectPath, "lerna.json")) ? "Lerna" : "pnpm Workspace",
|
|
57690
57797
|
subApps: monorepoSubApps,
|
|
57691
57798
|
packageManager: pm,
|
|
57692
57799
|
rootDir: projectPath
|
|
@@ -57796,6 +57903,23 @@ var init_pack6 = __esm({
|
|
|
57796
57903
|
}
|
|
57797
57904
|
});
|
|
57798
57905
|
|
|
57906
|
+
// plugins/huaweicloud-core/dist.new/lib/approval-mode.js
|
|
57907
|
+
function approvalModeFromEnv(env) {
|
|
57908
|
+
const raw = env[APPROVAL_MODE_ENV];
|
|
57909
|
+
if (raw === void 0 || raw === "")
|
|
57910
|
+
return "token";
|
|
57911
|
+
if (raw === "ask" || raw === "token")
|
|
57912
|
+
return raw;
|
|
57913
|
+
throw new Error(`DEVKIT_APPROVAL_MODE must be "ask" or "token" (got "${raw}")`);
|
|
57914
|
+
}
|
|
57915
|
+
var APPROVAL_MODE_ENV;
|
|
57916
|
+
var init_approval_mode = __esm({
|
|
57917
|
+
"plugins/huaweicloud-core/dist.new/lib/approval-mode.js"() {
|
|
57918
|
+
"use strict";
|
|
57919
|
+
APPROVAL_MODE_ENV = "DEVKIT_APPROVAL_MODE";
|
|
57920
|
+
}
|
|
57921
|
+
});
|
|
57922
|
+
|
|
57799
57923
|
// plugins/huaweicloud-core/dist.new/packs/huaweicloud-cli/tools.js
|
|
57800
57924
|
async function runVersionCheck(options = {}) {
|
|
57801
57925
|
const result = probeHcloud(options);
|
|
@@ -57899,10 +58023,41 @@ async function listOperations(service, options = {}) {
|
|
|
57899
58023
|
result
|
|
57900
58024
|
};
|
|
57901
58025
|
}
|
|
58026
|
+
function assertNoPlaceholderSecret(args, mode) {
|
|
58027
|
+
const placeholderArg = firstPlaceholderSecretArg(args);
|
|
58028
|
+
if (!placeholderArg)
|
|
58029
|
+
return;
|
|
58030
|
+
throw new Error(`The argument "${placeholderArg}" still carries a placeholder secret value: replace <redacted> with the actual value the user approved, ` + (mode === "ask" ? "then re-run." : "then re-run with the same approval token."));
|
|
58031
|
+
}
|
|
58032
|
+
function approvedRunOptions(args) {
|
|
58033
|
+
return {
|
|
58034
|
+
allowWrites: true,
|
|
58035
|
+
timeoutMs: args.timeoutMs,
|
|
58036
|
+
maxRetries: args.maxRetries,
|
|
58037
|
+
cwd: args.cwd,
|
|
58038
|
+
stdin: args.stdin
|
|
58039
|
+
};
|
|
58040
|
+
}
|
|
58041
|
+
async function runApprovedCommandAskMode(args) {
|
|
58042
|
+
const providedArgs = Array.isArray(args.args) ? args.args.map(String) : [];
|
|
58043
|
+
const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedArgs);
|
|
58044
|
+
assertNoPlaceholderSecret(effectiveArgs, "ask");
|
|
58045
|
+
const strictPlan = planHcloudCommand(effectiveArgs, {
|
|
58046
|
+
allowWrites: false,
|
|
58047
|
+
mintApprovalToken: false,
|
|
58048
|
+
approvalMode: "ask"
|
|
58049
|
+
});
|
|
58050
|
+
const result = await runHcloud2(effectiveArgs, approvedRunOptions(args));
|
|
58051
|
+
return { ...result, approved: true, plan: strictPlan };
|
|
58052
|
+
}
|
|
57902
58053
|
async function runApprovedCommand(args = {}) {
|
|
57903
58054
|
if (args.approvedByUser !== true) {
|
|
57904
58055
|
throw new Error("approvedByUser must be true after explicit user approval for this exact command.");
|
|
57905
58056
|
}
|
|
58057
|
+
const approvalMode = approvalModeFromEnv(process.env);
|
|
58058
|
+
if (approvalMode === "ask") {
|
|
58059
|
+
return runApprovedCommandAskMode(args);
|
|
58060
|
+
}
|
|
57906
58061
|
const token = String(args.approvalToken || "");
|
|
57907
58062
|
const inspection = inspectApprovalToken(token);
|
|
57908
58063
|
if (inspection.state === "already_consumed") {
|
|
@@ -57916,10 +58071,7 @@ async function runApprovedCommand(args = {}) {
|
|
|
57916
58071
|
}
|
|
57917
58072
|
const providedArgs = Array.isArray(args.args) ? args.args.map(String) : [];
|
|
57918
58073
|
const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedArgs);
|
|
57919
|
-
|
|
57920
|
-
if (placeholderArg) {
|
|
57921
|
-
throw new Error(`The argument "${placeholderArg}" still carries a placeholder secret value: replace <redacted> with the actual value the user approved, then re-run with the same approval token.`);
|
|
57922
|
-
}
|
|
58074
|
+
assertNoPlaceholderSecret(effectiveArgs, "token");
|
|
57923
58075
|
const strictPlan = planHcloudCommand(effectiveArgs, { allowWrites: false, mintApprovalToken: false });
|
|
57924
58076
|
const consumed = consumeApprovalToken(token, { requireGrant: strictPlan.userConfirmation.needed });
|
|
57925
58077
|
if (consumed.status === "grant_required") {
|
|
@@ -57946,13 +58098,7 @@ async function runApprovedCommand(args = {}) {
|
|
|
57946
58098
|
throw new Error("Secret values are pinned to the approved plan: re-run huaweicloud_plan_cli_command with the final values and re-approve.");
|
|
57947
58099
|
}
|
|
57948
58100
|
}
|
|
57949
|
-
const result = await runHcloud2(effectiveArgs,
|
|
57950
|
-
allowWrites: true,
|
|
57951
|
-
timeoutMs: args.timeoutMs,
|
|
57952
|
-
maxRetries: args.maxRetries,
|
|
57953
|
-
cwd: args.cwd,
|
|
57954
|
-
stdin: args.stdin
|
|
57955
|
-
});
|
|
58101
|
+
const result = await runHcloud2(effectiveArgs, approvedRunOptions(args));
|
|
57956
58102
|
return { ...result, approved: true, plan: strictPlan };
|
|
57957
58103
|
}
|
|
57958
58104
|
async function listRegions() {
|
|
@@ -58003,7 +58149,10 @@ async function handleCheckCli(_args = {}, _opts = {}) {
|
|
|
58003
58149
|
return runVersionCheck();
|
|
58004
58150
|
}
|
|
58005
58151
|
async function handlePlanCliCommand(args = {}, _opts = {}) {
|
|
58006
|
-
return planHcloudCommand(args.args || [], {
|
|
58152
|
+
return planHcloudCommand(args.args || [], {
|
|
58153
|
+
allowWrites: args.allowWrites === true,
|
|
58154
|
+
approvalMode: approvalModeFromEnv(process.env)
|
|
58155
|
+
});
|
|
58007
58156
|
}
|
|
58008
58157
|
async function handleRunReadonlyCommand(args = {}, _opts = {}) {
|
|
58009
58158
|
return runHcloud2(args.args || [], {
|
|
@@ -58034,6 +58183,7 @@ var init_tools7 = __esm({
|
|
|
58034
58183
|
init_hcloud_probe();
|
|
58035
58184
|
init_safety_policy();
|
|
58036
58185
|
init_as_text();
|
|
58186
|
+
init_approval_mode();
|
|
58037
58187
|
init_approval_tokens();
|
|
58038
58188
|
init_tool_schema_parts();
|
|
58039
58189
|
init_as_record();
|
|
@@ -58102,7 +58252,7 @@ var init_tools7 = __esm({
|
|
|
58102
58252
|
runApprovedCommandSchema = external_exports.looseObject({
|
|
58103
58253
|
vendorConfirmed,
|
|
58104
58254
|
args: stringArrayArg.describe("hcloud arguments, excluding the hcloud executable."),
|
|
58105
|
-
approvalToken: external_exports.string().describe("
|
|
58255
|
+
approvalToken: external_exports.string().optional().describe("Required in token-approval mode (from huaweicloud_plan_cli_command); omit in ask mode where the harness client confirms at run time."),
|
|
58106
58256
|
approvedByUser: booleanArg.describe("Must be true only after the user explicitly approves this exact command."),
|
|
58107
58257
|
timeoutMs: numericArg.optional().describe("Optional timeout in milliseconds. Defaults to 60000."),
|
|
58108
58258
|
maxRetries: numericArg.optional().describe("Optional retry count for transient network errors. Defaults to 1."),
|
|
@@ -58122,7 +58272,7 @@ var init_tools7 = __esm({
|
|
|
58122
58272
|
},
|
|
58123
58273
|
{
|
|
58124
58274
|
name: "huaweicloud_plan_cli_command",
|
|
58125
|
-
description: "Classify and plan a Huawei Cloud hcloud command without executing it. When the result's userConfirmation.needed is true, the
|
|
58275
|
+
description: "Classify and plan a Huawei Cloud hcloud command without executing it. When the result's userConfirmation.needed is true, the command waits on user confirmation before huaweicloud_run_approved_command will accept it: in the default token mode the USER runs the userConfirmation.command line (npx huaweicloud-devkit approve <approvalToken>) in their own terminal, and under DEVKIT_APPROVAL_MODE=ask the harness client itself prompts the user on the run call \u2014 no token is needed. Vendor-gated (vendorConfirmed): call only when the vendor is established \u2014 see the vendorConfirmed parameter description; when unknown, ask which cloud the user means first.",
|
|
58126
58276
|
schema: planCliCommandSchema,
|
|
58127
58277
|
handler: handlePlanCliCommand
|
|
58128
58278
|
},
|
|
@@ -58140,7 +58290,7 @@ var init_tools7 = __esm({
|
|
|
58140
58290
|
},
|
|
58141
58291
|
{
|
|
58142
58292
|
name: "huaweicloud_run_approved_command",
|
|
58143
|
-
description: "Run a write-capable hcloud command only after the exact command has been shown and explicitly approved by the user
|
|
58293
|
+
description: "Run a write-capable hcloud command only after the exact command has been shown and explicitly approved by the user. In the default token mode the user must also confirm the plan token in their own terminal (npx huaweicloud-devkit approve <token>) \u2014 a non-read command without that terminal confirmation is rejected with USER_CONFIRMATION_REQUIRED and the token stays usable. Under DEVKIT_APPROVAL_MODE=ask the harness client's permission prompt on this call is the confirmation: pass the same args with approvedByUser: true and no approvalToken. Vendor-gated (vendorConfirmed): call only when the vendor is established \u2014 see the vendorConfirmed parameter description; when unknown, ask which cloud the user means first.",
|
|
58144
58294
|
schema: runApprovedCommandSchema,
|
|
58145
58295
|
handler: handleRunApprovedCommand
|
|
58146
58296
|
},
|
|
@@ -58217,9 +58367,9 @@ var init_pack7 = __esm({
|
|
|
58217
58367
|
|
|
58218
58368
|
// plugins/huaweicloud-core/dist.new/packs/huaweicloud-open-mcp/sidecar.js
|
|
58219
58369
|
import { spawn as spawn3 } from "node:child_process";
|
|
58220
|
-
import { mkdtempSync, rmSync as
|
|
58370
|
+
import { mkdtempSync, rmSync as rmSync9 } from "node:fs";
|
|
58221
58371
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
58222
|
-
import { isAbsolute as
|
|
58372
|
+
import { isAbsolute as isAbsolute3, join as join41 } from "node:path";
|
|
58223
58373
|
function resolveGatewayCommand(env = process.env) {
|
|
58224
58374
|
const resolved = resolveDependencyCommand(DEPENDENCIES["open-mcp-gateway"].resolution, env);
|
|
58225
58375
|
if (!resolved)
|
|
@@ -58229,7 +58379,7 @@ function resolveGatewayCommand(env = process.env) {
|
|
|
58229
58379
|
function resolveGatewaySpawnArgs(env = process.env) {
|
|
58230
58380
|
for (const key of ["HUAWEICLOUD_MCP_POLICY_FILE", "HUAWEICLOUD_MCP_AUDIT_FILE"]) {
|
|
58231
58381
|
const value = (env[key] ?? "").trim();
|
|
58232
|
-
if (value !== "" && !
|
|
58382
|
+
if (value !== "" && !isAbsolute3(value)) {
|
|
58233
58383
|
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
58384
|
}
|
|
58235
58385
|
}
|
|
@@ -58248,18 +58398,18 @@ function resolveGatewaySpawnArgs(env = process.env) {
|
|
|
58248
58398
|
let provision = null;
|
|
58249
58399
|
if (policyEnv === "") {
|
|
58250
58400
|
const dir = packStateDir("huaweicloud-open-mcp", env);
|
|
58251
|
-
provision = { dir, policyPath:
|
|
58401
|
+
provision = { dir, policyPath: join41(dir, POLICY_FILE) };
|
|
58252
58402
|
args.push("--policy", provision.policyPath);
|
|
58253
58403
|
}
|
|
58254
58404
|
if (!(env.HUAWEICLOUD_MCP_LOG_FILE ?? "").trim()) {
|
|
58255
|
-
args.push("--log-file",
|
|
58405
|
+
args.push("--log-file", join41(tmpdir6(), "huaweicloud-open-mcp.log"));
|
|
58256
58406
|
}
|
|
58257
58407
|
return { args, provision };
|
|
58258
58408
|
}
|
|
58259
58409
|
function removeScratchCwd(dir) {
|
|
58260
58410
|
scratchCwds.delete(dir);
|
|
58261
58411
|
try {
|
|
58262
|
-
|
|
58412
|
+
rmSync9(dir, { recursive: true, force: true });
|
|
58263
58413
|
} catch {
|
|
58264
58414
|
}
|
|
58265
58415
|
}
|
|
@@ -58272,7 +58422,7 @@ async function spawnSidecar() {
|
|
|
58272
58422
|
if (plan.provision) {
|
|
58273
58423
|
ensurePackState("huaweicloud-open-mcp", [POLICY_FILE]);
|
|
58274
58424
|
}
|
|
58275
|
-
const scratchCwd = mkdtempSync(
|
|
58425
|
+
const scratchCwd = mkdtempSync(join41(tmpdir6(), "openmcp-gw-"));
|
|
58276
58426
|
scratchCwds.add(scratchCwd);
|
|
58277
58427
|
if (!scratchExitSweepInstalled) {
|
|
58278
58428
|
scratchExitSweepInstalled = true;
|
|
@@ -58476,12 +58626,12 @@ var init_sidecar = __esm({
|
|
|
58476
58626
|
return Promise.reject(new Error("open-mcp gateway sidecar is dead; the next call respawns it"));
|
|
58477
58627
|
}
|
|
58478
58628
|
const id = this.nextId++;
|
|
58479
|
-
return new Promise((
|
|
58629
|
+
return new Promise((resolve10, reject) => {
|
|
58480
58630
|
const timer = setTimeout(() => {
|
|
58481
58631
|
this.pending.delete(id);
|
|
58482
58632
|
reject(new Error(`open-mcp gateway ${method} timed out after ${timeoutMs}ms`));
|
|
58483
58633
|
}, timeoutMs);
|
|
58484
|
-
this.pending.set(id, { resolve:
|
|
58634
|
+
this.pending.set(id, { resolve: resolve10, reject, timer });
|
|
58485
58635
|
this.child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
|
|
58486
58636
|
`);
|
|
58487
58637
|
});
|
|
@@ -58510,11 +58660,11 @@ var init_sidecar = __esm({
|
|
|
58510
58660
|
if (!this.alive)
|
|
58511
58661
|
return;
|
|
58512
58662
|
this.kill();
|
|
58513
|
-
await new Promise((
|
|
58514
|
-
const bound = setTimeout(
|
|
58663
|
+
await new Promise((resolve10) => {
|
|
58664
|
+
const bound = setTimeout(resolve10, 4500);
|
|
58515
58665
|
this.child.once("exit", () => {
|
|
58516
58666
|
clearTimeout(bound);
|
|
58517
|
-
|
|
58667
|
+
resolve10();
|
|
58518
58668
|
});
|
|
58519
58669
|
});
|
|
58520
58670
|
}
|
|
@@ -58540,18 +58690,18 @@ var init_sidecar = __esm({
|
|
|
58540
58690
|
});
|
|
58541
58691
|
|
|
58542
58692
|
// plugins/huaweicloud-core/dist.new/packs/huaweicloud-open-mcp/approval.js
|
|
58543
|
-
import { join as
|
|
58693
|
+
import { join as join42 } from "node:path";
|
|
58544
58694
|
function resolveApprovalMode(env = process.env) {
|
|
58545
58695
|
const value = (env.HUAWEICLOUD_OPENMCP_APPROVAL ?? "").trim();
|
|
58546
58696
|
if (value === "")
|
|
58547
58697
|
return;
|
|
58548
58698
|
const operatorPath = (env.HUAWEICLOUD_MCP_POLICY_FILE ?? "").trim();
|
|
58549
|
-
const policyFile = operatorPath !== "" ? operatorPath :
|
|
58699
|
+
const policyFile = operatorPath !== "" ? operatorPath : join42(packStateDir("huaweicloud-open-mcp", env), POLICY_FILE);
|
|
58550
58700
|
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
58701
|
}
|
|
58552
58702
|
function permanentGrantReason() {
|
|
58553
58703
|
const operatorPath = (process.env.HUAWEICLOUD_MCP_POLICY_FILE ?? "").trim();
|
|
58554
|
-
const path = operatorPath !== "" ? operatorPath :
|
|
58704
|
+
const path = operatorPath !== "" ? operatorPath : join42(packStateDir("huaweicloud-open-mcp"), POLICY_FILE);
|
|
58555
58705
|
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
58706
|
}
|
|
58557
58707
|
function classify(tool, toolArgs) {
|
|
@@ -59075,13 +59225,13 @@ var init_registry = __esm({
|
|
|
59075
59225
|
});
|
|
59076
59226
|
|
|
59077
59227
|
// plugins/huaweicloud-core/dist.new/lib/skill-tree.js
|
|
59078
|
-
import { existsSync as
|
|
59079
|
-
import { join as
|
|
59228
|
+
import { existsSync as existsSync32, readdirSync as readdirSync6, readFileSync as readFileSync31 } from "node:fs";
|
|
59229
|
+
import { join as join43 } from "node:path";
|
|
59080
59230
|
function listSkillDirs(root) {
|
|
59081
|
-
if (!
|
|
59231
|
+
if (!existsSync32(root))
|
|
59082
59232
|
return [];
|
|
59083
59233
|
try {
|
|
59084
|
-
return readdirSync6(root, { withFileTypes: true }).filter((d) => (d.isDirectory() || d.isSymbolicLink()) &&
|
|
59234
|
+
return readdirSync6(root, { withFileTypes: true }).filter((d) => (d.isDirectory() || d.isSymbolicLink()) && existsSync32(join43(root, d.name, "SKILL.md"))).map((d) => d.name);
|
|
59085
59235
|
} catch {
|
|
59086
59236
|
return [];
|
|
59087
59237
|
}
|
|
@@ -59092,8 +59242,74 @@ var init_skill_tree = __esm({
|
|
|
59092
59242
|
}
|
|
59093
59243
|
});
|
|
59094
59244
|
|
|
59245
|
+
// plugins/huaweicloud-core/dist.new/lib/param-warnings.js
|
|
59246
|
+
function levenshtein(a, b) {
|
|
59247
|
+
const rows = a.length + 1;
|
|
59248
|
+
const cols = b.length + 1;
|
|
59249
|
+
const previous = new Array(cols);
|
|
59250
|
+
const current = new Array(cols);
|
|
59251
|
+
for (let j = 0; j < cols; j++)
|
|
59252
|
+
previous[j] = j;
|
|
59253
|
+
for (let i = 1; i < rows; i++) {
|
|
59254
|
+
current[0] = i;
|
|
59255
|
+
for (let j = 1; j < cols; j++) {
|
|
59256
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
59257
|
+
current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + cost);
|
|
59258
|
+
}
|
|
59259
|
+
for (let j = 0; j < cols; j++)
|
|
59260
|
+
previous[j] = current[j];
|
|
59261
|
+
}
|
|
59262
|
+
return previous[cols - 1];
|
|
59263
|
+
}
|
|
59264
|
+
function suggestParam(key, knownKeys) {
|
|
59265
|
+
let best = null;
|
|
59266
|
+
let bestDistance = SUGGESTION_DISTANCE + 1;
|
|
59267
|
+
const lowerKey = key.toLowerCase();
|
|
59268
|
+
for (const candidate of knownKeys) {
|
|
59269
|
+
if (candidate === key)
|
|
59270
|
+
continue;
|
|
59271
|
+
const distance = levenshtein(lowerKey, candidate.toLowerCase());
|
|
59272
|
+
if (distance > SUGGESTION_DISTANCE)
|
|
59273
|
+
continue;
|
|
59274
|
+
if (distance < bestDistance || distance === bestDistance && best !== null && candidate < best) {
|
|
59275
|
+
best = candidate;
|
|
59276
|
+
bestDistance = distance;
|
|
59277
|
+
}
|
|
59278
|
+
}
|
|
59279
|
+
return best;
|
|
59280
|
+
}
|
|
59281
|
+
function unknownParamWarnings(args, knownKeys) {
|
|
59282
|
+
const unknown2 = Object.keys(args).filter((key) => !knownKeys.has(key)).sort((a, b) => a.localeCompare(b));
|
|
59283
|
+
return unknown2.slice(0, MAX_WARNINGS).map((key) => {
|
|
59284
|
+
const suggestion = suggestParam(key, knownKeys);
|
|
59285
|
+
return suggestion ? `Unknown parameter "${key}" was ignored. Did you mean "${suggestion}"?` : `Unknown parameter "${key}" was ignored (no matching parameter).`;
|
|
59286
|
+
});
|
|
59287
|
+
}
|
|
59288
|
+
function attachParamWarnings(result, warnings) {
|
|
59289
|
+
if (warnings.length === 0)
|
|
59290
|
+
return result;
|
|
59291
|
+
if (result === null || typeof result !== "object" || Array.isArray(result))
|
|
59292
|
+
return result;
|
|
59293
|
+
const record2 = result;
|
|
59294
|
+
if (Array.isArray(record2.warnings)) {
|
|
59295
|
+
return { ...record2, warnings: [...record2.warnings, ...warnings] };
|
|
59296
|
+
}
|
|
59297
|
+
if (record2.warnings === void 0) {
|
|
59298
|
+
return { ...record2, warnings };
|
|
59299
|
+
}
|
|
59300
|
+
return { ...record2, paramWarnings: warnings };
|
|
59301
|
+
}
|
|
59302
|
+
var MAX_WARNINGS, SUGGESTION_DISTANCE;
|
|
59303
|
+
var init_param_warnings = __esm({
|
|
59304
|
+
"plugins/huaweicloud-core/dist.new/lib/param-warnings.js"() {
|
|
59305
|
+
"use strict";
|
|
59306
|
+
MAX_WARNINGS = 5;
|
|
59307
|
+
SUGGESTION_DISTANCE = 2;
|
|
59308
|
+
}
|
|
59309
|
+
});
|
|
59310
|
+
|
|
59095
59311
|
// plugins/huaweicloud-core/dist.new/lib/call-trace.js
|
|
59096
|
-
import { appendFileSync as appendFileSync4, existsSync as
|
|
59312
|
+
import { appendFileSync as appendFileSync4, existsSync as existsSync33, writeFileSync as writeFileSync15 } from "node:fs";
|
|
59097
59313
|
function redactSupplemental(value) {
|
|
59098
59314
|
if (Array.isArray(value))
|
|
59099
59315
|
return value.map((item) => redactSupplemental(item));
|
|
@@ -59118,7 +59334,7 @@ function appendRecord(record2) {
|
|
|
59118
59334
|
try {
|
|
59119
59335
|
const line = `${JSON.stringify(record2)}
|
|
59120
59336
|
`;
|
|
59121
|
-
if (
|
|
59337
|
+
if (existsSync33(path)) {
|
|
59122
59338
|
appendFileSync4(path, line, "utf8");
|
|
59123
59339
|
} else {
|
|
59124
59340
|
writeFileSync15(path, line, { mode: 384, encoding: "utf8" });
|
|
@@ -59450,88 +59666,6 @@ var init_tool_definitions = __esm({
|
|
|
59450
59666
|
}
|
|
59451
59667
|
});
|
|
59452
59668
|
|
|
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
59669
|
// plugins/huaweicloud-core/dist.new/tool-schemas.js
|
|
59536
59670
|
function getToolSchema(name) {
|
|
59537
59671
|
return TOOL_SCHEMAS[name];
|
|
@@ -59539,6 +59673,16 @@ function getToolSchema(name) {
|
|
|
59539
59673
|
function toolSchemaEntries() {
|
|
59540
59674
|
return Object.entries(TOOL_SCHEMAS);
|
|
59541
59675
|
}
|
|
59676
|
+
function toolArgKeys(name) {
|
|
59677
|
+
const cached2 = argKeyCache.get(name);
|
|
59678
|
+
if (cached2)
|
|
59679
|
+
return cached2;
|
|
59680
|
+
const def = TOOL_SCHEMAS[name]._zod?.def;
|
|
59681
|
+
const keys = new Set(Object.keys(def?.shape ?? {}));
|
|
59682
|
+
keys.add("vendorConfirmed");
|
|
59683
|
+
argKeyCache.set(name, keys);
|
|
59684
|
+
return keys;
|
|
59685
|
+
}
|
|
59542
59686
|
function assertConstructedSchemas() {
|
|
59543
59687
|
for (const [name, schema] of toolSchemaEntries()) {
|
|
59544
59688
|
const def = schema._zod?.def;
|
|
@@ -59547,7 +59691,7 @@ function assertConstructedSchemas() {
|
|
|
59547
59691
|
}
|
|
59548
59692
|
}
|
|
59549
59693
|
}
|
|
59550
|
-
var SCHEMA_DRIFT_IGNORED_KEYS, artifactsItem, TOOL_SCHEMAS;
|
|
59694
|
+
var SCHEMA_DRIFT_IGNORED_KEYS, artifactsItem, TOOL_SCHEMAS, argKeyCache;
|
|
59551
59695
|
var init_tool_schemas = __esm({
|
|
59552
59696
|
"plugins/huaweicloud-core/dist.new/tool-schemas.js"() {
|
|
59553
59697
|
"use strict";
|
|
@@ -59656,6 +59800,89 @@ var init_tool_schemas = __esm({
|
|
|
59656
59800
|
reset: external_exports.boolean().optional().describe("Drop the session override and return to the operator DEVKIT_PACKS posture.")
|
|
59657
59801
|
})
|
|
59658
59802
|
};
|
|
59803
|
+
argKeyCache = /* @__PURE__ */ new Map();
|
|
59804
|
+
}
|
|
59805
|
+
});
|
|
59806
|
+
|
|
59807
|
+
// plugins/huaweicloud-core/dist.new/vendor-gate.js
|
|
59808
|
+
function vendorChallengeEnabled() {
|
|
59809
|
+
return process.env.HUAWEICLOUD_VENDOR_CHALLENGE !== "off";
|
|
59810
|
+
}
|
|
59811
|
+
function enforceVendorGate(args, opts) {
|
|
59812
|
+
const quote = args.vendorConfirmed;
|
|
59813
|
+
if (typeof quote !== "string" || quote.trim().length === 0) {
|
|
59814
|
+
throw new Error(VENDOR_GATE_MESSAGE);
|
|
59815
|
+
}
|
|
59816
|
+
const challengeKey = opts.sessionId || "default";
|
|
59817
|
+
if (vendorChallengeEnabled() && !vendorChallengeConsumed.get(challengeKey)) {
|
|
59818
|
+
vendorChallengeConsumed.set(challengeKey, true);
|
|
59819
|
+
throw new Error(VENDOR_CHALLENGE_MESSAGE);
|
|
59820
|
+
}
|
|
59821
|
+
}
|
|
59822
|
+
var VENDOR_GATED_TOOLS, VENDOR_GATE_MESSAGE, VENDOR_CHALLENGE_MESSAGE, vendorChallengeConsumed;
|
|
59823
|
+
var init_vendor_gate = __esm({
|
|
59824
|
+
"plugins/huaweicloud-core/dist.new/vendor-gate.js"() {
|
|
59825
|
+
"use strict";
|
|
59826
|
+
VENDOR_GATED_TOOLS = /* @__PURE__ */ new Set([
|
|
59827
|
+
"huaweicloud_auth_status",
|
|
59828
|
+
"huaweicloud_auth_init",
|
|
59829
|
+
"huaweicloud_auth_switch",
|
|
59830
|
+
"huaweicloud_check_cli",
|
|
59831
|
+
"huaweicloud_show_profile_redacted",
|
|
59832
|
+
"huaweicloud_list_operations",
|
|
59833
|
+
"huaweicloud_list_regions",
|
|
59834
|
+
"huaweicloud_run_readonly_command",
|
|
59835
|
+
"huaweicloud_plan_cli_command",
|
|
59836
|
+
"huaweicloud_run_approved_command",
|
|
59837
|
+
"huaweicloud_service_catalog",
|
|
59838
|
+
"huaweicloud_sandbox_connect",
|
|
59839
|
+
"huaweicloud_voucher_claim",
|
|
59840
|
+
"huaweicloud_competition_voucher_claim"
|
|
59841
|
+
]);
|
|
59842
|
+
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.";
|
|
59843
|
+
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.";
|
|
59844
|
+
vendorChallengeConsumed = /* @__PURE__ */ new Map();
|
|
59845
|
+
}
|
|
59846
|
+
});
|
|
59847
|
+
|
|
59848
|
+
// plugins/huaweicloud-core/dist.new/packs/enable.js
|
|
59849
|
+
function setRuntimePacksOverride(raw) {
|
|
59850
|
+
const parsed = parseDevkitPacks(raw);
|
|
59851
|
+
if (!parsed.raw) {
|
|
59852
|
+
throw new Error("Runtime pack override cannot be blank. Clear it with reset instead.");
|
|
59853
|
+
}
|
|
59854
|
+
if (parsed.unknown.length > 0) {
|
|
59855
|
+
throw new Error(`Runtime pack override contains unknown pack id(s): ${parsed.unknown.join(", ")}. Valid pack ids: ${VALID_IDS.join(", ")}.`);
|
|
59856
|
+
}
|
|
59857
|
+
runtimeOverride = parsed;
|
|
59858
|
+
return parsed;
|
|
59859
|
+
}
|
|
59860
|
+
function clearRuntimePacksOverride() {
|
|
59861
|
+
runtimeOverride = null;
|
|
59862
|
+
}
|
|
59863
|
+
function runtimePacksOverride() {
|
|
59864
|
+
return runtimeOverride;
|
|
59865
|
+
}
|
|
59866
|
+
function resolveEnabledPacks(env = process.env) {
|
|
59867
|
+
if (runtimeOverride)
|
|
59868
|
+
return runtimeOverride.enabled;
|
|
59869
|
+
const raw = (env.DEVKIT_PACKS ?? "").trim();
|
|
59870
|
+
if (!raw)
|
|
59871
|
+
return new Set(PACK_IDS);
|
|
59872
|
+
const { unknown: unknown2, enabled } = parseDevkitPacks(raw);
|
|
59873
|
+
if (unknown2.length > 0) {
|
|
59874
|
+
throw new Error(`DEVKIT_PACKS contains unknown pack id(s): ${unknown2.join(", ")}. Valid pack ids: ${VALID_IDS.join(", ")}.`);
|
|
59875
|
+
}
|
|
59876
|
+
return enabled;
|
|
59877
|
+
}
|
|
59878
|
+
var VALID_IDS, runtimeOverride;
|
|
59879
|
+
var init_enable = __esm({
|
|
59880
|
+
"plugins/huaweicloud-core/dist.new/packs/enable.js"() {
|
|
59881
|
+
"use strict";
|
|
59882
|
+
init_pack_types();
|
|
59883
|
+
init_dependency_model();
|
|
59884
|
+
VALID_IDS = PACK_IDS;
|
|
59885
|
+
runtimeOverride = null;
|
|
59659
59886
|
}
|
|
59660
59887
|
});
|
|
59661
59888
|
|
|
@@ -60238,8 +60465,8 @@ var init_skill_frontmatter = __esm({
|
|
|
60238
60465
|
});
|
|
60239
60466
|
|
|
60240
60467
|
// plugins/huaweicloud-core/dist.new/skill-disclosure.js
|
|
60241
|
-
import { readFileSync as readFileSync32, readdirSync as readdirSync7, existsSync as
|
|
60242
|
-
import { join as
|
|
60468
|
+
import { readFileSync as readFileSync32, readdirSync as readdirSync7, existsSync as existsSync34 } from "node:fs";
|
|
60469
|
+
import { join as join44, dirname as dirname25 } from "node:path";
|
|
60243
60470
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
60244
60471
|
function verifySkillTree(root = SKILLS_ROOT) {
|
|
60245
60472
|
const present2 = new Set(listSkillDirs(root));
|
|
@@ -60255,8 +60482,8 @@ function verifySkillTree(root = SKILLS_ROOT) {
|
|
|
60255
60482
|
}
|
|
60256
60483
|
}
|
|
60257
60484
|
function referenceFilenames(skillName) {
|
|
60258
|
-
const refDir =
|
|
60259
|
-
if (!
|
|
60485
|
+
const refDir = join44(SKILLS_ROOT, skillName, "references");
|
|
60486
|
+
if (!existsSync34(refDir))
|
|
60260
60487
|
return [];
|
|
60261
60488
|
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
60489
|
}
|
|
@@ -60288,7 +60515,7 @@ function listSkills(pack, opts = {}) {
|
|
|
60288
60515
|
if (!enabled.has(entry.id))
|
|
60289
60516
|
continue;
|
|
60290
60517
|
for (const skillName of entry.skills) {
|
|
60291
|
-
const fm = parseSkillFrontmatter(readFileSync32(
|
|
60518
|
+
const fm = parseSkillFrontmatter(readFileSync32(join44(SKILLS_ROOT, skillName, "SKILL.md"), "utf8"));
|
|
60292
60519
|
skills.push({
|
|
60293
60520
|
name: skillName,
|
|
60294
60521
|
description: fm.description ?? "",
|
|
@@ -60316,8 +60543,8 @@ async function retrieveSkill(name, opts = {}) {
|
|
|
60316
60543
|
error: 'Invalid skill name "' + skillName + '". Skill names are lowercase letters, digits, and dashes.'
|
|
60317
60544
|
};
|
|
60318
60545
|
}
|
|
60319
|
-
const skillPath =
|
|
60320
|
-
if (!
|
|
60546
|
+
const skillPath = join44(SKILLS_ROOT, skillName, "SKILL.md");
|
|
60547
|
+
if (!existsSync34(skillPath)) {
|
|
60321
60548
|
const enabled = resolveEnabledPacks();
|
|
60322
60549
|
const dirs = listSkillDirs(SKILLS_ROOT).filter((dir) => {
|
|
60323
60550
|
const owner2 = SKILL_OWNER.get(dir);
|
|
@@ -60335,7 +60562,7 @@ async function retrieveSkill(name, opts = {}) {
|
|
|
60335
60562
|
const content = readFileSync32(skillPath, "utf8");
|
|
60336
60563
|
const references = [];
|
|
60337
60564
|
for (const filename of referenceFilenames(skillName)) {
|
|
60338
|
-
const refPath =
|
|
60565
|
+
const refPath = join44(SKILLS_ROOT, skillName, "references", filename);
|
|
60339
60566
|
const raw = readFileSync32(refPath, "utf8");
|
|
60340
60567
|
references.push({
|
|
60341
60568
|
filename,
|
|
@@ -60367,29 +60594,29 @@ var init_skill_disclosure = __esm({
|
|
|
60367
60594
|
init_skill_tree();
|
|
60368
60595
|
init_skill_frontmatter();
|
|
60369
60596
|
init_capability_catalog();
|
|
60370
|
-
__dirname8 =
|
|
60371
|
-
SKILLS_ROOT =
|
|
60597
|
+
__dirname8 = dirname25(fileURLToPath10(import.meta.url));
|
|
60598
|
+
SKILLS_ROOT = join44(__dirname8, "..", "skills");
|
|
60372
60599
|
REFERENCE_CAP = 4e3;
|
|
60373
60600
|
}
|
|
60374
60601
|
});
|
|
60375
60602
|
|
|
60376
60603
|
// plugins/huaweicloud-core/dist.new/search-docs.js
|
|
60377
|
-
import { readFileSync as readFileSync33, existsSync as
|
|
60378
|
-
import { join as
|
|
60604
|
+
import { readFileSync as readFileSync33, existsSync as existsSync35 } from "node:fs";
|
|
60605
|
+
import { join as join45 } from "node:path";
|
|
60379
60606
|
async function searchDocs(query, topic = "all") {
|
|
60380
60607
|
const q = String(query || "").toLowerCase();
|
|
60381
60608
|
const tokens = q.split(/\s+/).filter((t) => t.length > 0);
|
|
60382
60609
|
const enabled = resolveEnabledPacks();
|
|
60383
60610
|
const results = [];
|
|
60384
60611
|
try {
|
|
60385
|
-
if (
|
|
60612
|
+
if (existsSync35(SKILLS_ROOT)) {
|
|
60386
60613
|
const dirs = listSkillDirs(SKILLS_ROOT);
|
|
60387
60614
|
for (const dir of dirs) {
|
|
60388
60615
|
const owner = SKILL_OWNER.get(dir);
|
|
60389
60616
|
if (owner && !enabled.has(owner))
|
|
60390
60617
|
continue;
|
|
60391
|
-
const skillPath =
|
|
60392
|
-
if (!
|
|
60618
|
+
const skillPath = join45(SKILLS_ROOT, dir, "SKILL.md");
|
|
60619
|
+
if (!existsSync35(skillPath))
|
|
60393
60620
|
continue;
|
|
60394
60621
|
const content = readFileSync33(skillPath, "utf8");
|
|
60395
60622
|
const fm = parseSkillFrontmatter(content);
|
|
@@ -60454,12 +60681,13 @@ async function callTool(name, rawArgs = {}, opts = {}) {
|
|
|
60454
60681
|
const args = normalizeNumericArgs(rawArgs);
|
|
60455
60682
|
const toolValue = toolInvokeValue(name, args);
|
|
60456
60683
|
trackToolInvoke(name, toolValue);
|
|
60684
|
+
const paramWarnings = unknownParamWarnings(args, toolArgKeys(name));
|
|
60457
60685
|
if (!traceEnabled())
|
|
60458
|
-
return dispatchTool(name, args, opts);
|
|
60686
|
+
return attachParamWarnings(await dispatchTool(name, args, opts), paramWarnings);
|
|
60459
60687
|
try {
|
|
60460
60688
|
const result = await dispatchTool(name, args, opts);
|
|
60461
60689
|
recordToolCall(name, args, true);
|
|
60462
|
-
return result;
|
|
60690
|
+
return attachParamWarnings(result, paramWarnings);
|
|
60463
60691
|
} catch (error62) {
|
|
60464
60692
|
recordToolCall(name, args, false, error62);
|
|
60465
60693
|
throw error62;
|
|
@@ -60510,7 +60738,10 @@ function hookResult(result) {
|
|
|
60510
60738
|
ok: result.decision !== "deny",
|
|
60511
60739
|
decision: result.decision,
|
|
60512
60740
|
findings: result.findings,
|
|
60513
|
-
|
|
60741
|
+
// allow means "no rule matched", never "approved": make that explicit so
|
|
60742
|
+
// an agent cannot read a green advisory check as a safety verdict.
|
|
60743
|
+
...result.decision === "allow" ? { unmatched: true } : {},
|
|
60744
|
+
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
60745
|
};
|
|
60515
60746
|
}
|
|
60516
60747
|
function withUnknownOperationWarn(command, result, classify2 = classifyTextCommand) {
|
|
@@ -60522,6 +60753,9 @@ function withUnknownOperationWarn(command, result, classify2 = classifyTextComma
|
|
|
60522
60753
|
} catch {
|
|
60523
60754
|
return { ...result, decision: "warn", findings: [unverifiedFinding(command)] };
|
|
60524
60755
|
}
|
|
60756
|
+
if (classification?.risk === "write" || classification?.risk === "execution") {
|
|
60757
|
+
return { ...result, decision: "warn", findings: [writeOperationFinding(command)] };
|
|
60758
|
+
}
|
|
60525
60759
|
if (classification?.risk !== "unknown_read")
|
|
60526
60760
|
return result;
|
|
60527
60761
|
const triage = triageUnknownService(classification.service);
|
|
@@ -60545,7 +60779,7 @@ function withUnknownOperationWarn(command, result, classify2 = classifyTextComma
|
|
|
60545
60779
|
}
|
|
60546
60780
|
return { ...result, decision: "warn", findings: [unknownOperationFinding(command)] };
|
|
60547
60781
|
}
|
|
60548
|
-
var NUMERIC_ARG_KEYS, unknownOperationFinding, unverifiedFinding;
|
|
60782
|
+
var NUMERIC_ARG_KEYS, unknownOperationFinding, unverifiedFinding, writeOperationFinding;
|
|
60549
60783
|
var init_tools10 = __esm({
|
|
60550
60784
|
"plugins/huaweicloud-core/dist.new/tools.js"() {
|
|
60551
60785
|
"use strict";
|
|
@@ -60558,8 +60792,10 @@ var init_tools10 = __esm({
|
|
|
60558
60792
|
init_availability();
|
|
60559
60793
|
init_registry();
|
|
60560
60794
|
init_skill_tree();
|
|
60795
|
+
init_param_warnings();
|
|
60561
60796
|
init_call_trace();
|
|
60562
60797
|
init_tool_definitions();
|
|
60798
|
+
init_tool_schemas();
|
|
60563
60799
|
init_vendor_gate();
|
|
60564
60800
|
init_capability_catalog();
|
|
60565
60801
|
init_packs_configure();
|
|
@@ -60594,6 +60830,16 @@ var init_tools10 = __esm({
|
|
|
60594
60830
|
source: "command",
|
|
60595
60831
|
evidence: command.slice(0, 240)
|
|
60596
60832
|
});
|
|
60833
|
+
writeOperationFinding = (command) => ({
|
|
60834
|
+
ruleId: "hwc-write-operation",
|
|
60835
|
+
title: "Write or execution operation",
|
|
60836
|
+
category: "approval",
|
|
60837
|
+
severity: "warn",
|
|
60838
|
+
message: "This command is classified as a write or execution operation. Raw shell execution is blocked; writes require a plan and explicit user approval.",
|
|
60839
|
+
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.",
|
|
60840
|
+
source: "command",
|
|
60841
|
+
evidence: command.slice(0, 240)
|
|
60842
|
+
});
|
|
60597
60843
|
}
|
|
60598
60844
|
});
|
|
60599
60845
|
|
|
@@ -60654,6 +60900,7 @@ function normalizeToolCallParams(message) {
|
|
|
60654
60900
|
}
|
|
60655
60901
|
function createDevkitMcpServer({ sessionId, runtimePacks = false, remoteSurface = false } = {}) {
|
|
60656
60902
|
assertConstructedSchemas();
|
|
60903
|
+
const askMode = approvalModeFromEnv(process.env) === "ask";
|
|
60657
60904
|
if (remoteSurface && runtimePacks) {
|
|
60658
60905
|
throw new Error("contradictory construction: remoteSurface and runtimePacks are mutually exclusive \u2014 the stateless remote must not carry runtime pack toggling (it would leak host paths through skill payloads)");
|
|
60659
60906
|
}
|
|
@@ -60671,7 +60918,18 @@ function createDevkitMcpServer({ sessionId, runtimePacks = false, remoteSurface
|
|
|
60671
60918
|
]);
|
|
60672
60919
|
const isWanted = (tool, enabled) => enabled.has(PACK_OF[tool.name]) && (runtimePacks || tool.name !== "huaweicloud_packs_configure") && (!remoteSurface || PACK_OF[tool.name] !== "secrets" && !REMOTE_WITHHELD_LOCAL_WRITERS.has(tool.name));
|
|
60673
60920
|
const registerOne = (tool) => {
|
|
60674
|
-
registered.set(tool.name, server.registerTool(tool.name, {
|
|
60921
|
+
registered.set(tool.name, server.registerTool(tool.name, {
|
|
60922
|
+
description: tool.description,
|
|
60923
|
+
inputSchema: getToolSchema(tool.name),
|
|
60924
|
+
// Ask mode only: Claude Code honors this flag by prompting the
|
|
60925
|
+
// user on every call of this tool — even in acceptEdits/auto/
|
|
60926
|
+
// bypassPermissions modes, with no "don't ask again" — and that
|
|
60927
|
+
// client prompt IS the user's confirmation the mode trusts.
|
|
60928
|
+
// Other clients ignore the flag. Declared only in ask mode so
|
|
60929
|
+
// token-mode Claude Code users don't gain a second prompt on top
|
|
60930
|
+
// of the terminal approve they already run.
|
|
60931
|
+
...askMode && tool.name === "huaweicloud_run_approved_command" ? { _meta: { "anthropic/requiresUserInteraction": true } } : {}
|
|
60932
|
+
}, async (args) => {
|
|
60675
60933
|
const callOpts = runtimePacks ? { sessionId, onPacksChanged: () => syncDisclosure() } : { sessionId };
|
|
60676
60934
|
const result = await callTool(tool.name, args, callOpts);
|
|
60677
60935
|
const decorated = _decorateResult(sessionId, tool.name, result);
|
|
@@ -60716,6 +60974,7 @@ var init_mcp_protocol = __esm({
|
|
|
60716
60974
|
init_telemetry();
|
|
60717
60975
|
init_agent_detect();
|
|
60718
60976
|
init_as_record();
|
|
60977
|
+
init_approval_mode();
|
|
60719
60978
|
pkgVersion = readInstalledVersion() || "0.0.0";
|
|
60720
60979
|
TRIMMED_CAPABILITY_RULE = "That unavailability is about the capability, not just the skill text or the MCP tools: a trimmed pack's services are unavailable through every execution path, including hcloud commands run directly from your shell \u2014 never silently proceed that way; confirm with the user instead. ";
|
|
60721
60980
|
VENDOR_BOUNDARY_RULE = "Vendor boundary: tools or skills being available in this session is not evidence of which cloud the user means. For a request that involves cloud resources but names no vendor, infer the vendor only from an explicit mention, hcloud/KooCLI artifacts, myhuaweicloud endpoints, Huawei region IDs, or earlier turns of this conversation \u2014 generic service vocabulary (ECS, VPC, RDS, serverless) and the devkit's own presence do not infer it. When the vendor is still unknown, ask the user which cloud they mean before operating on cloud resources through any tool or hcloud command, and before probing Huawei Cloud tooling, credential, or account state (CLI install checks, profile reads, auth status). Cloud-facing tools enforce this with a vendorConfirmed parameter \u2014 pass the user's establishing words as its value, never an invented quote. Requests that are not cloud tasks are outside this rule; tasks for other clouds remain answerable from general knowledge \u2014 the devkit's tools themselves only operate on Huawei Cloud. ";
|
|
@@ -61383,9 +61642,9 @@ data:
|
|
|
61383
61642
|
const initRequest = messages.find((m) => isInitializeRequest(m));
|
|
61384
61643
|
const clientProtocolVersion = initRequest ? initRequest.params.protocolVersion : req.headers.get("mcp-protocol-version") ?? DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
|
|
61385
61644
|
if (this._enableJsonResponse) {
|
|
61386
|
-
return new Promise((
|
|
61645
|
+
return new Promise((resolve10) => {
|
|
61387
61646
|
this._streamMapping.set(streamId, {
|
|
61388
|
-
resolveJson:
|
|
61647
|
+
resolveJson: resolve10,
|
|
61389
61648
|
cleanup: () => {
|
|
61390
61649
|
this._streamMapping.delete(streamId);
|
|
61391
61650
|
}
|
|
@@ -61810,8 +62069,8 @@ var init_mcp_server_remote = __esm({
|
|
|
61810
62069
|
});
|
|
61811
62070
|
|
|
61812
62071
|
// plugins/huaweicloud-core/dist.new/mcp-server.js
|
|
61813
|
-
import { rmSync as
|
|
61814
|
-
import { resolve as
|
|
62072
|
+
import { rmSync as rmSync11, existsSync as existsSync37 } from "node:fs";
|
|
62073
|
+
import { resolve as resolve9, dirname as dirname27 } from "node:path";
|
|
61815
62074
|
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
61816
62075
|
|
|
61817
62076
|
// plugins/huaweicloud-core/dist.new/mcp-stdio-transport.js
|
|
@@ -62000,15 +62259,15 @@ init_update_check();
|
|
|
62000
62259
|
init_hcloud_probe();
|
|
62001
62260
|
init_koocli_paths();
|
|
62002
62261
|
import { spawn as spawn4 } from "node:child_process";
|
|
62003
|
-
import { appendFileSync as appendFileSync5, closeSync, existsSync as
|
|
62004
|
-
import { dirname as
|
|
62262
|
+
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";
|
|
62263
|
+
import { dirname as dirname26, join as join46 } from "node:path";
|
|
62005
62264
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
62006
|
-
var __dirname9 =
|
|
62265
|
+
var __dirname9 = dirname26(fileURLToPath11(import.meta.url));
|
|
62007
62266
|
var INSTALL_LOCK_TTL_MS = 15 * 60 * 1e3;
|
|
62008
62267
|
var INSTALL_LOG_MAX_BYTES = 1024 * 1024;
|
|
62009
62268
|
var INSTALL_FAILURE_COOLDOWN_MS = 24 * 60 * 60 * 1e3;
|
|
62010
62269
|
function failureMarkerPath() {
|
|
62011
|
-
return
|
|
62270
|
+
return join46(dirname26(kooCliInstallLockPath()), ".koocli-install.failed");
|
|
62012
62271
|
}
|
|
62013
62272
|
function lockIsStale(body) {
|
|
62014
62273
|
const ts = Number(body.trim());
|
|
@@ -62018,7 +62277,7 @@ function lockIsStale(body) {
|
|
|
62018
62277
|
}
|
|
62019
62278
|
function acquireInstallLock(lockPath = kooCliInstallLockPath()) {
|
|
62020
62279
|
try {
|
|
62021
|
-
|
|
62280
|
+
mkdirSync16(dirname26(lockPath), { recursive: true });
|
|
62022
62281
|
let replace = false;
|
|
62023
62282
|
try {
|
|
62024
62283
|
replace = lockIsStale(String(readFileSync34(lockPath, "utf8")));
|
|
@@ -62026,7 +62285,7 @@ function acquireInstallLock(lockPath = kooCliInstallLockPath()) {
|
|
|
62026
62285
|
}
|
|
62027
62286
|
if (replace) {
|
|
62028
62287
|
try {
|
|
62029
|
-
|
|
62288
|
+
rmSync10(lockPath, { force: true });
|
|
62030
62289
|
} catch (error62) {
|
|
62031
62290
|
return { acquired: false, reason: `stale lock cleanup failed: ${error62.message}` };
|
|
62032
62291
|
}
|
|
@@ -62048,25 +62307,25 @@ function releaseInstallLock(lockPath = kooCliInstallLockPath(), ownedTs) {
|
|
|
62048
62307
|
if (body !== String(ownedTs))
|
|
62049
62308
|
return;
|
|
62050
62309
|
}
|
|
62051
|
-
|
|
62310
|
+
rmSync10(lockPath, { force: true });
|
|
62052
62311
|
} catch {
|
|
62053
62312
|
}
|
|
62054
62313
|
}
|
|
62055
62314
|
function openKooCliInstallLog(logPath = kooCliInstallLogPath()) {
|
|
62056
62315
|
try {
|
|
62057
|
-
const st =
|
|
62316
|
+
const st = existsSync36(logPath) ? statSync10(logPath) : null;
|
|
62058
62317
|
if (st && st.size > INSTALL_LOG_MAX_BYTES)
|
|
62059
|
-
|
|
62060
|
-
|
|
62318
|
+
rmSync10(logPath, { force: true });
|
|
62319
|
+
mkdirSync16(dirname26(logPath), { recursive: true });
|
|
62061
62320
|
} catch {
|
|
62062
62321
|
}
|
|
62063
62322
|
return openSync(logPath, "a", 384);
|
|
62064
62323
|
}
|
|
62065
62324
|
function resolvePreinstallCliEntry() {
|
|
62066
|
-
const compiled =
|
|
62067
|
-
if (
|
|
62325
|
+
const compiled = join46(__dirname9, "setup-cli.js");
|
|
62326
|
+
if (existsSync36(compiled))
|
|
62068
62327
|
return compiled;
|
|
62069
|
-
return
|
|
62328
|
+
return join46(__dirname9, "setup-cli.ts");
|
|
62070
62329
|
}
|
|
62071
62330
|
var spawnForTests = null;
|
|
62072
62331
|
var installStarted = false;
|
|
@@ -62080,7 +62339,7 @@ function maybePreinstallKooCli({ force = false } = {}) {
|
|
|
62080
62339
|
return { launched: false, reason: "already installed" };
|
|
62081
62340
|
}
|
|
62082
62341
|
try {
|
|
62083
|
-
if (
|
|
62342
|
+
if (existsSync36(failureMarkerPath())) {
|
|
62084
62343
|
const ts = Number(String(readFileSync34(failureMarkerPath(), "utf8")).trim());
|
|
62085
62344
|
if (Number.isFinite(ts) && Date.now() - ts < INSTALL_FAILURE_COOLDOWN_MS) {
|
|
62086
62345
|
return { launched: false, reason: "cooldown after an unsuccessful install attempt" };
|
|
@@ -62103,7 +62362,7 @@ function maybePreinstallKooCli({ force = false } = {}) {
|
|
|
62103
62362
|
const releaseOwned = () => releaseInstallLock(kooCliInstallLockPath(), ownedTs);
|
|
62104
62363
|
installStarted = true;
|
|
62105
62364
|
const entryPath = resolvePreinstallCliEntry();
|
|
62106
|
-
if (!
|
|
62365
|
+
if (!existsSync36(entryPath)) {
|
|
62107
62366
|
releaseOwned();
|
|
62108
62367
|
console.error(`[preflight] install entry missing: ${entryPath}`);
|
|
62109
62368
|
return { launched: false, reason: `install entry missing: ${entryPath}` };
|
|
@@ -62152,6 +62411,7 @@ function maybePreinstallKooCli({ force = false } = {}) {
|
|
|
62152
62411
|
}
|
|
62153
62412
|
|
|
62154
62413
|
// plugins/huaweicloud-core/dist.new/mcp-server.js
|
|
62414
|
+
init_approval_mode();
|
|
62155
62415
|
var transportIdx = process.argv.indexOf("--transport");
|
|
62156
62416
|
var transport = transportIdx > -1 && process.argv[transportIdx + 1] ? process.argv[transportIdx + 1] : "stdio";
|
|
62157
62417
|
var portIdx = process.argv.indexOf("--port");
|
|
@@ -62184,13 +62444,17 @@ try {
|
|
|
62184
62444
|
} catch {
|
|
62185
62445
|
}
|
|
62186
62446
|
try {
|
|
62187
|
-
const pluginDir =
|
|
62188
|
-
const marker =
|
|
62189
|
-
if (
|
|
62190
|
-
|
|
62447
|
+
const pluginDir = resolve9(dirname27(fileURLToPath12(import.meta.url)), "..");
|
|
62448
|
+
const marker = resolve9(pluginDir, ".installed");
|
|
62449
|
+
if (existsSync37(marker))
|
|
62450
|
+
rmSync11(marker, { force: true });
|
|
62191
62451
|
} catch {
|
|
62192
62452
|
}
|
|
62193
62453
|
if (transport === "remote") {
|
|
62454
|
+
if (approvalModeFromEnv(process.env) === "ask") {
|
|
62455
|
+
process.env.DEVKIT_APPROVAL_MODE = "token";
|
|
62456
|
+
process.stderr.write("DEVKIT_APPROVAL_MODE=ask is not supported on the remote transport (no per-call permission prompt to trust); falling back to token approval.\n");
|
|
62457
|
+
}
|
|
62194
62458
|
const { startRemoteServer: startRemoteServer2 } = await Promise.resolve().then(() => (init_mcp_server_remote(), mcp_server_remote_exports));
|
|
62195
62459
|
startRemoteServer2({ port: remotePort, host: remoteHost }).catch((error62) => {
|
|
62196
62460
|
process.stderr.write(`Failed to start MCP remote server: ${error62 instanceof Error ? error62.message : String(error62)}
|