@hcmai/cli 0.33.1 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1368 -269
- package/dist/index.js.map +1 -1
- package/dist/skills/hcm-env-transfer/SKILL.md +5 -2
- package/dist/skills/manifest.json +76 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -785,7 +785,7 @@ import chalk from "chalk";
|
|
|
785
785
|
import ora from "ora";
|
|
786
786
|
import { marked } from "marked";
|
|
787
787
|
import { markedTerminal } from "marked-terminal";
|
|
788
|
-
import { absoluteDownloadUrl } from "@hcmai/sdk";
|
|
788
|
+
import { absoluteDownloadUrl, readTextPart } from "@hcmai/sdk";
|
|
789
789
|
function terminalHyperlink(url, text2) {
|
|
790
790
|
return `\x1B]8;;${url}\x07${text2}\x1B]8;;\x07`;
|
|
791
791
|
}
|
|
@@ -1168,6 +1168,18 @@ var init_TerminalRenderer = __esm({
|
|
|
1168
1168
|
this.blockBoundary();
|
|
1169
1169
|
const type = part.type;
|
|
1170
1170
|
const pad = this.indent();
|
|
1171
|
+
const textPart = readTextPart(part);
|
|
1172
|
+
if (textPart) {
|
|
1173
|
+
if (textPart.notice) {
|
|
1174
|
+
const body = textPart.text.replace(/\n+$/, "") || `[${textPart.notice}]`;
|
|
1175
|
+
const lines = body.split("\n");
|
|
1176
|
+
this.write(lines.map((l) => pad + chalk.gray(l)).join("\n") + "\n");
|
|
1177
|
+
} else if (textPart.text) {
|
|
1178
|
+
this.writeChatChunk(textPart.text);
|
|
1179
|
+
this.flushChatBuffer();
|
|
1180
|
+
}
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1171
1183
|
if (type === "chart") {
|
|
1172
1184
|
this.write(pad + chalk.cyan(`\u25B8 \u56FE\u8868 \xB7 ${part.title ?? ""}`) + "\n");
|
|
1173
1185
|
if (part.insight) this.write(pad + chalk.gray(` ${String(part.insight)}`) + "\n");
|
|
@@ -1433,7 +1445,7 @@ var init_StreamPresenter = __esm({
|
|
|
1433
1445
|
// src/repl/InkRendererBridge.ts
|
|
1434
1446
|
import { marked as marked2 } from "marked";
|
|
1435
1447
|
import { markedTerminal as markedTerminal2 } from "marked-terminal";
|
|
1436
|
-
import { absoluteDownloadUrl as absoluteDownloadUrl2 } from "@hcmai/sdk";
|
|
1448
|
+
import { absoluteDownloadUrl as absoluteDownloadUrl2, readTextPart as readTextPart2 } from "@hcmai/sdk";
|
|
1437
1449
|
function createInkRendererBridge(sinks, apiBase) {
|
|
1438
1450
|
let chatBuffer = "";
|
|
1439
1451
|
let thinkingChars = 0;
|
|
@@ -1515,6 +1527,15 @@ function createInkRendererBridge(sinks, apiBase) {
|
|
|
1515
1527
|
},
|
|
1516
1528
|
contentPartSummary(part) {
|
|
1517
1529
|
flushParagraphs(true);
|
|
1530
|
+
const textPart = readTextPart2(part);
|
|
1531
|
+
if (textPart) {
|
|
1532
|
+
if (textPart.notice) {
|
|
1533
|
+
sinks.appendBlock({ kind: "interactionNote", tone: "info", text: textPart.text || `[${textPart.notice}]` });
|
|
1534
|
+
} else if (textPart.text.trim()) {
|
|
1535
|
+
sinks.appendBlock({ kind: "assistant", ansi: renderAnsi(textPart.text) });
|
|
1536
|
+
}
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1518
1539
|
const type = part.type;
|
|
1519
1540
|
let label;
|
|
1520
1541
|
let detail;
|
|
@@ -3444,9 +3465,9 @@ ${e.stdout ?? e.message}`,
|
|
|
3444
3465
|
|
|
3445
3466
|
\u7531 \`hcm chiron case submit\` \u63D0\u4EA4\uFF0Clint \u5DF2\u8FC7\u3002`
|
|
3446
3467
|
]);
|
|
3447
|
-
const
|
|
3468
|
+
const num2 = /number: "?(\d+)/.exec(pr)?.[1] ?? null;
|
|
3448
3469
|
rmSync(INDEX_CACHE(), { force: true });
|
|
3449
|
-
return { id, pr:
|
|
3470
|
+
return { id, pr: num2, url: `${CNB_ORIGIN}/${CASES_REPO_SLUG}/-/pulls/${num2 ?? ""}`, lint: lint.trim() };
|
|
3450
3471
|
} finally {
|
|
3451
3472
|
rmSync(work, { recursive: true, force: true });
|
|
3452
3473
|
}
|
|
@@ -3557,8 +3578,8 @@ function verifyFailure(reasonCode, code2, written, message, nextStep, extra = {}
|
|
|
3557
3578
|
}
|
|
3558
3579
|
function who(u) {
|
|
3559
3580
|
if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
|
|
3560
|
-
const
|
|
3561
|
-
return u.name && u.name !==
|
|
3581
|
+
const shown2 = u.displayName ?? u.name ?? u.key ?? "?";
|
|
3582
|
+
return u.name && u.name !== shown2 ? `${shown2}\uFF08${u.name}\uFF09` : shown2;
|
|
3562
3583
|
}
|
|
3563
3584
|
function sameUser(a, b) {
|
|
3564
3585
|
if (!a || !b) return false;
|
|
@@ -6635,10 +6656,10 @@ async function loginCommand(args) {
|
|
|
6635
6656
|
}
|
|
6636
6657
|
const err = e;
|
|
6637
6658
|
if (err.isAxiosError) {
|
|
6638
|
-
const { fromAxiosError:
|
|
6659
|
+
const { fromAxiosError: fromAxiosError37 } = await import("@hcmai/sdk");
|
|
6639
6660
|
exitWithError(
|
|
6640
6661
|
withTenantHostMismatchStep(
|
|
6641
|
-
|
|
6662
|
+
fromAxiosError37(
|
|
6642
6663
|
e,
|
|
6643
6664
|
envName
|
|
6644
6665
|
),
|
|
@@ -8348,13 +8369,120 @@ init_exit();
|
|
|
8348
8369
|
init_auth_guard();
|
|
8349
8370
|
import {
|
|
8350
8371
|
HcmClient as HcmClient11,
|
|
8372
|
+
MUTATION_CAPABILITY_OPS,
|
|
8373
|
+
MUTATION_CELL_KEYS,
|
|
8351
8374
|
formatObject as formatObject10,
|
|
8352
|
-
fromAxiosError as fromAxiosError14
|
|
8375
|
+
fromAxiosError as fromAxiosError14,
|
|
8376
|
+
missingKeys
|
|
8353
8377
|
} from "@hcmai/sdk";
|
|
8378
|
+
|
|
8379
|
+
// src/commands/introspection-cli.ts
|
|
8380
|
+
var NOT_PROVIDED = "\u672C\u73AF\u5883\u672A\u63D0\u4F9B";
|
|
8381
|
+
function shellArg(v) {
|
|
8382
|
+
return /^[A-Za-z0-9_./:@=+-]+$/.test(v) || /^[\p{Script=Han}A-Za-z0-9_]+$/u.test(v) ? v : `'${v.replace(/'/g, `'\\''`)}'`;
|
|
8383
|
+
}
|
|
8384
|
+
function parseQuery(q) {
|
|
8385
|
+
try {
|
|
8386
|
+
const out = /* @__PURE__ */ new Map();
|
|
8387
|
+
for (const pair of q.replace(/^\?/, "").split("&")) {
|
|
8388
|
+
if (!pair) continue;
|
|
8389
|
+
const i = pair.indexOf("=");
|
|
8390
|
+
const k = decodeURIComponent((i < 0 ? pair : pair.slice(0, i)).replace(/\+/g, " "));
|
|
8391
|
+
const v = i < 0 ? "" : decodeURIComponent(pair.slice(i + 1).replace(/\+/g, " "));
|
|
8392
|
+
out.set(k, v);
|
|
8393
|
+
}
|
|
8394
|
+
return out;
|
|
8395
|
+
} catch {
|
|
8396
|
+
return void 0;
|
|
8397
|
+
}
|
|
8398
|
+
}
|
|
8399
|
+
function introspectCommandFor(query) {
|
|
8400
|
+
const q = parseQuery(query);
|
|
8401
|
+
if (!q) return void 0;
|
|
8402
|
+
const parts = ["hcm introspect"];
|
|
8403
|
+
for (const [k, v] of q) {
|
|
8404
|
+
if (k === "path") parts.splice(1, 0, shellArg(v));
|
|
8405
|
+
else if (k === "detail" && v === "true") parts.push("--detail");
|
|
8406
|
+
else if (k === "limit" && /^\d+$/.test(v)) parts.push(`--limit ${v}`);
|
|
8407
|
+
else return void 0;
|
|
8408
|
+
}
|
|
8409
|
+
return parts.join(" ");
|
|
8410
|
+
}
|
|
8411
|
+
function modelSearchCommandFor(query) {
|
|
8412
|
+
const q = parseQuery(query);
|
|
8413
|
+
const keyword = q?.get("keyword");
|
|
8414
|
+
if (!q || !keyword) return void 0;
|
|
8415
|
+
const parts = ["hcm models", shellArg(keyword), "--search"];
|
|
8416
|
+
for (const [k, v] of q) {
|
|
8417
|
+
if (k === "keyword") continue;
|
|
8418
|
+
if (k === "limit" && /^\d+$/.test(v)) parts.push(`--limit ${v}`);
|
|
8419
|
+
else return void 0;
|
|
8420
|
+
}
|
|
8421
|
+
return parts.join(" ");
|
|
8422
|
+
}
|
|
8423
|
+
var INTROSPECTION_LINK = /GET \/api\/system\/introspection(\?[^\s((]*)?(?: -H "Accept: application\/json")?/g;
|
|
8424
|
+
var MODEL_SEARCH_LINK = /GET \/api\/system\/models\/search(\?[^\s((]*)/g;
|
|
8425
|
+
function rewriteSelfLinks(text2) {
|
|
8426
|
+
return text2.replace(INTROSPECTION_LINK, (whole, query) => {
|
|
8427
|
+
const cmd = introspectCommandFor(query ?? "");
|
|
8428
|
+
return cmd ? `\`${cmd}\`` : whole;
|
|
8429
|
+
}).replace(MODEL_SEARCH_LINK, (whole, query) => {
|
|
8430
|
+
const cmd = modelSearchCommandFor(query);
|
|
8431
|
+
return cmd ? `\`${cmd}\`` : whole;
|
|
8432
|
+
});
|
|
8433
|
+
}
|
|
8434
|
+
var REST_LEFTOVER = /\b(GET|POST|PUT|DELETE|PATCH) \/api\//;
|
|
8435
|
+
var isCapabilityHeader = (line) => /^(GET|POST|PUT|DELETE|PATCH) \/api\//.test(line);
|
|
8436
|
+
function markRestLeftovers(lines, skip = () => false) {
|
|
8437
|
+
return lines.some((l) => !skip(l) && REST_LEFTOVER.test(l)) ? [...lines, "\u2139\uFE0F \u4E0A\u9762\u539F\u6837\u7559\u7740\u7684 `GET /api/\u2026` \u8FD9\u7C7B\u662F\u670D\u52A1\u7AEF\u539F\u6587\uFF08REST \u5199\u6CD5\uFF09\uFF1Ahcm \u6CA1\u6709\u7B49\u4EF7\u547D\u4EE4\uFF0C\u6216\u7B54\u4E0D\u5168\u90A3\u4E00\u95EE\uFF1B\u5B88\u4EA4\u4ED8\u8FB9\u754C\u65F6\u522B\u7167\u7740 curl\uFF0C\u5230\u90A3\u91CC\u505C\u4E0B\u8BF7\u6709\u6743\u9650\u7684\u4EBA\u505A"] : lines;
|
|
8438
|
+
}
|
|
8439
|
+
function howToCommand(howTo) {
|
|
8440
|
+
if (!howTo) return void 0;
|
|
8441
|
+
const t = howTo.trim();
|
|
8442
|
+
const direct2 = /^(?:GET|POST|PUT|DELETE|PATCH) \/api\/models\/([^/\s]+)\/(?:([^/\s]+)\/)?action\/([^/\s?]+)$/.exec(t);
|
|
8443
|
+
if (direct2) {
|
|
8444
|
+
const [, model, id, action] = direct2;
|
|
8445
|
+
const idArg = id ? ` --id ${id === "{id}" ? "<id>" : shellArg(id)}` : "";
|
|
8446
|
+
return `\`hcm action ${model}.${action}${idArg}\``;
|
|
8447
|
+
}
|
|
8448
|
+
const lookup = /^GET \/api\/models\/([^/\s]+)\/actions → 找 key=([^\s((]+)/.exec(t);
|
|
8449
|
+
if (lookup) {
|
|
8450
|
+
const [, model, action] = lookup;
|
|
8451
|
+
return `\`hcm describe ${model}\`\uFF08\u627E ${action} \u90A3\u4E00\u884C\uFF0C\u770B\u4F5C\u7528\u57DF\u4E0E grant\uFF09\u518D \`hcm action ${model}.${action}\``;
|
|
8452
|
+
}
|
|
8453
|
+
return void 0;
|
|
8454
|
+
}
|
|
8455
|
+
var CAPABILITY_CLI = {
|
|
8456
|
+
"GET /api/system/introspection": "`hcm introspect`",
|
|
8457
|
+
"GET /api/system/models": "`hcm models [\u5173\u952E\u5B57]`",
|
|
8458
|
+
"GET /api/system/models/search": "`hcm models <\u8BF4\u6CD5> --search`",
|
|
8459
|
+
"GET /api/models/{model}/meta": "`hcm describe <Model>`\uFF08\u5B57\u6BB5\u4E0E action \u53C2\u6570\uFF1B\u679A\u4E3E\u52A0 -v\uFF1B\u4E0D\u542B permission \u4E0E\u89C6\u56FE\u5B9A\u4E49\uFF09",
|
|
8460
|
+
"GET /api/models/{model}/actions": "`hcm describe <Model> --state <\u89C6\u56FE>`\uFF08actions \u6BB5\uFF09",
|
|
8461
|
+
"GET /api/models/{model}/mutation-capability": "`hcm describe <Model>`\uFF08\u901A\u7528\u589E\u5220\u6539\u6BB5\uFF09",
|
|
8462
|
+
"GET /api/models/{model}/preset-origin": "`hcm preset-origin <Model>`",
|
|
8463
|
+
"GET /api/version/backend": "`hcm version`",
|
|
8464
|
+
"GET /api/chiron.json": "`hcm skills list`",
|
|
8465
|
+
"GET /api/chiron/skills/{id}.md": "`hcm skills show <id>`",
|
|
8466
|
+
"GET /api/system/health/report": "`hcm chiron doctor`",
|
|
8467
|
+
"POST /api/system/health/report": "`hcm chiron doctor --active`",
|
|
8468
|
+
"GET /api/system/health/checks": "`hcm chiron doctor --list`",
|
|
8469
|
+
"POST /api/script/manifest/validate": "`hcm script manifest-validate`"
|
|
8470
|
+
};
|
|
8471
|
+
var CLI_NOT_PROVIDED = "CLI \u672A\u63D0\u4F9B";
|
|
8472
|
+
function cliCommandForCapability(method3, path49) {
|
|
8473
|
+
if (!method3 || !path49) return null;
|
|
8474
|
+
return CAPABILITY_CLI[`${method3} ${path49}`] ?? null;
|
|
8475
|
+
}
|
|
8476
|
+
|
|
8477
|
+
// src/commands/describe.ts
|
|
8354
8478
|
async function describeCommand(model, args) {
|
|
8355
8479
|
try {
|
|
8356
8480
|
const client4 = HcmClient11.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
8357
|
-
const desc = await client4.describe(model, {
|
|
8481
|
+
const desc = await client4.describe(model, {
|
|
8482
|
+
verbose: !!args.verbose,
|
|
8483
|
+
...args.state !== void 0 ? { state: args.state } : {},
|
|
8484
|
+
withMutationCapability: true
|
|
8485
|
+
});
|
|
8358
8486
|
const fmt = args.output ?? "table";
|
|
8359
8487
|
if (fmt !== "table") {
|
|
8360
8488
|
process.stdout.write(formatObject10(desc, { format: fmt }) + "\n");
|
|
@@ -8376,8 +8504,8 @@ function formatEnumValues(enums) {
|
|
|
8376
8504
|
if (!enums?.length) return "";
|
|
8377
8505
|
const items = enums.map((e) => {
|
|
8378
8506
|
const raw = e.value ?? e.key;
|
|
8379
|
-
const
|
|
8380
|
-
return e.label && e.label !==
|
|
8507
|
+
const shown2 = raw === void 0 || raw === null ? "?" : String(raw);
|
|
8508
|
+
return e.label && e.label !== shown2 ? `${shown2}=${e.label}` : shown2;
|
|
8381
8509
|
});
|
|
8382
8510
|
return `[${items.join("|")}]`;
|
|
8383
8511
|
}
|
|
@@ -8417,14 +8545,14 @@ function formatDescriptionTable(desc, verbose = false) {
|
|
|
8417
8545
|
' \u2139\uFE0F (match) = \u53EF\u7528\u8BED\u4E49\u5339\u914D\uFF1Afilter \u5199 {"field":"<\u5B57\u6BB5>","op":"match","value":"<\u7B80\u79F0\u6216\u53E3\u8BED>"}\uFF0C\u670D\u52A1\u7AEF\u6309\u8BED\u4E49\u7EB3\u5165\u771F\u5B9E\u53D6\u503C\u518D\u6539\u5199\u6210 in\uFF1B\u7EB3\u5165\u4E86\u54EA\u4E9B\u503C\u3001\u662F\u5426\u964D\u7EA7\u4E3A\u5B57\u9762\u5305\u542B\uFF0C\u89C1 hcm query \u6253\u5230 stderr \u7684\u63D0\u793A'
|
|
8418
8546
|
);
|
|
8419
8547
|
}
|
|
8420
|
-
lines.push(`actions (${desc.actions.length}):`);
|
|
8548
|
+
lines.push(`actions (${desc.actions.length}${actionsScopeNote(desc)}):`);
|
|
8421
8549
|
for (const a of desc.actions) {
|
|
8422
8550
|
const call = [a.scope, a.httpMethod].filter(Boolean).join(" ");
|
|
8423
8551
|
const params = a.params?.length ? ` params: ${a.params.map((p) => `${p.name}:${p.type}`).join(", ")}` : "";
|
|
8424
8552
|
const description = verbose && a.description ? ` ${a.description}` : "";
|
|
8425
8553
|
const source = a.source && a.source.toLowerCase() !== "java" ? ` [${a.source.toLowerCase()}]` : "";
|
|
8426
8554
|
lines.push(
|
|
8427
|
-
` ${a.name.padEnd(20)} ${call.padEnd(12)} ${a.label ?? ""}${source}${params}${description}`
|
|
8555
|
+
` ${a.name.padEnd(20)} ${call.padEnd(12)} ${a.label ?? ""}${source} ${actionTags(desc, a, verbose)}${params}${description}`
|
|
8428
8556
|
);
|
|
8429
8557
|
}
|
|
8430
8558
|
if (!desc.effectiveActionsAvailable) {
|
|
@@ -8432,6 +8560,7 @@ function formatDescriptionTable(desc, verbose = false) {
|
|
|
8432
8560
|
` \u26A0\uFE0F \u4EE5\u4E0A\u53EA\u542B\u6CE8\u89E3 action\uFF0CYAML \u58F0\u660E\u7684\u811A\u672C Action \u672A\u7EB3\u5165\uFF1A${desc.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}`
|
|
8433
8561
|
);
|
|
8434
8562
|
}
|
|
8563
|
+
if (desc.actions.length) lines.push(...actionLegend(desc));
|
|
8435
8564
|
if (desc.relations.length) {
|
|
8436
8565
|
lines.push(`relations: ${desc.relations.map((r) => {
|
|
8437
8566
|
const target = r.target ? ` \u2192 ${r.target}` : "";
|
|
@@ -8441,8 +8570,123 @@ function formatDescriptionTable(desc, verbose = false) {
|
|
|
8441
8570
|
return `${r.key}(via ${r.via}${target}${card}${filter}${declared})`;
|
|
8442
8571
|
}).join(", ")}`);
|
|
8443
8572
|
}
|
|
8573
|
+
if (desc.mutationCapability) lines.push(...formatMutationCapability(desc.model, desc.mutationCapability));
|
|
8444
8574
|
return lines.join("\n");
|
|
8445
8575
|
}
|
|
8576
|
+
function actionsScopeNote(desc) {
|
|
8577
|
+
if (!desc.effectiveActionsAvailable) return "";
|
|
8578
|
+
const state = desc.actionsState === void 0 ? `state=${NOT_PROVIDED}` : desc.actionsState === "" ? "state=\u9ED8\u8BA4\u89C6\u56FE" : `state=${desc.actionsState}`;
|
|
8579
|
+
const coverage = desc.actionsCoverage ?? `coverage=${NOT_PROVIDED}`;
|
|
8580
|
+
return `\uFF0C${state}\uFF0C${coverage}`;
|
|
8581
|
+
}
|
|
8582
|
+
function shown(v, notProvided) {
|
|
8583
|
+
if (notProvided || v === void 0) return NOT_PROVIDED;
|
|
8584
|
+
return typeof v === "string" ? v : JSON.stringify(v);
|
|
8585
|
+
}
|
|
8586
|
+
function grantCell(desc, a) {
|
|
8587
|
+
if (!desc.effectiveActionsAvailable) return "\u672A\u53D6\u5230";
|
|
8588
|
+
if (a.effectiveRow === "not-listed") return "\u4E0D\u5728\u6709\u6548\u96C6";
|
|
8589
|
+
return shown(a.grantForCaller, !!a.notProvided?.includes("grantForCaller"));
|
|
8590
|
+
}
|
|
8591
|
+
function actionTags(desc, a, verbose) {
|
|
8592
|
+
const tags = [
|
|
8593
|
+
`effect=${shown(a.effect, !!a.notProvided?.includes("effect"))}`,
|
|
8594
|
+
`grant=${grantCell(desc, a)}`
|
|
8595
|
+
];
|
|
8596
|
+
if (verbose) {
|
|
8597
|
+
tags.push(
|
|
8598
|
+
`ext=${shown(a.hasExternalDep, false)}`,
|
|
8599
|
+
`sens=${shown(a.sensitiveData, false)}`,
|
|
8600
|
+
`confirm=${shown(a.requiresConfirmation ?? a.confirm, false)}`
|
|
8601
|
+
);
|
|
8602
|
+
if (desc.effectiveActionsAvailable && a.effectiveRow === "listed") tags.push(`conflict=${shown(a.conflict, false)}`);
|
|
8603
|
+
}
|
|
8604
|
+
return tags.join(" ");
|
|
8605
|
+
}
|
|
8606
|
+
var EFFECT_MEANING = {
|
|
8607
|
+
READ_ONLY: "\u5224\u8FC7\u3001\u4E0D\u5199\u5E93",
|
|
8608
|
+
WRITES: "\u5224\u8FC7\u3001\u4F1A\u5199\u5E93",
|
|
8609
|
+
ACCOUNTING_ONLY: "\u4E0D\u5199\u4E1A\u52A1\u6570\u636E\uFF0C\u53EA\u4EA7\u751F\u767B\u8BB0\u5728\u518C\u7684\u8BB0\u8D26\u7C7B\u526F\u4F5C\u7528\uFF08\u9700\u786E\u8BA4\uFF09",
|
|
8610
|
+
UNKNOWN: "\u6CA1\u4EBA\u5224\u8FC7\u2014\u2014\u4E0D\u662F\u300C\u5B89\u5168\u300D\uFF0C\u6309\u4F1A\u5199\u5BF9\u5F85"
|
|
8611
|
+
};
|
|
8612
|
+
var GRANT_MEANING = {
|
|
8613
|
+
GRANTED: "\u5F53\u524D\u8EAB\u4EFD\u6709\u8D44\u683C\u53D1\u8D77",
|
|
8614
|
+
NOT_GRANTED: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u88AB\u6388\u4E88",
|
|
8615
|
+
NOT_CONSTRAINED: "\u6A21\u578B\u6CA1\u6709 permission \u5757\uFF0C\u6388\u6743\u5C42\u4E0D\u6784\u6210\u7EA6\u675F\u2014\u2014\u4E0D\u7B49\u4E8E\u300C\u53EF\u8C03\u300D\uFF0C\u4E0D\u80FD\u5F53 GRANTED \u7528",
|
|
8616
|
+
NOT_RESOLVED: "\u670D\u52A1\u7AEF\u8FD9\u6B21\u6CA1\u5224\u51FA\u6765\uFF08\u6CA1\u8BFB\u51FA meta\uFF09\u2014\u2014\u4E0D\u662F\u300C\u6CA1\u6743\u9650\u300D\uFF0C\u4E5F\u4E0D\u662F\u300C\u6709\u6743\u300D",
|
|
8617
|
+
\u672A\u53D6\u5230: "\u8FD9\u6B21\u6CA1\u8BFB\u5230 /actions\uFF0C\u6388\u6743\u6863\u4F4D\u65E0\u4ECE\u8BF4\u8D77",
|
|
8618
|
+
\u4E0D\u5728\u6709\u6548\u96C6: "\u672C\u89C6\u56FE\u4E0B /actions \u6CA1\u5217\u8FD9\u4E00\u884C\uFF08\u6362 --state \u518D\u770B\uFF09",
|
|
8619
|
+
[NOT_PROVIDED]: "\u670D\u52A1\u7AEF\u65E9\u4E8E\u8BE5\u5B57\u6BB5\uFF0C\u6CA1\u8BF4\u2014\u2014\u4E0D\u8BB8\u6309\u4EFB\u4F55\u4E00\u6863\u8BFB"
|
|
8620
|
+
};
|
|
8621
|
+
function actionLegend(desc) {
|
|
8622
|
+
const effects = /* @__PURE__ */ new Set();
|
|
8623
|
+
const grants = /* @__PURE__ */ new Set();
|
|
8624
|
+
for (const a of desc.actions) {
|
|
8625
|
+
effects.add(shown(a.effect, !!a.notProvided?.includes("effect")));
|
|
8626
|
+
grants.add(grantCell(desc, a));
|
|
8627
|
+
}
|
|
8628
|
+
const describeSet = (set, meaning) => [...set].map((v) => `${v} ${meaning[v] ?? (v === NOT_PROVIDED ? "\u670D\u52A1\u7AEF\u65E9\u4E8E\u8BE5\u5B57\u6BB5" : "\uFF08\u8FD9\u7248 CLI \u4E0D\u8BA4\u8BC6\u8FD9\u4E00\u6863\uFF0C\u7167\u670D\u52A1\u7AEF\u539F\u6587\u5224\uFF09")}`).join(" \xB7 ");
|
|
8629
|
+
const lines = [
|
|
8630
|
+
` \u2139\uFE0F effect\uFF1A${describeSet(effects, { ...EFFECT_MEANING, [NOT_PROVIDED]: "\u670D\u52A1\u7AEF\u65E9\u4E8E effect \u58F0\u660E\uFF0C\u6CA1\u8BF4" })}`,
|
|
8631
|
+
" \u2139\uFE0F grant = \u5F53\u524D\u8EAB\u4EFD\u80FD\u4E0D\u80FD\u53D1\u8D77\u8FD9\u4E2A action\uFF0C\u53EA\u5224\u5230\u6388\u6743\u5C42\uFF08grant\uFF09\uFF0C\u4E0D\u542B\u884C\u7EA7\u8303\u56F4\uFF1AGRANTED \u4E5F\u4E0D\u4EE3\u8868\u5BF9\u4EFB\u610F\u4E00\u884C\u90FD\u80FD\u8C03\uFF0C\u884C\u7EA7\u8303\u56F4\u5728\u6267\u884C\u65F6\u5224",
|
|
8632
|
+
` ${describeSet(grants, GRANT_MEANING)}`
|
|
8633
|
+
];
|
|
8634
|
+
if (desc.effectiveActionsAvailable) {
|
|
8635
|
+
const view = desc.actionsState === void 0 ? `state=${NOT_PROVIDED} \u7684\u89C6\u56FE` : desc.actionsState ? `state=${desc.actionsState}` : "\u9ED8\u8BA4\u89C6\u56FE";
|
|
8636
|
+
lines.push(` \u2139\uFE0F \u8FD9\u4EFD\u52A8\u4F5C\u96C6\u53EA\u5BF9 ${view} \u6210\u7ACB\uFF08state-scoped\uFF09\uFF0C\u522B\u7684\u89C6\u56FE\u6362 \`--state <\u89C6\u56FE>\` \u518D\u770B\uFF1B\u5916\u90E8\u4F9D\u8D56 / \u654F\u611F\u6570\u636E / \u786E\u8BA4\u8981\u6C42\u52A0 -v \u770B`);
|
|
8637
|
+
}
|
|
8638
|
+
return lines;
|
|
8639
|
+
}
|
|
8640
|
+
function formatMutationCapability(model, mc) {
|
|
8641
|
+
if (!mc.available) {
|
|
8642
|
+
return mc.notProvided ? [`\u901A\u7528\u589E\u5220\u6539\uFF1A${NOT_PROVIDED}\uFF08${mc.note}\uFF09`] : [`\u901A\u7528\u589E\u5220\u6539\uFF1A\u8BFB\u4E0D\u5230\uFF08${mc.note}\uFF09\u2014\u2014\u4E0D\u7B49\u4E8E\u300C\u4E0D\u80FD\u6539\u300D\uFF0C\u4E5F\u4E0D\u7B49\u4E8E\u300C\u80FD\u6539\u300D`];
|
|
8643
|
+
}
|
|
8644
|
+
const lines = ["\u901A\u7528\u589E\u5220\u6539\uFF08hcm create / update / delete \u80FD\u4E0D\u80FD\u76F4\u63A5\u7528\uFF1B\u53EA\u5224\u7ED3\u6784\u4E0E\u6CE8\u89E3\uFF0C\u4E0D\u5224 RBAC\u3001\u4E0D\u5224\u8FD0\u884C\u671F\u95F8\uFF09\uFF1A"];
|
|
8645
|
+
const rbac = /* @__PURE__ */ new Map();
|
|
8646
|
+
const gates = /* @__PURE__ */ new Map();
|
|
8647
|
+
const gateNotProvided = [];
|
|
8648
|
+
const scopes = /* @__PURE__ */ new Set();
|
|
8649
|
+
for (const op of MUTATION_CAPABILITY_OPS) {
|
|
8650
|
+
const key2 = op in mc.ops ? op : op === "batchDelete" && "batch_delete" in mc.ops ? "batch_delete" : void 0;
|
|
8651
|
+
if (!key2) {
|
|
8652
|
+
lines.push(` ${op.padEnd(12)} ${NOT_PROVIDED}`);
|
|
8653
|
+
continue;
|
|
8654
|
+
}
|
|
8655
|
+
const cell2 = mc.ops[key2] ?? {};
|
|
8656
|
+
const missing2 = missingKeys(cell2, MUTATION_CELL_KEYS);
|
|
8657
|
+
const allowed = "allowed" in cell2 ? String(cell2.allowed) : NOT_PROVIDED;
|
|
8658
|
+
let line = ` ${op.padEnd(12)} allowed=${allowed}${key2 !== op ? `\uFF08\u670D\u52A1\u7AEF\u952E\u540D ${key2}\uFF0C\u65E7\u5199\u6CD5\uFF09` : ""}`;
|
|
8659
|
+
if (cell2.allowed !== true && cell2.reason) line += ` \u539F\u56E0\uFF1A${cell2.reason}`;
|
|
8660
|
+
if (missing2.length && missing2.some((k) => k !== "allowed")) line += ` \uFF08\u7F3A ${missing2.filter((k) => k !== "allowed").join("\u3001")}\uFF1A${NOT_PROVIDED}\uFF09`;
|
|
8661
|
+
lines.push(line);
|
|
8662
|
+
const alts = Array.isArray(cell2.alternatives) ? cell2.alternatives : [];
|
|
8663
|
+
if (alts.length) {
|
|
8664
|
+
lines.push(` \u66FF\u4EE3\u5165\u53E3 ${alts.length} \u6761\uFF1A`);
|
|
8665
|
+
for (const alt of alts) {
|
|
8666
|
+
const cmd = howToCommand(alt.howTo);
|
|
8667
|
+
const how = cmd ?? (alt.howTo ? `\u670D\u52A1\u7AEF\u539F\u6587 ${alt.howTo}` : `\u8C03\u7528\u5F62\u6001 ${NOT_PROVIDED}`);
|
|
8668
|
+
const other = alt.model && alt.model !== model ? `\uFF08\u5728 ${alt.model} \u4E0A\uFF09` : "";
|
|
8669
|
+
lines.push(` \xB7 ${how}${other}${alt.when ? ` ${alt.when}` : ""}`);
|
|
8670
|
+
}
|
|
8671
|
+
} else if (cell2.allowed === false && "alternatives" in cell2) {
|
|
8672
|
+
lines.push(" \u66FF\u4EE3\u5165\u53E3\uFF1A\u670D\u52A1\u7AEF\u6CA1\u767B\u8BB0\uFF08\u7A7A\u5217\u8868\uFF09\u2014\u2014\u522B\u731C\u4E00\u4E2A action \u53BB\u8BD5\uFF0C\u5148\u95EE\u4EBA");
|
|
8673
|
+
}
|
|
8674
|
+
if (typeof cell2.scope === "string") scopes.add(cell2.scope);
|
|
8675
|
+
if (typeof cell2.rbacSource === "string") rbac.set(cell2.rbacSource, [...rbac.get(cell2.rbacSource) ?? [], op]);
|
|
8676
|
+
if (typeof cell2.runtimeGateSource === "string") {
|
|
8677
|
+
gates.set(cell2.runtimeGateSource, [...gates.get(cell2.runtimeGateSource) ?? [], op]);
|
|
8678
|
+
} else if (cell2.allowed === true) {
|
|
8679
|
+
gateNotProvided.push(op);
|
|
8680
|
+
}
|
|
8681
|
+
}
|
|
8682
|
+
if (scopes.size) lines.push(` scope=${[...scopes].join(",")}\uFF08\u7ED3\u6784\u9762\uFF1Aallowed=true \u53EA\u4EE3\u8868\u7ED3\u6784\u4E0E\u6CE8\u89E3\u5141\u8BB8\uFF09`);
|
|
8683
|
+
for (const [text2, ops] of rbac) lines.push(` RBAC\uFF08${ops.join(" / ")}\uFF09\uFF1A${text2}`);
|
|
8684
|
+
for (const [text2, ops] of gates) lines.push(` \u8FD0\u884C\u671F\u95F8\uFF08${ops.join(" / ")}\uFF09\uFF1A${text2}`);
|
|
8685
|
+
if (gateNotProvided.length) {
|
|
8686
|
+
lines.push(` \u8FD0\u884C\u671F\u95F8\uFF08${gateNotProvided.join(" / ")}\uFF09\uFF1A${NOT_PROVIDED}\uFF08\u670D\u52A1\u7AEF\u6CA1\u8BF4\u6709\u6CA1\u6709\u8FD0\u884C\u671F\u95F8\u2014\u2014allowed=true \u4E0D\u4EE3\u8868\u771F\u53D1\u8BF7\u6C42\u4E0D\u4F1A\u88AB\u62D2\uFF09`);
|
|
8687
|
+
}
|
|
8688
|
+
return markRestLeftovers(lines);
|
|
8689
|
+
}
|
|
8446
8690
|
|
|
8447
8691
|
// src/commands/chat.ts
|
|
8448
8692
|
import {
|
|
@@ -9098,6 +9342,7 @@ async function chatCommand(prompt, args) {
|
|
|
9098
9342
|
elapsedMs: r.elapsedMs,
|
|
9099
9343
|
stopReason: r.stopReason,
|
|
9100
9344
|
tokens: r.tokens,
|
|
9345
|
+
notices: r.notices,
|
|
9101
9346
|
events: r.events
|
|
9102
9347
|
},
|
|
9103
9348
|
{ format: "json" }
|
|
@@ -9114,6 +9359,8 @@ async function chatCommand(prompt, args) {
|
|
|
9114
9359
|
);
|
|
9115
9360
|
}
|
|
9116
9361
|
}
|
|
9362
|
+
for (const n2 of r.notices) process.stderr.write(chalk2.gray(`${n2.text || `[${n2.notice}]`}
|
|
9363
|
+
`));
|
|
9117
9364
|
process.stdout.write(r.content + "\n");
|
|
9118
9365
|
process.stdout.write(
|
|
9119
9366
|
chalk2.dim(
|
|
@@ -9844,19 +10091,72 @@ async function traceCommand(traceId, args) {
|
|
|
9844
10091
|
}
|
|
9845
10092
|
}
|
|
9846
10093
|
|
|
10094
|
+
// src/commands/subscription-migration.ts
|
|
10095
|
+
init_auth_guard();
|
|
10096
|
+
init_exit();
|
|
10097
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
10098
|
+
import { HcmClient as HcmClient18, fromAxiosError as fromAxiosError18 } from "@hcmai/sdk";
|
|
10099
|
+
var FAILED_TASK_STATUSES = /* @__PURE__ */ new Set(["FAILED", "CANCELLED", "TIMEOUT", "DEAD_LETTERED"]);
|
|
10100
|
+
async function subscriptionMigrationCommand(operation, args) {
|
|
10101
|
+
try {
|
|
10102
|
+
if (args.output && args.output !== "json") throw new Error("\u8FC1\u79FB\u547D\u4EE4\u53EA\u652F\u6301 --output json\uFF0C\u5B8C\u6574\u4FDD\u7559\u672A\u77E5\u8BA1\u6570\u4E0E\u539F\u56E0");
|
|
10103
|
+
let body = {};
|
|
10104
|
+
if (args.data) {
|
|
10105
|
+
const text2 = args.data.startsWith("@") ? await readFile5(args.data.slice(1), "utf8") : args.data;
|
|
10106
|
+
const parsed = JSON.parse(text2);
|
|
10107
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("--data \u5FC5\u987B\u662F JSON \u5BF9\u8C61\u6216 @\u6587\u4EF6");
|
|
10108
|
+
body = parsed;
|
|
10109
|
+
}
|
|
10110
|
+
if (args.dryRunTaskId) body.dryRunTaskId = args.dryRunTaskId;
|
|
10111
|
+
if (args.taskId) body.taskId = args.taskId;
|
|
10112
|
+
if (args.recordIds !== void 0) {
|
|
10113
|
+
const ids = args.recordIds.split(",").map((id) => id.trim());
|
|
10114
|
+
if (ids.some((id) => id === "")) throw new Error("--record-ids \u542B\u7A7A id\uFF1B\u5199\u6210\u9017\u53F7\u5206\u9694\u7684\u7269\u7406\u8BB0\u5F55 UUID\uFF0C\u4F8B\u5982 --record-ids <id1>,<id2>");
|
|
10115
|
+
body.recordIds = ids;
|
|
10116
|
+
}
|
|
10117
|
+
if (operation === "apply" && !body.dryRunTaskId) throw new Error("apply \u5FC5\u987B\u4F20 --dry-run-task-id <id>\uFF0C\u5148 dry-run \u5E76\u67E5\u770B\u5B8C\u6574\u62A5\u544A");
|
|
10118
|
+
if (operation === "restore" && Boolean(body.taskId) === Boolean(body.recordIds)) throw new Error("restore \u5FC5\u987B\u4F20 --task-id \u6216 --record-ids\uFF0C\u4E8C\u9009\u4E00");
|
|
10119
|
+
if (operation === "status" && !args.taskId) throw new Error("status \u5FC5\u987B\u4F20\u4EFB\u52A1 id");
|
|
10120
|
+
const client4 = HcmClient18.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
10121
|
+
const base = "/api/subscription-migration";
|
|
10122
|
+
const response = operation === "status" ? await client4.raw().get(`${base}/tasks/${encodeURIComponent(args.taskId)}`) : await client4.raw().post(`${base}/${operation}`, body);
|
|
10123
|
+
const payload = response.data;
|
|
10124
|
+
process.stdout.write(JSON.stringify(payload, null, 2) + "\n");
|
|
10125
|
+
const result = payload?.data ?? payload;
|
|
10126
|
+
if (operation !== "status" && result?.taskId) {
|
|
10127
|
+
process.stderr.write(`\u4E0B\u4E00\u6B65\uFF1Ahcm subscription-migration status ${result.taskId}${args.env ? ` --env ${args.env}` : ""}
|
|
10128
|
+
`);
|
|
10129
|
+
} else if (result?.nextStep) {
|
|
10130
|
+
process.stderr.write(`\u4E0B\u4E00\u6B65\uFF1A${result.nextStep}
|
|
10131
|
+
`);
|
|
10132
|
+
}
|
|
10133
|
+
const failed2 = operation === "status" && FAILED_TASK_STATUSES.has(String(result?.status));
|
|
10134
|
+
if (failed2) {
|
|
10135
|
+
process.stderr.write(`\u4EFB\u52A1 ${args.taskId} \u72B6\u6001\u4E3A ${result.status}\uFF1A${result?.errorMessage ?? result?.reason ?? "\u672A\u7ED9\u51FA\u539F\u56E0"}\uFF1B\u5DF2\u5199\u6761\u76EE\u89C1 report.details / report.writtenByBackups
|
|
10136
|
+
`);
|
|
10137
|
+
}
|
|
10138
|
+
process.exitCode = failed2 ? 1 : 0;
|
|
10139
|
+
} catch (error) {
|
|
10140
|
+
if (error && typeof error === "object" && "isAxiosError" in error) {
|
|
10141
|
+
exitWithError(fromAxiosError18(error, args.env));
|
|
10142
|
+
}
|
|
10143
|
+
exitWithError(error);
|
|
10144
|
+
}
|
|
10145
|
+
}
|
|
10146
|
+
|
|
9847
10147
|
// src/commands/cache.ts
|
|
9848
10148
|
init_exit();
|
|
9849
10149
|
init_auth_guard();
|
|
9850
10150
|
import {
|
|
9851
|
-
HcmClient as
|
|
10151
|
+
HcmClient as HcmClient19,
|
|
9852
10152
|
formatObject as formatObject15,
|
|
9853
|
-
fromAxiosError as
|
|
10153
|
+
fromAxiosError as fromAxiosError19,
|
|
9854
10154
|
getCacheStats,
|
|
9855
10155
|
clearModelCache,
|
|
9856
10156
|
clearMetaCache
|
|
9857
10157
|
} from "@hcmai/sdk";
|
|
9858
10158
|
async function withClient(args, fn) {
|
|
9859
|
-
const client4 =
|
|
10159
|
+
const client4 = HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9860
10160
|
return fn(client4);
|
|
9861
10161
|
}
|
|
9862
10162
|
function emit(result, args, human) {
|
|
@@ -9868,7 +10168,7 @@ function emit(result, args, human) {
|
|
|
9868
10168
|
}
|
|
9869
10169
|
function fail3(e, args) {
|
|
9870
10170
|
const err = e;
|
|
9871
|
-
if (err?.isAxiosError) exitWithError(
|
|
10171
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
|
|
9872
10172
|
exitWithError(e);
|
|
9873
10173
|
process.exit(1);
|
|
9874
10174
|
}
|
|
@@ -9906,16 +10206,16 @@ init_exit();
|
|
|
9906
10206
|
init_auth_guard();
|
|
9907
10207
|
import { readFileSync as readFileSync4 } from "fs";
|
|
9908
10208
|
import {
|
|
9909
|
-
HcmClient as
|
|
10209
|
+
HcmClient as HcmClient20,
|
|
9910
10210
|
formatObject as formatObject16,
|
|
9911
|
-
fromAxiosError as
|
|
10211
|
+
fromAxiosError as fromAxiosError20,
|
|
9912
10212
|
scriptDryRun,
|
|
9913
10213
|
validateScriptManifest,
|
|
9914
10214
|
queryScriptLogs,
|
|
9915
10215
|
getScriptTask
|
|
9916
10216
|
} from "@hcmai/sdk";
|
|
9917
10217
|
async function withClient2(args, fn) {
|
|
9918
|
-
const client4 =
|
|
10218
|
+
const client4 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9919
10219
|
return fn(client4);
|
|
9920
10220
|
}
|
|
9921
10221
|
function emit2(result, args, human) {
|
|
@@ -9927,7 +10227,7 @@ function emit2(result, args, human) {
|
|
|
9927
10227
|
}
|
|
9928
10228
|
function fail4(e, args) {
|
|
9929
10229
|
const err = e;
|
|
9930
|
-
if (err?.isAxiosError) exitWithError(
|
|
10230
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
|
|
9931
10231
|
exitWithError(e);
|
|
9932
10232
|
process.exit(1);
|
|
9933
10233
|
}
|
|
@@ -10017,16 +10317,16 @@ async function scriptTaskCommand(taskId, args) {
|
|
|
10017
10317
|
init_exit();
|
|
10018
10318
|
init_auth_guard();
|
|
10019
10319
|
import {
|
|
10020
|
-
HcmClient as
|
|
10320
|
+
HcmClient as HcmClient21,
|
|
10021
10321
|
formatObject as formatObject17,
|
|
10022
|
-
fromAxiosError as
|
|
10322
|
+
fromAxiosError as fromAxiosError21,
|
|
10023
10323
|
uploadDocument as uploadDocument2
|
|
10024
10324
|
} from "@hcmai/sdk";
|
|
10025
10325
|
var DEFAULT_UPLOAD_CATEGORY = "attachment";
|
|
10026
10326
|
async function uploadCommand(filePath2, args) {
|
|
10027
10327
|
try {
|
|
10028
10328
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
10029
|
-
const client4 =
|
|
10329
|
+
const client4 = HcmClient21.fromAuthContext(ctx);
|
|
10030
10330
|
const meta2 = await uploadDocument2(
|
|
10031
10331
|
client4.raw(),
|
|
10032
10332
|
filePath2,
|
|
@@ -10060,7 +10360,7 @@ async function uploadCommand(filePath2, args) {
|
|
|
10060
10360
|
} else if (status === 413) {
|
|
10061
10361
|
exitWithError(new Error("\u6587\u4EF6\u8D85\u51FA\u670D\u52A1\u7AEF\u5927\u5C0F\u4E0A\u9650\uFF08413\uFF09"));
|
|
10062
10362
|
} else if (err?.isAxiosError) {
|
|
10063
|
-
exitWithError(
|
|
10363
|
+
exitWithError(fromAxiosError21(err, args.env));
|
|
10064
10364
|
} else {
|
|
10065
10365
|
exitWithError(e);
|
|
10066
10366
|
}
|
|
@@ -10071,11 +10371,11 @@ async function uploadCommand(filePath2, args) {
|
|
|
10071
10371
|
init_exit();
|
|
10072
10372
|
init_auth_guard();
|
|
10073
10373
|
import {
|
|
10074
|
-
HcmClient as
|
|
10374
|
+
HcmClient as HcmClient22,
|
|
10075
10375
|
CliError as CliError22,
|
|
10076
10376
|
CliErrorCode as CliErrorCode22,
|
|
10077
10377
|
formatObject as formatObject18,
|
|
10078
|
-
fromAxiosError as
|
|
10378
|
+
fromAxiosError as fromAxiosError22,
|
|
10079
10379
|
packDataPackage,
|
|
10080
10380
|
installDataPackageArtifactAsync,
|
|
10081
10381
|
waitForInstallRun,
|
|
@@ -10143,7 +10443,7 @@ function parseRetries(raw) {
|
|
|
10143
10443
|
async function datapackageInstallCommand(artifactPath, args) {
|
|
10144
10444
|
try {
|
|
10145
10445
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
10146
|
-
const client4 =
|
|
10446
|
+
const client4 = HcmClient22.fromAuthContext(ctx);
|
|
10147
10447
|
const fmt = args.output ?? "json";
|
|
10148
10448
|
const human = fmt !== "json";
|
|
10149
10449
|
const confirmations = {
|
|
@@ -10259,7 +10559,7 @@ async function datapackageInstallCommand(artifactPath, args) {
|
|
|
10259
10559
|
if (err?.code === "ENOENT") {
|
|
10260
10560
|
exitWithError(new Error(`\u5236\u54C1\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${artifactPath}`));
|
|
10261
10561
|
} else if (err?.isAxiosError) {
|
|
10262
|
-
exitWithError(
|
|
10562
|
+
exitWithError(fromAxiosError22(err, args.env));
|
|
10263
10563
|
} else {
|
|
10264
10564
|
exitWithError(e);
|
|
10265
10565
|
}
|
|
@@ -10268,7 +10568,7 @@ async function datapackageInstallCommand(artifactPath, args) {
|
|
|
10268
10568
|
async function datapackageStatusCommand(runId, args) {
|
|
10269
10569
|
try {
|
|
10270
10570
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
10271
|
-
const client4 =
|
|
10571
|
+
const client4 = HcmClient22.fromAuthContext(ctx);
|
|
10272
10572
|
const run3 = await fetchInstallRun(client4, runId);
|
|
10273
10573
|
const fmt = args.output ?? "json";
|
|
10274
10574
|
if (!run3) {
|
|
@@ -10297,7 +10597,7 @@ async function datapackageStatusCommand(runId, args) {
|
|
|
10297
10597
|
return;
|
|
10298
10598
|
} catch (e) {
|
|
10299
10599
|
const err = e;
|
|
10300
|
-
if (err?.isAxiosError) exitWithError(
|
|
10600
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
|
|
10301
10601
|
else exitWithError(e);
|
|
10302
10602
|
}
|
|
10303
10603
|
}
|
|
@@ -10323,7 +10623,7 @@ init_auth_guard();
|
|
|
10323
10623
|
import { promises as fs7 } from "fs";
|
|
10324
10624
|
import * as path7 from "path";
|
|
10325
10625
|
import yaml from "js-yaml";
|
|
10326
|
-
import { HcmClient as
|
|
10626
|
+
import { HcmClient as HcmClient23, fromAxiosError as fromAxiosError23, CliError as CliError23, CliErrorCode as CliErrorCode23, stripDefinitionIds, columnSlotsToFlex, redactDescriptiveUuids, removeActionsUsingScripts, stripUnknownFieldKeysForPath } from "@hcmai/sdk";
|
|
10327
10627
|
|
|
10328
10628
|
// src/commands/env-lane-api.ts
|
|
10329
10629
|
function createLaneApi(http2) {
|
|
@@ -10381,7 +10681,7 @@ function createLaneApi(http2) {
|
|
|
10381
10681
|
},
|
|
10382
10682
|
async presetOrigin(model) {
|
|
10383
10683
|
try {
|
|
10384
|
-
const resp = await http2.get(`/api/models/${model}/preset-origin
|
|
10684
|
+
const resp = await http2.get(`/api/models/${model}/preset-origin`, { params: { includeTenantIds: true } });
|
|
10385
10685
|
return resp.data;
|
|
10386
10686
|
} catch (e) {
|
|
10387
10687
|
if (e.response?.status === 404) return void 0;
|
|
@@ -10531,6 +10831,51 @@ function resolveLanes(metas, metaUnavailable = []) {
|
|
|
10531
10831
|
configModels.sort((a, b) => order(a) - order(b) || a.localeCompare(b));
|
|
10532
10832
|
return { laneSource, configModels, envLocalModels, skipped: skipped2 };
|
|
10533
10833
|
}
|
|
10834
|
+
var idOf = (r) => typeof r.id === "string" ? r.id.toLowerCase() : void 0;
|
|
10835
|
+
var idList = (v) => Array.isArray(v) && v.every((x) => typeof x === "string") ? v.map((x) => x.toLowerCase()) : void 0;
|
|
10836
|
+
var OLD_CORE_HINT = "\u6E90\u73AF\u5883 Core \u4E0D\u56DE\u884C\u7EA7 id\uFF08\u65E9\u4E8E HCMNX-806 \u7684 preset-origin?includeTenantIds\uFF09\uFF0C\u53EA\u80FD\u6309 createById \u731C\uFF1B\u6E90\u73AF\u5883\u5347\u7EA7 Core \u540E\u91CD\u65B0\u5BFC\u51FA\u5373\u53EF\u9010\u884C\u5206\u4FA7";
|
|
10837
|
+
function splitByServerIds(rows2, origin, baseline, original, override) {
|
|
10838
|
+
if (origin.tenantIds === void 0) return void 0;
|
|
10839
|
+
const ovr = idList(origin.tenantIds?.TENANT_OVERRIDE), orig = idList(origin.tenantIds?.TENANT_ORIGINAL);
|
|
10840
|
+
if (!ovr || !orig) {
|
|
10841
|
+
return {
|
|
10842
|
+
tenantRows: [],
|
|
10843
|
+
systemRows: 0,
|
|
10844
|
+
tenantOriginal: original,
|
|
10845
|
+
tenantOverride: override,
|
|
10846
|
+
classification: "COUNTS_MISMATCH",
|
|
10847
|
+
detail: "preset-origin \u56DE\u4E86 tenantIds \u4F46\u5F62\u72B6\u4E0D\u8BA4\u8BC6\uFF08\u5E94\u4E3A TENANT_OVERRIDE / TENANT_ORIGINAL \u4E24\u4E2A id \u5B57\u7B26\u4E32\u6570\u7EC4\uFF09\uFF0C\u4E0D\u6562\u5206\u4FA7"
|
|
10848
|
+
};
|
|
10849
|
+
}
|
|
10850
|
+
if (ovr.length !== override || orig.length !== original) {
|
|
10851
|
+
return {
|
|
10852
|
+
tenantRows: [],
|
|
10853
|
+
systemRows: 0,
|
|
10854
|
+
tenantOriginal: original,
|
|
10855
|
+
tenantOverride: override,
|
|
10856
|
+
classification: "COUNTS_MISMATCH",
|
|
10857
|
+
detail: `\u670D\u52A1\u7AEF id \u6E05\u5355\u4E0E\u8BA1\u6570\u5BF9\u4E0D\u4E0A\uFF1A\u8986\u76D6 id ${ovr.length} / \u8BA1\u6570 ${override}\uFF0C\u539F\u521B id ${orig.length} / \u8BA1\u6570 ${original}`
|
|
10858
|
+
};
|
|
10859
|
+
}
|
|
10860
|
+
const unique = /* @__PURE__ */ new Map();
|
|
10861
|
+
let noId = 0;
|
|
10862
|
+
for (const r of rows2) {
|
|
10863
|
+
const id = idOf(r);
|
|
10864
|
+
if (id === void 0) noId++;
|
|
10865
|
+
else if (!unique.has(id)) unique.set(id, r);
|
|
10866
|
+
}
|
|
10867
|
+
const tenantIds = /* @__PURE__ */ new Set([...ovr, ...orig]), overrideSet = new Set(ovr);
|
|
10868
|
+
const tenantRows = [...unique.entries()].filter(([id]) => tenantIds.has(id)).map(([, r]) => r);
|
|
10869
|
+
const missing2 = [...tenantIds].filter((id) => !unique.has(id));
|
|
10870
|
+
const listedOverride = tenantRows.filter((r) => overrideSet.has(idOf(r))).length;
|
|
10871
|
+
const systemRows = unique.size - tenantRows.length + noId, expectSystem = baseline - override;
|
|
10872
|
+
const split2 = { tenantRows, systemRows, tenantOriginal: tenantRows.length - listedOverride, tenantOverride: listedOverride };
|
|
10873
|
+
const gaps = [];
|
|
10874
|
+
if (missing2.length) gaps.push(`\u670D\u52A1\u7AEF\u5224\u4E3A\u79DF\u6237\u81EA\u6709 ${tenantIds.size} \u884C\uFF0C\u5217\u8868\u53EA\u8BFB\u5230 ${tenantRows.length} \u884C\uFF0C\u7F3A ${missing2.length} \u884C\u672A\u5BFC\u51FA\uFF08\u4F8B\uFF1A${missing2.slice(0, 5).join("\u3001")}\uFF1B\u9010\u884C\u67E5 GET /api/models/{\u6A21\u578B}/preset-origin?id=<id>\uFF0C\u518D\u67E5\u5217\u8868\u4E3A\u4EC0\u4E48\u8BFB\u4E0D\u5230\uFF1A\u6743\u9650 / \u5185\u7F6E\u8FC7\u6EE4\uFF09`);
|
|
10875
|
+
if (systemRows !== expectSystem) gaps.push(`\u5217\u8868\u91CC\u4E0D\u5728\u79DF\u6237\u6E05\u5355\u4E0A\u7684 ${systemRows} \u884C\u4E0E\u7CFB\u7EDF\u4FA7\u8BA1\u6570 ${expectSystem}\uFF08\u57FA\u7EBF ${baseline} \u2212 \u8986\u76D6 ${override}\uFF09\u5BF9\u4E0D\u4E0A${noId ? `\uFF08\u5176\u4E2D ${noId} \u884C\u6CA1\u6709 id\uFF09` : ""}\uFF0C\u591A\u51FA\u6765\u7684\u53EF\u80FD\u662F\u5BFC\u51FA\u671F\u95F4\u65B0\u5EFA\u7684\u79DF\u6237\u884C\uFF0C\u672A\u5BFC\u51FA\uFF1B\u91CD\u65B0\u5BFC\u51FA\u4E00\u6B21\u518D\u770B`);
|
|
10876
|
+
if (!gaps.length) return { ...split2, classification: "SERVER_IDS" };
|
|
10877
|
+
return { ...split2, classification: "SERVER_IDS_UNRECONCILED", detail: gaps.join("\uFF1B") };
|
|
10878
|
+
}
|
|
10534
10879
|
var isTenantByHeuristic = (r) => r.customized === true || typeof r.createById === "string" && r.createById !== SYSTEM_USER_ID;
|
|
10535
10880
|
function splitPresetRows(rows2, origin, isPresetByMeta) {
|
|
10536
10881
|
if (origin && !origin.presetModel) {
|
|
@@ -10563,10 +10908,19 @@ function splitPresetRows(rows2, origin, isPresetByMeta) {
|
|
|
10563
10908
|
}
|
|
10564
10909
|
const baseline = c2.SYSTEM_BASELINE, override = c2.TENANT_OVERRIDE, original = c2.TENANT_ORIGINAL;
|
|
10565
10910
|
if (original + override === 0) return { tenantRows: [], systemRows: rows2.length, tenantOriginal: 0, tenantOverride: 0, classification: "ALL_SYSTEM" };
|
|
10911
|
+
const byIds = splitByServerIds(rows2, origin, baseline, original, override);
|
|
10912
|
+
if (byIds) return byIds;
|
|
10566
10913
|
if (baseline === 0) return { tenantRows: rows2, systemRows: 0, tenantOriginal: original, tenantOverride: override, classification: "ALL_TENANT" };
|
|
10567
10914
|
const expectTenant = original + override, expectSystem = baseline - override;
|
|
10568
10915
|
if (tenant2.length === expectTenant && rows2.length - tenant2.length === expectSystem && overrides === override) {
|
|
10569
|
-
return {
|
|
10916
|
+
return {
|
|
10917
|
+
tenantRows: tenant2,
|
|
10918
|
+
systemRows: expectSystem,
|
|
10919
|
+
tenantOriginal: original,
|
|
10920
|
+
tenantOverride: override,
|
|
10921
|
+
classification: "CREATE_BY_VERIFIED_BY_COUNTS",
|
|
10922
|
+
detail: `\u53EA\u662F\u6761\u6570\u5BF9\u4E0A\uFF1A\u731C\u53CD\u7684\u884C\u6070\u597D\u62B5\u6D88\u65F6\u4E5F\u5BF9\u5F97\u4E0A\uFF0C\u53EF\u80FD\u5BFC\u51FA\u7CFB\u7EDF\u884C\u3001\u6F0F\u6389\u79DF\u6237\u884C\uFF1B${OLD_CORE_HINT}`
|
|
10923
|
+
};
|
|
10570
10924
|
}
|
|
10571
10925
|
return {
|
|
10572
10926
|
tenantRows: [],
|
|
@@ -10574,8 +10928,95 @@ function splitPresetRows(rows2, origin, isPresetByMeta) {
|
|
|
10574
10928
|
tenantOriginal: original,
|
|
10575
10929
|
tenantOverride: override,
|
|
10576
10930
|
classification: "COUNTS_MISMATCH",
|
|
10577
|
-
detail: `\u884C\u7EA7\u5224\u51FA\u79DF\u6237 ${tenant2.length}\uFF08\u8986\u76D6 ${overrides}\uFF09/ \u7CFB\u7EDF ${rows2.length - tenant2.length}\uFF1B\u670D\u52A1\u7AEF\u8BA1\u6570\u671F\u671B\u79DF\u6237 ${expectTenant}\uFF08\u8986\u76D6 ${override}\uFF09/ \u7CFB\u7EDF ${expectSystem}`
|
|
10931
|
+
detail: `\u884C\u7EA7\u5224\u51FA\u79DF\u6237 ${tenant2.length}\uFF08\u8986\u76D6 ${overrides}\uFF09/ \u7CFB\u7EDF ${rows2.length - tenant2.length}\uFF1B\u670D\u52A1\u7AEF\u8BA1\u6570\u671F\u671B\u79DF\u6237 ${expectTenant}\uFF08\u8986\u76D6 ${override}\uFF09/ \u7CFB\u7EDF ${expectSystem}\uFF1B${OLD_CORE_HINT}`
|
|
10932
|
+
};
|
|
10933
|
+
}
|
|
10934
|
+
var newLookupState = () => ({ failed: /* @__PURE__ */ new Map(), noKeys: /* @__PURE__ */ new Set(), emptyKey: /* @__PURE__ */ new Map() });
|
|
10935
|
+
var addTo = (m, k, v) => {
|
|
10936
|
+
if (!m.has(k)) m.set(k, /* @__PURE__ */ new Set());
|
|
10937
|
+
m.get(k).add(v);
|
|
10938
|
+
};
|
|
10939
|
+
var EMBEDDED_REF_ALIASES = {
|
|
10940
|
+
org: "OrgUnit",
|
|
10941
|
+
orgUnit: "OrgUnit",
|
|
10942
|
+
dept: "OrgUnit",
|
|
10943
|
+
department: "OrgUnit",
|
|
10944
|
+
unit: "OrgUnit",
|
|
10945
|
+
emp: "Employee",
|
|
10946
|
+
employee: "Employee",
|
|
10947
|
+
person: "Employee",
|
|
10948
|
+
indicator: "AnalyticsIndicator",
|
|
10949
|
+
scheme: "AnalyticsTargetScheme",
|
|
10950
|
+
targetScheme: "AnalyticsTargetScheme",
|
|
10951
|
+
dashboard: "DashboardDefinition",
|
|
10952
|
+
board: "DashboardDefinition",
|
|
10953
|
+
template: "DashboardTemplate"
|
|
10954
|
+
};
|
|
10955
|
+
var EMBEDDED_REF_PROBE_MODELS = ["OrgUnit", "Employee", "Position"];
|
|
10956
|
+
var PLACEHOLDER_VALUE_RE = /^[A-Za-z0-9._-]+$/;
|
|
10957
|
+
var PLACEHOLDER_FIELD_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
10958
|
+
function placeholderSafeKey(key2) {
|
|
10959
|
+
if (PLACEHOLDER_VALUE_RE.test(key2)) return true;
|
|
10960
|
+
const pairs = key2.split(",");
|
|
10961
|
+
return pairs.length > 1 && pairs.every((p) => {
|
|
10962
|
+
const eq = p.indexOf("=");
|
|
10963
|
+
return eq > 0 && PLACEHOLDER_FIELD_RE.test(p.slice(0, eq)) && PLACEHOLDER_VALUE_RE.test(p.slice(eq + 1));
|
|
10964
|
+
});
|
|
10965
|
+
}
|
|
10966
|
+
function embeddedHintModels(hintKey, pathModel, modelNames) {
|
|
10967
|
+
const out = [];
|
|
10968
|
+
const add = (m) => {
|
|
10969
|
+
if (!m) return;
|
|
10970
|
+
const name = modelNames.has(m) ? m : modelNames.has(`${m}Model`) ? `${m}Model` : void 0;
|
|
10971
|
+
if (name && !out.includes(name)) out.push(name);
|
|
10578
10972
|
};
|
|
10973
|
+
add(pathModel);
|
|
10974
|
+
const base = hintKey ? /^([A-Za-z][A-Za-z0-9]*?)(?:_?[iI]ds?)$/.exec(hintKey)?.[1] : void 0;
|
|
10975
|
+
if (base) {
|
|
10976
|
+
add(EMBEDDED_REF_ALIASES[base]);
|
|
10977
|
+
add(base.charAt(0).toUpperCase() + base.slice(1));
|
|
10978
|
+
}
|
|
10979
|
+
return out;
|
|
10980
|
+
}
|
|
10981
|
+
var NEAR_KEY_RE = /["']?([A-Za-z_][A-Za-z0-9_]*)["']?\s*[:=]\s*(?:\[\s*(?:["'][^"'\]]*["']\s*,\s*)*)?["']?$/;
|
|
10982
|
+
var PATH_MODEL_RE = /\/page\/([A-Z][A-Za-z0-9_]*)\/$/;
|
|
10983
|
+
function embeddedUuids(value, p) {
|
|
10984
|
+
const segs = p.split(/[.[\]~]/).filter(Boolean);
|
|
10985
|
+
const lastKey = segs.pop() ?? p;
|
|
10986
|
+
const ownerKey = /^\d+$/.test(lastKey) ? [...segs].reverse().find((s) => !/^\d+$/.test(s)) ?? lastKey : lastKey;
|
|
10987
|
+
const out = [];
|
|
10988
|
+
for (const m of value.matchAll(UUID_RE)) {
|
|
10989
|
+
const offset = m.index ?? 0;
|
|
10990
|
+
const before = value.slice(Math.max(0, offset - 1e3), offset);
|
|
10991
|
+
out.push({ uuid: m[0], offset, ownerKey, nearKey: NEAR_KEY_RE.exec(before)?.[1] ?? ownerKey, pathModel: PATH_MODEL_RE.exec(before)?.[1] });
|
|
10992
|
+
}
|
|
10993
|
+
return out;
|
|
10994
|
+
}
|
|
10995
|
+
function resolveEmbedded(e, ctx) {
|
|
10996
|
+
const id = e.uuid.toLowerCase();
|
|
10997
|
+
const names = ctx.modelNames ?? new Set(ctx.idKeys.keys());
|
|
10998
|
+
const hinted = embeddedHintModels(e.nearKey, e.pathModel, names).filter((m) => ctx.idKeys.get(m)?.has(id));
|
|
10999
|
+
const holders = hinted.length ? hinted : [...ctx.idKeys].filter(([, map]) => map.has(id)).map(([m]) => m);
|
|
11000
|
+
if (holders.length === 0) {
|
|
11001
|
+
const st = ctx.lookupState;
|
|
11002
|
+
const candidates = [...embeddedHintModels(e.nearKey, e.pathModel, names), ...EMBEDDED_REF_PROBE_MODELS.filter((m) => names.has(m))];
|
|
11003
|
+
const failed2 = candidates.filter((m) => st?.failed.get(m)?.has(id));
|
|
11004
|
+
if (failed2.length) return { reason: "EMBEDDED_LOOKUP_FAILED", target: failed2.join(" | ") };
|
|
11005
|
+
const empty = candidates.filter((m) => st?.emptyKey.get(m)?.has(id));
|
|
11006
|
+
if (empty.length) return { reason: "EMBEDDED_TARGET_KEY_EMPTY", target: empty.join(" | ") };
|
|
11007
|
+
const noKeys = candidates.filter((m) => st?.noKeys.has(m));
|
|
11008
|
+
if (noKeys.length) return { reason: "EMBEDDED_TARGET_NATURAL_KEY_UNKNOWN", target: noKeys.join(" | ") };
|
|
11009
|
+
return { reason: "EMBEDDED_UUID_NOT_FOUND" };
|
|
11010
|
+
}
|
|
11011
|
+
if (holders.length > 1) return { reason: "EMBEDDED_UUID_AMBIGUOUS", target: holders.join(" | ") };
|
|
11012
|
+
const targetModel = holders[0];
|
|
11013
|
+
const key2 = ctx.idKeys.get(targetModel).get(id);
|
|
11014
|
+
const placeholder2 = `\${ref:${targetModel}:${key2}}`;
|
|
11015
|
+
if (new RegExp(UUID_RE.source, "i").test(key2)) return { reason: "EMBEDDED_KEY_HAS_UUID", target: placeholder2 };
|
|
11016
|
+
if (!placeholderSafeKey(key2)) return { reason: "EMBEDDED_KEY_NOT_PLACEHOLDER_SAFE", target: placeholder2 };
|
|
11017
|
+
const blocked = ctx.packageGuard?.(targetModel, id);
|
|
11018
|
+
if (blocked) return { reason: blocked, target: placeholder2 };
|
|
11019
|
+
return { targetModel, placeholder: placeholder2 };
|
|
10579
11020
|
}
|
|
10580
11021
|
function refTargetOf(object3) {
|
|
10581
11022
|
return object3.startsWith("CO_") ? { placeholderModel: "CodeItemData", lookupModel: "CodeItemData" } : { placeholderModel: object3, lookupModel: object3 };
|
|
@@ -10598,6 +11039,7 @@ function rewriteRow(row, rowKey, ctx) {
|
|
|
10598
11039
|
const item = {};
|
|
10599
11040
|
const unresolved = [];
|
|
10600
11041
|
const envLocal = [];
|
|
11042
|
+
const rewrites = [];
|
|
10601
11043
|
const selfKeys = ctx.idKeys.get(ctx.model);
|
|
10602
11044
|
for (const f of ctx.fields) {
|
|
10603
11045
|
if (!exportableField(f) || !(f.key in row)) continue;
|
|
@@ -10632,35 +11074,69 @@ function rewriteRow(row, rowKey, ctx) {
|
|
|
10632
11074
|
item[f.key] = Array.isArray(value) ? value.map((v, i) => mapOne(v, `${f.key}[${i}]`)) : mapOne(value, f.key);
|
|
10633
11075
|
continue;
|
|
10634
11076
|
}
|
|
10635
|
-
item[f.key] = scanEmbedded(value, f.key, rowKey, ctx, unresolved, envLocal);
|
|
11077
|
+
item[f.key] = scanEmbedded(value, f.key, rowKey, ctx, { unresolved, envLocal, rewrites });
|
|
10636
11078
|
}
|
|
10637
|
-
return { item, unresolved, envLocal };
|
|
11079
|
+
return { item, unresolved, envLocal, rewrites };
|
|
10638
11080
|
}
|
|
10639
|
-
function scanEmbedded(value, p, rowKey, ctx,
|
|
11081
|
+
function scanEmbedded(value, p, rowKey, ctx, sink) {
|
|
10640
11082
|
if (typeof value === "string") {
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
11083
|
+
const found2 = embeddedUuids(value, p);
|
|
11084
|
+
if (!found2.length) return value;
|
|
11085
|
+
let out = "";
|
|
11086
|
+
let at = 0;
|
|
11087
|
+
for (const e of found2) {
|
|
11088
|
+
out += value.slice(at, e.offset);
|
|
11089
|
+
at = e.offset + e.uuid.length;
|
|
11090
|
+
const fieldPath = e.nearKey !== e.ownerKey ? `${p}~${e.nearKey}` : p;
|
|
11091
|
+
const byId = ctx.envLocalIds.get(e.uuid.toLowerCase());
|
|
11092
|
+
if (byId || ENV_LOCAL_KEY_RE.test(e.nearKey)) {
|
|
11093
|
+
const targetModel = byId ?? `UNKNOWN_ENV_LOCAL(by key ${e.nearKey})`;
|
|
11094
|
+
sink.envLocal.push({ model: ctx.model, rowKey, fieldPath, targetModel, note: "\u76EE\u6807\u73AF\u5883\u88C5\u5305\u540E\u9700\u91CD\u65B0\u7ED1\u5B9A" });
|
|
11095
|
+
out += envLocalMarker(byId ?? "UNKNOWN");
|
|
11096
|
+
continue;
|
|
11097
|
+
}
|
|
11098
|
+
const r = resolveEmbedded(e, ctx);
|
|
11099
|
+
if ("placeholder" in r) {
|
|
11100
|
+
sink.rewrites.push({ model: ctx.model, rowKey, fieldPath, uuidPrefix: e.uuid.slice(0, 8), targetModel: r.targetModel, placeholder: r.placeholder });
|
|
11101
|
+
out += r.placeholder;
|
|
11102
|
+
} else {
|
|
11103
|
+
sink.unresolved.push({ model: ctx.model, rowKey, fieldPath, value: e.uuid, reason: r.reason, ...r.target ? { target: r.target } : {} });
|
|
11104
|
+
out += e.uuid;
|
|
11105
|
+
}
|
|
11106
|
+
}
|
|
11107
|
+
return out + value.slice(at);
|
|
10655
11108
|
}
|
|
10656
|
-
if (Array.isArray(value)) return value.map((v, i) => scanEmbedded(v, `${p}[${i}]`, rowKey, ctx,
|
|
11109
|
+
if (Array.isArray(value)) return value.map((v, i) => scanEmbedded(v, `${p}[${i}]`, rowKey, ctx, sink));
|
|
10657
11110
|
if (value && typeof value === "object") {
|
|
10658
11111
|
const out = {};
|
|
10659
|
-
for (const [k, v] of Object.entries(value)) out[k] = scanEmbedded(v, `${p}.${k}`, rowKey, ctx,
|
|
11112
|
+
for (const [k, v] of Object.entries(value)) out[k] = scanEmbedded(v, `${p}.${k}`, rowKey, ctx, sink);
|
|
10660
11113
|
return out;
|
|
10661
11114
|
}
|
|
10662
11115
|
return value;
|
|
10663
11116
|
}
|
|
11117
|
+
function collectEmbeddedLookups(rows2, fields, ctx, into) {
|
|
11118
|
+
const names = ctx.modelNames ?? new Set(ctx.idKeys.keys());
|
|
11119
|
+
const known = (id) => ctx.envLocalIds.has(id) || [...ctx.idKeys.values()].some((m) => m.has(id));
|
|
11120
|
+
const want = (model, id) => {
|
|
11121
|
+
if (!into.has(model)) into.set(model, /* @__PURE__ */ new Set());
|
|
11122
|
+
into.get(model).add(id);
|
|
11123
|
+
};
|
|
11124
|
+
const walk = (v, p) => {
|
|
11125
|
+
if (typeof v === "string") {
|
|
11126
|
+
for (const e of embeddedUuids(v, p)) {
|
|
11127
|
+
const id = e.uuid.toLowerCase();
|
|
11128
|
+
if (known(id) || ENV_LOCAL_KEY_RE.test(e.nearKey)) continue;
|
|
11129
|
+
for (const m of embeddedHintModels(e.nearKey, e.pathModel, names)) want(m, id);
|
|
11130
|
+
for (const m of EMBEDDED_REF_PROBE_MODELS) if (names.has(m)) want(m, id);
|
|
11131
|
+
}
|
|
11132
|
+
} else if (Array.isArray(v)) v.forEach((x, i) => walk(x, `${p}[${i}]`));
|
|
11133
|
+
else if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk(x, `${p}.${k}`);
|
|
11134
|
+
};
|
|
11135
|
+
for (const f of fields) {
|
|
11136
|
+
if (!exportableField(f) || f.object || f.type === "uuid") continue;
|
|
11137
|
+
for (const r of rows2) if (f.key in r) walk(r[f.key], f.key);
|
|
11138
|
+
}
|
|
11139
|
+
}
|
|
10664
11140
|
function scanExtensionUuids(file, text2) {
|
|
10665
11141
|
const out = [];
|
|
10666
11142
|
text2.split("\n").forEach((line, i) => {
|
|
@@ -10704,6 +11180,13 @@ function collectIndicatorRefs(value, out) {
|
|
|
10704
11180
|
return out;
|
|
10705
11181
|
}
|
|
10706
11182
|
var UUID_NEXT_STEP = "\u6E90\u73AF\u5883\u6539\u6210\u6309\u7F16\u7801\u5F15\u7528\uFF08${Model:key}\uFF09\uFF0C\u91CD\u65B0\u5BFC\u51FA";
|
|
11183
|
+
function uuidNextStep(reason) {
|
|
11184
|
+
if (reason === "EMBEDDED_LOOKUP_FAILED") return "\u53CD\u67E5\u6CA1\u67E5\u6210\uFF08\u62A5\u9519\u89C1 degradedReasons \u7684 REFERENCE_LOOKUP_FAILED\uFF09\uFF1A\u6062\u590D\u540E\u91CD\u65B0\u5BFC\u51FA\uFF1B\u4ECD\u6539\u5199\u4E0D\u4E86\u518D\u6309 reason \u5904\u7406";
|
|
11185
|
+
if (reason === "EMBEDDED_UUID_NOT_FOUND") return "\u6E90\u73AF\u5883\u91CC\u67E5\u4E0D\u5230\u8FD9\u884C\uFF1A\u662F\u5F15\u7528\u7684\u8BDD\u6E90\u73AF\u5883\u5DF2\u7ECF\u6307\u7A7A\uFF0C\u6539\u6210\u6309\u7F16\u7801\u5F15\u7528\u6216\u5220\u6389\uFF1B\u4E0D\u6307\u5411\u6570\u636E\u7684\u6807\u8BC6\uFF08\u5982 templateOrigin.creationRequestId\uFF09\u53EF\u5FFD\u7565";
|
|
11186
|
+
if (/^EMBEDDED_REF_/.test(reason)) return "\u5305\u5185\u4F9D\u8D56\u4E0D\u80FD\u5199\u6210\u7F16\u7801\u5F15\u7528\uFF08\u540C\u7C7B\u914D\u7F6E\u4E92\u6307 / \u672C\u5305\u540E\u88C5\u6216\u6CA1\u5BFC\u51FA\u7684\u884C\uFF0C\u88C5\u5305\u6309\u987A\u5E8F\u89E3\u6790\u4E0D\u5230\uFF09\uFF1A\u6E90\u73AF\u5883\u6539\u6210\u8FD0\u884C\u65F6\u6309\u7F16\u7801\u53D6\u6570\uFF0C\u4E0D\u8981\u624B\u5199 ${ref:} \u5360\u4F4D\u7B26\uFF1B\u6216\u88C5\u5305\u540E\u5728\u76EE\u6807\u73AF\u5883\u91CD\u65B0\u6307\u5411";
|
|
11187
|
+
if (reason === "EMBEDDED_KEY_HAS_UUID") return "\u76EE\u6807\u884C\u7684\u81EA\u7136\u952E\u672C\u8EAB\u7531\u5185\u90E8 ID \u7EC4\u6210\uFF0C\u8DE8\u73AF\u5883\u5BF9\u4E0D\u4E0A\uFF1A\u6E90\u73AF\u5883\u6539\u6210\u5F15\u7528\u5B83\u7684\u4E0A\u7EA7\u914D\u7F6E\uFF08\u6309\u7F16\u7801\uFF09\uFF0C\u6216\u88C5\u5305\u540E\u5728\u76EE\u6807\u73AF\u5883\u91CD\u65B0\u6307\u5411";
|
|
11188
|
+
return UUID_NEXT_STEP;
|
|
11189
|
+
}
|
|
10707
11190
|
var HARDCODED_UUID_IN_CODE = "HARDCODED_UUID_IN_CODE";
|
|
10708
11191
|
var OPAQUE_FIELD_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
10709
11192
|
var REF_LIKE_FIELD_RE = /(?:_id|Id)$/;
|
|
@@ -10773,6 +11256,10 @@ async function runExportConfig(api2, opts) {
|
|
|
10773
11256
|
lanes.skipped.push({ model, reason: "PRESET_SPLIT_UNVERIFIABLE", detail: split2.detail });
|
|
10774
11257
|
} else if (split2.classification === "CREATE_BY_HEURISTIC_UNVERIFIED") {
|
|
10775
11258
|
degraded.push(`PRESET_SPLIT_UNVERIFIED: ${model}`);
|
|
11259
|
+
} else if (split2.classification === "SERVER_IDS_UNRECONCILED") {
|
|
11260
|
+
degraded.push(`PRESET_SPLIT_UNRECONCILED: ${model}`);
|
|
11261
|
+
} else if (split2.classification === "CREATE_BY_VERIFIED_BY_COUNTS") {
|
|
11262
|
+
degraded.push(`PRESET_SPLIT_HEURISTIC: ${model}`);
|
|
10776
11263
|
}
|
|
10777
11264
|
if (split2.systemRows > 0 && split2.tenantRows.length === 0 && split2.classification !== "COUNTS_MISMATCH") {
|
|
10778
11265
|
lanes.skipped.push({ model, reason: "PRESET_ROWS_ONLY", detail: `${split2.systemRows} \u884C\u5168\u662F\u7CFB\u7EDF\u9884\u7F6E` });
|
|
@@ -10809,35 +11296,67 @@ async function runExportConfig(api2, opts) {
|
|
|
10809
11296
|
}
|
|
10810
11297
|
}
|
|
10811
11298
|
}
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
const
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
11299
|
+
const lookupState = newLookupState();
|
|
11300
|
+
const lookupIds = async (wantedIds) => {
|
|
11301
|
+
for (const [target, ids] of wantedIds) {
|
|
11302
|
+
const tmeta = metas.get(target) ?? await api2.meta(target).catch(() => void 0);
|
|
11303
|
+
const keys = naturalKeysOf(target, tmeta);
|
|
11304
|
+
if (!keys) {
|
|
11305
|
+
lookupState.noKeys.add(target);
|
|
11306
|
+
continue;
|
|
11307
|
+
}
|
|
11308
|
+
const map = idKeys.get(target) ?? /* @__PURE__ */ new Map();
|
|
11309
|
+
const list2 = [...ids].filter((id) => !map.has(id.toLowerCase()));
|
|
11310
|
+
for (let i = 0; i < list2.length; i += 200) {
|
|
11311
|
+
const batch = list2.slice(i, i + 200);
|
|
11312
|
+
try {
|
|
11313
|
+
const fields = target === ROOT_MODEL ? ["id", "parentId", ...keys.keys] : ["id", ...keys.keys];
|
|
11314
|
+
const rows2 = await api2.listAll(target, { fields, filter: { field: "id", op: "in", value: batch }, pageSize: 500 });
|
|
11315
|
+
const asked = new Set(batch.map((x) => x.toLowerCase()));
|
|
11316
|
+
for (const r of rows2) {
|
|
11317
|
+
const k = rootAwareKey(target, keys.keys, r);
|
|
11318
|
+
if (typeof r.id !== "string" || !asked.has(r.id.toLowerCase())) continue;
|
|
11319
|
+
if (k) map.set(r.id.toLowerCase(), k);
|
|
11320
|
+
else addTo(lookupState.emptyKey, target, r.id.toLowerCase());
|
|
11321
|
+
}
|
|
11322
|
+
} catch (e) {
|
|
11323
|
+
for (const id of batch) addTo(lookupState.failed, target, id.toLowerCase());
|
|
11324
|
+
degraded.push(`REFERENCE_LOOKUP_FAILED: ${target}: ${describeError(e)}`);
|
|
10825
11325
|
}
|
|
10826
|
-
} catch (e) {
|
|
10827
|
-
degraded.push(`REFERENCE_LOOKUP_FAILED: ${target}: ${describeError(e)}`);
|
|
10828
11326
|
}
|
|
11327
|
+
idKeys.set(target, map);
|
|
10829
11328
|
}
|
|
10830
|
-
|
|
11329
|
+
};
|
|
11330
|
+
await lookupIds(wanted);
|
|
11331
|
+
const modelNames = new Set(metas.keys());
|
|
11332
|
+
const embeddedWanted = /* @__PURE__ */ new Map();
|
|
11333
|
+
for (const l of loaded) {
|
|
11334
|
+
collectEmbeddedLookups(l.split.tenantRows, l.meta.fields ?? [], { model: l.model, fields: l.meta.fields ?? [], idKeys, envLocalModels: envLocalSet, envLocalIds, modelNames, lookupState }, embeddedWanted);
|
|
10831
11335
|
}
|
|
11336
|
+
await lookupIds(embeddedWanted);
|
|
10832
11337
|
const unresolved = [];
|
|
10833
11338
|
const uuidFindings = [];
|
|
11339
|
+
const uuidRewrites = [];
|
|
10834
11340
|
const opaque = /* @__PURE__ */ new Set();
|
|
10835
11341
|
const envLocalRefs = [];
|
|
10836
11342
|
const manifestModels = [];
|
|
10837
|
-
|
|
11343
|
+
const installIndex = new Map(loaded.map((l, i) => [l.model, i]));
|
|
11344
|
+
const packageRowIds = new Map(loaded.map((l) => [l.model, new Set(l.split.tenantRows.map((r) => String(r.id).toLowerCase()))]));
|
|
11345
|
+
const droppedRowIds = /* @__PURE__ */ new Map();
|
|
11346
|
+
const notExported = new Set(lanes.configModels.filter((m) => !installIndex.has(m) || loaded.find((l) => l.model === m)?.split.classification === "COUNTS_MISMATCH"));
|
|
11347
|
+
for (const [ci, l] of loaded.entries()) {
|
|
10838
11348
|
const entry = entries.find((e) => e.model === l.model);
|
|
10839
11349
|
if (l.split.tenantRows.length === 0 || !l.keys) continue;
|
|
10840
|
-
const
|
|
11350
|
+
const packageGuard = (target, id) => {
|
|
11351
|
+
if (target === l.model) return "EMBEDDED_REF_SAME_MODEL";
|
|
11352
|
+
if (notExported.has(target)) return "EMBEDDED_REF_TARGET_NOT_EXPORTED";
|
|
11353
|
+
const ti = installIndex.get(target);
|
|
11354
|
+
if (ti === void 0 || !packageRowIds.get(target)?.has(id)) return void 0;
|
|
11355
|
+
if (ti > ci) return "EMBEDDED_REF_INSTALLED_LATER";
|
|
11356
|
+
if (droppedRowIds.get(target)?.has(id)) return "EMBEDDED_REF_TARGET_DROPPED";
|
|
11357
|
+
return void 0;
|
|
11358
|
+
};
|
|
11359
|
+
const ctx = { model: l.model, fields: l.meta.fields ?? [], idKeys, envLocalModels: envLocalSet, envLocalIds, modelNames, packageGuard, lookupState };
|
|
10841
11360
|
const keys = l.keys.keys;
|
|
10842
11361
|
const rewrite = (rows2) => {
|
|
10843
11362
|
const ordered = l.meta.fields?.some((f) => f.key === "parentId") ? parentFirst(rows2) : rows2;
|
|
@@ -10850,11 +11369,25 @@ async function runExportConfig(api2, opts) {
|
|
|
10850
11369
|
});
|
|
10851
11370
|
for (const u of res.unresolved) {
|
|
10852
11371
|
const field = topLevelField(u.fieldPath);
|
|
10853
|
-
uuidFindings.push({
|
|
11372
|
+
uuidFindings.push({
|
|
11373
|
+
model: l.model,
|
|
11374
|
+
rowKey,
|
|
11375
|
+
field,
|
|
11376
|
+
fieldPath: u.fieldPath,
|
|
11377
|
+
uuidPrefix: u.value.slice(0, 8),
|
|
11378
|
+
action: drop ? "ROW_DROPPED" : "OPAQUE_DECLARED",
|
|
11379
|
+
reason: u.reason,
|
|
11380
|
+
...u.target ? { target: u.target } : {},
|
|
11381
|
+
nextStep: uuidNextStep(u.reason)
|
|
11382
|
+
});
|
|
10854
11383
|
if (!drop) opaque.add(`${l.model}.${field}`);
|
|
10855
11384
|
}
|
|
10856
|
-
if (drop)
|
|
11385
|
+
if (drop) {
|
|
11386
|
+
addTo(droppedRowIds, l.model, String(r.id).toLowerCase());
|
|
11387
|
+
return [];
|
|
11388
|
+
}
|
|
10857
11389
|
envLocalRefs.push(...res.envLocal);
|
|
11390
|
+
uuidRewrites.push(...res.rewrites);
|
|
10858
11391
|
return [res.item];
|
|
10859
11392
|
});
|
|
10860
11393
|
};
|
|
@@ -11011,7 +11544,7 @@ async function runExportConfig(api2, opts) {
|
|
|
11011
11544
|
const opaqueN = uuidFindings.filter((u) => u.action === "OPAQUE_DECLARED").length;
|
|
11012
11545
|
const droppedRowsN = new Set(uuidFindings.filter((u) => u.action === "ROW_DROPPED").map((u) => `${u.model}|${u.rowKey}`)).size;
|
|
11013
11546
|
if (uuidFindings.length || extensionRedactions.length || droppedGroups.size) {
|
|
11014
|
-
degraded.push(`SOURCE_UUID_HANDLED: \u6570\u636E\u884C\u88F8 UUID ${uuidFindings.length} \u5904\uFF08\u58F0\u660E opaque ${opaqueN} \u5904 / \u5220\u884C ${droppedRowsN} \u884C\uFF09\uFF0C\u6269\u5C55\u63CF\u8FF0\u6587\u672C\u66FF\u6362 ${redactedUuidN} \u5904\uFF0C\u5254\u9664\u5B57\u6BB5\u5951\u7EA6\u5916\u7684\u952E ${unknownKeyN} \u5904\uFF0C\u4EE3\u7801\u8D44\u4EA7\u4E0D\u5BFC\u51FA ${droppedGroups.size} \u4E2A\uFF08\u5220\u5F15\u7528\u52A8\u4F5C ${removedRefs.length} \u4E2A\uFF09\uFF1B\u5305\u7167\u5E38\u4EA7\u51FA\uFF0C\u89C1 uuidFindings / extensionRedactions / skipped`);
|
|
11547
|
+
degraded.push(`SOURCE_UUID_HANDLED: \u6570\u636E\u884C\u6539\u5199\u4E0D\u4E86\u7684\u88F8 UUID ${uuidFindings.length} \u5904\uFF08\u58F0\u660E opaque ${opaqueN} \u5904 / \u5220\u884C ${droppedRowsN} \u884C\uFF1B\u53E6\u6709 ${uuidRewrites.length} \u5904\u5DF2\u6539\u4E3A\u6309\u7F16\u7801\u5F15\u7528\uFF0C\u89C1 uuidRewrites\uFF09\uFF0C\u6269\u5C55\u63CF\u8FF0\u6587\u672C\u66FF\u6362 ${redactedUuidN} \u5904\uFF0C\u5254\u9664\u5B57\u6BB5\u5951\u7EA6\u5916\u7684\u952E ${unknownKeyN} \u5904\uFF0C\u4EE3\u7801\u8D44\u4EA7\u4E0D\u5BFC\u51FA ${droppedGroups.size} \u4E2A\uFF08\u5220\u5F15\u7528\u52A8\u4F5C ${removedRefs.length} \u4E2A\uFF09\uFF1B\u5305\u7167\u5E38\u4EA7\u51FA\uFF0C\u89C1 uuidFindings / extensionRedactions / skipped`);
|
|
11015
11548
|
}
|
|
11016
11549
|
if (dangling.length) degraded.push(`DANGLING_REFERENCES: ${dangling.length} \u5904\u4ECD\u5F15\u7528\u5DF2\u5254\u9664\u7684\u4EE3\u7801\u8D44\u4EA7\uFF0C\u89C1 removedReferences.dangling`);
|
|
11017
11550
|
if (unresolved.length) degraded.push(`UNRESOLVED_REFERENCES: ${unresolved.length} \u5904\u5F15\u7528/UUID \u65E0\u6CD5\u6539\u5199\u4E3A\u81EA\u7136\u952E\uFF0C\u539F\u503C\u4FDD\u7559\uFF08pack \u4F1A\u62D2\uFF09\uFF0C\u89C1 unresolvedReferences`);
|
|
@@ -11057,6 +11590,7 @@ async function runExportConfig(api2, opts) {
|
|
|
11057
11590
|
models: entries,
|
|
11058
11591
|
extensions: { files: extFiles.length, strippedDefinitionIds, nonActive, failed: extFailed },
|
|
11059
11592
|
uuidFindings,
|
|
11593
|
+
uuidRewrites,
|
|
11060
11594
|
opaqueUuidFields: [...opaque].sort(),
|
|
11061
11595
|
extensionRedactions,
|
|
11062
11596
|
removedReferences: { removed: removedRefs, dangling },
|
|
@@ -11122,7 +11656,7 @@ async function envExportConfigCommand(args) {
|
|
|
11122
11656
|
throw new CliError23({ code: CliErrorCode23.INVALID_ARGUMENT, message: `\u8F93\u51FA\u76EE\u5F55\u975E\u7A7A\uFF1A${outDir}`, context: { nextStep: "\u6362\u4E00\u4E2A\u7A7A\u76EE\u5F55\uFF0C\u6216\u52A0 --force \u8986\u76D6\uFF08\u4F1A\u5148\u6E05\u7A7A data/ \u4E0E extensions/\uFF09" } });
|
|
11123
11657
|
}
|
|
11124
11658
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
11125
|
-
const client4 =
|
|
11659
|
+
const client4 = HcmClient23.fromAuthContext(ctx);
|
|
11126
11660
|
const result = await runExportConfig(createLaneApi(client4.raw()), {
|
|
11127
11661
|
endpoint: ctx.endpoint,
|
|
11128
11662
|
tenantId: ctx.tenantId,
|
|
@@ -11151,6 +11685,7 @@ async function envExportConfigCommand(args) {
|
|
|
11151
11685
|
strippedDefinitionIds: r.extensions.strippedDefinitionIds,
|
|
11152
11686
|
unresolvedReferences: r.unresolvedReferences.length,
|
|
11153
11687
|
envLocalReferences: r.envLocalReferences.length,
|
|
11688
|
+
uuidRewrites: r.uuidRewrites.length,
|
|
11154
11689
|
uuidFindings: r.uuidFindings.length,
|
|
11155
11690
|
opaqueUuidFields: r.opaqueUuidFields,
|
|
11156
11691
|
extensionRedactions: r.extensionRedactions.length,
|
|
@@ -11169,7 +11704,7 @@ async function envExportConfigCommand(args) {
|
|
|
11169
11704
|
process.stderr.write(renderNextSteps(outDir, r));
|
|
11170
11705
|
process.exitCode = r.status === "DEGRADED" ? 3 : 0;
|
|
11171
11706
|
} catch (e) {
|
|
11172
|
-
if (e?.isAxiosError) exitWithError(
|
|
11707
|
+
if (e?.isAxiosError) exitWithError(fromAxiosError23(e, args.env));
|
|
11173
11708
|
exitWithError(e);
|
|
11174
11709
|
}
|
|
11175
11710
|
}
|
|
@@ -11180,7 +11715,7 @@ function renderPreconditions(r) {
|
|
|
11180
11715
|
lines.push(`\u5305\u8EAB\u4EFD\uFF1A${p.name}\uFF08${p.source === "INHERITED_FROM_INSTALLED_PACKAGE" ? `\u6CBF\u7528\u6E90\u73AF\u5883\u5DF2\u88C5\u5305\uFF0C\u6E90\u73AF\u5883\u7248\u672C ${p.inheritedFromVersion ?? "?"}\uFF1B\u88C5\u5230\u88C5\u8FC7\u5B83\u7684\u73AF\u5883\u5373\u5347\u7EA7` : p.source === "FLAG" ? "--package-name \u6307\u5B9A" : `${p.detail ?? "\u672A\u67E5\u5230\u6301\u6709\u6269\u5C55\u6587\u4EF6\u7684\u5DF2\u88C5\u5305"}\uFF0C\u6309\u79DF\u6237\u8D77\u540D\uFF1B\u76EE\u6807\u73AF\u5883\u82E5\u5DF2\u88C5\u8FC7\u522B\u7684\u5305\u540D\uFF0C\u88C5\u5305\u4F1A\u62A5 PACKAGE_EXTENSION_PATH_OWNED_BY_OTHER_PACKAGE\uFF0C\u5C4A\u65F6\u7528 --package-name \u6539\u6210\u90A3\u4E2A\u5305\u540D\u91CD\u5BFC`}\uFF09`);
|
|
11181
11716
|
}
|
|
11182
11717
|
lines.push("\u524D\u63D0\u65AD\u8A00\uFF08\u6E90\u7AEF\uFF09\uFF1A", ` CONFIG \u6A21\u578B\u79DF\u6237\u81EA\u6709\u884C\u6570\uFF08laneSource=${r.laneSource}\uFF09\uFF1A`);
|
|
11183
|
-
for (const m of r.models) lines.push(` ${m.model.padEnd(24)} ${m.tenantOriginal + m.tenantOverride}\uFF08\u539F\u521B ${m.tenantOriginal} / \u8986\u76D6 ${m.tenantOverride}\uFF1B\u7CFB\u7EDF\u9884\u7F6E\u8DF3\u8FC7 ${m.systemRowsSkipped}\uFF1B${m.presetClassification}\uFF09${m.overrideFile ? `\uFF1B\u8986\u76D6\u884C ${m.exportedOverrideRows} \u6761\u5BFC\u51FA\u5230 ${m.overrideFile}\uFF08update_existing: true\uFF09` : ""}`);
|
|
11718
|
+
for (const m of r.models) lines.push(` ${m.model.padEnd(24)} ${m.tenantOriginal + m.tenantOverride}\uFF08\u539F\u521B ${m.tenantOriginal} / \u8986\u76D6 ${m.tenantOverride}\uFF1B\u7CFB\u7EDF\u9884\u7F6E\u8DF3\u8FC7 ${m.systemRowsSkipped}\uFF1B${m.presetClassification}\uFF09${m.detail && m.presetClassification !== "COUNTS_MISMATCH" ? `\uFF1B${m.detail}` : ""}${m.overrideFile ? `\uFF1B\u8986\u76D6\u884C ${m.exportedOverrideRows} \u6761\u5BFC\u51FA\u5230 ${m.overrideFile}\uFF08update_existing: true\uFF09` : ""}`);
|
|
11184
11719
|
lines.push(` \u5408\u8BA1 ${r.preconditions.configTenantRowsTotal}${r.preconditions.configTenantRowsTotal > 0 ? "" : " \u26A0\uFE0F \u4E3A 0\uFF1A\u5BFC\u51FA\u662F\u7A7A\u96C6\u5408\uFF0CE1 \u5224\u636E\u65E0\u6548"}`);
|
|
11185
11720
|
lines.push(" ENV_LOCAL \u6A21\u578B\u884C\u6570\uFF08\u8BC1\u660E\u300CENV_LOCAL \u96F6\u5BFC\u51FA\u300D\u4E0D\u662F\u7A7A\u96C6\u5408\u901A\u8FC7\uFF09\uFF1A");
|
|
11186
11721
|
for (const [m, n2] of Object.entries(r.preconditions.envLocalRows)) {
|
|
@@ -11202,6 +11737,13 @@ function renderNextSteps(outDir, r) {
|
|
|
11202
11737
|
const lines = ["\u4E0B\u4E00\u6B65\uFF1A", ` 1. hcm package pack ${outDir} -o ${artifact}`, ` 2. hcm package install ${artifact} --env <\u76EE\u6807\u73AF\u5883>`];
|
|
11203
11738
|
if (r.unresolvedReferences.length) lines.push(` \u26A0\uFE0F ${r.unresolvedReferences.length} \u5904\u5F15\u7528\u672A\u6539\u5199\uFF08unresolvedReferences\uFF09\uFF0Cpack \u4F1A\u62A5 UUID \u8FDD\u89C4\uFF0C\u5148\u6309\u62A5\u544A\u9010\u6761\u5904\u7406`);
|
|
11204
11739
|
if (r.missingIndicatorRefs.length) lines.push(` \u26A0\uFE0F ${new Set(r.missingIndicatorRefs.map((m) => m.board)).size} \u4E2A\u770B\u677F\u5F15\u7528\u4E86\u5305\u91CC\u6CA1\u6709\u7684\u6307\u6807\uFF08missingIndicatorRefs\uFF09\uFF0C\u88C5\u5B8C\u8FD9\u4E9B\u5757\u4F1A\u62A5\u9519\uFF1B\u6E90\u73AF\u5883\u8865\u4E0A\u6307\u6807\u6216\u6539\u770B\u677F\u540E\u91CD\u5BFC`);
|
|
11740
|
+
if (r.uuidRewrites.length) {
|
|
11741
|
+
const byModel = /* @__PURE__ */ new Map();
|
|
11742
|
+
for (const w of r.uuidRewrites) byModel.set(w.targetModel, (byModel.get(w.targetModel) ?? 0) + 1);
|
|
11743
|
+
lines.push(` ${r.uuidRewrites.length} \u5904\u914D\u7F6E\u91CC\u5199\u6B7B\u7684\u5185\u90E8 ID \u5DF2\u6539\u6210\u6309\u7F16\u7801\u5F15\u7528\uFF08uuidRewrites\uFF1A${[...byModel].map(([m, n2]) => `${m} ${n2}`).join("\u3001")}\uFF09\uFF1B\u76EE\u6807\u73AF\u5883\u987B\u6709\u540C\u7F16\u7801\u7684\u884C\uFF0C\u7F3A\u4E86\u88C5\u5305\u62A5 DATA_PACKAGE_REF_UNRESOLVED`);
|
|
11744
|
+
}
|
|
11745
|
+
const opaqueLeft = r.uuidFindings.filter((u) => u.action === "OPAQUE_DECLARED");
|
|
11746
|
+
if (opaqueLeft.length) lines.push(` \u26A0\uFE0F ${opaqueLeft.length} \u5904\u5185\u90E8 ID \u6539\u5199\u4E0D\u4E86\u3001\u539F\u6837\u88C5\u5165\uFF08uuidFindings\uFF0Creason \u8BF4\u660E\u539F\u56E0\uFF09\uFF1B\u662F\u5F15\u7528\u7684\u8BDD\u76EE\u6807\u73AF\u5883\u90A3\u4E00\u5757\u4F1A\u7A7A\uFF0C\u56DE\u6E90\u73AF\u5883\u6539\u6210\u6309\u7F16\u7801\u5F15\u7528\u540E\u91CD\u5BFC`);
|
|
11205
11747
|
if (r.envLocalReferences.length) lines.push(` \u88C5\u5305\u540E\u5728\u76EE\u6807\u73AF\u5883\u91CD\u65B0\u7ED1\u5B9A ${r.envLocalReferences.length} \u5904 ENV_LOCAL \u5F15\u7528\uFF08envLocalReferences\uFF09`);
|
|
11206
11748
|
if (r.columnSlots.fields.length && r.columnSlots.mode === "keep") lines.push(` \u76EE\u6807\u73AF\u5883\u987B\u5DF2\u5EFA\u597D ${r.columnSlots.fields.length} \u4E2A\u5217\u69FD\uFF08\u89C1\u4E0A\u65B9\u6E05\u5355\uFF09\uFF0C\u5426\u5219\u88C5\u5305\u5931\u8D25`);
|
|
11207
11749
|
return lines.join("\n") + "\n";
|
|
@@ -11213,7 +11755,7 @@ init_auth_guard();
|
|
|
11213
11755
|
import { promises as fs8 } from "fs";
|
|
11214
11756
|
import * as path8 from "path";
|
|
11215
11757
|
import yaml2 from "js-yaml";
|
|
11216
|
-
import { HcmClient as
|
|
11758
|
+
import { HcmClient as HcmClient24, fromAxiosError as fromAxiosError24, CliError as CliError24, CliErrorCode as CliErrorCode24 } from "@hcmai/sdk";
|
|
11217
11759
|
var FINGERPRINT_MODELS = ["Employee", "OrgUnit", "Position", "Assignment"];
|
|
11218
11760
|
var RED_LINE_FIELD_RE = /^(name|shortName|code|fullName|realName|userName|username|idNumber|idNo|certNo|archiveNumber)$|(name|idnumber|idcard|phone|mobile|tel|email|address|contact|remark|description|comment|memo|note|reason|text)$|(creator|updator|updater|operator|modifier|handler|approver|reviewer|auditor)(id|code|no)?$/i;
|
|
11219
11761
|
var OTHER_BUCKET = "_other";
|
|
@@ -11875,7 +12417,7 @@ async function envFingerprintCommand(args) {
|
|
|
11875
12417
|
});
|
|
11876
12418
|
}
|
|
11877
12419
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
11878
|
-
const api2 = createLaneApi(
|
|
12420
|
+
const api2 = createLaneApi(HcmClient24.fromAuthContext(ctx).raw());
|
|
11879
12421
|
const fieldMetas = /* @__PURE__ */ new Map();
|
|
11880
12422
|
const fp = await collectFingerprint(api2, { tenantId: ctx.tenantId, minBucket, fieldMetas, log: (l) => process.stderr.write(`${l}
|
|
11881
12423
|
`) });
|
|
@@ -11928,12 +12470,13 @@ async function envFingerprintCommand(args) {
|
|
|
11928
12470
|
`);
|
|
11929
12471
|
process.exitCode = exit;
|
|
11930
12472
|
} catch (e) {
|
|
11931
|
-
if (e?.isAxiosError) exitWithError(
|
|
12473
|
+
if (e?.isAxiosError) exitWithError(fromAxiosError24(e, args.env));
|
|
11932
12474
|
exitWithError(e);
|
|
11933
12475
|
}
|
|
11934
12476
|
}
|
|
11935
12477
|
|
|
11936
12478
|
// src/commands/skills.ts
|
|
12479
|
+
init_auth_guard();
|
|
11937
12480
|
init_exit();
|
|
11938
12481
|
import { promises as fsp4 } from "fs";
|
|
11939
12482
|
import os3 from "os";
|
|
@@ -11942,6 +12485,7 @@ import { createHash as createHash4 } from "crypto";
|
|
|
11942
12485
|
import axios4 from "axios";
|
|
11943
12486
|
import {
|
|
11944
12487
|
createHttpClient as createHttpClient2,
|
|
12488
|
+
TokenStore as TokenStore4,
|
|
11945
12489
|
fetchSkillCatalog,
|
|
11946
12490
|
fetchSkillMarkdown,
|
|
11947
12491
|
fetchSkillReference,
|
|
@@ -11956,7 +12500,7 @@ import {
|
|
|
11956
12500
|
matchSkills,
|
|
11957
12501
|
filterByStage,
|
|
11958
12502
|
formatObject as formatObject21,
|
|
11959
|
-
fromAxiosError as
|
|
12503
|
+
fromAxiosError as fromAxiosError25,
|
|
11960
12504
|
loadGlobalConfig as loadGlobalConfig6,
|
|
11961
12505
|
discoverProjectEnv as discoverProjectEnv3,
|
|
11962
12506
|
resolveEnvContext as resolveEnvContext5,
|
|
@@ -12502,7 +13046,7 @@ function sha2562(text2) {
|
|
|
12502
13046
|
}
|
|
12503
13047
|
async function resolveEndpoint(args) {
|
|
12504
13048
|
if (args.endpoint) {
|
|
12505
|
-
process.stderr.write(`\u2192 ${args.endpoint}
|
|
13049
|
+
process.stderr.write(`\u2192 ${args.endpoint}\uFF08\u6765\u81EA --endpoint\uFF09
|
|
12506
13050
|
`);
|
|
12507
13051
|
return args.endpoint.replace(/\/+$/, "");
|
|
12508
13052
|
}
|
|
@@ -12519,7 +13063,7 @@ async function resolveEndpoint(args) {
|
|
|
12519
13063
|
const fromProject = name ? project2?.config.environments[name] : void 0;
|
|
12520
13064
|
if (fromProject?.endpoint) {
|
|
12521
13065
|
process.stderr.write(
|
|
12522
|
-
`\u2192 ${fromProject.endpoint} \xB7 \u79DF\u6237 ${fromProject.tenant} \xB7 \u8EAB\u4EFD \u672A\u767B\u5F55\uFF08\u6765\u81EA ${project2.path} \u7684 '${name}'\uFF1B\u672C\u673A\u6CA1\u6709\u5339\u914D\u7684\u69FD\
|
|
13066
|
+
`\u2192 ${fromProject.endpoint} \xB7 \u79DF\u6237 ${fromProject.tenant} \xB7 \u8EAB\u4EFD \u672A\u767B\u5F55\uFF08\u6765\u81EA ${project2.path} \u7684 '${name}'\uFF1B\u672C\u673A\u6CA1\u6709\u5339\u914D\u7684\u69FD\uFF09
|
|
12523
13067
|
`
|
|
12524
13068
|
);
|
|
12525
13069
|
return fromProject.endpoint.replace(/\/+$/, "");
|
|
@@ -12528,7 +13072,7 @@ async function resolveEndpoint(args) {
|
|
|
12528
13072
|
}
|
|
12529
13073
|
throw new CliError31({
|
|
12530
13074
|
code: CliErrorCode31.MISSING_FLAG,
|
|
12531
|
-
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002\
|
|
13075
|
+
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002 \u8BBF\u95EE\u53D7\u4FDD\u62A4\u7684\u6280\u80FD\u5E93\u9700\u767B\u8BB0\u6709\u6743\u9650\u7684\u51ED\u636E\u3002"
|
|
12532
13076
|
});
|
|
12533
13077
|
}
|
|
12534
13078
|
function normalizeEndpoint(endpoint) {
|
|
@@ -12546,7 +13090,7 @@ function decideTrackedEndpoint(options) {
|
|
|
12546
13090
|
if (!current) {
|
|
12547
13091
|
throw new CliError31({
|
|
12548
13092
|
code: CliErrorCode31.MISSING_FLAG,
|
|
12549
|
-
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002\
|
|
13093
|
+
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002 \u8BBF\u95EE\u53D7\u4FDD\u62A4\u7684\u6280\u80FD\u5E93\u9700\u767B\u8BB0\u6709\u6743\u9650\u7684\u51ED\u636E\u3002"
|
|
12550
13094
|
});
|
|
12551
13095
|
}
|
|
12552
13096
|
return current;
|
|
@@ -12622,15 +13166,42 @@ async function resolveInstallLayout(args, cwd = process.cwd(), forWrite = false)
|
|
|
12622
13166
|
baseDir: explicitDir ?? (args.global ? path16.join(os3.homedir(), ".claude", "skills") : path16.join(cwd, ".claude", "skills"))
|
|
12623
13167
|
};
|
|
12624
13168
|
}
|
|
13169
|
+
async function createChironHttpClient(endpoint, args, timeoutMs) {
|
|
13170
|
+
const target = normalizeEndpoint(endpoint);
|
|
13171
|
+
let accessToken = null;
|
|
13172
|
+
const explicitToken = process.env.HCM_PAT || process.env.HCM_ACCESS_TOKEN;
|
|
13173
|
+
const project2 = await discoverProjectEnv3(args.cwd);
|
|
13174
|
+
if (explicitToken && args.endpoint && !project2 && normalizeEndpoint(args.endpoint) === target) {
|
|
13175
|
+
accessToken = explicitToken;
|
|
13176
|
+
} else {
|
|
13177
|
+
try {
|
|
13178
|
+
const resolved = await resolveEnvContext5({ envFlag: args.env, cwd: args.cwd }, process.env, await loadGlobalConfig6());
|
|
13179
|
+
if (normalizeEndpoint(resolved.config.endpoint) === target) {
|
|
13180
|
+
const context = await getActiveAuthContextFromCli(
|
|
13181
|
+
{ env: args.env ?? resolved.project?.name ?? resolved.name },
|
|
13182
|
+
{ cwd: args.cwd }
|
|
13183
|
+
);
|
|
13184
|
+
if (normalizeEndpoint(context.endpoint) !== target) {
|
|
13185
|
+
throw new CliError31({
|
|
13186
|
+
code: CliErrorCode31.IDENTITY_NOT_IN_ENV,
|
|
13187
|
+
message: "\u6280\u80FD\u5E93\u76EE\u6807\u4E0E\u5F53\u524D\u8EAB\u4EFD\u5730\u5740\u4E0D\u4E00\u81F4",
|
|
13188
|
+
context: { nextStep: "\u6838\u5BF9\u76EE\u6807\u73AF\u5883\u7684 endpoint\uFF0C\u91CD\u65B0\u9009\u62E9\u8BE5\u73AF\u5883\u540E\u518D\u540C\u6B65\u3002" }
|
|
13189
|
+
});
|
|
13190
|
+
}
|
|
13191
|
+
accessToken = context.ephemeralAccessToken ?? await TokenStore4.forIdentity(context.identity).getStoredAccessToken();
|
|
13192
|
+
}
|
|
13193
|
+
} catch (error) {
|
|
13194
|
+
if (!(error instanceof CliError31 && (error.code === CliErrorCode31.NO_ACTIVE_ENV || error.code === CliErrorCode31.ENV_NOT_FOUND || error.code === CliErrorCode31.IDENTITY_NOT_FOUND))) throw error;
|
|
13195
|
+
}
|
|
13196
|
+
}
|
|
13197
|
+
const http2 = createHttpClient2({ endpoint: target, getAccessToken: async () => accessToken, onRefresh: async () => {
|
|
13198
|
+
}, timeoutMs });
|
|
13199
|
+
if (accessToken) http2.defaults.maxRedirects = 0;
|
|
13200
|
+
return http2;
|
|
13201
|
+
}
|
|
12625
13202
|
async function chironClient(args, options = {}) {
|
|
12626
13203
|
const endpoint = options.endpoint ?? await resolveEndpoint(args);
|
|
12627
|
-
const http2 =
|
|
12628
|
-
endpoint,
|
|
12629
|
-
getAccessToken: async () => null,
|
|
12630
|
-
onRefresh: async () => {
|
|
12631
|
-
},
|
|
12632
|
-
timeoutMs: options.timeoutMs
|
|
12633
|
-
});
|
|
13204
|
+
const http2 = await createChironHttpClient(endpoint, args, options.timeoutMs);
|
|
12634
13205
|
if (options.signal) http2.defaults.signal = options.signal;
|
|
12635
13206
|
if (options.onNoResponse) {
|
|
12636
13207
|
const observe = options.onNoResponse;
|
|
@@ -12663,13 +13234,13 @@ function fail6(e, args) {
|
|
|
12663
13234
|
if (err.config?.url) requestPath = new URL(axios4.getUri(err.config), "https://request-path.invalid").pathname;
|
|
12664
13235
|
} catch {
|
|
12665
13236
|
}
|
|
12666
|
-
const traceId =
|
|
13237
|
+
const traceId = fromAxiosError25(err, args.env).traceId;
|
|
12667
13238
|
exitWithError(new Error(
|
|
12668
13239
|
`\u6280\u80FD\u8D44\u6E90\u8BF7\u6C42\u8FD4\u56DE HTTP 404${requestPath ? `\uFF1A${requestPath}` : "\uFF08\u8BF7\u6C42\u8DEF\u5F84\u672A\u77E5\uFF09"}${traceId ? ` [traceId: ${traceId}]` : ""}\u3002
|
|
12669
13240
|
\u4E0B\u4E00\u6B65: \u8FD0\u884C hcm skills list \u6838\u5BF9\u5F53\u524D\u76EE\u5F55\uFF1B\u82E5\u76EE\u5F55\u4ECD\u58F0\u660E\u8BE5\u8D44\u6E90\uFF0C\u8BF7\u68C0\u67E5\u670D\u52A1\u7AEF\u8D44\u6E90\u548C\u5B9E\u4F8B\u7248\u672C\uFF0C\u518D\u91CD\u8BD5\u3002`
|
|
12670
13241
|
));
|
|
12671
13242
|
}
|
|
12672
|
-
if (err?.isAxiosError) exitWithError(
|
|
13243
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError25(err, args.env));
|
|
12673
13244
|
exitWithError(e);
|
|
12674
13245
|
process.exit(1);
|
|
12675
13246
|
}
|
|
@@ -12737,9 +13308,9 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
|
|
|
12737
13308
|
process.exitCode = 0;
|
|
12738
13309
|
return;
|
|
12739
13310
|
}
|
|
12740
|
-
const
|
|
13311
|
+
const shown2 = cats.flatMap((c2) => c2.skills);
|
|
12741
13312
|
const total = (manifest2?.skillCount ?? 0) + catalog.cli.entries.size;
|
|
12742
|
-
if (
|
|
13313
|
+
if (shown2.length === 0) {
|
|
12743
13314
|
process.stdout.write(`\u6CA1\u6709\u5339\u914D\u7684\u6280\u80FD\uFF08\u8FD9\u4E00\u8D9F\u770B\u7684\u6765\u6E90\u5171 ${total} \u4E2A\uFF09
|
|
12744
13315
|
`);
|
|
12745
13316
|
process.exitCode = 0;
|
|
@@ -12774,7 +13345,7 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
|
|
|
12774
13345
|
}
|
|
12775
13346
|
process.stdout.write("\n");
|
|
12776
13347
|
}
|
|
12777
|
-
process.stdout.write(` \u25CF CLI \u5C31\u7EEA \u25CB \u5F85\u6539\u5199\u52A8\u4F5C\u9762 \u5171 ${
|
|
13348
|
+
process.stdout.write(` \u25CF CLI \u5C31\u7EEA \u25CB \u5F85\u6539\u5199\u52A8\u4F5C\u9762 \u5171 ${shown2.length} \u4E2A
|
|
12778
13349
|
`);
|
|
12779
13350
|
process.stdout.write(` \u88C5\u4E00\u4E2A\uFF1Ahcm chiron skills sync --only <id>
|
|
12780
13351
|
`);
|
|
@@ -12791,7 +13362,7 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
|
|
|
12791
13362
|
}
|
|
12792
13363
|
process.stdout.write("\n");
|
|
12793
13364
|
}
|
|
12794
|
-
process.stdout.write(` \u25CF CLI \u5C31\u7EEA \u25CB \u5F85\u6539\u5199\u52A8\u4F5C\u9762 \u5171 ${
|
|
13365
|
+
process.stdout.write(` \u25CF CLI \u5C31\u7EEA \u25CB \u5F85\u6539\u5199\u52A8\u4F5C\u9762 \u5171 ${shown2.length} \u4E2A
|
|
12795
13366
|
`);
|
|
12796
13367
|
process.stdout.write(` \u88C5\u4E00\u4E2A\uFF1Ahcm chiron skills sync --only <id>
|
|
12797
13368
|
`);
|
|
@@ -12866,7 +13437,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
12866
13437
|
const allRows = [...rows2.filter((r) => !shadowed.has(r.id)), ...localRows].sort((a, b) => a.id.localeCompare(b.id));
|
|
12867
13438
|
const byKeyword = keyword ? allRows.filter((row) => row.id.includes(keyword) || row.title.includes(keyword)) : allRows;
|
|
12868
13439
|
const sourceFilter = parseSourceFilter(args.source);
|
|
12869
|
-
const
|
|
13440
|
+
const shown2 = sourceFilter === "all" ? byKeyword : byKeyword.filter((row) => row.sourceKind === sourceFilter);
|
|
12870
13441
|
const groupOf = (kind) => kind === "cli" ? "CLI \u81EA\u5E26" : kind === "local" ? "\u672C\u9879\u76EE\u81EA\u5DF1\u7684\uFF08hcm-skills/local/\uFF09" : "\u777F\u620E\u6280\u80FD\u5E93";
|
|
12871
13442
|
if (fmt === "json" || fmt === "yaml") {
|
|
12872
13443
|
process.stdout.write(formatObject21({
|
|
@@ -12877,11 +13448,11 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
12877
13448
|
updatedAt: state?.updatedAt,
|
|
12878
13449
|
// 按来源分组的小计:顾问要能一眼看出「这份是跟着 CLI 走的还是跟着后端走的」
|
|
12879
13450
|
bySource: {
|
|
12880
|
-
cli:
|
|
12881
|
-
chiron:
|
|
12882
|
-
local:
|
|
13451
|
+
cli: shown2.filter((r) => r.sourceKind === "cli").length,
|
|
13452
|
+
chiron: shown2.filter((r) => r.sourceKind === "chiron").length,
|
|
13453
|
+
local: shown2.filter((r) => r.sourceKind === "local").length
|
|
12883
13454
|
},
|
|
12884
|
-
skills:
|
|
13455
|
+
skills: shown2
|
|
12885
13456
|
}, { format: fmt }) + "\n");
|
|
12886
13457
|
process.exitCode = 0;
|
|
12887
13458
|
return;
|
|
@@ -12889,14 +13460,14 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
12889
13460
|
process.stdout.write(`\u5DF2\u5B89\u88C5\u7684\u6280\u80FD \u2014 ${layout.baseDir}\uFF08${layout.target}\uFF09
|
|
12890
13461
|
`);
|
|
12891
13462
|
process.stdout.write(`\u6765\u6E90 ${state?.endpoint ?? "\uFF08\u672A\u8BB0\u5F55\uFF09"}` + (state?.all ? " \u8DDF\u968F\u5168\u96C6\uFF1A\u662F\n\n" : "\n\n"));
|
|
12892
|
-
if (
|
|
13463
|
+
if (shown2.length === 0) {
|
|
12893
13464
|
process.stdout.write(` \u6CA1\u6709\u5339\u914D\u300C${keyword}\u300D\u7684\u6280\u80FD\uFF08\u5171\u88C5\u4E86 ${rows2.length} \u4E2A\uFF09
|
|
12894
13465
|
`);
|
|
12895
13466
|
process.exitCode = 0;
|
|
12896
13467
|
return;
|
|
12897
13468
|
}
|
|
12898
13469
|
for (const kind of ["chiron", "cli", "local"]) {
|
|
12899
|
-
const group =
|
|
13470
|
+
const group = shown2.filter((row) => row.sourceKind === kind);
|
|
12900
13471
|
if (group.length === 0) continue;
|
|
12901
13472
|
process.stdout.write(` ${groupOf(kind)}\uFF08${group.length}\uFF09
|
|
12902
13473
|
`);
|
|
@@ -12908,13 +13479,13 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
12908
13479
|
}
|
|
12909
13480
|
process.stdout.write("\n");
|
|
12910
13481
|
}
|
|
12911
|
-
const modified =
|
|
12912
|
-
const missing2 =
|
|
12913
|
-
const indirect =
|
|
13482
|
+
const modified = shown2.filter((row) => row.status === "locally-modified").length;
|
|
13483
|
+
const missing2 = shown2.filter((row) => row.status === "missing").length;
|
|
13484
|
+
const indirect = shown2.filter((row) => row.direct === false).length;
|
|
12914
13485
|
process.stdout.write("\n");
|
|
12915
13486
|
process.stdout.write(` \u25CF \u76F4\u63A5\u5B89\u88C5 \u25CB \u4F9D\u8D56\u5E26\u5165 ! \u672C\u5730\u6539\u8FC7 ? \u6587\u4EF6\u7F3A\u5931
|
|
12916
13487
|
`);
|
|
12917
|
-
process.stdout.write(` \u5171 ${
|
|
13488
|
+
process.stdout.write(` \u5171 ${shown2.length} \u4E2A` + [
|
|
12918
13489
|
indirect > 0 ? `${indirect} \u4E2A\u662F\u4F9D\u8D56\u5E26\u5165` : "",
|
|
12919
13490
|
modified > 0 ? `${modified} \u4E2A\u672C\u5730\u6539\u8FC7` : "",
|
|
12920
13491
|
missing2 > 0 ? `${missing2} \u4E2A\u6587\u4EF6\u7F3A\u5931` : ""
|
|
@@ -12928,7 +13499,7 @@ var SHOW_CHECK_REQUEST_TIMEOUT_MS = 5e3;
|
|
|
12928
13499
|
var SHOW_CHECK_TOTAL_MS = 8e3;
|
|
12929
13500
|
function uncheckedReason(error, args) {
|
|
12930
13501
|
const err = error;
|
|
12931
|
-
const resolved = err?.isAxiosError ?
|
|
13502
|
+
const resolved = err?.isAxiosError ? fromAxiosError25(err, args.env) : error;
|
|
12932
13503
|
const first = (resolved instanceof Error ? resolved.message : String(resolved)).split("\n")[0].trim();
|
|
12933
13504
|
if (!(resolved instanceof CliError31)) return first || String(resolved);
|
|
12934
13505
|
const reason = typeof resolved.context?.reason === "string" ? `\uFF1A${resolved.context.reason}` : "";
|
|
@@ -13040,11 +13611,11 @@ async function skillsInstallCommand(id, args) {
|
|
|
13040
13611
|
}),
|
|
13041
13612
|
recorded: (await readSkillsState(layout.baseDir))?.endpoint
|
|
13042
13613
|
});
|
|
13043
|
-
const client4 = await beforeAnyWrite(chironClient(
|
|
13614
|
+
const client4 = await beforeAnyWrite(chironClient(args, { endpoint: tracked }));
|
|
13044
13615
|
endpoint = client4.endpoint;
|
|
13045
13616
|
base = client4.base;
|
|
13046
13617
|
http2 = client4.http;
|
|
13047
|
-
manifest2 = await beforeAnyWrite(fetchSkillCatalog(http2, base));
|
|
13618
|
+
manifest2 = await beforeAnyWrite(fetchSkillCatalog(http2, base, { requireInstallMetadata: true }));
|
|
13048
13619
|
}
|
|
13049
13620
|
const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
|
|
13050
13621
|
const conflicts = detectIdConflicts(catalog);
|
|
@@ -14529,10 +15100,10 @@ async function skillsUpdateCommand(args) {
|
|
|
14529
15100
|
let base;
|
|
14530
15101
|
let http2;
|
|
14531
15102
|
if (source !== "cli") {
|
|
14532
|
-
const client4 = await beforeAnyWrite(chironClient(
|
|
15103
|
+
const client4 = await beforeAnyWrite(chironClient(args, { endpoint }));
|
|
14533
15104
|
http2 = client4.http;
|
|
14534
15105
|
base = client4.base;
|
|
14535
|
-
manifest2 = await beforeAnyWrite(fetchSkillCatalog(http2, base));
|
|
15106
|
+
manifest2 = await beforeAnyWrite(fetchSkillCatalog(http2, base, { requireInstallMetadata: true }));
|
|
14536
15107
|
}
|
|
14537
15108
|
const bundled = source === "chiron" ? void 0 : listBundledSkills();
|
|
14538
15109
|
const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
|
|
@@ -14835,14 +15406,14 @@ async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
|
|
|
14835
15406
|
import {
|
|
14836
15407
|
bootstrapTenant,
|
|
14837
15408
|
resetTenant,
|
|
14838
|
-
HcmClient as
|
|
15409
|
+
HcmClient as HcmClient25,
|
|
14839
15410
|
readSessionPrincipal as readSessionPrincipal2,
|
|
14840
15411
|
discoverProjectEnv as discoverProjectEnv4,
|
|
14841
15412
|
assertDangerWrite as assertDangerWrite4,
|
|
14842
15413
|
normalizeOrigin as normalizeOrigin4,
|
|
14843
15414
|
createHttpClient as createHttpClient3,
|
|
14844
15415
|
formatObject as formatObject22,
|
|
14845
|
-
fromAxiosError as
|
|
15416
|
+
fromAxiosError as fromAxiosError26,
|
|
14846
15417
|
loadGlobalConfig as loadGlobalConfig7,
|
|
14847
15418
|
resolveEnvContext as resolveEnvContext6,
|
|
14848
15419
|
printResolvedEnvironment as printResolvedEnvironment5,
|
|
@@ -14867,9 +15438,9 @@ async function tenantResetCommand(args) {
|
|
|
14867
15438
|
const { endpoint, tenantId, env: env2 } = ctx;
|
|
14868
15439
|
const safety = ctx.environmentSafety ? { ...ctx.environmentSafety } : void 0;
|
|
14869
15440
|
assertDangerWrite4(safety, "\u91CD\u7F6E\u79DF\u6237 PostgreSQL \u6570\u636E");
|
|
14870
|
-
const accessToken = await
|
|
15441
|
+
const accessToken = await HcmClient25.fromAuthContext(ctx).getAccessToken();
|
|
14871
15442
|
if (!accessToken) throw new CliError32({ code: CliErrorCode32.AUTH_FAILED, message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002" });
|
|
14872
|
-
const client4 = new
|
|
15443
|
+
const client4 = new HcmClient25({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
|
|
14873
15444
|
client4.raw().defaults.maxRedirects = 0;
|
|
14874
15445
|
client4.raw().defaults.__skipRetry = true;
|
|
14875
15446
|
const principal = await readSessionPrincipal2(client4.raw());
|
|
@@ -14912,7 +15483,7 @@ PostgreSQL \u6838\u9A8C=${receipt.pgVerified}\uFF1B\u6574\u4F53\u6838\u9A8C=${re
|
|
|
14912
15483
|
process.exitCode = receipt.pgVerified ? 0 : 4;
|
|
14913
15484
|
} catch (error) {
|
|
14914
15485
|
const e = error;
|
|
14915
|
-
const cliError = e?.isAxiosError ?
|
|
15486
|
+
const cliError = e?.isAxiosError ? fromAxiosError26(error, args.env) : error;
|
|
14916
15487
|
if (attempted) {
|
|
14917
15488
|
process.stderr.write(rejectedBeforeExecution(cliError) ? "TENANT_RESET_REJECTED_BEFORE_EXECUTION\uFF1A\u670D\u52A1\u7AEF\u5728\u6267\u884C\u524D\u62D2\u7EDD\u4E86\u672C\u6B21\u8BF7\u6C42\uFF0C\u672A\u53D1\u751F\u91CD\u7F6E\u3001\u6CA1\u6709\u91CD\u7F6E\u6D41\u6C34\uFF1B\u6309\u4E0B\u9762\u7684\u670D\u52A1\u7AEF\u8BF4\u660E\u5904\u7406\u540E\u518D\u91CD\u8BD5\u3002\n" : "TENANT_RESET_RESULT_UNKNOWN\uFF1A\u672C\u6B21\u5DF2\u5C1D\u8BD5\u4E00\u6B21\u91CD\u7F6E\uFF0C\u7ED3\u679C\u672A\u786E\u8BA4\uFF1B\u672A\u81EA\u52A8\u91CD\u8BD5\u3002\u4E0D\u8981\u76F2\u76EE\u91CD\u8DD1\uFF0C\u8BF7\u6838\u67E5\u670D\u52A1\u7AEF\u6D41\u6C34\u4E0E\u5F53\u524D\u79DF\u6237\u72B6\u6001\u3002\n");
|
|
14918
15489
|
}
|
|
@@ -15085,7 +15656,7 @@ async function tenantBootstrapCommand(args) {
|
|
|
15085
15656
|
if (err?.response?.status === 403) {
|
|
15086
15657
|
exitWithError(new Error("bootstrap key \u65E0\u6548\uFF08403\uFF09\u2014\u2014 \u6838\u5BF9\u90E8\u7F72\u65B9\u63D0\u4F9B\u7684 key\uFF0C\u52FF\u590D\u7528\u5176\u4ED6\u73AF\u5883\u7684"));
|
|
15087
15658
|
} else if (err?.isAxiosError) {
|
|
15088
|
-
exitWithError(
|
|
15659
|
+
exitWithError(fromAxiosError26(err, args.env));
|
|
15089
15660
|
} else {
|
|
15090
15661
|
exitWithError(e);
|
|
15091
15662
|
}
|
|
@@ -15095,14 +15666,14 @@ async function tenantBootstrapCommand(args) {
|
|
|
15095
15666
|
// src/commands/tenant-reconcile.ts
|
|
15096
15667
|
init_auth_guard();
|
|
15097
15668
|
import {
|
|
15098
|
-
HcmClient as
|
|
15669
|
+
HcmClient as HcmClient26,
|
|
15099
15670
|
readSessionPrincipal as readSessionPrincipal3,
|
|
15100
15671
|
reconcileTenant,
|
|
15101
15672
|
assertDangerWrite as assertDangerWrite5,
|
|
15102
15673
|
formatObject as formatObject23,
|
|
15103
15674
|
CliError as CliError33,
|
|
15104
15675
|
CliErrorCode as CliErrorCode33,
|
|
15105
|
-
fromAxiosError as
|
|
15676
|
+
fromAxiosError as fromAxiosError27
|
|
15106
15677
|
} from "@hcmai/sdk";
|
|
15107
15678
|
import axios5 from "axios";
|
|
15108
15679
|
init_exit();
|
|
@@ -15141,12 +15712,12 @@ async function tenantReconcileCommand(args) {
|
|
|
15141
15712
|
const { endpoint, tenantId, env: env2 } = ctx;
|
|
15142
15713
|
const safety = ctx.environmentSafety ? { ...ctx.environmentSafety } : void 0;
|
|
15143
15714
|
assertDangerWrite5(safety, "\u8865\u8DD1\u5F53\u524D\u79DF\u6237\u521D\u59CB\u5316");
|
|
15144
|
-
const accessToken = await
|
|
15715
|
+
const accessToken = await HcmClient26.fromAuthContext(ctx).getAccessToken();
|
|
15145
15716
|
if (!accessToken) throw new CliError33({
|
|
15146
15717
|
code: CliErrorCode33.AUTH_FAILED,
|
|
15147
15718
|
message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u8865\u8DD1\u3002"
|
|
15148
15719
|
});
|
|
15149
|
-
const client4 = new
|
|
15720
|
+
const client4 = new HcmClient26({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
|
|
15150
15721
|
client4.raw().defaults.maxRedirects = 0;
|
|
15151
15722
|
client4.raw().defaults.__skipRetry = true;
|
|
15152
15723
|
const principal = await readSessionPrincipal3(client4.raw());
|
|
@@ -15191,7 +15762,7 @@ async function tenantReconcileCommand(args) {
|
|
|
15191
15762
|
...!passed ? { reason: "\u521D\u59CB\u5316\u590D\u9A8C\u672A\u8BC1\u660E\u5F53\u524D\u79DF\u6237\u5168\u90E8\u7EC4\u4EF6\u901A\u8FC7\uFF1B\u8BF7\u8BFB\u53D6\u539F\u59CB report\uFF0C\u4E0D\u80FD\u5BA3\u79F0\u5B8C\u6210\u3002" } : {}
|
|
15192
15763
|
};
|
|
15193
15764
|
} catch (error) {
|
|
15194
|
-
const translated = axios5.isAxiosError(error) ?
|
|
15765
|
+
const translated = axios5.isAxiosError(error) ? fromAxiosError27(error, env2) : error;
|
|
15195
15766
|
verification = { status: "UNDETERMINED", reason: translated instanceof Error ? translated.message : "\u521D\u59CB\u5316\u590D\u9A8C\u5931\u8D25\uFF0C\u539F\u56E0\u672A\u77E5" };
|
|
15196
15767
|
}
|
|
15197
15768
|
}
|
|
@@ -15212,7 +15783,7 @@ async function tenantReconcileCommand(args) {
|
|
|
15212
15783
|
process.exitCode = verification.status === "PASS" ? 0 : 3;
|
|
15213
15784
|
} catch (error) {
|
|
15214
15785
|
if (attempted) process.stderr.write("TENANT_RECONCILE_RESULT_UNKNOWN\uFF1A\u5DF2\u5C1D\u8BD5\u4E00\u6B21\u8865\u8DD1\uFF0C\u7ED3\u679C\u672A\u786E\u8BA4\uFF0C\u672A\u81EA\u52A8\u91CD\u53D1\uFF1B\u5148\u53EA\u8BFB\u68C0\u67E5 tenant.bootstrap \u4E0E\u670D\u52A1\u7AEF\u65E5\u5FD7\uFF0C\u4E0D\u8981\u76F2\u76EE\u91CD\u8DD1\u3002\n");
|
|
15215
|
-
exitWithError(axios5.isAxiosError(error) ?
|
|
15786
|
+
exitWithError(axios5.isAxiosError(error) ? fromAxiosError27(error, args.env) : error);
|
|
15216
15787
|
}
|
|
15217
15788
|
}
|
|
15218
15789
|
|
|
@@ -15221,9 +15792,9 @@ import { promises as fsp5 } from "fs";
|
|
|
15221
15792
|
import os4 from "os";
|
|
15222
15793
|
import nodePath from "path";
|
|
15223
15794
|
import {
|
|
15224
|
-
HcmClient as
|
|
15795
|
+
HcmClient as HcmClient27,
|
|
15225
15796
|
formatObject as formatObject24,
|
|
15226
|
-
fromAxiosError as
|
|
15797
|
+
fromAxiosError as fromAxiosError28,
|
|
15227
15798
|
listTenantMeta,
|
|
15228
15799
|
getTenantMeta,
|
|
15229
15800
|
saveTenantMeta,
|
|
@@ -15240,7 +15811,7 @@ init_exit();
|
|
|
15240
15811
|
init_impersonation_lifecycle();
|
|
15241
15812
|
init_auth_guard();
|
|
15242
15813
|
async function client2(args) {
|
|
15243
|
-
return
|
|
15814
|
+
return HcmClient27.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
15244
15815
|
}
|
|
15245
15816
|
function formatMetaForbiddenMessage(mode = "write") {
|
|
15246
15817
|
if (mode === "read") {
|
|
@@ -15255,7 +15826,7 @@ function fail7(e, args, mode = "write") {
|
|
|
15255
15826
|
new Error(formatMetaForbiddenMessage(mode))
|
|
15256
15827
|
);
|
|
15257
15828
|
}
|
|
15258
|
-
if (err?.isAxiosError) exitWithError(
|
|
15829
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError28(err, args.env));
|
|
15259
15830
|
exitWithError(e);
|
|
15260
15831
|
process.exit(1);
|
|
15261
15832
|
}
|
|
@@ -15561,7 +16132,7 @@ init_exit();
|
|
|
15561
16132
|
init_error_output();
|
|
15562
16133
|
init_auth_guard();
|
|
15563
16134
|
import {
|
|
15564
|
-
HcmClient as
|
|
16135
|
+
HcmClient as HcmClient28,
|
|
15565
16136
|
CliError as CliError35,
|
|
15566
16137
|
CliErrorCode as CliErrorCode35,
|
|
15567
16138
|
formatObject as formatObject25,
|
|
@@ -15593,7 +16164,7 @@ function flagsOf(args) {
|
|
|
15593
16164
|
return connFlags(args) + (args.workspace ? ` --workspace ${args.workspace}` : "");
|
|
15594
16165
|
}
|
|
15595
16166
|
function client3(args) {
|
|
15596
|
-
return getActiveAuthContextFromCli(args).then((ctx) =>
|
|
16167
|
+
return getActiveAuthContextFromCli(args).then((ctx) => HcmClient28.fromAuthContext(ctx));
|
|
15597
16168
|
}
|
|
15598
16169
|
function formatOf(args) {
|
|
15599
16170
|
return args.output === "json" || args.output === "yaml" ? args.output : "table";
|
|
@@ -15792,7 +16363,7 @@ async function metaColumnSlotSqlCommand(model, field, args) {
|
|
|
15792
16363
|
init_exit();
|
|
15793
16364
|
init_auth_guard();
|
|
15794
16365
|
import {
|
|
15795
|
-
HcmClient as
|
|
16366
|
+
HcmClient as HcmClient29,
|
|
15796
16367
|
CliError as CliError36,
|
|
15797
16368
|
CliErrorCode as CliErrorCode36,
|
|
15798
16369
|
formatObject as formatObject26,
|
|
@@ -15888,7 +16459,7 @@ function writeNotes2(view, args, fmt) {
|
|
|
15888
16459
|
async function metaStorageSlotsCommand(args) {
|
|
15889
16460
|
try {
|
|
15890
16461
|
const family = requestedFamily(args);
|
|
15891
|
-
const client4 =
|
|
16462
|
+
const client4 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
15892
16463
|
const full = await getStorageSlots(client4.raw());
|
|
15893
16464
|
const view = family ? pickFamily(full, family) : full;
|
|
15894
16465
|
const fmt = formatOf2(args);
|
|
@@ -15916,7 +16487,7 @@ import {
|
|
|
15916
16487
|
formatObject as formatObject28,
|
|
15917
16488
|
formatRows as formatRows6,
|
|
15918
16489
|
getMiniStatus,
|
|
15919
|
-
HcmClient as
|
|
16490
|
+
HcmClient as HcmClient30,
|
|
15920
16491
|
initMiniAppProject,
|
|
15921
16492
|
inferMiniWritableTemplateOptionsFromModel,
|
|
15922
16493
|
listWorkspaceFiles,
|
|
@@ -15933,14 +16504,14 @@ import {
|
|
|
15933
16504
|
validateMiniProject,
|
|
15934
16505
|
validateMetaContent as validateMetaContent2,
|
|
15935
16506
|
validateWorkspaceFiles,
|
|
15936
|
-
fromAxiosError as
|
|
16507
|
+
fromAxiosError as fromAxiosError30,
|
|
15937
16508
|
CliError as CliError38,
|
|
15938
16509
|
CliErrorCode as CliErrorCode38
|
|
15939
16510
|
} from "@hcmai/sdk";
|
|
15940
16511
|
|
|
15941
16512
|
// src/commands/workspace-push-progress.ts
|
|
15942
16513
|
import { isAxiosError as isAxiosError2 } from "axios";
|
|
15943
|
-
import { CliError as CliError37, CliErrorCode as CliErrorCode37, fromAxiosError as
|
|
16514
|
+
import { CliError as CliError37, CliErrorCode as CliErrorCode37, fromAxiosError as fromAxiosError29 } from "@hcmai/sdk";
|
|
15944
16515
|
var PUSH_DEADLINE_MS = 3e5;
|
|
15945
16516
|
var HEARTBEAT_MS = 1e4;
|
|
15946
16517
|
async function withWorkspacePushProgress(run3, profile) {
|
|
@@ -16011,7 +16582,7 @@ async function withWorkspacePushProgress(run3, profile) {
|
|
|
16011
16582
|
return await Promise.race([operation, deadline]);
|
|
16012
16583
|
} catch (error) {
|
|
16013
16584
|
if (!isAxiosError2(error)) throw error;
|
|
16014
|
-
const translated =
|
|
16585
|
+
const translated = fromAxiosError29(error, profile);
|
|
16015
16586
|
throw new CliError37({
|
|
16016
16587
|
code: translated.code,
|
|
16017
16588
|
message: translated.message,
|
|
@@ -16392,7 +16963,7 @@ function isProtectedWorkspacePath(relativePath) {
|
|
|
16392
16963
|
}
|
|
16393
16964
|
async function workspaceListCommand(args) {
|
|
16394
16965
|
try {
|
|
16395
|
-
const client4 =
|
|
16966
|
+
const client4 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
16396
16967
|
const limit = parsePositiveInt3(args.limit, 50, "--limit");
|
|
16397
16968
|
const result = await client4.query("TenantExtensionWorkspace", {
|
|
16398
16969
|
keyword: args.keyword,
|
|
@@ -16425,7 +16996,7 @@ async function workspaceActiveCommand(args) {
|
|
|
16425
16996
|
const ctx = await getActiveAuthContextFromCli(args, {
|
|
16426
16997
|
fallbackEnv: localContext?.profile
|
|
16427
16998
|
});
|
|
16428
|
-
const client4 =
|
|
16999
|
+
const client4 = HcmClient30.fromAuthContext(ctx);
|
|
16429
17000
|
const binding = await readWorkspaceDevModeBinding(client4);
|
|
16430
17001
|
const activeWorkspaceKey = binding.enabled ? optionalText(binding.workspaceKey) : null;
|
|
16431
17002
|
const bindingUpdatedAt = typeof binding.updatedAt === "number" && Number.isFinite(binding.updatedAt) && binding.updatedAt > 0 && binding.updatedAt <= 864e13 ? binding.updatedAt : null;
|
|
@@ -16483,7 +17054,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
|
|
|
16483
17054
|
`${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
|
|
16484
17055
|
);
|
|
16485
17056
|
}
|
|
16486
|
-
const client4 =
|
|
17057
|
+
const client4 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
16487
17058
|
const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
|
|
16488
17059
|
const resp = await client4.raw().post("/api/models/TenantExtensionWorkspace", {
|
|
16489
17060
|
workspaceKey: normalizedWorkspaceKey,
|
|
@@ -16525,7 +17096,7 @@ async function workspaceRebaseCommand(args) {
|
|
|
16525
17096
|
try {
|
|
16526
17097
|
const existing = await readWorkspaceContext(resolveRootDir(args.dir));
|
|
16527
17098
|
const workspaceKey = normalizeWorkspaceKey(args.workspace ?? existing?.workspaceKey ?? "");
|
|
16528
|
-
await runWorkspaceRebase(workspaceKey, args, async () =>
|
|
17099
|
+
await runWorkspaceRebase(workspaceKey, args, async () => HcmClient30.fromAuthContext(
|
|
16529
17100
|
await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
|
|
16530
17101
|
));
|
|
16531
17102
|
process.exitCode = 0;
|
|
@@ -16543,7 +17114,7 @@ async function workspacePullCommand(args) {
|
|
|
16543
17114
|
`workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
|
|
16544
17115
|
);
|
|
16545
17116
|
}
|
|
16546
|
-
const client4 =
|
|
17117
|
+
const client4 = HcmClient30.fromAuthContext(
|
|
16547
17118
|
await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
|
|
16548
17119
|
);
|
|
16549
17120
|
const context = buildWorkspaceContext({
|
|
@@ -16710,7 +17281,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
16710
17281
|
const manifest2 = await readWorkspaceRawManifest(rootDir, context);
|
|
16711
17282
|
let manifestEntry = workspaceRawBaselineByPath(manifest2).get(normalized);
|
|
16712
17283
|
if (!manifestEntry) {
|
|
16713
|
-
const client4 =
|
|
17284
|
+
const client4 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(
|
|
16714
17285
|
args,
|
|
16715
17286
|
{ fallbackEnv: context.profile }
|
|
16716
17287
|
));
|
|
@@ -16874,7 +17445,7 @@ async function workspacePushCommand(args) {
|
|
|
16874
17445
|
});
|
|
16875
17446
|
}
|
|
16876
17447
|
}
|
|
16877
|
-
const client4 =
|
|
17448
|
+
const client4 = HcmClient30.fromAuthContext(
|
|
16878
17449
|
await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
|
|
16879
17450
|
);
|
|
16880
17451
|
profile = client4.profile ?? profile;
|
|
@@ -17482,7 +18053,7 @@ ${formatReleaseIssues(result.preflight.releaseIssues, " ")}` : ""),
|
|
|
17482
18053
|
checkpointSaved
|
|
17483
18054
|
});
|
|
17484
18055
|
} catch (error) {
|
|
17485
|
-
const translated = error?.isAxiosError ?
|
|
18056
|
+
const translated = error?.isAxiosError ? fromAxiosError30(error, args.profile ?? args.context.profile) : error;
|
|
17486
18057
|
const details = translated instanceof CliError38 ? translated.context?.details : void 0;
|
|
17487
18058
|
const commitDetails = details && typeof details === "object" && !Array.isArray(details) ? details : void 0;
|
|
17488
18059
|
const serverCommitted = error?.isAxiosError === true && commitDetails?.workspaceKey === args.context.workspaceKey && commitDetails.relativePath === operation.remotePath && commitDetails.commitState === "COMMITTED";
|
|
@@ -17573,7 +18144,7 @@ async function preflightWorkspacePlan(http2, workspaceKey, operations, localFile
|
|
|
17573
18144
|
}
|
|
17574
18145
|
function preflightCallFailure(error, sent, profile) {
|
|
17575
18146
|
const status = error?.response?.status;
|
|
17576
|
-
const translated = error?.isAxiosError ?
|
|
18147
|
+
const translated = error?.isAxiosError ? fromAxiosError30(error, profile) : error;
|
|
17577
18148
|
const detail = translated instanceof Error ? translated.message : String(translated);
|
|
17578
18149
|
return {
|
|
17579
18150
|
status: "unavailable",
|
|
@@ -17946,7 +18517,7 @@ async function readMiniStatusSafely(app) {
|
|
|
17946
18517
|
async function loadProfileClient(args) {
|
|
17947
18518
|
try {
|
|
17948
18519
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
17949
|
-
return
|
|
18520
|
+
return HcmClient30.fromAuthContext(ctx);
|
|
17950
18521
|
} catch (e) {
|
|
17951
18522
|
if (args.env || args.profile) throw e;
|
|
17952
18523
|
return null;
|
|
@@ -18404,7 +18975,7 @@ function exitWorkspaceError(err, profile, operation, format) {
|
|
|
18404
18975
|
return exitWithError(failure2);
|
|
18405
18976
|
};
|
|
18406
18977
|
const maybeAxios = err;
|
|
18407
|
-
const translated = maybeAxios?.isAxiosError ?
|
|
18978
|
+
const translated = maybeAxios?.isAxiosError ? fromAxiosError30(err, profile) : err;
|
|
18408
18979
|
if (translated instanceof CliError38 && operation && translated.context?.status === 409 && ["WORKSPACE_REVISION_CONFLICT", "DEPLOY_IN_PROGRESS"].includes(String(translated.context.responseCode))) {
|
|
18409
18980
|
const scope = `${profile ? ` --env ${quoteWorkspaceArg(profile)}` : ""}${operation.as ? ` --as ${quoteWorkspaceArg(operation.as)}` : ""}`;
|
|
18410
18981
|
const active = "hcm workspace active" + scope + (operation.dir ? ` --dir ${quoteWorkspaceArg(operation.dir)}` : "");
|
|
@@ -18491,7 +19062,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
18491
19062
|
let recovery2;
|
|
18492
19063
|
let profile = args.env ?? args.profile;
|
|
18493
19064
|
try {
|
|
18494
|
-
const client4 =
|
|
19065
|
+
const client4 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
18495
19066
|
profile = client4.profile ?? profile;
|
|
18496
19067
|
const key2 = normalizeWorkspaceKey(workspaceKey);
|
|
18497
19068
|
recovery2 = { command: "activate", workspaceKey: key2, as: args.as };
|
|
@@ -18514,7 +19085,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
18514
19085
|
}
|
|
18515
19086
|
async function workspaceDeactivateCommand(args) {
|
|
18516
19087
|
try {
|
|
18517
|
-
const client4 =
|
|
19088
|
+
const client4 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
18518
19089
|
const binding = await requestWorkspaceDeactivation(client4);
|
|
18519
19090
|
const result = { ...binding, deactivated: true };
|
|
18520
19091
|
const fmt = args.output ?? "table";
|
|
@@ -18540,7 +19111,7 @@ import {
|
|
|
18540
19111
|
CliErrorCode as CliErrorCode39,
|
|
18541
19112
|
formatObject as formatObject29,
|
|
18542
19113
|
formatRows as formatRows7,
|
|
18543
|
-
fromAxiosError as
|
|
19114
|
+
fromAxiosError as fromAxiosError31,
|
|
18544
19115
|
loadEnv as loadEnv4,
|
|
18545
19116
|
saveEnv as saveEnv3,
|
|
18546
19117
|
loadIdentity as loadIdentity4,
|
|
@@ -18549,7 +19120,7 @@ import {
|
|
|
18549
19120
|
loadGlobalConfig as loadGlobalConfig8,
|
|
18550
19121
|
resolveActiveEnv,
|
|
18551
19122
|
printResolvedEnvironment as printResolvedEnvironment6,
|
|
18552
|
-
TokenStore as
|
|
19123
|
+
TokenStore as TokenStore5,
|
|
18553
19124
|
toPrincipal
|
|
18554
19125
|
} from "@hcmai/sdk";
|
|
18555
19126
|
var fetchAuthInfo = async (endpoint, accessToken) => {
|
|
@@ -18562,7 +19133,7 @@ var fetchAuthInfo = async (endpoint, accessToken) => {
|
|
|
18562
19133
|
async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
18563
19134
|
const meta2 = await loadIdentity4(name);
|
|
18564
19135
|
const env2 = await loadEnv4(meta2.env);
|
|
18565
|
-
const accessToken = await
|
|
19136
|
+
const accessToken = await TokenStore5.forIdentity(name).getStoredAccessToken();
|
|
18566
19137
|
if (!accessToken) {
|
|
18567
19138
|
throw new CliError39({
|
|
18568
19139
|
code: CliErrorCode39.AUTH_FAILED,
|
|
@@ -18595,7 +19166,7 @@ async function identityShow(name, args) {
|
|
|
18595
19166
|
const details = await inspectIdentity(name);
|
|
18596
19167
|
return exitOk(formatObject29(details, { format: args.output ?? "json" }));
|
|
18597
19168
|
} catch (e) {
|
|
18598
|
-
exitWithError(axios6.isAxiosError(e) ?
|
|
19169
|
+
exitWithError(axios6.isAxiosError(e) ? fromAxiosError31(e, name) : e);
|
|
18599
19170
|
}
|
|
18600
19171
|
}
|
|
18601
19172
|
async function identityList(args) {
|
|
@@ -18644,7 +19215,7 @@ async function identityRemove(name) {
|
|
|
18644
19215
|
try {
|
|
18645
19216
|
const meta2 = await loadIdentity4(name);
|
|
18646
19217
|
try {
|
|
18647
|
-
await
|
|
19218
|
+
await TokenStore5.forIdentity(name).clear();
|
|
18648
19219
|
} catch (err) {
|
|
18649
19220
|
process.stderr.write(
|
|
18650
19221
|
`[hcm] event=identity_cleanup_failed identity=${name} reason=${JSON.stringify(String(err.message))}
|
|
@@ -18671,7 +19242,7 @@ import path19 from "path";
|
|
|
18671
19242
|
import {
|
|
18672
19243
|
CliError as CliError40,
|
|
18673
19244
|
CliErrorCode as CliErrorCode40,
|
|
18674
|
-
HcmClient as
|
|
19245
|
+
HcmClient as HcmClient31,
|
|
18675
19246
|
fetchReconIdentity,
|
|
18676
19247
|
formatObject as formatObject30,
|
|
18677
19248
|
httpProbe,
|
|
@@ -18686,7 +19257,7 @@ import {
|
|
|
18686
19257
|
} from "@hcmai/sdk";
|
|
18687
19258
|
async function probeTokenTenant(envName, requested) {
|
|
18688
19259
|
const ctx = await getActiveAuthContextFromCli({ env: envName });
|
|
18689
|
-
const client4 =
|
|
19260
|
+
const client4 = HcmClient31.fromAuthContext(ctx);
|
|
18690
19261
|
const identity3 = await fetchReconIdentity(httpProbe(client4.raw(), "default"), requested);
|
|
18691
19262
|
return identity3?.tenantId ? String(identity3.tenantId) : void 0;
|
|
18692
19263
|
}
|
|
@@ -18960,7 +19531,7 @@ import {
|
|
|
18960
19531
|
listIdentities as listIdentities6,
|
|
18961
19532
|
parseEnvYaml as parseEnvYaml2,
|
|
18962
19533
|
renderEnvYaml as renderEnvYaml2,
|
|
18963
|
-
TokenStore as
|
|
19534
|
+
TokenStore as TokenStore6,
|
|
18964
19535
|
toPrincipal as toPrincipal2,
|
|
18965
19536
|
validateCliAuthorizationUrl as validateCliAuthorizationUrl2
|
|
18966
19537
|
} from "@hcmai/sdk";
|
|
@@ -19011,7 +19582,7 @@ async function tokenTenant(endpoint, token) {
|
|
|
19011
19582
|
return typeof tenant2 === "string" || typeof tenant2 === "number" && Number.isSafeInteger(tenant2) ? toPrincipal2(raw)?.tenantId : void 0;
|
|
19012
19583
|
}
|
|
19013
19584
|
function readStoredIdentityToken(name) {
|
|
19014
|
-
return
|
|
19585
|
+
return TokenStore6.forIdentity(name).getStoredAccessToken();
|
|
19015
19586
|
}
|
|
19016
19587
|
async function inspectEnvironment(env2) {
|
|
19017
19588
|
try {
|
|
@@ -19204,7 +19775,6 @@ import {
|
|
|
19204
19775
|
METHOD_REPO_DISPLAY,
|
|
19205
19776
|
METHOD_REPO_URL,
|
|
19206
19777
|
assertSafeSkillId as assertSafeSkillId2,
|
|
19207
|
-
createHttpClient as createHttpClient5,
|
|
19208
19778
|
discoverProjectEnv as discoverProjectEnv7,
|
|
19209
19779
|
fetchSkillCatalog as fetchSkillCatalog2,
|
|
19210
19780
|
flattenSkills as flattenSkills2,
|
|
@@ -19351,9 +19921,8 @@ function defaultMethodDeps() {
|
|
|
19351
19921
|
repoDisplay: METHOD_REPO_DISPLAY,
|
|
19352
19922
|
git: makeGitRunner(METHOD_REPO_DISPLAY),
|
|
19353
19923
|
listBundled: () => ({ ids: listBundledSkills().map((s) => s.id), version: CLI_VERSION, dir: bundledSkillsDir() }),
|
|
19354
|
-
fetchOnlineCatalog: async (endpoint) => {
|
|
19355
|
-
const http2 =
|
|
19356
|
-
}, timeoutMs: 15e3 });
|
|
19924
|
+
fetchOnlineCatalog: async (endpoint, projectRoot, envName) => {
|
|
19925
|
+
const http2 = await createChironHttpClient(endpoint, { cwd: projectRoot, env: envName }, 15e3);
|
|
19357
19926
|
const base = await resolveChironBase2(http2);
|
|
19358
19927
|
return flattenSkills2(await fetchSkillCatalog2(http2, base)).map((s) => s.id);
|
|
19359
19928
|
},
|
|
@@ -19711,7 +20280,7 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
|
|
|
19711
20280
|
b.note = online.reason ?? "\u6CA1\u6709\u53EF\u6BD4\u5BF9\u7684\u73AF\u5883";
|
|
19712
20281
|
} else {
|
|
19713
20282
|
try {
|
|
19714
|
-
const ids = await deps.fetchOnlineCatalog(online.endpoint);
|
|
20283
|
+
const ids = await deps.fetchOnlineCatalog(online.endpoint, root, online.envName);
|
|
19715
20284
|
if (ids.length === 0) {
|
|
19716
20285
|
b.note = `${online.endpoint} \u7684\u5728\u7EBF\u76EE\u5F55\u662F\u7A7A\u7684\uFF0C\u7A7A\u96C6\u5408\u4E0A\u6BD4\u4E0D\u51FA\u300C\u65E0\u540C\u540D\u300D\uFF0C\u5728\u7EBF\u76EE\u5F55\u672A\u6BD4\u5BF9`;
|
|
19717
20286
|
} else {
|
|
@@ -20257,9 +20826,9 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
20257
20826
|
if (!existsSync6(copyDir) && state?.target !== "claude") continue;
|
|
20258
20827
|
const prefix = `${path22.posix.dirname(s.path)}/`;
|
|
20259
20828
|
for (const f of manifest2.files.filter((x) => x.path.startsWith(prefix))) {
|
|
20260
|
-
const
|
|
20261
|
-
copyEntries.push({ ...f, path:
|
|
20262
|
-
copyMap.set(
|
|
20829
|
+
const shown2 = `.claude/skills/${s.id}/${f.path.slice(prefix.length)}`;
|
|
20830
|
+
copyEntries.push({ ...f, path: shown2 });
|
|
20831
|
+
copyMap.set(shown2, path22.join(root, shown2));
|
|
20263
20832
|
}
|
|
20264
20833
|
}
|
|
20265
20834
|
const copies = await verifyDigests(copyEntries, (p) => copyMap.get(p));
|
|
@@ -20663,23 +21232,29 @@ var installed = async (ctx) => {
|
|
|
20663
21232
|
}
|
|
20664
21233
|
};
|
|
20665
21234
|
var fresh = async (ctx, _env, execution) => {
|
|
20666
|
-
|
|
21235
|
+
const target = ctx.environments.find((e) => e.report.target);
|
|
21236
|
+
const states = ctx.skills;
|
|
21237
|
+
if (!hasProductSkills(states)) return ctx.services.skillsFresh(states, target.config.endpoint, execution.signal);
|
|
21238
|
+
const credential2 = await target.credential();
|
|
21239
|
+
const token = credential2.resolved && normalizeEndpoint(credential2.resolved.config.endpoint) === normalizeEndpoint(target.config.endpoint) ? credential2.token ?? void 0 : void 0;
|
|
21240
|
+
return ctx.services.skillsFresh(states, target.config.endpoint, execution.signal, token);
|
|
20667
21241
|
};
|
|
20668
21242
|
var NO_PRODUCT_SKILLS = "\u6CA1\u6709\u4EA7\u54C1\u6280\u80FD\u8981\u548C\u76EE\u5F55\u5BF9\u8D26\uFF1A\u672C\u9879\u76EE\u7684\u6280\u80FD\u90FD\u6765\u81EA local/\uFF0Csync \u4E0D\u7BA1\u5B83\u4EEC";
|
|
20669
21243
|
function hasProductSkills(states) {
|
|
20670
21244
|
return states.some(({ state }) => Boolean(state.all) || Object.values(state.skills).some((r) => (r.sourceKind ?? "chiron") !== "local"));
|
|
20671
21245
|
}
|
|
20672
|
-
async function inspectSkillsFresh(states, endpoint, signal) {
|
|
21246
|
+
async function inspectSkillsFresh(states, endpoint, signal, token) {
|
|
20673
21247
|
if (!hasProductSkills(states)) return { level: "NOT_APPLICABLE", summary: NO_PRODUCT_SKILLS, note: "\u672A\u8BF7\u6C42\u6280\u80FD\u76EE\u5F55" };
|
|
20674
21248
|
const http2 = axios7.create({
|
|
20675
21249
|
baseURL: endpoint,
|
|
20676
21250
|
timeout: 5e3,
|
|
20677
21251
|
maxRedirects: 0,
|
|
21252
|
+
headers: token ? { Authorization: `Bearer ${token}` } : void 0,
|
|
20678
21253
|
signal: AbortSignal.any([signal, AbortSignal.timeout(8e3)])
|
|
20679
21254
|
});
|
|
20680
21255
|
try {
|
|
20681
21256
|
const base = await resolveChironBase3(http2);
|
|
20682
|
-
const manifest2 = await fetchSkillCatalog3(http2, base);
|
|
21257
|
+
const manifest2 = await fetchSkillCatalog3(http2, base, { requireInstallMetadata: true });
|
|
20683
21258
|
const catalog = buildUnifiedCatalog({ source: "all", chironManifest: manifest2, bundled: listBundledSkills(), cliVersion: "doctor" });
|
|
20684
21259
|
const conflicts = detectIdConflicts(catalog);
|
|
20685
21260
|
if (conflicts.ids.length > 0) {
|
|
@@ -20713,13 +21288,14 @@ async function inspectSkillsFresh(states, endpoint, signal) {
|
|
|
20713
21288
|
} catch (error) {
|
|
20714
21289
|
if (error instanceof CliError46 && error.code === CliErrorCode46.SKILL_CATALOG_UNAVAILABLE) {
|
|
20715
21290
|
const reason = typeof error.context?.reason === "string" ? `\uFF1A${error.context.reason}` : "";
|
|
20716
|
-
const
|
|
20717
|
-
return unknown("SKILLS_CATALOG_UNAVAILABLE", `\u670D\u52A1\u7AEF\u6280\u80FD\u76EE\u5F55\u4E0D\u53EF\u7528\uFF08${error.message}${reason}\uFF09\uFF0C\u672C\u8F6E\u6CA1\u6CD5\u5BF9\u8D26`,
|
|
21291
|
+
const next2 = typeof error.context?.nextStep === "string" ? error.context.nextStep : void 0;
|
|
21292
|
+
return unknown("SKILLS_CATALOG_UNAVAILABLE", `\u670D\u52A1\u7AEF\u6280\u80FD\u76EE\u5F55\u4E0D\u53EF\u7528\uFF08${error.message}${reason}\uFF09\uFF0C\u672C\u8F6E\u6CA1\u6CD5\u5BF9\u8D26`, next2 ? { note: next2 } : {});
|
|
20718
21293
|
}
|
|
20719
21294
|
if (error instanceof CliError46 && error.code === CliErrorCode46.SKILL_SOURCE_UNREACHABLE) {
|
|
20720
21295
|
return unknown("SKILLS_BUNDLED_UNREACHABLE", void 0, { note: safeError(error) });
|
|
20721
21296
|
}
|
|
20722
|
-
|
|
21297
|
+
const next = error instanceof CliError46 ? error.context?.nextStep : void 0;
|
|
21298
|
+
return unknown("SKILLS_CATALOG_UNCHECKED", void 0, { note: [safeError(error), next].filter(Boolean).join("\uFF1B") });
|
|
20723
21299
|
}
|
|
20724
21300
|
}
|
|
20725
21301
|
function classifySkillFreshness(stateCount, entries, mismatched) {
|
|
@@ -22922,7 +23498,7 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
|
|
|
22922
23498
|
import fs17 from "fs/promises";
|
|
22923
23499
|
import os6 from "os";
|
|
22924
23500
|
import path27 from "path";
|
|
22925
|
-
import { CliError as CliError52, CliErrorCode as CliErrorCode51, formatObject as formatObject35, HcmClient as
|
|
23501
|
+
import { CliError as CliError52, CliErrorCode as CliErrorCode51, formatObject as formatObject35, HcmClient as HcmClient32, loadEnv as loadEnv6 } from "@hcmai/sdk";
|
|
22926
23502
|
import { createRequire } from "module";
|
|
22927
23503
|
|
|
22928
23504
|
// src/commands/chiron-page-cdp.ts
|
|
@@ -23534,7 +24110,7 @@ var defaultChironPageDeps = {
|
|
|
23534
24110
|
context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
|
|
23535
24111
|
});
|
|
23536
24112
|
}
|
|
23537
|
-
const client4 =
|
|
24113
|
+
const client4 = HcmClient32.fromAuthContext(ctx);
|
|
23538
24114
|
const { ticket } = await mintBrowserTicket(client4, ctx.env)();
|
|
23539
24115
|
return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
|
|
23540
24116
|
},
|
|
@@ -23622,7 +24198,7 @@ import { formatObject as formatObject36 } from "@hcmai/sdk";
|
|
|
23622
24198
|
|
|
23623
24199
|
// src/commands/delivery-action-policy.ts
|
|
23624
24200
|
init_auth_guard();
|
|
23625
|
-
import { HcmClient as
|
|
24201
|
+
import { HcmClient as HcmClient33, classifyEffect } from "@hcmai/sdk";
|
|
23626
24202
|
|
|
23627
24203
|
// src/commands/delivery.ts
|
|
23628
24204
|
import { createHash as createHash9 } from "crypto";
|
|
@@ -23642,6 +24218,7 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
|
23642
24218
|
"record-create",
|
|
23643
24219
|
"record-update",
|
|
23644
24220
|
"cache-mutation",
|
|
24221
|
+
"subscription-migration-write",
|
|
23645
24222
|
"setting-write",
|
|
23646
24223
|
"credential-reset",
|
|
23647
24224
|
"action-write",
|
|
@@ -23795,6 +24372,7 @@ function classify(argv, actionResolution) {
|
|
|
23795
24372
|
if (name === "version") return direct("R0", "product-discovery", "product-discovery");
|
|
23796
24373
|
if (name === "open") return direct("R1", "remote-read", "browser-session-open");
|
|
23797
24374
|
if (name === "models") return direct("R0", "product-discovery", "model-discovery");
|
|
24375
|
+
if (name === "introspect") return direct("R0", "product-discovery", "introspection-index");
|
|
23798
24376
|
if (name === "llm") {
|
|
23799
24377
|
if (subcommand === "probe") return {
|
|
23800
24378
|
risk: "R2",
|
|
@@ -23929,6 +24507,11 @@ function classify(argv, actionResolution) {
|
|
|
23929
24507
|
if (name === "query" || name === "describe" || name === "trace") {
|
|
23930
24508
|
return direct("R1", "remote-read", "business-read");
|
|
23931
24509
|
}
|
|
24510
|
+
if (name === "preset-origin") return direct("R1", "remote-read", "preset-origin-read");
|
|
24511
|
+
if (name === "subscription-migration") {
|
|
24512
|
+
if (subcommand === "dry-run" || subcommand === "status") return direct("R1", "remote-read", "subscription-migration-read");
|
|
24513
|
+
if (subcommand === "apply" || subcommand === "restore") return guarded("tenant-config-write", "subscription-migration-write");
|
|
24514
|
+
}
|
|
23932
24515
|
if (name === "cache") {
|
|
23933
24516
|
if (subcommand === "stats") return direct("R1", "remote-read", "cache-read");
|
|
23934
24517
|
if (subcommand === "clear" || subcommand === "clear-meta") {
|
|
@@ -24041,7 +24624,7 @@ function summarizeTarget(argv, actionResolution) {
|
|
|
24041
24624
|
const name = argv[0] ?? "";
|
|
24042
24625
|
const subcommand = argv[1] ?? "";
|
|
24043
24626
|
const target = {};
|
|
24044
|
-
if (["query", "describe", "create", "update", "delete"].includes(name) && subcommand) {
|
|
24627
|
+
if (["query", "describe", "create", "update", "delete", "preset-origin"].includes(name) && subcommand) {
|
|
24045
24628
|
target.model = subcommand;
|
|
24046
24629
|
}
|
|
24047
24630
|
if (name === "action" && subcommand) {
|
|
@@ -24236,7 +24819,7 @@ async function resolveCoreAction(request) {
|
|
|
24236
24819
|
as: request.identity,
|
|
24237
24820
|
profile: request.profile
|
|
24238
24821
|
});
|
|
24239
|
-
const description = await
|
|
24822
|
+
const description = await HcmClient33.fromAuthContext(auth2).describe(request.model);
|
|
24240
24823
|
const named = description.actions.filter((action) => action.name === request.action);
|
|
24241
24824
|
if (named.length === 0) {
|
|
24242
24825
|
const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
|
|
@@ -24707,12 +25290,12 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
|
|
|
24707
25290
|
init_auth_guard();
|
|
24708
25291
|
init_exit();
|
|
24709
25292
|
import {
|
|
24710
|
-
HcmClient as
|
|
25293
|
+
HcmClient as HcmClient34,
|
|
24711
25294
|
ReconLayout,
|
|
24712
25295
|
ROUND_EXIT_CODES,
|
|
24713
25296
|
computeReconSourceKey,
|
|
24714
25297
|
formatObject as formatObject37,
|
|
24715
|
-
fromAxiosError as
|
|
25298
|
+
fromAxiosError as fromAxiosError32,
|
|
24716
25299
|
httpProbe as httpProbe3,
|
|
24717
25300
|
inspectRound,
|
|
24718
25301
|
renderRound,
|
|
@@ -24722,7 +25305,7 @@ var DEFAULT_CAPABILITIES = "default";
|
|
|
24722
25305
|
async function deliveryReconCommand(args) {
|
|
24723
25306
|
try {
|
|
24724
25307
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
24725
|
-
const client4 =
|
|
25308
|
+
const client4 = HcmClient34.fromAuthContext(ctx);
|
|
24726
25309
|
const probe3 = httpProbe3(client4.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
|
|
24727
25310
|
const sourceKey = await computeReconSourceKey(probe3);
|
|
24728
25311
|
const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
|
|
@@ -24734,7 +25317,7 @@ async function deliveryReconCommand(args) {
|
|
|
24734
25317
|
process.stdout.write(formatObject37(summary, { format: args.output ?? "json" }) + "\n");
|
|
24735
25318
|
} catch (e) {
|
|
24736
25319
|
const err = e;
|
|
24737
|
-
if (err?.isAxiosError) exitWithError(
|
|
25320
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError32(err, args.env));
|
|
24738
25321
|
exitWithError(e);
|
|
24739
25322
|
process.exit(1);
|
|
24740
25323
|
}
|
|
@@ -24765,7 +25348,7 @@ import {
|
|
|
24765
25348
|
DRY_RUN_TAIL,
|
|
24766
25349
|
DriftDetected,
|
|
24767
25350
|
FORCE_STALE_FLAG,
|
|
24768
|
-
HcmClient as
|
|
25351
|
+
HcmClient as HcmClient35,
|
|
24769
25352
|
fetchReconIdentity as fetchReconIdentity2,
|
|
24770
25353
|
INIT_EXIT_CODES,
|
|
24771
25354
|
JOURNAL_STOP_KINDS,
|
|
@@ -24905,7 +25488,7 @@ async function authOrSignpost(args, cmd) {
|
|
|
24905
25488
|
}
|
|
24906
25489
|
async function deliverySeedPlanCommand(args) {
|
|
24907
25490
|
const ctx = await authOrSignpost(args, "plan");
|
|
24908
|
-
const client4 =
|
|
25491
|
+
const client4 = HcmClient35.fromAuthContext(ctx);
|
|
24909
25492
|
process.exitCode = await runSeedPlan(args, seedClient(client4, ctx));
|
|
24910
25493
|
}
|
|
24911
25494
|
function seedClient(client4, ctx) {
|
|
@@ -25079,7 +25662,7 @@ async function runSeedApply(args, client4) {
|
|
|
25079
25662
|
}
|
|
25080
25663
|
async function deliverySeedApplyCommand(args) {
|
|
25081
25664
|
const ctx = await authOrSignpost(args, "apply");
|
|
25082
|
-
const client4 =
|
|
25665
|
+
const client4 = HcmClient35.fromAuthContext(ctx);
|
|
25083
25666
|
process.exitCode = await runSeedApply(args, seedClient(client4, ctx));
|
|
25084
25667
|
}
|
|
25085
25668
|
async function runSeedVerify(args, client4) {
|
|
@@ -25103,7 +25686,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
25103
25686
|
return;
|
|
25104
25687
|
}
|
|
25105
25688
|
const ctx = await authOrSignpost(args, "verify");
|
|
25106
|
-
const client4 =
|
|
25689
|
+
const client4 = HcmClient35.fromAuthContext(ctx);
|
|
25107
25690
|
process.exitCode = await runSeedVerify(args, await seedVerifyClient(client4, ctx));
|
|
25108
25691
|
}
|
|
25109
25692
|
|
|
@@ -25218,7 +25801,7 @@ import {
|
|
|
25218
25801
|
CHANGE_STATES,
|
|
25219
25802
|
CHANGE_UNKNOWN,
|
|
25220
25803
|
CODE_WORDS,
|
|
25221
|
-
HcmClient as
|
|
25804
|
+
HcmClient as HcmClient36,
|
|
25222
25805
|
INIT_EXIT_CODES as INIT_EXIT_CODES3,
|
|
25223
25806
|
META_WRITE_STEPS,
|
|
25224
25807
|
META_VERIFY_STEPS,
|
|
@@ -25446,7 +26029,7 @@ function lowerCaseHeaders2(headers) {
|
|
|
25446
26029
|
}
|
|
25447
26030
|
async function deliveryMetaCommand(args) {
|
|
25448
26031
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
25449
|
-
const client4 =
|
|
26032
|
+
const client4 = HcmClient36.fromAuthContext(ctx);
|
|
25450
26033
|
process.exitCode = await runDeliveryMeta(
|
|
25451
26034
|
{ ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
|
|
25452
26035
|
metaClient(client4, ctx)
|
|
@@ -25458,7 +26041,7 @@ init_auth_guard();
|
|
|
25458
26041
|
init_exit();
|
|
25459
26042
|
import {
|
|
25460
26043
|
computeReconSourceKey as computeReconSourceKey2,
|
|
25461
|
-
HcmClient as
|
|
26044
|
+
HcmClient as HcmClient37,
|
|
25462
26045
|
httpProbe as httpProbe4,
|
|
25463
26046
|
ReconLayout as ReconLayout2,
|
|
25464
26047
|
runTriageRound
|
|
@@ -25514,7 +26097,7 @@ async function runTriage(args) {
|
|
|
25514
26097
|
return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
|
|
25515
26098
|
}
|
|
25516
26099
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
25517
|
-
const client4 =
|
|
26100
|
+
const client4 = HcmClient37.fromAuthContext(ctx);
|
|
25518
26101
|
const probe3 = httpProbe4(client4.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
|
|
25519
26102
|
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe3)).dir;
|
|
25520
26103
|
const result = await runTriageRound(probe3, artifactsDir, entriesIn);
|
|
@@ -25543,10 +26126,10 @@ async function deliveryTriageCommand(args) {
|
|
|
25543
26126
|
init_auth_guard();
|
|
25544
26127
|
init_exit();
|
|
25545
26128
|
import {
|
|
25546
|
-
HcmClient as
|
|
26129
|
+
HcmClient as HcmClient38,
|
|
25547
26130
|
adminResetPassword,
|
|
25548
26131
|
formatObject as formatObject38,
|
|
25549
|
-
fromAxiosError as
|
|
26132
|
+
fromAxiosError as fromAxiosError33,
|
|
25550
26133
|
CliError as CliError53,
|
|
25551
26134
|
CliErrorCode as CliErrorCode52
|
|
25552
26135
|
} from "@hcmai/sdk";
|
|
@@ -25577,12 +26160,12 @@ async function userResetPasswordCommand(args) {
|
|
|
25577
26160
|
try {
|
|
25578
26161
|
const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
|
|
25579
26162
|
const request = buildAdminResetPasswordRequest(args, password);
|
|
25580
|
-
const client4 =
|
|
26163
|
+
const client4 = HcmClient38.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
25581
26164
|
const result = await adminResetPassword(client4.raw(), request);
|
|
25582
26165
|
process.stdout.write(formatObject38(result, { format: args.output ?? "json" }) + "\n");
|
|
25583
26166
|
} catch (cause) {
|
|
25584
26167
|
const err = cause;
|
|
25585
|
-
if (err?.isAxiosError) exitWithError(
|
|
26168
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError33(err, args.env));
|
|
25586
26169
|
exitWithError(cause);
|
|
25587
26170
|
}
|
|
25588
26171
|
}
|
|
@@ -25602,25 +26185,197 @@ async function promptPasswordTwice() {
|
|
|
25602
26185
|
init_exit();
|
|
25603
26186
|
init_auth_guard();
|
|
25604
26187
|
import {
|
|
25605
|
-
|
|
26188
|
+
CliError as CliError55,
|
|
26189
|
+
CliErrorCode as CliErrorCode54,
|
|
26190
|
+
HcmClient as HcmClient39,
|
|
26191
|
+
formatObject as formatObject40,
|
|
26192
|
+
fromAxiosError as fromAxiosError34
|
|
26193
|
+
} from "@hcmai/sdk";
|
|
26194
|
+
|
|
26195
|
+
// src/commands/models-search.ts
|
|
26196
|
+
import {
|
|
26197
|
+
CliError as CliError54,
|
|
26198
|
+
CliErrorCode as CliErrorCode53,
|
|
26199
|
+
MODEL_SEARCH_DEGRADED_COUNT_KEYS,
|
|
26200
|
+
MODEL_SEARCH_KEYS,
|
|
26201
|
+
MODEL_SEARCH_PATH,
|
|
26202
|
+
classifyEndpointFailure,
|
|
25606
26203
|
formatObject as formatObject39,
|
|
25607
|
-
|
|
26204
|
+
missingKeys as missingKeys2,
|
|
26205
|
+
searchModels
|
|
25608
26206
|
} from "@hcmai/sdk";
|
|
26207
|
+
var EVIDENCE_MAX_CHARS = 60;
|
|
26208
|
+
function clip(s) {
|
|
26209
|
+
const chars = [...s.replace(/\s+/g, " ")];
|
|
26210
|
+
return chars.length <= EVIDENCE_MAX_CHARS ? { text: chars.join(""), clipped: false } : { text: `${chars.slice(0, EVIDENCE_MAX_CHARS).join("")}\u2026`, clipped: true };
|
|
26211
|
+
}
|
|
26212
|
+
function num(view, key2, v) {
|
|
26213
|
+
return key2 in view ? String(v) : NOT_PROVIDED;
|
|
26214
|
+
}
|
|
26215
|
+
function renderDegraded(view) {
|
|
26216
|
+
if (!("degraded" in view) || !view.degraded || typeof view.degraded !== "object") {
|
|
26217
|
+
return [`\u964D\u7EA7\uFF1A${NOT_PROVIDED}\uFF08\u670D\u52A1\u7AEF\u6CA1\u8BF4\u6709\u6CA1\u6709\u6A21\u578B\u6CA1\u626B\u5168\u2014\u20140 \u547D\u4E2D\u65F6\u5C24\u5176\u4E0D\u80FD\u5F53\u300C\u67E5\u8FC7\u4E14\u4E3A\u7A7A\u300D\uFF09`];
|
|
26218
|
+
}
|
|
26219
|
+
const d = view.degraded;
|
|
26220
|
+
const missing2 = new Set(missingKeys2(d, MODEL_SEARCH_DEGRADED_COUNT_KEYS));
|
|
26221
|
+
const count = (k, v) => missing2.has(k) ? NOT_PROVIDED : String(v);
|
|
26222
|
+
const lines = [
|
|
26223
|
+
`\u964D\u7EA7\uFF08\u4E09\u4E2A\u6876\u90FD\u8981\u770B\uFF1B0 \u662F\u4E00\u6761\u80AF\u5B9A\u4FE1\u606F\uFF0C\u4E0D\u662F\u300C\u8FD9\u4E2A\u7AEF\u70B9\u4E0D\u62A5\u544A\u964D\u7EA7\u300D\uFF09\uFF1AnotScanned=${count("notScannedCount", d.notScannedCount)} \xB7 scanFailed=${count("scanFailedCount", d.scanFailedCount)} \xB7 metaUnavailable=${count("metaUnavailableCount", d.metaUnavailableCount)}`
|
|
26224
|
+
];
|
|
26225
|
+
const bucket = (label, n2, keys, what) => {
|
|
26226
|
+
if (!n2) return;
|
|
26227
|
+
const listed = keys?.length ?? 0;
|
|
26228
|
+
const tail = listed < n2 ? `\uFF08\u5217\u4E86 ${listed} \u4E2A\uFF0C\u5171 ${n2} \u4E2A\uFF09` : "";
|
|
26229
|
+
lines.push(` ${label}\uFF08${what}\uFF09\uFF1A${(keys ?? []).join("\u3001")}${tail}`);
|
|
26230
|
+
};
|
|
26231
|
+
bucket("notScanned", d.notScannedCount, d.notScannedModels, "\u8FDE\u5B9E\u4F8B\u90FD\u9020\u4E0D\u51FA\u6765\uFF0C\u516B\u7EF4\u4E00\u7EF4\u90FD\u6CA1\u8DD1");
|
|
26232
|
+
bucket("scanFailed", d.scanFailedCount, d.scanFailedModels, "\u626B\u63CF\u4E2D\u9014\u629B\u5F02\u5E38\uFF0C\u90A3\u534A\u4EFD\u4E5F\u88AB\u4E22\u5F03");
|
|
26233
|
+
bucket("metaUnavailable", d.metaUnavailableCount, d.metaUnavailableModels, "\u5408\u5E76\u5143\u6570\u636E\u6CA1\u8BFB\u5230\uFF0C\u4E94\u7EF4\u6CA1\u8DD1\uFF0C\u5DF2\u6709\u4E09\u7EF4\u53EA\u5F53\u5F31\u7EBF\u7D22");
|
|
26234
|
+
if (d.meaning) lines.push(` \u8BF4\u660E\uFF1A${rewriteSelfLinks(d.meaning)}`);
|
|
26235
|
+
return lines;
|
|
26236
|
+
}
|
|
26237
|
+
function renderModelSearch(keyword, view) {
|
|
26238
|
+
const total = view.totalCount;
|
|
26239
|
+
const scanned = view.scannedCount;
|
|
26240
|
+
const lines = [
|
|
26241
|
+
`\u68C0\u7D22\u300C${keyword}\u300D\uFF1A\u626B\u5B8C ${num(view, "scannedCount", scanned)} \u4E2A\u6A21\u578B\uFF0C\u547D\u4E2D ${num(view, "totalCount", total)} \u4E2A\uFF0C\u672C\u6B21\u8FD4\u56DE ${num(view, "returned", view.returned)} \u4E2A\uFF08\u751F\u6548 limit=${num(view, "effectiveLimit", view.effectiveLimit)}\uFF09\u3002`
|
|
26242
|
+
];
|
|
26243
|
+
if (view.limitNote) lines.push(`\u26A0\uFE0F limit \u88AB\u6539\u8FC7\uFF1A${rewriteSelfLinks(view.limitNote)}`);
|
|
26244
|
+
if (!("truncatedBy" in view)) {
|
|
26245
|
+
lines.push(`truncatedBy\uFF1A${NOT_PROVIDED}\uFF08\u670D\u52A1\u7AEF\u6CA1\u8BF4\u8FD9\u4EFD\u662F\u4E0D\u662F\u5168\u96C6\u2014\u2014\u522B\u5F53\u5168\u96C6\u7528\uFF09`);
|
|
26246
|
+
} else if (view.truncatedBy) {
|
|
26247
|
+
lines.push(`\u26A0\uFE0F \u672C\u54CD\u5E94\u4E0D\u662F\u5168\u96C6\uFF1A${rewriteSelfLinks(view.truncatedBy)}`);
|
|
26248
|
+
if (view.nextStep) lines.push(` \u4E0B\u4E00\u6B65\uFF1A${rewriteSelfLinks(view.nextStep)}`);
|
|
26249
|
+
}
|
|
26250
|
+
lines.push(`\u6392\u5E8F\uFF1A${"rankingNote" in view ? rewriteSelfLinks(view.rankingNote ?? "null") : NOT_PROVIDED}`);
|
|
26251
|
+
lines.push("");
|
|
26252
|
+
const hits = Array.isArray(view.models) ? view.models : void 0;
|
|
26253
|
+
let clipped = false;
|
|
26254
|
+
if (!hits) {
|
|
26255
|
+
lines.push(`\u5019\u9009\uFF1A${NOT_PROVIDED}`);
|
|
26256
|
+
} else if (hits.length === 0) {
|
|
26257
|
+
if (scanned === 0) {
|
|
26258
|
+
lines.push(
|
|
26259
|
+
"\u{1F534} \u8FD9\u4E00\u8F6E\u4E00\u4E2A\u6A21\u578B\u90FD\u6CA1\u626B\u5230\uFF08scannedCount=0\uFF09\u2014\u2014\u4E0D\u662F\u300C\u6CA1\u547D\u4E2D\u300D\uFF0C\u662F\u8FD9\u6B21\u68C0\u7D22\u6CA1\u6709\u5206\u6BCD\uFF1A\u670D\u52A1\u7AEF\u626B\u7684\u662F\u5168\u90E8\u6CE8\u518C\u6A21\u578B\u3001\u4E0D\u6309\u8EAB\u4EFD\u8FC7\u6EE4\uFF0C0 \u53EA\u4F1A\u662F\u5168\u90E8\u6A21\u578B\u90FD\u6CA1\u626B\u6210\uFF08\u770B\u4E0B\u9762\u7684\u964D\u7EA7\u6876\uFF09\u2014\u2014\u4E0E\u5F53\u524D\u8EAB\u4EFD\u65E0\u5173\uFF0C\u6362\u8EAB\u4EFD\u6CA1\u7528\u3002",
|
|
26260
|
+
" \u4E0B\u4E00\u6B65\uFF1A\u8FD9\u662F\u670D\u52A1\u7AEF\u626B\u63CF\u9762\u7684\u95EE\u9898\uFF0C\u8BF7\u7BA1\u7406\u5458\u67E5\u540E\u7AEF\u65E5\u5FD7\uFF0C\u6216\u8DD1 `hcm chiron doctor` \u770B\u5E73\u53F0\u5C42\uFF1B\u5728\u90A3\u4E4B\u524D\u8FD9\u6B21\u68C0\u7D22\u7684\u7ED3\u8BBA\u662F\u300C\u4E0D\u77E5\u9053\u300D\uFF0C\u4E0D\u662F\u300C\u6CA1\u6709\u300D\u3002"
|
|
26261
|
+
);
|
|
26262
|
+
} else {
|
|
26263
|
+
lines.push(
|
|
26264
|
+
`\u67E5\u8FC7\u4E14\u4E3A\u7A7A\uFF1A\u626B\u5B8C ${num(view, "scannedCount", scanned)} \u4E2A\u6A21\u578B\uFF0C\u300C${keyword}\u300D\u4E00\u4E2A\u90FD\u6CA1\u547D\u4E2D\u3002`,
|
|
26265
|
+
" \u26A0\uFE0F score \u662F\u8BCD\u6CD5\u5339\u914D\u4E0D\u662F\u8BED\u4E49\u76F8\u4F3C\u5EA6\uFF1A\u540C\u4E49\u8BF4\u6CD5\u6CA1\u767B\u8BB0\u6210 synonyms \u65F6\u4E5F\u662F 0\uFF0C\u8FD9\u548C\u300C\u4EA7\u54C1\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B\u300D\u540C\u5F62\u3002",
|
|
26266
|
+
` \u4E0B\u4E00\u6B65\uFF1A\u6362\u66F4\u63A5\u8FD1\u5B57\u6BB5\u6807\u7B7E / \u6A21\u578B\u540D\u7684\u8BCD\u518D\u641C\uFF1B\u4ECD\u4E3A 0 \u7528 \`hcm models\` \u62C9\u5168\u540D\u518C\u4EBA\u5DE5\u770B\u2014\u2014\u522B\u636E\u6B64\u5224\u300C\u4EA7\u54C1\u6CA1\u6709\u8FD9\u4E2A\u80FD\u529B\u300D\u3002`
|
|
26267
|
+
);
|
|
26268
|
+
}
|
|
26269
|
+
} else {
|
|
26270
|
+
hits.forEach((h, i) => {
|
|
26271
|
+
const tied = typeof h.tiedWith === "number" ? h.tiedWith > 0 ? `\u4E0E\u53E6\u5916 ${h.tiedWith} \u4E2A\u540C\u5206` : "\u5206\u6570\u552F\u4E00" : `\u540C\u5206\u60C5\u51B5 ${NOT_PROVIDED}`;
|
|
26272
|
+
const assurance = h._evidence?.assurance ? ` assurance=${h._evidence.assurance}` : "";
|
|
26273
|
+
const name = h.name && h.name !== h.modelKey ? `\uFF08${h.name}\uFF09` : "";
|
|
26274
|
+
lines.push(`${i + 1}. ${h.modelKey ?? "?"}${name} score=${h.score ?? NOT_PROVIDED} ${tied}${assurance}`);
|
|
26275
|
+
if (!Array.isArray(h.matchedOn)) {
|
|
26276
|
+
lines.push(` \u547D\u4E2D\u8BC1\u636E\uFF1A${NOT_PROVIDED}`);
|
|
26277
|
+
return;
|
|
26278
|
+
}
|
|
26279
|
+
for (const m of h.matchedOn) {
|
|
26280
|
+
const ev = m.evidence ? clip(m.evidence) : void 0;
|
|
26281
|
+
if (ev?.clipped) clipped = true;
|
|
26282
|
+
lines.push(` ${m.dimension ?? "?"} ${m.weight ?? "?"}${ev ? ` \u300C${ev.text}\u300D` : ""}${m.reason ? ` ${m.reason}` : ""}`);
|
|
26283
|
+
}
|
|
26284
|
+
if (h._evidence?.assurance && h._evidence.assurance !== "STRUCTURAL" && h._evidence.source) {
|
|
26285
|
+
lines.push(` \u26A0\uFE0F ${h._evidence.source}`);
|
|
26286
|
+
}
|
|
26287
|
+
});
|
|
26288
|
+
}
|
|
26289
|
+
lines.push("", ...renderDegraded(view));
|
|
26290
|
+
if (clipped) lines.push(`\u2139\uFE0F \u547D\u4E2D\u539F\u6587\u8D85\u8FC7 ${EVIDENCE_MAX_CHARS} \u5B57\u7684\u5DF2\u622A\u65AD\uFF08\u2026\uFF09\uFF0C\u5168\u6587\u52A0 --output json`);
|
|
26291
|
+
lines.push(
|
|
26292
|
+
"\u2139\uFE0F \u53E3\u5F84\uFF1A\u5143\u6570\u636E\u9762\uFF0C\u4E0D\u5224\u6388\u6743\u2014\u2014\u547D\u4E2D\u4E0D\u4EE3\u8868\u4F60\u80FD\u8BFB\u5B83\u7684\u6570\u636E\uFF0C0 \u547D\u4E2D\u4E5F\u4E0D\u662F\u88AB\u89D2\u8272\u88C1\u6389\u3002",
|
|
26293
|
+
"\u4E0B\u4E00\u6B65\uFF1A`hcm describe <Model>` \u770B\u5B57\u6BB5\u3001\u52A8\u4F5C\u4E0E\u901A\u7528\u589E\u5220\u6539\uFF1B`hcm chiron seed find --tenant <\u79DF\u6237> <\u8BF4\u6CD5>` \u843D\u5230 \u6A21\u578B.\u5B57\u6BB5"
|
|
26294
|
+
);
|
|
26295
|
+
return markRestLeftovers(lines).join("\n");
|
|
26296
|
+
}
|
|
26297
|
+
var NOT_PROVIDED_NEXT_STEP = "\u8FD9\u4E2A\u540E\u7AEF\u6CA1\u6709\u6309\u8BF4\u6CD5\u68C0\u7D22\u7684\u7AEF\u70B9\uFF08Core 2026-09-03 \u8D77\u624D\u6709\uFF0C#1989\uFF09\uFF1A\u7528 `hcm version` \u770B\u540E\u7AEF\u7248\u672C\uFF1B\u8FD9\u4E00\u7248\u53EA\u80FD\u9000\u56DE\u540D\u518C\u5185\u5B57\u7B26\u4E32\u5339\u914D `hcm models <\u5173\u952E\u5B57>`\uFF08\u4E0D\u5E26 --search\uFF0C\u4E0D\u6392\u5E8F\u3001\u4E0D\u7ED9\u547D\u4E2D\u8BC1\u636E\uFF09";
|
|
26298
|
+
function parseSearchArgs(keyword, args) {
|
|
26299
|
+
const kw = keyword?.trim();
|
|
26300
|
+
if (!kw) {
|
|
26301
|
+
throw new CliError54({
|
|
26302
|
+
code: CliErrorCode53.MISSING_FLAG,
|
|
26303
|
+
message: "--search \u8981\u5E26\u4E00\u4E2A\u8BF4\u6CD5\uFF1Ahcm models <\u8BF4\u6CD5> --search",
|
|
26304
|
+
context: { nextStep: "\u4F8B\u5982 `hcm models \u5DE5\u53F7 --search`\uFF1B\u53EA\u60F3\u770B\u5168\u90E8\u6A21\u578B\u540D\u518C\u53BB\u6389 --search" }
|
|
26305
|
+
});
|
|
26306
|
+
}
|
|
26307
|
+
let limit;
|
|
26308
|
+
if (args.limit !== void 0) {
|
|
26309
|
+
limit = Number(args.limit);
|
|
26310
|
+
if (!Number.isInteger(limit) || limit < 1) {
|
|
26311
|
+
throw new CliError54({
|
|
26312
|
+
code: CliErrorCode53.INVALID_ARGUMENT,
|
|
26313
|
+
message: `--limit \u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF0C\u6536\u5230 ${JSON.stringify(args.limit)}`,
|
|
26314
|
+
context: { nextStep: "\u53BB\u6389 --limit \u7528\u670D\u52A1\u7AEF\u9ED8\u8BA4\uFF0810\uFF09\uFF1B\u8D8A\u754C\u65F6\u670D\u52A1\u7AEF\u6536\u655B\u5230 [1, 100] \u5E76\u5728 limitNote \u91CC\u8BF4" }
|
|
26315
|
+
});
|
|
26316
|
+
}
|
|
26317
|
+
}
|
|
26318
|
+
return { kw, ...limit !== void 0 ? { limit } : {} };
|
|
26319
|
+
}
|
|
26320
|
+
async function modelsSearch(client4, parsed, args) {
|
|
26321
|
+
const { kw, limit } = parsed;
|
|
26322
|
+
let view;
|
|
26323
|
+
try {
|
|
26324
|
+
view = await searchModels(client4.raw(), kw, limit);
|
|
26325
|
+
} catch (e) {
|
|
26326
|
+
if (e?.isAxiosError && classifyEndpointFailure(e, { modelScoped: false }).kind === "not-provided") {
|
|
26327
|
+
const f = classifyEndpointFailure(e, { modelScoped: false });
|
|
26328
|
+
throw new CliError54({
|
|
26329
|
+
code: CliErrorCode53.PROTOCOL_UNSUPPORTED,
|
|
26330
|
+
message: `${NOT_PROVIDED}\uFF1AGET ${MODEL_SEARCH_PATH} \u2192 ${f.detail}`,
|
|
26331
|
+
context: { nextStep: NOT_PROVIDED_NEXT_STEP }
|
|
26332
|
+
});
|
|
26333
|
+
}
|
|
26334
|
+
throw e;
|
|
26335
|
+
}
|
|
26336
|
+
const fmt = args.output ?? "table";
|
|
26337
|
+
if (fmt !== "table") {
|
|
26338
|
+
const notProvided = missingKeys2(view, MODEL_SEARCH_KEYS);
|
|
26339
|
+
const out = {
|
|
26340
|
+
...view,
|
|
26341
|
+
...view.nextStep ? { cliNextStep: rewriteSelfLinks(view.nextStep) } : {},
|
|
26342
|
+
...notProvided.length ? { notProvided } : {}
|
|
26343
|
+
};
|
|
26344
|
+
process.stdout.write(formatObject39(out, { format: fmt }) + "\n");
|
|
26345
|
+
} else {
|
|
26346
|
+
process.stdout.write(renderModelSearch(kw, view) + "\n");
|
|
26347
|
+
}
|
|
26348
|
+
process.exitCode = 0;
|
|
26349
|
+
}
|
|
26350
|
+
|
|
26351
|
+
// src/commands/models.ts
|
|
25609
26352
|
async function modelsCommand(keyword, args) {
|
|
25610
26353
|
try {
|
|
25611
|
-
|
|
26354
|
+
if (args.limit !== void 0 && !args.search) {
|
|
26355
|
+
throw new CliError55({
|
|
26356
|
+
code: CliErrorCode54.INVALID_ARGUMENT,
|
|
26357
|
+
message: "--limit \u53EA\u914D\u5408 --search \u7528\uFF08\u540D\u518C\u5217\u8868\u672C\u6765\u5C31\u662F\u5168\u96C6\uFF0C\u4E0D\u622A\u65AD\uFF09",
|
|
26358
|
+
context: { nextStep: "\u8981\u6309\u8BF4\u6CD5\u68C0\u7D22\u5E76\u9650\u6761\u6570\uFF1A`hcm models <\u8BF4\u6CD5> --search --limit <n>`" }
|
|
26359
|
+
});
|
|
26360
|
+
}
|
|
26361
|
+
const parsedSearch = args.search ? parseSearchArgs(keyword, args) : void 0;
|
|
26362
|
+
const client4 = HcmClient39.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
26363
|
+
if (parsedSearch) {
|
|
26364
|
+
await modelsSearch(client4, parsedSearch, args);
|
|
26365
|
+
return;
|
|
26366
|
+
}
|
|
25612
26367
|
const all = await client4.listModels();
|
|
25613
26368
|
const needle = keyword?.trim().toLowerCase();
|
|
25614
26369
|
const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
|
|
25615
26370
|
const fmt = args.output ?? "table";
|
|
25616
26371
|
if (fmt !== "table") {
|
|
25617
|
-
process.stdout.write(
|
|
26372
|
+
process.stdout.write(formatObject40({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
|
|
25618
26373
|
process.exitCode = 0;
|
|
25619
26374
|
return;
|
|
25620
26375
|
}
|
|
25621
26376
|
if (rows2.length === 0) {
|
|
25622
26377
|
process.stdout.write(
|
|
25623
|
-
needle ? `\u6CA1\u6709\
|
|
26378
|
+
needle ? `\u540D\u518C\u91CC\u6CA1\u6709\u5B57\u9762\u5305\u542B "${keyword}" \u7684 Model\uFF08\u5171 ${all.length} \u4E2A\u53EF\u89C1\uFF09\uFF1B\u6309\u8BF4\u6CD5\u68C0\u7D22\uFF08\u540C\u4E49\u8BCD / \u5B57\u6BB5\u6807\u7B7E / \u7528\u9014\u4E5F\u641C\uFF0C\u5E26\u547D\u4E2D\u8BC1\u636E\uFF09\u7528 \`hcm models <\u8BF4\u6CD5> --search\`\u3002
|
|
25624
26379
|
` : "\u5F53\u524D\u8EAB\u4EFD\u5728\u8FD9\u4E2A\u73AF\u5883\u770B\u4E0D\u5230\u4EFB\u4F55 Model\u3002\n"
|
|
25625
26380
|
);
|
|
25626
26381
|
process.exitCode = 0;
|
|
@@ -25636,12 +26391,12 @@ async function modelsCommand(keyword, args) {
|
|
|
25636
26391
|
process.stdout.write(`
|
|
25637
26392
|
\u5171 ${rows2.length} \u4E2A${needle ? `\uFF08\u5168\u90E8 ${all.length} \u4E2A\u4E2D\u5339\u914D\uFF09` : ""}\u3002
|
|
25638
26393
|
`);
|
|
25639
|
-
process.stdout.write("\u4E0B\u4E00\u6B65\uFF1Ahcm describe <Model> \u770B\u5B57\u6BB5\u3001\u5173\u7CFB\u4E0E Action\u3002\n");
|
|
26394
|
+
process.stdout.write("\u4E0B\u4E00\u6B65\uFF1Ahcm describe <Model> \u770B\u5B57\u6BB5\u3001\u5173\u7CFB\u4E0E Action\uFF1B\u6309\u5BA2\u6237\u8BF4\u6CD5\u627E\u3001\u8981\u547D\u4E2D\u8BC1\u636E\u7528 `hcm models <\u8BF4\u6CD5> --search`\u3002\n");
|
|
25640
26395
|
process.exitCode = 0;
|
|
25641
26396
|
return;
|
|
25642
26397
|
} catch (e) {
|
|
25643
26398
|
const err = e;
|
|
25644
|
-
if (err?.isAxiosError) exitWithError(
|
|
26399
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError34(err, args.env ?? args.profile));
|
|
25645
26400
|
exitWithError(e);
|
|
25646
26401
|
}
|
|
25647
26402
|
}
|
|
@@ -25649,6 +26404,343 @@ function key(m) {
|
|
|
25649
26404
|
return typeof m.modelKey === "string" && m.modelKey ? m.modelKey : "(\u672A\u547D\u540D)";
|
|
25650
26405
|
}
|
|
25651
26406
|
|
|
26407
|
+
// src/commands/introspect.ts
|
|
26408
|
+
init_exit();
|
|
26409
|
+
init_auth_guard();
|
|
26410
|
+
import {
|
|
26411
|
+
HcmClient as HcmClient40,
|
|
26412
|
+
CliError as CliError56,
|
|
26413
|
+
CliErrorCode as CliErrorCode55,
|
|
26414
|
+
INTROSPECTION_ENVELOPE_KEYS,
|
|
26415
|
+
INTROSPECTION_PATH,
|
|
26416
|
+
classifyEndpointFailure as classifyEndpointFailure2,
|
|
26417
|
+
fetchIntrospection,
|
|
26418
|
+
formatObject as formatObject41,
|
|
26419
|
+
fromAxiosError as fromAxiosError35,
|
|
26420
|
+
missingKeys as missingKeys3
|
|
26421
|
+
} from "@hcmai/sdk";
|
|
26422
|
+
function parseLimit2(raw) {
|
|
26423
|
+
if (raw === void 0) return void 0;
|
|
26424
|
+
const n2 = Number(raw);
|
|
26425
|
+
if (!Number.isInteger(n2) || n2 < 1) {
|
|
26426
|
+
throw new CliError56({
|
|
26427
|
+
code: CliErrorCode55.INVALID_ARGUMENT,
|
|
26428
|
+
message: `--limit \u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF0C\u6536\u5230 ${JSON.stringify(raw)}`,
|
|
26429
|
+
context: { nextStep: "\u53BB\u6389 --limit \u7528\u670D\u52A1\u7AEF\u9ED8\u8BA4\u6863\uFF1B\u8D8A\u754C\u65F6\u670D\u52A1\u7AEF\u4F1A\u6536\u655B\u5230\u8FB9\u754C\u5E76\u5728 truncatedBy \u91CC\u8BF4\u51FA\u5B9E\u9645\u751F\u6548\u7684\u503C" }
|
|
26430
|
+
});
|
|
26431
|
+
}
|
|
26432
|
+
return n2;
|
|
26433
|
+
}
|
|
26434
|
+
function cliCell(c2) {
|
|
26435
|
+
return cliCommandForCapability(c2.method, c2.path) ?? CLI_NOT_PROVIDED;
|
|
26436
|
+
}
|
|
26437
|
+
function renderEnvelope(view, layer2) {
|
|
26438
|
+
const missing2 = new Set(missingKeys3(view, INTROSPECTION_ENVELOPE_KEYS));
|
|
26439
|
+
const show = (k, v) => missing2.has(k) ? NOT_PROVIDED : v === null ? "null" : String(v);
|
|
26440
|
+
const lines = [
|
|
26441
|
+
`\u81EA\u7701\u9762\u5165\u53E3\u7D22\u5F15\uFF08${layer2}\uFF09\uFF1A\u5171 ${show("totalCount", view.totalCount)} \u683C\uFF0C\u672C\u6B21\u8FD4\u56DE ${show("returnedCount", view.returnedCount)} \u683C\u3002`
|
|
26442
|
+
];
|
|
26443
|
+
if (missing2.has("truncatedBy")) {
|
|
26444
|
+
lines.push(`truncatedBy\uFF1A${NOT_PROVIDED}\uFF08\u670D\u52A1\u7AEF\u6CA1\u8BF4\u8FD9\u4EFD\u662F\u4E0D\u662F\u5168\u96C6\u2014\u2014\u522B\u628A\u5B83\u5F53\u5168\u96C6\u7528\uFF09`);
|
|
26445
|
+
} else if (view.truncatedBy) {
|
|
26446
|
+
lines.push(`\u26A0\uFE0F truncatedBy\uFF1A${rewriteSelfLinks(view.truncatedBy)}`);
|
|
26447
|
+
} else {
|
|
26448
|
+
lines.push("truncatedBy\uFF1Anull\uFF08\u6CA1\u6709\u6309 limit \u622A\u65AD\uFF09");
|
|
26449
|
+
}
|
|
26450
|
+
if (missing2.has("nextStep")) lines.push(`nextStep\uFF1A${NOT_PROVIDED}`);
|
|
26451
|
+
else if (view.nextStep) lines.push(`nextStep\uFF1A${rewriteSelfLinks(view.nextStep)}`);
|
|
26452
|
+
if (missing2.has("detailWith")) lines.push(`detailWith\uFF1A${NOT_PROVIDED}`);
|
|
26453
|
+
else if (view.detailWith) lines.push(`detailWith\uFF1A${rewriteSelfLinks(view.detailWith)}`);
|
|
26454
|
+
if ([view.detailWith, view.nextStep, view.truncatedBy].some((t) => typeof t === "string" && t.includes("urlencode"))) {
|
|
26455
|
+
lines.push("\u2139\uFE0F \u670D\u52A1\u7AEF\u539F\u6587\u91CC\u300C\u5FC5\u987B urlencode\u300D\u8BF4\u7684\u662F REST \u5199\u6CD5\uFF1B\u4E0A\u9762\u6362\u597D\u7684 hcm \u547D\u4EE4\u81EA\u5DF1\u7F16\u7801\uFF0Cpath \u7167\u539F\u6837\uFF08\u4E0D\u7F16\u7801\uFF09\u6284");
|
|
26456
|
+
}
|
|
26457
|
+
return lines;
|
|
26458
|
+
}
|
|
26459
|
+
function renderSummary(view) {
|
|
26460
|
+
const caps = view.capabilities ?? [];
|
|
26461
|
+
const lines = renderEnvelope(view, "\u6458\u8981\u5C42");
|
|
26462
|
+
lines.push("");
|
|
26463
|
+
if (!Array.isArray(view.capabilities)) {
|
|
26464
|
+
lines.push(`capabilities\uFF1A${NOT_PROVIDED}`);
|
|
26465
|
+
return lines.join("\n");
|
|
26466
|
+
}
|
|
26467
|
+
for (const c2 of caps) {
|
|
26468
|
+
const blind = typeof c2.blindSpotCount === "number" ? `\u76F2\u533A ${c2.blindSpotCount}` : `\u76F2\u533A ${NOT_PROVIDED}`;
|
|
26469
|
+
lines.push(`${c2.method ?? "?"} ${c2.path ?? "?"} \xB7 ${c2.assurance ?? `assurance ${NOT_PROVIDED}`} \xB7 ${blind}`);
|
|
26470
|
+
if (c2.what) lines.push(` ${rewriteSelfLinks(c2.what)}`);
|
|
26471
|
+
lines.push(` CLI\uFF1A${cliCell(c2)}`);
|
|
26472
|
+
}
|
|
26473
|
+
lines.push(
|
|
26474
|
+
"",
|
|
26475
|
+
"\u2139\uFE0F \u67D0\u4E00\u683C\u7684\u660E\u7EC6\uFF08what \u5168\u6587\u3001\u76F2\u533A\u660E\u7EC6\u3001\u5165\u53C2\u81EA\u8FF0\uFF09\uFF1A`hcm introspect <path>`\uFF0Cpath \u7167\u4E0A\u9762\u539F\u6837\u6284\uFF08\u542B {model} \u8FD9\u7C7B\u6A21\u677F\u6BB5\uFF09",
|
|
26476
|
+
`\u2139\uFE0F \u300C${CLI_NOT_PROVIDED}\u300D= \u8FD9\u4E00\u683C\u4ECA\u5929\u53EA\u80FD\u7ECF REST \u53D6\uFF1B\u5B88\u4EA4\u4ED8\u8FB9\u754C\u65F6\u5230\u8FD9\u91CC\u505C\u4E0B\uFF0C\u8BF7\u6709\u6743\u9650\u7684\u4EBA\u505A\uFF0C\u522B\u6539\u7528 curl`
|
|
26477
|
+
);
|
|
26478
|
+
return markRestLeftovers(lines, isCapabilityHeader).join("\n");
|
|
26479
|
+
}
|
|
26480
|
+
function renderCapabilityDetail(c2, route) {
|
|
26481
|
+
const lines = [`${c2.method ?? "?"} ${c2.path ?? "?"}`, ` CLI\uFF1A${cliCell(c2)}`];
|
|
26482
|
+
lines.push(` what\uFF1A${c2.what ? rewriteSelfLinks(c2.what) : NOT_PROVIDED}`);
|
|
26483
|
+
lines.push(` assurance\uFF1A${c2.assurance ?? NOT_PROVIDED}`);
|
|
26484
|
+
if (c2._evidence) lines.push(` _evidence\uFF1Aorigin=${c2._evidence.origin ?? "?"} source=${c2._evidence.source ?? "?"}`);
|
|
26485
|
+
if (c2.guardedBy !== void 0) lines.push(` guardedBy\uFF1A${c2.guardedBy}`);
|
|
26486
|
+
if (c2.probedBy?.length) lines.push(` probedBy\uFF1A${c2.probedBy.join("\u3001")}`);
|
|
26487
|
+
if (route?.aliases?.length) lines.push(` \u522B\u540D\uFF1A${route.aliases.join("\u3001")}`);
|
|
26488
|
+
if (Array.isArray(c2.blindSpots)) {
|
|
26489
|
+
lines.push(` \u76F2\u533A\uFF08${c2.blindSpots.length}\uFF09\uFF1A`);
|
|
26490
|
+
for (const b of c2.blindSpots) {
|
|
26491
|
+
lines.push(` \xB7 \u7B54\u4E0D\u4E86\uFF1A${b.unknown ?? b.title ?? NOT_PROVIDED}`);
|
|
26492
|
+
if (b.remedy) lines.push(` \u600E\u4E48\u529E\uFF1A${rewriteSelfLinks(b.remedy)}`);
|
|
26493
|
+
}
|
|
26494
|
+
} else if (typeof c2.blindSpotCount === "number") {
|
|
26495
|
+
lines.push(` \u76F2\u533A\uFF1A${c2.blindSpotCount} \u6761\uFF08\u8FD9\u4E00\u5C42\u4E0D\u7ED9\u660E\u7EC6\uFF09`);
|
|
26496
|
+
}
|
|
26497
|
+
if (Array.isArray(c2.params)) {
|
|
26498
|
+
lines.push(` \u5165\u53C2\uFF08${c2.params.length}\uFF09\uFF1A`);
|
|
26499
|
+
for (const p of c2.params) {
|
|
26500
|
+
const dflt = p.defaultValue === null || p.defaultValue === void 0 ? "" : ` \u9ED8\u8BA4 ${typeof p.defaultValue === "string" && p.defaultValue === "" ? '""\uFF08\u7A7A\u4E32\uFF09' : String(p.defaultValue)}`;
|
|
26501
|
+
lines.push(` \xB7 ${p.name ?? "?"}\uFF08${p.in ?? "?"}${p.required ? "\uFF0C\u5FC5\u586B" : ""}${dflt}\uFF09${p.what ? `\uFF1A${rewriteSelfLinks(p.what)}` : ""}`);
|
|
26502
|
+
}
|
|
26503
|
+
}
|
|
26504
|
+
return lines;
|
|
26505
|
+
}
|
|
26506
|
+
function renderDetail(view, layer2) {
|
|
26507
|
+
const lines = renderEnvelope(view, layer2);
|
|
26508
|
+
if (!Array.isArray(view.capabilities)) {
|
|
26509
|
+
lines.push("", `capabilities\uFF1A${NOT_PROVIDED}`);
|
|
26510
|
+
return lines.join("\n");
|
|
26511
|
+
}
|
|
26512
|
+
if (!Array.isArray(view.routes)) lines.push(`routes\uFF08\u5404\u683C\u7684\u522B\u540D\uFF09\uFF1A${NOT_PROVIDED}`);
|
|
26513
|
+
const routes = Array.isArray(view.routes) ? view.routes : [];
|
|
26514
|
+
for (const c2 of view.capabilities) {
|
|
26515
|
+
const route = routes.find((r) => r.path === c2.path && r.method === c2.method);
|
|
26516
|
+
lines.push("", ...renderCapabilityDetail(c2, route));
|
|
26517
|
+
}
|
|
26518
|
+
return markRestLeftovers(lines, isCapabilityHeader).join("\n");
|
|
26519
|
+
}
|
|
26520
|
+
function jsonView(view) {
|
|
26521
|
+
const notProvided = missingKeys3(view, [...INTROSPECTION_ENVELOPE_KEYS, "capabilities"]);
|
|
26522
|
+
return {
|
|
26523
|
+
...view,
|
|
26524
|
+
...Array.isArray(view.capabilities) ? {
|
|
26525
|
+
capabilities: view.capabilities.map((c2) => ({
|
|
26526
|
+
...c2,
|
|
26527
|
+
cliCommand: cliCommandForCapability(c2.method, c2.path)?.replace(/^`([^`]+)`.*$/, "$1") ?? null
|
|
26528
|
+
}))
|
|
26529
|
+
} : {},
|
|
26530
|
+
cliNextStep: view.nextStep ? rewriteSelfLinks(view.nextStep) : null,
|
|
26531
|
+
cliDetailWith: view.detailWith ? rewriteSelfLinks(view.detailWith) : null,
|
|
26532
|
+
...notProvided.length ? { notProvided } : {}
|
|
26533
|
+
};
|
|
26534
|
+
}
|
|
26535
|
+
var NOT_PROVIDED_NEXT_STEP2 = "\u8FD9\u4E2A\u540E\u7AEF\u6CA1\u6709\u81EA\u7701\u5165\u53E3\u7D22\u5F15\uFF08Core 2026-09-03 \u8D77\u624D\u6709\uFF0C#1879 / ADR-332\uFF09\uFF1A\u7528 `hcm version` \u770B\u540E\u7AEF\u7248\u672C\uFF1B\u8FD9\u4E00\u7248\u53EA\u80FD\u9760 `hcm models` / `hcm describe <Model>` \u9010\u4E2A\u95EE";
|
|
26536
|
+
function handleError(e, args, capability) {
|
|
26537
|
+
const err = e;
|
|
26538
|
+
if (!err?.isAxiosError) exitWithError(e);
|
|
26539
|
+
const f = classifyEndpointFailure2(e, { modelScoped: false });
|
|
26540
|
+
if (f.kind === "not-provided") {
|
|
26541
|
+
exitWithError(new CliError56({
|
|
26542
|
+
code: CliErrorCode55.PROTOCOL_UNSUPPORTED,
|
|
26543
|
+
message: `${NOT_PROVIDED}\uFF1AGET ${INTROSPECTION_PATH} \u2192 ${f.detail}`,
|
|
26544
|
+
context: { nextStep: NOT_PROVIDED_NEXT_STEP2 }
|
|
26545
|
+
}));
|
|
26546
|
+
}
|
|
26547
|
+
const ce = fromAxiosError35(err, args.env);
|
|
26548
|
+
const body = err.response?.data?.error;
|
|
26549
|
+
if (capability !== void 0 && body?.code === "INTROSPECTION_PATH_NOT_FOUND") {
|
|
26550
|
+
const available = body?.details?.availablePaths;
|
|
26551
|
+
const list = Array.isArray(available) ? [...new Set(available.map(String))] : [];
|
|
26552
|
+
exitWithError(new CliError56({
|
|
26553
|
+
code: ce.code,
|
|
26554
|
+
message: `\u81EA\u7701\u7D22\u5F15\u91CC\u6CA1\u6709 ${capability} \u8FD9\u4E00\u683C`,
|
|
26555
|
+
context: {
|
|
26556
|
+
nextStep: list.length ? `\u7167\u539F\u6837\u4ECE\u8FD9 ${list.length} \u4E2A\u91CC\u9009\u4E00\u4E2A\u518D\u8DD1 \`hcm introspect <path>\`\uFF1A${list.join("\u3001")}` : "\u5148\u8DD1 `hcm introspect` \u62FF\u5168\u96C6\uFF0C\u7167 capabilities \u7684 path \u539F\u6837\u6284"
|
|
26557
|
+
},
|
|
26558
|
+
traceId: ce.traceId
|
|
26559
|
+
}));
|
|
26560
|
+
}
|
|
26561
|
+
exitWithError(ce);
|
|
26562
|
+
}
|
|
26563
|
+
async function introspectCommand(capability, args) {
|
|
26564
|
+
try {
|
|
26565
|
+
const limit = parseLimit2(args.limit);
|
|
26566
|
+
if (capability !== void 0 && !capability.trim()) {
|
|
26567
|
+
throw new CliError56({
|
|
26568
|
+
code: CliErrorCode55.INVALID_ARGUMENT,
|
|
26569
|
+
message: "capability \u4E0D\u80FD\u662F\u7A7A\u4E32",
|
|
26570
|
+
context: { nextStep: "\u4E0D\u5E26\u53C2\u6570\u8DD1 `hcm introspect` \u770B\u5168\u96C6\uFF1B\u8981\u4E00\u683C\u5C31\u7167\u5B83\u7ED9\u7684 path \u539F\u6837\u6284" }
|
|
26571
|
+
});
|
|
26572
|
+
}
|
|
26573
|
+
if (capability !== void 0 && (args.detail || limit !== void 0)) {
|
|
26574
|
+
process.stderr.write("\u2139\uFE0F \u7ED9\u4E86 capability \u65F6\u53EA\u53D6\u90A3\u4E00\u683C\uFF08\u672C\u6765\u5C31\u662F\u660E\u7EC6\u5F62\u6001\uFF09\uFF0C--detail / --limit \u4E0D\u751F\u6548\n");
|
|
26575
|
+
}
|
|
26576
|
+
const client4 = HcmClient40.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
26577
|
+
const view = await fetchIntrospection(client4.raw(), {
|
|
26578
|
+
...capability !== void 0 ? { path: capability } : {},
|
|
26579
|
+
...args.detail ? { detail: true } : {},
|
|
26580
|
+
...limit !== void 0 ? { limit } : {}
|
|
26581
|
+
});
|
|
26582
|
+
const fmt = args.output ?? "table";
|
|
26583
|
+
if (fmt !== "table") {
|
|
26584
|
+
process.stdout.write(formatObject41(jsonView(view), { format: fmt }) + "\n");
|
|
26585
|
+
} else if (capability !== void 0) {
|
|
26586
|
+
process.stdout.write(renderDetail(view, `\u5355\u683C ${shellArg(capability)}`) + "\n");
|
|
26587
|
+
} else if (args.detail) {
|
|
26588
|
+
process.stdout.write(renderDetail(view, "\u5168\u91CF\u660E\u7EC6\u5C42") + "\n");
|
|
26589
|
+
} else {
|
|
26590
|
+
process.stdout.write(renderSummary(view) + "\n");
|
|
26591
|
+
}
|
|
26592
|
+
process.exitCode = 0;
|
|
26593
|
+
} catch (e) {
|
|
26594
|
+
handleError(e, args, capability);
|
|
26595
|
+
}
|
|
26596
|
+
}
|
|
26597
|
+
|
|
26598
|
+
// src/commands/preset-origin.ts
|
|
26599
|
+
init_exit();
|
|
26600
|
+
init_auth_guard();
|
|
26601
|
+
import {
|
|
26602
|
+
HcmClient as HcmClient41,
|
|
26603
|
+
CliError as CliError57,
|
|
26604
|
+
CliErrorCode as CliErrorCode56,
|
|
26605
|
+
PRESET_ORIGIN_PATH,
|
|
26606
|
+
classifyEndpointFailure as classifyEndpointFailure3,
|
|
26607
|
+
fetchPresetOrigin,
|
|
26608
|
+
formatObject as formatObject42,
|
|
26609
|
+
fromAxiosError as fromAxiosError36,
|
|
26610
|
+
isUuid
|
|
26611
|
+
} from "@hcmai/sdk";
|
|
26612
|
+
var ORIGIN_MEANING = {
|
|
26613
|
+
SYSTEM_BASELINE: "\u5E73\u53F0\u57FA\u7EBF\u884C\uFF0C\u5F53\u524D\u79DF\u6237\u6CA1\u6539\u8FC7\u5B83",
|
|
26614
|
+
TENANT_OVERRIDE: "\u79DF\u6237\u5BF9\u5E73\u53F0\u57FA\u7EBF\u7684\u8986\u76D6",
|
|
26615
|
+
TENANT_ORIGINAL: "\u79DF\u6237\u81EA\u5DF1\u5EFA\u7684\u884C\uFF0C\u57FA\u7EBF\u91CC\u6CA1\u6709\u5BF9\u5E94\u7269",
|
|
26616
|
+
NOT_FOUND: "\u8FD9\u4E2A canonical id \u4E0D\u5728\u5F53\u524D\u79DF\u6237\u7684\u53D8\u4F53\u89C6\u56FE\u91CC",
|
|
26617
|
+
NOT_A_PRESET_MODEL: "\u8FD9\u4E2A\u6A21\u578B\u6CA1\u6709\u300C\u7CFB\u7EDF\u9884\u7F6E / \u79DF\u6237\u539F\u521B\u300D\u8FD9\u6761\u8FB9\u754C\uFF0C\u6BCF\u4E00\u884C\u90FD\u662F\u79DF\u6237\u6570\u636E"
|
|
26618
|
+
};
|
|
26619
|
+
function cliNextStepForOrigin(model, origin, id) {
|
|
26620
|
+
const idArg = id ?? "<id>";
|
|
26621
|
+
switch (origin) {
|
|
26622
|
+
case "SYSTEM_BASELINE":
|
|
26623
|
+
return `\u6539\u5B83\uFF1A\`hcm update ${model} --id ${idArg} --data '<JSON>'\` \u4F1A\u7269\u5316\u51FA\u4E00\u6761\u79DF\u6237\u8986\u76D6\uFF0C\u4E0D\u662F\u5C31\u5730\u6539\u57FA\u7EBF\uFF1B\u54EA\u4E9B\u5B57\u6BB5\u5141\u8BB8\u8986\u76D6\u7531\u6A21\u578B\u81EA\u5DF1\u58F0\u660E\uFF0C\u88AB\u62D2\u65F6\u662F 422 PRESET_FIELD_OVERRIDE_FORBIDDEN`;
|
|
26624
|
+
case "TENANT_OVERRIDE":
|
|
26625
|
+
return `\u64A4\u9500\u8986\u76D6\u3001\u56DE\u843D\u57FA\u7EBF\uFF08\u5E42\u7B49\uFF09\uFF1A\`hcm action ${model}.resetToDefault --id ${idArg}\`\uFF08\u5F53\u524D\u8EAB\u4EFD\u80FD\u4E0D\u80FD\u8C03\u770B \`hcm describe ${model}\` \u91CC resetToDefault \u90A3\u884C\u7684 grant\uFF09\uFF1B\u7EE7\u7EED\u6539\u4ECD\u8D70 \`hcm update ${model} --id ${idArg} --data '<JSON>'\``;
|
|
26626
|
+
case "TENANT_ORIGINAL":
|
|
26627
|
+
return `\u666E\u901A\u79DF\u6237\u6570\u636E\uFF1A\u5220\u9664 \`hcm delete ${model} --id ${idArg}\`\uFF1B\u5B83\u6CA1\u6709\u57FA\u7EBF\u53EF\u56DE\u843D\uFF0CresetToDefault \u5BF9\u5B83\u662F no-op`;
|
|
26628
|
+
case "NOT_FOUND":
|
|
26629
|
+
return `\u5148\u786E\u8BA4\u5B83\u8BFB\u4E0D\u8BFB\u5F97\u5230\uFF1A\`hcm query ${model} --filter '{"field":"id","op":"eq","value":"${idArg}"}'\`\uFF1B\u8BFB\u5F97\u5230\u5374\u4ECD\u662F NOT_FOUND\uFF0C\u8BF4\u660E\u5B83\u4E0D\u5728\u672C\u79DF\u6237\u4E0E __SYSTEM__ \u8FD9\u4E24\u4E2A\u4F5C\u7528\u57DF\u5185`;
|
|
26630
|
+
case "NOT_A_PRESET_MODEL":
|
|
26631
|
+
return `\u6309\u666E\u901A\u6A21\u578B\u7684\u589E\u5220\u6539\u8D70\uFF1B\u7ED3\u6784\u4E0A\u80FD\u4E0D\u80FD\u5220\u770B \`hcm describe ${model}\` \u7684\u901A\u7528\u589E\u5220\u6539\u6BB5`;
|
|
26632
|
+
default:
|
|
26633
|
+
return void 0;
|
|
26634
|
+
}
|
|
26635
|
+
}
|
|
26636
|
+
function originLine2(origin) {
|
|
26637
|
+
if (origin === void 0) return `origin=${NOT_PROVIDED}`;
|
|
26638
|
+
const meaning = ORIGIN_MEANING[origin];
|
|
26639
|
+
return meaning ? `origin=${origin}\uFF08${meaning}\uFF09` : `origin=${origin}\uFF08\u8FD9\u7248 CLI \u4E0D\u8BA4\u8BC6\u8FD9\u4E00\u6863\uFF0C\u7167\u670D\u52A1\u7AEF\u539F\u6587\u5224\uFF09`;
|
|
26640
|
+
}
|
|
26641
|
+
function renderPresetOrigin(model, view, args) {
|
|
26642
|
+
const lines = [];
|
|
26643
|
+
if (!("presetModel" in view)) {
|
|
26644
|
+
lines.push(`${model}\uFF1ApresetModel=${NOT_PROVIDED}`);
|
|
26645
|
+
} else if (view.presetModel === false) {
|
|
26646
|
+
lines.push(`${model} \u4E0D\u662F\u9884\u7F6E\u6A21\u578B\uFF08presetModel=false\uFF09\uFF0C${originLine2(view.origin)}\u3002`);
|
|
26647
|
+
const next = cliNextStepForOrigin(model, view.origin ?? "NOT_A_PRESET_MODEL");
|
|
26648
|
+
if (next) lines.push(`\u4E0B\u4E00\u6B65\uFF1A${next}`);
|
|
26649
|
+
if (view.nextStep) lines.push(`\u670D\u52A1\u7AEF\u539F\u6587\uFF1A${view.nextStep}`);
|
|
26650
|
+
if (args.id || args.includeTenantIds) {
|
|
26651
|
+
lines.push("\u2139\uFE0F \u975E\u9884\u7F6E\u6A21\u578B\u4E0D\u5206\u884C\u7684\u6765\u6E90\uFF0C--id / --include-tenant-ids \u5728\u8FD9\u91CC\u6CA1\u6709\u610F\u4E49\u2014\u2014\u5B83\u7684\u6BCF\u4E00\u884C\u90FD\u662F\u79DF\u6237\u6570\u636E");
|
|
26652
|
+
}
|
|
26653
|
+
return lines.join("\n");
|
|
26654
|
+
} else {
|
|
26655
|
+
lines.push(`${model} \u662F\u9884\u7F6E\u6A21\u578B\uFF08presetModel=true\uFF09\u3002`);
|
|
26656
|
+
}
|
|
26657
|
+
if (view.counts && typeof view.counts === "object") {
|
|
26658
|
+
const total = typeof view.totalVariantRows === "number" ? `\uFF0C\u5171 ${view.totalVariantRows} \u884C` : `\uFF0C\u603B\u884C\u6570 ${NOT_PROVIDED}`;
|
|
26659
|
+
lines.push(`\u6309\u6765\u6E90\u5206\u7EC4\uFF08\u5F53\u524D\u79DF\u6237\u7684\u53D8\u4F53\u89C6\u56FE${total}\uFF09\uFF1A`);
|
|
26660
|
+
for (const [k, v] of Object.entries(view.counts)) {
|
|
26661
|
+
lines.push(` ${k.padEnd(16)} ${String(v).padStart(5)} ${ORIGIN_MEANING[k] ?? ""}`.trimEnd());
|
|
26662
|
+
}
|
|
26663
|
+
} else {
|
|
26664
|
+
lines.push(`\u6309\u6765\u6E90\u5206\u7EC4\uFF1A${NOT_PROVIDED}`);
|
|
26665
|
+
}
|
|
26666
|
+
if (args.includeTenantIds) {
|
|
26667
|
+
if (!view.tenantIds || typeof view.tenantIds !== "object") {
|
|
26668
|
+
lines.push(`\u79DF\u6237\u81EA\u6709\u884C id\uFF1A${NOT_PROVIDED}\uFF08\u670D\u52A1\u7AEF\u65E9\u4E8E includeTenantIds\uFF0C\u53EA\u56DE\u4E86\u8BA1\u6570\uFF09`);
|
|
26669
|
+
} else {
|
|
26670
|
+
lines.push("\u79DF\u6237\u81EA\u6709\u884C id\uFF08\u4E0E\u5217\u8868\u884C\u7684 id \u540C\u4E00\u8EAB\u4EFD\uFF1B\u6761\u6570\u4E0E\u4E0A\u9762\u7684\u8BA1\u6570\u540C\u53E3\u5F84\uFF09\uFF1A");
|
|
26671
|
+
const buckets = [.../* @__PURE__ */ new Set(["TENANT_OVERRIDE", "TENANT_ORIGINAL", ...Object.keys(view.tenantIds)])];
|
|
26672
|
+
for (const k of buckets) {
|
|
26673
|
+
const ids = view.tenantIds[k];
|
|
26674
|
+
if (!Array.isArray(ids)) {
|
|
26675
|
+
lines.push(` ${k}\uFF1A${NOT_PROVIDED}${ids === void 0 ? "" : "\uFF08\u670D\u52A1\u7AEF\u7ED9\u7684\u4E0D\u662F id \u5217\u8868\uFF0C\u8BA4\u4E0D\u51FA\uFF09"}`);
|
|
26676
|
+
continue;
|
|
26677
|
+
}
|
|
26678
|
+
const list = ids.map(String);
|
|
26679
|
+
const expected = view.counts?.[k];
|
|
26680
|
+
const recon2 = typeof expected === "number" ? expected === list.length ? `\u2713 \u4E0E\u8BA1\u6570 ${expected} \u5BF9\u5F97\u4E0A` : `\u26A0\uFE0F \u4E0E\u8BA1\u6570 ${expected} \u5BF9\u4E0D\u4E0A\u2014\u2014\u522B\u62FF\u8FD9\u4EFD\u6E05\u5355\u5F53\u5168\u96C6` : `\u8BA1\u6570 ${NOT_PROVIDED}\uFF0C\u5BF9\u4E0D\u4E86\u8D26`;
|
|
26681
|
+
lines.push(` ${k}\uFF08${list.length}\uFF0C${recon2}\uFF09\uFF1A${list.length ? list.join("\u3001") : "\uFF08\u65E0\uFF09"}`);
|
|
26682
|
+
}
|
|
26683
|
+
}
|
|
26684
|
+
}
|
|
26685
|
+
if (args.id) {
|
|
26686
|
+
lines.push("", `${model} / ${view.id ?? args.id}\uFF1A${originLine2(view.origin)}`);
|
|
26687
|
+
lines.push(` \u7269\u7406\u5C42\uFF1A${Array.isArray(view.layers) ? view.layers.length ? view.layers.join(" + ") : "\uFF08\u65E0\uFF09" : NOT_PROVIDED}`);
|
|
26688
|
+
lines.push(
|
|
26689
|
+
` resetToDefaultApplicable=${"resetToDefaultApplicable" in view ? String(view.resetToDefaultApplicable) : NOT_PROVIDED}\uFF08\u7ED3\u6784\u4E0A\u8FD9\u4E00\u6863\u9002\u4E0D\u9002\u7528 resetToDefault\uFF0C\u4E0D\u662F\u4F60\u6709\u6743\u8C03\u5B83\uFF09`
|
|
26690
|
+
);
|
|
26691
|
+
const next = view.origin ? cliNextStepForOrigin(model, view.origin, args.id) : void 0;
|
|
26692
|
+
if (next) lines.push(`\u4E0B\u4E00\u6B65\uFF1A${next}`);
|
|
26693
|
+
} else {
|
|
26694
|
+
lines.push(
|
|
26695
|
+
args.includeTenantIds ? `\u4E0B\u4E00\u6B65\uFF1A\u95EE\u67D0\u4E00\u884C\u843D\u5728\u54EA\u4E00\u4FA7 \`hcm preset-origin ${model} --id <canonicalId>\`` : `\u4E0B\u4E00\u6B65\uFF1A\u95EE\u67D0\u4E00\u884C\u843D\u5728\u54EA\u4E00\u4FA7 \`hcm preset-origin ${model} --id <canonicalId>\`\uFF1B\u4E00\u6B21\u62FF\u5168\u79DF\u6237\u81EA\u6709\u884C\u7684 id \`hcm preset-origin ${model} --include-tenant-ids\``
|
|
26696
|
+
);
|
|
26697
|
+
}
|
|
26698
|
+
if (view.nextStep) lines.push(`\u670D\u52A1\u7AEF\u539F\u6587\uFF1A${view.nextStep}`);
|
|
26699
|
+
lines.push("\u2139\uFE0F \u5224\u636E\u662F\u670D\u52A1\u7AEF\u7684\u7269\u7406\u884C\u53D8\u4F53\uFF0C\u4E0D\u662F tenantId / isSystem / createById\u2014\u2014\u522B\u62FF\u90A3\u51E0\u4E2A\u5B57\u6BB5\u53BB\u731C");
|
|
26700
|
+
return lines.join("\n");
|
|
26701
|
+
}
|
|
26702
|
+
var NOT_PROVIDED_NEXT_STEP3 = "\u8FD9\u4E2A\u540E\u7AEF\u6CA1\u6709\u884C\u6765\u6E90\u7AEF\u70B9\uFF08Core 2026-09-06 \u8D77\u624D\u6709\uFF0C#2229 / issue #2179\uFF1B--include-tenant-ids \u8981 Core \u542B HCMNX-806\uFF09\uFF1A\u7528 `hcm version` \u770B\u540E\u7AEF\u7248\u672C\u3002\u8FD9\u4E00\u7248\u5224\u4E0D\u4E86\u300C\u8FD9\u4E00\u884C\u662F\u5E73\u53F0\u57FA\u7EBF\u8FD8\u662F\u79DF\u6237\u81EA\u5DF1\u7684\u300D\uFF0C\u6539\u5B83\u4E4B\u524D\u505C\u4E0B\u95EE\u4EBA\uFF0C\u522B\u62FF createById \u53BB\u731C";
|
|
26703
|
+
async function presetOriginCommand(model, args) {
|
|
26704
|
+
try {
|
|
26705
|
+
if (args.id !== void 0 && !isUuid(args.id.trim())) {
|
|
26706
|
+
throw new CliError57({
|
|
26707
|
+
code: CliErrorCode56.INVALID_ARGUMENT,
|
|
26708
|
+
message: `--id \u8981\u7684\u662F\u884C\u7684 canonical id\uFF08UUID\uFF09\uFF0C\u6536\u5230 ${JSON.stringify(args.id)}`,
|
|
26709
|
+
context: { nextStep: `\u4E0D\u77E5\u9053 id \u65F6\u5148 \`hcm preset-origin ${model} --include-tenant-ids\` \u62FF\u79DF\u6237\u81EA\u6709\u884C\u7684 id\uFF0C\u6216\u4ECE \`hcm query ${model}\` \u7684\u7ED3\u679C\u91CC\u6284 id` }
|
|
26710
|
+
});
|
|
26711
|
+
}
|
|
26712
|
+
if (args.id !== void 0 && args.includeTenantIds) {
|
|
26713
|
+
process.stderr.write("\u2139\uFE0F \u540C\u65F6\u7ED9\u4E86 --id \u4E0E --include-tenant-ids\uFF1A\u4E24\u6837\u90FD\u95EE\uFF0C\u8F93\u51FA\u91CC\u4E24\u6BB5\u90FD\u6709\n");
|
|
26714
|
+
}
|
|
26715
|
+
const client4 = HcmClient41.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
26716
|
+
const view = await fetchPresetOrigin(client4.raw(), model, {
|
|
26717
|
+
...args.id !== void 0 ? { id: args.id.trim() } : {},
|
|
26718
|
+
...args.includeTenantIds ? { includeTenantIds: true } : {}
|
|
26719
|
+
});
|
|
26720
|
+
const fmt = args.output ?? "table";
|
|
26721
|
+
if (fmt !== "table") {
|
|
26722
|
+
const origin = view.origin;
|
|
26723
|
+
const cliNextStep = origin ? cliNextStepForOrigin(model, origin, args.id?.trim()) : void 0;
|
|
26724
|
+
process.stdout.write(formatObject42({ ...view, ...cliNextStep ? { cliNextStep } : {} }, { format: fmt }) + "\n");
|
|
26725
|
+
} else {
|
|
26726
|
+
process.stdout.write(renderPresetOrigin(model, view, args) + "\n");
|
|
26727
|
+
}
|
|
26728
|
+
process.exitCode = 0;
|
|
26729
|
+
} catch (e) {
|
|
26730
|
+
const err = e;
|
|
26731
|
+
if (!err?.isAxiosError) exitWithError(e);
|
|
26732
|
+
const f = classifyEndpointFailure3(e, { modelScoped: true });
|
|
26733
|
+
if (f.kind === "not-provided") {
|
|
26734
|
+
exitWithError(new CliError57({
|
|
26735
|
+
code: CliErrorCode56.PROTOCOL_UNSUPPORTED,
|
|
26736
|
+
message: `${NOT_PROVIDED}\uFF1AGET ${PRESET_ORIGIN_PATH(model)} \u2192 ${f.detail}\uFF08\u670D\u52A1\u7AEF\u65E9\u4E8E\u8BE5\u7AEF\u70B9\uFF0C\u8DEF\u7531\u88AB\u5F53\u6210\u6309 id \u8BFB\u884C\uFF09`,
|
|
26737
|
+
context: { nextStep: NOT_PROVIDED_NEXT_STEP3 }
|
|
26738
|
+
}));
|
|
26739
|
+
}
|
|
26740
|
+
exitWithError(fromAxiosError36(err, args.env));
|
|
26741
|
+
}
|
|
26742
|
+
}
|
|
26743
|
+
|
|
25652
26744
|
// src/startup.ts
|
|
25653
26745
|
function needsLegacyProfileMigration(argv) {
|
|
25654
26746
|
const args = argv.slice(2);
|
|
@@ -25663,7 +26755,7 @@ init_error_output();
|
|
|
25663
26755
|
|
|
25664
26756
|
// src/commands/offline/guard.ts
|
|
25665
26757
|
init_state();
|
|
25666
|
-
import { CliError as
|
|
26758
|
+
import { CliError as CliError58, CliErrorCode as CliErrorCode57 } from "@hcmai/sdk";
|
|
25667
26759
|
var OFFLINE_BLOCKED = {
|
|
25668
26760
|
"chiron gap search": "\u56DE\u5916\u7F51\u540E\u8DD1 `hcm chiron gap search \u2026`",
|
|
25669
26761
|
"chiron gap status": "\u56DE\u5916\u7F51\u540E\u8DD1 `hcm chiron gap status`",
|
|
@@ -25687,8 +26779,8 @@ function assertOnlineAllowed(path49, offline2 = () => isOfflineMode()) {
|
|
|
25687
26779
|
const next = OFFLINE_BLOCKED[path49];
|
|
25688
26780
|
if (!next) return;
|
|
25689
26781
|
if (!offline2()) return;
|
|
25690
|
-
throw new
|
|
25691
|
-
code:
|
|
26782
|
+
throw new CliError58({
|
|
26783
|
+
code: CliErrorCode57.OFFLINE_UNAVAILABLE,
|
|
25692
26784
|
message: `\u300Chcm ${path49}\u300D\u8981\u8FDE\u516C\u53F8\u7F51\u7EDC\uFF0C${OFFLINE_REASON}\uFF1B\u672C\u6B21\u6CA1\u6709\u8FDE\u63A5\uFF0C\u4E5F\u6CA1\u6709\u6267\u884C`,
|
|
25693
26785
|
context: { nextStep: next, reasonCode: "offline-kit" }
|
|
25694
26786
|
});
|
|
@@ -25701,13 +26793,13 @@ import { execFileSync as execFileSync2 } from "child_process";
|
|
|
25701
26793
|
import { existsSync as existsSync14, promises as fsp11 } from "fs";
|
|
25702
26794
|
import os9 from "os";
|
|
25703
26795
|
import path38 from "path";
|
|
25704
|
-
import { CliError as
|
|
26796
|
+
import { CliError as CliError64, CliErrorCode as CliErrorCode63 } from "@hcmai/sdk";
|
|
25705
26797
|
|
|
25706
26798
|
// src/commands/offline/assemble-hcm.ts
|
|
25707
26799
|
import { existsSync as existsSync11, promises as fsp7, readFileSync as readFileSync15, realpathSync, statSync as statSync6 } from "fs";
|
|
25708
26800
|
import path32 from "path";
|
|
25709
26801
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
25710
|
-
import { CliError as
|
|
26802
|
+
import { CliError as CliError59, CliErrorCode as CliErrorCode58 } from "@hcmai/sdk";
|
|
25711
26803
|
var SKIPPED_PACKAGES = /* @__PURE__ */ new Set(["keytar"]);
|
|
25712
26804
|
function readPkg(dir) {
|
|
25713
26805
|
return JSON.parse(readFileSync15(path32.join(dir, "package.json"), "utf8"));
|
|
@@ -25731,8 +26823,8 @@ function runningCliPackageDir(from = path32.dirname(fileURLToPath2(import.meta.u
|
|
|
25731
26823
|
if (existsSync11(f) && readPkg(d).name === "@hcmai/cli") return d;
|
|
25732
26824
|
const parent = path32.dirname(d);
|
|
25733
26825
|
if (parent === d) {
|
|
25734
|
-
throw new
|
|
25735
|
-
code:
|
|
26826
|
+
throw new CliError59({
|
|
26827
|
+
code: CliErrorCode58.OFFLINE_KIT_ERROR,
|
|
25736
26828
|
message: `\u4ECE ${from} \u5411\u4E0A\u627E\u4E0D\u5230 @hcmai/cli \u7684 package.json\uFF0C\u6CA1\u6CD5\u628A hcm \u62F7\u8FDB\u79BB\u7EBF\u5305`,
|
|
25737
26829
|
context: { nextStep: "\u7528 npm \u88C5\u7684 hcm\uFF08npm i -g @hcmai/cli\uFF09\u8DD1 hcm offline build" }
|
|
25738
26830
|
});
|
|
@@ -25759,8 +26851,8 @@ function dependencyClosure(cliPkgDir) {
|
|
|
25759
26851
|
const found2 = resolvePackageDir(dir, n2);
|
|
25760
26852
|
if (!found2) {
|
|
25761
26853
|
if (optional) continue;
|
|
25762
|
-
throw new
|
|
25763
|
-
code:
|
|
26854
|
+
throw new CliError59({
|
|
26855
|
+
code: CliErrorCode58.OFFLINE_KIT_ERROR,
|
|
25764
26856
|
message: `${pkg.name ?? dir} \u4F9D\u8D56\u7684 ${n2} \u5728\u672C\u673A\u627E\u4E0D\u5230\uFF0C\u4F9D\u8D56\u6811\u4E0D\u5B8C\u6574\uFF0C\u6CA1\u6709\u51FA\u5305`,
|
|
25765
26857
|
context: { nextStep: "\u91CD\u88C5 @hcmai/cli\uFF08npm i -g @hcmai/cli\uFF09\u540E\u91CD\u8DD1 hcm offline build" }
|
|
25766
26858
|
});
|
|
@@ -25814,16 +26906,16 @@ async function assembleHcm(cliPkgDir, destDir) {
|
|
|
25814
26906
|
for (const d of dirs) await copyPackage(d, path32.join(destDir, path32.relative(root, d)));
|
|
25815
26907
|
const native = await listNativeModules(destDir);
|
|
25816
26908
|
if (native.length) {
|
|
25817
|
-
throw new
|
|
25818
|
-
code:
|
|
26909
|
+
throw new CliError59({
|
|
26910
|
+
code: CliErrorCode58.OFFLINE_KIT_ERROR,
|
|
25819
26911
|
message: `CLI \u7684\u4F9D\u8D56\u91CC\u6709\u5E73\u53F0\u76F8\u5173\u7684\u539F\u751F\u6A21\u5757\uFF0C\u62F7\u8FDB\u79BB\u7EBF\u5305\u540E\u5728\u522B\u7684\u5E73\u53F0\u4E0A\u8DD1\u4E0D\u8D77\u6765\uFF1A${native.join("\u3001")}`,
|
|
25820
26912
|
context: { nextStep: "\u62A5\u7ED9 CLI \u7EF4\u62A4\u65B9\uFF08\u79BB\u7EBF\u5305\u8981\u6C42 hcm \u7684\u8FD0\u884C\u65F6\u4F9D\u8D56\u662F\u7EAF JS\uFF09\uFF1B\u6CA1\u6709\u51FA\u5305", reasonCode: "native-module" }
|
|
25821
26913
|
});
|
|
25822
26914
|
}
|
|
25823
26915
|
const entry = path32.relative(destDir, path32.join(destDir, path32.relative(root, cliPkgDir), "dist", "index.js")).split(path32.sep).join("/");
|
|
25824
26916
|
if (!statSync6(path32.join(destDir, entry), { throwIfNoEntry: false })) {
|
|
25825
|
-
throw new
|
|
25826
|
-
code:
|
|
26917
|
+
throw new CliError59({
|
|
26918
|
+
code: CliErrorCode58.OFFLINE_KIT_ERROR,
|
|
25827
26919
|
message: `\u62F7\u8D1D\u540E\u627E\u4E0D\u5230 hcm \u5165\u53E3 ${entry}`,
|
|
25828
26920
|
context: { nextStep: "\u7528 npm \u88C5\u597D\u7684 hcm \u8DD1 hcm offline build\uFF08\u6E90\u7801\u76EE\u5F55\u8981\u5148 npm run build\uFF09" }
|
|
25829
26921
|
});
|
|
@@ -25837,14 +26929,14 @@ import { createWriteStream, promises as fsp8 } from "fs";
|
|
|
25837
26929
|
import { pipeline } from "stream/promises";
|
|
25838
26930
|
import * as yazl from "yazl";
|
|
25839
26931
|
import path33 from "path";
|
|
25840
|
-
import { CliError as
|
|
26932
|
+
import { CliError as CliError60, CliErrorCode as CliErrorCode59 } from "@hcmai/sdk";
|
|
25841
26933
|
function hasCommand(cmd) {
|
|
25842
26934
|
const probe3 = process.platform === "win32" ? spawnSync4("where", [cmd], { stdio: "ignore" }) : spawnSync4("sh", ["-c", `command -v ${cmd}`], { stdio: "ignore" });
|
|
25843
26935
|
return probe3.status === 0;
|
|
25844
26936
|
}
|
|
25845
26937
|
function missing(what, need) {
|
|
25846
|
-
return new
|
|
25847
|
-
code:
|
|
26938
|
+
return new CliError60({
|
|
26939
|
+
code: CliErrorCode59.OFFLINE_KIT_ERROR,
|
|
25848
26940
|
message: `${what}\u9700\u8981 ${need}\uFF0C\u672C\u673A\u6CA1\u6709`,
|
|
25849
26941
|
context: { nextStep: `\u88C5\u4E0A ${need} \u540E\u91CD\u8DD1 hcm offline build\uFF08macOS \u4E0E Windows 10+ \u81EA\u5E26\u7684 tar \u5373\u53EF\uFF09` }
|
|
25850
26942
|
});
|
|
@@ -25894,8 +26986,8 @@ async function zipDir(dir, prefix, out) {
|
|
|
25894
26986
|
await pipeline(zip.outputStream, createWriteStream(out));
|
|
25895
26987
|
} catch (e) {
|
|
25896
26988
|
await fsp8.rm(out, { force: true });
|
|
25897
|
-
throw new
|
|
25898
|
-
code:
|
|
26989
|
+
throw new CliError60({
|
|
26990
|
+
code: CliErrorCode59.OFFLINE_KIT_ERROR,
|
|
25899
26991
|
message: `\u6253 zip \u5305\u65F6\u8BFB\u6587\u4EF6\u5931\u8D25\uFF08${e.code ?? e.message}\uFF09\uFF1A${e.message}`,
|
|
25900
26992
|
context: { reasonCode: "zip-failed", nextStep: "\u591A\u534A\u662F\u6740\u6BD2\u8F6F\u4EF6\u9501\u4F4F\u4E86\u521A\u89E3\u51FA\u7684\u7A0B\u5E8F\u6587\u4EF6\uFF1A\u628A\u51FA\u5305\u7528\u7684\u4E34\u65F6\u76EE\u5F55\u52A0\u5165\u767D\u540D\u5355\uFF0C\u6216\u6682\u505C\u5B9E\u65F6\u9632\u62A4\u540E\u91CD\u65B0 `hcm offline build`" }
|
|
25901
26993
|
});
|
|
@@ -25915,7 +27007,7 @@ async function findFile(root, name) {
|
|
|
25915
27007
|
|
|
25916
27008
|
// src/commands/offline/components.ts
|
|
25917
27009
|
import { readFileSync as readFileSync16 } from "fs";
|
|
25918
|
-
import { CliError as
|
|
27010
|
+
import { CliError as CliError61, CliErrorCode as CliErrorCode60 } from "@hcmai/sdk";
|
|
25919
27011
|
var PLATFORMS = ["win-x64", "linux-x64", "linux-arm64"];
|
|
25920
27012
|
var NODE = "v22.23.5";
|
|
25921
27013
|
var CRUSH = "0.101.0";
|
|
@@ -25981,16 +27073,16 @@ function componentsFor(p) {
|
|
|
25981
27073
|
try {
|
|
25982
27074
|
table = JSON.parse(readFileSync16(file, "utf8"));
|
|
25983
27075
|
} catch (e) {
|
|
25984
|
-
throw new
|
|
25985
|
-
code:
|
|
27076
|
+
throw new CliError61({
|
|
27077
|
+
code: CliErrorCode60.CONFIG_PARSE_ERROR,
|
|
25986
27078
|
message: `HCM_OFFLINE_COMPONENTS_FILE=${file} \u8BFB\u4E0D\u61C2\uFF1A${e.message}`,
|
|
25987
27079
|
context: { nextStep: "\u4FEE\u597D\u8FD9\u4E2A\u6587\u4EF6\uFF0C\u6216 unset HCM_OFFLINE_COMPONENTS_FILE \u7528\u5185\u7F6E\u7684\u7EC4\u4EF6\u8868" }
|
|
25988
27080
|
});
|
|
25989
27081
|
}
|
|
25990
27082
|
const list = table[p];
|
|
25991
27083
|
if (!Array.isArray(list)) {
|
|
25992
|
-
throw new
|
|
25993
|
-
code:
|
|
27084
|
+
throw new CliError61({
|
|
27085
|
+
code: CliErrorCode60.CONFIG_PARSE_ERROR,
|
|
25994
27086
|
message: `HCM_OFFLINE_COMPONENTS_FILE=${file} \u91CC\u6CA1\u6709\u5E73\u53F0 ${p} \u7684\u7EC4\u4EF6`,
|
|
25995
27087
|
context: { nextStep: `\u8865\u4E0A "${p}": [...]\uFF0C\u6216 unset HCM_OFFLINE_COMPONENTS_FILE` }
|
|
25996
27088
|
});
|
|
@@ -26003,7 +27095,7 @@ import { createHash as createHash10 } from "crypto";
|
|
|
26003
27095
|
import { createReadStream, promises as fsp9 } from "fs";
|
|
26004
27096
|
import os7 from "os";
|
|
26005
27097
|
import path34 from "path";
|
|
26006
|
-
import { CliError as
|
|
27098
|
+
import { CliError as CliError62, CliErrorCode as CliErrorCode61 } from "@hcmai/sdk";
|
|
26007
27099
|
function offlineCacheDir() {
|
|
26008
27100
|
const xdg = process.env.XDG_CACHE_HOME?.trim();
|
|
26009
27101
|
return path34.join(xdg || path34.join(process.env.HOME ?? os7.homedir(), ".cache"), "hcm", "offline");
|
|
@@ -26054,8 +27146,8 @@ async function fetchComponent(a, opts = {}) {
|
|
|
26054
27146
|
const actual = await sha256File2(part);
|
|
26055
27147
|
if (actual !== a.sha256) {
|
|
26056
27148
|
await fsp9.rm(part, { force: true });
|
|
26057
|
-
throw new
|
|
26058
|
-
code:
|
|
27149
|
+
throw new CliError62({
|
|
27150
|
+
code: CliErrorCode61.OFFLINE_KIT_ERROR,
|
|
26059
27151
|
message: `${a.name} ${a.version} \u7684 SHA256 \u4E0D\u5BF9\uFF1A\u671F\u671B ${a.sha256}\uFF0C\u5B9E\u9645 ${actual}\uFF08${url}\uFF09\uFF1B\u6CA1\u6709\u51FA\u5305`,
|
|
26060
27152
|
context: { nextStep: "\u6362\u4E86\u955C\u50CF\u7684\u8BDD\u5148\u786E\u8BA4\u955C\u50CF\u540C\u6B65\u7684\u662F\u540C\u4E00\u4E2A\u6587\u4EF6\uFF1B\u6587\u4EF6\u88AB\u6539\u8FC7\u65F6\u4E0D\u8981\u7528\u5B83\u51FA\u5305", reasonCode: "sha256-mismatch" }
|
|
26061
27153
|
});
|
|
@@ -26064,8 +27156,8 @@ async function fetchComponent(a, opts = {}) {
|
|
|
26064
27156
|
return file;
|
|
26065
27157
|
}
|
|
26066
27158
|
function downloadFailed(a, url, why) {
|
|
26067
|
-
return new
|
|
26068
|
-
code:
|
|
27159
|
+
return new CliError62({
|
|
27160
|
+
code: CliErrorCode61.NETWORK_ERROR,
|
|
26069
27161
|
message: `\u4E0B\u8F7D ${a.name} ${a.version} \u5931\u8D25\uFF08${why}\uFF09\uFF1A${url}`,
|
|
26070
27162
|
context: {
|
|
26071
27163
|
nextStep: `\u56FD\u5185\u4E0B\u4E0D\u52A8\u65F6\u8BBE ${MIRROR_ENV[a.mirror]} \u6362\u955C\u50CF\u524D\u7F00\uFF08\u4F8B\uFF1A${a.mirror === "node" ? "HCM_OFFLINE_MIRROR_NODE=https://npmmirror.com/mirrors/node" : "HCM_OFFLINE_MIRROR_GITHUB=https://<\u955C\u50CF>/github.com\uFF0C\u955C\u50CF\u4E0B\u7684\u8DEF\u5F84\u4E0E github.com \u4E00\u81F4"}\uFF09\uFF0CSHA256 \u7167\u6837\u6BD4\u5BF9\uFF1B\u7136\u540E\u91CD\u8DD1 hcm offline build`
|
|
@@ -26307,7 +27399,7 @@ init_gaps();
|
|
|
26307
27399
|
import { existsSync as existsSync12, promises as fsp10 } from "fs";
|
|
26308
27400
|
import os8 from "os";
|
|
26309
27401
|
import path36 from "path";
|
|
26310
|
-
import { CASES_REPO_SLUG as CASES_REPO_SLUG4, CASES_REPO_URL as CASES_REPO_URL3, CliError as
|
|
27402
|
+
import { CASES_REPO_SLUG as CASES_REPO_SLUG4, CASES_REPO_URL as CASES_REPO_URL3, CliError as CliError63, CliErrorCode as CliErrorCode62, createJiraClient as createJiraClient3, METHOD_REPO_DISPLAY as METHOD_REPO_DISPLAY2, METHOD_REPO_URL as METHOD_REPO_URL2 } from "@hcmai/sdk";
|
|
26311
27403
|
init_knowledge_format();
|
|
26312
27404
|
function defaultKnowledgeDeps(log) {
|
|
26313
27405
|
return {
|
|
@@ -26445,7 +27537,7 @@ async function packCases(dest, withEvidence, deps, missing2) {
|
|
|
26445
27537
|
}
|
|
26446
27538
|
}
|
|
26447
27539
|
var KNOWLEDGE_RETRY_DELAYS_MS = [2e3, 5e3];
|
|
26448
|
-
var isTransient = (e) => e instanceof
|
|
27540
|
+
var isTransient = (e) => e instanceof CliError63 && e.code === CliErrorCode62.METHOD_SOURCE_NETWORK;
|
|
26449
27541
|
async function withRetry(item, label, dest, deps, retries, missing2, run3) {
|
|
26450
27542
|
const delays = deps.retryDelaysMs ?? KNOWLEDGE_RETRY_DELAYS_MS;
|
|
26451
27543
|
for (let n2 = 0; ; n2 += 1) {
|
|
@@ -26630,8 +27722,8 @@ async function placeComponent(a, file, p, kit, work) {
|
|
|
26630
27722
|
const need = async (name) => {
|
|
26631
27723
|
const hit = a.name === "node" && !win ? path38.join(dir, (await fsp11.readdir(dir)).find((e) => e.startsWith("node-")) ?? "", "bin", "node") : await findFile(dir, name);
|
|
26632
27724
|
if (!hit || !existsSync14(hit)) {
|
|
26633
|
-
throw new
|
|
26634
|
-
code:
|
|
27725
|
+
throw new CliError64({
|
|
27726
|
+
code: CliErrorCode63.OFFLINE_KIT_ERROR,
|
|
26635
27727
|
message: `${a.name} ${a.version} \u7684\u53D1\u884C\u5305\u91CC\u627E\u4E0D\u5230 ${name}\uFF08${a.url}\uFF09`,
|
|
26636
27728
|
context: { nextStep: "\u7EC4\u4EF6\u53D1\u884C\u5305\u7684\u7ED3\u6784\u53D8\u4E86\uFF1A\u62A5\u7ED9 CLI \u7EF4\u62A4\u65B9\u66F4\u65B0 components.ts\uFF1B\u6CA1\u6709\u51FA\u5305" }
|
|
26637
27729
|
});
|
|
@@ -26665,7 +27757,7 @@ async function placeComponent(a, file, p, kit, work) {
|
|
|
26665
27757
|
}
|
|
26666
27758
|
case "python": {
|
|
26667
27759
|
const top = path38.join(dir, "python");
|
|
26668
|
-
if (!existsSync14(top)) throw new
|
|
27760
|
+
if (!existsSync14(top)) throw new CliError64({ code: CliErrorCode63.OFFLINE_KIT_ERROR, message: `${a.url} \u89E3\u51FA\u6765\u6CA1\u6709 python/ \u76EE\u5F55`, context: { nextStep: "\u62A5\u7ED9 CLI \u7EF4\u62A4\u65B9\u66F4\u65B0 components.ts\uFF1B\u6CA1\u6709\u51FA\u5305" } });
|
|
26669
27761
|
await fsp11.rename(top, path38.join(kit, "python"));
|
|
26670
27762
|
return;
|
|
26671
27763
|
}
|
|
@@ -26715,8 +27807,8 @@ function bundledSkillRoots(cliPkgDir) {
|
|
|
26715
27807
|
}
|
|
26716
27808
|
async function runOfflineBuild(opts, deps = {}) {
|
|
26717
27809
|
if (!isPlatform(opts.platform)) {
|
|
26718
|
-
throw new
|
|
26719
|
-
code:
|
|
27810
|
+
throw new CliError64({
|
|
27811
|
+
code: CliErrorCode63.INVALID_ARGUMENT,
|
|
26720
27812
|
message: `--platform \u53EA\u80FD\u662F ${PLATFORMS.join(" / ")}\uFF0C\u6536\u5230\u300C${opts.platform}\u300D`,
|
|
26721
27813
|
context: { nextStep: `hcm offline build --platform ${PLATFORMS[0]}` }
|
|
26722
27814
|
});
|
|
@@ -26848,11 +27940,11 @@ import { spawnSync as spawnSync7 } from "child_process";
|
|
|
26848
27940
|
import { existsSync as existsSync19, promises as fsp15, readdirSync as readdirSync6, readFileSync as readFileSync20 } from "fs";
|
|
26849
27941
|
import os11 from "os";
|
|
26850
27942
|
import path43 from "path";
|
|
26851
|
-
import { CliError as
|
|
27943
|
+
import { CliError as CliError68, CliErrorCode as CliErrorCode67, hcmConfigDir as hcmConfigDir2 } from "@hcmai/sdk";
|
|
26852
27944
|
|
|
26853
27945
|
// src/commands/offline/path-env.ts
|
|
26854
27946
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
26855
|
-
import { CliError as
|
|
27947
|
+
import { CliError as CliError65, CliErrorCode as CliErrorCode64 } from "@hcmai/sdk";
|
|
26856
27948
|
import { existsSync as existsSync15, promises as fsp12 } from "fs";
|
|
26857
27949
|
import os10 from "os";
|
|
26858
27950
|
import path39 from "path";
|
|
@@ -26903,8 +27995,8 @@ function addToUserPathWindows(kitBin) {
|
|
|
26903
27995
|
);
|
|
26904
27996
|
const out = `${r.stdout ?? ""}`.trim();
|
|
26905
27997
|
if (r.status === 0 && /ADDED|ALREADY/.test(out)) return out.includes("ALREADY") ? "already" : "added";
|
|
26906
|
-
throw new
|
|
26907
|
-
code:
|
|
27998
|
+
throw new CliError65({
|
|
27999
|
+
code: CliErrorCode64.OFFLINE_KIT_ERROR,
|
|
26908
28000
|
message: `\u6CA1\u80FD\u628A ${kitBin} \u52A0\u5230\u5F53\u524D\u7528\u6237\u7684 PATH\uFF08${r.error?.message ?? `powershell \u9000\u51FA\u7801 ${r.status}\uFF1A${`${r.stderr ?? ""}${out}`.trim().slice(-300)}`}\uFF09`,
|
|
26909
28001
|
context: { reasonCode: "user-path-failed", nextStep: "\u53EF\u4EE5\u5148\u53CC\u51FB\u5B89\u88C5\u76EE\u5F55\u91CC\u7684\u300C\u777F\u620E\u7EC8\u7AEF.cmd\u300D\u7528\uFF1B\u6216\u8DD1 `hcm offline setup --from <\u5B89\u88C5\u76EE\u5F55> --step path` \u91CD\u8BD5\uFF0C\u4E0D\u60F3\u6539 PATH \u5C31\u52A0 --no-path" }
|
|
26910
28002
|
});
|
|
@@ -26951,7 +28043,7 @@ async function writeCrushConfig(kitHome, cfg, now = /* @__PURE__ */ new Date())
|
|
|
26951
28043
|
}
|
|
26952
28044
|
|
|
26953
28045
|
// src/commands/offline/setup-llm.ts
|
|
26954
|
-
import { CliError as
|
|
28046
|
+
import { CliError as CliError66, CliErrorCode as CliErrorCode65 } from "@hcmai/sdk";
|
|
26955
28047
|
|
|
26956
28048
|
// src/commands/offline/http.ts
|
|
26957
28049
|
import http from "http";
|
|
@@ -26984,7 +28076,7 @@ var SMALL_CONTEXT_WINDOW = 131072;
|
|
|
26984
28076
|
var auth = (key2) => key2 ? { authorization: `Bearer ${key2}` } : {};
|
|
26985
28077
|
var normalizeBaseUrl = (u) => u.trim().replace(/\/+$/, "");
|
|
26986
28078
|
function llmError(message, nextStep, reasonCode) {
|
|
26987
|
-
return new
|
|
28079
|
+
return new CliError66({ code: CliErrorCode65.LLM_PROBE_UNAVAILABLE, message, context: { nextStep, reasonCode } });
|
|
26988
28080
|
}
|
|
26989
28081
|
async function probeModels(baseUrl, key2, ca) {
|
|
26990
28082
|
const url = `${normalizeBaseUrl(baseUrl)}/models`;
|
|
@@ -27045,7 +28137,7 @@ init_state();
|
|
|
27045
28137
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
27046
28138
|
import { copyFileSync, existsSync as existsSync17, promises as fsp14, readdirSync as readdirSync5, readFileSync as readFileSync18, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
27047
28139
|
import { X509Certificate } from "crypto";
|
|
27048
|
-
import { CliError as
|
|
28140
|
+
import { CliError as CliError67, CliErrorCode as CliErrorCode66 } from "@hcmai/sdk";
|
|
27049
28141
|
import path41 from "path";
|
|
27050
28142
|
import tls from "tls";
|
|
27051
28143
|
var UNTRUSTED = /* @__PURE__ */ new Set([
|
|
@@ -27117,8 +28209,8 @@ async function writeTrustBundle(kitHome, files, systemCa = null) {
|
|
|
27117
28209
|
try {
|
|
27118
28210
|
parts.push(await fsp14.readFile(f, "utf8"));
|
|
27119
28211
|
} catch (e) {
|
|
27120
|
-
throw new
|
|
27121
|
-
code:
|
|
28212
|
+
throw new CliError67({
|
|
28213
|
+
code: CliErrorCode66.OFFLINE_KIT_ERROR,
|
|
27122
28214
|
message: `\u4FE1\u4EFB\u8FC7\u7684\u8BC1\u4E66\u6587\u4EF6 ${f} \u8BFB\u4E0D\u4E86\uFF08${e.code ?? e.message}\uFF09`,
|
|
27123
28215
|
context: { reasonCode: "trust-file-missing", nextStep: "\u8DD1 `hcm offline setup --from <\u5B89\u88C5\u76EE\u5F55> --step llm` \u91CD\u65B0\u8FDE\u4E00\u6B21\uFF0C\u63D0\u95EE\u8BC1\u4E66\u65F6\u7B54 y \u5C31\u4F1A\u91CD\u65B0\u5B58\u4E0B\u6765" }
|
|
27124
28216
|
});
|
|
@@ -27493,7 +28585,7 @@ function defaultKitHome(p, env2 = process.env) {
|
|
|
27493
28585
|
}
|
|
27494
28586
|
var resume = (step2) => `hcm offline setup --from <\u89E3\u538B\u76EE\u5F55> --step ${step2}`;
|
|
27495
28587
|
function kitError(message, step2, reasonCode, nextStep) {
|
|
27496
|
-
return new
|
|
28588
|
+
return new CliError68({ code: CliErrorCode67.OFFLINE_KIT_ERROR, message, context: { nextStep: nextStep ?? `\u5904\u7406\u597D\u540E\u8DD1 \`${resume(step2)}\` \u4ECE\u8FD9\u4E00\u6B65\u7EED\u88C5`, reasonCode } });
|
|
27497
28589
|
}
|
|
27498
28590
|
function readManifest(from) {
|
|
27499
28591
|
const file = path43.join(from, "manifest.json");
|
|
@@ -27576,7 +28668,7 @@ function interactive() {
|
|
|
27576
28668
|
return async (q, def) => {
|
|
27577
28669
|
if (!process.stdin.isTTY) {
|
|
27578
28670
|
if (def !== void 0) return def;
|
|
27579
|
-
throw new
|
|
28671
|
+
throw new CliError68({ code: CliErrorCode67.INVALID_ARGUMENT, message: `\u9700\u8981\u56DE\u7B54\u300C${q}\u300D\uFF0C\u4F46\u8FD9\u91CC\u4E0D\u662F\u7EC8\u7AEF`, context: { nextStep: "\u5728\u7EC8\u7AEF\u91CC\u8FD0\u884C\u5B89\u88C5\uFF0C\u6216\u7528 hcm offline setup --help \u91CC\u7684\u53C2\u6570\u76F4\u63A5\u7ED9\u51FA" } });
|
|
27580
28672
|
}
|
|
27581
28673
|
const ans = await promptText(def ? `${q} [${def}]\uFF1A` : `${q}\uFF1A`);
|
|
27582
28674
|
return ans || def || "";
|
|
@@ -27654,7 +28746,7 @@ function readdirNames(dir) {
|
|
|
27654
28746
|
}
|
|
27655
28747
|
var STEP_LABEL2 = { verify: "\u6821\u9A8C", install: "\u5B89\u88C5", path: "PATH", llm: "\u5927\u6A21\u578B", hcm: "HCM", finish: "\u6536\u5C3E" };
|
|
27656
28748
|
function asStepError(e, step2) {
|
|
27657
|
-
if (e instanceof
|
|
28749
|
+
if (e instanceof CliError68) return e;
|
|
27658
28750
|
const code2 = e?.code;
|
|
27659
28751
|
const hint = code2 === "EPERM" || code2 === "EBUSY" || code2 === "EACCES" ? "\u5173\u6389 crush\u3001\u777F\u620E\u7EC8\u7AEF\u7A97\u53E3\u548C\u505C\u5728\u5B89\u88C5\u76EE\u5F55\u91CC\u7684\u8D44\u6E90\u7BA1\u7406\u5668\u7A97\u53E3\uFF08\u6740\u6BD2\u8F6F\u4EF6\u62E6\u622A\u65F6\u628A\u5B89\u88C5\u76EE\u5F55\u52A0\u5165\u767D\u540D\u5355\uFF09\u540E\uFF0C" : code2 === "ENOSPC" ? "\u817E\u51FA\u78C1\u76D8\u7A7A\u95F4\u540E\uFF0C" : "\u5904\u7406\u597D\u540E\uFF0C";
|
|
27660
28752
|
return kitError(
|
|
@@ -27683,7 +28775,7 @@ async function runSteps(opts, deps, cur) {
|
|
|
27683
28775
|
const from = path43.resolve(opts.from);
|
|
27684
28776
|
const start = opts.step ?? "verify";
|
|
27685
28777
|
if (!SETUP_STEPS.includes(start)) {
|
|
27686
|
-
throw new
|
|
28778
|
+
throw new CliError68({ code: CliErrorCode67.INVALID_ARGUMENT, message: `--step \u53EA\u80FD\u662F ${SETUP_STEPS.join(" / ")}\uFF0C\u6536\u5230\u300C${opts.step}\u300D`, context: { nextStep: resume("verify") } });
|
|
27687
28779
|
}
|
|
27688
28780
|
const at = (s) => SETUP_STEPS.indexOf(s) >= SETUP_STEPS.indexOf(start);
|
|
27689
28781
|
const m = readManifest(from);
|
|
@@ -27757,7 +28849,7 @@ async function runSteps(opts, deps, cur) {
|
|
|
27757
28849
|
try {
|
|
27758
28850
|
log(` \u5DF2\u52A0\u5230 ${await add(p, kitBin)}`);
|
|
27759
28851
|
} catch (e) {
|
|
27760
|
-
if (!(e instanceof
|
|
28852
|
+
if (!(e instanceof CliError68)) throw e;
|
|
27761
28853
|
notes.push(`${e.message}\uFF1B${e.context?.nextStep ?? ""}`);
|
|
27762
28854
|
log(" \u6CA1\u52A0\u4E0A\uFF0C\u7EE7\u7EED\u5F80\u4E0B\u88C5\uFF08\u7ED3\u675F\u65F6\u6709\u63D0\u793A\uFF09");
|
|
27763
28855
|
}
|
|
@@ -27803,7 +28895,7 @@ async function runSteps(opts, deps, cur) {
|
|
|
27803
28895
|
log(` \u6A21\u578B ${llm2.model}\uFF0C\u4E0A\u4E0B\u6587 ${llm2.contextWindow}${progress.ctxSource === "default" ? "\uFF08\u6A21\u578B\u670D\u52A1\u6CA1\u62A5\uFF0C\u6309\u9ED8\u8BA4\uFF09" : ""}\uFF0C\u5355\u6B21\u8F93\u51FA\u4E0A\u9650 ${llm2.maxTokens}\uFF08\u9ED8\u8BA4\uFF09`);
|
|
27804
28896
|
const tool = await probeToolCall(baseUrl, key2, llm2.model, ca);
|
|
27805
28897
|
if (!tool.ok) {
|
|
27806
|
-
throw new
|
|
28898
|
+
throw new CliError68({ code: CliErrorCode67.LLM_PROBE_UNAVAILABLE, message: `\u6A21\u578B ${llm2.model} \u4E0D\u80FD\u8C03\u7528\u5DE5\u5177\uFF0C\u777F\u620E\u9760\u5B83\u6267\u884C\u547D\u4EE4\uFF1A${tool.reason}`, context: { nextStep: TOOL_CALL_HELP, reasonCode: "no-tool-call" } });
|
|
27807
28899
|
}
|
|
27808
28900
|
log(" \u5DE5\u5177\u8C03\u7528\uFF1A\u901A\u8FC7");
|
|
27809
28901
|
const backup = await writeCrushConfig(home, renderCrushConfig({ ...llm2, apiKey: key2 }));
|
|
@@ -27951,7 +29043,7 @@ import { createHash as createHash11 } from "crypto";
|
|
|
27951
29043
|
import { createReadStream as createReadStream2, existsSync as existsSync20, promises as fsp16 } from "fs";
|
|
27952
29044
|
import os12 from "os";
|
|
27953
29045
|
import path44 from "path";
|
|
27954
|
-
import { CliError as
|
|
29046
|
+
import { CliError as CliError69, CliErrorCode as CliErrorCode68 } from "@hcmai/sdk";
|
|
27955
29047
|
init_outbox();
|
|
27956
29048
|
init_state();
|
|
27957
29049
|
var EXPORT_MANIFEST = "export.json";
|
|
@@ -28030,8 +29122,8 @@ async function runOfflineExport(opts = {}) {
|
|
|
28030
29122
|
`));
|
|
28031
29123
|
const state = readOfflineState();
|
|
28032
29124
|
if (!state?.kitHome) {
|
|
28033
|
-
throw new
|
|
28034
|
-
code:
|
|
29125
|
+
throw new CliError69({
|
|
29126
|
+
code: CliErrorCode68.OFFLINE_KIT_ERROR,
|
|
28035
29127
|
message: "\u8FD9\u53F0\u7535\u8111\u4E0D\u662F\u79BB\u7EBF\u5B89\u88C5\u5305\u88C5\u7684\uFF08\u6CA1\u6709 ~/.config/hcm/offline.json \u6216\u91CC\u9762\u6CA1\u6709\u5B89\u88C5\u76EE\u5F55\uFF09\uFF0C\u6CA1\u6709\u5F85\u4EA4\u961F\u5217\u53EF\u5BFC\u51FA",
|
|
28036
29128
|
context: { nextStep: "\u5728\u88C5\u4E86\u79BB\u7EBF\u5305\u7684\u90A3\u53F0\u5BA2\u6237\u7535\u8111\u4E0A\u8DD1 `hcm offline export`", reasonCode: "export-not-offline" }
|
|
28037
29129
|
});
|
|
@@ -28042,8 +29134,8 @@ async function runOfflineExport(opts = {}) {
|
|
|
28042
29134
|
try {
|
|
28043
29135
|
listing = await listOutbox(outboxDirOf(state.kitHome));
|
|
28044
29136
|
} catch (e) {
|
|
28045
|
-
throw new
|
|
28046
|
-
code:
|
|
29137
|
+
throw new CliError69({
|
|
29138
|
+
code: CliErrorCode68.OFFLINE_KIT_ERROR,
|
|
28047
29139
|
message: `\u5F85\u4EA4\u961F\u5217\u8BFB\u4E0D\u4E86\uFF08${e.code ?? e.message}\uFF09\uFF0C\u6CA1\u6709\u5BFC\u51FA`,
|
|
28048
29140
|
context: { nextStep: `\u68C0\u67E5 ${outboxDirOf(state.kitHome)} \u7684\u6743\u9650\u540E\u91CD\u8DD1`, reasonCode: "outbox-unreadable" }
|
|
28049
29141
|
});
|
|
@@ -28057,8 +29149,8 @@ async function runOfflineExport(opts = {}) {
|
|
|
28057
29149
|
const files = projectDir && !projectReason ? await projectFiles(projectDir) : [];
|
|
28058
29150
|
const carry = includeExported ? [...listing.pending, ...listing.exported].sort((a, b) => a.seq - b.seq) : listing.pending;
|
|
28059
29151
|
if (!carry.length && !files.length) {
|
|
28060
|
-
throw new
|
|
28061
|
-
code:
|
|
29152
|
+
throw new CliError69({
|
|
29153
|
+
code: CliErrorCode68.INVALID_ARGUMENT,
|
|
28062
29154
|
message: `\u6CA1\u6709\u53EF\u5E26\u51FA\u7684\uFF1A\u5F85\u4EA4\u961F\u5217\u662F\u7A7A\u7684\uFF08\u4EE5\u524D\u5BFC\u51FA\u8FC7 ${listing.exported.length} \u6761${listing.exported.length ? "\uFF0C\u8981\u518D\u5E26\u7528 --include-exported" : ""}\uFF09${projectReason ? `\uFF0C\u9879\u76EE\u4E5F\u4E0D\u5E26\uFF08${projectReason}\uFF09` : "\uFF0C\u9879\u76EE\u76EE\u5F55\u91CC\u4E5F\u6CA1\u6709\u6587\u4EF6"}`,
|
|
28063
29155
|
context: { nextStep: "\u79BB\u7EBF\u65F6\u63D0\u7684\u7F3A\u53E3 / \u6848\u4F8B\uFF08hcm chiron gap submit\u3001case submit\uFF09\u4F1A\u8FDB\u5F85\u4EA4\u961F\u5217\uFF0C\u6709\u4E86\u518D\u5BFC\u51FA", reasonCode: "export-empty" }
|
|
28064
29156
|
});
|
|
@@ -28162,7 +29254,7 @@ init_exit();
|
|
|
28162
29254
|
import { createHash as createHash12 } from "crypto";
|
|
28163
29255
|
import { createReadStream as createReadStream3, existsSync as existsSync21, promises as fsp18 } from "fs";
|
|
28164
29256
|
import path46 from "path";
|
|
28165
|
-
import { CliError as
|
|
29257
|
+
import { CliError as CliError70, CliErrorCode as CliErrorCode69, hcmConfigDir as hcmConfigDir3 } from "@hcmai/sdk";
|
|
28166
29258
|
|
|
28167
29259
|
// src/commands/offline/unzip.ts
|
|
28168
29260
|
import { createWriteStream as createWriteStream2, promises as fsp17 } from "fs";
|
|
@@ -28228,8 +29320,8 @@ async function extractZipSafe(file, dest) {
|
|
|
28228
29320
|
|
|
28229
29321
|
// src/commands/offline/flush.ts
|
|
28230
29322
|
init_outbox();
|
|
28231
|
-
function flushError(message, nextStep, reasonCode, code2 =
|
|
28232
|
-
return new
|
|
29323
|
+
function flushError(message, nextStep, reasonCode, code2 = CliErrorCode69.INVALID_ARGUMENT) {
|
|
29324
|
+
return new CliError70({ code: code2, message, context: { nextStep, reasonCode } });
|
|
28233
29325
|
}
|
|
28234
29326
|
var sha256File3 = (f) => new Promise((resolve8, reject) => {
|
|
28235
29327
|
const h = createHash12("sha256");
|
|
@@ -28288,7 +29380,7 @@ async function readLedger(dir) {
|
|
|
28288
29380
|
`\u8865\u4EA4\u603B\u8D26\u91CC\u7684 ${file} \u8BFB\u4E0D\u61C2\uFF08${e.message.split("\n")[0]}\uFF09\uFF0C\u6CA1\u6709\u8865\u4EA4`,
|
|
28289
29381
|
`\u5148\u770B\u4E00\u773C\u5B83\uFF08\u91CC\u9762\u662F\u4EA4\u8FC7\u7684\u5355\u53F7 / PR \u53F7\uFF09\uFF1B\u786E\u8BA4\u4E0D\u8981\u4E86\u628A\u5B83\u6539\u540D\u632A\u51FA ${dir} \u518D\u91CD\u8DD1\uFF08\u522B\u5220\uFF1A\u5220\u4E86\u5C31\u8BA4\u4E0D\u51FA\u90A3\u4E00\u6761\u4EA4\u8FC7\uFF09`,
|
|
28290
29382
|
"flush-ledger-corrupt",
|
|
28291
|
-
|
|
29383
|
+
CliErrorCode69.OFFLINE_KIT_ERROR
|
|
28292
29384
|
);
|
|
28293
29385
|
}
|
|
28294
29386
|
}
|
|
@@ -28544,7 +29636,7 @@ import { X509Certificate as X509Certificate2 } from "crypto";
|
|
|
28544
29636
|
import { existsSync as existsSync22, lstatSync, readdirSync as readdirSync7, readFileSync as readFileSync21, realpathSync as realpathSync2, rmSync as rmSync3, promises as fsp19 } from "fs";
|
|
28545
29637
|
import os13 from "os";
|
|
28546
29638
|
import path48 from "path";
|
|
28547
|
-
import { CliError as
|
|
29639
|
+
import { CliError as CliError71, CliErrorCode as CliErrorCode70, hcmConfigDir as hcmConfigDir4 } from "@hcmai/sdk";
|
|
28548
29640
|
init_outbox();
|
|
28549
29641
|
init_state();
|
|
28550
29642
|
async function scanIdentities(configDir) {
|
|
@@ -28591,7 +29683,7 @@ var realOrSelf = (p) => {
|
|
|
28591
29683
|
}
|
|
28592
29684
|
};
|
|
28593
29685
|
function uninstallError(message, reasonCode, nextStep) {
|
|
28594
|
-
return new
|
|
29686
|
+
return new CliError71({ code: CliErrorCode70.OFFLINE_KIT_ERROR, message, context: { reasonCode, nextStep } });
|
|
28595
29687
|
}
|
|
28596
29688
|
function isKitHome(dir) {
|
|
28597
29689
|
try {
|
|
@@ -29288,8 +30380,10 @@ ${DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key_field.description}
|
|
|
29288
30380
|
${DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key.description}
|
|
29289
30381
|
\u5B8C\u6574\u5B89\u88C5\u5305 manifest \u7684 models[].keys \u7531 hcm package install \u5904\u7406\u3002
|
|
29290
30382
|
`).action((p, opts) => importCommand(p, opts));
|
|
29291
|
-
program.command("
|
|
29292
|
-
program.command("
|
|
30383
|
+
program.command("introspect [capability]").description("\u81EA\u7701\u9762\u5165\u53E3\u7D22\u5F15\uFF1A\u73AF\u5883\u91CC\u6709\u54EA\u4E9B\u81EA\u7701\u7AEF\u70B9\u3001\u5404\u7B54\u4EC0\u4E48\u95EE\u9898\u3001\u6709\u4EC0\u4E48\u76F2\u533A\u3001CLI \u7528\u54EA\u6761\u547D\u4EE4\uFF08\u53EA\u8BFB\uFF09").option("--detail", "\u5168\u91CF\u660E\u7EC6\u5C42\uFF08\u4E00\u6B21\u53EF\u80FD\u5F88\u957F\uFF1B\u53EA\u8981\u67D0\u4E00\u683C\u5C31\u76F4\u63A5 hcm introspect <path>\uFF09").option("--limit <n>", "\u6700\u591A\u8FD4\u56DE\u51E0\u683C\uFF08\u670D\u52A1\u7AEF\u6536\u655B\u5230\u8FB9\u754C\u5E76\u5728 truncatedBy \u91CC\u8BF4\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").addHelpText("after", "\n\u4E0D\u5E26\u53C2\u6570\u662F\u6458\u8981\u5C42\uFF1Bcapability \u7167\u6458\u8981\u5C42\u7684 path \u539F\u6837\u6284\uFF08\u542B {model} \u8FD9\u7C7B\u6A21\u677F\u6BB5\uFF09\uFF0C\u7ED9\u51FA\u90A3\u4E00\u683C\u7684\u76F2\u533A\u660E\u7EC6\u4E0E\u5165\u53C2\u81EA\u8FF0\u3002\n\u670D\u52A1\u7AEF\u7ED9\u7684\u4E0B\u4E00\u8DF3\uFF08REST \u5F62\u6001\uFF09\u4F1A\u6362\u6210 hcm \u5199\u6CD5\u518D\u6253\uFF1B\u6807\u300CCLI \u672A\u63D0\u4F9B\u300D\u7684\u683C\u4ECA\u5929\u53EA\u80FD\u7ECF REST \u53D6\uFF0C\u5B88\u4EA4\u4ED8\u8FB9\u754C\u65F6\u5230\u8FD9\u91CC\u505C\u4E0B\u95EE\u4EBA\u3002\n").action((capability, opts) => introspectCommand(capability, opts));
|
|
30384
|
+
program.command("models [keyword]").description("\u5217\u51FA\u76EE\u6807\u73AF\u5883\u6709\u54EA\u4E9B Model\uFF08describe \u7684\u4E0A\u4E00\u6B65\uFF09\uFF1B\u53EF\u5E26\u5173\u952E\u5B57\u8FC7\u6EE4\uFF0C--search \u6309\u5BA2\u6237\u8BF4\u6CD5\u68C0\u7D22\u5E76\u7ED9\u547D\u4E2D\u8BC1\u636E").option("--search", "\u6309\u8BF4\u6CD5\u68C0\u7D22\uFF08\u540C\u4E49\u8BCD / \u7528\u9014 / \u5B57\u6BB5\u6807\u7B7E / \u679A\u4E3E\u6807\u7B7E\u7B49\u516B\u7EF4\u52A0\u6743\uFF09\uFF0C\u6BCF\u4E2A\u5019\u9009\u5E26\u547D\u4E2D\u8BC1\u636E\u4E0E\u964D\u7EA7\u6876").option("--limit <n>", "\u914D\u5408 --search\uFF1A\u6700\u591A\u8FD4\u56DE\u51E0\u4E2A\u5019\u9009\uFF08\u670D\u52A1\u7AEF\u9ED8\u8BA4 10\uFF0C\u4E0A\u9650 100\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((keyword, opts) => modelsCommand(keyword, opts));
|
|
30385
|
+
program.command("describe <Model>").description("\u67E5\u770B Model \u5143\u6570\u636E\uFF08\u5B57\u6BB5\u3001\u5173\u7CFB\u3001Action \u5217\u8868\u4E0E\u5404\u81EA\u7684 effect / \u6388\u6743\u6863\u4F4D\u3001\u901A\u7528\u589E\u5220\u6539\u80FD\u4E0D\u80FD\u7528\uFF09").option("-v, --verbose", "\u663E\u793A enum \u53D6\u503C\u57DF\u3001\u81EA\u5B9A\u4E49\u5B57\u6BB5\u7684\u63CF\u8FF0\uFF0C\u4EE5\u53CA action \u7684\u5916\u90E8\u4F9D\u8D56 / \u654F\u611F\u6570\u636E / \u786E\u8BA4\u8981\u6C42").option("--state <\u89C6\u56FE>", "Action \u96C6\u6309\u54EA\u4E2A\u89C6\u56FE\uFF08state\uFF09\u53D6\uFF1B\u4E0D\u7ED9 = \u9ED8\u8BA4\u89C6\u56FE\uFF08Action \u96C6\u53EA\u5BF9\u4E00\u4E2A\u89C6\u56FE\u6210\u7ACB\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => describeCommand(m, opts));
|
|
30386
|
+
program.command("preset-origin <Model>").description("\u9884\u7F6E\u6A21\u578B\u7684\u884C\u6765\u6E90\uFF1A\u8981\u6539\u7684\u90A3\u4E00\u884C\u662F\u5E73\u53F0\u57FA\u7EBF\u3001\u79DF\u6237\u8986\u76D6\u8FD8\u662F\u79DF\u6237\u81EA\u5DF1\u5EFA\u7684\uFF08\u53EA\u8BFB\uFF09").option("--id <canonicalId>", "\u95EE\u67D0\u4E00\u884C\uFF08UUID\uFF09\u843D\u5728\u54EA\u4E00\u4FA7\u3001resetToDefault \u7ED3\u6784\u4E0A\u9002\u4E0D\u9002\u7528").option("--include-tenant-ids", "\u4E00\u6B21\u62FF\u5168\u79DF\u6237\u8986\u76D6 / \u79DF\u6237\u539F\u521B\u90A3\u51E0\u884C\u7684 id\uFF0C\u5E76\u4E0E\u8BA1\u6570\u5BF9\u8D26").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => presetOriginCommand(m, opts));
|
|
29293
30387
|
var interactions = program.command("interactions").description("\u770B\u89C1\u5E76\u5904\u7406\u4F1A\u8BDD\u91CC\u672A\u51B3\u7684\u6682\u505C\uFF08\u786E\u8BA4 / \u8FFD\u95EE\uFF09\u2014\u2014\u4E0D\u53D1\u65B0\u6D88\u606F\uFF0C\u76F4\u63A5\u56DE\u5230\u90A3\u4E00\u6761");
|
|
29294
30388
|
var withInteractionCommonOpts = (cmd) => {
|
|
29295
30389
|
cmd.option("--conversation <id>", "\u76EE\u6807\u4F1A\u8BDD\uFF1B\u4E0D\u4F20\u5219\u7528\u672C env \u4E0A\u4E00\u6B21\u804A\u7684\u90A3\u4E2A").option("--agent <uuid>", "\u6307\u5B9A agent UUID\uFF08\u9ED8\u8BA4\u5185\u7F6E analyst\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atext | json", "text");
|
|
@@ -29378,6 +30472,11 @@ script.command("dry-run").description("\u53EA\u8BFB\u8BD5\u8FD0\u884C\u4E91\u51F
|
|
|
29378
30472
|
script.command("manifest-validate").description("\u6821\u9A8C\u6269\u5C55\u5305 manifest.yml").requiredOption("--file <path>", "manifest.yml \u8DEF\u5F84").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => scriptManifestValidateCommand(opts));
|
|
29379
30473
|
script.command("logs").description("\u67E5\u540C\u6B65\u6267\u884C\u65E5\u5FD7\uFF08\u5206\u9875\uFF09").option("--script-key <key>", "\u53EA\u770B\u67D0\u4E2A\u811A\u672C").option("--status <status>", "\u6309\u72B6\u6001\u8FC7\u6EE4").option("--mode <mode>", "\u6309 sync/async \u8FC7\u6EE4").option("--dry-run", "\u53EA\u770B dry-run \u8BB0\u5F55").option("--from <iso>", "\u8D77\u59CB\u65F6\u95F4\uFF08ISO 8601\uFF09").option("--to <iso>", "\u7ED3\u675F\u65F6\u95F4\uFF08ISO 8601\uFF09").option("--page <n>", "\u9875\u7801\uFF0C\u4ECE 0 \u5F00\u59CB").option("--size <n>", "\u6BCF\u9875\u6761\u6570").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => scriptLogsCommand(opts));
|
|
29380
30474
|
script.command("task <taskId>").description("\u67E5\u5F02\u6B65\u4EFB\u52A1\uFF1A\u72B6\u6001\u3001\u91CD\u8BD5\u6B21\u6570\u3001\u6700\u7EC8\u7ED3\u679C\u4E0E\u9519\u8BEF").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((taskId, opts) => scriptTaskCommand(taskId, opts));
|
|
30475
|
+
var subscriptionMigration = program.command("subscription-migration").description("\u8BA2\u9605\u8FC1\u79FB\uFF1A\u5148\u5E72\u8DD1\u51BB\u7ED3\u8BA1\u5212\uFF0C\u518D\u663E\u5F0F\u5199\u56DE\uFF1B\u5907\u4EFD\u539F\u6587\u53EF\u6309\u8BB0\u5F55\u6062\u590D");
|
|
30476
|
+
for (const operation of ["dry-run", "apply", "restore"]) {
|
|
30477
|
+
subscriptionMigration.command(operation).description({ "dry-run": "\u53EA\u8BFB\u626B\u63CF\uFF0C\u53EF\u7528 --data @\u6587\u4EF6\u63D0\u4EA4 revisions \u4EBA\u5DE5\u7A3F", apply: "\u6309\u5B8C\u6574\u51BB\u7ED3\u8BA1\u5212\u5907\u4EFD\u540E\u5199\u56DE", restore: "\u8FD8\u539F\u5907\u4EFD\uFF0C\u62D2\u7EDD\u8986\u76D6\u540E\u7EED\u4FEE\u6539" }[operation]).option("--env <name>", "\u672C\u5730\u90E8\u7F72\u670D\u52A1\u7684\u73AF\u5883\u540D").option("--as <identity>", "\u5F53\u524D\u79DF\u6237\u7CFB\u7EDF\u7BA1\u7406\u5458\u8EAB\u4EFD").option("--data <json>", "JSON \u8BF7\u6C42\u5BF9\u8C61\u6216 @\u6587\u4EF6").option("--dry-run-task-id <id>", "apply \u4F7F\u7528\u7684 dry-run \u4EFB\u52A1 ID").option("--task-id <id>", "restore \u4F7F\u7528\u7684\u5199\u56DE\u4EFB\u52A1 ID").option("--record-ids <ids>", "\u9017\u53F7\u5206\u9694\u7684\u7269\u7406\u8BB0\u5F55 ID").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Ajson", "json").action((opts) => subscriptionMigrationCommand(operation, opts));
|
|
30478
|
+
}
|
|
30479
|
+
subscriptionMigration.command("status <taskId>").description("\u67E5\u770B\u540E\u53F0\u4EFB\u52A1\u4E0E\u5B8C\u6574\u8FC1\u79FB\u62A5\u544A\uFF0C\u672A\u77E5\u8BA1\u6570\u4FDD\u7559 null \u4E0E\u539F\u56E0").option("--env <name>", "\u672C\u5730\u90E8\u7F72\u670D\u52A1\u7684\u73AF\u5883\u540D").option("--as <identity>", "\u5F53\u524D\u79DF\u6237\u7CFB\u7EDF\u7BA1\u7406\u5458\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Ajson", "json").action((taskId, opts) => subscriptionMigrationCommand("status", { ...opts, taskId }));
|
|
29381
30480
|
var cache = program.command("cache").description("\u6A21\u578B\u7F13\u5B58\u8FD0\u7EF4\uFF08Caffeine \u672C\u5730 + Redis \u8FDC\u7A0B\uFF0C\u987B\u8D70 API\uFF09");
|
|
29382
30481
|
cache.command("stats <Model>").description("\u67E5\u770B\u6A21\u578B\u7F13\u5B58\u7EDF\u8BA1").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((model, opts) => cacheStatsCommand(model, opts));
|
|
29383
30482
|
cache.command("clear <Model>").description("\u6E05\u6A21\u578B\u5B9E\u4F53\u7F13\u5B58\uFF08\u5E42\u7B49\uFF0C\u4E0D\u7834\u574F\u6570\u636E\uFF09").option("--id <id>", "\u53EA\u6E05\u5355\u6761\uFF08\u9ED8\u8BA4\u6E05\u5168\u90E8\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((model, opts) => cacheClearCommand(model, opts));
|