@thinkingai/ae-cli 6.1.27 → 6.1.29

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 (177) hide show
  1. package/README.md +52 -6
  2. package/README.zh.md +52 -6
  3. package/bin/ae-cli.js +5 -0
  4. package/bin/runtime-capabilities.json +5 -0
  5. package/cli-installation-guide.md +24 -3
  6. package/dist/{auth-WA7YGGRT.js → auth-OBQ5KVQM.js} +175 -45
  7. package/dist/{automation-VAAQBM7Y.js → automation-NAR5DDGL.js} +94 -38
  8. package/dist/{capability-GAAYJ3IQ.js → capability-LFSVNI5B.js} +57 -28
  9. package/dist/chunk-2UW3Y463.js +2289 -0
  10. package/dist/{chunk-VZZNLV3I.js → chunk-3SDHJOCR.js} +68 -18
  11. package/dist/chunk-6HAUVWOQ.js +132 -0
  12. package/dist/{chunk-5XJYLEVC.js → chunk-72NJKS7O.js} +4 -4
  13. package/dist/{chunk-Q5US7JC5.js → chunk-7JAVT5TK.js} +3 -3
  14. package/dist/{chunk-7KU2WNQE.js → chunk-CVCTFLSO.js} +37 -15
  15. package/dist/{chunk-GHXZK54S.js → chunk-H3K5UGYC.js} +41 -13
  16. package/dist/{chunk-OP44TT4H.js → chunk-IN7KKL6K.js} +4 -2
  17. package/dist/{chunk-S6M42KND.js → chunk-JEUXDY3B.js} +1 -1
  18. package/dist/{chunk-ZL7SGNIA.js → chunk-JNVVJ273.js} +58 -46
  19. package/dist/chunk-N6XBLRB7.js +105 -0
  20. package/dist/{chunk-AP7YP2NX.js → chunk-OAWPT7VP.js} +2 -2
  21. package/dist/{chunk-AQJPNWZF.js → chunk-PWXDWMCW.js} +7 -7
  22. package/dist/{chunk-CT7QDJS6.js → chunk-QVRIDN42.js} +2 -2
  23. package/dist/chunk-QZLRHGVH.js +222 -0
  24. package/dist/{chunk-RPBOAQQQ.js → chunk-QZUVLFNR.js} +1 -1
  25. package/dist/{chunk-3YVEAZUN.js → chunk-RJHGDWSC.js} +32 -21
  26. package/dist/{chunk-MWIA43UJ.js → chunk-VCZE3IWO.js} +10 -8
  27. package/dist/chunk-YVG6QD3V.js +233 -0
  28. package/dist/{chunk-WNGFSIOB.js → chunk-Z3Q2AEIN.js} +237 -86
  29. package/dist/{community-report-client-PEERQCX2.js → community-report-client-TJVCLZ3K.js} +1 -1
  30. package/dist/compat-check-CII6B74E.js +32 -0
  31. package/dist/{config-JOD5DOPE.js → config-YZ6O2UQ2.js} +40 -7
  32. package/dist/{context-NGVFPCBK.js → context-F6FCGTF3.js} +4 -4
  33. package/dist/{data-integration-BCLQFTGU.js → data-integration-6UAZO4GG.js} +207 -24
  34. package/dist/evaluation-4LO2O4AF.js +3714 -0
  35. package/dist/index.js +352 -81
  36. package/dist/{local-data-upload-client-TWMHFLUA.js → local-data-upload-client-KCMG6J62.js} +1 -1
  37. package/dist/{memory-CQKH2JAV.js → memory-HHPX3NF2.js} +6 -6
  38. package/dist/{metadata-NR3PHR23.js → metadata-TIFY24LW.js} +17 -9
  39. package/dist/{model-VX5M2CJ6.js → model-7UHGWYVR.js} +4 -4
  40. package/dist/{personal-semantic-preference-2RAI36P3.js → personal-semantic-preference-WKJEGPTM.js} +7 -6
  41. package/dist/{project-semantic-3BUGP3ZM.js → project-semantic-EIQVZNHW.js} +11 -10
  42. package/dist/{sync-RZIAV37C.js → sync-RV3OPCTI.js} +8 -7
  43. package/dist/{te-agent-AORRE2FM.js → te-agent-5ENVZJUH.js} +757 -94
  44. package/dist/{te-analysis-GP7DSQ7Q.js → te-analysis-USIK6ZZG.js} +584 -100
  45. package/dist/{te-community-42M7ICDO.js → te-community-WE2UU4XV.js} +722 -228
  46. package/dist/{te-dataops-BNKNZ4F2.js → te-dataops-XNMO7MBF.js} +9 -6
  47. package/dist/{te-engage-2CO6LRCX.js → te-engage-6C3HCFQR.js} +13 -12
  48. package/dist/{te-experiment-652CLXMU.js → te-experiment-LVTRI3QK.js} +55 -21
  49. package/dist/{te-kb-ULATOTQ3.js → te-kb-TUPGMVBY.js} +409 -85
  50. package/dist/{te-system-UGHVKBVV.js → te-system-YM657FKO.js} +6 -6
  51. package/dist/{te-team-YA6SNOJ3.js → te-team-G4VEJJNL.js} +64 -41
  52. package/dist/{things-DTCOQIQB.js → things-22KQWC23.js} +7 -7
  53. package/dist/{update-ESNYKUVR.js → update-XX4ILU7X.js} +11 -7
  54. package/dist/{workspace-JEOHKFPX.js → workspace-LYDAP647.js} +6 -6
  55. package/package.json +26 -11
  56. package/skills/ae-agent/SKILL.md +22 -3
  57. package/skills/ae-agent/references/command_index.md +8 -0
  58. package/skills/ae-agent/references/resource-package.md +57 -0
  59. package/skills/ae-analysis/SKILL.md +23 -10
  60. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  61. package/skills/ae-analysis/references/agent_review_preflight.md +55 -10
  62. package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
  63. package/skills/ae-analysis/references/agent_review_submit_to_page.md +60 -24
  64. package/skills/ae-analysis/references/ai_models/event.md +58 -2
  65. package/skills/ae-analysis/references/ai_models/rank_list.md +1 -0
  66. package/skills/ae-analysis/references/ai_models/retention.md +2 -0
  67. package/skills/ae-analysis/references/ai_models/revenue.md +2 -0
  68. package/skills/ae-analysis/references/analysis_data_export.md +11 -1
  69. package/skills/ae-analysis/references/asset_batch_info_export.md +2 -2
  70. package/skills/ae-analysis/references/asset_batch_sql_export.md +2 -2
  71. package/skills/ae-analysis/references/asset_export.md +1 -1
  72. package/skills/ae-analysis/references/bi_panel_page_data_export.md +1 -1
  73. package/skills/ae-analysis/references/check_export.md +1 -1
  74. package/skills/ae-analysis/references/command_index.md +39 -26
  75. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  76. package/skills/ae-analysis/references/dashboard_report_get.md +6 -2
  77. package/skills/ae-analysis/references/dashboard_report_update.md +24 -5
  78. package/skills/ae-analysis/references/feedback_submit.md +1 -1
  79. package/skills/ae-analysis/references/governance_recommendation_export.md +40 -18
  80. package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
  81. package/skills/ae-analysis/references/live_data_export.md +1 -1
  82. package/skills/ae-analysis/references/metric_create.md +29 -0
  83. package/skills/ae-analysis/references/metric_get.md +2 -0
  84. package/skills/ae-analysis/references/metric_update.md +2 -0
  85. package/skills/ae-analysis/references/operation_record_export.md +1 -1
  86. package/skills/ae-analysis/references/plan_change_log_export.md +1 -1
  87. package/skills/ae-analysis/references/plan_export.md +1 -1
  88. package/skills/ae-analysis/references/project_info_get.md +4 -0
  89. package/skills/ae-analysis/references/project_member_group_add_members.md +35 -0
  90. package/skills/ae-analysis/references/project_member_group_create.md +25 -0
  91. package/skills/ae-analysis/references/project_member_group_delete.md +34 -0
  92. package/skills/ae-analysis/references/project_member_group_list.md +29 -0
  93. package/skills/ae-analysis/references/project_member_group_members.md +28 -0
  94. package/skills/ae-analysis/references/project_member_group_remove_members.md +35 -0
  95. package/skills/ae-analysis/references/project_member_group_rename.md +26 -0
  96. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
  97. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +6 -1
  98. package/skills/ae-analysis/references/report_data_export.md +1 -1
  99. package/skills/ae-analysis/references/scenario_append.md +31 -0
  100. package/skills/ae-analysis/references/scenario_begin.md +11 -0
  101. package/skills/ae-analysis/references/scenario_collect.md +43 -0
  102. package/skills/ae-analysis/references/scenario_evaluation.md +18 -0
  103. package/skills/ae-analysis/references/scenario_get.md +15 -0
  104. package/skills/ae-analysis/references/scenario_list.md +64 -0
  105. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +73 -4
  106. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
  107. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +5 -1
  108. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/execution-contract.mjs +173 -0
  109. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +109 -64
  110. package/skills/ae-automation/SKILL.md +2 -2
  111. package/skills/ae-automation/references/cli.md +18 -1
  112. package/skills/ae-capability/SKILL.md +7 -3
  113. package/skills/ae-community/SKILL.md +77 -27
  114. package/skills/ae-community/references/community-analyzing-theme-comment.md +10 -8
  115. package/skills/ae-community/references/community-data-quality.md +68 -0
  116. package/skills/ae-community/references/community-query-evidence.md +85 -0
  117. package/skills/ae-community/references/community-scenario-capabilities.md +137 -0
  118. package/skills/ae-community/references/community-weekly-report.md +6 -3
  119. package/skills/ae-community/references/get_channel_info.md +7 -4
  120. package/skills/ae-community/references/get_comment_tag_analysis.md +3 -3
  121. package/skills/ae-community/references/get_comments_summary.md +4 -4
  122. package/skills/ae-community/references/get_corpus_tags.md +3 -3
  123. package/skills/ae-community/references/get_daily_summary.md +3 -3
  124. package/skills/ae-community/references/get_hot_topics.md +3 -3
  125. package/skills/ae-community/references/get_livestream_analysis.md +3 -3
  126. package/skills/ae-community/references/get_livestream_detail.md +4 -4
  127. package/skills/ae-community/references/get_livestream_list.md +3 -3
  128. package/skills/ae-community/references/get_livestream_overview.md +3 -3
  129. package/skills/ae-community/references/get_livestream_room_metrics.md +3 -3
  130. package/skills/ae-community/references/get_livestream_rooms.md +3 -3
  131. package/skills/ae-community/references/get_overview_metrics.md +3 -3
  132. package/skills/ae-community/references/get_post_detail.md +4 -4
  133. package/skills/ae-community/references/get_risk_content.md +5 -5
  134. package/skills/ae-community/references/get_sentiment_overview.md +4 -4
  135. package/skills/ae-community/references/get_tag_trends.md +3 -3
  136. package/skills/ae-community/references/get_topic_detail.md +3 -3
  137. package/skills/ae-community/references/list_sources.md +28 -0
  138. package/skills/ae-community/references/list_spaces.md +39 -0
  139. package/skills/ae-community/references/search_posts.md +21 -7
  140. package/skills/ae-data-integration/SKILL.md +6 -4
  141. package/skills/ae-data-integration/references/error-handling.md +1 -0
  142. package/skills/ae-data-integration/references/handoff.md +1 -1
  143. package/skills/ae-data-integration/references/sink-upload.md +11 -0
  144. package/skills/ae-data-integration/references/source-inspect.md +2 -1
  145. package/skills/ae-data-integration/references/transform.md +1 -1
  146. package/skills/ae-data-integration/references/ue-mapping.md +1 -1
  147. package/skills/ae-evaluation/SKILL.md +83 -0
  148. package/skills/ae-evaluation/references/access-and-members.md +55 -0
  149. package/skills/ae-evaluation/references/connections.md +78 -0
  150. package/skills/ae-evaluation/references/datasets.md +57 -0
  151. package/skills/ae-evaluation/references/evaluators.md +81 -0
  152. package/skills/ae-evaluation/references/files.md +33 -0
  153. package/skills/ae-evaluation/references/integrations.md +39 -0
  154. package/skills/ae-evaluation/references/runs.md +160 -0
  155. package/skills/ae-evaluation/references/schedules.md +31 -0
  156. package/skills/ae-experiment/SKILL.md +7 -1
  157. package/skills/ae-experiment/references/manage_experiment.md +18 -1
  158. package/skills/ae-experiment/references/query_experiment_detail.md +7 -0
  159. package/skills/ae-experiment/references/save_experiment.md +76 -2
  160. package/skills/ae-experiment/references/save_submit_experiment.md +7 -0
  161. package/skills/ae-kb/SKILL.md +33 -7
  162. package/skills/ae-kb/references/publication.md +81 -0
  163. package/skills/ae-kb/references/query-workflow.md +14 -1
  164. package/skills/ae-metadata/SKILL.md +3 -2
  165. package/skills/ae-metadata/references/metadata_data_table_download.md +7 -1
  166. package/skills/ae-metadata/references/metadata_data_table_get.md +37 -0
  167. package/skills/ae-system/SKILL.md +1 -1
  168. package/skills/ae-team/SKILL.md +2 -2
  169. package/skills/ae-team/references/run-start.md +1 -0
  170. package/skills/ae-team/references/run-watch.md +7 -5
  171. package/skills/ae-things/SKILL.md +53 -51
  172. package/skills/ae-things/references/cli.md +56 -54
  173. package/skills/ae-things-progress/SKILL.md +20 -20
  174. package/skills/ae-things-review/SKILL.md +19 -19
  175. package/skills/ae-workspace/SKILL.md +1 -1
  176. package/dist/chunk-6VNIR4AP.js +0 -1422
  177. package/dist/chunk-CI24BDR2.js +0 -43
