@thinkingai/ae-cli 6.1.32 → 6.1.33

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.
Files changed (94) hide show
  1. package/README.md +6 -3
  2. package/README.zh.md +8 -3
  3. package/bin/runtime-capabilities.json +1 -1
  4. package/dist/{ai-monitor-MKMHSSNI.js → ai-monitor-OHTSU6SV.js} +10 -9
  5. package/dist/ai-monitor.js +14 -13
  6. package/dist/{auth-CZHHPZOQ.js → auth-2MOK4OI6.js} +18 -9
  7. package/dist/{automation-FLCPFMN4.js → automation-6L6IAYRK.js} +6 -7
  8. package/dist/{capability-64KVJFIA.js → capability-EMIHQJA3.js} +10 -9
  9. package/dist/{chunk-OAWPT7VP.js → chunk-2I5SZ5DS.js} +2 -2
  10. package/dist/{chunk-4XKTRCRK.js → chunk-4IQYPWCX.js} +9 -8
  11. package/dist/{chunk-T7WF4HYW.js → chunk-7DHSB3FL.js} +3 -3
  12. package/dist/{chunk-4PSTYEG5.js → chunk-AMURHMS3.js} +11 -7
  13. package/dist/{chunk-6M7ZEDT2.js → chunk-BQFLABJQ.js} +11 -7
  14. package/dist/{chunk-KTJXD27G.js → chunk-COOMXFUG.js} +3 -3
  15. package/dist/{chunk-NLEXY2TM.js → chunk-DWAG2QJM.js} +7 -5
  16. package/dist/{chunk-DWBYNGSR.js → chunk-E3ONSFUN.js} +165 -186
  17. package/dist/{chunk-CF6JTT2U.js → chunk-EFGUBGA6.js} +1 -1
  18. package/dist/{chunk-BNBCMCYN.js → chunk-EWVEAERM.js} +11 -11
  19. package/dist/{chunk-F2VFZUGG.js → chunk-HIMOBNEY.js} +2 -2
  20. package/dist/{chunk-JEUXDY3B.js → chunk-HQED4YB4.js} +1 -1
  21. package/dist/{chunk-2F64AZYH.js → chunk-KA5WKR5P.js} +2 -2
  22. package/dist/{chunk-FCAA7I2D.js → chunk-KD5UC33N.js} +23 -9
  23. package/dist/{chunk-P7QDCWJ6.js → chunk-LFJ7N36I.js} +5 -1
  24. package/dist/chunk-NNK3JBH4.js +60 -0
  25. package/dist/{chunk-3ULDJJTZ.js → chunk-O45NOIWR.js} +2 -2
  26. package/dist/{chunk-HTZ2MLYA.js → chunk-PLNS5J33.js} +11 -5
  27. package/dist/chunk-PUSFEC6B.js +29 -0
  28. package/dist/{chunk-Z3Q2AEIN.js → chunk-R2SVAO4G.js} +14 -2
  29. package/dist/{chunk-TMQGS4TO.js → chunk-RC3PPCYD.js} +3 -3
  30. package/dist/{chunk-HVMCPKOZ.js → chunk-THTROEGD.js} +1 -1
  31. package/dist/{chunk-QVRIDN42.js → chunk-UCMO4LKL.js} +2 -2
  32. package/dist/{chunk-5M5LBRR3.js → chunk-VLOGOM7N.js} +13 -7
  33. package/dist/{chunk-72NJKS7O.js → chunk-XZDKAR4N.js} +4 -4
  34. package/dist/{chunk-IDDWEZ7F.js → chunk-YE6MJB5V.js} +3 -3
  35. package/dist/{community-report-client-TJVCLZ3K.js → community-report-client-ULRNXLQV.js} +1 -1
  36. package/dist/{compat-check-ZJNCMNQV.js → compat-check-CADG7GND.js} +5 -4
  37. package/dist/{config-FSH2NMNZ.js → config-PFD3KWQG.js} +7 -6
  38. package/dist/{context-YAQG6YQC.js → context-SOQDFZIB.js} +8 -6
  39. package/dist/{data-integration-QE37EQ3A.js → data-integration-UNJ7EPW2.js} +6 -6
  40. package/dist/{evaluation-2JSF4V47.js → evaluation-Q3AIGFOG.js} +5 -5
  41. package/dist/index.js +47 -43
  42. package/dist/{local-data-upload-client-KCMG6J62.js → local-data-upload-client-YTWMAAGE.js} +1 -1
  43. package/dist/{memory-VEZZVAAP.js → memory-HKNGUIPK.js} +6 -7
  44. package/dist/{metadata-3IWHX3V4.js → metadata-GFWR5ZHC.js} +10 -9
  45. package/dist/{model-T7H7Q6BG.js → model-NAKQWK4W.js} +4 -5
  46. package/dist/{personal-semantic-preference-YITU23SA.js → personal-semantic-preference-JCTKXLC3.js} +45 -14
  47. package/dist/{project-semantic-MHEXJF3C.js → project-semantic-B2NWQOKK.js} +9 -8
  48. package/dist/{sync-AQHVCSPI.js → sync-UQH4J4BD.js} +9 -9
  49. package/dist/{te-agent-RXI7WOH4.js → te-agent-L6EYFQCC.js} +303 -17
  50. package/dist/{te-analysis-CZY74HVF.js → te-analysis-U7NNOY66.js} +25 -20
  51. package/dist/{te-community-DKCYUBCM.js → te-community-3UQEW3KD.js} +13 -11
  52. package/dist/{te-dataops-QEH6VE56.js → te-dataops-SUNYXF5G.js} +13 -11
  53. package/dist/{te-engage-WK7WKDKF.js → te-engage-KMXZJ2KN.js} +9 -8
  54. package/dist/{te-experiment-LH3RPIOE.js → te-experiment-IEYKP6VC.js} +215 -28
  55. package/dist/{te-kb-UPORIOVN.js → te-kb-MT3V5ZMH.js} +68 -17
  56. package/dist/{te-system-AL4B4XZL.js → te-system-F4ZU2HRQ.js} +6 -7
  57. package/dist/{te-team-LLVTO2G4.js → te-team-M6E6XQ5H.js} +9 -8
  58. package/dist/{things-XLMLBYQR.js → things-FRLBZV2Z.js} +9 -8
  59. package/dist/{update-7J5UQHSK.js → update-NULYHVE6.js} +8 -6
  60. package/dist/{workspace-FF2HXJGR.js → workspace-Z7L33OBQ.js} +6 -7
  61. package/package.json +6 -3
  62. package/skills/ae-agent/SKILL.md +19 -5
  63. package/skills/ae-agent/references/a2a.md +103 -0
  64. package/skills/ae-agent/references/command_index.md +11 -0
  65. package/skills/ae-analysis/SKILL.md +35 -23
  66. package/skills/ae-analysis/references/analysis_data_retrieval.md +1 -1
  67. package/skills/ae-analysis/references/asset_authentication_export.md +1 -1
  68. package/skills/ae-analysis/references/asset_authentication_update.md +6 -2
  69. package/skills/ae-analysis/references/bad_case_review.md +4 -4
  70. package/skills/ae-analysis/references/command_index.md +7 -7
  71. package/skills/ae-analysis/references/governance_recommendation_export.md +2 -2
  72. package/skills/ae-analysis/references/personal_semantic_preference_add.md +9 -1
  73. package/skills/ae-analysis/references/personal_semantic_preference_delete.md +2 -0
  74. package/skills/ae-analysis/references/personal_semantic_preference_get.md +2 -0
  75. package/skills/ae-analysis/references/personal_semantic_preference_list.md +10 -2
  76. package/skills/ae-analysis/references/personal_semantic_preference_update.md +8 -0
  77. package/skills/ae-analysis/references/project_owner_update.md +5 -1
  78. package/skills/ae-analysis/references/scenario_evaluation.md +17 -1
  79. package/skills/ae-analysis/references/scenario_list.md +5 -6
  80. package/skills/ae-capability/SKILL.md +8 -4
  81. package/skills/ae-experiment/SKILL.md +45 -16
  82. package/skills/ae-experiment/references/experiment_approval.md +87 -29
  83. package/skills/ae-experiment/references/manage_experiment.md +7 -3
  84. package/skills/ae-experiment/references/manage_traffic_domains.md +131 -0
  85. package/skills/ae-experiment/references/query_experiment_detail.md +8 -0
  86. package/skills/ae-experiment/references/query_experiment_list.md +6 -0
  87. package/skills/ae-experiment/references/save_experiment.md +39 -13
  88. package/skills/ae-experiment/references/save_metric.md +29 -2
  89. package/skills/ae-experiment/references/save_submit_experiment.md +11 -7
  90. package/skills/ae-experiment/references/save_submit_external_experiment.md +16 -14
  91. package/skills/ae-experiment/references/save_traffic_layer.md +17 -1
  92. package/skills/ae-kb/SKILL.md +4 -2
  93. package/skills/ae-kb/references/publication.md +45 -0
  94. package/dist/chunk-Y74WTIKJ.js +0 -10
