@triflux/core 10.50.1 → 10.51.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 (90) hide show
  1. package/hooks/agy-session-hook.mjs +11 -56
  2. package/hooks/codex-session-hook.mjs +11 -101
  3. package/hub/bridge.mjs +1 -79
  4. package/hub/cli-adapter-base.mjs +12 -90
  5. package/hub/codex-adapter.mjs +0 -1
  6. package/hub/codex-preflight.mjs +5 -28
  7. package/hub/index.mjs +3 -9
  8. package/hub/lib/cto-env.mjs +0 -23
  9. package/hub/lib/known-errors.json +2 -2
  10. package/hub/lib/process-utils.mjs +0 -123
  11. package/hub/lib/spawn-trace.mjs +3 -2
  12. package/hub/lib/timeout-defaults.mjs +0 -1
  13. package/hub/paths.mjs +0 -6
  14. package/hub/pipeline/index.mjs +0 -190
  15. package/hub/pipeline/transitions.mjs +0 -10
  16. package/hub/reflexion.mjs +1 -84
  17. package/hub/role-contract.mjs +0 -2
  18. package/hud/cli-policy.mjs +0 -26
  19. package/hud/colors.mjs +0 -13
  20. package/hud/constants.mjs +7 -153
  21. package/hud/context-monitor.mjs +3 -64
  22. package/hud/hud-qos-status.mjs +54 -264
  23. package/hud/providers/claude.mjs +4 -16
  24. package/hud/providers/gemini.mjs +83 -689
  25. package/hud/renderers.mjs +59 -367
  26. package/hud/terminal.mjs +1 -63
  27. package/hud/utils.mjs +2 -26
  28. package/package.json +1 -4
  29. package/scripts/lib/agent-route-policy.mjs +162 -14
  30. package/scripts/lib/claudemd-scanner.mjs +2 -199
  31. package/scripts/lib/cli-claude.mjs +0 -2
  32. package/scripts/lib/context.mjs +3 -19
  33. package/scripts/lib/env-probe.mjs +5 -64
  34. package/scripts/lib/gemini-profiles.mjs +2 -69
  35. package/scripts/lib/legacy-mcp-cleanup.mjs +14 -3
  36. package/scripts/lib/machine-profile.mjs +3 -17
  37. package/scripts/lib/mcp-filter.mjs +109 -53
  38. package/scripts/lib/mcp-health.mjs +2 -2
  39. package/scripts/lib/mcp-server-catalog.mjs +2 -2
  40. package/scripts/lib/psmux-info.mjs +25 -104
  41. package/scripts/lib/session-presence.mjs +1 -1
  42. package/scripts/lib/skill-template.mjs +0 -271
  43. package/hub/codex-compat.mjs +0 -12
  44. package/hub/dynamic-routing-engine.mjs +0 -511
  45. package/hub/fullcycle.mjs +0 -113
  46. package/hub/gemini-adapter.mjs +0 -174
  47. package/hub/intent.mjs +0 -321
  48. package/hub/lib/mcp-response-cache.mjs +0 -239
  49. package/hub/lib/path-utils.mjs +0 -165
  50. package/hub/lib/risk-tier.mjs +0 -53
  51. package/hub/lib/ssh-command.mjs +0 -231
  52. package/hub/lib/staged-file-detect.mjs +0 -43
  53. package/hub/lib/tfx-route-args.mjs +0 -353
  54. package/hub/lib/timeline-adapter.mjs +0 -190
  55. package/hub/pipeline/gates/confidence.mjs +0 -75
  56. package/hub/pipeline/gates/consensus.mjs +0 -106
  57. package/hub/pipeline/gates/index.mjs +0 -9
  58. package/hub/pipeline/gates/selfcheck.mjs +0 -120
  59. package/hub/quality/deslop.mjs +0 -274
  60. package/hub/research.mjs +0 -155
  61. package/hub/role-control-events.mjs +0 -113
  62. package/hub/routing/complexity.mjs +0 -269
  63. package/hub/routing/index.mjs +0 -122
  64. package/hub/routing/q-learning.mjs +0 -387
  65. package/hub/routing-snapshot.mjs +0 -261
  66. package/hub/token-mode.mjs +0 -228
  67. package/hud/mission-board.mjs +0 -56
  68. package/hud/providers/cto.mjs +0 -76
  69. package/mesh/index.mjs +0 -69
  70. package/mesh/mesh-budget.mjs +0 -137
  71. package/mesh/mesh-heartbeat.mjs +0 -100
  72. package/mesh/mesh-protocol.mjs +0 -96
  73. package/mesh/mesh-queue.mjs +0 -163
  74. package/mesh/mesh-registry.mjs +0 -78
  75. package/mesh/mesh-router.mjs +0 -77
  76. package/scripts/lib/agent-json.mjs +0 -27
  77. package/scripts/lib/async.mjs +0 -174
  78. package/scripts/lib/cli-agy.mjs +0 -85
  79. package/scripts/lib/cli-codex.mjs +0 -62
  80. package/scripts/lib/cli-gemini.mjs +0 -37
  81. package/scripts/lib/dynamic-route-cli.mjs +0 -107
  82. package/scripts/lib/env.mjs +0 -14
  83. package/scripts/lib/hub.mjs +0 -48
  84. package/scripts/lib/pid.mjs +0 -63
  85. package/scripts/lib/quota.mjs +0 -47
  86. package/scripts/lib/skill-state.mjs +0 -220
  87. package/scripts/lib/team.mjs +0 -75
  88. package/scripts/lib/timeout.mjs +0 -66
  89. package/scripts/lib/tmp.mjs +0 -26
  90. package/scripts/lib/toml.mjs +0 -132
