@triflux/core 10.1.0 → 10.26.0

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 (145) hide show
  1. package/hooks/agent-route-guard.mjs +14 -10
  2. package/hooks/cross-review-tracker.mjs +21 -8
  3. package/hooks/error-context.mjs +20 -8
  4. package/hooks/hook-adaptive-collector.mjs +18 -16
  5. package/hooks/hook-manager.mjs +93 -32
  6. package/hooks/hook-orchestrator.mjs +267 -35
  7. package/hooks/hook-registry.json +343 -256
  8. package/hooks/hooks.json +49 -1
  9. package/hooks/keyword-rules.json +191 -31
  10. package/hooks/lib/resolve-root.mjs +1 -1
  11. package/hooks/mcp-config-watcher.mjs +6 -2
  12. package/hooks/permission-safe-allow.mjs +233 -0
  13. package/hooks/pipeline-stop.mjs +369 -22
  14. package/hooks/post-tool-tips.mjs +306 -0
  15. package/hooks/pre-compact-snapshot.mjs +181 -0
  16. package/hooks/safety-guard.mjs +262 -34
  17. package/hooks/session-end-cleanup.mjs +345 -0
  18. package/hooks/session-start-fast.mjs +214 -0
  19. package/hooks/subagent-tracker.mjs +267 -0
  20. package/hooks/subagent-verifier.mjs +9 -4
  21. package/hub/account-broker.mjs +1036 -66
  22. package/hub/adaptive-diagnostic.mjs +75 -48
  23. package/hub/adaptive-inject.mjs +96 -58
  24. package/hub/adaptive-memory.mjs +156 -42
  25. package/hub/adaptive.mjs +60 -31
  26. package/hub/assign-callbacks.mjs +163 -126
  27. package/hub/bridge.mjs +1051 -290
  28. package/hub/cli-adapter-base.mjs +321 -97
  29. package/hub/codex-adapter.mjs +179 -93
  30. package/hub/codex-compat.mjs +4 -4
  31. package/hub/codex-preflight.mjs +113 -37
  32. package/hub/delegator/contracts.mjs +22 -21
  33. package/hub/delegator/index.mjs +14 -14
  34. package/hub/delegator/schema/delegator-tools.schema.json +1 -1
  35. package/hub/delegator/service.mjs +93 -64
  36. package/hub/delegator/tool-definitions.mjs +35 -35
  37. package/hub/dynamic-routing-engine.mjs +511 -0
  38. package/hub/fullcycle.mjs +34 -18
  39. package/hub/gemini-adapter.mjs +82 -108
  40. package/hub/hitl.mjs +202 -143
  41. package/hub/intent.mjs +167 -38
  42. package/hub/lib/bash-path.mjs +73 -0
  43. package/hub/lib/cache-guard.mjs +43 -17
  44. package/hub/lib/env-detect.mjs +145 -0
  45. package/hub/lib/hosts-compat.mjs +319 -0
  46. package/hub/lib/mcp-response-cache.mjs +239 -0
  47. package/hub/lib/memory-store.mjs +285 -111
  48. package/hub/lib/path-utils.mjs +165 -0
  49. package/hub/lib/phase-manager.mjs +493 -0
  50. package/hub/lib/process-utils.mjs +797 -104
  51. package/hub/lib/prompt-tmp.mjs +33 -0
  52. package/hub/lib/risk-tier.mjs +53 -0
  53. package/hub/lib/spawn-trace.mjs +561 -0
  54. package/hub/lib/ssh-command.mjs +44 -24
  55. package/hub/lib/ssh-retry.mjs +5 -1
  56. package/hub/lib/staged-file-detect.mjs +43 -0
  57. package/hub/lib/state-snapshot.mjs +293 -0
  58. package/hub/lib/tfx-route-args.mjs +309 -0
  59. package/hub/lib/timeline-adapter.mjs +190 -0
  60. package/hub/lib/trace-recorder.mjs +153 -0
  61. package/hub/lib/uuidv7.mjs +4 -3
  62. package/hub/memory-doctor.mjs +266 -106
  63. package/hub/middleware/quota-middleware.mjs +70 -0
  64. package/hub/middleware/request-logger.mjs +61 -34
  65. package/hub/paths.mjs +9 -9
  66. package/hub/pipeline/gates/confidence.mjs +34 -15
  67. package/hub/pipeline/gates/consensus.mjs +27 -15
  68. package/hub/pipeline/gates/index.mjs +7 -3
  69. package/hub/pipeline/gates/selfcheck.mjs +57 -19
  70. package/hub/pipeline/index.mjs +77 -42
  71. package/hub/pipeline/state.mjs +10 -10
  72. package/hub/pipeline/transitions.mjs +40 -23
  73. package/hub/platform.mjs +65 -48
  74. package/hub/quality/deslop.mjs +70 -49
  75. package/hub/reflexion.mjs +87 -13
  76. package/hub/research.mjs +33 -25
  77. package/hub/router.mjs +941 -791
  78. package/hub/routing/complexity.mjs +132 -29
  79. package/hub/routing/index.mjs +17 -12
  80. package/hub/routing/q-learning.mjs +78 -30
  81. package/hub/routing-snapshot.mjs +261 -0
  82. package/hub/session-fingerprint.mjs +127 -61
  83. package/hub/state.mjs +86 -44
  84. package/hub/team/claude-daemon-control.mjs +1130 -0
  85. package/hub/team/retry-state-machine.mjs +336 -0
  86. package/hub/token-mode.mjs +72 -71
  87. package/hub/workers/worker-utils.mjs +23 -17
  88. package/hud/colors.mjs +27 -9
  89. package/hud/constants.mjs +190 -27
  90. package/hud/context-monitor.mjs +133 -44
  91. package/hud/hud-qos-status.mjs +157 -50
  92. package/hud/mission-board.mjs +56 -0
  93. package/hud/providers/claude.mjs +398 -114
  94. package/hud/providers/codex.mjs +96 -21
  95. package/hud/providers/gemini.mjs +210 -52
  96. package/hud/renderers.mjs +440 -127
  97. package/hud/terminal.mjs +101 -31
  98. package/hud/utils.mjs +81 -39
  99. package/mesh/index.mjs +69 -0
  100. package/mesh/mesh-budget.mjs +137 -0
  101. package/mesh/mesh-heartbeat.mjs +100 -0
  102. package/mesh/mesh-protocol.mjs +96 -0
  103. package/mesh/mesh-queue.mjs +163 -0
  104. package/mesh/mesh-registry.mjs +78 -0
  105. package/mesh/mesh-router.mjs +77 -0
  106. package/package.json +5 -1
  107. package/scripts/lib/agent-json.mjs +27 -0
  108. package/scripts/lib/async.mjs +174 -0
  109. package/scripts/lib/claudemd-scanner.mjs +6 -1
  110. package/scripts/lib/cli-agy.mjs +62 -0
  111. package/scripts/lib/cli-claude.mjs +78 -0
  112. package/scripts/lib/cli-codex.mjs +199 -0
  113. package/scripts/lib/cli-gemini.mjs +37 -0
  114. package/scripts/lib/codex-recovery.sh +50 -0
  115. package/scripts/lib/context.mjs +3 -3
  116. package/scripts/lib/cross-review-utils.mjs +13 -5
  117. package/scripts/lib/doctor-env-checks.mjs +121 -0
  118. package/scripts/lib/dynamic-route-cli.mjs +107 -0
  119. package/scripts/lib/env-probe.mjs +58 -30
  120. package/scripts/lib/env.mjs +14 -0
  121. package/scripts/lib/gemini-profiles.mjs +44 -10
  122. package/scripts/lib/handoff.mjs +33 -17
  123. package/scripts/lib/hook-utils.mjs +8 -6
  124. package/scripts/lib/hub.mjs +48 -0
  125. package/scripts/lib/keyword-rules.mjs +49 -20
  126. package/scripts/lib/logger.mjs +24 -24
  127. package/scripts/lib/mcp-filter.mjs +391 -247
  128. package/scripts/lib/mcp-gateway-health-check.mjs +159 -0
  129. package/scripts/lib/mcp-gateway-servers.mjs +70 -0
  130. package/scripts/lib/mcp-gateway-wrapper-check.mjs +35 -0
  131. package/scripts/lib/mcp-guard-engine.mjs +1281 -115
  132. package/scripts/lib/mcp-health.mjs +773 -0
  133. package/scripts/lib/mcp-manifest.mjs +24 -14
  134. package/scripts/lib/mcp-server-catalog.mjs +355 -118
  135. package/scripts/lib/pid.mjs +63 -0
  136. package/scripts/lib/process-utils.mjs +26 -0
  137. package/scripts/lib/psmux-info.mjs +117 -12
  138. package/scripts/lib/quota.mjs +47 -0
  139. package/scripts/lib/remote-spawn-transfer.mjs +44 -14
  140. package/scripts/lib/skill-state.mjs +220 -0
  141. package/scripts/lib/skill-template.mjs +32 -7
  142. package/scripts/lib/team.mjs +75 -0
  143. package/scripts/lib/timeout.mjs +66 -0
  144. package/scripts/lib/tmp.mjs +26 -0
  145. package/scripts/lib/toml.mjs +113 -0
