@hcmai/cli 0.4.4 → 0.4.5

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 CHANGED
@@ -2286,9 +2286,9 @@ async function loginCommand(args) {
2286
2286
  } catch (e) {
2287
2287
  const err = e;
2288
2288
  if (err.isAxiosError) {
2289
- const { fromAxiosError: fromAxiosError21 } = await import("@hcmai/sdk");
2289
+ const { fromAxiosError: fromAxiosError22 } = await import("@hcmai/sdk");
2290
2290
  exitWithError(
2291
- fromAxiosError21(
2291
+ fromAxiosError22(
2292
2292
  e,
2293
2293
  envName
2294
2294
  )
@@ -3211,29 +3211,29 @@ import {
3211
3211
  import chalk2 from "chalk";
3212
3212
  import * as fs4 from "fs/promises";
3213
3213
  function parseInjectOn(s) {
3214
- const fail5 = (detail) => {
3214
+ const fail6 = (detail) => {
3215
3215
  throw new CliError13({
3216
3216
  code: CliErrorCode12.INVALID_ARGUMENT,
3217
3217
  message: `--inject-on \u683C\u5F0F <eventType>:<action>[:<arg>]\uFF0Caction \u2208 {interrupt, steer}\uFF08steer \u5FC5\u987B\u5E26 content\uFF09\uFF1B${detail}\uFF0C\u6536\u5230 "${s}"`
3218
3218
  });
3219
3219
  };
3220
3220
  const firstColon = s.indexOf(":");
3221
- if (firstColon < 0) return fail5("\u7F3A\u5C11 action \u6BB5");
3221
+ if (firstColon < 0) return fail6("\u7F3A\u5C11 action \u6BB5");
3222
3222
  const eventType = s.slice(0, firstColon);
3223
3223
  const rest = s.slice(firstColon + 1);
3224
3224
  const secondColon = rest.indexOf(":");
3225
3225
  const action = secondColon < 0 ? rest : rest.slice(0, secondColon);
3226
3226
  const arg = secondColon < 0 ? void 0 : rest.slice(secondColon + 1);
3227
- if (!eventType) return fail5("eventType \u6BB5\u4E3A\u7A7A");
3227
+ if (!eventType) return fail6("eventType \u6BB5\u4E3A\u7A7A");
3228
3228
  if (action === "interrupt") {
3229
- if (arg !== void 0) return fail5("interrupt \u4E0D\u63A5\u53D7 arg");
3229
+ if (arg !== void 0) return fail6("interrupt \u4E0D\u63A5\u53D7 arg");
3230
3230
  return { eventType, action: "interrupt" };
3231
3231
  }
3232
3232
  if (action === "steer") {
3233
- if (arg === void 0 || arg === "") return fail5("steer \u5FC5\u987B\u5E26 content\uFF08arg\uFF09");
3233
+ if (arg === void 0 || arg === "") return fail6("steer \u5FC5\u987B\u5E26 content\uFF08arg\uFF09");
3234
3234
  return { eventType, action: "steer", arg };
3235
3235
  }
3236
- return fail5(`\u672A\u77E5 action "${action}"`);
3236
+ return fail6(`\u672A\u77E5 action "${action}"`);
3237
3237
  }
3238
3238
  function parseOnConfirm(s) {
3239
3239
  if (s === "approve") return { decision: "approve" };
@@ -4258,20 +4258,131 @@ async function cacheClearMetaCommand(model, args) {
4258
4258
  }
4259
4259
  }
4260
4260
 
4261
- // src/commands/upload.ts
4261
+ // src/commands/script.ts
4262
4262
  init_exit();
4263
4263
  init_auth_guard();
4264
+ import { readFileSync as readFileSync3 } from "fs";
4264
4265
  import {
4265
4266
  HcmClient as HcmClient14,
4266
4267
  formatObject as formatObject12,
4267
4268
  fromAxiosError as fromAxiosError12,
4269
+ scriptDryRun,
4270
+ validateScriptManifest,
4271
+ queryScriptLogs,
4272
+ getScriptTask
4273
+ } from "@hcmai/sdk";
4274
+ async function withClient2(args, fn) {
4275
+ const client3 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
4276
+ return fn(client3);
4277
+ }
4278
+ function emit2(result, args, human) {
4279
+ const fmt = args.output ?? "json";
4280
+ if (fmt !== "json") process.stdout.write(human + "\n");
4281
+ process.stdout.write(formatObject12(result, { format: fmt }) + "\n");
4282
+ process.exit(0);
4283
+ }
4284
+ function fail3(e, args) {
4285
+ const err = e;
4286
+ if (err?.isAxiosError) exitWithError(fromAxiosError12(err, args.env));
4287
+ exitWithError(e);
4288
+ process.exit(1);
4289
+ }
4290
+ function parseJsonArg(raw, field) {
4291
+ if (raw === void 0) return void 0;
4292
+ try {
4293
+ const parsed = JSON.parse(raw);
4294
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
4295
+ throw new Error(`${field} \u5FC5\u987B\u662F JSON \u5BF9\u8C61\uFF0C\u5B9E\u9645\u662F ${Array.isArray(parsed) ? "\u6570\u7EC4" : typeof parsed}`);
4296
+ }
4297
+ return parsed;
4298
+ } catch (e) {
4299
+ throw new Error(`--${field} \u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61\uFF1A${e.message}
4300
+ \u6536\u5230\uFF1A${raw}`);
4301
+ }
4302
+ }
4303
+ async function scriptDryRunCommand(args) {
4304
+ try {
4305
+ if (!args.scriptKey) {
4306
+ throw new Error("\u7F3A\u5C11 --script-key\n \u4E0B\u4E00\u6B65\uFF1Ahcm script dry-run --script-key <scriptKey>");
4307
+ }
4308
+ if (args.params && args.paramsFile) {
4309
+ throw new Error("--params \u4E0E --params-file \u4E92\u65A5\uFF0C\u4E8C\u9009\u4E00");
4310
+ }
4311
+ const rawParams = args.paramsFile ? readFileSync3(args.paramsFile, "utf8") : args.params;
4312
+ const request = {
4313
+ scriptKey: args.scriptKey,
4314
+ modelKey: args.model,
4315
+ actionKey: args.action,
4316
+ scope: args.scope,
4317
+ httpMethod: args.method,
4318
+ targetId: args.targetId,
4319
+ params: parseJsonArg(rawParams, "params"),
4320
+ context: parseJsonArg(args.context, "context"),
4321
+ event: parseJsonArg(args.event, "event"),
4322
+ timeoutMs: args.timeout ? Number(args.timeout) : void 0
4323
+ };
4324
+ const result = await withClient2(args, (c) => scriptDryRun(c.raw(), request));
4325
+ const intents = Array.isArray(result?.writeIntents) ? result.writeIntents.length : 0;
4326
+ emit2(result, args, `\u{1F9EA} dry-run \u5B8C\u6210\uFF1A${args.scriptKey}\uFF08\u62E6\u4E0B ${intents} \u4E2A\u5199\u610F\u56FE\uFF09`);
4327
+ } catch (e) {
4328
+ fail3(e, args);
4329
+ }
4330
+ }
4331
+ async function scriptManifestValidateCommand(args) {
4332
+ try {
4333
+ if (!args.file) {
4334
+ throw new Error("\u7F3A\u5C11 --file\n \u4E0B\u4E00\u6B65\uFF1Ahcm script manifest-validate --file ./manifest.yml");
4335
+ }
4336
+ const yaml = readFileSync3(args.file, "utf8");
4337
+ const result = await withClient2(args, (c) => validateScriptManifest(c.raw(), yaml));
4338
+ emit2(result, args, `\u{1F4CB} manifest \u6821\u9A8C\u5B8C\u6210\uFF1A${args.file}`);
4339
+ } catch (e) {
4340
+ fail3(e, args);
4341
+ }
4342
+ }
4343
+ async function scriptLogsCommand(args) {
4344
+ try {
4345
+ const page = await withClient2(
4346
+ args,
4347
+ (c) => queryScriptLogs(c.raw(), {
4348
+ scriptKey: args.scriptKey,
4349
+ status: args.status,
4350
+ mode: args.mode,
4351
+ dryRun: args.dryRun,
4352
+ from: args.from,
4353
+ to: args.to,
4354
+ page: args.page ? Number(args.page) : void 0,
4355
+ size: args.size ? Number(args.size) : void 0
4356
+ })
4357
+ );
4358
+ emit2(page, args, "\u{1F4DC} \u811A\u672C\u6267\u884C\u65E5\u5FD7");
4359
+ } catch (e) {
4360
+ fail3(e, args);
4361
+ }
4362
+ }
4363
+ async function scriptTaskCommand(taskId, args) {
4364
+ try {
4365
+ const task = await withClient2(args, (c) => getScriptTask(c.raw(), taskId));
4366
+ emit2(task, args, `\u2699\uFE0F \u4EFB\u52A1 ${taskId}\uFF1A${task?.status ?? "\u672A\u77E5"}\uFF08\u7B2C ${task?.attempts ?? "?"}/${task?.maxAttempts ?? "?"} \u6B21\uFF09`);
4367
+ } catch (e) {
4368
+ fail3(e, args);
4369
+ }
4370
+ }
4371
+
4372
+ // src/commands/upload.ts
4373
+ init_exit();
4374
+ init_auth_guard();
4375
+ import {
4376
+ HcmClient as HcmClient15,
4377
+ formatObject as formatObject13,
4378
+ fromAxiosError as fromAxiosError13,
4268
4379
  uploadDocument as uploadDocument2
4269
4380
  } from "@hcmai/sdk";
4270
4381
  var DEFAULT_UPLOAD_CATEGORY = "attachment";
4271
4382
  async function uploadCommand(filePath, args) {
4272
4383
  try {
4273
4384
  const ctx = await getActiveAuthContextFromCli(args);
4274
- const client3 = HcmClient14.fromAuthContext(ctx);
4385
+ const client3 = HcmClient15.fromAuthContext(ctx);
4275
4386
  const meta2 = await uploadDocument2(
4276
4387
  client3.raw(),
4277
4388
  filePath,
@@ -4284,7 +4395,7 @@ async function uploadCommand(filePath, args) {
4284
4395
  `
4285
4396
  );
4286
4397
  }
4287
- process.stdout.write(formatObject12(meta2, { format: fmt }) + "\n");
4398
+ process.stdout.write(formatObject13(meta2, { format: fmt }) + "\n");
4288
4399
  process.exit(0);
4289
4400
  } catch (e) {
4290
4401
  const err = e;
@@ -4294,7 +4405,7 @@ async function uploadCommand(filePath, args) {
4294
4405
  } else if (status === 413) {
4295
4406
  exitWithError(new Error("\u6587\u4EF6\u8D85\u51FA\u670D\u52A1\u7AEF\u5927\u5C0F\u4E0A\u9650\uFF08413\uFF09"));
4296
4407
  } else if (err?.isAxiosError) {
4297
- exitWithError(fromAxiosError12(err, args.env));
4408
+ exitWithError(fromAxiosError13(err, args.env));
4298
4409
  } else {
4299
4410
  exitWithError(e);
4300
4411
  }
@@ -4322,8 +4433,8 @@ import {
4322
4433
  resolveAllSkillsInstallOrder,
4323
4434
  matchSkills,
4324
4435
  filterByStage,
4325
- formatObject as formatObject14,
4326
- fromAxiosError as fromAxiosError13,
4436
+ formatObject as formatObject15,
4437
+ fromAxiosError as fromAxiosError14,
4327
4438
  loadEnv as loadEnv5,
4328
4439
  loadGlobalConfig as loadGlobalConfig6,
4329
4440
  resolveActiveEnv as resolveActiveEnv3,
@@ -4450,11 +4561,11 @@ import * as path3 from "path";
4450
4561
  import { CliError as CliError15, CliErrorCode as CliErrorCode14, assertSafeReferencePath, parseSkillRequirements } from "@hcmai/sdk";
4451
4562
 
4452
4563
  // src/commands/skills-manifest.ts
4453
- import { readFileSync as readFileSync3, readdirSync as readdirSync2, statSync as statSync3, existsSync } from "fs";
4564
+ import { readFileSync as readFileSync4, readdirSync as readdirSync2, statSync as statSync3, existsSync } from "fs";
4454
4565
  import { createHash } from "crypto";
4455
4566
  import * as path2 from "path";
4456
4567
  import { fileURLToPath } from "url";
4457
- import { formatObject as formatObject13, parseSkillFrontmatter } from "@hcmai/sdk";
4568
+ import { formatObject as formatObject14, parseSkillFrontmatter } from "@hcmai/sdk";
4458
4569
  function collectCommandSurface(root) {
4459
4570
  const out = [];
4460
4571
  const walk = (cmd, prefix) => {
@@ -4495,11 +4606,11 @@ function collectBundledSkills(dir = bundledSkillsDir()) {
4495
4606
  if (!files.includes("SKILL.md")) continue;
4496
4607
  let bytes = 0;
4497
4608
  const fileRows = files.map((rel) => {
4498
- const buf = readFileSync3(path2.join(skillDir, rel));
4609
+ const buf = readFileSync4(path2.join(skillDir, rel));
4499
4610
  bytes += buf.byteLength;
4500
4611
  return { path: rel, bytes: buf.byteLength, sha256: sha256(buf) };
4501
4612
  });
4502
- const body = readFileSync3(path2.join(skillDir, "SKILL.md"), "utf8");
4613
+ const body = readFileSync4(path2.join(skillDir, "SKILL.md"), "utf8");
4503
4614
  const fm = parseSkillFrontmatter(body, id);
4504
4615
  out.push({
4505
4616
  id,
@@ -4525,7 +4636,7 @@ function buildManifest(root, skillsDir = bundledSkillsDir()) {
4525
4636
  }
4526
4637
  function skillsManifestCommand(root, args) {
4527
4638
  const manifest2 = buildManifest(root);
4528
- process.stdout.write(formatObject13(manifest2, { format: args.output ?? "json" }) + "\n");
4639
+ process.stdout.write(formatObject14(manifest2, { format: args.output ?? "json" }) + "\n");
4529
4640
  }
4530
4641
  function str(v) {
4531
4642
  return typeof v === "string" && v ? v : void 0;
@@ -4716,12 +4827,12 @@ async function chironClient(args) {
4716
4827
  });
4717
4828
  return { http, endpoint, base: await resolveChironBase(http) };
4718
4829
  }
4719
- function fail3(e, args) {
4830
+ function fail4(e, args) {
4720
4831
  const err = e;
4721
4832
  if (err?.response?.status === 404) {
4722
4833
  exitWithError(new Error("\u8BE5\u73AF\u5883\u6CA1\u6709\u8FD9\u4E2A\u6280\u80FD \u2014\u2014 \u8DD1 `hcm skills list` \u770B\u76EE\u5F55\uFF08\u6280\u80FD\u968F\u4EA7\u54C1\u7248\u672C\u8D70\uFF09"));
4723
4834
  }
4724
- if (err?.isAxiosError) exitWithError(fromAxiosError13(err, args.env));
4835
+ if (err?.isAxiosError) exitWithError(fromAxiosError14(err, args.env));
4725
4836
  exitWithError(e);
4726
4837
  process.exit(1);
4727
4838
  }
@@ -4772,7 +4883,7 @@ async function skillsListCommand(keyword, args) {
4772
4883
  }
4773
4884
  if (fmt === "json" || fmt === "yaml") {
4774
4885
  process.stdout.write(
4775
- formatObject14(
4886
+ formatObject15(
4776
4887
  {
4777
4888
  ...manifest2 ?? {},
4778
4889
  categories: cats,
@@ -4845,7 +4956,7 @@ async function skillsListCommand(keyword, args) {
4845
4956
  `);
4846
4957
  process.exit(0);
4847
4958
  } catch (e) {
4848
- fail3(e, args);
4959
+ fail4(e, args);
4849
4960
  }
4850
4961
  }
4851
4962
  async function listInstalledSkills(keyword, args) {
@@ -4854,7 +4965,7 @@ async function listInstalledSkills(keyword, args) {
4854
4965
  const fmt = args.output ?? "table";
4855
4966
  if (!state || Object.keys(state.skills).length === 0) {
4856
4967
  if (fmt === "json" || fmt === "yaml") {
4857
- process.stdout.write(formatObject14({ baseDir: layout.baseDir, target: layout.target, all: false, skills: [] }, { format: fmt }) + "\n");
4968
+ process.stdout.write(formatObject15({ baseDir: layout.baseDir, target: layout.target, all: false, skills: [] }, { format: fmt }) + "\n");
4858
4969
  process.exit(0);
4859
4970
  }
4860
4971
  process.stdout.write(`${path4.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A \u2014\u2014 \u8FD9\u4E2A\u76EE\u5F55\u4E0B\u8FD8\u6CA1\u7528\u672C CLI \u88C5\u8FC7\u6280\u80FD\u3002
@@ -4887,7 +4998,7 @@ async function listInstalledSkills(keyword, args) {
4887
4998
  const shown = sourceFilter === "all" ? byKeyword : byKeyword.filter((row) => row.sourceKind === sourceFilter);
4888
4999
  const groupOf = (kind) => kind === "cli" ? "CLI \u81EA\u5E26" : kind === "local" ? "\u672C\u5730\u76EE\u5F55\u88C5\u7684" : "\u777F\u620E\u6280\u80FD\u5E93";
4889
5000
  if (fmt === "json" || fmt === "yaml") {
4890
- process.stdout.write(formatObject14({
5001
+ process.stdout.write(formatObject15({
4891
5002
  baseDir: layout.baseDir,
4892
5003
  target: layout.target,
4893
5004
  endpoint: state.endpoint,
@@ -4956,7 +5067,7 @@ async function skillsShowCommand(id, args) {
4956
5067
  process.stdout.write(md.endsWith("\n") ? md : md + "\n");
4957
5068
  process.exit(0);
4958
5069
  } catch (e) {
4959
- fail3(e, args);
5070
+ fail4(e, args);
4960
5071
  }
4961
5072
  }
4962
5073
  async function skillsInstallCommand(id, args) {
@@ -5086,7 +5197,7 @@ async function skillsInstallCommand(id, args) {
5086
5197
  const agents = layout.agentsFile ? await syncAgentsIndex(layout, manifest2) : void 0;
5087
5198
  const fmt = args.output ?? "table";
5088
5199
  if (fmt === "json" || fmt === "yaml") {
5089
- process.stdout.write(formatObject14({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
5200
+ process.stdout.write(formatObject15({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
5090
5201
  } else {
5091
5202
  const headline = all ? `\u2705 \u5168\u90E8 ${requestedIds.length} \u4E2A\u6280\u80FD \u2192 ${result.baseDir}` : `\u2705 ${id} \u2192 ${path4.join(result.baseDir, id, "SKILL.md")}`;
5092
5203
  process.stdout.write(`${headline}
@@ -5118,7 +5229,7 @@ async function skillsInstallCommand(id, args) {
5118
5229
  }
5119
5230
  process.exit(0);
5120
5231
  } catch (e) {
5121
- fail3(e, args);
5232
+ fail4(e, args);
5122
5233
  }
5123
5234
  }
5124
5235
  var FETCH_CONCURRENCY = 6;
@@ -5651,7 +5762,7 @@ async function skillsUpdateCommand(args) {
5651
5762
  const changed = plan.entries.filter((e) => e.status === "updated" || e.status === "added");
5652
5763
  const fmt = args.output ?? "table";
5653
5764
  if (fmt === "json" || fmt === "yaml") {
5654
- process.stdout.write(formatObject14({
5765
+ process.stdout.write(formatObject15({
5655
5766
  endpoint,
5656
5767
  baseDir: layout.baseDir,
5657
5768
  target: layout.target,
@@ -5722,7 +5833,7 @@ async function skillsUpdateCommand(args) {
5722
5833
  }
5723
5834
  process.exit(0);
5724
5835
  } catch (e) {
5725
- fail3(e, args);
5836
+ fail4(e, args);
5726
5837
  }
5727
5838
  }
5728
5839
 
@@ -5730,8 +5841,8 @@ async function skillsUpdateCommand(args) {
5730
5841
  import {
5731
5842
  bootstrapTenant,
5732
5843
  createHttpClient as createHttpClient3,
5733
- formatObject as formatObject15,
5734
- fromAxiosError as fromAxiosError14,
5844
+ formatObject as formatObject16,
5845
+ fromAxiosError as fromAxiosError15,
5735
5846
  loadEnv as loadEnv6,
5736
5847
  loadGlobalConfig as loadGlobalConfig7,
5737
5848
  resolveActiveEnv as resolveActiveEnv4,
@@ -5822,14 +5933,14 @@ async function tenantBootstrapCommand(args) {
5822
5933
  `
5823
5934
  );
5824
5935
  }
5825
- process.stdout.write(formatObject15(result, { format: fmt }) + "\n");
5936
+ process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
5826
5937
  process.exit(0);
5827
5938
  } catch (e) {
5828
5939
  const err = e;
5829
5940
  if (err?.response?.status === 403) {
5830
5941
  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"));
5831
5942
  } else if (err?.isAxiosError) {
5832
- exitWithError(fromAxiosError14(err, args.env));
5943
+ exitWithError(fromAxiosError15(err, args.env));
5833
5944
  } else {
5834
5945
  exitWithError(e);
5835
5946
  }
@@ -5839,9 +5950,9 @@ async function tenantBootstrapCommand(args) {
5839
5950
  // src/commands/meta.ts
5840
5951
  import { promises as fsp3 } from "fs";
5841
5952
  import {
5842
- HcmClient as HcmClient15,
5843
- formatObject as formatObject16,
5844
- fromAxiosError as fromAxiosError15,
5953
+ HcmClient as HcmClient16,
5954
+ formatObject as formatObject17,
5955
+ fromAxiosError as fromAxiosError16,
5845
5956
  listTenantMeta,
5846
5957
  getTenantMeta,
5847
5958
  saveTenantMeta,
@@ -5852,16 +5963,16 @@ import {
5852
5963
  init_exit();
5853
5964
  init_auth_guard();
5854
5965
  async function client2(args) {
5855
- return HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
5966
+ return HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
5856
5967
  }
5857
- function fail4(e, args) {
5968
+ function fail5(e, args) {
5858
5969
  const err = e;
5859
5970
  if (err?.response?.status === 403) {
5860
5971
  exitWithError(
5861
5972
  new Error("\u5143\u6570\u636E\u5199\u5165\u88AB\u62D2\uFF08403\uFF09\u2014\u2014 \u9700 config-admin \u8EAB\u4EFD\u4E14\u5F53\u524D source \u53EF\u5199\uFF1B\u82E5\u5728\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\u5916\uFF0C\u5148 `hcm workspace bind <key>`")
5862
5973
  );
5863
5974
  }
5864
- if (err?.isAxiosError) exitWithError(fromAxiosError15(err, args.env));
5975
+ if (err?.isAxiosError) exitWithError(fromAxiosError16(err, args.env));
5865
5976
  exitWithError(e);
5866
5977
  process.exit(1);
5867
5978
  }
@@ -5877,10 +5988,10 @@ async function metaListCommand(args) {
5877
5988
  const fmt = args.output ?? "json";
5878
5989
  if (fmt !== "json") process.stdout.write(`\u{1F4C4} ${items.length} \u4EFD${total ? ` / \u5171 ${total}` : ""}
5879
5990
  `);
5880
- process.stdout.write(formatObject16(items, { format: fmt }) + "\n");
5991
+ process.stdout.write(formatObject17(items, { format: fmt }) + "\n");
5881
5992
  process.exit(0);
5882
5993
  } catch (e) {
5883
- fail4(e, args);
5994
+ fail5(e, args);
5884
5995
  }
5885
5996
  }
5886
5997
  async function metaGetCommand(path11, args) {
@@ -5890,7 +6001,7 @@ async function metaGetCommand(path11, args) {
5890
6001
  process.stdout.write(content.endsWith("\n") ? content : content + "\n");
5891
6002
  process.exit(0);
5892
6003
  } catch (e) {
5893
- fail4(e, args);
6004
+ fail5(e, args);
5894
6005
  }
5895
6006
  }
5896
6007
  async function metaSetCommand(path11, args) {
@@ -5925,11 +6036,11 @@ ${content}
5925
6036
  \u8BB0\u5F97\u6E05\u7F13\u5B58\uFF1Ahcm cache clear-meta <Model>
5926
6037
  `);
5927
6038
  }
5928
- process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
6039
+ process.stdout.write(formatObject17(result, { format: fmt }) + "\n");
5929
6040
  process.exit(0);
5930
6041
  } catch (e) {
5931
6042
  if (e?.code === "ENOENT") exitWithError(new Error(`\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${args.file}`));
5932
- fail4(e, args);
6043
+ fail5(e, args);
5933
6044
  }
5934
6045
  }
5935
6046
  async function metaDeleteCommand(path11, args) {
@@ -5946,10 +6057,10 @@ async function metaDeleteCommand(path11, args) {
5946
6057
  const fmt = args.output ?? "json";
5947
6058
  if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path11}
5948
6059
  `);
5949
- process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
6060
+ process.stdout.write(formatObject17(result, { format: fmt }) + "\n");
5950
6061
  process.exit(0);
5951
6062
  } catch (e) {
5952
- fail4(e, args);
6063
+ fail5(e, args);
5953
6064
  }
5954
6065
  }
5955
6066
 
@@ -5965,10 +6076,10 @@ import {
5965
6076
  createWorkspaceFile,
5966
6077
  deleteWorkspaceFile,
5967
6078
  formatMiniVerifyReport,
5968
- formatObject as formatObject17,
6079
+ formatObject as formatObject18,
5969
6080
  formatRows as formatRows5,
5970
6081
  getMiniStatus,
5971
- HcmClient as HcmClient16,
6082
+ HcmClient as HcmClient17,
5972
6083
  initMiniAppProject,
5973
6084
  inferMiniWritableTemplateOptionsFromModel,
5974
6085
  listWorkspaceFiles,
@@ -5978,7 +6089,7 @@ import {
5978
6089
  runMiniSmokeChecks,
5979
6090
  saveWorkspaceFileContent,
5980
6091
  validateMiniProject,
5981
- fromAxiosError as fromAxiosError16
6092
+ fromAxiosError as fromAxiosError17
5982
6093
  } from "@hcmai/sdk";
5983
6094
 
5984
6095
  // src/commands/workspace-format.ts
@@ -6025,7 +6136,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
6025
6136
  var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
6026
6137
  async function workspaceListCommand(args) {
6027
6138
  try {
6028
- const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
6139
+ const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
6029
6140
  const limit = parsePositiveInt3(args.limit, 50, "--limit");
6030
6141
  const result = await client3.query("TenantExtensionWorkspace", {
6031
6142
  keyword: args.keyword,
@@ -6054,7 +6165,7 @@ async function workspaceActiveCommand(args) {
6054
6165
  const ctx = await getActiveAuthContextFromCli(args, {
6055
6166
  fallbackEnv: localContext?.profile
6056
6167
  });
6057
- const client3 = HcmClient16.fromAuthContext(ctx);
6168
+ const client3 = HcmClient17.fromAuthContext(ctx);
6058
6169
  const result = await client3.query("TenantExtensionWorkspace", {
6059
6170
  filter: { devModeEnabled: true },
6060
6171
  fields: ["workspaceKey", "devModeEnabled"],
@@ -6109,7 +6220,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
6109
6220
  `${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
6110
6221
  );
6111
6222
  }
6112
- const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
6223
+ const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
6113
6224
  const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
6114
6225
  const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
6115
6226
  workspaceKey: normalizedWorkspaceKey,
@@ -6156,7 +6267,7 @@ async function workspacePullCommand(args) {
6156
6267
  `workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
6157
6268
  );
6158
6269
  }
6159
- const client3 = HcmClient16.fromAuthContext(
6270
+ const client3 = HcmClient17.fromAuthContext(
6160
6271
  await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
6161
6272
  );
6162
6273
  const context = buildWorkspaceContext({
@@ -6294,7 +6405,7 @@ async function workspaceStatusCommand(args) {
6294
6405
  }
6295
6406
  if (args.output === "json" || args.output === "yaml") {
6296
6407
  process.stdout.write(
6297
- formatObject17({ rootDir, miniApps: rows }, { format: args.output }) + "\n"
6408
+ formatObject18({ rootDir, miniApps: rows }, { format: args.output }) + "\n"
6298
6409
  );
6299
6410
  } else {
6300
6411
  process.stdout.write(formatRows5(rows, { format: "table" }) + "\n");
@@ -6323,7 +6434,7 @@ async function workspacePushCommand(args) {
6323
6434
  const rootDir = resolveRootDir(args.dir);
6324
6435
  const context = await requireWorkspaceContext(rootDir);
6325
6436
  const miniApps = await discoverMiniApps(rootDir);
6326
- const client3 = HcmClient16.fromAuthContext(
6437
+ const client3 = HcmClient17.fromAuthContext(
6327
6438
  await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
6328
6439
  );
6329
6440
  const rawResult = await pushWorkspaceRawFiles({
@@ -6344,7 +6455,7 @@ async function workspacePushCommand(args) {
6344
6455
  writeWorkspacePushResult(rawResult, results, args.output ?? "table");
6345
6456
  const hint = activationHint(
6346
6457
  await probeActiveWorkspaceKey(
6347
- HcmClient16.fromAuthContext(
6458
+ HcmClient17.fromAuthContext(
6348
6459
  await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
6349
6460
  )
6350
6461
  ),
@@ -6381,7 +6492,7 @@ async function workspacePreviewCommand(args) {
6381
6492
  );
6382
6493
  }
6383
6494
  if (args.output === "json" || args.output === "yaml") {
6384
- process.stdout.write(formatObject17(rows, { format: args.output }) + "\n");
6495
+ process.stdout.write(formatObject18(rows, { format: args.output }) + "\n");
6385
6496
  } else {
6386
6497
  process.stdout.write(formatRows5(rows, { format: "table" }) + "\n");
6387
6498
  }
@@ -6832,7 +6943,7 @@ async function readMiniStatusSafely(app) {
6832
6943
  async function loadProfileClient(args) {
6833
6944
  try {
6834
6945
  const ctx = await getActiveAuthContextFromCli(args);
6835
- return HcmClient16.fromAuthContext(ctx);
6946
+ return HcmClient17.fromAuthContext(ctx);
6836
6947
  } catch (e) {
6837
6948
  if (args.env || args.profile) throw e;
6838
6949
  return null;
@@ -6987,7 +7098,7 @@ function optionalText(value) {
6987
7098
  }
6988
7099
  function writeWorkspaceListResult(rows, format, total) {
6989
7100
  if (format !== "table") {
6990
- process.stdout.write(formatObject17({ rows, total }, { format }) + "\n");
7101
+ process.stdout.write(formatObject18({ rows, total }, { format }) + "\n");
6991
7102
  return;
6992
7103
  }
6993
7104
  process.stdout.write(formatRows5(toWorkspaceListRows(rows), { format: "table" }) + "\n");
@@ -6998,7 +7109,7 @@ function writeWorkspaceListResult(rows, format, total) {
6998
7109
  }
6999
7110
  function writeWorkspaceActiveResult(view, format) {
7000
7111
  if (format !== "table") {
7001
- process.stdout.write(formatObject17(view, { format }) + "\n");
7112
+ process.stdout.write(formatObject18(view, { format }) + "\n");
7002
7113
  return;
7003
7114
  }
7004
7115
  const rows = [
@@ -7016,7 +7127,7 @@ function writeWorkspaceActiveResult(view, format) {
7016
7127
  }
7017
7128
  function writeWorkspaceBindResult(context, rootDir, format) {
7018
7129
  if (format !== "table") {
7019
- process.stdout.write(formatObject17({ ...context, rootDir }, { format }) + "\n");
7130
+ process.stdout.write(formatObject18({ ...context, rootDir }, { format }) + "\n");
7020
7131
  return;
7021
7132
  }
7022
7133
  process.stdout.write(
@@ -7030,7 +7141,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
7030
7141
  }
7031
7142
  function writeWorkspaceCreateResult(result, format) {
7032
7143
  if (format !== "table") {
7033
- process.stdout.write(formatObject17(result, { format }) + "\n");
7144
+ process.stdout.write(formatObject18(result, { format }) + "\n");
7034
7145
  return;
7035
7146
  }
7036
7147
  process.stdout.write(
@@ -7046,7 +7157,7 @@ function writeWorkspaceCreateResult(result, format) {
7046
7157
  }
7047
7158
  function writeWorkspacePullResult(result, format) {
7048
7159
  if (format !== "table") {
7049
- process.stdout.write(formatObject17(result, { format }) + "\n");
7160
+ process.stdout.write(formatObject18(result, { format }) + "\n");
7050
7161
  return;
7051
7162
  }
7052
7163
  const lines = [
@@ -7064,7 +7175,7 @@ function writeWorkspacePullResult(result, format) {
7064
7175
  }
7065
7176
  function writeWorkspaceAddMiniResult(result, rootDir, format) {
7066
7177
  if (format !== "table") {
7067
- process.stdout.write(formatObject17({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
7178
+ process.stdout.write(formatObject18({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
7068
7179
  return;
7069
7180
  }
7070
7181
  process.stdout.write(
@@ -7080,7 +7191,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
7080
7191
  function writeWorkspaceValidateResult(results, format) {
7081
7192
  if (format !== "table") {
7082
7193
  process.stdout.write(
7083
- formatObject17(
7194
+ formatObject18(
7084
7195
  results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result })),
7085
7196
  { format }
7086
7197
  ) + "\n"
@@ -7108,7 +7219,7 @@ mini:${item.app.appCode}
7108
7219
  function writeWorkspacePushResult(rawResult, results, format) {
7109
7220
  if (format !== "table") {
7110
7221
  process.stdout.write(
7111
- formatObject17(
7222
+ formatObject18(
7112
7223
  {
7113
7224
  workspaceFiles: { artifact: "workspace", ...rawResult },
7114
7225
  miniApps: results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result }))
@@ -7164,7 +7275,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
7164
7275
  const ok = rawOk && reports.every((item) => item.report.ok);
7165
7276
  if (format === "json") {
7166
7277
  process.stdout.write(
7167
- formatObject17(
7278
+ formatObject18(
7168
7279
  {
7169
7280
  ok,
7170
7281
  workspaceKey: context.workspaceKey,
@@ -7191,7 +7302,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
7191
7302
  }
7192
7303
  if (format !== "table") {
7193
7304
  process.stdout.write(
7194
- formatObject17(
7305
+ formatObject18(
7195
7306
  {
7196
7307
  ok,
7197
7308
  workspaceKey: context.workspaceKey,
@@ -7243,7 +7354,7 @@ function formatStatusSummary(summary) {
7243
7354
  function exitWorkspaceError(err, profile) {
7244
7355
  const maybeAxios = err;
7245
7356
  if (maybeAxios?.isAxiosError) {
7246
- exitWithError(fromAxiosError16(err, profile));
7357
+ exitWithError(fromAxiosError17(err, profile));
7247
7358
  }
7248
7359
  exitWithError(err);
7249
7360
  }
@@ -7278,7 +7389,7 @@ async function setDevModeBinding(client3, workspaceKey) {
7278
7389
  }
7279
7390
  async function workspaceActivateCommand(workspaceKey, args) {
7280
7391
  try {
7281
- const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
7392
+ const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
7282
7393
  const key2 = normalizeWorkspaceKey(workspaceKey);
7283
7394
  await setDevModeBinding(client3, key2);
7284
7395
  const fmt = args.output ?? "table";
@@ -7288,7 +7399,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
7288
7399
  process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
7289
7400
  } else {
7290
7401
  process.stdout.write(
7291
- formatObject17({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
7402
+ formatObject18({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
7292
7403
  );
7293
7404
  }
7294
7405
  process.exit(0);
@@ -7374,8 +7485,8 @@ async function identityRemove(name) {
7374
7485
  // src/commands/delivery-action-policy.ts
7375
7486
  init_auth_guard();
7376
7487
  import {
7377
- HcmClient as HcmClient17,
7378
- formatObject as formatObject18
7488
+ HcmClient as HcmClient18,
7489
+ formatObject as formatObject19
7379
7490
  } from "@hcmai/sdk";
7380
7491
 
7381
7492
  // src/commands/delivery.ts
@@ -7731,7 +7842,7 @@ async function assessEffectiveDeliveryCommand(inputArgv, dependencies = {}) {
7731
7842
  }
7732
7843
  async function deliveryAssessCommand(argv, args) {
7733
7844
  const assessment = await assessEffectiveDeliveryCommand(argv);
7734
- process.stdout.write(formatObject18(assessment, { format: args.output ?? "json" }) + "\n");
7845
+ process.stdout.write(formatObject19(assessment, { format: args.output ?? "json" }) + "\n");
7735
7846
  }
7736
7847
  async function resolveCoreAction(request) {
7737
7848
  try {
@@ -7740,7 +7851,7 @@ async function resolveCoreAction(request) {
7740
7851
  as: request.identity,
7741
7852
  profile: request.profile
7742
7853
  });
7743
- const description = await HcmClient17.fromAuthContext(auth).describe(request.model);
7854
+ const description = await HcmClient18.fromAuthContext(auth).describe(request.model);
7744
7855
  const named = description.actions.filter((action2) => action2.name === request.action);
7745
7856
  if (named.length === 0) {
7746
7857
  return failed(
@@ -7830,10 +7941,10 @@ function flagValue2(argv, flag) {
7830
7941
  init_auth_guard();
7831
7942
  init_exit();
7832
7943
  import {
7833
- HcmClient as HcmClient18,
7944
+ HcmClient as HcmClient19,
7834
7945
  fetchReconIdentity,
7835
- formatObject as formatObject19,
7836
- fromAxiosError as fromAxiosError17,
7946
+ formatObject as formatObject20,
7947
+ fromAxiosError as fromAxiosError18,
7837
7948
  httpProbe,
7838
7949
  runDoctor
7839
7950
  } from "@hcmai/sdk";
@@ -7852,17 +7963,17 @@ function render2(report) {
7852
7963
  async function deliveryDoctorCommand(args) {
7853
7964
  try {
7854
7965
  const ctx = await getActiveAuthContextFromCli(args);
7855
- const client3 = HcmClient18.fromAuthContext(ctx);
7966
+ const client3 = HcmClient19.fromAuthContext(ctx);
7856
7967
  const probe = httpProbe(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
7857
7968
  const identity2 = await fetchReconIdentity(probe, ctx.tenantId);
7858
7969
  const report = await runDoctor(probe, identity2);
7859
7970
  const fmt = args.output ?? "json";
7860
7971
  if (fmt !== "json") process.stdout.write(render2(report) + "\n");
7861
- process.stdout.write(formatObject19(report, { format: fmt }) + "\n");
7972
+ process.stdout.write(formatObject20(report, { format: fmt }) + "\n");
7862
7973
  process.exit(report.ok ? 0 : 1);
7863
7974
  } catch (e) {
7864
7975
  const err = e;
7865
- if (err?.isAxiosError) exitWithError(fromAxiosError17(err, args.env));
7976
+ if (err?.isAxiosError) exitWithError(fromAxiosError18(err, args.env));
7866
7977
  exitWithError(e);
7867
7978
  process.exit(1);
7868
7979
  }
@@ -7872,12 +7983,12 @@ async function deliveryDoctorCommand(args) {
7872
7983
  init_auth_guard();
7873
7984
  init_exit();
7874
7985
  import {
7875
- HcmClient as HcmClient19,
7986
+ HcmClient as HcmClient20,
7876
7987
  ReconLayout,
7877
7988
  ROUND_EXIT_CODES,
7878
7989
  computeReconSourceKey,
7879
- formatObject as formatObject20,
7880
- fromAxiosError as fromAxiosError18,
7990
+ formatObject as formatObject21,
7991
+ fromAxiosError as fromAxiosError19,
7881
7992
  httpProbe as httpProbe2,
7882
7993
  inspectRound,
7883
7994
  renderRound,
@@ -7887,7 +7998,7 @@ var DEFAULT_CAPABILITIES2 = "default";
7887
7998
  async function deliveryReconCommand(args) {
7888
7999
  try {
7889
8000
  const ctx = await getActiveAuthContextFromCli(args);
7890
- const client3 = HcmClient19.fromAuthContext(ctx);
8001
+ const client3 = HcmClient20.fromAuthContext(ctx);
7891
8002
  const probe = httpProbe2(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES2);
7892
8003
  const sourceKey = await computeReconSourceKey(probe);
7893
8004
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
@@ -7896,10 +8007,10 @@ async function deliveryReconCommand(args) {
7896
8007
  onlyModel: args.model ?? null,
7897
8008
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
7898
8009
  });
7899
- process.stdout.write(formatObject20(summary, { format: args.output ?? "json" }) + "\n");
8010
+ process.stdout.write(formatObject21(summary, { format: args.output ?? "json" }) + "\n");
7900
8011
  } catch (e) {
7901
8012
  const err = e;
7902
- if (err?.isAxiosError) exitWithError(fromAxiosError18(err, args.env));
8013
+ if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
7903
8014
  exitWithError(e);
7904
8015
  process.exit(1);
7905
8016
  }
@@ -7910,7 +8021,7 @@ async function deliveryReconRoundCommand(args) {
7910
8021
  const result = inspectRound(args.dir ?? ".");
7911
8022
  const fmt = args.output ?? "json";
7912
8023
  if (fmt !== "json") process.stdout.write(renderRound(result));
7913
- process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
8024
+ process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
7914
8025
  code = ROUND_EXIT_CODES[result.state];
7915
8026
  } catch (e) {
7916
8027
  exitWithError(e);
@@ -7925,9 +8036,10 @@ import {
7925
8036
  baselineRoundPremise,
7926
8037
  checkPremise,
7927
8038
  CHANNELS,
8039
+ GAP_REASONS,
7928
8040
  deriveAclass,
7929
8041
  exitCode as gate0ExitCode,
7930
- formatObject as formatObject21,
8042
+ formatObject as formatObject22,
7931
8043
  inspectRound as inspectRound2,
7932
8044
  loadProtocolFacts,
7933
8045
  scan
@@ -7944,8 +8056,15 @@ function renderGate0(result, skillRoot) {
7944
8056
  for (const red of rows) lines.push(` - (${red.reason}) ${red.message}`);
7945
8057
  }
7946
8058
  if (result.gaps.length > 0) {
7947
- lines.push(` [gaps] ${result.gaps.length} \u6761\uFF08\u4E0D\u9876 rc\uFF0C\u8BF7\u81EA\u5DF1\u770B\u4E00\u773C\uFF09`);
7948
- for (const gap of result.gaps) lines.push(` - (${gap.reason}) ${gap.why}`);
8059
+ lines.push(` [gaps] ${result.gaps.length} \u6761\uFF08\u4E0D\u9876 rc\uFF0C\u8BF7\u81EA\u5DF1\u770B\u4E00\u773C\uFF1B\u9010\u6761\u89C1 --output json\uFF09`);
8060
+ for (const reason of GAP_REASONS) {
8061
+ const rows = result.gaps.filter((g) => g.reason === reason);
8062
+ if (rows.length === 0) continue;
8063
+ const byToken = /* @__PURE__ */ new Map();
8064
+ for (const g of rows) byToken.set(g.token, (byToken.get(g.token) ?? 0) + 1);
8065
+ const tokens = [...byToken.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([token, n]) => n > 1 ? `${token}\xD7${n}` : token);
8066
+ lines.push(` - (${reason}) ${rows.length} \u6761 / ${byToken.size} \u4E2A token\uFF1A${tokens.join("\u3001")}`);
8067
+ }
7949
8068
  }
7950
8069
  return `${lines.join("\n")}
7951
8070
  `;
@@ -7965,7 +8084,7 @@ async function deliveryGate0Command(args) {
7965
8084
  const merged = { ...result, premise: premise5 };
7966
8085
  const fmt = args.output ?? "json";
7967
8086
  if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
7968
- process.stdout.write(`${formatObject21(merged, { format: fmt })}
8087
+ process.stdout.write(`${formatObject22(merged, { format: fmt })}
7969
8088
  `);
7970
8089
  for (const problem of premise5) {
7971
8090
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
@@ -7989,7 +8108,8 @@ import {
7989
8108
  DRY_RUN_TAIL,
7990
8109
  DriftDetected,
7991
8110
  FORCE_STALE_FLAG,
7992
- HcmClient as HcmClient20,
8111
+ HcmClient as HcmClient21,
8112
+ fetchReconIdentity as fetchReconIdentity2,
7993
8113
  INIT_EXIT_CODES,
7994
8114
  JOURNAL_STOP_KINDS,
7995
8115
  JOURNAL_STOP_UNKNOWN,
@@ -8128,7 +8248,7 @@ async function authOrSignpost(args, cmd) {
8128
8248
  }
8129
8249
  async function deliverySeedPlanCommand(args) {
8130
8250
  const ctx = await authOrSignpost(args, "plan");
8131
- const client3 = HcmClient20.fromAuthContext(ctx);
8251
+ const client3 = HcmClient21.fromAuthContext(ctx);
8132
8252
  process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
8133
8253
  }
8134
8254
  function seedClient(client3, ctx) {
@@ -8162,6 +8282,11 @@ function seedClient(client3, ctx) {
8162
8282
  post: (p, body) => wrap(() => raw.post(p, body))
8163
8283
  };
8164
8284
  }
8285
+ async function seedVerifyClient(client3, ctx) {
8286
+ const base = seedClient(client3, ctx);
8287
+ const identity2 = await fetchReconIdentity2(base, String(ctx.tenantId ?? ""));
8288
+ return { ...base, identity: identity2 };
8289
+ }
8165
8290
  function lowerCaseHeaders(headers) {
8166
8291
  if (headers === null || typeof headers !== "object") return {};
8167
8292
  const out = {};
@@ -8297,7 +8422,7 @@ async function runSeedApply(args, client3) {
8297
8422
  }
8298
8423
  async function deliverySeedApplyCommand(args) {
8299
8424
  const ctx = await authOrSignpost(args, "apply");
8300
- const client3 = HcmClient20.fromAuthContext(ctx);
8425
+ const client3 = HcmClient21.fromAuthContext(ctx);
8301
8426
  process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
8302
8427
  }
8303
8428
  async function runSeedVerify(args, client3) {
@@ -8321,13 +8446,13 @@ async function deliverySeedVerifyCommand(args) {
8321
8446
  return;
8322
8447
  }
8323
8448
  const ctx = await authOrSignpost(args, "verify");
8324
- const client3 = HcmClient20.fromAuthContext(ctx);
8325
- process.exitCode = await runSeedVerify(args, seedClient(client3, ctx));
8449
+ const client3 = HcmClient21.fromAuthContext(ctx);
8450
+ process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
8326
8451
  }
8327
8452
 
8328
8453
  // src/commands/delivery-seed-find.ts
8329
8454
  import { existsSync as existsSync3 } from "fs";
8330
- import { readFileSync as readFileSync4 } from "fs";
8455
+ import { readFileSync as readFileSync5 } from "fs";
8331
8456
  import * as path8 from "path";
8332
8457
  import {
8333
8458
  INIT_EXIT_CODES as INIT_EXIT_CODES2,
@@ -8390,7 +8515,7 @@ function runSeedFind(args) {
8390
8515
  if (!existsSync3(chosen.indexFile)) {
8391
8516
  return premise2(`\u7D22\u5F15\u6587\u4EF6\u5728\u9009\u4E2D\u4E4B\u540E\u6D88\u5931\u4E86\uFF1A${chosen.indexFile}`);
8392
8517
  }
8393
- const { rows, problems } = loadRows(readFileSync4(chosen.indexFile, "utf-8"));
8518
+ const { rows, problems } = loadRows(readFileSync5(chosen.indexFile, "utf-8"));
8394
8519
  process.stdout.write(
8395
8520
  renderFind(find(rows, args.term), args.term, rows.length, {
8396
8521
  prefixBytes: Buffer.byteLength(prefix, "utf-8"),
@@ -8430,13 +8555,13 @@ function deliverySeedValuesCommand(model, args) {
8430
8555
 
8431
8556
  // src/commands/delivery-meta.ts
8432
8557
  init_auth_guard();
8433
- import { readFileSync as readFileSync5 } from "fs";
8558
+ import { readFileSync as readFileSync6 } from "fs";
8434
8559
  import {
8435
8560
  BINDING_WORDS,
8436
8561
  CHANGE_STATES,
8437
8562
  CHANGE_UNKNOWN,
8438
8563
  CODE_WORDS,
8439
- HcmClient as HcmClient21,
8564
+ HcmClient as HcmClient22,
8440
8565
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
8441
8566
  META_WRITE_STEPS,
8442
8567
  META_VERIFY_STEPS,
@@ -8578,7 +8703,7 @@ function premise3(what, hint) {
8578
8703
  async function runDeliveryMeta(args, client3) {
8579
8704
  let content;
8580
8705
  try {
8581
- content = readFileSync5(args.contentFile, "utf-8");
8706
+ content = readFileSync6(args.contentFile, "utf-8");
8582
8707
  } catch (e) {
8583
8708
  return premise3(
8584
8709
  `\u8981\u5199\u8FDB\u53BB\u7684\u6B63\u6587\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.message}`,
@@ -8664,7 +8789,7 @@ function lowerCaseHeaders2(headers) {
8664
8789
  }
8665
8790
  async function deliveryMetaCommand(args) {
8666
8791
  const ctx = await getActiveAuthContextFromCli(args);
8667
- const client3 = HcmClient21.fromAuthContext(ctx);
8792
+ const client3 = HcmClient22.fromAuthContext(ctx);
8668
8793
  process.exitCode = await runDeliveryMeta(
8669
8794
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
8670
8795
  metaClient(client3, ctx)
@@ -8676,12 +8801,12 @@ init_auth_guard();
8676
8801
  init_exit();
8677
8802
  import {
8678
8803
  computeReconSourceKey as computeReconSourceKey2,
8679
- HcmClient as HcmClient22,
8804
+ HcmClient as HcmClient23,
8680
8805
  httpProbe as httpProbe3,
8681
8806
  ReconLayout as ReconLayout2,
8682
8807
  runTriageRound
8683
8808
  } from "@hcmai/sdk";
8684
- import { mkdirSync, readFileSync as readFileSync6, writeFileSync as writeFileSync2 } from "fs";
8809
+ import { mkdirSync, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "fs";
8685
8810
  import * as path9 from "path";
8686
8811
  var DEFAULT_CAPABILITIES4 = "default";
8687
8812
  function premise4(message, hint) {
@@ -8695,7 +8820,7 @@ var REQUESTS_SHAPE = "`--requests` \u6536\u7684\u662F\u4E00\u4E2A JSON \u6570\u7
8695
8820
  function readRequests(file) {
8696
8821
  let raw;
8697
8822
  try {
8698
- raw = JSON.parse(readFileSync6(file, "utf8"));
8823
+ raw = JSON.parse(readFileSync7(file, "utf8"));
8699
8824
  } catch (e) {
8700
8825
  throw new Error(`\u9700\u6C42\u6E05\u5355\u8BFB\u4E0D\u51FA\u6765\uFF08${file}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}`);
8701
8826
  }
@@ -8732,7 +8857,7 @@ async function runTriage(args) {
8732
8857
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
8733
8858
  }
8734
8859
  const ctx = await getActiveAuthContextFromCli(args);
8735
- const client3 = HcmClient22.fromAuthContext(ctx);
8860
+ const client3 = HcmClient23.fromAuthContext(ctx);
8736
8861
  const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES4);
8737
8862
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
8738
8863
  const result = await runTriageRound(probe, artifactsDir, entriesIn);
@@ -8761,7 +8886,7 @@ import { createHash as createHash5, randomBytes as secureRandomBytes } from "cry
8761
8886
  import { spawn } from "child_process";
8762
8887
  import { createReadStream, promises as fs6 } from "fs";
8763
8888
  import path10 from "path";
8764
- import { CliError as CliError20, CliErrorCode as CliErrorCode19, formatObject as formatObject22 } from "@hcmai/sdk";
8889
+ import { CliError as CliError20, CliErrorCode as CliErrorCode19, formatObject as formatObject23 } from "@hcmai/sdk";
8765
8890
  init_exit();
8766
8891
  var EXECUTION_CONTRACT_VERSION = "2026-08-29.controlled-v3";
8767
8892
  var DEFAULT_TTL_SECONDS = 15 * 60;
@@ -8915,7 +9040,7 @@ async function deliveryPrepareCommand(argv, args) {
8915
9040
  evidenceDir: args.evidenceDir,
8916
9041
  ...ttlSeconds === void 0 ? {} : { ttlSeconds }
8917
9042
  });
8918
- process.stdout.write(formatObject22(plan, { format: args.output ?? "json" }) + "\n");
9043
+ process.stdout.write(formatObject23(plan, { format: args.output ?? "json" }) + "\n");
8919
9044
  process.stderr.write(`
8920
9045
  \u4E0B\u4E00\u6B65\uFF08argv \u5FC5\u987B\u4E0E\u672C\u6B21\u5B8C\u5168\u4E00\u81F4\uFF09\uFF1A
8921
9046
  ${nextCommandHint(plan.planId, args.project, argv)}
@@ -8936,7 +9061,7 @@ async function deliveryExecuteCommand(planId, argv, args) {
8936
9061
  planId,
8937
9062
  argv
8938
9063
  });
8939
- process.stdout.write(formatObject22(receipt, { format: args.output ?? "json" }) + "\n");
9064
+ process.stdout.write(formatObject23(receipt, { format: args.output ?? "json" }) + "\n");
8940
9065
  process.exitCode = receipt.exitCode;
8941
9066
  } catch (cause) {
8942
9067
  exitWithError(cause);
@@ -9325,10 +9450,10 @@ function nextCommandHint(planId, project, argv) {
9325
9450
  init_auth_guard();
9326
9451
  init_exit();
9327
9452
  import {
9328
- HcmClient as HcmClient23,
9453
+ HcmClient as HcmClient24,
9329
9454
  adminResetPassword,
9330
- formatObject as formatObject23,
9331
- fromAxiosError as fromAxiosError19,
9455
+ formatObject as formatObject24,
9456
+ fromAxiosError as fromAxiosError20,
9332
9457
  CliError as CliError21,
9333
9458
  CliErrorCode as CliErrorCode20
9334
9459
  } from "@hcmai/sdk";
@@ -9359,12 +9484,12 @@ async function userResetPasswordCommand(args) {
9359
9484
  try {
9360
9485
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
9361
9486
  const request = buildAdminResetPasswordRequest(args, password);
9362
- const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
9487
+ const client3 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
9363
9488
  const result = await adminResetPassword(client3.raw(), request);
9364
- process.stdout.write(formatObject23(result, { format: args.output ?? "json" }) + "\n");
9489
+ process.stdout.write(formatObject24(result, { format: args.output ?? "json" }) + "\n");
9365
9490
  } catch (cause) {
9366
9491
  const err = cause;
9367
- if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
9492
+ if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
9368
9493
  exitWithError(cause);
9369
9494
  }
9370
9495
  }
@@ -9384,19 +9509,19 @@ async function promptPasswordTwice() {
9384
9509
  init_exit();
9385
9510
  init_auth_guard();
9386
9511
  import {
9387
- HcmClient as HcmClient24,
9388
- formatObject as formatObject24,
9389
- fromAxiosError as fromAxiosError20
9512
+ HcmClient as HcmClient25,
9513
+ formatObject as formatObject25,
9514
+ fromAxiosError as fromAxiosError21
9390
9515
  } from "@hcmai/sdk";
9391
9516
  async function modelsCommand(keyword, args) {
9392
9517
  try {
9393
- const client3 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
9518
+ const client3 = HcmClient25.fromAuthContext(await getActiveAuthContextFromCli(args));
9394
9519
  const all = await client3.listModels();
9395
9520
  const needle = keyword?.trim().toLowerCase();
9396
9521
  const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
9397
9522
  const fmt = args.output ?? "table";
9398
9523
  if (fmt !== "table") {
9399
- process.stdout.write(formatObject24({ total: rows.length, models: rows }, { format: fmt }) + "\n");
9524
+ process.stdout.write(formatObject25({ total: rows.length, models: rows }, { format: fmt }) + "\n");
9400
9525
  process.exit(0);
9401
9526
  }
9402
9527
  if (rows.length === 0) {
@@ -9420,7 +9545,7 @@ async function modelsCommand(keyword, args) {
9420
9545
  process.exit(0);
9421
9546
  } catch (e) {
9422
9547
  const err = e;
9423
- if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.profile));
9548
+ if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.profile));
9424
9549
  exitWithError(e);
9425
9550
  }
9426
9551
  }
@@ -9579,6 +9704,11 @@ workspace.command("verify").description(
9579
9704
  ).option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0Cdry-run \u9636\u6BB5\u9700\u8981\uFF09").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("--frontend <url>", "\u524D\u7AEF\u5730\u5740", "http://127.0.0.1:5179").option("--surface <surface>", "\u9884\u89C8\u5F62\u6001\uFF1Aall | bare | standalone | embedded", "all").option("--smoke", "\u5BF9\u9884\u89C8\u5165\u53E3\u4E0E\u57FA\u7840\u8D44\u6E90\u6267\u884C\u53EA\u8BFB HTTP GET \u53EF\u8FBE\u68C0\u67E5").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceVerifyCommand(opts));
9580
9705
  program.command("trace [traceId]").description("\u67E5\u770B trace\uFF1A\u4E0D\u4F20 traceId \u5217\u6700\u8FD1\u8BB0\u5F55\uFF0C\u4F20 traceId \u663E\u793A\u4EBA\u7C7B\u53EF\u8BFB\u8BE6\u60C5").option("--conv <convId>", "\u67E5\u4F1A\u8BDD\u7684 LLM \u9010\u8C03\u7528 trace\uFF08PG llm_call_trace\uFF0CADR-134 D2\uFF09").option("--llm-calls", "\u628A\u4F4D\u7F6E\u53C2\u5F53 convId \u67E5 LLM \u9010\u8C03\u7528\uFF08\u7B49\u4EF7 --conv <convId>\uFF09").option("--span <N>", "\u67E5\u770B\u7B2C N \u4E2A span \u7684\u8BE6\u60C5").option("-n, --limit <N>", "\u5217\u8868\u6A21\u5F0F\u663E\u793A\u6761\u6570", "10").option("--events", "\u6309\u4E8B\u4EF6\u65F6\u95F4\u7EBF\u5C55\u793A spans/logs/LLM \u5185\u5BB9\u6458\u8981").option("--raw", "\u8F93\u51FA\u539F\u59CB trace \u805A\u5408 JSON\uFF08\u534F\u8BAE/P0 \u8C03\u8BD5\u7528\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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>", "\u517C\u5BB9\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml\uFF1B\u8C03\u8BD5\u539F\u6587\u4F18\u5148\u7528 --raw", "table").action((traceId, opts) => traceCommand(traceId ?? null, opts));
9581
9706
  program.command("mini").description("\u5DF2\u79FB\u9664\uFF1A\u8BF7\u6539\u7528 hcm workspace").allowUnknownOption(true).allowExcessArguments(true).argument("[args...]").action(() => removedMiniCommand());
9707
+ var script = program.command("script").description("\u4E91\u51FD\u6570\uFF1A\u53EA\u8BFB\u8BD5\u8FD0\u884C\u3001manifest \u6821\u9A8C\u3001\u6267\u884C\u65E5\u5FD7\u4E0E\u5F02\u6B65\u4EFB\u52A1\uFF08\u8D70 CLI \u8BA4\u8BC1\uFF0C\u4E0D\u9700\u8981\u81EA\u5DF1\u62FF token\uFF09");
9708
+ script.command("dry-run").description("\u53EA\u8BFB\u8BD5\u8FD0\u884C\u4E91\u51FD\u6570\uFF1B\u5199\u64CD\u4F5C\u88AB\u62E6\u622A\u3001\u4EC5\u8BB0\u5F55\u4E3A writeIntents\uFF0C\u4E0D\u6539\u6570\u636E").requiredOption("--script-key <key>", "\u811A\u672C key\uFF0C\u5982 employee.sync-tags").option("--model <Model>", "\u7ED1\u5B9A\u7684 Model").option("--action <action>", "\u7ED1\u5B9A\u7684 Action key").option("--scope <scope>", "Action scope\uFF1Aclass | object").option("--method <method>", "HTTP \u65B9\u6CD5").option("--target-id <id>", "object scope \u7684\u76EE\u6807\u5B9E\u4F53 id").option("--params <JSON>", "\u5165\u53C2 JSON \u5BF9\u8C61").option("--params-file <path>", "\u4ECE UTF-8 JSON \u6587\u4EF6\u8BFB\u5165\u53C2\uFF08\u4E0E --params \u4E92\u65A5\uFF09").option("--context <JSON>", "context JSON \u5BF9\u8C61").option("--event <JSON>", "event JSON \u5BF9\u8C61").option("--timeout <ms>", "\u8D85\u65F6\u6BEB\u79D2").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => scriptDryRunCommand(opts));
9709
+ script.command("manifest-validate").description("\u6821\u9A8C\u6269\u5C55\u5305 manifest.yml").requiredOption("--file <path>", "manifest.yml \u8DEF\u5F84").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => scriptManifestValidateCommand(opts));
9710
+ 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>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => scriptLogsCommand(opts));
9711
+ 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>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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));
9582
9712
  var cache = program.command("cache").description("\u6A21\u578B\u7F13\u5B58\u8FD0\u7EF4\uFF08Caffeine \u672C\u5730 + Redis \u8FDC\u7A0B\uFF0C\u987B\u8D70 API\uFF09");
9583
9713
  cache.command("stats <Model>").description("\u67E5\u770B\u6A21\u578B\u7F13\u5B58\u7EDF\u8BA1").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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));
9584
9714
  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>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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));