@@ -1,19 +1,20 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createCapabilityCommand
4
- } from "./chunk-TMQGS4TO.js";
4
+ } from "./chunk-RC3PPCYD.js";
5
5
  import {
6
6
  registerCapabilityGatewayRoute
7
7
  } from "./chunk-AWW2T2WL.js";
8
- import "./chunk-3ULDJJTZ.js";
9
- import "./chunk-4XKTRCRK.js";
10
- import "./chunk-Y74WTIKJ.js";
11
- import "./chunk-DWBYNGSR.js";
12
- import "./chunk-HTZ2MLYA.js";
13
- import "./chunk-4PSTYEG5.js";
8
+ import "./chunk-O45NOIWR.js";
9
+ import "./chunk-4IQYPWCX.js";
10
+ import "./chunk-NNK3JBH4.js";
11
+ import "./chunk-E3ONSFUN.js";
12
+ import "./chunk-PUSFEC6B.js";
13
+ import "./chunk-PLNS5J33.js";
14
+ import "./chunk-AMURHMS3.js";
14
15
  import {
15
16
  CliValidationError
16
- } from "./chunk-Z3Q2AEIN.js";
17
+ } from "./chunk-R2SVAO4G.js";
17
18
 
18
19
  // src/commands/te-experiment/capability-shared.ts
