@thinkingai/ae-cli 6.0.42 → 6.0.44

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 (87) hide show
  1. package/dist/{auth-GBMV6TEJ.js → auth-2WTQOP77.js} +3 -3
  2. package/dist/{auth-NDSXE54J.js → auth-77BUFLGC.js} +57 -13
  3. package/dist/{capability-CETVHGXF.js → capability-ENHWPMTG.js} +12 -12
  4. package/dist/{capability-ZSQBMNOE.js → capability-WA37LSIR.js} +12 -12
  5. package/dist/{chunk-AFXA7BRK.js → chunk-4KVPKXFX.js} +5 -5
  6. package/dist/chunk-4SGZG4XY.js +311 -0
  7. package/dist/chunk-6EIJSNBD.js +8 -0
  8. package/dist/chunk-C4MGVGJW.js +13 -0
  9. package/dist/{chunk-4E3DB4MM.js → chunk-EE45RGOO.js} +7 -7
  10. package/dist/{chunk-WZRX4KOH.js → chunk-GT46FPXN.js} +4 -6
  11. package/dist/{chunk-5XUSIK27.js → chunk-ILIU36SU.js} +10 -7
  12. package/dist/{chunk-JHENBQ5B.js → chunk-LYVNONC4.js} +0 -35
  13. package/dist/{chunk-WANVG6SY.js → chunk-MGU2N3HW.js} +7 -7
  14. package/dist/{chunk-JUW4AJXN.js → chunk-P3FGXJTU.js} +12 -7
  15. package/dist/{chunk-FNZA5RZA.js → chunk-QEFCIRNJ.js} +4 -4
  16. package/dist/chunk-QGM4M3NI.js +37 -0
  17. package/dist/{chunk-J2N4PB56.js → chunk-QI524WPY.js} +4 -4
  18. package/dist/{chunk-VLWOLBGZ.js → chunk-UOUS37JQ.js} +149 -161
  19. package/dist/{chunk-AXDXJTPC.js → chunk-UW5UN47B.js} +19 -2
  20. package/dist/chunk-VPKZ7I72.js +509 -0
  21. package/dist/chunk-ZZUOD757.js +598 -0
  22. package/dist/{client-L2YDMHQ6.js → client-TKG4WBHN.js} +4 -5
  23. package/dist/{community-report-client-M2RW4MXD.js → community-report-client-FI4LNVYS.js} +3 -2
  24. package/dist/{config-OL2LWGBV.js → config-RE6CMGPK.js} +7 -7
  25. package/dist/data-integration-2MYMANJI.js +3383 -0
  26. package/dist/index.js +74 -40
  27. package/dist/local-data-upload-client-BWHSUQQK.js +167 -0
  28. package/dist/{memory-MUP7PPL7.js → memory-CHRU2F7W.js} +7 -6
  29. package/dist/{memory-U4O5PMXH.js → memory-YK33G4T7.js} +7 -6
  30. package/dist/{metadata-BD6BXAYE.js → metadata-AXVHAAZG.js} +10 -9
  31. package/dist/{metadata-HXOFACDE.js → metadata-GGEHHPBE.js} +10 -9
  32. package/dist/{model-JTUEO5M4.js → model-K3KLWIW6.js} +7 -3
  33. package/dist/model-NR3JHFSJ.js +139 -0
  34. package/dist/{sync-MOSFNBVR.js → sync-DAVKYVMW.js} +8 -6
  35. package/dist/sync-FCKOVWWS.js +10261 -0
  36. package/dist/{te-agent-IFKZDHZI.js → te-agent-4BKBODMF.js} +686 -71
  37. package/dist/te-agent-HLW4VTQK.js +3893 -0
  38. package/dist/{te-analysis-PXNF7ZJT.js → te-analysis-WX7LRVAV.js} +38 -15
  39. package/dist/{te-analysis-T7C7WSAH.js → te-analysis-YKFDBMA6.js} +38 -15
  40. package/dist/{te-community-HNKVTERD.js → te-community-6HPBWJUZ.js} +24 -19
  41. package/dist/{te-community-IWE5B7W6.js → te-community-HLC43QKH.js} +24 -20
  42. package/dist/{te-dataops-KXCEB4CS.js → te-dataops-EJP56W3K.js} +57 -34
  43. package/dist/{te-dataops-KQPYNAE3.js → te-dataops-HDRUXY4K.js} +59 -34
  44. package/dist/{te-engage-BVB7RGEO.js → te-engage-UBHPAJCO.js} +12 -11
  45. package/dist/{te-engage-LCEGC7G4.js → te-engage-WLDTS5J5.js} +12 -11
  46. package/dist/{te-kb-OIH3T6CS.js → te-kb-APXBWBDY.js} +6 -6
  47. package/dist/{te-system-AZ3URMUO.js → te-system-YARIK4S5.js} +7 -4
  48. package/dist/te-system-Z77IKZFN.js +2213 -0
  49. package/dist/{te-team-GZPU6UWA.js → te-team-EFKWYKMK.js} +7 -7
  50. package/dist/{update-TOBFXF2V.js → update-OGPSZM5A.js} +7 -7
  51. package/package.json +13 -3
  52. package/skills/ae-agent/SKILL.md +21 -11
  53. package/skills/ae-agent/references/approval-effect.md +44 -0
  54. package/skills/ae-agent/references/approval-request.md +46 -0
  55. package/skills/ae-agent/references/approval-task.md +45 -0
  56. package/skills/ae-agent/references/approval-type.md +32 -0
  57. package/skills/ae-agent/references/command_index.md +19 -0
  58. package/skills/ae-analysis/SKILL.md +11 -7
  59. package/skills/ae-analysis/references/adhoc_run.md +2 -0
  60. package/skills/ae-analysis/references/ai_models.md +27 -0
  61. package/skills/ae-analysis/references/analysis_gateway_assets.md +3 -2
  62. package/skills/ae-analysis/references/command_index.md +4 -1
  63. package/skills/ae-analysis/references/dashboard_get.md +8 -2
  64. package/skills/ae-analysis/references/dashboard_report_data_run.md +3 -1
  65. package/skills/ae-analysis/references/dashboard_update.md +4 -1
  66. package/skills/ae-analysis/references/project_space_business_filter_upsert.md +17 -0
  67. package/skills/ae-analysis/references/user_tag_models.md +4 -4
  68. package/skills/ae-data-integration/SKILL.md +54 -0
  69. package/skills/ae-data-integration/references/handoff.md +43 -0
  70. package/skills/ae-data-integration/references/local-analysis.md +27 -0
  71. package/skills/ae-data-integration/references/reuse.md +41 -0
  72. package/skills/ae-data-integration/references/sink-upload.md +58 -0
  73. package/skills/ae-data-integration/references/source-inspect.md +55 -0
  74. package/skills/ae-data-integration/references/sync-json-upload.md +60 -0
  75. package/skills/ae-data-integration/references/tracking-plan.md +35 -0
  76. package/skills/ae-data-integration/references/transform.md +65 -0
  77. package/skills/ae-data-integration/references/ue-mapping.md +142 -0
  78. package/skills/ae-data-integration/references/ue-routing.md +35 -0
  79. package/skills/ae-data-integration-helper/SKILL.md +1 -1
  80. package/skills/ae-dataops/SKILL.md +1 -1
  81. package/skills/ae-dataops/references/dataops-query.md +4 -4
  82. package/skills/ae-generate-tracking-plan/SKILL.md +54 -3
  83. package/skills/ae-metadata/SKILL.md +0 -1
  84. package/dist/chunk-3FY3RJ26.js +0 -293
  85. package/dist/chunk-S5NTSDBS.js +0 -198
  86. package/dist/chunk-ZQKDZXDO.js +0 -317
  87. package/dist/cli-token-4UPER74P.js +0 -21
