@triflux/core 10.51.0 → 10.52.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/hub/bridge.mjs +65 -1172
- package/hub/index.mjs +2 -18
- package/hub/lib/process-utils.mjs +1 -33
- package/hub/team/claude-daemon-control.mjs +1 -2
- package/hub/team/claude-session-projection.mjs +5 -73
- package/hub/team/nativeProxy.mjs +759 -0
- package/hub/team/session-context.mjs +1 -1
- package/hud/constants.mjs +2 -0
- package/hud/hud-qos-status.mjs +21 -5
- package/hud/providers/gemini.mjs +20 -0
- package/hud/renderers.mjs +79 -46
- package/hud/utils.mjs +9 -5
- package/package.json +2 -4
- package/scripts/lib/agent-route-policy.mjs +0 -67
- package/scripts/lib/cli-claude.mjs +0 -12
- package/scripts/lib/env-probe.mjs +0 -70
- package/scripts/lib/legacy-mcp-cleanup.mjs +283 -0
- package/scripts/lib/mcp-guard-engine.mjs +40 -98
- package/scripts/lib/session-presence.mjs +1 -99
- package/hub/adaptive-diagnostic.mjs +0 -350
- package/hub/adaptive-inject.mjs +0 -224
- package/hub/adaptive-memory.mjs +0 -277
- package/hub/adaptive.mjs +0 -172
- package/hub/assign-callbacks.mjs +0 -170
- package/hub/delegator/contracts.mjs +0 -38
- package/hub/delegator/index.mjs +0 -14
- package/hub/delegator/schema/delegator-tools.schema.json +0 -250
- package/hub/delegator/service.mjs +0 -336
- package/hub/delegator/tool-definitions.mjs +0 -35
- package/hub/hitl.mjs +0 -202
- package/hub/lib/known-errors.json +0 -72
- package/hub/lib/memory-store.mjs +0 -1001
- package/hub/lib/phase-manager.mjs +0 -493
- package/hub/lib/state-snapshot.mjs +0 -293
- package/hub/lib/trace-recorder.mjs +0 -153
- package/hub/lib/uuidv7.mjs +0 -45
- package/hub/memory-doctor.mjs +0 -640
- package/hub/middleware/quota-middleware.mjs +0 -70
- package/hub/middleware/request-logger.mjs +0 -191
- package/hub/paths.mjs +0 -24
- package/hub/pipeline/index.mjs +0 -163
- package/hub/pipeline/state.mjs +0 -191
- package/hub/pipeline/transitions.mjs +0 -131
- package/hub/reflexion.mjs +0 -290
- package/hub/role-contract.mjs +0 -312
- package/hub/router.mjs +0 -2026
- package/hub/session-fingerprint.mjs +0 -418
- package/hub/state.mjs +0 -300
- package/hub/team/synapse-http.mjs +0 -311
- package/hub/team-bridge.mjs +0 -27
- package/scripts/lib/claudemd-scanner.mjs +0 -26
- package/scripts/lib/context.mjs +0 -51
- package/scripts/lib/handoff.mjs +0 -187
- package/scripts/lib/logger.mjs +0 -122
- package/scripts/lib/stealth-fetch.mjs +0 -176
package/hub/index.mjs
CHANGED
|
@@ -4,25 +4,9 @@ export { buildExecCommand, sleep, CODEX_MCP_TRANSPORT_EXIT_CODE, normalizePathFo
|
|
|
4
4
|
export { execute as executeCodex, buildExecArgs as buildCodexArgs, buildLaunchScript, getCircuitState as getCodexCircuit } from './codex-adapter.mjs';
|
|
5
5
|
export { getCodexVersion, runPreflight } from './codex-preflight.mjs';
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
export { createRouter } from './router.mjs';
|
|
9
|
-
|
|
10
|
-
// State & Paths & Platform
|
|
11
|
-
export * from './paths.mjs';
|
|
7
|
+
// Platform
|
|
12
8
|
export { IS_WINDOWS, IS_MAC, IS_LINUX, TEMP_DIR, normalizePath, whichCommand, killProcess, pipePath } from './platform.mjs';
|
|
13
9
|
|
|
14
10
|
// Core services
|
|
15
|
-
export {
|
|
16
|
-
export { createAssignCallbackServer } from './assign-callbacks.mjs';
|
|
17
|
-
export { getHubUrl, getHubPipePath, requestJson, post, connectPipe, parseArgs, parseJsonSafe } from './bridge.mjs';
|
|
18
|
-
|
|
19
|
-
// Reflexion (adaptive error learning)
|
|
20
|
-
export { normalizeError, adaptiveRuleFromError } from './reflexion.mjs';
|
|
21
|
-
|
|
22
|
-
// Neural Memory (Lake 1.5)
|
|
23
|
-
export { createAdaptiveEngine } from './adaptive.mjs';
|
|
24
|
-
export { createAdaptiveMemory } from './adaptive-memory.mjs';
|
|
25
|
-
export { createDiagnosticPipeline } from './adaptive-diagnostic.mjs';
|
|
26
|
-
export { createAdaptiveInjector } from './adaptive-inject.mjs';
|
|
27
|
-
export { buildAdaptiveFingerprint, createAdaptiveFingerprintService } from './session-fingerprint.mjs';
|
|
11
|
+
export { parseArgs, parseJsonSafe } from './bridge.mjs';
|
|
28
12
|
export { broker as accountBroker } from './account-broker.mjs';
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
unlinkSync,
|
|
10
10
|
writeFileSync,
|
|
11
11
|
} from "node:fs";
|
|
12
|
-
import {
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
13
|
import { join } from "node:path";
|
|
14
14
|
import { IS_WINDOWS, killProcess } from "../platform.mjs";
|
|
15
15
|
|
|
@@ -387,23 +387,6 @@ function getProcessSnapshot({
|
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
-
function addHubPid(protectedPids) {
|
|
391
|
-
try {
|
|
392
|
-
const hubPidPath = join(
|
|
393
|
-
homedir(),
|
|
394
|
-
".claude",
|
|
395
|
-
"cache",
|
|
396
|
-
"tfx-hub",
|
|
397
|
-
"hub.pid",
|
|
398
|
-
);
|
|
399
|
-
if (existsSync(hubPidPath)) {
|
|
400
|
-
const hubInfo = JSON.parse(readFileSync(hubPidPath, "utf8"));
|
|
401
|
-
const hubPid = normalizePid(hubInfo?.pid);
|
|
402
|
-
if (hubPid) protectedPids.add(hubPid);
|
|
403
|
-
}
|
|
404
|
-
} catch {}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
390
|
function getProtectedPids({
|
|
408
391
|
protectedPids,
|
|
409
392
|
isWindows = IS_WINDOWS,
|
|
@@ -415,7 +398,6 @@ function getProtectedPids({
|
|
|
415
398
|
if (Number.isInteger(process.ppid) && process.ppid > 0) {
|
|
416
399
|
result.add(process.ppid);
|
|
417
400
|
}
|
|
418
|
-
addHubPid(result);
|
|
419
401
|
if (!includeAncestorScan) return result;
|
|
420
402
|
|
|
421
403
|
const snapshot = getProcessSnapshot({ isWindows, spawnSyncFn });
|
|
@@ -845,22 +827,8 @@ export function cleanupStaleFsmonitorDaemons({
|
|
|
845
827
|
function cleanupOrphansUnix() {
|
|
846
828
|
const myPid = process.pid;
|
|
847
829
|
|
|
848
|
-
// Hub PID 보호
|
|
849
830
|
const protectedPids = new Set();
|
|
850
831
|
protectedPids.add(myPid);
|
|
851
|
-
try {
|
|
852
|
-
const hubPidPath = join(
|
|
853
|
-
homedir(),
|
|
854
|
-
".claude",
|
|
855
|
-
"cache",
|
|
856
|
-
"tfx-hub",
|
|
857
|
-
"hub.pid",
|
|
858
|
-
);
|
|
859
|
-
if (existsSync(hubPidPath)) {
|
|
860
|
-
const hubPid = Number(JSON.parse(readFileSync(hubPidPath, "utf8"))?.pid);
|
|
861
|
-
if (Number.isFinite(hubPid) && hubPid > 0) protectedPids.add(hubPid);
|
|
862
|
-
}
|
|
863
|
-
} catch {}
|
|
864
832
|
|
|
865
833
|
// 현재 프로세스의 조상 트리 보호
|
|
866
834
|
try {
|
|
@@ -1775,8 +1775,7 @@ export async function dispatchClaudeDaemonJob({
|
|
|
1775
1775
|
/**
|
|
1776
1776
|
* dispatchClaudeDaemonJob 의 대칭 정리 경로.
|
|
1777
1777
|
* removeProjection + killDaemonJob (+ optional removeClaudeJobState) 를
|
|
1778
|
-
* 모두 시도하며, 각 스텝 오류는
|
|
1779
|
-
* 동일하게 .catch 로 삼킨다.
|
|
1778
|
+
* 모두 시도하며, 각 스텝 오류는 .catch 로 삼킨다.
|
|
1780
1779
|
*/
|
|
1781
1780
|
export async function teardownClaudeDaemonJob({
|
|
1782
1781
|
controlSock,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// 실제 bridge ID 가 없으면 만들어 내지 않는다. 추정 ID 는 붙을 수 있는 세션처럼 보이게 한다.
|
|
5
|
+
export function normalizeClaudeBridgeSessionId(bridgeSessionId) {
|
|
5
6
|
const value = String(bridgeSessionId || "").trim();
|
|
6
|
-
if (value.startsWith("session_")) return value;
|
|
7
7
|
if (value.startsWith("cse_")) return `session_${value.slice(4)}`;
|
|
8
|
-
|
|
9
|
-
return `session_${short}`;
|
|
8
|
+
return value;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export function buildClaudeSessionProjection({
|
|
@@ -30,6 +29,7 @@ export function buildClaudeSessionProjection({
|
|
|
30
29
|
if (!cwd) throw new Error("cwd is required");
|
|
31
30
|
if (!name) throw new Error("name is required");
|
|
32
31
|
if (!agent) throw new Error("agent is required");
|
|
32
|
+
const bridge = normalizeClaudeBridgeSessionId(bridgeSessionId);
|
|
33
33
|
return {
|
|
34
34
|
pid,
|
|
35
35
|
sessionId,
|
|
@@ -45,7 +45,7 @@ export function buildClaudeSessionProjection({
|
|
|
45
45
|
jobId: short,
|
|
46
46
|
status,
|
|
47
47
|
updatedAt,
|
|
48
|
-
bridgeSessionId:
|
|
48
|
+
...(bridge ? { bridgeSessionId: bridge } : {}),
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -58,74 +58,6 @@ export async function writeClaudeSessionProjection(sessionsDir, projection) {
|
|
|
58
58
|
return sessionPath;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export async function updateClaudeSessionProjection(sessionPath, patch) {
|
|
62
|
-
const parsed = JSON.parse(await fs.readFile(sessionPath, "utf8"));
|
|
63
|
-
const next = {
|
|
64
|
-
...parsed,
|
|
65
|
-
...patch,
|
|
66
|
-
updatedAt: patch.updatedAt || Date.now(),
|
|
67
|
-
};
|
|
68
|
-
await fs.writeFile(sessionPath, `${JSON.stringify(next)}\n`, "utf8");
|
|
69
|
-
return next;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function projectionSessionId(projection) {
|
|
73
|
-
return String(
|
|
74
|
-
projection?.sessionId ?? projection?.session_id ?? projection?.id ?? "",
|
|
75
|
-
).trim();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export async function findClaudeSessionProjectionBySessionId(
|
|
79
|
-
sessionsDir,
|
|
80
|
-
sessionId,
|
|
81
|
-
) {
|
|
82
|
-
const expected = String(sessionId || "").trim();
|
|
83
|
-
if (!sessionsDir || !expected) return null;
|
|
84
|
-
let entries;
|
|
85
|
-
try {
|
|
86
|
-
entries = await fs.readdir(sessionsDir, { withFileTypes: true });
|
|
87
|
-
} catch (error) {
|
|
88
|
-
if (error?.code === "ENOENT") return null;
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
for (const entry of entries) {
|
|
93
|
-
if (!entry.isFile() || !entry.name.endsWith(".json")) continue;
|
|
94
|
-
const filePath = path.join(sessionsDir, entry.name);
|
|
95
|
-
try {
|
|
96
|
-
const projection = JSON.parse(await fs.readFile(filePath, "utf8"));
|
|
97
|
-
if (projectionSessionId(projection) === expected) {
|
|
98
|
-
return { path: filePath, projection };
|
|
99
|
-
}
|
|
100
|
-
} catch (error) {
|
|
101
|
-
if (error instanceof SyntaxError) continue;
|
|
102
|
-
if (error?.code === "ENOENT") continue;
|
|
103
|
-
throw error;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export async function refreshClaudeSessionProjectionCwd({
|
|
110
|
-
sessionsDir,
|
|
111
|
-
sessionId,
|
|
112
|
-
cwd,
|
|
113
|
-
updatedAt = Date.now(),
|
|
114
|
-
} = {}) {
|
|
115
|
-
const nextCwd = String(cwd || "").trim();
|
|
116
|
-
if (!nextCwd) return { updated: false, reason: "missing_cwd" };
|
|
117
|
-
const found = await findClaudeSessionProjectionBySessionId(
|
|
118
|
-
sessionsDir,
|
|
119
|
-
sessionId,
|
|
120
|
-
);
|
|
121
|
-
if (!found) return { updated: false, reason: "projection_not_found" };
|
|
122
|
-
const projection = await updateClaudeSessionProjection(found.path, {
|
|
123
|
-
cwd: nextCwd,
|
|
124
|
-
updatedAt,
|
|
125
|
-
});
|
|
126
|
-
return { updated: true, path: found.path, projection };
|
|
127
|
-
}
|
|
128
|
-
|
|
129
61
|
export async function removeClaudeSessionProjection(sessionPath) {
|
|
130
62
|
await fs.rm(sessionPath, { force: true });
|
|
131
63
|
}
|