@@ -1,66 +0,0 @@
1
- import { spawn } from "node:child_process";
2
-
3
- export function timeoutCodeForSignal(signal) {
4
- return signal ? 124 : null;
5
- }
6
-
7
- export function runWithTimeout(command, args = [], options = {}) {
8
- const {
9
- cwd = process.cwd(),
10
- env = process.env,
11
- input,
12
- timeoutMs = 0,
13
- stdio = "pipe",
14
- spawnFn = spawn,
15
- } = options;
16
-
17
- return new Promise((resolve, reject) => {
18
- const controller = new AbortController();
19
- let timedOut = false;
20
- const child = spawnFn(command, args, {
21
- cwd,
22
- env,
23
- stdio,
24
- signal: controller.signal,
25
- });
26
- const stdout = [];
27
- const stderr = [];
28
- let timer = null;
29
-
30
- if (child.stdout) child.stdout.on("data", (chunk) => stdout.push(chunk));
31
- if (child.stderr) child.stderr.on("data", (chunk) => stderr.push(chunk));
32
- child.on("error", (err) => {
33
- if (timedOut && err.name === "AbortError") return;
34
- reject(err);
35
- });
36
- child.on("exit", (code, signal) => {
37
- if (timer) clearTimeout(timer);
38
- resolve({
39
- code: timedOut ? 124 : (code ?? timeoutCodeForSignal(signal) ?? 1),
40
- signal,
41
- timedOut,
42
- stdout: Buffer.concat(stdout).toString("utf8"),
43
- stderr: Buffer.concat(stderr).toString("utf8"),
44
- });
45
- });
46
-
47
- if (timeoutMs > 0) {
48
- timer = setTimeout(() => {
49
- timedOut = true;
50
- controller.abort();
51
- if (child.pid) {
52
- try {
53
- process.kill(child.pid, "SIGTERM");
54
- } catch {
55
- // Process already exited.
56
- }
57
- }
58
- }, timeoutMs);
59
- timer.unref?.();
60
- }
61
-
62
- if (input !== undefined && child.stdin) {
63
- child.stdin.end(input);
64
- }
65
- });
66
- }
@@ -1,26 +0,0 @@
1
- import { mkdirSync } from "node:fs";
2
- import { tmpdir } from "node:os";
3
- import { join } from "node:path";
4
-
5
- export function resolveTmpDir({ env = process.env, cwd = process.cwd() } = {}) {
6
- const candidate = env.TFX_TMP || tmpdir();
7
- try {
8
- mkdirSync(candidate, { recursive: true });
9
- return candidate;
10
- } catch {
11
- const fallback = join(cwd, ".tfx-tmp");
12
- try {
13
- mkdirSync(fallback, { recursive: true });
14
- } catch {
15
- // Bash printed the fallback path even when mkdir failed.
16
- }
17
- return fallback;
18
- }
19
- }
20
-
21
- export function resolveJobsDir({
22
- env = process.env,
23
- tmpDir = resolveTmpDir({ env }),
24
- } = {}) {
25
- return env.TFX_JOBS_DIR || join(tmpDir, "tfx-jobs");
26
- }
@@ -1,132 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
- import { createRequire } from "node:module";
3
- import { dirname } from "node:path";
4
- import { sanitizeCodexProfileConfig } from "./codex-profile-config.mjs";
5
-
6
- const require = createRequire(import.meta.url);
7
- let TOML = null;
8
- try {
9
- TOML = require("@iarna/toml");
10
- } catch {
11
- TOML = null;
12
- }
13
-
14
- function walk(value, visitor) {
15
- if (!value || typeof value !== "object") return;
16
- for (const [key, child] of Object.entries(value)) {
17
- visitor(value, key, child);
18
- walk(child, visitor);
19
- }
20
- }
21
-
22
- export function parseToml(source) {
23
- if (!TOML) return parseTomlFallback(source);
24
- return TOML.parse(source || "");
25
- }
26
-
27
- export function stringifyToml(value) {
28
- if (!TOML) return stringifyTomlFallback(value);
29
- return TOML.stringify(value);
30
- }
31
-
32
- function parseTomlFallback(source = "") {
33
- const root = {};
34
- let current = root;
35
- for (const rawLine of String(source).split(/\r?\n/)) {
36
- const line = rawLine.trim();
37
- if (!line || line.startsWith("#")) continue;
38
- const section = line.match(/^\[([^\]]+)\]$/);
39
- if (section) {
40
- current = root;
41
- for (const part of section[1].split(".")) {
42
- current[part] ??= {};
43
- current = current[part];
44
- }
45
- continue;
46
- }
47
- const assignment = line.match(/^([A-Za-z0-9_-]+)\s*=\s*"([^"]*)"$/);
48
- if (assignment) {
49
- current[assignment[1]] = assignment[2];
50
- }
51
- }
52
- return root;
53
- }
54
-
55
- function stringifyTomlFallback(value) {
56
- const lines = [];
57
- for (const [key, child] of Object.entries(value)) {
58
- if (child && typeof child === "object") continue;
59
- lines.push(`${key} = "${String(child)}"`);
60
- }
61
- function writeSections(prefix, obj) {
62
- for (const [key, child] of Object.entries(obj)) {
63
- if (!child || typeof child !== "object") continue;
64
- const section = [...prefix, key];
65
- lines.push("", `[${section.join(".")}]`);
66
- for (const [childKey, childValue] of Object.entries(child)) {
67
- if (childValue && typeof childValue === "object") continue;
68
- lines.push(`${childKey} = "${String(childValue)}"`);
69
- }
70
- writeSections(section, child);
71
- }
72
- }
73
- writeSections([], value);
74
- return `${lines.join("\n")}\n`;
75
- }
76
-
77
- export function detectTopLevelCodexConfig(source) {
78
- const parsed = parseToml(source);
79
- return {
80
- hasTopLevelSandboxOrApproval:
81
- Object.hasOwn(parsed, "sandbox") ||
82
- Object.hasOwn(parsed, "approval_mode"),
83
- };
84
- }
85
-
86
- export function patchMcpApprovalMode(source) {
87
- const parsed = parseToml(source);
88
- let count = 0;
89
- walk(parsed.mcp_servers, (parent, key, value) => {
90
- if (key === "approval_mode" && value === "approve") {
91
- parent[key] = "full-auto";
92
- count += 1;
93
- }
94
- });
95
- return {
96
- changed: count > 0,
97
- count,
98
- toml: count > 0 ? stringifyToml(parsed) : source,
99
- };
100
- }
101
-
102
- export function patchCodexConfigFile(path, { now = () => new Date() } = {}) {
103
- if (!path || !existsSync(path)) return { changed: false, count: 0 };
104
- const source = readFileSync(path, "utf8");
105
- const approvalPatched = patchMcpApprovalMode(source);
106
- const profileSanitized = sanitizeCodexProfileConfig(approvalPatched.toml, {
107
- codexHome: dirname(path),
108
- });
109
- const changed = approvalPatched.changed || profileSanitized.changed;
110
- if (!changed) {
111
- return {
112
- changed: false,
113
- count: 0,
114
- removedProfiles: [],
115
- migratedProfiles: [],
116
- };
117
- }
118
- const stamp = now()
119
- .toISOString()
120
- .replace(/[-:]/g, "")
121
- .replace(/\..*$/, "")
122
- .replace("T", "-");
123
- writeFileSync(`${path}.bak-${stamp}`, source);
124
- writeFileSync(path, profileSanitized.toml);
125
- return {
126
- changed: true,
127
- count: approvalPatched.count,
128
- removedProfiles: profileSanitized.removedProfiles,
129
- migratedProfiles: profileSanitized.migratedProfiles,
130
- toml: profileSanitized.toml,
131
- };
132
- }