@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.
- package/hooks/agent-route-guard.mjs +14 -10
- package/hooks/cross-review-tracker.mjs +21 -8
- package/hooks/error-context.mjs +20 -8
- package/hooks/hook-adaptive-collector.mjs +18 -16
- package/hooks/hook-manager.mjs +93 -32
- package/hooks/hook-orchestrator.mjs +267 -35
- package/hooks/hook-registry.json +343 -256
- package/hooks/hooks.json +49 -1
- package/hooks/keyword-rules.json +191 -31
- package/hooks/lib/resolve-root.mjs +1 -1
- package/hooks/mcp-config-watcher.mjs +6 -2
- package/hooks/permission-safe-allow.mjs +233 -0
- package/hooks/pipeline-stop.mjs +369 -22
- package/hooks/post-tool-tips.mjs +306 -0
- package/hooks/pre-compact-snapshot.mjs +181 -0
- package/hooks/safety-guard.mjs +262 -34
- package/hooks/session-end-cleanup.mjs +345 -0
- package/hooks/session-start-fast.mjs +214 -0
- package/hooks/subagent-tracker.mjs +267 -0
- package/hooks/subagent-verifier.mjs +9 -4
- package/hub/account-broker.mjs +1036 -66
- package/hub/adaptive-diagnostic.mjs +75 -48
- package/hub/adaptive-inject.mjs +96 -58
- package/hub/adaptive-memory.mjs +156 -42
- package/hub/adaptive.mjs +60 -31
- package/hub/assign-callbacks.mjs +163 -126
- package/hub/bridge.mjs +1051 -290
- package/hub/cli-adapter-base.mjs +321 -97
- package/hub/codex-adapter.mjs +179 -93
- package/hub/codex-compat.mjs +4 -4
- package/hub/codex-preflight.mjs +113 -37
- package/hub/delegator/contracts.mjs +22 -21
- package/hub/delegator/index.mjs +14 -14
- package/hub/delegator/schema/delegator-tools.schema.json +1 -1
- package/hub/delegator/service.mjs +93 -64
- package/hub/delegator/tool-definitions.mjs +35 -35
- package/hub/dynamic-routing-engine.mjs +511 -0
- package/hub/fullcycle.mjs +34 -18
- package/hub/gemini-adapter.mjs +82 -108
- package/hub/hitl.mjs +202 -143
- package/hub/intent.mjs +167 -38
- package/hub/lib/bash-path.mjs +73 -0
- package/hub/lib/cache-guard.mjs +43 -17
- package/hub/lib/env-detect.mjs +145 -0
- package/hub/lib/hosts-compat.mjs +319 -0
- package/hub/lib/mcp-response-cache.mjs +239 -0
- package/hub/lib/memory-store.mjs +285 -111
- package/hub/lib/path-utils.mjs +165 -0
- package/hub/lib/phase-manager.mjs +493 -0
- package/hub/lib/process-utils.mjs +797 -104
- package/hub/lib/prompt-tmp.mjs +33 -0
- package/hub/lib/risk-tier.mjs +53 -0
- package/hub/lib/spawn-trace.mjs +561 -0
- package/hub/lib/ssh-command.mjs +44 -24
- package/hub/lib/ssh-retry.mjs +5 -1
- package/hub/lib/staged-file-detect.mjs +43 -0
- package/hub/lib/state-snapshot.mjs +293 -0
- package/hub/lib/tfx-route-args.mjs +309 -0
- package/hub/lib/timeline-adapter.mjs +190 -0
- package/hub/lib/trace-recorder.mjs +153 -0
- package/hub/lib/uuidv7.mjs +4 -3
- package/hub/memory-doctor.mjs +266 -106
- package/hub/middleware/quota-middleware.mjs +70 -0
- package/hub/middleware/request-logger.mjs +61 -34
- package/hub/paths.mjs +9 -9
- package/hub/pipeline/gates/confidence.mjs +34 -15
- package/hub/pipeline/gates/consensus.mjs +27 -15
- package/hub/pipeline/gates/index.mjs +7 -3
- package/hub/pipeline/gates/selfcheck.mjs +57 -19
- package/hub/pipeline/index.mjs +77 -42
- package/hub/pipeline/state.mjs +10 -10
- package/hub/pipeline/transitions.mjs +40 -23
- package/hub/platform.mjs +65 -48
- package/hub/quality/deslop.mjs +70 -49
- package/hub/reflexion.mjs +87 -13
- package/hub/research.mjs +33 -25
- package/hub/router.mjs +941 -791
- package/hub/routing/complexity.mjs +132 -29
- package/hub/routing/index.mjs +17 -12
- package/hub/routing/q-learning.mjs +78 -30
- package/hub/routing-snapshot.mjs +261 -0
- package/hub/session-fingerprint.mjs +127 -61
- package/hub/state.mjs +86 -44
- package/hub/team/claude-daemon-control.mjs +1130 -0
- package/hub/team/retry-state-machine.mjs +336 -0
- package/hub/token-mode.mjs +72 -71
- package/hub/workers/worker-utils.mjs +23 -17
- package/hud/colors.mjs +27 -9
- package/hud/constants.mjs +190 -27
- package/hud/context-monitor.mjs +133 -44
- package/hud/hud-qos-status.mjs +157 -50
- package/hud/mission-board.mjs +56 -0
- package/hud/providers/claude.mjs +398 -114
- package/hud/providers/codex.mjs +96 -21
- package/hud/providers/gemini.mjs +210 -52
- package/hud/renderers.mjs +440 -127
- package/hud/terminal.mjs +101 -31
- package/hud/utils.mjs +81 -39
- package/mesh/index.mjs +69 -0
- package/mesh/mesh-budget.mjs +137 -0
- package/mesh/mesh-heartbeat.mjs +100 -0
- package/mesh/mesh-protocol.mjs +96 -0
- package/mesh/mesh-queue.mjs +163 -0
- package/mesh/mesh-registry.mjs +78 -0
- package/mesh/mesh-router.mjs +77 -0
- package/package.json +5 -1
- package/scripts/lib/agent-json.mjs +27 -0
- package/scripts/lib/async.mjs +174 -0
- package/scripts/lib/claudemd-scanner.mjs +6 -1
- package/scripts/lib/cli-agy.mjs +62 -0
- package/scripts/lib/cli-claude.mjs +78 -0
- package/scripts/lib/cli-codex.mjs +199 -0
- package/scripts/lib/cli-gemini.mjs +37 -0
- package/scripts/lib/codex-recovery.sh +50 -0
- package/scripts/lib/context.mjs +3 -3
- package/scripts/lib/cross-review-utils.mjs +13 -5
- package/scripts/lib/doctor-env-checks.mjs +121 -0
- package/scripts/lib/dynamic-route-cli.mjs +107 -0
- package/scripts/lib/env-probe.mjs +58 -30
- package/scripts/lib/env.mjs +14 -0
- package/scripts/lib/gemini-profiles.mjs +44 -10
- package/scripts/lib/handoff.mjs +33 -17
- package/scripts/lib/hook-utils.mjs +8 -6
- package/scripts/lib/hub.mjs +48 -0
- package/scripts/lib/keyword-rules.mjs +49 -20
- package/scripts/lib/logger.mjs +24 -24
- package/scripts/lib/mcp-filter.mjs +391 -247
- package/scripts/lib/mcp-gateway-health-check.mjs +159 -0
- package/scripts/lib/mcp-gateway-servers.mjs +70 -0
- package/scripts/lib/mcp-gateway-wrapper-check.mjs +35 -0
- package/scripts/lib/mcp-guard-engine.mjs +1281 -115
- package/scripts/lib/mcp-health.mjs +773 -0
- package/scripts/lib/mcp-manifest.mjs +24 -14
- package/scripts/lib/mcp-server-catalog.mjs +355 -118
- package/scripts/lib/pid.mjs +63 -0
- package/scripts/lib/process-utils.mjs +26 -0
- package/scripts/lib/psmux-info.mjs +117 -12
- package/scripts/lib/quota.mjs +47 -0
- package/scripts/lib/remote-spawn-transfer.mjs +44 -14
- package/scripts/lib/skill-state.mjs +220 -0
- package/scripts/lib/skill-template.mjs +32 -7
- package/scripts/lib/team.mjs +75 -0
- package/scripts/lib/timeout.mjs +66 -0
- package/scripts/lib/tmp.mjs +26 -0
- package/scripts/lib/toml.mjs +113 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// scripts/lib/mcp-gateway-health-check.mjs
|
|
2
|
+
//
|
|
3
|
+
// `~/.local/state/triflux/mcp-gateway.out.log` 파싱 헬퍼.
|
|
4
|
+
// install-mcp-gateway-startup.mjs 가 LaunchAgent/systemd 로 띄운 gateway daemon
|
|
5
|
+
// (mcp-gateway-start.mjs) 의 stdout 로그에서 다음 신호를 추출한다.
|
|
6
|
+
//
|
|
7
|
+
// [WARN] <server> skipped — missing env: <KEY> → missing-env finding
|
|
8
|
+
// [START] <server> on :<port> → started
|
|
9
|
+
// [SKIP] <server> already running on :<port> → started (preExisting)
|
|
10
|
+
// [SKIP] <server> — manifest에서 비활성 → manifest-disabled skip
|
|
11
|
+
//
|
|
12
|
+
// 호출자는 `findings` 만 보고 doctor 진단을 출력할 수 있다.
|
|
13
|
+
// log 파일이 없으면 `available: false` 로 반환하므로, gateway 미설치 환경에서는
|
|
14
|
+
// 침묵한다 (false-positive 방지).
|
|
15
|
+
|
|
16
|
+
import { readFileSync, statSync } from "node:fs";
|
|
17
|
+
import { homedir } from "node:os";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
|
|
20
|
+
const DEFAULT_LOG_PATH = join(
|
|
21
|
+
homedir(),
|
|
22
|
+
".local",
|
|
23
|
+
"state",
|
|
24
|
+
"triflux",
|
|
25
|
+
"mcp-gateway.out.log",
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// producer (scripts/mcp-gateway-start.mjs:146) 가 missing env 를 `missing.join(", ")`
|
|
29
|
+
// 로 출력하므로 detail 은 공백 포함 다중 키 (예: "JIRA_API_TOKEN, JIRA_EMAIL, JIRA_INSTANCE_URL")
|
|
30
|
+
// 일 수 있다. line 끝까지 캡처한다.
|
|
31
|
+
const MISSING_ENV_RE = /^\[WARN\]\s+(\S+)\s+skipped\s+—\s+missing env:\s+(.+)$/;
|
|
32
|
+
const START_RE = /^\[START\]\s+(\S+)\s+on\s+:(\d+)$/;
|
|
33
|
+
const SKIP_RUNNING_RE = /^\[SKIP\]\s+(\S+)\s+already running on\s+:(\d+)$/;
|
|
34
|
+
const SKIP_DISABLED_RE = /^\[SKIP\]\s+(\S+)\s+—\s+manifest에서 비활성$/;
|
|
35
|
+
|
|
36
|
+
export function checkMcpGatewayHealth({
|
|
37
|
+
fs = { readFileSync, statSync },
|
|
38
|
+
logPath = DEFAULT_LOG_PATH,
|
|
39
|
+
} = {}) {
|
|
40
|
+
try {
|
|
41
|
+
fs.statSync(logPath);
|
|
42
|
+
} catch {
|
|
43
|
+
return {
|
|
44
|
+
available: false,
|
|
45
|
+
logPath,
|
|
46
|
+
findings: [],
|
|
47
|
+
started: [],
|
|
48
|
+
skipped: [],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let text;
|
|
53
|
+
try {
|
|
54
|
+
text = fs.readFileSync(logPath, "utf8");
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return {
|
|
57
|
+
available: true,
|
|
58
|
+
logPath,
|
|
59
|
+
findings: [
|
|
60
|
+
{
|
|
61
|
+
server: null,
|
|
62
|
+
reason: "log-read-error",
|
|
63
|
+
detail: error?.message || String(error),
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
started: [],
|
|
67
|
+
skipped: [],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// log 는 append-only 라 옛 [WARN] 라인 뒤에 새 [START] 라인이 올 수 있다.
|
|
72
|
+
// server 별 마지막 이벤트가 현재 상태이므로 그것만 finding 으로 환원한다.
|
|
73
|
+
// (예: BRAVE_API_KEY missing 으로 한 번 skip → secrets 추가 후 restart 로 start)
|
|
74
|
+
const lastEvent = new Map();
|
|
75
|
+
|
|
76
|
+
for (const rawLine of text.split("\n")) {
|
|
77
|
+
const line = rawLine.trim();
|
|
78
|
+
if (!line) continue;
|
|
79
|
+
|
|
80
|
+
let m;
|
|
81
|
+
if ((m = MISSING_ENV_RE.exec(line))) {
|
|
82
|
+
lastEvent.set(m[1], {
|
|
83
|
+
type: "missing-env",
|
|
84
|
+
detail: m[2],
|
|
85
|
+
});
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if ((m = START_RE.exec(line))) {
|
|
89
|
+
lastEvent.set(m[1], {
|
|
90
|
+
type: "started",
|
|
91
|
+
port: Number(m[2]),
|
|
92
|
+
preExisting: false,
|
|
93
|
+
});
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if ((m = SKIP_RUNNING_RE.exec(line))) {
|
|
97
|
+
lastEvent.set(m[1], {
|
|
98
|
+
type: "started",
|
|
99
|
+
port: Number(m[2]),
|
|
100
|
+
preExisting: true,
|
|
101
|
+
});
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if ((m = SKIP_DISABLED_RE.exec(line))) {
|
|
105
|
+
lastEvent.set(m[1], {
|
|
106
|
+
type: "manifest-disabled",
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const findings = [];
|
|
112
|
+
const started = [];
|
|
113
|
+
const skipped = [];
|
|
114
|
+
for (const [server, ev] of lastEvent) {
|
|
115
|
+
if (ev.type === "missing-env") {
|
|
116
|
+
findings.push({ server, reason: "missing-env", detail: ev.detail });
|
|
117
|
+
} else if (ev.type === "started") {
|
|
118
|
+
started.push({ server, port: ev.port, preExisting: ev.preExisting });
|
|
119
|
+
} else if (ev.type === "manifest-disabled") {
|
|
120
|
+
skipped.push({ server, reason: "manifest-disabled" });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
available: true,
|
|
126
|
+
logPath,
|
|
127
|
+
findings,
|
|
128
|
+
started,
|
|
129
|
+
skipped,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function summarizeMcpGatewayHealth(result) {
|
|
134
|
+
if (!result?.available) {
|
|
135
|
+
return {
|
|
136
|
+
level: "skip",
|
|
137
|
+
message: "mcp-gateway log 없음 (gateway 미설치 또는 미실행)",
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (result.findings.length === 0) {
|
|
141
|
+
return {
|
|
142
|
+
level: "ok",
|
|
143
|
+
message: `mcp-gateway healthy (${result.started.length}개 server up)`,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const missingEnv = result.findings.filter((f) => f.reason === "missing-env");
|
|
147
|
+
if (missingEnv.length > 0) {
|
|
148
|
+
const list = missingEnv.map((f) => `${f.server} (${f.detail})`).join(", ");
|
|
149
|
+
return {
|
|
150
|
+
level: "warn",
|
|
151
|
+
message: `${missingEnv.length}개 MCP 서버가 missing env 로 skip: ${list}`,
|
|
152
|
+
fix: "secrets 를 ~/.config/triflux/secrets.env 에 추가하고 `launchctl kickstart -k gui/$(id -u)/com.tellang.mcp-gateway` (macOS) 또는 `systemctl --user restart mcp-gateway` (linux)",
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
level: "warn",
|
|
157
|
+
message: `${result.findings.length}개 gateway 이슈`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const SERVER_DEFINITIONS = Object.freeze([
|
|
2
|
+
{
|
|
3
|
+
name: "context7",
|
|
4
|
+
port: 8100,
|
|
5
|
+
stdioCmd: "npx -y @upstash/context7-mcp@latest",
|
|
6
|
+
envVars: [],
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: "brave-search",
|
|
10
|
+
port: 8101,
|
|
11
|
+
stdioCmd: "npx -y @brave/brave-search-mcp-server",
|
|
12
|
+
envVars: ["BRAVE_API_KEY"],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "exa",
|
|
16
|
+
port: 8102,
|
|
17
|
+
stdioCmd: "npx -y exa-mcp-server",
|
|
18
|
+
envVars: ["EXA_API_KEY"],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "tavily",
|
|
22
|
+
port: 8103,
|
|
23
|
+
stdioCmd: "npx -y tavily-mcp@latest",
|
|
24
|
+
envVars: ["TAVILY_API_KEY"],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "jira",
|
|
28
|
+
port: 8104,
|
|
29
|
+
stdioCmd: "npx -y mcp-jira-cloud@latest",
|
|
30
|
+
envVars: ["JIRA_API_TOKEN", "JIRA_EMAIL", "JIRA_INSTANCE_URL"],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "serena",
|
|
34
|
+
port: 8105,
|
|
35
|
+
stdioCmd:
|
|
36
|
+
"uvx --from git+https://github.com/oraios/serena serena start-mcp-server",
|
|
37
|
+
envVars: [],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "notion",
|
|
41
|
+
port: 8106,
|
|
42
|
+
stdioCmd: "npx -y @notionhq/notion-mcp-server",
|
|
43
|
+
envVars: ["NOTION_TOKEN"],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "notion-guest",
|
|
47
|
+
port: 8107,
|
|
48
|
+
stdioCmd: "npx -y @notionhq/notion-mcp-server",
|
|
49
|
+
envVars: ["NOTION_TOKEN"],
|
|
50
|
+
},
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
export const SERVERS = SERVER_DEFINITIONS.map((server) => ({
|
|
54
|
+
name: server.name,
|
|
55
|
+
port: server.port,
|
|
56
|
+
cmd: server.stdioCmd,
|
|
57
|
+
envVars: [...server.envVars],
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
export const GATEWAY_SERVERS = SERVER_DEFINITIONS.map((server) => ({
|
|
61
|
+
name: server.name,
|
|
62
|
+
port: server.port,
|
|
63
|
+
stdioCmd: server.stdioCmd,
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
export function serversWithSatisfiedEnv(env = process.env) {
|
|
67
|
+
return SERVERS.filter((server) =>
|
|
68
|
+
server.envVars.every((envName) => Boolean(env[envName])),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
export async function checkWrapperSourcing({
|
|
6
|
+
wrapperPath = path.join(
|
|
7
|
+
os.homedir(),
|
|
8
|
+
".local",
|
|
9
|
+
"bin",
|
|
10
|
+
"mcp-gateway-wrapper.sh",
|
|
11
|
+
),
|
|
12
|
+
marker = "secrets.env",
|
|
13
|
+
} = {}) {
|
|
14
|
+
let text;
|
|
15
|
+
try {
|
|
16
|
+
text = await readFile(wrapperPath, "utf8");
|
|
17
|
+
} catch (error) {
|
|
18
|
+
const result = { status: "missing", wrapperPath };
|
|
19
|
+
if (error?.code !== "ENOENT") {
|
|
20
|
+
result.message = `wrapper read failed: ${error?.message || String(error)}`;
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (text.includes(marker)) {
|
|
26
|
+
return { status: "ok", wrapperPath };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
status: "warn",
|
|
31
|
+
wrapperPath,
|
|
32
|
+
message: "wrapper exists but does not source secrets.env",
|
|
33
|
+
suggestedFix: "Re-run: node scripts/install-mcp-gateway-startup.mjs",
|
|
34
|
+
};
|
|
35
|
+
}
|