@defai.digital/automatosx 12.6.0 → 12.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  [![Ubuntu](https://img.shields.io/badge/Ubuntu-24.04-blue.svg)](https://ubuntu.com)
13
13
  [![License](https://img.shields.io/badge/license-Apache--2.0-yellow.svg)](LICENSE)
14
14
 
15
- **Status**: ✅ **Production Ready** | v12.6.0 | Refactor System & TypeScript Fixes
15
+ **Status**: ✅ **Production Ready** | v12.6.2 | Test Coverage Improvements
16
16
 
17
17
  > 🎯 **What AutomatosX Does**: Adds 20+ specialized agents, persistent memory, workflow automation, and 80% cost savings to Claude Code/Codex - **without changing how you work**.
18
18
 
package/dist/index.js CHANGED
@@ -1418,6 +1418,119 @@ var init_path_resolver = __esm({
1418
1418
  }
1419
1419
  });
1420
1420
 
1421
+ // src/shared/utils/safe-timers.ts
1422
+ function createSafeInterval(callback, intervalMs, options = {}) {
1423
+ const { ref = false, name, signal, immediate = false } = options;
1424
+ if (signal?.aborted) {
1425
+ logger.debug("createSafeInterval: already aborted", { name });
1426
+ return () => {
1427
+ };
1428
+ }
1429
+ let cleared = false;
1430
+ let intervalId = null;
1431
+ const safeCallback = async () => {
1432
+ if (cleared) return;
1433
+ try {
1434
+ await callback();
1435
+ } catch (error) {
1436
+ logger.error("Safe interval callback error", {
1437
+ name,
1438
+ error: error.message
1439
+ });
1440
+ }
1441
+ };
1442
+ if (immediate) {
1443
+ setImmediate(() => {
1444
+ if (!cleared) {
1445
+ safeCallback();
1446
+ }
1447
+ });
1448
+ }
1449
+ intervalId = setInterval(safeCallback, intervalMs);
1450
+ if (!ref && intervalId.unref) {
1451
+ intervalId.unref();
1452
+ }
1453
+ const cleanup = () => {
1454
+ if (cleared) return;
1455
+ cleared = true;
1456
+ if (intervalId !== null) {
1457
+ clearInterval(intervalId);
1458
+ intervalId = null;
1459
+ logger.debug("Safe interval cleared", { name });
1460
+ }
1461
+ };
1462
+ if (signal) {
1463
+ signal.addEventListener("abort", cleanup, { once: true });
1464
+ }
1465
+ logger.debug("Safe interval created", {
1466
+ name,
1467
+ intervalMs,
1468
+ ref,
1469
+ immediate
1470
+ });
1471
+ return cleanup;
1472
+ }
1473
+ function createSafeTimeout(callback, delayMs, options = {}) {
1474
+ const { ref = false, name, signal } = options;
1475
+ if (signal?.aborted) {
1476
+ logger.debug("createSafeTimeout: already aborted", { name });
1477
+ return () => {
1478
+ };
1479
+ }
1480
+ let cleared = false;
1481
+ let timeoutId = null;
1482
+ const safeCallback = async () => {
1483
+ if (cleared) return;
1484
+ cleared = true;
1485
+ try {
1486
+ await callback();
1487
+ } catch (error) {
1488
+ logger.error("Safe timeout callback error", {
1489
+ name,
1490
+ error: error.message
1491
+ });
1492
+ }
1493
+ };
1494
+ timeoutId = setTimeout(safeCallback, delayMs);
1495
+ if (!ref && timeoutId.unref) {
1496
+ timeoutId.unref();
1497
+ }
1498
+ const cleanup = () => {
1499
+ if (cleared) return;
1500
+ cleared = true;
1501
+ if (timeoutId !== null) {
1502
+ clearTimeout(timeoutId);
1503
+ timeoutId = null;
1504
+ logger.debug("Safe timeout cleared", { name });
1505
+ }
1506
+ };
1507
+ if (signal) {
1508
+ signal.addEventListener("abort", cleanup, { once: true });
1509
+ }
1510
+ logger.debug("Safe timeout created", {
1511
+ name,
1512
+ delayMs,
1513
+ ref
1514
+ });
1515
+ return cleanup;
1516
+ }
1517
+ async function sleep(ms, signal) {
1518
+ return new Promise((resolve13, reject) => {
1519
+ const timeoutId = setTimeout(() => {
1520
+ resolve13();
1521
+ }, ms);
1522
+ if (timeoutId.unref) {
1523
+ timeoutId.unref();
1524
+ }
1525
+ });
1526
+ }
1527
+ var init_safe_timers = __esm({
1528
+ "src/shared/utils/safe-timers.ts"() {
1529
+ init_esm_shims();
1530
+ init_logger();
1531
+ }
1532
+ });
1533
+
1421
1534
  // src/core/workspace-indexer.ts
1422
1535
  var workspace_indexer_exports = {};
1423
1536
  __export(workspace_indexer_exports, {
@@ -5551,6 +5664,7 @@ var init_hybrid_adapter_base = __esm({
5551
5664
  init_flags();
5552
5665
  init_fallback_decision();
5553
5666
  init_provider_metrics();
5667
+ init_safe_timers();
5554
5668
  DEFAULT_CIRCUIT_BREAKER_CONFIG = {
5555
5669
  failureThreshold: 3,
5556
5670
  resetTimeout: 6e4,
@@ -5705,7 +5819,7 @@ var init_hybrid_adapter_base = __esm({
5705
5819
  });
5706
5820
  if (classification.decision === "retry_sdk" /* RETRY_SDK */ && attempt < this.maxRetries) {
5707
5821
  const delay = classification.retryDelayMs || 1e3;
5708
- await this.sleep(delay);
5822
+ await sleep(delay);
5709
5823
  continue;
5710
5824
  }
5711
5825
  if (classification.decision === "use_cli" /* USE_CLI */ || classification.decision === "retry_sdk" /* RETRY_SDK */ && attempt >= this.maxRetries) {
@@ -5880,12 +5994,6 @@ var init_hybrid_adapter_base = __esm({
5880
5994
  } catch {
5881
5995
  }
5882
5996
  }
5883
- /**
5884
- * Sleep utility
5885
- */
5886
- sleep(ms) {
5887
- return new Promise((resolve13) => setTimeout(resolve13, ms));
5888
- }
5889
5997
  /**
5890
5998
  * Get current active mode
5891
5999
  */
@@ -6481,6 +6589,7 @@ var init_sdk_only_adapter = __esm({
6481
6589
  "src/integrations/ax-glm/sdk-only-adapter.ts"() {
6482
6590
  init_esm_shims();
6483
6591
  init_logger();
6592
+ init_safe_timers();
6484
6593
  init_sdk_adapter2();
6485
6594
  init_types2();
6486
6595
  GLMSdkOnlyAdapter = class {
@@ -6560,7 +6669,7 @@ var init_sdk_only_adapter = __esm({
6560
6669
  attempt: attempt + 1,
6561
6670
  delayMs: delay
6562
6671
  });
6563
- await this.sleep(delay);
6672
+ await sleep(delay);
6564
6673
  continue;
6565
6674
  }
6566
6675
  break;
@@ -6596,12 +6705,6 @@ var init_sdk_only_adapter = __esm({
6596
6705
  }
6597
6706
  return false;
6598
6707
  }
6599
- /**
6600
- * Sleep utility
6601
- */
6602
- sleep(ms) {
6603
- return new Promise((resolve13) => setTimeout(resolve13, ms));
6604
- }
6605
6708
  /**
6606
6709
  * Get the configured model
6607
6710
  */
@@ -7438,6 +7541,7 @@ var init_sdk_only_adapter2 = __esm({
7438
7541
  "src/integrations/ax-grok/sdk-only-adapter.ts"() {
7439
7542
  init_esm_shims();
7440
7543
  init_logger();
7544
+ init_safe_timers();
7441
7545
  init_sdk_adapter3();
7442
7546
  init_types3();
7443
7547
  GrokSdkOnlyAdapter = class {
@@ -7517,7 +7621,7 @@ var init_sdk_only_adapter2 = __esm({
7517
7621
  attempt: attempt + 1,
7518
7622
  delayMs: delay
7519
7623
  });
7520
- await this.sleep(delay);
7624
+ await sleep(delay);
7521
7625
  continue;
7522
7626
  }
7523
7627
  break;
@@ -7553,12 +7657,6 @@ var init_sdk_only_adapter2 = __esm({
7553
7657
  }
7554
7658
  return false;
7555
7659
  }
7556
- /**
7557
- * Sleep utility
7558
- */
7559
- sleep(ms) {
7560
- return new Promise((resolve13) => setTimeout(resolve13, ms));
7561
- }
7562
7660
  /**
7563
7661
  * Get the configured model
7564
7662
  */
@@ -9394,7 +9492,7 @@ var PRECOMPILED_CONFIG = {
9394
9492
  "enableFreeTierPrioritization": true,
9395
9493
  "enableWorkloadAwareRouting": true
9396
9494
  },
9397
- "version": "12.6.0"
9495
+ "version": "12.6.1"
9398
9496
  };
9399
9497
 
9400
9498
  // src/core/config/schemas.ts
@@ -12417,7 +12515,11 @@ var ProfileLoader = class {
12417
12515
  continue;
12418
12516
  }
12419
12517
  const data = load(content);
12420
- return data && typeof data === "object" && !Array.isArray(data) && "displayName" in data ? data.displayName || null : null;
12518
+ if (data && typeof data === "object" && !Array.isArray(data) && "displayName" in data) {
12519
+ const profile = data;
12520
+ return profile.displayName ?? null;
12521
+ }
12522
+ return null;
12421
12523
  } catch (error) {
12422
12524
  if (error.code === "ENOENT") {
12423
12525
  continue;
@@ -12446,7 +12548,7 @@ var ProfileLoader = class {
12446
12548
  });
12447
12549
  return identifier;
12448
12550
  } catch (error) {
12449
- if (error.name === "AgentNotFoundError") {
12551
+ if (error instanceof Error && error.name === "AgentNotFoundError") {
12450
12552
  logger.debug("Direct profile load failed, trying displayName lookup", { identifier });
12451
12553
  await this.buildDisplayNameMap();
12452
12554
  const resolved = this.displayNameMap.get(identifier.toLowerCase());
@@ -12775,7 +12877,7 @@ var ProfileLoader = class {
12775
12877
  if (typeof orch !== "object" || orch === null || Array.isArray(orch)) {
12776
12878
  throw new AgentValidationError("orchestration must be an object");
12777
12879
  }
12778
- if (orch.canDelegate !== void 0) {
12880
+ if ("canDelegate" in orch && orch.canDelegate !== void 0) {
12779
12881
  logger.warn("orchestration.canDelegate is deprecated and ignored (v4.9.0+). All agents can delegate by default.", {
12780
12882
  agent: profile.name
12781
12883
  });
@@ -12821,17 +12923,18 @@ var ProfileLoader = class {
12821
12923
  if (!data || typeof data !== "object" || Array.isArray(data)) {
12822
12924
  throw new AgentValidationError(`Invalid profile data for ${name}: expected object, got ${typeof data}`);
12823
12925
  }
12824
- if (data.name && typeof data.name === "string") {
12825
- if (!/^[a-zA-Z0-9_-]+$/.test(data.name)) {
12826
- if (!data.displayName) {
12827
- data.displayName = data.name;
12926
+ const profileData = data;
12927
+ if (profileData.name && typeof profileData.name === "string") {
12928
+ if (!/^[a-zA-Z0-9_-]+$/.test(profileData.name)) {
12929
+ if (!profileData.displayName) {
12930
+ profileData.displayName = profileData.name;
12828
12931
  }
12829
- data.name = name;
12932
+ profileData.name = name;
12830
12933
  }
12831
- } else if (!data.name) {
12832
- data.name = name;
12934
+ } else if (!profileData.name) {
12935
+ profileData.name = name;
12833
12936
  }
12834
- const validationResult = safeValidateAgentProfile(data);
12937
+ const validationResult = safeValidateAgentProfile(profileData);
12835
12938
  if (!validationResult.success) {
12836
12939
  const validationErrors = validationResult.error.issues.map(
12837
12940
  (e) => `${e.path.join(".")}: ${e.message}`
@@ -12841,22 +12944,22 @@ var ProfileLoader = class {
12841
12944
  );
12842
12945
  }
12843
12946
  let teamConfig;
12844
- if (data.team && this.teamManager) {
12947
+ if (profileData.team && this.teamManager) {
12845
12948
  try {
12846
- teamConfig = await this.teamManager.loadTeam(data.team);
12949
+ teamConfig = await this.teamManager.loadTeam(profileData.team);
12847
12950
  logger.debug("Team configuration loaded for agent", {
12848
12951
  agent: name,
12849
- team: data.team
12952
+ team: profileData.team
12850
12953
  });
12851
12954
  } catch (error) {
12852
12955
  logger.warn("Failed to load team configuration, using agent defaults", {
12853
12956
  agent: name,
12854
- team: data.team,
12957
+ team: profileData.team,
12855
12958
  error: error.message
12856
12959
  });
12857
12960
  }
12858
12961
  }
12859
- const abilities = data.abilities || [];
12962
+ const abilities = profileData.abilities || [];
12860
12963
  if (teamConfig?.sharedAbilities) {
12861
12964
  const allAbilities = [.../* @__PURE__ */ new Set([...teamConfig.sharedAbilities, ...abilities])];
12862
12965
  logger.debug("Merged abilities from team", {
@@ -12868,7 +12971,7 @@ var ProfileLoader = class {
12868
12971
  });
12869
12972
  abilities.splice(0, abilities.length, ...allAbilities);
12870
12973
  }
12871
- let orchestration = data.orchestration;
12974
+ let orchestration = profileData.orchestration;
12872
12975
  if (teamConfig?.orchestration && !orchestration) {
12873
12976
  orchestration = teamConfig.orchestration;
12874
12977
  logger.debug("Using team orchestration defaults", {
@@ -12877,32 +12980,32 @@ var ProfileLoader = class {
12877
12980
  });
12878
12981
  }
12879
12982
  const profile = {
12880
- name: data.name || name,
12881
- displayName: data.displayName,
12882
- role: data.role,
12883
- description: data.description,
12983
+ name: profileData.name || name,
12984
+ displayName: profileData.displayName,
12985
+ role: profileData.role,
12986
+ description: profileData.description,
12884
12987
  // v4.10.0+: Team field
12885
- team: data.team,
12886
- systemPrompt: data.systemPrompt,
12988
+ team: profileData.team,
12989
+ systemPrompt: profileData.systemPrompt,
12887
12990
  abilities,
12888
- dependencies: data.dependencies,
12889
- parallel: data.parallel,
12991
+ dependencies: profileData.dependencies,
12992
+ parallel: profileData.parallel,
12890
12993
  // Enhanced v4.1+ features
12891
- stages: data.stages,
12892
- personality: data.personality,
12893
- thinking_patterns: data.thinking_patterns,
12894
- abilitySelection: data.abilitySelection,
12994
+ stages: profileData.stages,
12995
+ personality: profileData.personality,
12996
+ thinking_patterns: profileData.thinking_patterns,
12997
+ abilitySelection: profileData.abilitySelection,
12895
12998
  // v5.7.0+: Agent Selection Metadata
12896
- selectionMetadata: data.selectionMetadata,
12999
+ selectionMetadata: profileData.selectionMetadata,
12897
13000
  // Provider preferences (deprecated, kept for backward compatibility)
12898
- provider: data.provider,
12899
- model: data.model,
12900
- temperature: data.temperature,
12901
- maxTokens: data.maxTokens,
13001
+ provider: profileData.provider,
13002
+ model: profileData.model,
13003
+ temperature: profileData.temperature,
13004
+ maxTokens: profileData.maxTokens,
12902
13005
  // Optional
12903
- tags: data.tags,
12904
- version: data.version,
12905
- metadata: data.metadata,
13006
+ tags: profileData.tags,
13007
+ version: profileData.version,
13008
+ metadata: profileData.metadata,
12906
13009
  // v4.7.0+ Orchestration (merged with team defaults)
12907
13010
  orchestration
12908
13011
  };
@@ -16677,107 +16780,7 @@ init_logger();
16677
16780
  // src/shared/utils/disposable.ts
16678
16781
  init_esm_shims();
16679
16782
  init_logger();
16680
-
16681
- // src/shared/utils/safe-timers.ts
16682
- init_esm_shims();
16683
- init_logger();
16684
- function createSafeInterval(callback, intervalMs, options = {}) {
16685
- const { ref = false, name, signal, immediate = false } = options;
16686
- if (signal?.aborted) {
16687
- logger.debug("createSafeInterval: already aborted", { name });
16688
- return () => {
16689
- };
16690
- }
16691
- let cleared = false;
16692
- let intervalId = null;
16693
- const safeCallback = async () => {
16694
- if (cleared) return;
16695
- try {
16696
- await callback();
16697
- } catch (error) {
16698
- logger.error("Safe interval callback error", {
16699
- name,
16700
- error: error.message
16701
- });
16702
- }
16703
- };
16704
- if (immediate) {
16705
- setImmediate(() => {
16706
- if (!cleared) {
16707
- safeCallback();
16708
- }
16709
- });
16710
- }
16711
- intervalId = setInterval(safeCallback, intervalMs);
16712
- if (!ref && intervalId.unref) {
16713
- intervalId.unref();
16714
- }
16715
- const cleanup = () => {
16716
- if (cleared) return;
16717
- cleared = true;
16718
- if (intervalId !== null) {
16719
- clearInterval(intervalId);
16720
- intervalId = null;
16721
- logger.debug("Safe interval cleared", { name });
16722
- }
16723
- };
16724
- if (signal) {
16725
- signal.addEventListener("abort", cleanup, { once: true });
16726
- }
16727
- logger.debug("Safe interval created", {
16728
- name,
16729
- intervalMs,
16730
- ref,
16731
- immediate
16732
- });
16733
- return cleanup;
16734
- }
16735
- function createSafeTimeout(callback, delayMs, options = {}) {
16736
- const { ref = false, name, signal } = options;
16737
- if (signal?.aborted) {
16738
- logger.debug("createSafeTimeout: already aborted", { name });
16739
- return () => {
16740
- };
16741
- }
16742
- let cleared = false;
16743
- let timeoutId = null;
16744
- const safeCallback = async () => {
16745
- if (cleared) return;
16746
- cleared = true;
16747
- try {
16748
- await callback();
16749
- } catch (error) {
16750
- logger.error("Safe timeout callback error", {
16751
- name,
16752
- error: error.message
16753
- });
16754
- }
16755
- };
16756
- timeoutId = setTimeout(safeCallback, delayMs);
16757
- if (!ref && timeoutId.unref) {
16758
- timeoutId.unref();
16759
- }
16760
- const cleanup = () => {
16761
- if (cleared) return;
16762
- cleared = true;
16763
- if (timeoutId !== null) {
16764
- clearTimeout(timeoutId);
16765
- timeoutId = null;
16766
- logger.debug("Safe timeout cleared", { name });
16767
- }
16768
- };
16769
- if (signal) {
16770
- signal.addEventListener("abort", cleanup, { once: true });
16771
- }
16772
- logger.debug("Safe timeout created", {
16773
- name,
16774
- delayMs,
16775
- ref
16776
- });
16777
- return cleanup;
16778
- }
16779
-
16780
- // src/shared/utils/disposable.ts
16783
+ init_safe_timers();
16781
16784
  var DisposableEventEmitter = class extends EventEmitter {
16782
16785
  /** Registered cleanup tasks */
16783
16786
  cleanupTasks = [];
@@ -28643,7 +28646,7 @@ var BugDetector = class {
28643
28646
  });
28644
28647
  let files;
28645
28648
  if (fileFilter && fileFilter.length > 0) {
28646
- files = fileFilter.map((f) => f.startsWith("/") ? f : join(rootDir, f)).filter((f) => {
28649
+ files = fileFilter.map((f) => isAbsolute(f) ? f : join(rootDir, f)).filter((f) => {
28647
28650
  const ext = extname$1(f);
28648
28651
  return [".ts", ".js", ".mts", ".mjs", ".tsx", ".jsx"].includes(ext);
28649
28652
  }).filter((f) => !this.isExcluded(relative(rootDir, f)));
@@ -33191,6 +33194,9 @@ function countAnyTypes(code) {
33191
33194
  }
33192
33195
  return count;
33193
33196
  }
33197
+ function escapeRegex2(str) {
33198
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
33199
+ }
33194
33200
  function countUnusedImports(code) {
33195
33201
  const importMatches = code.match(/import\s+{([^}]+)}\s+from/g);
33196
33202
  if (!importMatches) return 0;
@@ -33200,10 +33206,17 @@ function countUnusedImports(code) {
33200
33206
  const namedImports = importMatch.match(/{([^}]+)}/);
33201
33207
  const namedImportContent = namedImports?.[1];
33202
33208
  if (namedImportContent) {
33203
- const names = namedImportContent.split(",").map((n) => n.trim().split(/\s+as\s+/).pop()?.trim() ?? "");
33209
+ const names = namedImportContent.split(",").map((n) => {
33210
+ const trimmed = n.trim();
33211
+ const withoutType = trimmed.replace(/^type\s+/, "");
33212
+ return withoutType.split(/\s+as\s+/).pop()?.trim() ?? "";
33213
+ }).filter((name) => name.length > 0 && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name));
33204
33214
  for (const name of names) {
33205
- if (name && !new RegExp(`\\b${name}\\b`).test(codeWithoutImports)) {
33206
- unusedCount++;
33215
+ try {
33216
+ if (!new RegExp(`\\b${escapeRegex2(name)}\\b`).test(codeWithoutImports)) {
33217
+ unusedCount++;
33218
+ }
33219
+ } catch {
33207
33220
  }
33208
33221
  }
33209
33222
  }
@@ -36659,6 +36672,7 @@ init_logger();
36659
36672
  // src/core/task-engine/task-queue.ts
36660
36673
  init_esm_shims();
36661
36674
  init_logger();
36675
+ init_safe_timers();
36662
36676
 
36663
36677
  // src/mcp/tools/task/create-task.ts
36664
36678
  init_logger();
@@ -40894,6 +40908,7 @@ function createResourceEnforcer(config) {
40894
40908
 
40895
40909
  // src/mcp/unified-manager.ts
40896
40910
  init_validation_limits();
40911
+ init_safe_timers();
40897
40912
  var UnifiedMCPManager = class {
40898
40913
  constructor(config) {
40899
40914
  this.config = config;
@@ -41013,7 +41028,7 @@ var UnifiedMCPManager = class {
41013
41028
  };
41014
41029
  this.setupProcessHandlers(config.name, childProcess, serverProcess);
41015
41030
  this.servers.set(config.name, serverProcess);
41016
- await new Promise((resolve13) => setTimeout(resolve13, 100));
41031
+ await sleep(100);
41017
41032
  if (childProcess.killed || childProcess.exitCode !== null) {
41018
41033
  throw new Error(
41019
41034
  `Server process exited immediately with code ${childProcess.exitCode}`
@@ -41124,7 +41139,7 @@ var UnifiedMCPManager = class {
41124
41139
  async restartServer(serverName) {
41125
41140
  logger.info("UnifiedMCPManager: Restarting server", { name: serverName });
41126
41141
  await this.stopServer(serverName);
41127
- await new Promise((resolve13) => setTimeout(resolve13, 1e3));
41142
+ await sleep(1e3);
41128
41143
  const serverConfig = this.config.servers.find((s) => s.name === serverName);
41129
41144
  if (!serverConfig) {
41130
41145
  throw new Error(`Server configuration not found: ${serverName}`);
@@ -43650,6 +43665,7 @@ var ProgressRenderer = class {
43650
43665
 
43651
43666
  // src/core/stage-execution-controller.ts
43652
43667
  init_logger();
43668
+ init_safe_timers();
43653
43669
  var StageExecutionController = class {
43654
43670
  // Dependencies
43655
43671
  agentExecutor;
@@ -44316,9 +44332,9 @@ ${action.modifications}`;
44316
44332
  )
44317
44333
  );
44318
44334
  console.log(chalk5.gray(` Waiting ${delay}ms before retry...`));
44319
- await new Promise((resolve13) => setTimeout(resolve13, delay));
44335
+ await sleep(delay);
44320
44336
  } else {
44321
- await new Promise((resolve13) => setTimeout(resolve13, delay));
44337
+ await sleep(delay);
44322
44338
  }
44323
44339
  }
44324
44340
  const executionOptions = {
@@ -58294,6 +58310,7 @@ async function runMcpDiagnostics(verbose) {
58294
58310
  // src/cli/commands/cleanup.ts
58295
58311
  init_esm_shims();
58296
58312
  init_logger();
58313
+ init_safe_timers();
58297
58314
  var execAsync6 = promisify(exec);
58298
58315
  var cleanupCommand2 = {
58299
58316
  command: "cleanup [provider]",
@@ -58486,7 +58503,7 @@ async function killProcess(pid, verbose) {
58486
58503
  });
58487
58504
  proc.on("error", reject);
58488
58505
  });
58489
- await new Promise((resolve13) => setTimeout(resolve13, 1e3));
58506
+ await sleep(1e3);
58490
58507
  try {
58491
58508
  await new Promise((resolve13, reject) => {
58492
58509
  const proc = spawn("ps", ["-p", String(pid)], {
@@ -59737,6 +59754,7 @@ init_esm_shims();
59737
59754
  init_flags();
59738
59755
  init_logger();
59739
59756
  init_validation_limits();
59757
+ init_safe_timers();
59740
59758
  var flagsCommand = {
59741
59759
  command: "flags <command>",
59742
59760
  describe: "Manage feature flags",
@@ -59886,7 +59904,7 @@ async function handleKill(argv) {
59886
59904
  `);
59887
59905
  console.log(chalk5.yellow("This will immediately disable the feature for ALL users."));
59888
59906
  console.log(chalk5.gray("Press Ctrl+C to cancel, or wait 5 seconds to confirm...\n"));
59889
- await new Promise((resolve13) => setTimeout(resolve13, TIMEOUTS.KILL_SWITCH_DELAY));
59907
+ await sleep(TIMEOUTS.KILL_SWITCH_DELAY);
59890
59908
  try {
59891
59909
  await flagManager.killSwitch(flagName, reason);
59892
59910
  console.log(chalk5.red("\u2713 Kill switch activated"));
@@ -61896,42 +61914,20 @@ var AgentInstructionInjector = class {
61896
61914
  this.lastQualityCheckTurn = context.turnCount;
61897
61915
  }
61898
61916
  const taskText = this.extractTaskText(context);
61899
- if (this.config.delegationDetection) {
61900
- if (taskText !== this.recentTaskText) {
61901
- this.recentTaskText = taskText;
61902
- const delegationContent = this.checkAndFormatDelegation(template, taskText);
61903
- if (delegationContent) {
61904
- instructions.push({
61905
- type: "delegation",
61906
- priority: "high",
61907
- content: delegationContent,
61908
- source: INSTRUCTION_SOURCE,
61909
- createdAt: Date.now(),
61910
- createdAtTurn: context.turnCount,
61911
- expiresAfter: 3,
61912
- id: `agent-delegation-${Date.now()}`
61913
- });
61914
- }
61915
- }
61917
+ const delegationInstruction = this.tryCreateDelegationInstruction(
61918
+ template,
61919
+ taskText,
61920
+ context.turnCount
61921
+ );
61922
+ if (delegationInstruction) {
61923
+ instructions.push(delegationInstruction);
61916
61924
  }
61917
- if (this.config.contextAwareBoosting && taskText) {
61918
- const detectedCategories = this.detectContextCategories(taskText);
61919
- const contextBoostContent = this.formatContextBoost(detectedCategories);
61920
- if (contextBoostContent) {
61921
- instructions.push({
61922
- type: "context",
61923
- priority: "normal",
61924
- content: contextBoostContent,
61925
- source: INSTRUCTION_SOURCE,
61926
- createdAt: Date.now(),
61927
- createdAtTurn: context.turnCount,
61928
- expiresAfter: 5,
61929
- id: `agent-context-boost-${Date.now()}`
61930
- });
61931
- logger.debug("Context-aware boost applied", {
61932
- categories: detectedCategories.map((c) => c.name)
61933
- });
61934
- }
61925
+ const contextInstruction = this.tryCreateContextBoostInstruction(
61926
+ taskText,
61927
+ context.turnCount
61928
+ );
61929
+ if (contextInstruction) {
61930
+ instructions.push(contextInstruction);
61935
61931
  }
61936
61932
  logger.debug("Agent instructions generated", {
61937
61933
  domain,
@@ -62032,6 +62028,62 @@ var AgentInstructionInjector = class {
62032
62028
  lines.push("Use `DELEGATE TO @agent: task` or `@agent task` syntax to delegate.");
62033
62029
  return lines.join("\n");
62034
62030
  }
62031
+ /**
62032
+ * Try to create a delegation instruction
62033
+ * Returns null if delegation detection is disabled or no delegation is needed
62034
+ * @since v12.6.1 - Extracted to reduce nesting
62035
+ */
62036
+ tryCreateDelegationInstruction(template, taskText, turnCount) {
62037
+ if (!this.config.delegationDetection) {
62038
+ return null;
62039
+ }
62040
+ if (taskText === this.recentTaskText) {
62041
+ return null;
62042
+ }
62043
+ this.recentTaskText = taskText;
62044
+ const delegationContent = this.checkAndFormatDelegation(template, taskText);
62045
+ if (!delegationContent) {
62046
+ return null;
62047
+ }
62048
+ return {
62049
+ type: "delegation",
62050
+ priority: "high",
62051
+ content: delegationContent,
62052
+ source: INSTRUCTION_SOURCE,
62053
+ createdAt: Date.now(),
62054
+ createdAtTurn: turnCount,
62055
+ expiresAfter: 3,
62056
+ id: `agent-delegation-${Date.now()}`
62057
+ };
62058
+ }
62059
+ /**
62060
+ * Try to create a context boost instruction
62061
+ * Returns null if context boosting is disabled or no boost is needed
62062
+ * @since v12.6.1 - Extracted to reduce nesting
62063
+ */
62064
+ tryCreateContextBoostInstruction(taskText, turnCount) {
62065
+ if (!this.config.contextAwareBoosting || !taskText) {
62066
+ return null;
62067
+ }
62068
+ const detectedCategories = this.detectContextCategories(taskText);
62069
+ const contextBoostContent = this.formatContextBoost(detectedCategories);
62070
+ if (!contextBoostContent) {
62071
+ return null;
62072
+ }
62073
+ logger.debug("Context-aware boost applied", {
62074
+ categories: detectedCategories.map((c) => c.name)
62075
+ });
62076
+ return {
62077
+ type: "context",
62078
+ priority: "normal",
62079
+ content: contextBoostContent,
62080
+ source: INSTRUCTION_SOURCE,
62081
+ createdAt: Date.now(),
62082
+ createdAtTurn: turnCount,
62083
+ expiresAfter: 5,
62084
+ id: `agent-context-boost-${Date.now()}`
62085
+ };
62086
+ }
62035
62087
  /**
62036
62088
  * Detect context categories from task text
62037
62089
  * @since v11.3.1
package/dist/mcp/index.js CHANGED
@@ -772,6 +772,119 @@ var init_errors = __esm({
772
772
  }
773
773
  });
774
774
 
775
+ // src/shared/utils/safe-timers.ts
776
+ function createSafeInterval(callback, intervalMs, options = {}) {
777
+ const { ref = false, name, signal, immediate = false } = options;
778
+ if (signal?.aborted) {
779
+ logger.debug("createSafeInterval: already aborted", { name });
780
+ return () => {
781
+ };
782
+ }
783
+ let cleared = false;
784
+ let intervalId = null;
785
+ const safeCallback = async () => {
786
+ if (cleared) return;
787
+ try {
788
+ await callback();
789
+ } catch (error) {
790
+ logger.error("Safe interval callback error", {
791
+ name,
792
+ error: error.message
793
+ });
794
+ }
795
+ };
796
+ if (immediate) {
797
+ setImmediate(() => {
798
+ if (!cleared) {
799
+ safeCallback();
800
+ }
801
+ });
802
+ }
803
+ intervalId = setInterval(safeCallback, intervalMs);
804
+ if (!ref && intervalId.unref) {
805
+ intervalId.unref();
806
+ }
807
+ const cleanup = () => {
808
+ if (cleared) return;
809
+ cleared = true;
810
+ if (intervalId !== null) {
811
+ clearInterval(intervalId);
812
+ intervalId = null;
813
+ logger.debug("Safe interval cleared", { name });
814
+ }
815
+ };
816
+ if (signal) {
817
+ signal.addEventListener("abort", cleanup, { once: true });
818
+ }
819
+ logger.debug("Safe interval created", {
820
+ name,
821
+ intervalMs,
822
+ ref,
823
+ immediate
824
+ });
825
+ return cleanup;
826
+ }
827
+ function createSafeTimeout(callback, delayMs, options = {}) {
828
+ const { ref = false, name, signal } = options;
829
+ if (signal?.aborted) {
830
+ logger.debug("createSafeTimeout: already aborted", { name });
831
+ return () => {
832
+ };
833
+ }
834
+ let cleared = false;
835
+ let timeoutId = null;
836
+ const safeCallback = async () => {
837
+ if (cleared) return;
838
+ cleared = true;
839
+ try {
840
+ await callback();
841
+ } catch (error) {
842
+ logger.error("Safe timeout callback error", {
843
+ name,
844
+ error: error.message
845
+ });
846
+ }
847
+ };
848
+ timeoutId = setTimeout(safeCallback, delayMs);
849
+ if (!ref && timeoutId.unref) {
850
+ timeoutId.unref();
851
+ }
852
+ const cleanup = () => {
853
+ if (cleared) return;
854
+ cleared = true;
855
+ if (timeoutId !== null) {
856
+ clearTimeout(timeoutId);
857
+ timeoutId = null;
858
+ logger.debug("Safe timeout cleared", { name });
859
+ }
860
+ };
861
+ if (signal) {
862
+ signal.addEventListener("abort", cleanup, { once: true });
863
+ }
864
+ logger.debug("Safe timeout created", {
865
+ name,
866
+ delayMs,
867
+ ref
868
+ });
869
+ return cleanup;
870
+ }
871
+ async function sleep(ms, signal) {
872
+ return new Promise((resolve5, reject) => {
873
+ const timeoutId = setTimeout(() => {
874
+ resolve5();
875
+ }, ms);
876
+ if (timeoutId.unref) {
877
+ timeoutId.unref();
878
+ }
879
+ });
880
+ }
881
+ var init_safe_timers = __esm({
882
+ "src/shared/utils/safe-timers.ts"() {
883
+ init_esm_shims();
884
+ init_logger();
885
+ }
886
+ });
887
+
775
888
  // src/shared/process/process-manager.ts
776
889
  var process_manager_exports = {};
777
890
  __export(process_manager_exports, {
@@ -5295,6 +5408,7 @@ var init_hybrid_adapter_base = __esm({
5295
5408
  init_flags();
5296
5409
  init_fallback_decision();
5297
5410
  init_provider_metrics();
5411
+ init_safe_timers();
5298
5412
  DEFAULT_CIRCUIT_BREAKER_CONFIG = {
5299
5413
  failureThreshold: 3,
5300
5414
  resetTimeout: 6e4,
@@ -5449,7 +5563,7 @@ var init_hybrid_adapter_base = __esm({
5449
5563
  });
5450
5564
  if (classification.decision === "retry_sdk" /* RETRY_SDK */ && attempt < this.maxRetries) {
5451
5565
  const delay = classification.retryDelayMs || 1e3;
5452
- await this.sleep(delay);
5566
+ await sleep(delay);
5453
5567
  continue;
5454
5568
  }
5455
5569
  if (classification.decision === "use_cli" /* USE_CLI */ || classification.decision === "retry_sdk" /* RETRY_SDK */ && attempt >= this.maxRetries) {
@@ -5624,12 +5738,6 @@ var init_hybrid_adapter_base = __esm({
5624
5738
  } catch {
5625
5739
  }
5626
5740
  }
5627
- /**
5628
- * Sleep utility
5629
- */
5630
- sleep(ms) {
5631
- return new Promise((resolve5) => setTimeout(resolve5, ms));
5632
- }
5633
5741
  /**
5634
5742
  * Get current active mode
5635
5743
  */
@@ -6225,6 +6333,7 @@ var init_sdk_only_adapter = __esm({
6225
6333
  "src/integrations/ax-glm/sdk-only-adapter.ts"() {
6226
6334
  init_esm_shims();
6227
6335
  init_logger();
6336
+ init_safe_timers();
6228
6337
  init_sdk_adapter2();
6229
6338
  init_types2();
6230
6339
  GLMSdkOnlyAdapter = class {
@@ -6304,7 +6413,7 @@ var init_sdk_only_adapter = __esm({
6304
6413
  attempt: attempt + 1,
6305
6414
  delayMs: delay
6306
6415
  });
6307
- await this.sleep(delay);
6416
+ await sleep(delay);
6308
6417
  continue;
6309
6418
  }
6310
6419
  break;
@@ -6340,12 +6449,6 @@ var init_sdk_only_adapter = __esm({
6340
6449
  }
6341
6450
  return false;
6342
6451
  }
6343
- /**
6344
- * Sleep utility
6345
- */
6346
- sleep(ms) {
6347
- return new Promise((resolve5) => setTimeout(resolve5, ms));
6348
- }
6349
6452
  /**
6350
6453
  * Get the configured model
6351
6454
  */
@@ -7182,6 +7285,7 @@ var init_sdk_only_adapter2 = __esm({
7182
7285
  "src/integrations/ax-grok/sdk-only-adapter.ts"() {
7183
7286
  init_esm_shims();
7184
7287
  init_logger();
7288
+ init_safe_timers();
7185
7289
  init_sdk_adapter3();
7186
7290
  init_types3();
7187
7291
  GrokSdkOnlyAdapter = class {
@@ -7261,7 +7365,7 @@ var init_sdk_only_adapter2 = __esm({
7261
7365
  attempt: attempt + 1,
7262
7366
  delayMs: delay
7263
7367
  });
7264
- await this.sleep(delay);
7368
+ await sleep(delay);
7265
7369
  continue;
7266
7370
  }
7267
7371
  break;
@@ -7297,12 +7401,6 @@ var init_sdk_only_adapter2 = __esm({
7297
7401
  }
7298
7402
  return false;
7299
7403
  }
7300
- /**
7301
- * Sleep utility
7302
- */
7303
- sleep(ms) {
7304
- return new Promise((resolve5) => setTimeout(resolve5, ms));
7305
- }
7306
7404
  /**
7307
7405
  * Get the configured model
7308
7406
  */
@@ -8690,7 +8788,7 @@ var PRECOMPILED_CONFIG = {
8690
8788
  "enableFreeTierPrioritization": true,
8691
8789
  "enableWorkloadAwareRouting": true
8692
8790
  },
8693
- "version": "12.6.0"
8791
+ "version": "12.6.1"
8694
8792
  };
8695
8793
 
8696
8794
  // src/core/config/schemas.ts
@@ -9565,107 +9663,7 @@ init_logger();
9565
9663
  // src/shared/utils/disposable.ts
9566
9664
  init_esm_shims();
9567
9665
  init_logger();
9568
-
9569
- // src/shared/utils/safe-timers.ts
9570
- init_esm_shims();
9571
- init_logger();
9572
- function createSafeInterval(callback, intervalMs, options = {}) {
9573
- const { ref = false, name, signal, immediate = false } = options;
9574
- if (signal?.aborted) {
9575
- logger.debug("createSafeInterval: already aborted", { name });
9576
- return () => {
9577
- };
9578
- }
9579
- let cleared = false;
9580
- let intervalId = null;
9581
- const safeCallback = async () => {
9582
- if (cleared) return;
9583
- try {
9584
- await callback();
9585
- } catch (error) {
9586
- logger.error("Safe interval callback error", {
9587
- name,
9588
- error: error.message
9589
- });
9590
- }
9591
- };
9592
- if (immediate) {
9593
- setImmediate(() => {
9594
- if (!cleared) {
9595
- safeCallback();
9596
- }
9597
- });
9598
- }
9599
- intervalId = setInterval(safeCallback, intervalMs);
9600
- if (!ref && intervalId.unref) {
9601
- intervalId.unref();
9602
- }
9603
- const cleanup = () => {
9604
- if (cleared) return;
9605
- cleared = true;
9606
- if (intervalId !== null) {
9607
- clearInterval(intervalId);
9608
- intervalId = null;
9609
- logger.debug("Safe interval cleared", { name });
9610
- }
9611
- };
9612
- if (signal) {
9613
- signal.addEventListener("abort", cleanup, { once: true });
9614
- }
9615
- logger.debug("Safe interval created", {
9616
- name,
9617
- intervalMs,
9618
- ref,
9619
- immediate
9620
- });
9621
- return cleanup;
9622
- }
9623
- function createSafeTimeout(callback, delayMs, options = {}) {
9624
- const { ref = false, name, signal } = options;
9625
- if (signal?.aborted) {
9626
- logger.debug("createSafeTimeout: already aborted", { name });
9627
- return () => {
9628
- };
9629
- }
9630
- let cleared = false;
9631
- let timeoutId = null;
9632
- const safeCallback = async () => {
9633
- if (cleared) return;
9634
- cleared = true;
9635
- try {
9636
- await callback();
9637
- } catch (error) {
9638
- logger.error("Safe timeout callback error", {
9639
- name,
9640
- error: error.message
9641
- });
9642
- }
9643
- };
9644
- timeoutId = setTimeout(safeCallback, delayMs);
9645
- if (!ref && timeoutId.unref) {
9646
- timeoutId.unref();
9647
- }
9648
- const cleanup = () => {
9649
- if (cleared) return;
9650
- cleared = true;
9651
- if (timeoutId !== null) {
9652
- clearTimeout(timeoutId);
9653
- timeoutId = null;
9654
- logger.debug("Safe timeout cleared", { name });
9655
- }
9656
- };
9657
- if (signal) {
9658
- signal.addEventListener("abort", cleanup, { once: true });
9659
- }
9660
- logger.debug("Safe timeout created", {
9661
- name,
9662
- delayMs,
9663
- ref
9664
- });
9665
- return cleanup;
9666
- }
9667
-
9668
- // src/shared/utils/disposable.ts
9666
+ init_safe_timers();
9669
9667
  var DisposableEventEmitter = class extends EventEmitter {
9670
9668
  /** Registered cleanup tasks */
9671
9669
  cleanupTasks = [];
@@ -16922,7 +16920,11 @@ var ProfileLoader = class {
16922
16920
  continue;
16923
16921
  }
16924
16922
  const data = load(content);
16925
- return data && typeof data === "object" && !Array.isArray(data) && "displayName" in data ? data.displayName || null : null;
16923
+ if (data && typeof data === "object" && !Array.isArray(data) && "displayName" in data) {
16924
+ const profile = data;
16925
+ return profile.displayName ?? null;
16926
+ }
16927
+ return null;
16926
16928
  } catch (error) {
16927
16929
  if (error.code === "ENOENT") {
16928
16930
  continue;
@@ -16951,7 +16953,7 @@ var ProfileLoader = class {
16951
16953
  });
16952
16954
  return identifier;
16953
16955
  } catch (error) {
16954
- if (error.name === "AgentNotFoundError") {
16956
+ if (error instanceof Error && error.name === "AgentNotFoundError") {
16955
16957
  logger.debug("Direct profile load failed, trying displayName lookup", { identifier });
16956
16958
  await this.buildDisplayNameMap();
16957
16959
  const resolved = this.displayNameMap.get(identifier.toLowerCase());
@@ -17280,7 +17282,7 @@ var ProfileLoader = class {
17280
17282
  if (typeof orch !== "object" || orch === null || Array.isArray(orch)) {
17281
17283
  throw new AgentValidationError("orchestration must be an object");
17282
17284
  }
17283
- if (orch.canDelegate !== void 0) {
17285
+ if ("canDelegate" in orch && orch.canDelegate !== void 0) {
17284
17286
  logger.warn("orchestration.canDelegate is deprecated and ignored (v4.9.0+). All agents can delegate by default.", {
17285
17287
  agent: profile.name
17286
17288
  });
@@ -17326,17 +17328,18 @@ var ProfileLoader = class {
17326
17328
  if (!data || typeof data !== "object" || Array.isArray(data)) {
17327
17329
  throw new AgentValidationError(`Invalid profile data for ${name}: expected object, got ${typeof data}`);
17328
17330
  }
17329
- if (data.name && typeof data.name === "string") {
17330
- if (!/^[a-zA-Z0-9_-]+$/.test(data.name)) {
17331
- if (!data.displayName) {
17332
- data.displayName = data.name;
17331
+ const profileData = data;
17332
+ if (profileData.name && typeof profileData.name === "string") {
17333
+ if (!/^[a-zA-Z0-9_-]+$/.test(profileData.name)) {
17334
+ if (!profileData.displayName) {
17335
+ profileData.displayName = profileData.name;
17333
17336
  }
17334
- data.name = name;
17337
+ profileData.name = name;
17335
17338
  }
17336
- } else if (!data.name) {
17337
- data.name = name;
17339
+ } else if (!profileData.name) {
17340
+ profileData.name = name;
17338
17341
  }
17339
- const validationResult = safeValidateAgentProfile(data);
17342
+ const validationResult = safeValidateAgentProfile(profileData);
17340
17343
  if (!validationResult.success) {
17341
17344
  const validationErrors = validationResult.error.issues.map(
17342
17345
  (e) => `${e.path.join(".")}: ${e.message}`
@@ -17346,22 +17349,22 @@ var ProfileLoader = class {
17346
17349
  );
17347
17350
  }
17348
17351
  let teamConfig;
17349
- if (data.team && this.teamManager) {
17352
+ if (profileData.team && this.teamManager) {
17350
17353
  try {
17351
- teamConfig = await this.teamManager.loadTeam(data.team);
17354
+ teamConfig = await this.teamManager.loadTeam(profileData.team);
17352
17355
  logger.debug("Team configuration loaded for agent", {
17353
17356
  agent: name,
17354
- team: data.team
17357
+ team: profileData.team
17355
17358
  });
17356
17359
  } catch (error) {
17357
17360
  logger.warn("Failed to load team configuration, using agent defaults", {
17358
17361
  agent: name,
17359
- team: data.team,
17362
+ team: profileData.team,
17360
17363
  error: error.message
17361
17364
  });
17362
17365
  }
17363
17366
  }
17364
- const abilities = data.abilities || [];
17367
+ const abilities = profileData.abilities || [];
17365
17368
  if (teamConfig?.sharedAbilities) {
17366
17369
  const allAbilities = [.../* @__PURE__ */ new Set([...teamConfig.sharedAbilities, ...abilities])];
17367
17370
  logger.debug("Merged abilities from team", {
@@ -17373,7 +17376,7 @@ var ProfileLoader = class {
17373
17376
  });
17374
17377
  abilities.splice(0, abilities.length, ...allAbilities);
17375
17378
  }
17376
- let orchestration = data.orchestration;
17379
+ let orchestration = profileData.orchestration;
17377
17380
  if (teamConfig?.orchestration && !orchestration) {
17378
17381
  orchestration = teamConfig.orchestration;
17379
17382
  logger.debug("Using team orchestration defaults", {
@@ -17382,32 +17385,32 @@ var ProfileLoader = class {
17382
17385
  });
17383
17386
  }
17384
17387
  const profile = {
17385
- name: data.name || name,
17386
- displayName: data.displayName,
17387
- role: data.role,
17388
- description: data.description,
17388
+ name: profileData.name || name,
17389
+ displayName: profileData.displayName,
17390
+ role: profileData.role,
17391
+ description: profileData.description,
17389
17392
  // v4.10.0+: Team field
17390
- team: data.team,
17391
- systemPrompt: data.systemPrompt,
17393
+ team: profileData.team,
17394
+ systemPrompt: profileData.systemPrompt,
17392
17395
  abilities,
17393
- dependencies: data.dependencies,
17394
- parallel: data.parallel,
17396
+ dependencies: profileData.dependencies,
17397
+ parallel: profileData.parallel,
17395
17398
  // Enhanced v4.1+ features
17396
- stages: data.stages,
17397
- personality: data.personality,
17398
- thinking_patterns: data.thinking_patterns,
17399
- abilitySelection: data.abilitySelection,
17399
+ stages: profileData.stages,
17400
+ personality: profileData.personality,
17401
+ thinking_patterns: profileData.thinking_patterns,
17402
+ abilitySelection: profileData.abilitySelection,
17400
17403
  // v5.7.0+: Agent Selection Metadata
17401
- selectionMetadata: data.selectionMetadata,
17404
+ selectionMetadata: profileData.selectionMetadata,
17402
17405
  // Provider preferences (deprecated, kept for backward compatibility)
17403
- provider: data.provider,
17404
- model: data.model,
17405
- temperature: data.temperature,
17406
- maxTokens: data.maxTokens,
17406
+ provider: profileData.provider,
17407
+ model: profileData.model,
17408
+ temperature: profileData.temperature,
17409
+ maxTokens: profileData.maxTokens,
17407
17410
  // Optional
17408
- tags: data.tags,
17409
- version: data.version,
17410
- metadata: data.metadata,
17411
+ tags: profileData.tags,
17412
+ version: profileData.version,
17413
+ metadata: profileData.metadata,
17411
17414
  // v4.7.0+ Orchestration (merged with team defaults)
17412
17415
  orchestration
17413
17416
  };
@@ -22983,7 +22986,7 @@ var BugDetector = class {
22983
22986
  });
22984
22987
  let files;
22985
22988
  if (fileFilter && fileFilter.length > 0) {
22986
- files = fileFilter.map((f) => f.startsWith("/") ? f : join(rootDir, f)).filter((f) => {
22989
+ files = fileFilter.map((f) => isAbsolute(f) ? f : join(rootDir, f)).filter((f) => {
22987
22990
  const ext = extname$1(f);
22988
22991
  return [".ts", ".js", ".mts", ".mjs", ".tsx", ".jsx"].includes(ext);
22989
22992
  }).filter((f) => !this.isExcluded(relative(rootDir, f)));
@@ -27531,6 +27534,9 @@ function countAnyTypes(code) {
27531
27534
  }
27532
27535
  return count;
27533
27536
  }
27537
+ function escapeRegex2(str) {
27538
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
27539
+ }
27534
27540
  function countUnusedImports(code) {
27535
27541
  const importMatches = code.match(/import\s+{([^}]+)}\s+from/g);
27536
27542
  if (!importMatches) return 0;
@@ -27540,10 +27546,17 @@ function countUnusedImports(code) {
27540
27546
  const namedImports = importMatch.match(/{([^}]+)}/);
27541
27547
  const namedImportContent = namedImports?.[1];
27542
27548
  if (namedImportContent) {
27543
- const names = namedImportContent.split(",").map((n) => n.trim().split(/\s+as\s+/).pop()?.trim() ?? "");
27549
+ const names = namedImportContent.split(",").map((n) => {
27550
+ const trimmed = n.trim();
27551
+ const withoutType = trimmed.replace(/^type\s+/, "");
27552
+ return withoutType.split(/\s+as\s+/).pop()?.trim() ?? "";
27553
+ }).filter((name) => name.length > 0 && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name));
27544
27554
  for (const name of names) {
27545
- if (name && !new RegExp(`\\b${name}\\b`).test(codeWithoutImports)) {
27546
- unusedCount++;
27555
+ try {
27556
+ if (!new RegExp(`\\b${escapeRegex2(name)}\\b`).test(codeWithoutImports)) {
27557
+ unusedCount++;
27558
+ }
27559
+ } catch {
27547
27560
  }
27548
27561
  }
27549
27562
  }
@@ -30999,6 +31012,7 @@ init_logger();
30999
31012
  // src/core/task-engine/task-queue.ts
31000
31013
  init_esm_shims();
31001
31014
  init_logger();
31015
+ init_safe_timers();
31002
31016
 
31003
31017
  // src/mcp/tools/task/create-task.ts
31004
31018
  init_logger();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defai.digital/automatosx",
3
- "version": "12.6.0",
3
+ "version": "12.6.2",
4
4
  "description": "Provider-agnostic AI orchestration platform with 20+ specialized agents, persistent memory, and multi-provider routing for Claude Code, Gemini CLI, Codex CLI, GLM, and Grok",
5
5
  "type": "module",
6
6
  "publishConfig": {