@@ -11,7 +11,7 @@ import {
11
11
  workspaceResourcePath,
12
12
  workspaceTargetFlags,
13
13
  workspaceTargetPath
14
- } from "./chunk-Q5US7JC5.js";
14
+ } from "./chunk-7JAVT5TK.js";
15
15
  import {
16
16
  currentAgentSpaceId
17
17
  } from "./chunk-RK6GLDGI.js";
@@ -19,24 +19,31 @@ import {
19
19
  deleteAgentApi,
20
20
  getAgentApi,
21
21
  getAgentBuffer,
22
+ isTransientResourcePackageError,
22
23
  patchAgentApi,
23
24
  postAgentApi,
24
25
  putAgentApi,
26
+ requestResourcePackageApi,
27
+ requestResourcePackageRaw,
28
+ resourcePackagePreflightChange,
25
29
  uploadAgentApi
26
- } from "./chunk-CI24BDR2.js";
30
+ } from "./chunk-N6XBLRB7.js";
27
31
  import {
32
+ TeAgentApiError,
28
33
  resolveTeClaudeBaseUrl
29
- } from "./chunk-3YVEAZUN.js";
34
+ } from "./chunk-RJHGDWSC.js";
30
35
  import {
31
36
  buildCapabilityGatewayUrl,
32
37
  callCapabilityApi
33
- } from "./chunk-VZZNLV3I.js";
38
+ } from "./chunk-3SDHJOCR.js";
34
39
  import "./chunk-Y74WTIKJ.js";
35
- import "./chunk-GHXZK54S.js";
36
- import "./chunk-ZL7SGNIA.js";
40
+ import "./chunk-H3K5UGYC.js";
41
+ import {
42
+ getConfigDir
43
+ } from "./chunk-JNVVJ273.js";
37
44
  import {
38
45
  CliValidationError
39
- } from "./chunk-WNGFSIOB.js";
46
+ } from "./chunk-Z3Q2AEIN.js";
40
47
 
41
48
  // src/commands/te-agent/notifications.ts
42
49
  import { openSync, closeSync, fstatSync, readSync } from "fs";
@@ -44,28 +51,29 @@ import { openSync, closeSync, fstatSync, readSync } from "fs";
44
51
  // src/commands/te-agent/approval-cli-client.ts
45
52
  var APPROVAL_GATEWAY_DOMAIN = "approval";
46
53
  var resolveApprovalApiBaseUrl = resolveTeClaudeBaseUrl;