package/dist/index.js CHANGED
@@ -1,45 +1,46 @@
1
+ import {
2
+ getLocalCliPackageInfo
3
+ } from "./chunk-VTWMIC5L.js";
1
4
  import {
2
5
  requiresConfirmation
3
6
  } from "./chunk-OO6XR6LK.js";
4
7
  import {
5
8
  TeAgentApiError,
6
9
  TeAgentCredentialsError
7
- } from "./chunk-VLWOLBGZ.js";
8
- import {
9
- getLocalCliPackageInfo
10
- } from "./chunk-VTWMIC5L.js";
11
- import {
12
- CapabilityGatewayError,
13
- executeCapability,
14
- uploadInputFileBytes
15
- } from "./chunk-JUW4AJXN.js";
10
+ } from "./chunk-VPKZ7I72.js";
16
11
  import {
17
12
  formatCapabilityMissCompatHint,
18
13
  printError,
19
14
  printOutput,
20
15
  runHostCompatCheck
21
- } from "./chunk-WZRX4KOH.js";
16
+ } from "./chunk-GT46FPXN.js";
17
+ import {
18
+ CapabilityGatewayError,
19
+ executeCapability,
20
+ uploadInputFileBytes
21
+ } from "./chunk-ILIU36SU.js";
22
+ import "./chunk-6EIJSNBD.js";
22
23
  import {
23
24
  clearCliToken,
24
25
  getCliToken
25
- } from "./chunk-S5NTSDBS.js";
26
+ } from "./chunk-4SGZG4XY.js";
26
27
  import {
27
28
  SecureStoreAuthError,
28
- resolveHost
29
- } from "./chunk-ZQKDZXDO.js";
30
- import {
31
29
  getActiveHost,
32
30
  getConfigDir,
31
+ resolveHost,
33
32
  safeJsonParse
34
- } from "./chunk-3FY3RJ26.js";
33
+ } from "./chunk-ZZUOD757.js";
35
34
  import {
36
35
  CliValidationError,
37
36
  CommunityReportError,
37
+ LocalDataUploadError,
38
38
  PermissionError
39
- } from "./chunk-AXDXJTPC.js";
39
+ } from "./chunk-UW5UN47B.js";
40
40
  import {
41
41
  logger
42
- } from "./chunk-JHENBQ5B.js";
42
+ } from "./chunk-LYVNONC4.js";
43
+ import "./chunk-QGM4M3NI.js";
43
44
 