19
20
  function createExperimentCapabilityCommand(config) {
@@ -95,8 +96,8 @@ var approvalSubmit = createExperimentCapabilityCommand({
95
96
  resource: "approval",
96
97
  command: "submit",
97
98
  capabilityId: "experiment.approval.submit",
98
- description: "Submit a saved experiment draft for approval.",
99
- helpText: "Submission creates a pending review; it does not approve or start the experiment.\nRead approval get after submission to inspect the exact proposal and approval ID.",
99
+ description: "Submit a saved experiment draft using the server approval policy.",
100
+ helpText: "On updated servers, only Feature experiments with configured approvers enter review.\nExternal experiments and Feature experiments with an empty roster submit directly.\nAn exempt Feature submission stays pending for its existing manual or scheduled start.\nExisting pending reviews must be withdrawn before resubmission.\nRead experiment get for actual status and approval get for any review; older servers may use a different policy.",
100
101
  flags: [
101
102
  { name: "project-id", type: "number", required: true, alias: "p", desc: "Positive integer project ID." },
102
103
  { name: "exp-id", type: "string", required: true, desc: "Existing experiment ID." }
@@ -201,6 +202,7 @@ var approverList = createExperimentCapabilityCommand({
201
202
  command: "list",
202
203
  capabilityId: "experiment.approver.list",
203
204
  description: "List project experiment approvers and their eligibility.",
205
+ helpText: "Requires engage:read and experiment settings view permission (experimentViewSetting).",
204
206
  flags: [
205
207
  { name: "project-id", type: "number", required: true, alias: "p", desc: "Positive integer project ID." }
206
208
  ],
@@ -227,7 +229,7 @@ var approverAdd = createExperimentCapabilityCommand({
227
229
  command: "add",
228
230
  capabilityId: "experiment.approver.add",
229
231
  description: "Add eligible project experiment approvers.",
230
- helpText: "Adds 1 to 10 verified project member open IDs. Experiment management permission is required.\nExperiment approvers are independent of Engage task approvers.",
232
+ helpText: "Adds 1 to 10 verified project member open IDs.\nRequires engage:write and experiment settings edit permission (experimentEditSetting).\nExperiment approvers are independent of Engage task approvers.\nOn updated servers, a non-empty roster enables Feature experiment approval for subsequent submissions and delivery changes.\nExternal experiments are exempt; existing effective configurations do not require retrospective approval.",
231
233
  flags: [
232
234
  { name: "project-id", type: "number", required: true, alias: "p", desc: "Positive integer project ID." },
233
235
  { name: "approvers", type: "json", required: true, desc: "JSON array of 1 to 10 eligible project member open IDs." }
@@ -251,7 +253,7 @@ var approverDelete = createExperimentCapabilityCommand({
251
253
  command: "delete",
252
254
  capabilityId: "experiment.approver.delete",
253
255
  description: "Remove one project experiment approver.",
254
- helpText: "Requires experiment management permission. Removing a member preserves approval history.",
256
+ helpText: "Requires engage:write and experiment settings edit permission (experimentEditSetting).\nRemoving a member preserves approval history.\nOn updated servers, removing the last approver disables approval for subsequent Feature submissions and delivery changes.\nExisting pending reviews remain pending; withdraw and resubmit them under the current policy when authorized.",
255
257
  flags: [
256
258
  { name: "project-id", type: "number", required: true, alias: "p", desc: "Positive integer project ID." },
257
259
  { name: "approver", type: "string", required: true, desc: "Existing experiment approver open ID to remove." }
@@ -428,7 +430,7 @@ var experimentManage = createExperimentCapabilityCommand({
428
430
  command: "manage",
429
431
  capabilityId: "experiment.experiment.manage",
430
432
  description: "Update an experiment status.",
431
- helpText: "On approval-enabled servers, draft to pending submits the saved draft for approval.\nThe pending submission path also works on older servers. Use approval get only when supported.\nSubmit once; success does not mean running. Verify runtime status with experiment get.\nUsing --target-status running on an eligible experiment starts immediately. Read detail first: when\nstart_time_adjustment_required is true, an early start uses the current server time.",
433
+ helpText: "Draft to pending submits the saved draft under the server approval policy.\nOn updated servers, only Feature experiments with configured approvers enter review; exempt submissions use the existing lifecycle.\nThe pending submission path also works on older servers. Use approval get only when supported.\nSubmit once; success does not establish pending or running status. Verify status and approval with experiment get.\nUsing --target-status running on an eligible experiment starts immediately. Read detail first: when\nstart_time_adjustment_required is true, an early start uses the current server time.",
432
434
  flags: [
433
435
  { name: "project-id", type: "number", required: true, alias: "p", desc: "Numeric project ID." },
434
436
  { name: "exp-id", type: "string", required: true, desc: "Experiment ID." },
@@ -460,6 +462,19 @@ var experimentReadyCheck = createExperimentCapabilityCommand({
460
462
  });
461
463
 
462
464
  // src/commands/te-experiment/experiment/save.ts
465
+ var layerTypes = /* @__PURE__ */ new Set(["remote", "local"]);
466
+ function validateExperimentSaveRequest(req) {
467
+ const layerType = req.layerType;
468
+ if (layerType !== void 0 && (typeof layerType !== "string" || !layerTypes.has(layerType))) {
469
+ throw new Error("Flag --req.layerType must be one of: remote, local");
470
+ }
471
+ if (layerType !== void 0 && req.isExpSharing !== 0) {
472
+ throw new Error("Flag --req.layerType requires --req.isExpSharing=0");
473
+ }
474
+ if (layerType === "local" && req.bucketId === "#user_id") {
475
+ throw new Error("Flag --req.bucketId #user_id is not supported when --req.layerType=local");
476
+ }
477
+ }
463
478
  function readTimestamp(ctx, name) {
464
479
  const value = ctx.str(name);
465
480
  if (!(ctx.has?.(name) ?? value !== "")) return void 0;
@@ -470,6 +485,7 @@ function readTimestamp(ctx, name) {
470
485
  }
471
486
  function buildInput12(ctx) {
472
487
  const req = { ...readRequiredObject(ctx, "req") };
488
+ validateExperimentSaveRequest(req);
473
489
  const startTime = readTimestamp(ctx, "start-time");
474
490
  const fixedEndTime = readTimestamp(ctx, "fixed-end-time");
475
491
  if (startTime !== void 0 || fixedEndTime !== void 0) {
@@ -491,14 +507,14 @@ var experimentSave = createExperimentCapabilityCommand({
491
507
  command: "save",
492
508
  capabilityId: "experiment.experiment.save",
493
509
  description: "Create or update an experiment, including Feature start and end times.",
494
- helpText: "Timing flags override matching fields in --req. Saving a draft does not submit or start it.\nAfter readiness checks, use experiment experiment manage --target-status pending to submit once.\nThat submission path works on older and approval-enabled servers.\nDelivery changes to submitted experiments enter approval on approval-enabled servers.\nVerify runtime status with experiment get; use approval commands only when supported.\nUse timestamps with minutes 00 or 30 to align with scheduling checks.",
510
+ helpText: "Timing flags override matching fields in --req. Saving a draft does not submit or start it.\nAfter readiness checks, use experiment experiment manage --target-status pending to submit once.\nThat submission path works on older and approval-enabled servers.\nOn updated servers, delivery changes enter approval only for Feature experiments with configured approvers.\nExternal experiments and Feature experiments with an empty roster save directly; existing pending reviews still block edits.\nVerify runtime status with experiment get; use approval commands only when supported.\nUse timestamps with minutes 00 or 30 to align with scheduling checks.",
495
511
  flags: [
496
512
  { name: "project-id", type: "number", required: true, alias: "p", desc: "Numeric project ID." },
497
513
  {
498
514
  name: "req",
499
515
  type: "json",
500
516
  required: true,
501
- desc: "Native camelCase request; custom audiences use targeting.definitionRequest, never targetConfig."
517
+ desc: "Native camelCase request; custom audiences use targeting.definitionRequest, never targetConfig; optional domainId selects an exclusive draft domain; exclusive local routing uses isExpSharing=0, layerType=local, and a bucketId other than #user_id."
502
518
  },
503
519
  { name: "start-time", type: "string", desc: "Optional Feature start timestamp with timezone offset; overrides req.startTime. The server clears seconds and milliseconds." },
504
520
  { name: "fixed-end-time", type: "string", desc: "Optional Feature deadline with timezone offset; sets req.expCycle.cycleType=time and overrides fixedEndTime." }
@@ -677,7 +693,7 @@ var externalExperimentSaveSubmit = createExperimentCapabilityCommand({
677
693
  command: "save-submit",
678
694
  capabilityId: "experiment.experiment.save-submit",
679
695
  description: "Create or update and submit an external experiment without Feature or traffic-layer configuration.",
680
- helpText: "On approval-enabled servers, initial submission and delivery changes enter approval.\nOn servers exposing req.clearEndTime, omitting --end-time preserves an existing deadline; use --clear-end-time true to cancel it.\nVerify runtime status with experiment experiment get; read approval get only when supported.\nOlder servers retain their existing submission behavior; success does not mean running.",
696
+ helpText: "On updated servers, external experiments submit and save delivery changes without approval, regardless of the approver roster.\nExisting pending reviews remain pending and must be withdrawn before resubmission.\nOn servers exposing req.clearEndTime, omitting --end-time preserves an existing deadline; use --clear-end-time true to cancel it.\nVerify runtime status with experiment experiment get; read approval get only when supported.\nOlder servers retain their existing submission behavior; success does not mean running.",
681
697
  flags: [
682
698
  { name: "project-id", type: "number", required: true, alias: "p", desc: "Numeric project ID." },
683
699
  { name: "exp-id", type: "string", desc: "Existing external experiment ID; omit to create." },
@@ -1038,12 +1054,15 @@ var aggregations = /* @__PURE__ */ new Set([
1038
1054
  "distinct_count"
1039
1055
  ]);
1040
1056
  var propertyAggregations = /* @__PURE__ */ new Set(["sum", "avg", "max", "distinct_count"]);
1057
+ var countAggregations = /* @__PURE__ */ new Set(["total_count", "user_count", "active_days"]);
1058
+ var gatewayValidatedMetricTypes = /* @__PURE__ */ new Set(["formula", "retention", "funnel"]);
1041
1059
  var metricDefinitionFields = /* @__PURE__ */ new Set([
1042
1060
  "type",
1043
1061
  "event",
1044
1062
  "aggregation",
1045
1063
  "property",
1046
- "filters"
1064
+ "filters",
1065
+ "display_name"
1047
1066
  ]);
1048
1067
  function validateMetricFilters(rawFilters) {
1049
1068
  if (rawFilters === void 0) return;
@@ -1081,14 +1100,15 @@ function validateMetricSaveRequest(req) {
1081
1100
  throw new Error("Flag --req.metricDefinition must be a JSON object");
1082
1101
  }
1083
1102
  const definition = rawDefinition;
1103
+ if (typeof definition.type === "string" && gatewayValidatedMetricTypes.has(definition.type)) return;
1104
+ if (definition.type !== "event") {
1105
+ throw new Error("Flag --req.metricDefinition.type must be one of: event, formula, retention, funnel");
1106
+ }
1084
1107
  for (const field of Object.keys(definition)) {
1085
1108
  if (!metricDefinitionFields.has(field)) {
1086
1109
  throw new Error(`Flag --req.metricDefinition.${field} is not supported`);
1087
1110
  }
1088
1111
  }
1089
- if (definition.type !== "event") {
1090
- throw new Error("Flag --req.metricDefinition.type must be event");
1091
- }
1092
1112
  if (typeof definition.event !== "string" || definition.event.trim() === "") {
1093
1113
  throw new Error("Flag --req.metricDefinition.event is required");
1094
1114
  }
@@ -1100,6 +1120,16 @@ function validateMetricSaveRequest(req) {
1100
1120
  }
1101
1121
  validateMetricFilters(definition.filters);
1102
1122
  }
1123
+ function applyMetricCreateDefaults(req) {
1124
+ if (req.update !== void 0 && req.update !== false) return req;
1125
+ const definition = req.metricDefinition;
1126
+ if (definition?.type !== "event" || typeof definition.aggregation !== "string" || !countAggregations.has(definition.aggregation)) return req;
1127
+ return {
1128
+ metricPurpose: "confidence_statistics",
1129
+ format: "integer",
1130
+ ...req
1131
+ };
1132
+ }
1103
1133
  var metricSave = createExperimentCapabilityCommand({
1104
1134
  resource: "metric",
1105
1135
  command: "save",
@@ -1111,14 +1141,17 @@ var metricSave = createExperimentCapabilityCommand({
1111
1141
  name: "req",
1112
1142
  type: "json",
1113
1143
  required: true,
1114
- desc: "Native camelCase request. Property comparisons use metricDefinition.filters={relation,items:[{field,operator,values}]}. Never use metricConfig, calcType, or raw filts."
1144
+ desc: "Native camelCase request. New user_count, total_count, and active_days metrics default to metricPurpose=confidence_statistics and format=integer. metricDefinition supports event, formula, retention, and funnel. Event property comparisons use metricDefinition.filters={relation,items:[{field,operator,values}]}. Never use metricConfig, calcType, or raw filts."
1115
1145
  }
1116
1146
  ],
1117
1147
  risk: "write",
1118
1148
  validate: (ctx) => {
1119
1149
  validateMetricSaveRequest(readRequiredObject(ctx, "req"));
1120
1150
  },
1121
- buildInput: (ctx) => ({ project_id: ctx.num("project-id"), req: readRequiredObject(ctx, "req") })
1151
+ buildInput: (ctx) => ({
1152
+ project_id: ctx.num("project-id"),
1153
+ req: applyMetricCreateDefaults(readRequiredObject(ctx, "req"))
1154
+ })
1122
1155
  });
1123
1156
 
1124
1157
  // src/commands/te-experiment/operation-log/query.ts
@@ -1195,11 +1228,15 @@ var saveValidate = createExperimentCapabilityCommand({
1195
1228
  }
1196
1229
  readRequiredObject(ctx, "req");
1197
1230
  },
1198
- buildInput: (ctx) => ({
1199
- project_id: ctx.num("project-id"),
1200
- operation_mode: ctx.str("operation-mode"),
1201
- req: readRequiredObject(ctx, "req")
1202
- })
1231
+ buildInput: (ctx) => {
1232
+ const mode = ctx.str("operation-mode");
1233
+ const req = readRequiredObject(ctx, "req");
1234
+ return {
1235
+ project_id: ctx.num("project-id"),
1236
+ operation_mode: mode,
1237
+ req: mode === "save_metric" ? applyMetricCreateDefaults(req) : req
1238
+ };
1239
+ }
1203
1240
  });
1204
1241
 
1205
1242
  // src/commands/te-experiment/report/metric-trend.ts
@@ -1294,6 +1331,148 @@ var reportSummary = createExperimentCapabilityCommand({
1294
1331
  }
1295
1332
  });
1296
1333
 
1334
+ // src/commands/te-experiment/traffic-domain/shared.ts
1335
+ function integerFlag(ctx, name, min, max = Number.MAX_SAFE_INTEGER) {
1336
+ const value = ctx.num(name);
1337
+ if (ctx.str(name).trim() === "" || !Number.isSafeInteger(value) || value < min || value > max) {
1338
+ throw new Error(`Flag --${name} must be an integer between ${min} and ${max}`);
1339
+ }
1340
+ return value;
1341
+ }
1342
+ function baseInput(ctx, bucketRequired = false) {
1343
+ const input = { project_id: integerFlag(ctx, "project-id", 1, 2147483647) };
1344
+ const bucket = ctx.str("bucket-id").trim();
1345
+ if (bucketRequired || bucket !== "") {
1346
+ if (!["#user_id", "#account_id", "#distinct_id", "#device_id"].includes(bucket)) {
1347
+ throw new Error("Flag --bucket-id must be one of #user_id, #account_id, #distinct_id, #device_id");
1348
+ }
1349
+ input.bucket_id = bucket;
1350
+ }
1351
+ return input;
1352
+ }
1353
+ function domainId(ctx) {
1354
+ const value = ctx.str("domain-id").trim();
1355
+ if (!value) throw new Error("Flag --domain-id must be a non-empty string");
1356
+ return value;
1357
+ }
1358
+ function writeInput(ctx, create) {
1359
+ const input = baseInput(ctx, create);
1360
+ if (!create) input.domain_id = domainId(ctx);
1361
+ const name = ctx.str("name").trim();
1362
+ const description = ctx.str("description");
1363
+ if (!name || name.length > 128) throw new Error("Flag --name must contain 1 to 128 characters");
1364
+ if (description.length > 200) throw new Error("Flag --description must contain at most 200 characters");
1365
+ input.domain_name = name;
1366
+ input.domain_desc = description;
1367
+ const quotaChange = create || ["allocation-bps", "allocations", "expected-version"].some(
1368
+ (flag) => ctx.has?.(flag) ?? ctx.str(flag) !== ""
1369
+ );
1370
+ if (!quotaChange) return input;
1371
+ input.allocation_bps = integerFlag(ctx, "allocation-bps", 1, 1e4);
1372
+ input.expected_version = integerFlag(ctx, "expected-version", 0);
1373
+ const raw = ctx.json("allocations");
1374
+ const allocations = raw === void 0 && create ? [] : raw;
1375
+ if (!Array.isArray(allocations)) throw new Error("Flag --allocations must be a JSON array of all other domains");
1376
+ const ids = /* @__PURE__ */ new Set();
1377
+ let total = input.allocation_bps;
1378
+ input.allocations = allocations.map((item, index) => {
1379
+ if (!item || typeof item !== "object" || Array.isArray(item) || Object.keys(item).some((key) => !["domain_id", "allocation_bps"].includes(key)) || typeof item.domain_id !== "string" || !item.domain_id.trim() || !Number.isInteger(item.allocation_bps) || item.allocation_bps < 1 || item.allocation_bps > 1e4) {
1380
+ throw new Error(`Flag --allocations[${index}] must contain only domain_id and integer allocation_bps (1 to 10000)`);
1381
+ }
1382
+ const id = item.domain_id.trim();
1383
+ if (ids.has(id) || id === input.domain_id) {
1384
+ throw new Error("Flag --allocations must not repeat a domain or include the domain being updated");
1385
+ }
1386
+ ids.add(id);
1387
+ total += item.allocation_bps;
1388
+ return { domain_id: id, allocation_bps: item.allocation_bps };
1389
+ });
1390
+ if (total > 1e4) throw new Error("Total domain allocation must not exceed 10000 basis points");
1391
+ return input;
1392
+ }
1393
+
1394
+ // src/commands/te-experiment/traffic-domain/list.ts
1395
+ var trafficDomainList = createExperimentCapabilityCommand({
1396
+ resource: "traffic-domain",
1397
+ command: "list",
1398
+ capabilityId: "experiment.traffic_domain.list",
1399
+ description: "List traffic domains grouped into bucket Spaces with quotas, versions, and permissions.",
1400
+ flags: [
1401
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Numeric project ID." },
1402
+ { name: "bucket-id", type: "string", desc: "Bucket subject: #user_id, #account_id, #distinct_id, or #device_id." }
1403
+ ],
1404
+ risk: "read",
1405
+ validate: (ctx) => {
1406
+ baseInput(ctx);
1407
+ },
1408
+ buildInput: baseInput
1409
+ });
1410
+
1411
+ // src/commands/te-experiment/traffic-domain/create.ts
1412
+ var trafficDomainCreate = createExperimentCapabilityCommand({
1413
+ resource: "traffic-domain",
1414
+ command: "create",
1415
+ capabilityId: "experiment.traffic_domain.create",
1416
+ description: "Create a traffic domain with complete Space quotas.",
1417
+ flags: [
1418
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Numeric project ID." },
1419
+ { name: "bucket-id", type: "string", required: true, desc: "Bucket subject: #user_id, #account_id, #distinct_id, or #device_id." },
1420
+ { name: "name", type: "string", required: true, desc: "Domain name, 1 to 128 characters; unique within the bucket subject." },
1421
+ { name: "description", type: "string", desc: "Domain description, at most 200 characters; omitted value clears the description." },
1422
+ { name: "allocation-bps", type: "number", required: true, desc: "Domain quota in integer basis points (1 to 10000; 10000 = 100%)." },
1423
+ { name: "expected-version", type: "number", required: true, desc: "Current Space allocation_version from list; use 0 only when no domains exist." },
1424
+ { name: "allocations", type: "json", desc: 'Complete other-domain quotas: [{"domain_id":"d1","allocation_bps":3000}]; omit only for the first domain.' }
1425
+ ],
1426
+ risk: "write",
1427
+ validate: (ctx) => {
1428
+ writeInput(ctx, true);
1429
+ },
1430
+ buildInput: (ctx) => writeInput(ctx, true)
1431
+ });
1432
+
1433
+ // src/commands/te-experiment/traffic-domain/update.ts
1434
+ var trafficDomainUpdate = createExperimentCapabilityCommand({
1435
+ resource: "traffic-domain",
1436
+ command: "update",
1437
+ capabilityId: "experiment.traffic_domain.update",
1438
+ description: "Update traffic domain metadata and optionally replace complete Space quotas.",
1439
+ flags: [
1440
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Numeric project ID." },
1441
+ { name: "domain-id", type: "string", required: true, desc: "Existing traffic domain ID in this project." },
1442
+ { name: "bucket-id", type: "string", desc: "Bucket subject: #user_id, #account_id, #distinct_id, or #device_id." },
1443
+ { name: "name", type: "string", required: true, desc: "Domain name, 1 to 128 characters; unique within the bucket subject." },
1444
+ { name: "description", type: "string", desc: "Domain description, at most 200 characters; omitted value clears the description." },
1445
+ { name: "allocation-bps", type: "number", desc: "Domain quota in integer basis points (1 to 10000; 10000 = 100%)." },
1446
+ { name: "expected-version", type: "number", desc: "Current Space allocation_version from list; use 0 only when no domains exist." },
1447
+ { name: "allocations", type: "json", desc: 'Complete other-domain quotas: [{"domain_id":"d1","allocation_bps":3000}]; required with --allocation-bps and --expected-version; exclude this domain.' }
1448
+ ],
1449
+ risk: "write",
1450
+ validate: (ctx) => {
1451
+ writeInput(ctx, false);
1452
+ },
1453
+ buildInput: (ctx) => writeInput(ctx, false)
1454
+ });
1455
+
1456
+ // src/commands/te-experiment/traffic-domain/delete.ts
1457
+ var trafficDomainDelete = createExperimentCapabilityCommand({
1458
+ resource: "traffic-domain",
1459
+ command: "delete",
1460
+ capabilityId: "experiment.traffic_domain.delete",
1461
+ description: "Delete a traffic domain and unbind its layers while retaining layers and experiments.",
1462
+ flags: [
1463
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Numeric project ID." },
1464
+ { name: "domain-id", type: "string", required: true, desc: "Existing traffic domain ID in this project." },
1465
+ { name: "expected-version", type: "number", required: true, desc: "Current Space allocation_version from list; use 0 only when no domains exist." }
1466
+ ],
1467
+ risk: "high-risk-write",
1468
+ validate: (ctx) => {
1469
+ baseInput(ctx);
1470
+ domainId(ctx);
1471
+ integerFlag(ctx, "expected-version", 0);
1472
+ },
1473
+ buildInput: (ctx) => ({ ...baseInput(ctx), domain_id: domainId(ctx), expected_version: integerFlag(ctx, "expected-version", 0) })
1474
+ });
1475
+
1297
1476
  // src/commands/te-experiment/traffic-layer/batch-delete.ts
1298
1477
  var trafficLayerBatchDelete = createExperimentCapabilityCommand({
1299
1478
  resource: "traffic-layer",
@@ -1347,7 +1526,7 @@ var trafficLayerSave = createExperimentCapabilityCommand({
1347
1526
  description: "Create or update a traffic layer.",
1348
1527
  flags: [
1349
1528
  { name: "project-id", type: "number", required: true, alias: "p", desc: "Numeric project ID." },
1350
- { name: "req", type: "json", required: true, desc: "Native camelCase traffic layer save request object." }
1529
+ { name: "req", type: "json", required: true, desc: "Native camelCase traffic layer save request; optional domainId binds a domain, empty string clears membership on eligible layers." }
1351
1530
  ],
1352
1531
  risk: "write",
1353
1532
  validate: (ctx) => {
@@ -1381,6 +1560,10 @@ var commands = [
1381
1560
  operationLogQuery,
1382
1561
  saveBuildGuide,
1383
1562
  saveValidate,
1563
+ trafficDomainList,
1564
+ trafficDomainCreate,
1565
+ trafficDomainUpdate,
1566
+ trafficDomainDelete,
1384
1567
  trafficLayerSave,
1385
1568
  trafficLayerGet,
1386
1569
  trafficLayerList,
@@ -1449,6 +1632,10 @@ export {
1449
1632
  reportSummary,
1450
1633
  saveBuildGuide,
1451
1634
  saveValidate,
1635
+ trafficDomainCreate,
1636
+ trafficDomainDelete,
1637
+ trafficDomainList,
1638
+ trafficDomainUpdate,
1452
1639
  trafficLayerBatchDelete,
1453
1640
  trafficLayerGet,
1454
1641
  trafficLayerList,
@@ -2,26 +2,27 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  kbApi,
4
4
  kbUpload
5
- } from "./chunk-FCAA7I2D.js";
5
+ } from "./chunk-KD5UC33N.js";
6
6
  import {
7
7
  TeAgentApiError
8
- } from "./chunk-5M5LBRR3.js";
8
+ } from "./chunk-VLOGOM7N.js";
9
9
  import {
10
10
  printError
11
- } from "./chunk-3ULDJJTZ.js";
11
+ } from "./chunk-O45NOIWR.js";
12
12
  import {
13
13
  CapabilityGatewayError
14
- } from "./chunk-4XKTRCRK.js";
15
- import "./chunk-Y74WTIKJ.js";
16
- import "./chunk-DWBYNGSR.js";
17
- import "./chunk-HTZ2MLYA.js";
18
- import "./chunk-4PSTYEG5.js";
14
+ } from "./chunk-4IQYPWCX.js";
15
+ import "./chunk-NNK3JBH4.js";
16
+ import "./chunk-E3ONSFUN.js";
17
+ import "./chunk-PUSFEC6B.js";
18
+ import "./chunk-PLNS5J33.js";
19
+ import "./chunk-AMURHMS3.js";
19
20
  import {
20
21
  CliApiError,
21
22
  CliValidationError,
22
23
  PermissionError,
23
24
  kbExecutionContextRequired
24
- } from "./chunk-Z3Q2AEIN.js";
25
+ } from "./chunk-R2SVAO4G.js";
25
26
 
26
27
  // src/commands/te-kb/project-target.ts
27
28
  var API_PATH = "/agent/api/project-semantic-target";
@@ -221,7 +222,15 @@ function createBody(ctx) {
221
222
  (source) => !source || !["personal", "company", "system"].includes(source.scope) || typeof source.name !== "string" || !source.name || Object.keys(source).some((key) => !["name", "scope"].includes(key))
222
223
  )))
223
224
  throw new CliValidationError("--sources must be an array of {scope,name}");
225
+ const candidateId = ctx.str("candidate");
226
+ if (candidateId || ctx.has?.("candidate")) {
227
+ if (!/^[A-Za-z0-9_-]{1,191}$/.test(candidateId))
228
+ throw new CliValidationError("Invalid --candidate");
229
+ if (!Array.isArray(sources) || sources.length !== 1 || sources[0].scope !== "company")
230
+ throw new CliValidationError("--candidate requires exactly one company KB in --sources");
231
+ }
224
232
  return {
233
+ ...candidateId ? { candidateId } : {},
225
234
  ...sources ? { sources } : {},
226
235
  ...ctx.str("locale") ? { locale: ctx.str("locale") } : {}
227
236
  };
@@ -231,13 +240,14 @@ var readContextCreate = {
231
240
  resource: "read-context",
232
241
  command: "create",
233
242
  risk: "read",
234
- description: "Pin the current authorized formal KB views for subsequent reads (15 minutes).",
243
+ description: "Pin authorized formal KB views or one pending candidate for subsequent reads (15 minutes).",
235
244
  flags: [
236
245
  {
237
246
  name: "sources",
238
247
  type: "json",
239
248
  desc: "Optional array of {scope,name}; omit to discover authorized published KBs"
240
249
  },
250
+ { ...candidate, required: false },
241
251
  { name: "locale", type: "string", desc: "zh | en | ja | ko" }
242
252
  ],
243
253
  validate: (ctx) => {
@@ -248,7 +258,16 @@ var readContextCreate = {
248
258
  url: ctx.host().replace(/\/$/, "") + `${root}/read-contexts`,
249
259
  body: createBody(ctx)
250
260
  }),
251
- execute: (ctx) => kbApi(ctx, "POST", `${root}/read-contexts`, {}, createBody(ctx), options)
261
+ execute: async (ctx) => {
262
+ const body4 = createBody(ctx);
263
+ const result = await kbApi(ctx, "POST", `${root}/read-contexts`, {}, body4, options);
264
+ if (body4.candidateId && (!result?.readContextId || !Array.isArray(result.views) || result.views.length !== 1 || result.views[0]?.viewKind !== "candidate" || result.views[0]?.candidateId !== body4.candidateId))
265
+ throw new CliApiError("This server did not return the requested candidate read context.", {
266
+ code: "KB_CANDIDATE_READ_CONTEXT_UNSUPPORTED",
267
+ hint: "Use a Host that supports candidate read contexts."
268
+ });
269
+ return result;
270
+ }
252
271
  };
253
272
  var readContextRelease = {
254
273
  service: "kb",
@@ -1764,6 +1783,26 @@ var kbRead = {
1764
1783
  execute: async (ctx) => kbApi(ctx, "POST", API_PATH16, {}, buildBody10(ctx))
1765
1784
  };
1766
1785
 
1786
+ // src/commands/te-kb/ask-identity.ts
1787
+ function askIdentity(value) {
1788
+ function invalid() {
1789
+ throw new CliValidationError("Ask response is missing or has inconsistent readViews. This host may not support explicit contexts.", { code: "KB_READ_CONTEXT_MISMATCH" });
1790
+ }
1791
+ if (!Array.isArray(value) || !value.length || value.length > 100) return invalid();
1792
+ const identities = value.map((view) => {
1793
+ if (!view || typeof view !== "object") return invalid();
1794
+ const text = (key) => typeof view[key] === "string" && view[key].trim().length > 0;
1795
+ if (!text("resourceKey") || !text("readIdentity")) return invalid();
1796
+ if (view.viewKind === "candidate") {
1797
+ if (view.consistency !== "candidate_pinned" || !text("candidateId") || !(view.baseVersion === null || text("baseVersion")) || view.versionId !== null || view.versionNumber !== null)
1798
+ return invalid();
1799
+ } else if (view.viewKind !== "snapshot" || view.consistency !== "version_pinned" || !text("versionId") || !Number.isSafeInteger(view.versionNumber) || view.versionNumber < 1) return invalid();
1800
+ return ["resourceKey", "viewKind", "consistency", "readIdentity", "versionId", "versionNumber", "candidateId", "baseVersion"].map((key) => view[key] ?? null);
1801
+ });
1802
+ if (new Set(identities.map((view) => view[0])).size !== identities.length) return invalid();
1803
+ return JSON.stringify(identities.sort((a, b) => String(a[0]).localeCompare(String(b[0]))));
1804
+ }
1805
+
1767
1806
  // src/commands/te-kb/ask-shared.ts
1768
1807
  var ASK_API_PATH = "/agent/api/external/knowledge-bases/ask";
1769
1808
  var ASK_POLL_INTERVAL_MS = 5e3;
@@ -1818,6 +1857,7 @@ function transformCompletedResponse(response) {
1818
1857
  answer: response.answer ?? "",
1819
1858
  sources: response.sources ?? []
1820
1859
  };
1860
+ if (response.readViews !== void 0) result.readViews = response.readViews;
1821
1861
  if (response.modelId !== void 0) result.modelId = response.modelId;
1822
1862
  if (response.modelUsage !== void 0) result.modelUsage = response.modelUsage;
1823
1863
  if (response.toolCallCount !== void 0) result.toolCallCount = response.toolCallCount;
@@ -1858,6 +1898,7 @@ var ask = {
1858
1898
  command: "+ask",
1859
1899
  description: "Ask knowledge bases via LLM-powered retrieval (POST /agent/api/external/knowledge-bases/ask). Consumes platform tokens. Prefer +index -> +grep -> +read for deterministic, token-free lookup. By default, polls for completion; use --no-wait to return immediately with executionId.",
1860
1900
  flags: [
1901
+ { name: "read-context", type: "string", required: false, desc: "Use an existing formal snapshot or pending candidate context. Omit for existing published Ask behavior." },
1861
1902
  {
1862
1903
  name: "question",
1863
1904
  type: "string",
@@ -1893,23 +1934,31 @@ var ask = {
1893
1934
  dryRun: (ctx) => ({
1894
1935
  method: "POST",
1895
1936
  url: `${ctx.host().replace(/\/$/, "")}${ASK_API_PATH}`,
1896
- body: buildBody11(ctx)
1937
+ body: buildBody11(ctx),
1938
+ ...ctx.str("read-context") ? { headers: { "X-KB-Read-Context": ctx.str("read-context") } } : {}
1897
1939
  }),
1898
1940
  execute: async (ctx) => {
1899
1941
  const noWait = ctx.bool("no-wait");
1900
- const submitResponse = await kbApi(ctx, "POST", ASK_API_PATH, {}, buildBody11(ctx));
1942
+ const submitResponse = await kbApi(ctx, "POST", ASK_API_PATH, {}, buildBody11(ctx), ctx.str("read-context") ? { preserveErrorMetadata: true } : {});
1901
1943
  if (!submitResponse.executionId) {
1902
1944
  throw new Error("Invalid submit response: missing executionId");
1903
1945
  }
1904
1946
  const executionId = submitResponse.executionId;
1947
+ const identity = ctx.str("read-context") ? askIdentity(submitResponse.readViews) : void 0;
1905
1948
  if (noWait) {
1906
1949
  return {
1907
1950
  executionId,
1908
- status: submitResponse.status
1951
+ status: submitResponse.status,
1952
+ ...identity ? { readViews: submitResponse.readViews } : {}
1909
1953
  };
1910
1954
  }
1911
1955
  const finalResponse = await pollUntilSettled(
1912
- (id) => kbApi(ctx, "GET", ASK_API_PATH, { executionId: id }),
1956
+ async (id) => {
1957
+ const response = await kbApi(ctx, "GET", ASK_API_PATH, { executionId: id }, void 0, identity ? { preserveErrorMetadata: true } : {});
1958
+ if (identity && askIdentity(response.readViews) !== identity)
1959
+ throw new CliValidationError("Ask response changed its version identity.", { code: "KB_READ_CONTEXT_MISMATCH" });
1960
+ return response;
1961
+ },
1913
1962
  executionId
1914
1963
  );
1915
1964
  if (finalResponse.status === "completed") {
@@ -1984,10 +2033,12 @@ var askStatus = {
1984
2033
  { code: "KB_READ_CONTEXT_REFERENCE_FORBIDDEN" }
1985
2034
  );
1986
2035
  }
1987
- return kbApi(ctx, "GET", ASK_API_PATH, {
2036
+ const result = await kbApi(ctx, "GET", ASK_API_PATH, {
1988
2037
  executionId,
1989
2038
  ...sourceIndex !== void 0 ? { sourceIndex } : {}
1990
- });
2039
+ }, void 0, { preserveErrorMetadata: true });
2040
+ if (result.readViews !== void 0) askIdentity(result.readViews);
2041
+ return result;
1991
2042
  }
1992
2043
  };
1993
2044
 
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  require_archiver
4
- } from "./chunk-OAWPT7VP.js";
5
- import "./chunk-JEUXDY3B.js";
4
+ } from "./chunk-2I5SZ5DS.js";
5
+ import "./chunk-HQED4YB4.js";
6
6
  import {
7
7
  TeAgentApiError,
8
8
  deleteFromMainApp,
@@ -12,19 +12,18 @@ import {
12
12
  postToMainApp,
13
13
  putToMainApp,
14
14
  uploadToMainApp
15
- } from "./chunk-5M5LBRR3.js";
16
- import "./chunk-Y74WTIKJ.js";
17
- import "./chunk-HTZ2MLYA.js";
15
+ } from "./chunk-VLOGOM7N.js";
16
+ import "./chunk-PLNS5J33.js";
18
17
  import {
19
18
  isAeSandboxRuntime,
20
19
  readSandboxCliTokenEntry,
21
20
  safeJsonParse
22
- } from "./chunk-4PSTYEG5.js";
21
+ } from "./chunk-AMURHMS3.js";
23
22
  import {
24
23
  CliValidationError,
25
24
  PermissionError,
26
25
  __toESM
27
- } from "./chunk-Z3Q2AEIN.js";
26
+ } from "./chunk-R2SVAO4G.js";
28
27
 
29
28
  // src/commands/te-system/shared.ts
30
29
  import { readFileSync } from "fs";
@@ -2,20 +2,21 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  getAuthHeaders,
4
4
  kbApi
5
- } from "./chunk-FCAA7I2D.js";
5
+ } from "./chunk-KD5UC33N.js";
6
6
  import {
7
7
  printError,
8
8
  printOutput
9
- } from "./chunk-3ULDJJTZ.js";
10
- import "./chunk-4XKTRCRK.js";
11
- import "./chunk-Y74WTIKJ.js";
12
- import "./chunk-DWBYNGSR.js";
13
- import "./chunk-HTZ2MLYA.js";
14
- import "./chunk-4PSTYEG5.js";
9
+ } from "./chunk-O45NOIWR.js";
10
+ import "./chunk-4IQYPWCX.js";
11
+ import "./chunk-NNK3JBH4.js";
12
+ import "./chunk-E3ONSFUN.js";
13
+ import "./chunk-PUSFEC6B.js";
14
+ import "./chunk-PLNS5J33.js";
15
+ import "./chunk-AMURHMS3.js";
15
16
  import {
16
17
  externalCliTokenRequestOptions,
17
18
  redactExternalCliToken
18
- } from "./chunk-Z3Q2AEIN.js";
19
+ } from "./chunk-R2SVAO4G.js";
19
20
 
20
21
  // src/commands/te-team/shared.ts
21
22
  var API_PREFIX = process.env.AE_API_PREFIX ?? "/agent";