47
- function buildApprovalCliUrl(ctx, path) {
48
- return buildCapabilityGatewayUrl(resolveApprovalApiBaseUrl(ctx.host()), APPROVAL_GATEWAY_DOMAIN, path);
54
+ function buildApprovalCliUrl(ctx, path2) {
55
+ return buildCapabilityGatewayUrl(resolveApprovalApiBaseUrl(ctx.host()), APPROVAL_GATEWAY_DOMAIN, path2);
49
56
  }
50
- function requestApprovalCli(ctx, method, path, body, options = {}) {
57
+ function requestApprovalCli(ctx, method, path2, body, options = {}) {
51
58
  return callCapabilityApi(
52
59
  ctx.host(),
53
60
  APPROVAL_GATEWAY_DOMAIN,
54
- path,
61
+ path2,
55
62
  method,
56
63
  body,
57
64
  {
58
65
  apiBaseUrl: resolveApprovalApiBaseUrl(ctx.host()),
66
+ includeClientContextInBody: false,
59
67
  ...options,
60
68
  retryOnInvalidTokenForbidden: false
61
69
  }
62
70
  );
63
71
  }
64
- function getApprovalCli(ctx, path) {
65
- return requestApprovalCli(ctx, "GET", path);
72
+ function getApprovalCli(ctx, path2) {
73
+ return requestApprovalCli(ctx, "GET", path2);
66
74
  }
67
- function postApprovalCli(ctx, path, body, options = {}) {
68
- return requestApprovalCli(ctx, "POST", path, body, options);
75
+ function postApprovalCli(ctx, path2, body, options = {}) {
76
+ return requestApprovalCli(ctx, "POST", path2, body, options);
69
77
  }
70
78
 
71
79
  // src/commands/te-agent/notifications.ts
@@ -204,7 +212,7 @@ function query(ctx, mode) {
204
212
  }
205
213
  return params.toString() ? `?${params}` : "";
206
214
  }
207
- function command(name, description, flags, method, path, body) {
215
+ function command(name, description, flags, method, path2, body) {
208
216
  return {
209
217
  service: "agent",
210
218
  resource: "notification",
@@ -214,7 +222,7 @@ function command(name, description, flags, method, path, body) {
214
222
  flags,
215
223
  risk: method === "GET" ? "read" : "write",
216
224
  validate(ctx) {
217
- path(ctx);
225
+ path2(ctx);
218
226
  body?.(ctx);
219
227
  },
220
228
  dryRun(ctx) {
@@ -224,7 +232,7 @@ function command(name, description, flags, method, path, body) {
224
232
  url: buildCapabilityGatewayUrl(
225
233
  resolveApprovalApiBaseUrl(ctx.host()),
226
234
  "agent",
227
- path(ctx)
235
+ path2(ctx)
228
236
  ),
229
237
  ...payload ? {
230
238
  body: name === "send" ? { ...payload, title: "[redacted]", body: "[redacted]" } : payload
@@ -235,7 +243,7 @@ function command(name, description, flags, method, path, body) {
235
243
  return callCapabilityApi(
236
244
  ctx.host(),
237
245
  "agent",
238
- path(ctx),
246
+ path2(ctx),
239
247
  method,
240
248
  body?.(ctx),
241
249
  {
@@ -355,9 +363,9 @@ var notificationCommands = [
355
363
  var BASE_PATH = "/api/sandbox/agent/agents";
356
364
  function buildQuery(ctx) {
357
365
  const params = new URLSearchParams();
358
- const scope = ctx.str("scope");
366
+ const scope2 = ctx.str("scope");
359
367
  const q = ctx.str("q");
360
- if (scope) params.set("scope", scope);
368
+ if (scope2) params.set("scope", scope2);
361
369
  if (q) params.set("q", q);
362
370
  const qs = params.toString();
363
371
  return qs ? `?${qs}` : "";
@@ -382,8 +390,8 @@ var listAgents = {
382
390
  ],
383
391
  risk: "read",
384
392
  validate: (ctx) => {
385
- const scope = ctx.str("scope");
386
- if (scope && !["personal", "company", "system"].includes(scope)) {
393
+ const scope2 = ctx.str("scope");
394
+ if (scope2 && !["personal", "company", "system"].includes(scope2)) {
387
395
  throw new Error("--scope \u5FC5\u987B\u662F personal\u3001company \u6216 system");
388
396
  }
389
397
  },
@@ -422,8 +430,8 @@ var createAgent = {
422
430
  if (!name || name.length < 1 || name.length > 100) {
423
431
  throw new Error("--name length must be between 1 and 100");
424
432
  }
425
- const scope = ctx.str("scope");
426
- if (scope && !["personal", "company"].includes(scope)) {
433
+ const scope2 = ctx.str("scope");
434
+ if (scope2 && !["personal", "company"].includes(scope2)) {
427
435
  throw new Error("--scope must be personal or company");
428
436
  }
429
437
  },
@@ -569,8 +577,8 @@ var getAgentContext = {
569
577
  ],
570
578
  risk: "read",
571
579
  validate: (ctx) => {
572
- const id = ctx.str("id");
573
- if (!id || id !== id.trim() || id.length > 191) {
580
+ const id2 = ctx.str("id");
581
+ if (!id2 || id2 !== id2.trim() || id2.length > 191) {
574
582
  throw new CliValidationError("--id must be a non-empty identifier of at most 191 characters");
575
583
  }
576
584
  },
@@ -601,11 +609,11 @@ function requireId(ctx, key, flag2) {
601
609
  }
602
610
  return value;
603
611
  }
604
- function url(ctx, path) {
605
- return buildCapabilityGatewayUrl(resolveApprovalApiBaseUrl(ctx.host()), "agent", path);
612
+ function url(ctx, path2) {
613
+ return buildCapabilityGatewayUrl(resolveApprovalApiBaseUrl(ctx.host()), "agent", path2);
606
614
  }
607
- function request(ctx, method, path, body) {
608
- return callCapabilityApi(ctx.host(), "agent", path, method, body, {
615
+ function request(ctx, method, path2, body) {
616
+ return callCapabilityApi(ctx.host(), "agent", path2, method, body, {
609
617
  apiBaseUrl: resolveApprovalApiBaseUrl(ctx.host()),
610
618
  retryOnInvalidTokenForbidden: false
611
619
  });
@@ -647,7 +655,7 @@ var expectedVersionFlag = {
647
655
  };
648
656
  function shareBody(ctx) {
649
657
  const recipients = ctx.json("toUserIds");
650
- if (!Array.isArray(recipients) || recipients.length < 1 || recipients.length > 50 || recipients.some((id) => typeof id !== "string" || !id || id.trim() !== id || id.length > 191) || new Set(recipients).size !== recipients.length) {
658
+ if (!Array.isArray(recipients) || recipients.length < 1 || recipients.length > 50 || recipients.some((id2) => typeof id2 !== "string" || !id2 || id2.trim() !== id2 || id2.length > 191) || new Set(recipients).size !== recipients.length) {
651
659
  throw new CliValidationError(
652
660
  "--to-user-ids must be a JSON array of 1-50 distinct non-empty user IDs"
653
661
  );
@@ -865,22 +873,22 @@ var listModels = {
865
873
  ],
866
874
  risk: "read",
867
875
  validate: (ctx) => {
868
- const scope = ctx.str("scope");
869
- if (scope && !["personal", "company", "system"].includes(scope)) {
876
+ const scope2 = ctx.str("scope");
877
+ if (scope2 && !["personal", "company", "system"].includes(scope2)) {
870
878
  throw new Error("--scope must be personal, company, or system");
871
879
  }
872
880
  },
873
881
  dryRun: (ctx) => {
874
- const scope = ctx.str("scope");
882
+ const scope2 = ctx.str("scope");
875
883
  const params = new URLSearchParams();
876
- if (scope) params.set("scope", scope);
884
+ if (scope2) params.set("scope", scope2);
877
885
  const qs = params.toString();
878
886
  return { method: "GET", url: `${BASE_PATH2}${qs ? `?${qs}` : ""}` };
879
887
  },
880
888
  execute: async (ctx) => {
881
- const scope = ctx.str("scope");
889
+ const scope2 = ctx.str("scope");
882
890
  const params = new URLSearchParams();
883
- if (scope) params.set("scope", scope);
891
+ if (scope2) params.set("scope", scope2);
884
892
  const qs = params.toString();
885
893
  const current = process.env.TE_AGENT_CURRENT_MODEL_ID?.trim();
886
894
  const data = await getAgentApi(
@@ -944,8 +952,8 @@ var addModel = {
944
952
  } catch {
945
953
  throw new Error("--base-url must be a valid URL");
946
954
  }
947
- const scope = ctx.str("scope");
948
- if (scope && !["personal", "company"].includes(scope)) {
955
+ const scope2 = ctx.str("scope");
956
+ if (scope2 && !["personal", "company"].includes(scope2)) {
949
957
  throw new Error("--scope must be personal or company");
950
958
  }
951
959
  },
@@ -997,19 +1005,19 @@ var delModel = {
997
1005
  ],
998
1006
  risk: "high-risk-write",
999
1007
  validate: (ctx) => {
1000
- const scope = ctx.str("scope");
1001
- if (scope && !["personal", "company"].includes(scope)) {
1008
+ const scope2 = ctx.str("scope");
1009
+ if (scope2 && !["personal", "company"].includes(scope2)) {
1002
1010
  throw new Error("--scope must be personal or company");
1003
1011
  }
1004
1012
  },
1005
1013
  dryRun: (ctx) => {
1006
- const scope = ctx.str("scope") || "personal";
1007
- const qs = `id=${encodeURIComponent(ctx.str("id"))}&scope=${encodeURIComponent(scope)}`;
1014
+ const scope2 = ctx.str("scope") || "personal";
1015
+ const qs = `id=${encodeURIComponent(ctx.str("id"))}&scope=${encodeURIComponent(scope2)}`;
1008
1016
  return { method: "DELETE", url: `${BASE_PATH2}?${qs}` };
1009
1017
  },
1010
1018
  execute: async (ctx) => {
1011
- const scope = ctx.str("scope") || "personal";
1012
- const qs = `id=${encodeURIComponent(ctx.str("id"))}&scope=${encodeURIComponent(scope)}`;
1019
+ const scope2 = ctx.str("scope") || "personal";
1020
+ const qs = `id=${encodeURIComponent(ctx.str("id"))}&scope=${encodeURIComponent(scope2)}`;
1013
1021
  return deleteAgentApi(ctx, `${BASE_PATH2}?${qs}`);
1014
1022
  }
1015
1023
  };
@@ -1069,8 +1077,8 @@ var updateModel = {
1069
1077
  } catch {
1070
1078
  throw new Error("--base-url must be a valid URL");
1071
1079
  }
1072
- const scope = ctx.str("scope");
1073
- if (scope && !["personal", "company"].includes(scope)) {
1080
+ const scope2 = ctx.str("scope");
1081
+ if (scope2 && !["personal", "company"].includes(scope2)) {
1074
1082
  throw new Error("--scope must be personal or company");
1075
1083
  }
1076
1084
  },
@@ -1144,8 +1152,8 @@ var testModel = {
1144
1152
  if (apiKey) body.apiKey = apiKey;
1145
1153
  const provider = ctx.str("provider");
1146
1154
  if (provider) body.provider = provider;
1147
- const id = ctx.str("id");
1148
- if (id) body.existingConfigId = id;
1155
+ const id2 = ctx.str("id");
1156
+ if (id2) body.existingConfigId = id2;
1149
1157
  return { method: "POST", url: `${BASE_PATH2}/test`, body };
1150
1158
  },
1151
1159
  execute: async (ctx) => {
@@ -1157,8 +1165,8 @@ var testModel = {
1157
1165
  if (apiKey) body.apiKey = apiKey;
1158
1166
  const provider = ctx.str("provider");
1159
1167
  if (provider) body.provider = provider;
1160
- const id = ctx.str("id");
1161
- if (id) body.existingConfigId = id;
1168
+ const id2 = ctx.str("id");
1169
+ if (id2) body.existingConfigId = id2;
1162
1170
  return postAgentApi(ctx, `${BASE_PATH2}/test`, body);
1163
1171
  }
1164
1172
  };
@@ -1220,19 +1228,19 @@ var listMcps = {
1220
1228
  ],
1221
1229
  risk: "read",
1222
1230
  validate: (ctx) => {
1223
- const scope = ctx.str("scope");
1224
- if (scope && !["personal", "company", "system"].includes(scope)) {
1231
+ const scope2 = ctx.str("scope");
1232
+ if (scope2 && !["personal", "company", "system"].includes(scope2)) {
1225
1233
  throw new Error("--scope must be personal, company, or system");
1226
1234
  }
1227
1235
  },
1228
1236
  dryRun: (ctx) => {
1229
- const scope = ctx.str("scope");
1230
- const qs = scope ? `?scope=${encodeURIComponent(scope)}` : "";
1237
+ const scope2 = ctx.str("scope");
1238
+ const qs = scope2 ? `?scope=${encodeURIComponent(scope2)}` : "";
1231
1239
  return { method: "GET", url: `${BASE_PATH3}${qs}` };
1232
1240
  },
1233
1241
  execute: async (ctx) => {
1234
- const scope = ctx.str("scope");
1235
- const qs = scope ? `?scope=${encodeURIComponent(scope)}` : "";
1242
+ const scope2 = ctx.str("scope");
1243
+ const qs = scope2 ? `?scope=${encodeURIComponent(scope2)}` : "";
1236
1244
  return getAgentApi(ctx, `${BASE_PATH3}${qs}`);
1237
1245
  }
1238
1246
  };
@@ -1277,8 +1285,8 @@ var addMcp = {
1277
1285
  if (category && !isValidMarketCategory(category)) {
1278
1286
  throw new Error(`--category must be one of: ${MARKET_CATEGORIES.join(", ")}`);
1279
1287
  }
1280
- const scope = ctx.str("scope");
1281
- if (scope && !["personal", "company"].includes(scope)) {
1288
+ const scope2 = ctx.str("scope");
1289
+ if (scope2 && !["personal", "company"].includes(scope2)) {
1282
1290
  throw new Error("--scope must be personal or company");
1283
1291
  }
1284
1292
  },
@@ -1306,11 +1314,11 @@ var addMcp = {
1306
1314
  headers: ctx.json("headers") || void 0,
1307
1315
  scope: ctx.str("scope") || "personal"
1308
1316
  });
1309
- const id = created?.item?.id;
1317
+ const id2 = created?.item?.id;
1310
1318
  const meta = buildMetaBody(ctx);
1311
- if (id && meta) {
1319
+ if (id2 && meta) {
1312
1320
  try {
1313
- await patchAgentApi(ctx, `${MARKET_BASE_PATH}/${encodeURIComponent(id)}/meta`, meta);
1321
+ await patchAgentApi(ctx, `${MARKET_BASE_PATH}/${encodeURIComponent(id2)}/meta`, meta);
1314
1322
  } catch (err) {
1315
1323
  process.stderr.write(`Warning: MCP created but meta update failed: ${err?.message ?? err}
1316
1324
  `);
@@ -1370,8 +1378,8 @@ var listMcpMarket = {
1370
1378
  ],
1371
1379
  risk: "read",
1372
1380
  validate: (ctx) => {
1373
- const scope = ctx.str("scope");
1374
- if (scope && !MARKET_SCOPES.includes(scope)) {
1381
+ const scope2 = ctx.str("scope");
1382
+ if (scope2 && !MARKET_SCOPES.includes(scope2)) {
1375
1383
  throw new Error(`--scope must be one of: ${MARKET_SCOPES.join(", ")}`);
1376
1384
  }
1377
1385
  const category = ctx.str("category");
@@ -1558,14 +1566,14 @@ var mcpAuthStart = {
1558
1566
  }
1559
1567
  );
1560
1568
  if (result?.authorizeUrl && (process.stderr.isTTY || process.stdout.isTTY)) {
1561
- const id = ctx.str("id");
1569
+ const id2 = ctx.str("id");
1562
1570
  process.stderr.write(
1563
1571
  `
1564
1572
  \u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00\u4EE5\u4E0B URL \u5B8C\u6210\u6388\u6743\uFF1A
1565
1573
  ${result.authorizeUrl}
1566
1574
 
1567
1575
  \u6388\u6743\u5B8C\u6210\u540E\uFF0C\u8FD0\u884C\u4EE5\u4E0B\u547D\u4EE4\u8F6E\u8BE2\u6388\u6743\u72B6\u6001\uFF1A
1568
- ae-cli agent +mcp-auth-status --id ${id}
1576
+ ae-cli agent +mcp-auth-status --id ${id2}
1569
1577
 
1570
1578
  `
1571
1579
  );
@@ -1752,19 +1760,19 @@ var listSkills = {
1752
1760
  ],
1753
1761
  risk: "read",
1754
1762
  validate: (ctx) => {
1755
- const scope = ctx.str("scope");
1756
- if (scope && !["personal", "company", "system"].includes(scope)) {
1763
+ const scope2 = ctx.str("scope");
1764
+ if (scope2 && !["personal", "company", "system"].includes(scope2)) {
1757
1765
  throw new Error("--scope must be personal, company, or system");
1758
1766
  }
1759
1767
  },
1760
1768
  dryRun: (ctx) => {
1761
- const scope = ctx.str("scope");
1762
- const qs = scope ? `?scope=${encodeURIComponent(scope)}` : "";
1769
+ const scope2 = ctx.str("scope");
1770
+ const qs = scope2 ? `?scope=${encodeURIComponent(scope2)}` : "";
1763
1771
  return { method: "GET", url: `${BASE_PATH4}${qs}` };
1764
1772
  },
1765
1773
  execute: async (ctx) => {
1766
- const scope = ctx.str("scope");
1767
- const qs = scope ? `?scope=${encodeURIComponent(scope)}` : "";
1774
+ const scope2 = ctx.str("scope");
1775
+ const qs = scope2 ? `?scope=${encodeURIComponent(scope2)}` : "";
1768
1776
  return getAgentApi(ctx, `${BASE_PATH4}${qs}`);
1769
1777
  }
1770
1778
  };
@@ -1839,8 +1847,8 @@ var addSkill = {
1839
1847
  if (category && !isValidMarketCategory(category)) {
1840
1848
  throw new Error(`--category must be one of: ${MARKET_CATEGORIES.join(", ")}`);
1841
1849
  }
1842
- const scope = ctx.str("scope");
1843
- if (scope && !["personal", "company"].includes(scope)) {
1850
+ const scope2 = ctx.str("scope");
1851
+ if (scope2 && !["personal", "company"].includes(scope2)) {
1844
1852
  throw new Error("--scope must be personal or company");
1845
1853
  }
1846
1854
  const version = ctx.str("version");
@@ -1869,11 +1877,11 @@ var addSkill = {
1869
1877
  scope: ctx.str("scope") || "personal",
1870
1878
  version: ctx.str("version") || void 0
1871
1879
  });
1872
- const id = created?.item?.id;
1880
+ const id2 = created?.item?.id;
1873
1881
  const meta = buildMetaBody2(ctx);
1874
- if (id && meta) {
1882
+ if (id2 && meta) {
1875
1883
  try {
1876
- await patchAgentApi(ctx, `${MARKET_BASE_PATH2}/${encodeURIComponent(id)}/meta`, meta);
1884
+ await patchAgentApi(ctx, `${MARKET_BASE_PATH2}/${encodeURIComponent(id2)}/meta`, meta);
1877
1885
  } catch (err) {
1878
1886
  process.stderr.write(`Warning: Skill created but meta update failed: ${err?.message ?? err}
1879
1887
  `);
@@ -1982,8 +1990,8 @@ var listSkillMarket = {
1982
1990
  ],
1983
1991
  risk: "read",
1984
1992
  validate: (ctx) => {
1985
- const scope = ctx.str("scope");
1986
- if (scope && !MARKET_SCOPES.includes(scope)) {
1993
+ const scope2 = ctx.str("scope");
1994
+ if (scope2 && !MARKET_SCOPES.includes(scope2)) {
1987
1995
  throw new Error(`--scope must be one of: ${MARKET_SCOPES.join(", ")}`);
1988
1996
  }
1989
1997
  const category = ctx.str("category");
@@ -2594,8 +2602,8 @@ var uploadSkill = {
2594
2602
  if (!existsSync(resolved)) throw new Error(`File not found: ${resolved}`);
2595
2603
  const ext = extname(resolved).toLowerCase();
2596
2604
  if (ext !== ".zip") throw new Error("--file must be a .zip file");
2597
- const scope = ctx.str("scope");
2598
- if (scope && !["personal", "company"].includes(scope)) {
2605
+ const scope2 = ctx.str("scope");
2606
+ if (scope2 && !["personal", "company"].includes(scope2)) {
2599
2607
  throw new Error("--scope must be personal or company");
2600
2608
  }
2601
2609
  const category = ctx.str("category");
@@ -2640,8 +2648,8 @@ var uploadSkill = {
2640
2648
  type: "application/zip"
2641
2649
  });
2642
2650
  fd.append("file", blob, fileName);
2643
- const scope = ctx.str("scope") || "personal";
2644
- fd.append("scope", scope);
2651
+ const scope2 = ctx.str("scope") || "personal";
2652
+ fd.append("scope", scope2);
2645
2653
  if (ctx.bool("autoRename")) fd.append("autoRename", "true");
2646
2654
  if (ctx.str("replaceSkillId")) fd.append("replaceSkillId", ctx.str("replaceSkillId"));
2647
2655
  if (ctx.str("category")) fd.append("category", ctx.str("category"));
@@ -3121,12 +3129,12 @@ function parseShim(filePath) {
3121
3129
  target: ""
3122
3130
  };
3123
3131
  try {
3124
- const stat = lstatSync(filePath);
3125
- if (!stat.isFile() || stat.isSymbolicLink()) return fallback;
3126
- const lines = readShimHeader(filePath, stat.size).split("\n").slice(0, 10);
3132
+ const stat2 = lstatSync(filePath);
3133
+ if (!stat2.isFile() || stat2.isSymbolicLink()) return fallback;
3134
+ const lines = readShimHeader(filePath, stat2.size).split("\n").slice(0, 10);
3127
3135
  const managed = lines.includes(`# ${SHIM_MARKER}`);
3128
3136
  if (!managed) return fallback;
3129
- if (stat.size > MAX_SHIM_BYTES) {
3137
+ if (stat2.size > MAX_SHIM_BYTES) {
3130
3138
  return { ...fallback, managed: true, reason: "shim exceeds size limit" };
3131
3139
  }
3132
3140
  const values = /* @__PURE__ */ new Map();
@@ -3578,17 +3586,17 @@ function validateLimit(ctx) {
3578
3586
  function isRecord(value) {
3579
3587
  return value !== null && typeof value === "object" && !Array.isArray(value);
3580
3588
  }
3581
- function validateSnakeCaseValue(value, path = "payload") {
3589
+ function validateSnakeCaseValue(value, path2 = "payload") {
3582
3590
  if (Array.isArray(value)) {
3583
- value.forEach((item, index) => validateSnakeCaseValue(item, `${path}[${index}]`));
3591
+ value.forEach((item, index) => validateSnakeCaseValue(item, `${path2}[${index}]`));
3584
3592
  return;
3585
3593
  }
3586
3594
  if (!isRecord(value)) return;
3587
3595
  for (const [key, child] of Object.entries(value)) {
3588
3596
  if (!/^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/.test(key)) {
3589
- validation(`--payload keys must use snake_case (invalid key at ${path})`);
3597
+ validation(`--payload keys must use snake_case (invalid key at ${path2})`);
3590
3598
  }
3591
- validateSnakeCaseValue(child, `${path}.${key}`);
3599
+ validateSnakeCaseValue(child, `${path2}.${key}`);
3592
3600
  }
3593
3601
  }
3594
3602
  function approvalPayload(ctx) {
@@ -4013,6 +4021,652 @@ var retryApprovalEffect = {
4013
4021
  )
4014
4022
  };
4015
4023
 
4024
+ // src/commands/te-agent/resource-packages.ts
4025
+ import { randomUUID as randomUUID2 } from "crypto";
4026
+ import { readFileSync as readFileSync3 } from "fs";
4027
+
4028
+ // src/commands/te-agent/resource-package-transfer.ts
4029
+ import { createHash, randomUUID } from "crypto";
4030
+ import { createReadStream, createWriteStream } from "fs";
4031
+ import { chmod, link, lstat, mkdir, open, readFile, rename, stat, unlink, writeFile } from "fs/promises";
4032
+ import path from "path";
4033
+ import { Readable } from "stream";
4034
+ import { pipeline } from "stream/promises";
4035
+ function stateDirectory() {
4036
+ return path.join(getConfigDir(), "transfers", "resource-packages");
4037
+ }
4038
+ async function ensureDirectory(directory) {
4039
+ await mkdir(directory, { recursive: true, mode: 448 });
4040
+ await chmod(directory, 448);
4041
+ }
4042
+ async function saveJson(filePath, data) {
4043
+ const temporary = `${filePath}.${process.pid}.tmp`;
4044
+ await writeFile(temporary, `${JSON.stringify(data)}
4045
+ `, { mode: 384 });
4046
+ await chmod(temporary, 384);
4047
+ await rename(temporary, filePath);
4048
+ }
4049
+ async function loadJson(filePath) {
4050
+ try {
4051
+ const info = await lstat(filePath);
4052
+ if (!info.isFile() || info.isSymbolicLink()) throw new Error(`Unsafe transfer metadata: ${filePath}`);
4053
+ return JSON.parse(await readFile(filePath, "utf8"));
4054
+ } catch (error) {
4055
+ if (error.code === "ENOENT") return void 0;
4056
+ throw new Error(`Invalid transfer metadata: ${filePath}`);
4057
+ }
4058
+ }
4059
+ async function removeFile(filePath) {
4060
+ try {
4061
+ await unlink(filePath);
4062
+ } catch (error) {
4063
+ if (error.code !== "ENOENT") throw error;
4064
+ }
4065
+ }
4066
+ function sameIdentity(left, right) {
4067
+ return left.size === right.size && left.mtimeMs === right.mtimeMs && left.dev === right.dev && left.ino === right.ino;
4068
+ }
4069
+ function statePath(directory, host, filePath, scope2) {
4070
+ const key = createHash("sha256").update(`${host}\0${filePath}\0${scope2}`).digest("hex");
4071
+ return path.join(directory, `upload-${key}.json`);
4072
+ }
4073
+ async function slice(filePath, offset, length) {
4074
+ const file = await open(filePath, "r");
4075
+ try {
4076
+ const bytes = Buffer.allocUnsafe(length);
4077
+ const result = await file.read(bytes, 0, length, offset);
4078
+ if (result.bytesRead !== length) throw new Error("The resource package file changed during upload");
4079
+ return bytes;
4080
+ } finally {
4081
+ await file.close();
4082
+ }
4083
+ }
4084
+ async function transientRetry(operation, maxAttempts) {
4085
+ for (let attempt = 0; ; attempt += 1) {
4086
+ try {
4087
+ return await operation();
4088
+ } catch (error) {
4089
+ const transient = isTransientResourcePackageError(error);
4090
+ if (!transient || attempt + 1 >= maxAttempts) throw error;
4091
+ await new Promise((resolve4) => setTimeout(resolve4, 250 * 2 ** attempt));
4092
+ }
4093
+ }
4094
+ }
4095
+ async function uploadPackage(ctx, input) {
4096
+ const absolute = path.resolve(input.filePath);
4097
+ const before = await lstat(absolute).catch(() => void 0);
4098
+ if (!before?.isFile() || before.isSymbolicLink() || before.size < 1 || path.extname(absolute).toLowerCase() !== ".zip") {
4099
+ throw new Error("--file must point to a non-empty regular .zip file");
4100
+ }
4101
+ const directory = input.stateRoot ?? stateDirectory();
4102
+ await ensureDirectory(directory);
4103
+ const savedPath = statePath(directory, ctx.host(), absolute, input.scope);
4104
+ let saved = await loadJson(savedPath);
4105
+ if (saved && (!sameIdentity(saved, before) || saved.host !== ctx.host() || saved.scope !== input.scope)) {
4106
+ await removeFile(savedPath);
4107
+ saved = void 0;
4108
+ }
4109
+ let upload;
4110
+ const candidate = input.uploadId || saved?.uploadId;
4111
+ if (candidate) {
4112
+ try {
4113
+ upload = await requestResourcePackageApi(
4114
+ ctx,
4115
+ "GET",
4116
+ `/api/resource-packages/uploads/${encodeURIComponent(candidate)}`
4117
+ );
4118
+ } catch (error) {
4119
+ if (input.uploadId || !(error instanceof TeAgentApiError) || error.status !== 404 && error.status !== 410 && error.code !== "UPLOAD_EXPIRED") throw error;
4120
+ await removeFile(savedPath);
4121
+ saved = void 0;
4122
+ }
4123
+ }
4124
+ if (upload && (upload.fileName !== path.basename(absolute) || upload.totalBytes !== before.size || upload.scope !== input.scope || !["uploading", "completed"].includes(upload.status))) {
4125
+ if (input.uploadId) throw new Error("--upload-id does not match the selected ZIP and scope");
4126
+ upload = void 0;
4127
+ await removeFile(savedPath);
4128
+ }
4129
+ if (!upload) {
4130
+ upload = await requestResourcePackageApi(ctx, "POST", "/api/resource-packages/uploads", {
4131
+ fileName: path.basename(absolute),
4132
+ totalBytes: before.size,
4133
+ scope: input.scope
4134
+ });
4135
+ }
4136
+ if (!upload) throw new Error("The service did not create an upload");
4137
+ const active = upload;
4138
+ if (saved?.requestKey && input.requestKey && saved.requestKey !== input.requestKey) {
4139
+ throw new Error("--request-key differs from the existing upload state; reuse its original key");
4140
+ }
4141
+ const requestKey = input.requestKey || saved?.requestKey || randomUUID();
4142
+ const trustedLocalState = Boolean(saved && saved.uploadId === active.id && sameIdentity(saved, before));
4143
+ const state = {
4144
+ version: 1,
4145
+ host: ctx.host(),
4146
+ filePath: absolute,
4147
+ scope: input.scope,
4148
+ uploadId: active.id,
4149
+ size: before.size,
4150
+ mtimeMs: before.mtimeMs,
4151
+ dev: before.dev,
4152
+ ino: before.ino,
4153
+ requestKey
4154
+ };
4155
+ await saveJson(savedPath, state);
4156
+ if (active.status === "uploading") {
4157
+ const limits = await requestResourcePackageApi(
4158
+ ctx,
4159
+ "GET",
4160
+ "/api/resource-packages/limits"
4161
+ );
4162
+ const concurrency = Math.max(1, Math.min(8, limits.desktopUploadConcurrency || 3));
4163
+ const maxAttempts = Math.max(1, Math.min(10, limits.uploadChunkRetries || 3));
4164
+ const done = new Set(active.parts ?? []);
4165
+ const pending = Array.from({ length: active.totalChunks }, (_, index) => index).filter((index) => !trustedLocalState || !done.has(index));
4166
+ let next = 0;
4167
+ await Promise.all(Array.from({ length: Math.min(concurrency, pending.length) }, async () => {
4168
+ while (next < pending.length) {
4169
+ const part = pending[next++];
4170
+ const offset = part * active.chunkBytes;
4171
+ const bytes = await slice(absolute, offset, Math.min(active.chunkBytes, before.size - offset));
4172
+ const digest = createHash("sha256").update(bytes).digest("hex");
4173
+ await transientRetry(async () => {
4174
+ const response = await requestResourcePackageRaw(
4175
+ ctx,
4176
+ "PUT",
4177
+ `/api/resource-packages/uploads/${encodeURIComponent(active.id)}/chunks/${part}`,
4178
+ {
4179
+ body: new Uint8Array(bytes),
4180
+ timeoutMs: 12e4,
4181
+ headers: {
4182
+ "Content-Type": "application/octet-stream",
4183
+ "Content-Length": String(bytes.length),
4184
+ "X-Chunk-Sha256": digest
4185
+ }
4186
+ }
4187
+ );
4188
+ await response.body?.cancel();
4189
+ }, maxAttempts);
4190
+ }
4191
+ }));
4192
+ }
4193
+ const after = await stat(absolute);
4194
+ if (!sameIdentity(before, after)) {
4195
+ throw new Error("The resource package file changed during upload; retry with the unchanged ZIP");
4196
+ }
4197
+ const completed = await requestResourcePackageApi(
4198
+ ctx,
4199
+ "POST",
4200
+ `/api/resource-packages/uploads/${encodeURIComponent(active.id)}/complete`,
4201
+ {}
4202
+ );
4203
+ return { completed, statePath: savedPath, requestKey };
4204
+ }
4205
+ async function clearUploadState(filePath) {
4206
+ await removeFile(filePath);
4207
+ }
4208
+ function artifactFileName(response) {
4209
+ const disposition = response.headers.get("content-disposition") || "";
4210
+ const encoded = disposition.match(/filename\*=UTF-8''([^;]+)/i)?.[1];
4211
+ if (encoded) {
4212
+ try {
4213
+ return path.basename(decodeURIComponent(encoded.trim()));
4214
+ } catch {
4215
+ return path.basename(encoded.trim());
4216
+ }
4217
+ }
4218
+ const ordinary = disposition.match(/filename="([^"]+)"/i)?.[1] ?? disposition.match(/filename=([^;]+)/i)?.[1];
4219
+ return ordinary ? path.basename(ordinary.trim()) : void 0;
4220
+ }
4221
+ async function fileHash(filePath) {
4222
+ const hash = createHash("sha256");
4223
+ for await (const chunk of createReadStream(filePath)) hash.update(chunk);
4224
+ return hash.digest("hex");
4225
+ }
4226
+ async function downloadArtifact(ctx, task, outputPath, timezone) {
4227
+ const query2 = timezone ? `?timezone=${encodeURIComponent(timezone)}` : "";
4228
+ const url2 = `/api/resource-packages/tasks/${encodeURIComponent(task.id)}/artifact${query2}`;
4229
+ const head = await requestResourcePackageRaw(ctx, "HEAD", url2);
4230
+ const totalBytes = Number(head.headers.get("content-length"));
4231
+ if (!Number.isSafeInteger(totalBytes) || totalBytes < 1) throw new Error("Artifact Content-Length is invalid");
4232
+ const etag = head.headers.get("etag") || "";
4233
+ const output = path.resolve(outputPath ?? artifactFileName(head) ?? `resource-package-${task.id}.zip`);
4234
+ try {
4235
+ await lstat(output);
4236
+ throw new Error(`Output file already exists: ${output}`);
4237
+ } catch (error) {
4238
+ if (error.code !== "ENOENT") throw error;
4239
+ }
4240
+ const partial = `${output}.part`;
4241
+ const metadataPath = `${partial}.json`;
4242
+ let offset = 0;
4243
+ try {
4244
+ const info2 = await lstat(partial);
4245
+ if (!info2.isFile() || info2.isSymbolicLink()) throw new Error(`Unsafe partial file: ${partial}`);
4246
+ const metadata = await loadJson(metadataPath);
4247
+ if (!etag || !metadata || metadata.host !== ctx.host() || metadata.taskId !== task.id || metadata.etag !== etag || metadata.totalBytes !== totalBytes || info2.size > totalBytes) {
4248
+ throw new Error(`Partial artifact cannot be resumed safely: ${partial}`);
4249
+ }
4250
+ offset = info2.size;
4251
+ } catch (error) {
4252
+ if (error.code !== "ENOENT") throw error;
4253
+ }
4254
+ if (offset === 0) {
4255
+ await saveJson(metadataPath, { version: 1, host: ctx.host(), taskId: task.id, etag, totalBytes });
4256
+ }
4257
+ if (offset < totalBytes) {
4258
+ const response = await requestResourcePackageRaw(ctx, "GET", url2, {
4259
+ headers: offset ? { Range: `bytes=${offset}-`, "If-Range": etag } : void 0,
4260
+ timeoutMs: 12e4
4261
+ });
4262
+ if (offset && response.status !== 206 || !offset && response.status !== 200) {
4263
+ throw new Error("Artifact server returned an unexpected range status");
4264
+ }
4265
+ if (etag && response.headers.get("etag") !== etag) throw new Error("Artifact changed while downloading");
4266
+ if (offset && response.headers.get("content-range") !== `bytes ${offset}-${totalBytes - 1}/${totalBytes}`) {
4267
+ throw new Error("Artifact server returned a mismatched Content-Range");
4268
+ }
4269
+ if (!response.body) throw new Error("Artifact response body is empty");
4270
+ await pipeline(
4271
+ Readable.fromWeb(response.body),
4272
+ createWriteStream(partial, { flags: offset ? "a" : "wx", mode: 384 })
4273
+ );
4274
+ }
4275
+ const info = await stat(partial);
4276
+ if (info.size !== totalBytes) throw new Error(`Artifact size mismatch: expected ${totalBytes}, got ${info.size}`);
4277
+ const sha256 = await fileHash(partial);
4278
+ if (!task.packageSha256 || !/^[a-f0-9]{64}$/.test(task.packageSha256)) {
4279
+ throw new Error("Export task does not provide a valid package SHA-256 for verification");
4280
+ }
4281
+ if (sha256 !== task.packageSha256) {
4282
+ throw new Error(`Artifact SHA-256 mismatch: expected ${task.packageSha256}, got ${sha256}`);
4283
+ }
4284
+ await link(partial, output);
4285
+ await removeFile(partial);
4286
+ await removeFile(metadataPath);
4287
+ return { path: output, bytes: totalBytes, sha256 };
4288
+ }
4289
+
4290
+ // src/commands/te-agent/resource-packages.ts
4291
+ var statuses = /* @__PURE__ */ new Set([
4292
+ "uploading",
4293
+ "preflighting",
4294
+ "ready",
4295
+ "queued",
4296
+ "running",
4297
+ "cancelling",
4298
+ "succeeded",
4299
+ "partially_succeeded",
4300
+ "failed",
4301
+ "cancelled",
4302
+ "cancel_failed"
4303
+ ]);
4304
+ var terminal = /* @__PURE__ */ new Set(["succeeded", "partially_succeeded", "failed", "cancelled", "cancel_failed"]);
4305
+ var resourceTypes = /* @__PURE__ */ new Set(["knowledge_base", "mcp", "skill", "agent", "team"]);
4306
+ var previewNote = "Dry-run previews the local request only; it does not check permissions or current resources.";
4307
+ function id(ctx, key, flag2) {
4308
+ const value = ctx.str(key);
4309
+ if (!value || value.trim() !== value || value.length > 191) {
4310
+ throw new CliValidationError(`--${flag2} must be a non-empty identifier of at most 191 characters`);
4311
+ }
4312
+ return value;
4313
+ }
4314
+ function scope(ctx) {
4315
+ const value = ctx.str("scope");
4316
+ if (value !== "personal" && value !== "company") {
4317
+ throw new CliValidationError("--scope must be personal or company");
4318
+ }
4319
+ return value;
4320
+ }
4321
+ function jsonSource(raw, flag2) {
4322
+ if (!raw) throw new CliValidationError(`--${flag2} is required`);
4323
+ try {
4324
+ const text = raw === "-" ? readFileSync3(0, "utf8") : raw.startsWith("@") ? readFileSync3(raw.slice(1), "utf8") : raw;
4325
+ return JSON.parse(text);
4326
+ } catch (error) {
4327
+ throw new CliValidationError(`--${flag2} must contain valid JSON, @file JSON, or - for stdin: ${error.message}`);
4328
+ }
4329
+ }
4330
+ function references(ctx, key) {
4331
+ const raw = ctx.str(key);
4332
+ if (!raw && key === "excluded") return [];
4333
+ const value = jsonSource(raw, key);
4334
+ const maximum = key === "roots" ? 500 : 2e3;
4335
+ if (!Array.isArray(value) || key === "roots" && !value.length || value.length > maximum || value.some((entry) => !entry || typeof entry !== "object" || Array.isArray(entry) || Object.keys(entry).sort().join(",") !== "sourceId,type" || !resourceTypes.has(entry.type) || typeof entry.sourceId !== "string" || !entry.sourceId || entry.sourceId.length > 191)) {
4336
+ throw new CliValidationError(`--${key} must be a JSON array of valid resource references (max ${maximum})`);
4337
+ }
4338
+ return value;
4339
+ }
4340
+ function stringArray(ctx, key, flag2) {
4341
+ const raw = ctx.str(key);
4342
+ if (!raw) return [];
4343
+ const value = jsonSource(raw, flag2);
4344
+ if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
4345
+ throw new CliValidationError(`--${flag2} must be a JSON string array`);
4346
+ }
4347
+ return value;
4348
+ }
4349
+ function replacementMap(ctx) {
4350
+ const raw = ctx.str("systemReplacements");
4351
+ if (!raw) return {};
4352
+ const value = jsonSource(raw, "system-replacements");
4353
+ if (!value || typeof value !== "object" || Array.isArray(value) || Object.entries(value).length > 500 || Object.entries(value).some(([key, target]) => !key || key.length > 64 || typeof target !== "string" || !target || target.length > 191)) {
4354
+ throw new CliValidationError("--system-replacements must be a JSON object of reference keys to target IDs");
4355
+ }
4356
+ return value;
4357
+ }
4358
+ function taskPath(ctx) {
4359
+ return `/api/resource-packages/tasks/${encodeURIComponent(id(ctx, "taskId", "task-id"))}`;
4360
+ }
4361
+ function waitSettings(ctx) {
4362
+ const seconds = ctx.optionalNum("waitTimeoutSeconds") ?? 1800;
4363
+ const pollMs = ctx.optionalNum("pollIntervalMs") ?? 1500;
4364
+ if (!Number.isInteger(seconds) || seconds < 1 || seconds > 86400) {
4365
+ throw new CliValidationError("--wait-timeout-seconds must be an integer from 1 to 86400");
4366
+ }
4367
+ if (!Number.isInteger(pollMs) || pollMs < 250 || pollMs > 6e4) {
4368
+ throw new CliValidationError("--poll-interval-ms must be an integer from 250 to 60000");
4369
+ }
4370
+ return { timeoutMs: seconds * 1e3, pollMs };
4371
+ }
4372
+ async function waitForTask(ctx, task) {
4373
+ const { timeoutMs, pollMs } = waitSettings(ctx);
4374
+ const deadline = Date.now() + timeoutMs;
4375
+ let current = task;
4376
+ while (!terminal.has(current.status)) {
4377
+ if (Date.now() >= deadline) return { task: current, timedOut: true };
4378
+ await new Promise((resolve4) => setTimeout(resolve4, pollMs));
4379
+ current = await requestResourcePackageApi(ctx, "GET", `/api/resource-packages/tasks/${encodeURIComponent(task.id)}`);
4380
+ }
4381
+ return { task: current, timedOut: false };
4382
+ }
4383
+ var taskIdFlag2 = { name: "task-id", type: "string", required: true, desc: "Resource package task ID" };
4384
+ var waitFlags = [
4385
+ { name: "no-wait", type: "boolean", desc: "Return after submission without polling" },
4386
+ { name: "wait-timeout-seconds", type: "number", desc: "Maximum poll duration in seconds (default: 1800)" },
4387
+ { name: "poll-interval-ms", type: "number", desc: "Poll interval from 250 to 60000 milliseconds (default: 1500)" }
4388
+ ];
4389
+ function listPath2(ctx) {
4390
+ const kind = ctx.str("kind");
4391
+ const selectedScope = ctx.str("scope");
4392
+ const status = ctx.str("status");
4393
+ if (kind && !["export", "import"].includes(kind)) throw new CliValidationError("--kind must be export or import");
4394
+ if (selectedScope && !["personal", "company"].includes(selectedScope)) throw new CliValidationError("--scope must be personal or company");
4395
+ if (status && !statuses.has(status)) throw new CliValidationError("--status is invalid");
4396
+ const page = ctx.optionalNum("page") ?? 1;
4397
+ const pageSize = ctx.optionalNum("pageSize") ?? 20;
4398
+ if (!Number.isSafeInteger(page) || page < 1) throw new CliValidationError("--page must be a positive integer");
4399
+ if (![20, 50, 100].includes(pageSize)) throw new CliValidationError("--page-size must be 20, 50, or 100");
4400
+ const query2 = new URLSearchParams();
4401
+ if (kind) query2.set("kind", kind);
4402
+ if (selectedScope) query2.set("scope", selectedScope);
4403
+ if (status) query2.set("status", status);
4404
+ query2.set("page", String(page));
4405
+ query2.set("pageSize", String(pageSize));
4406
+ return `/api/resource-packages/tasks?${query2}`;
4407
+ }
4408
+ var listResourcePackages = {
4409
+ service: "agent",
4410
+ resource: "resource-package",
4411
+ command: "list",
4412
+ description: "List personal and company resource package tasks",
4413
+ helpText: previewNote,
4414
+ flags: [
4415
+ { name: "kind", type: "string", desc: "Filter by export or import" },
4416
+ { name: "scope", type: "string", desc: "Filter by personal or company" },
4417
+ { name: "status", type: "string", desc: "Filter by task status" },
4418
+ { name: "page", type: "number", desc: "Page number (default: 1)" },
4419
+ { name: "page-size", type: "number", desc: "Page size: 20, 50, or 100 (default: 20)" }
4420
+ ],
4421
+ risk: "read",
4422
+ validate: (ctx) => {
4423
+ listPath2(ctx);
4424
+ },
4425
+ dryRun: (ctx) => ({ method: "GET", url: listPath2(ctx) }),
4426
+ execute: (ctx) => requestResourcePackageApi(ctx, "GET", listPath2(ctx))
4427
+ };
4428
+ var showResourcePackage = {
4429
+ service: "agent",
4430
+ resource: "resource-package",
4431
+ command: "show",
4432
+ description: "Show a resource package task and its item results",
4433
+ flags: [taskIdFlag2],
4434
+ risk: "read",
4435
+ validate: (ctx) => {
4436
+ taskPath(ctx);
4437
+ },
4438
+ dryRun: (ctx) => ({ method: "GET", url: taskPath(ctx) }),
4439
+ execute: (ctx) => requestResourcePackageApi(ctx, "GET", taskPath(ctx))
4440
+ };
4441
+ var previewResourcePackageExport = {
4442
+ service: "agent",
4443
+ resource: "resource-package",
4444
+ command: "export-preview",
4445
+ description: "Preview export resources and dependencies",
4446
+ helpText: previewNote,
4447
+ flags: [{ name: "roots", type: "string", required: true, desc: "JSON, @file, or stdin (-) array of resource references" }],
4448
+ risk: "read",
4449
+ validate: (ctx) => {
4450
+ references(ctx, "roots");
4451
+ },
4452
+ dryRun: (ctx) => ({ method: "POST", url: "/api/resource-packages/exports/preview", body: { roots: references(ctx, "roots") } }),
4453
+ execute: (ctx) => requestResourcePackageApi(ctx, "POST", "/api/resource-packages/exports/preview", { roots: references(ctx, "roots") })
4454
+ };
4455
+ function exportBody(ctx) {
4456
+ return {
4457
+ requestKey: ctx.str("requestKey") || randomUUID2(),
4458
+ kind: "export",
4459
+ scope: scope(ctx),
4460
+ payload: {
4461
+ roots: references(ctx, "roots"),
4462
+ excluded: references(ctx, "excluded"),
4463
+ ...ctx.str("view") ? { view: ctx.str("view") } : {},
4464
+ ...ctx.str("fileNameBase") ? { fileNameBase: ctx.str("fileNameBase") } : {}
4465
+ }
4466
+ };
4467
+ }
4468
+ function validateExport(ctx) {
4469
+ if (ctx.str("view") && !["working", "published"].includes(ctx.str("view"))) throw new CliValidationError("--view must be working or published");
4470
+ exportBody(ctx);
4471
+ if (ctx.str("requestKey")) id(ctx, "requestKey", "request-key");
4472
+ const base = ctx.str("fileNameBase");
4473
+ if (base && (base.length > 160 || !/^[^\\/\x00-\x1f]+$/.test(base))) {
4474
+ throw new CliValidationError("--file-name-base must be a safe filename base of at most 160 characters");
4475
+ }
4476
+ if (ctx.bool("noWait") && ctx.str("output")) throw new CliValidationError("--no-wait cannot be combined with --output");
4477
+ if (!ctx.bool("noWait")) waitSettings(ctx);
4478
+ }
4479
+ var exportResourcePackage = {
4480
+ service: "agent",
4481
+ resource: "resource-package",
4482
+ command: "export",
4483
+ description: "Export a personal or company resource package and download the artifact",
4484
+ helpText: previewNote,
4485
+ flags: [
4486
+ { name: "scope", type: "string", required: true, desc: "Export scope: personal or company" },
4487
+ { name: "roots", type: "string", required: true, desc: "JSON, @file, or stdin (-) array of root resources" },
4488
+ { name: "excluded", type: "string", desc: "JSON or @file array of dependencies to exclude" },
4489
+ { name: "view", type: "string", desc: "Knowledge base content: working (default) or published" },
4490
+ { name: "file-name-base", type: "string", desc: "Optional output ZIP base name" },
4491
+ { name: "request-key", type: "string", desc: "Optional idempotency key; reuse only for the same export" },
4492
+ { name: "output", type: "string", desc: "Local ZIP path; defaults to the artifact filename" },
4493
+ { name: "timezone", type: "string", desc: "IANA timezone for generated artifact filename (default: UTC)" },
4494
+ ...waitFlags
4495
+ ],
4496
+ risk: "write",
4497
+ validate: validateExport,
4498
+ preflight: validateExport,
4499
+ dryRun: (ctx) => ({ method: "POST", url: "/api/resource-packages/tasks", body: exportBody(ctx) }),
4500
+ execute: async (ctx) => {
4501
+ let task = await requestResourcePackageApi(ctx, "POST", "/api/resource-packages/tasks", exportBody(ctx));
4502
+ if (ctx.bool("noWait")) return { status: "submitted", task };
4503
+ const waited = await waitForTask(ctx, task);
4504
+ task = waited.task;
4505
+ if (waited.timedOut) return { status: "still_running", task };
4506
+ if (task.status !== "succeeded" || !task.artifactAvailable) return { status: "completed", task };
4507
+ const artifact = await downloadArtifact(ctx, task, ctx.str("output") || void 0, ctx.str("timezone") || void 0);
4508
+ return { status: "downloaded", task, artifact };
4509
+ }
4510
+ };
4511
+ function validateImport(ctx) {
4512
+ if (!ctx.str("file")) throw new CliValidationError("--file is required");
4513
+ scope(ctx);
4514
+ stringArray(ctx, "confirmations", "confirmations");
4515
+ replacementMap(ctx);
4516
+ if (ctx.str("uploadId")) id(ctx, "uploadId", "upload-id");
4517
+ if (ctx.str("requestKey")) id(ctx, "requestKey", "request-key");
4518
+ if (!ctx.bool("noWait")) waitSettings(ctx);
4519
+ }
4520
+ function reviewPreflight(preflight, replacements, confirmations) {
4521
+ const unresolvedBlockers = preflight.blockers.filter((item) => {
4522
+ if (item.code !== "CORE_SYSTEM_AGENT_UNRESOLVED" || !item.referenceKey) return true;
4523
+ const replacement = replacements[item.referenceKey];
4524
+ return !replacement || replacement !== "__skip_resource__" && !item.replacementCandidates?.some((candidate) => candidate.id === replacement);
4525
+ });
4526
+ const missingConfirmations = preflight.confirmations.filter((item) => !confirmations.includes(item.code));
4527
+ return { unresolvedBlockers, missingConfirmations };
4528
+ }
4529
+ var importResourcePackage = {
4530
+ service: "agent",
4531
+ resource: "resource-package",
4532
+ command: "import",
4533
+ description: "Upload, preflight, confirm, and import a resource package with resume support",
4534
+ flags: [
4535
+ { name: "file", type: "string", required: true, desc: "Path to a non-empty resource package ZIP" },
4536
+ { name: "scope", type: "string", required: true, desc: "Import scope: personal or company" },
4537
+ { name: "upload-id", type: "string", desc: "Explicit upload ID to resume" },
4538
+ { name: "request-key", type: "string", desc: "Optional idempotency key; reuse only for the same import" },
4539
+ { name: "confirmations", type: "string", desc: "JSON or @file array of required confirmation codes" },
4540
+ { name: "system-replacements", type: "string", desc: "JSON or @file mapping of reference keys to target IDs or __skip_resource__" },
4541
+ { name: "accept-warnings", type: "boolean", desc: "Accept all warnings from the current preflight snapshot" },
4542
+ { name: "allow-duplicate", type: "boolean", desc: "Allow a package previously imported successfully" },
4543
+ ...waitFlags
4544
+ ],
4545
+ risk: "write",
4546
+ validate: validateImport,
4547
+ preflight: validateImport,
4548
+ dryRun: (ctx) => ({ method: "WORKFLOW", url: "/api/resource-packages/uploads", body: {
4549
+ file: ctx.str("file"),
4550
+ scope: scope(ctx),
4551
+ resume: true,
4552
+ wait: !ctx.bool("noWait")
4553
+ } }),
4554
+ execute: async (ctx) => {
4555
+ const { completed, statePath: statePath2, requestKey } = await uploadPackage(ctx, {
4556
+ filePath: ctx.str("file"),
4557
+ scope: scope(ctx),
4558
+ uploadId: ctx.str("uploadId") || void 0,
4559
+ requestKey: ctx.str("requestKey") || void 0
4560
+ });
4561
+ const confirmations = stringArray(ctx, "confirmations", "confirmations");
4562
+ const replacements = replacementMap(ctx);
4563
+ const review = reviewPreflight(completed.preflight, replacements, confirmations);
4564
+ if (completed.duplicateImport && !ctx.bool("allowDuplicate") || completed.preflight.warnings.length && !ctx.bool("acceptWarnings") || review.unresolvedBlockers.length || review.missingConfirmations.length) {
4565
+ return {
4566
+ status: "review_required",
4567
+ uploadId: completed.uploadId,
4568
+ requestKey,
4569
+ duplicateImport: completed.duplicateImport,
4570
+ preflight: completed.preflight,
4571
+ ...review
4572
+ };
4573
+ }
4574
+ let task;
4575
+ try {
4576
+ task = await requestResourcePackageApi(
4577
+ ctx,
4578
+ "POST",
4579
+ `/api/resource-packages/uploads/${encodeURIComponent(completed.uploadId)}/confirm`,
4580
+ {
4581
+ requestKey,
4582
+ preflightSnapshotId: completed.preflight.snapshotId,
4583
+ confirmations,
4584
+ systemReplacements: replacements
4585
+ }
4586
+ );
4587
+ } catch (error) {
4588
+ const changed = resourcePackagePreflightChange(error);
4589
+ if (changed) return {
4590
+ status: "review_required",
4591
+ reason: "preflight_changed",
4592
+ uploadId: completed.uploadId,
4593
+ requestKey,
4594
+ preflight: changed
4595
+ };
4596
+ throw error;
4597
+ }
4598
+ await clearUploadState(statePath2);
4599
+ if (ctx.bool("noWait")) return { status: "submitted", task };
4600
+ const waited = await waitForTask(ctx, task);
4601
+ return { status: waited.timedOut ? "still_running" : "completed", task: waited.task };
4602
+ }
4603
+ };
4604
+ var downloadResourcePackageCommand = {
4605
+ service: "agent",
4606
+ resource: "resource-package",
4607
+ command: "download",
4608
+ description: "Download or resume a completed export artifact and verify its SHA-256",
4609
+ flags: [
4610
+ taskIdFlag2,
4611
+ { name: "output", type: "string", desc: "Local ZIP path; defaults to the artifact filename" },
4612
+ { name: "timezone", type: "string", desc: "IANA timezone for generated artifact filename (default: UTC)" }
4613
+ ],
4614
+ risk: "read",
4615
+ validate: (ctx) => {
4616
+ taskPath(ctx);
4617
+ },
4618
+ dryRun: (ctx) => ({ method: "GET", url: `${taskPath(ctx)}/artifact` }),
4619
+ execute: async (ctx) => {
4620
+ const task = await requestResourcePackageApi(ctx, "GET", taskPath(ctx));
4621
+ if (task.kind !== "export" || task.status !== "succeeded" || !task.artifactAvailable) {
4622
+ throw new Error("This task does not have an available export artifact");
4623
+ }
4624
+ return downloadArtifact(ctx, task, ctx.str("output") || void 0, ctx.str("timezone") || void 0);
4625
+ }
4626
+ };
4627
+ var cancelResourcePackage = {
4628
+ service: "agent",
4629
+ resource: "resource-package",
4630
+ command: "cancel",
4631
+ description: "Request cancellation of a running resource package task",
4632
+ flags: [taskIdFlag2],
4633
+ risk: "high-risk-write",
4634
+ validate: (ctx) => {
4635
+ taskPath(ctx);
4636
+ },
4637
+ dryRun: (ctx) => ({ method: "POST", url: `${taskPath(ctx)}/cancel` }),
4638
+ execute: (ctx) => requestResourcePackageApi(ctx, "POST", `${taskPath(ctx)}/cancel`, {})
4639
+ };
4640
+ var retryResourcePackage = {
4641
+ service: "agent",
4642
+ resource: "resource-package",
4643
+ command: "retry",
4644
+ description: "Retry a retryable failed resource package task",
4645
+ flags: [taskIdFlag2, ...waitFlags],
4646
+ risk: "write",
4647
+ validate: (ctx) => {
4648
+ taskPath(ctx);
4649
+ if (!ctx.bool("noWait")) waitSettings(ctx);
4650
+ },
4651
+ dryRun: (ctx) => ({ method: "POST", url: `${taskPath(ctx)}/retry` }),
4652
+ execute: async (ctx) => {
4653
+ const task = await requestResourcePackageApi(ctx, "POST", `${taskPath(ctx)}/retry`, {});
4654
+ if (ctx.bool("noWait")) return { status: "submitted", task };
4655
+ const waited = await waitForTask(ctx, task);
4656
+ return { status: waited.timedOut ? "still_running" : "completed", task: waited.task };
4657
+ }
4658
+ };
4659
+ var resourcePackageCommands = [
4660
+ listResourcePackages,
4661
+ showResourcePackage,
4662
+ previewResourcePackageExport,
4663
+ exportResourcePackage,
4664
+ importResourcePackage,
4665
+ downloadResourcePackageCommand,
4666
+ cancelResourcePackage,
4667
+ retryResourcePackage
4668
+ ];
4669
+
4016
4670
  // src/commands/te-agent/index.ts
4017
4671
  var commands = [
4018
4672
  ...notificationCommands,
@@ -4113,15 +4767,24 @@ var commands = [
4113
4767
  findArchivedConversations,
4114
4768
  restoreConversation,
4115
4769
  // Sandbox tools (local scan of /home/ta/.local/bin managed shims)
4116
- listSandboxTools
4770
+ listSandboxTools,
4771
+ ...resourcePackageCommands
4117
4772
  ];
4118
4773
  var te_agent_default = commands;
4119
4774
  export {
4775
+ cancelResourcePackage,
4120
4776
  te_agent_default as default,
4777
+ downloadResourcePackageCommand,
4778
+ exportResourcePackage,
4779
+ importResourcePackage,
4780
+ listResourcePackages,
4121
4781
  notificationGet,
4122
4782
  notificationList,
4123
4783
  notificationMarkRead,
4124
4784
  notificationRecipients,
4125
4785
  notificationSend,
4126
- notificationUnreadCount
4786
+ notificationUnreadCount,
4787
+ previewResourcePackageExport,
4788
+ retryResourcePackage,
4789
+ showResourcePackage
4127
4790
  };