@@ -1,6 +1,6 @@
1
1
  import { readFileSync } from "node:fs";
2
2
 
3
- const VALID_MCP_ROUTES = new Set(["codex", "gemini", "claude"]);
3
+ const VALID_MCP_ROUTES = new Set(["codex", "antigravity", "gemini", "claude"]);
4
4
 
5
5
  function logRuleError(message, error) {
6
6
  if (error) {
@@ -28,21 +28,34 @@ function normalizeRule(rule) {
28
28
  if (!rule || typeof rule !== "object") return null;
29
29
  if (typeof rule.id !== "string" || !rule.id.trim()) return null;
30
30
  if (!Array.isArray(rule.patterns) || rule.patterns.length === 0) return null;
31
- if (typeof rule.priority !== "number" || !Number.isFinite(rule.priority)) return null;
31
+ if (typeof rule.priority !== "number" || !Number.isFinite(rule.priority))
32
+ return null;
32
33
 
33
34
  const patterns = rule.patterns.map(normalizePattern).filter(Boolean);
34
35
  if (patterns.length === 0) return null;
35
36
 
36
- const skill = typeof rule.skill === "string" && rule.skill.trim() ? rule.skill.trim() : null;
37
- const action = typeof rule.action === "string" && rule.action.trim() ? rule.action.trim() : null;
38
- const mcpRoute = typeof rule.mcp_route === "string" && VALID_MCP_ROUTES.has(rule.mcp_route)
39
- ? rule.mcp_route
40
- : null;
37
+ const skill =
38
+ typeof rule.skill === "string" && rule.skill.trim()
39
+ ? rule.skill.trim()
40
+ : null;
41
+ const action =
42
+ typeof rule.action === "string" && rule.action.trim()
43
+ ? rule.action.trim()
44
+ : null;
45
+ const mcpRoute =
46
+ typeof rule.mcp_route === "string" && VALID_MCP_ROUTES.has(rule.mcp_route)
47
+ ? rule.mcp_route
48
+ : null;
41
49
 
42
50
  if (!skill && !mcpRoute && !action) return null;
43
51
 
52
+ const hint =
53
+ typeof rule.hint === "string" && rule.hint.trim() ? rule.hint.trim() : null;
54
+
44
55
  const supersedes = Array.isArray(rule.supersedes)
45
- ? rule.supersedes.filter((id) => typeof id === "string" && id.trim()).map((id) => id.trim())
56
+ ? rule.supersedes
57
+ .filter((id) => typeof id === "string" && id.trim())
58
+ .map((id) => id.trim())
46
59
  : [];
47
60
 
48
61
  const state = normalizeState(rule.state);
@@ -53,11 +66,12 @@ function normalizeRule(rule) {
53
66
  patterns,
54
67
  skill,
55
68
  action,
69
+ hint,
56
70
  priority: rule.priority,
57
71
  supersedes,
58
72
  exclusive: rule.exclusive === true,
59
73
  state,
60
- mcp_route: mcpRoute
74
+ mcp_route: mcpRoute,
61
75
  };
62
76
  }
63
77
 
@@ -81,26 +95,40 @@ export function loadRules(rulesPath) {
81
95
 
82
96
  // pattern.source / flags를 RegExp로 컴파일
83
97
  export function compileRules(rules) {
84
- return rules.map((rule) => {
85
- try {
86
- return { ...rule, compiledPatterns: rule.patterns.map((p) => new RegExp(p.source, p.flags)) };
87
- } catch (error) {
88
- logRuleError(`정규식 컴파일 실패: ${rule.id}`, error);
89
- return null;
90
- }
91
- }).filter(Boolean);
98
+ return rules
99
+ .map((rule) => {
100
+ try {
101
+ return {
102
+ ...rule,
103
+ compiledPatterns: rule.patterns.map(
104
+ (p) => new RegExp(p.source, p.flags),
105
+ ),
106
+ };
107
+ } catch (error) {
108
+ logRuleError(`정규식 컴파일 실패: ${rule.id}`, error);
109
+ return null;
110
+ }
111
+ })
112
+ .filter(Boolean);
92
113
  }
93
114
 
94
115
  // 입력 텍스트에서 매칭된 규칙 목록 반환
95
116
  export function matchRules(compiledRules, cleanText) {
96
- if (!Array.isArray(compiledRules) || typeof cleanText !== "string" || !cleanText) {
117
+ if (
118
+ !Array.isArray(compiledRules) ||
119
+ typeof cleanText !== "string" ||
120
+ !cleanText
121
+ ) {
97
122
  return [];
98
123
  }
99
124
 
100
125
  const matches = [];
101
126
 
102
127
  for (const rule of compiledRules) {
103
- if (!Array.isArray(rule.compiledPatterns) || rule.compiledPatterns.length === 0) {
128
+ if (
129
+ !Array.isArray(rule.compiledPatterns) ||
130
+ rule.compiledPatterns.length === 0
131
+ ) {
104
132
  continue;
105
133
  }
106
134
 
@@ -115,11 +143,12 @@ export function matchRules(compiledRules, cleanText) {
115
143
  id: rule.id,
116
144
  skill: rule.skill,
117
145
  action: rule.action,
146
+ hint: rule.hint || null,
118
147
  priority: rule.priority,
119
148
  supersedes: rule.supersedes || [],
120
149
  exclusive: rule.exclusive === true,
121
150
  state: rule.state || null,
122
- mcp_route: rule.mcp_route || null
151
+ mcp_route: rule.mcp_route || null,
123
152
  });
124
153
  }
125
154
 
@@ -27,17 +27,17 @@
27
27
  * error — 작업 실패 (CLI 실행 실패, MCP 연결 끊김)
28
28
  * fatal — 프로세스 위협 (DB 연결 불가, 포트 충돌)
29
29
  */
30
- import pino from 'pino';
30
+ import pino from "pino";
31
31
 
32
- const isDev = process.env.NODE_ENV !== 'production';
32
+ const isDev = process.env.NODE_ENV !== "production";
33
33
 
34
34
  export const logger = pino({
35
- level: process.env.LOG_LEVEL || (isDev ? 'debug' : 'info'),
35
+ level: process.env.LOG_LEVEL || (isDev ? "debug" : "info"),
36
36
 
37
37
  // 모든 로그에 포함되는 기본 필드
38
38
  base: {
39
- service: process.env.SERVICE_NAME || 'triflux',
40
- env: process.env.NODE_ENV || 'development',
39
+ service: process.env.SERVICE_NAME || "triflux",
40
+ env: process.env.NODE_ENV || "development",
41
41
  },
42
42
 
43
43
  // 레벨을 대문자로 출력 (AI 파싱 용이)
@@ -51,18 +51,18 @@ export const logger = pino({
51
51
  // 민감정보 자동 필터링
52
52
  redact: {
53
53
  paths: [
54
- 'password',
55
- 'token',
56
- 'apiKey',
57
- 'secret',
58
- 'authorization',
59
- '*.password',
60
- '*.token',
61
- '*.apiKey',
62
- '*.secret',
63
- 'req.headers.authorization',
64
- 'req.headers.cookie',
65
- 'hubToken',
54
+ "password",
55
+ "token",
56
+ "apiKey",
57
+ "secret",
58
+ "authorization",
59
+ "*.password",
60
+ "*.token",
61
+ "*.apiKey",
62
+ "*.secret",
63
+ "req.headers.authorization",
64
+ "req.headers.cookie",
65
+ "hubToken",
66
66
  ],
67
67
  remove: true,
68
68
  },
@@ -70,11 +70,11 @@ export const logger = pino({
70
70
  // 개발 환경: 컬러 콘솔 출력
71
71
  transport: isDev
72
72
  ? {
73
- target: 'pino-pretty',
73
+ target: "pino-pretty",
74
74
  options: {
75
75
  colorize: true,
76
- translateTime: 'yyyy-mm-dd HH:MM:ss',
77
- ignore: 'pid,hostname',
76
+ translateTime: "yyyy-mm-dd HH:MM:ss",
77
+ ignore: "pid,hostname",
78
78
  },
79
79
  }
80
80
  : undefined,
@@ -92,14 +92,14 @@ export function createModuleLogger(module) {
92
92
  }
93
93
 
94
94
  // 정상 종료 시 버퍼 flush 보장
95
- process.on('uncaughtException', (err) => {
96
- logger.fatal({ err }, 'process.uncaught_exception');
95
+ process.on("uncaughtException", (err) => {
96
+ logger.fatal({ err }, "process.uncaught_exception");
97
97
  logger.flush();
98
98
  process.exit(1);
99
99
  });
100
100
 
101
- process.on('unhandledRejection', (reason) => {
102
- logger.fatal({ reason: String(reason) }, 'process.unhandled_rejection');
101
+ process.on("unhandledRejection", (reason) => {
102
+ logger.fatal({ reason: String(reason) }, "process.unhandled_rejection");
103
103
  logger.flush();
104
104
  process.exit(1);
105
105
  });