44
45
  // src/index.ts
45
46
  import { Command as CommanderCommand } from "commander";
@@ -66,6 +67,7 @@ async function runCommand(cmd, opts, globalOpts) {
66
67
  const missingRequired = cmd.flags.filter((flag) => {
67
68
  if (!flag.required) return false;
68
69
  const val = opts[camelCase(flag.name)];
70
+ if (flag.variadic) return !Array.isArray(val) || val.length === 0;
69
71
  return val === void 0 || val === null || val === "";
70
72
  });
71
73
  if (missingRequired.length > 0) {
@@ -79,6 +81,7 @@ async function runCommand(cmd, opts, globalOpts) {
79
81
  const LIMIT_FLAG_PATTERNS = [/limit/i, /page_size/i, /pagesize/i, /row_limit/i, /block_limit/i, /top[-_]?k/i];
80
82
  for (const flag of cmd.flags) {
81
83
  const val = opts[camelCase(flag.name)];
84
+ if (flag.variadic) continue;
82
85
  if (flag.type === "boolean") {
83
86
  if (val !== void 0 && typeof val !== "boolean") {
84
87
  printError("validation", `Invalid boolean for --${flag.name}: ${val}. Use true/false.`);
@@ -87,6 +90,7 @@ async function runCommand(cmd, opts, globalOpts) {
87
90
  continue;
88
91
  }
89
92
  if (flag.type !== "number") continue;
93
+ if (flag.variadic) continue;
90
94
  if (val === void 0 || val === null || val === "") continue;
91
95
  const num = Number(val);
92
96
  if (!Number.isFinite(num)) {
@@ -114,6 +118,7 @@ async function runCommand(cmd, opts, globalOpts) {
114
118
  }
115
119
  for (const flag of cmd.flags) {
116
120
  if (flag.type !== "string") continue;
121
+ if (flag.variadic) continue;
117
122
  const val = opts[camelCase(flag.name)];
118
123
  if (val === void 0 || val === null || val === "") continue;
119
124
  const error = stringFlagValidationError(flag, String(val));
@@ -170,7 +175,7 @@ async function runCommand(cmd, opts, globalOpts) {
170
175
  }
171
176
  const message = err.message || String(err);
172
177
  if (!(err instanceof CommunityReportError)) {
173
- logger.error(`Command failed: ${message}`);
178
+ if (!(err instanceof LocalDataUploadError)) logger.error(`Command failed: ${message}`);
174
179
  }
175
180
  if (err instanceof CliValidationError) {
176
181
  printError(
@@ -183,11 +188,13 @@ async function runCommand(cmd, opts, globalOpts) {
183
188
  } else if (err instanceof TeAgentCredentialsError) {
184
189
  printError("config", message, err.hint);
185
190
  } else if (err instanceof PermissionError) {
186
- printError("permission", message, void 0, err.code);
191
+ printError("permission", message, err.hint, err.code);
187
192
  } else if (err instanceof CapabilityGatewayError) {
188
193
  printError("api", message, err.hint ?? capabilityGatewayHint(err), err.code, err.meta);
189
194
  } else if (err instanceof CommunityReportError) {
190
195
  printError("api", message, err.hint, err.code, err.meta, { log: false });
196
+ } else if (err instanceof LocalDataUploadError) {
197
+ printError("api", message, err.hint, err.code, err.meta, { log: false });
191
198
  } else if (err instanceof SecureStoreAuthError) {
192
199
  printError("auth", message, "Run: ae-cli auth login");
193
200
  } else if (err instanceof TeAgentApiError) {
@@ -245,17 +252,24 @@ function createRuntimeContext(cmd, opts, globalOpts) {
245
252
  let _clientModule = null;
246
253
  async function getClient() {
247
254
  if (!_clientModule) {
248
- _clientModule = await import("./client-L2YDMHQ6.js");
255
+ _clientModule = await import("./client-TKG4WBHN.js");
249
256
  }
250
257
  return _clientModule;
251
258
  }
252
259
  let _communityReportModule = null;
253
260
  async function getCommunityReportClient() {
254
261
  if (!_communityReportModule) {
255
- _communityReportModule = await import("./community-report-client-M2RW4MXD.js");
262
+ _communityReportModule = await import("./community-report-client-FI4LNVYS.js");
256
263
  }
257
264
  return _communityReportModule;
258
265
  }
266
+ let _localDataUploadModule = null;
267
+ async function getLocalDataUploadClient() {
268
+ if (!_localDataUploadModule) {
269
+ _localDataUploadModule = await import("./local-data-upload-client-BWHSUQQK.js");
270
+ }
271
+ return _localDataUploadModule;
272
+ }
259
273
  const ctx = {
260
274
  str(name) {
261
275
  return String(opts[camelCase(name)] ?? "");
@@ -283,6 +297,12 @@ function createRuntimeContext(cmd, opts, globalOpts) {
283
297
  process.exit(1);
284
298
  }
285
299
  },
300
+ list(name) {
301
+ const val = opts[camelCase(name)];
302
+ if (Array.isArray(val)) return val.map(String);
303
+ if (val === void 0 || val === null || val === "") return [];
304
+ return [String(val)];
305
+ },
286
306
  async api(method, path4, params, data) {
287
307
  const client = await getClient();
288
308
  if (method.toUpperCase() === "GET") {
@@ -303,8 +323,12 @@ function createRuntimeContext(cmd, opts, globalOpts) {
303
323
  const client = await getClient();
304
324
  return client.queryReportData(projectId, reportId, qp, eventModel, options, ctx.host());
305
325
  },
326
+ async localDataUpload(endpoint, rawBody, options) {
327
+ const client = await getLocalDataUploadClient();
328
+ return client.localDataUpload(endpoint, rawBody, options);
329
+ },
306
330
  async token() {
307
- const { getToken } = await import("./auth-GBMV6TEJ.js");
331
+ const { getToken } = await import("./auth-2WTQOP77.js");
308
332
  return getToken(ctx.host());
309
333
  },
310
334
  host() {
@@ -365,7 +389,9 @@ function registerCommands(program2, commands) {
365
389
  const sub = parent.command(cmd.command).description(cmd.description);
366
390
  for (const flag of cmd.flags) {
367
391
  const flagStr = buildFlagString(flag);
368
- if (flag.type === "boolean") {
392
+ if (flag.variadic) {
393
+ sub.option(flagStr, flag.desc, collectVariadic, []);
394
+ } else if (flag.type === "boolean") {
369
395
  sub.option(flagStr, flag.desc, (value) => parseBooleanValue(value, flag.name));
370
396
  } else if (flag.default !== void 0) {
371
397
  sub.option(flagStr, flag.desc, String(flag.default));
@@ -401,6 +427,9 @@ function buildFlagString(flag) {
401
427
  }
402
428
  return `${short}${long} <value>`;
403
429
  }
430
+ function collectVariadic(value, previous) {
431
+ return (previous ?? []).concat([value]);
432
+ }
404
433
  function parseBooleanValue(value, flagName) {
405
434
  if (value === void 0) {
406
435
  return true;
@@ -1754,7 +1783,7 @@ function getAutotrackEvents(sdkType, locale = "zh") {
1754
1783
  // src/tracking/plan/draft.ts
1755
1784
  function injectAutotrackEvents(draft, locale = "zh") {
1756
1785
  const mode = draft.meta.sdk_integration_mode;
1757
- if (mode === "server_only") {
1786
+ if (mode !== "client_only" && mode !== "both") {
1758
1787
  return draft;
1759
1788
  }
1760
1789
  const platforms = draft.meta.client_platforms;
@@ -3442,95 +3471,100 @@ program.name("ae-cli").version(version).description("CLI tool for ThinkingAI (AE
3442
3471
  async function loadCommands() {
3443
3472
  const commands = [];
3444
3473
  try {
3445
- const teAnalysis = await import("./te-analysis-PXNF7ZJT.js");
3474
+ const teAnalysis = await import("./te-analysis-WX7LRVAV.js");
3446
3475
  commands.push(...teAnalysis.default);
3447
3476
  } catch {
3448
3477
  }
3449
3478
  try {
3450
- const engage = await import("./te-engage-BVB7RGEO.js");
3479
+ const engage = await import("./te-engage-UBHPAJCO.js");
3451
3480
  commands.push(...engage.default);
3452
3481
  } catch {
3453
3482
  }
3454
3483
  try {
3455
- const community = await import("./te-community-HNKVTERD.js");
3484
+ const community = await import("./te-community-HLC43QKH.js");
3456
3485
  commands.push(...community.default);
3457
3486
  } catch {
3458
3487
  }
3459
3488
  try {
3460
- const dataops = await import("./te-dataops-KQPYNAE3.js");
3489
+ const dataops = await import("./te-dataops-EJP56W3K.js");
3461
3490
  commands.push(...dataops.default);
3462
3491
  } catch {
3463
3492
  }
3464
3493
  try {
3465
- const teKb = await import("./te-kb-OIH3T6CS.js");
3494
+ const teKb = await import("./te-kb-APXBWBDY.js");
3466
3495
  commands.push(...teKb.default);
3467
3496
  } catch {
3468
3497
  }
3469
3498
  try {
3470
- const teTeam = await import("./te-team-GZPU6UWA.js");
3499
+ const teTeam = await import("./te-team-EFKWYKMK.js");
3471
3500
  commands.push(...teTeam.default);
3472
3501
  } catch {
3473
3502
  }
3474
3503
  try {
3475
- const teAgent = await import("./te-agent-IFKZDHZI.js");
3504
+ const teAgent = await import("./te-agent-4BKBODMF.js");
3476
3505
  commands.push(...teAgent.default);
3477
3506
  } catch {
3478
3507
  }
3479
3508
  try {
3480
- const memory = await import("./memory-MUP7PPL7.js");
3509
+ const memory = await import("./memory-YK33G4T7.js");
3481
3510
  commands.push(...memory.default);
3482
3511
  } catch {
3483
3512
  }
3484
3513
  try {
3485
- const teSystem = await import("./te-system-AZ3URMUO.js");
3514
+ const teSystem = await import("./te-system-Z77IKZFN.js");
3486
3515
  commands.push(...teSystem.default);
3487
3516
  } catch {
3488
3517
  }
3489
3518
  try {
3490
- const metadata = await import("./metadata-HXOFACDE.js");
3519
+ const metadata = await import("./metadata-AXVHAAZG.js");
3491
3520
  commands.push(...metadata.default);
3492
3521
  } catch {
3493
3522
  }
3523
+ try {
3524
+ const dataIntegration = await import("./data-integration-2MYMANJI.js");
3525
+ commands.push(...dataIntegration.default);
3526
+ } catch {
3527
+ }
3494
3528
  return commands;
3495
3529
  }
3496
3530
  async function registerAuthCommands() {
3497
3531
  try {
3498
- const { registerAuth } = await import("./auth-NDSXE54J.js");
3532
+ const { registerAuth } = await import("./auth-77BUFLGC.js");
3499
3533
  registerAuth(program);
3500
3534
  } catch {
3501
3535
  }
3502
3536
  }
3503
3537
  async function registerConfigCommands() {
3504
3538
  try {
3505
- const { registerConfig } = await import("./config-OL2LWGBV.js");
3539
+ const { registerConfig } = await import("./config-RE6CMGPK.js");
3506
3540
  registerConfig(program);
3507
3541
  } catch {
3508
3542
  }
3509
3543
  }
3510
3544
  async function registerCapabilityCommands() {
3511
3545
  try {
3512
- const { registerCapability } = await import("./capability-CETVHGXF.js");
3546
+ const { registerCapability } = await import("./capability-WA37LSIR.js");
3513
3547
  registerCapability(program);
3514
3548
  } catch {
3515
3549
  }
3516
3550
  }
3517
3551
  async function registerSyncCommand() {
3518
3552
  try {
3519
- const { registerSync } = await import("./sync-MOSFNBVR.js");
3553
+ const { registerSync } = await import("./sync-FCKOVWWS.js");
3520
3554
  registerSync(program);
3521
3555
  } catch {
3522
3556
  }
3523
3557
  }
3524
3558
  async function registerModelCommand() {
3525
3559
  try {
3526
- const { registerModel } = await import("./model-JTUEO5M4.js");
3560
+ const { registerModel } = await import("./model-NR3JHFSJ.js");
3527
3561
  registerModel(program);
3528
3562
  } catch {
3529
3563
  }
3530
3564
  }
3531
3565
  async function registerUpdateCommand() {
3532
3566
  try {
3533
- const { registerUpdate } = await import("./update-TOBFXF2V.js");
3567
+ const { registerUpdate } = await import("./update-OGPSZM5A.js");
3534
3568
  registerUpdate(program);
3535
3569
  } catch {
3536
3570
  }
@@ -0,0 +1,167 @@
1
+ import {
2
+ LocalDataUploadError
3
+ } from "./chunk-UW5UN47B.js";
4
+ import {
5
+ logger
6
+ } from "./chunk-LYVNONC4.js";
7
+ import "./chunk-QGM4M3NI.js";
8
+
9
+ // src/core/local-data-upload-client.ts
10
+ import { createHash } from "crypto";
11
+ import { gzipSync } from "zlib";
12
+ var DEFAULT_TIMEOUT_MS = 3e4;
13
+ async function localDataUpload(endpoint, rawBody, options = {}) {
14
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
15
+ const fetchImpl = options.fetchImpl ?? fetch;
16
+ const retries = options.retries ?? 0;
17
+ const retryDelayMs = options.retryDelayMs ?? 2e3;
18
+ const compress = options.compress === "gzip";
19
+ const body = compress ? gzipSync(rawBody) : rawBody;
20
+ const requestBytes = Buffer.byteLength(rawBody, "utf8");
21
+ let attempt = 0;
22
+ while (true) {
23
+ try {
24
+ return await performAttempt(endpoint, body, { timeoutMs, fetchImpl, requestBytes, compress });
25
+ } catch (error) {
26
+ if (!(error instanceof LocalDataUploadError) || attempt >= retries || !isRetryable(error)) {
27
+ throw stampRetryMeta(error, attempt);
28
+ }
29
+ attempt += 1;
30
+ await sleep(retryDelayMs);
31
+ }
32
+ }
33
+ }
34
+ async function performAttempt(endpoint, body, options) {
35
+ const { timeoutMs, fetchImpl, requestBytes, compress } = options;
36
+ const controller = new AbortController();
37
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
38
+ let response;
39
+ let responseText = "";
40
+ try {
41
+ response = await fetchImpl(endpoint, {
42
+ method: "POST",
43
+ headers: {
44
+ "Content-Type": "application/json",
45
+ "Accept": "application/json",
46
+ ...compress ? { "Content-Encoding": "gzip" } : {}
47
+ },
48
+ body,
49
+ redirect: "manual",
50
+ signal: controller.signal
51
+ });
52
+ responseText = await response.text();
53
+ } catch (error) {
54
+ const timedOut = controller.signal.aborted || isAbortError(error);
55
+ logUpload(endpoint, response?.status ?? "unavailable", requestBytes, 0);
56
+ throw new LocalDataUploadError(
57
+ timedOut ? `Local data upload timed out after ${timeoutMs} ms. Delivery state is unknown.` : "Local data upload failed before a response was received. Delivery state is unknown.",
58
+ {
59
+ code: timedOut ? "LOCAL_DATA_UPLOAD_TIMEOUT" : "LOCAL_DATA_UPLOAD_NETWORK_ERROR",
60
+ hint: "Verify receiver data before choosing a resume position.",
61
+ meta: { delivery_state: "unknown", persistence_verified: false, retry_attempted: false },
62
+ cause: error
63
+ }
64
+ );
65
+ } finally {
66
+ clearTimeout(timeout);
67
+ }
68
+ const responseBytes = Buffer.byteLength(responseText, "utf8");
69
+ logUpload(endpoint, response.status, requestBytes, responseBytes);
70
+ if (response.status >= 300 && response.status < 400) {
71
+ throw new LocalDataUploadError("Receiver redirect was rejected and was not followed.", {
72
+ code: "LOCAL_DATA_UPLOAD_REDIRECT_REJECTED",
73
+ httpStatus: response.status,
74
+ meta: safeMeta(requestBytes, responseBytes, "not_accepted")
75
+ });
76
+ }
77
+ if (!response.ok) {
78
+ throw new LocalDataUploadError(`Receiver returned HTTP ${response.status}.`, {
79
+ code: `LOCAL_DATA_UPLOAD_HTTP_${response.status}`,
80
+ httpStatus: response.status,
81
+ hint: response.status >= 500 ? "Check receiver logs." : void 0,
82
+ meta: safeMeta(requestBytes, responseBytes, "rejected")
83
+ });
84
+ }
85
+ const responseBody = parseResponse(responseText, response.status);
86
+ if (!isRecord(responseBody) || typeof responseBody.code !== "number") {
87
+ throw new LocalDataUploadError("Receiver returned an invalid response without numeric code.", {
88
+ code: "LOCAL_DATA_UPLOAD_INVALID_RESPONSE",
89
+ httpStatus: response.status,
90
+ meta: safeMeta(requestBytes, responseBytes, "unknown")
91
+ });
92
+ }
93
+ if (responseBody.code !== 0) {
94
+ throw new LocalDataUploadError("Receiver rejected the UE batch.", {
95
+ code: responseBody.code,
96
+ httpStatus: response.status,
97
+ meta: safeMeta(requestBytes, responseBytes, "rejected")
98
+ });
99
+ }
100
+ return {
101
+ code: 0,
102
+ message: typeof responseBody.msg === "string" ? responseBody.msg : "success",
103
+ http_status: response.status,
104
+ request_bytes: requestBytes,
105
+ response_bytes: responseBytes
106
+ };
107
+ }
108
+ function parseResponse(text, status) {
109
+ if (!text.trim()) {
110
+ throw new LocalDataUploadError("Receiver returned an empty response.", {
111
+ code: "LOCAL_DATA_UPLOAD_INVALID_RESPONSE",
112
+ httpStatus: status,
113
+ meta: { delivery_state: "unknown", persistence_verified: false, retry_attempted: false }
114
+ });
115
+ }
116
+ try {
117
+ return JSON.parse(text);
118
+ } catch {
119
+ throw new LocalDataUploadError("Receiver returned a non-JSON response.", {
120
+ code: "LOCAL_DATA_UPLOAD_INVALID_RESPONSE",
121
+ httpStatus: status,
122
+ meta: { delivery_state: "unknown", persistence_verified: false, retry_attempted: false }
123
+ });
124
+ }
125
+ }
126
+ function isRetryable(error) {
127
+ if (error.code === "LOCAL_DATA_UPLOAD_TIMEOUT" || error.code === "LOCAL_DATA_UPLOAD_NETWORK_ERROR") return true;
128
+ return typeof error.code === "string" && error.code.startsWith("LOCAL_DATA_UPLOAD_HTTP_") && (error.httpStatus ?? 0) >= 500;
129
+ }
130
+ function stampRetryMeta(error, attempt) {
131
+ if (!(error instanceof LocalDataUploadError) || attempt === 0) return error;
132
+ return new LocalDataUploadError(error.message, {
133
+ code: error.code,
134
+ httpStatus: error.httpStatus,
135
+ hint: error.hint,
136
+ meta: { ...error.meta, retry_attempted: true, retry_count: attempt },
137
+ cause: error.cause
138
+ });
139
+ }
140
+ function safeMeta(requestBytes, responseBytes, deliveryState) {
141
+ return {
142
+ request_bytes: requestBytes,
143
+ response_bytes: responseBytes,
144
+ delivery_state: deliveryState,
145
+ persistence_verified: false,
146
+ retry_attempted: false
147
+ };
148
+ }
149
+ function isRecord(value) {
150
+ return value !== null && typeof value === "object" && !Array.isArray(value);
151
+ }
152
+ function isAbortError(error) {
153
+ return error instanceof Error && error.name === "AbortError";
154
+ }
155
+ function sleep(ms) {
156
+ return new Promise((resolve) => setTimeout(resolve, ms));
157
+ }
158
+ function logUpload(endpoint, status, requestBytes, responseBytes) {
159
+ const targetFingerprint = createHash("sha256").update(endpoint).digest("hex").slice(0, 12);
160
+ logger.info(
161
+ `LOCAL_DATA_UPLOAD target_sha256=${targetFingerprint} status=${status} request_bytes=${requestBytes} response_bytes=${responseBytes}`
162
+ );
163
+ }
164
+ export {
165
+ LocalDataUploadError,
166
+ localDataUpload
167
+ };
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  buildCapabilityGatewayUrl,
3
3
  callCapabilityApi
4
- } from "./chunk-JUW4AJXN.js";
5
- import "./chunk-S5NTSDBS.js";
6
- import "./chunk-ZQKDZXDO.js";
7
- import "./chunk-3FY3RJ26.js";
8
- import "./chunk-AXDXJTPC.js";
9
- import "./chunk-JHENBQ5B.js";
4
+ } from "./chunk-P3FGXJTU.js";
5
+ import "./chunk-C4MGVGJW.js";
6
+ import "./chunk-4SGZG4XY.js";
7
+ import "./chunk-ZZUOD757.js";
8
+ import "./chunk-UW5UN47B.js";
9
+ import "./chunk-LYVNONC4.js";
10
+ import "./chunk-QGM4M3NI.js";
10
11
 
11
12
  // src/commands/memory/index.ts
12
13
  import fs from "fs/promises";
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  buildCapabilityGatewayUrl,
3
3
  callCapabilityApi
4
- } from "./chunk-5XUSIK27.js";
5
- import "./chunk-S5NTSDBS.js";
6
- import "./chunk-ZQKDZXDO.js";
7
- import "./chunk-3FY3RJ26.js";
8
- import "./chunk-AXDXJTPC.js";
9
- import "./chunk-JHENBQ5B.js";
4
+ } from "./chunk-ILIU36SU.js";
5
+ import "./chunk-6EIJSNBD.js";
6
+ import "./chunk-4SGZG4XY.js";
7
+ import "./chunk-ZZUOD757.js";
8
+ import "./chunk-UW5UN47B.js";
9
+ import "./chunk-LYVNONC4.js";
10
+ import "./chunk-QGM4M3NI.js";
10
11
 
11
12
  // src/commands/memory/index.ts
12
13
  import fs from "fs/promises";
@@ -1,19 +1,20 @@
1
1
  import {
2
2
  withAsyncArtifactLifecycle
3
- } from "./chunk-4E3DB4MM.js";
3
+ } from "./chunk-EE45RGOO.js";
4
4
  import {
5
5
  createCapabilityCommand
6
- } from "./chunk-J2N4PB56.js";
7
- import "./chunk-5XUSIK27.js";
8
- import "./chunk-WZRX4KOH.js";
6
+ } from "./chunk-QEFCIRNJ.js";
7
+ import "./chunk-GT46FPXN.js";
8
+ import "./chunk-ILIU36SU.js";
9
9
  import {
10
10
  registerCapabilityGatewayRoute
11
11
  } from "./chunk-PTE56QPL.js";
12
- import "./chunk-S5NTSDBS.js";
13
- import "./chunk-ZQKDZXDO.js";
14
- import "./chunk-3FY3RJ26.js";
15
- import "./chunk-AXDXJTPC.js";
16
- import "./chunk-JHENBQ5B.js";
12
+ import "./chunk-6EIJSNBD.js";
13
+ import "./chunk-4SGZG4XY.js";
14
+ import "./chunk-ZZUOD757.js";
15
+ import "./chunk-UW5UN47B.js";
16
+ import "./chunk-LYVNONC4.js";
17
+ import "./chunk-QGM4M3NI.js";
17
18
 
18
19
  // src/commands/metadata/shared.ts
19
20
  function createCapabilityCommand2(config) {
@@ -1,19 +1,20 @@
1
1
  import {
2
2
  withAsyncArtifactLifecycle
3
- } from "./chunk-WANVG6SY.js";
3
+ } from "./chunk-MGU2N3HW.js";
4
4
  import {
5
5
  createCapabilityCommand
6
- } from "./chunk-FNZA5RZA.js";
7
- import "./chunk-JUW4AJXN.js";
8
- import "./chunk-WZRX4KOH.js";
6
+ } from "./chunk-QI524WPY.js";
7
+ import "./chunk-GT46FPXN.js";
8
+ import "./chunk-P3FGXJTU.js";
9
9
  import {
10
10
  registerCapabilityGatewayRoute
11
11
  } from "./chunk-PTE56QPL.js";
12
- import "./chunk-S5NTSDBS.js";
13
- import "./chunk-ZQKDZXDO.js";
14
- import "./chunk-3FY3RJ26.js";
15
- import "./chunk-AXDXJTPC.js";
16
- import "./chunk-JHENBQ5B.js";
12
+ import "./chunk-C4MGVGJW.js";
13
+ import "./chunk-4SGZG4XY.js";
14
+ import "./chunk-ZZUOD757.js";
15
+ import "./chunk-UW5UN47B.js";
16
+ import "./chunk-LYVNONC4.js";
17
+ import "./chunk-QGM4M3NI.js";
17
18
 
18
19
  // src/commands/metadata/shared.ts
19
20
  function createCapabilityCommand2(config) {
@@ -11,9 +11,13 @@ import {
11
11
  getClaudeConfigDir,
12
12
  getSandboxModels,
13
13
  postSandboxModelSelection
14
- } from "./chunk-VLWOLBGZ.js";
15
- import "./chunk-3FY3RJ26.js";
16
- import "./chunk-JHENBQ5B.js";
14
+ } from "./chunk-UOUS37JQ.js";
15
+ import "./chunk-C4MGVGJW.js";
16
+ import "./chunk-4SGZG4XY.js";
17
+ import "./chunk-ZZUOD757.js";
18
+ import "./chunk-UW5UN47B.js";
19
+ import "./chunk-LYVNONC4.js";
20
+ import "./chunk-QGM4M3NI.js";
17
21
 
18
22
  // src/commands/model/index.ts
19
23
  import { existsSync, readFileSync } from "fs";