triflux 3.2.0-dev.8 → 3.3.0-dev.1
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/bin/triflux.mjs +1296 -1055
- package/hooks/hooks.json +17 -0
- package/hooks/keyword-rules.json +20 -4
- package/hooks/pipeline-stop.mjs +54 -0
- package/hub/bridge.mjs +517 -318
- package/hub/hitl.mjs +45 -31
- package/hub/pipe.mjs +457 -0
- package/hub/pipeline/index.mjs +121 -0
- package/hub/pipeline/state.mjs +164 -0
- package/hub/pipeline/transitions.mjs +114 -0
- package/hub/router.mjs +422 -161
- package/hub/schema.sql +14 -0
- package/hub/server.mjs +499 -424
- package/hub/store.mjs +388 -314
- package/hub/team/cli-team-common.mjs +348 -0
- package/hub/team/cli-team-control.mjs +393 -0
- package/hub/team/cli-team-start.mjs +516 -0
- package/hub/team/cli-team-status.mjs +269 -0
- package/hub/team/cli.mjs +75 -1475
- package/hub/team/dashboard.mjs +1 -9
- package/hub/team/native.mjs +190 -130
- package/hub/team/nativeProxy.mjs +165 -78
- package/hub/team/orchestrator.mjs +15 -20
- package/hub/team/pane.mjs +137 -103
- package/hub/team/psmux.mjs +506 -0
- package/hub/team/session.mjs +393 -330
- package/hub/team/shared.mjs +13 -0
- package/hub/team/staleState.mjs +299 -0
- package/hub/tools.mjs +105 -31
- package/hub/workers/claude-worker.mjs +446 -0
- package/hub/workers/codex-mcp.mjs +414 -0
- package/hub/workers/factory.mjs +18 -0
- package/hub/workers/gemini-worker.mjs +349 -0
- package/hub/workers/interface.mjs +41 -0
- package/hud/hud-qos-status.mjs +1790 -1788
- package/package.json +4 -1
- package/scripts/__tests__/keyword-detector.test.mjs +8 -8
- package/scripts/keyword-detector.mjs +15 -0
- package/scripts/lib/keyword-rules.mjs +4 -1
- package/scripts/preflight-cache.mjs +72 -0
- package/scripts/psmux-steering-prototype.sh +368 -0
- package/scripts/setup.mjs +136 -71
- package/scripts/tfx-route-worker.mjs +161 -0
- package/scripts/tfx-route.sh +485 -91
- package/skills/tfx-auto/SKILL.md +90 -564
- package/skills/tfx-auto-codex/SKILL.md +1 -3
- package/skills/tfx-codex/SKILL.md +1 -4
- package/skills/tfx-doctor/SKILL.md +1 -0
- package/skills/tfx-gemini/SKILL.md +1 -4
- package/skills/tfx-multi/SKILL.md +378 -0
- package/skills/tfx-setup/SKILL.md +1 -4
- package/skills/tfx-team/SKILL.md +0 -304
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// hub/team/shared.mjs — 팀 모듈 공유 유틸리티
|
|
2
|
+
// cli.mjs, dashboard.mjs 등에서 중복되던 상수/함수를 통합
|
|
3
|
+
|
|
4
|
+
// ── ANSI 색상 상수 ──
|
|
5
|
+
export const AMBER = "\x1b[38;5;214m";
|
|
6
|
+
export const GREEN = "\x1b[38;5;82m";
|
|
7
|
+
export const RED = "\x1b[38;5;196m";
|
|
8
|
+
export const GRAY = "\x1b[38;5;245m";
|
|
9
|
+
export const DIM = "\x1b[2m";
|
|
10
|
+
export const BOLD = "\x1b[1m";
|
|
11
|
+
export const RESET = "\x1b[0m";
|
|
12
|
+
export const WHITE = "\x1b[97m";
|
|
13
|
+
export const YELLOW = "\x1b[33m";
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// hub/team/staleState.mjs
|
|
2
|
+
// .omc/state 아래에 남은 stale team 상태를 탐지/정리한다.
|
|
3
|
+
|
|
4
|
+
import { existsSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync } from "node:fs";
|
|
5
|
+
import { execFileSync } from "node:child_process";
|
|
6
|
+
import { dirname, join, resolve } from "node:path";
|
|
7
|
+
|
|
8
|
+
export const TEAM_STATE_FILE_NAME = "team-state.json";
|
|
9
|
+
export const STALE_TEAM_MAX_AGE_MS = 60 * 60 * 1000;
|
|
10
|
+
|
|
11
|
+
function safeStat(path) {
|
|
12
|
+
try {
|
|
13
|
+
return statSync(path);
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function parseStartedAtMs(value) {
|
|
20
|
+
if (typeof value !== "string" || !value.trim()) return null;
|
|
21
|
+
const parsed = Date.parse(value);
|
|
22
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function findPidCandidates(state) {
|
|
26
|
+
const pidSet = new Set();
|
|
27
|
+
const pushPid = (value) => {
|
|
28
|
+
const pid = Number(value);
|
|
29
|
+
if (Number.isInteger(pid) && pid > 0) pidSet.add(pid);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
pushPid(state?.pid);
|
|
33
|
+
pushPid(state?.processId);
|
|
34
|
+
pushPid(state?.process_id);
|
|
35
|
+
pushPid(state?.leadPid);
|
|
36
|
+
pushPid(state?.lead_pid);
|
|
37
|
+
pushPid(state?.native?.supervisorPid);
|
|
38
|
+
pushPid(state?.native?.supervisor_pid);
|
|
39
|
+
|
|
40
|
+
return Array.from(pidSet);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function findSessionNames(state) {
|
|
44
|
+
const sessionNameSet = new Set();
|
|
45
|
+
const pushName = (value) => {
|
|
46
|
+
if (typeof value !== "string") return;
|
|
47
|
+
const trimmed = value.trim();
|
|
48
|
+
if (trimmed) sessionNameSet.add(trimmed);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
pushName(state?.sessionName);
|
|
52
|
+
pushName(state?.session_name);
|
|
53
|
+
pushName(state?.native?.teamName);
|
|
54
|
+
pushName(state?.native?.team_name);
|
|
55
|
+
|
|
56
|
+
return Array.from(sessionNameSet);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function findProcessTokens(state, sessionId) {
|
|
60
|
+
const tokenSet = new Set();
|
|
61
|
+
const pushToken = (value) => {
|
|
62
|
+
if (typeof value !== "string") return;
|
|
63
|
+
const trimmed = value.trim();
|
|
64
|
+
if (trimmed.length >= 6) tokenSet.add(trimmed.toLowerCase());
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
pushToken(sessionId);
|
|
68
|
+
pushToken(state?.session_id);
|
|
69
|
+
pushToken(state?.sessionId);
|
|
70
|
+
pushToken(state?.teamName);
|
|
71
|
+
pushToken(state?.team_name);
|
|
72
|
+
pushToken(state?.name);
|
|
73
|
+
pushToken(state?.native?.teamName);
|
|
74
|
+
pushToken(state?.native?.team_name);
|
|
75
|
+
|
|
76
|
+
return Array.from(tokenSet);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function isPidAlive(pid) {
|
|
80
|
+
try {
|
|
81
|
+
process.kill(pid, 0);
|
|
82
|
+
return true;
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function normalizeProcessEntries(processEntries = []) {
|
|
89
|
+
if (!Array.isArray(processEntries)) return [];
|
|
90
|
+
|
|
91
|
+
return processEntries.map((entry) => ({
|
|
92
|
+
pid: Number(entry?.pid ?? entry?.ProcessId ?? 0),
|
|
93
|
+
command: String(entry?.command ?? entry?.CommandLine ?? entry?.Name ?? "").toLowerCase(),
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function readProcessEntries() {
|
|
98
|
+
try {
|
|
99
|
+
if (process.platform === "win32") {
|
|
100
|
+
const raw = execFileSync(
|
|
101
|
+
"powershell",
|
|
102
|
+
[
|
|
103
|
+
"-NoProfile",
|
|
104
|
+
"-Command",
|
|
105
|
+
"$ErrorActionPreference='SilentlyContinue'; Get-CimInstance Win32_Process | Select-Object ProcessId,Name,CommandLine | ConvertTo-Json -Compress",
|
|
106
|
+
],
|
|
107
|
+
{
|
|
108
|
+
encoding: "utf8",
|
|
109
|
+
timeout: 10000,
|
|
110
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
111
|
+
windowsHide: true,
|
|
112
|
+
},
|
|
113
|
+
).trim();
|
|
114
|
+
|
|
115
|
+
if (!raw) return [];
|
|
116
|
+
const parsed = JSON.parse(raw);
|
|
117
|
+
return normalizeProcessEntries(Array.isArray(parsed) ? parsed : [parsed]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const raw = execFileSync("ps", ["-ax", "-o", "pid=,command="], {
|
|
121
|
+
encoding: "utf8",
|
|
122
|
+
timeout: 10000,
|
|
123
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
124
|
+
}).trim();
|
|
125
|
+
|
|
126
|
+
if (!raw) return [];
|
|
127
|
+
return raw
|
|
128
|
+
.split(/\r?\n/)
|
|
129
|
+
.map((line) => line.trim())
|
|
130
|
+
.filter(Boolean)
|
|
131
|
+
.map((line) => {
|
|
132
|
+
const match = /^(\d+)\s+(.*)$/.exec(line);
|
|
133
|
+
return {
|
|
134
|
+
pid: Number(match?.[1] || 0),
|
|
135
|
+
command: String(match?.[2] || "").toLowerCase(),
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
} catch {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function resolveLiveness(state, sessionId, liveSessionNames, processEntries) {
|
|
144
|
+
const pidCandidates = findPidCandidates(state);
|
|
145
|
+
for (const pid of pidCandidates) {
|
|
146
|
+
if (isPidAlive(pid)) {
|
|
147
|
+
return { active: true, reason: `pid:${pid}` };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const sessionNames = findSessionNames(state);
|
|
152
|
+
for (const sessionName of sessionNames) {
|
|
153
|
+
if (liveSessionNames.has(sessionName)) {
|
|
154
|
+
return { active: true, reason: `session:${sessionName}` };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const processTokens = findProcessTokens(state, sessionId);
|
|
159
|
+
if (processTokens.length > 0) {
|
|
160
|
+
const matched = processEntries.find((entry) => (
|
|
161
|
+
entry.pid > 0 && processTokens.some((token) => entry.command.includes(token))
|
|
162
|
+
));
|
|
163
|
+
if (matched) {
|
|
164
|
+
return { active: true, reason: `command:${matched.pid}` };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return { active: false, reason: "process_missing" };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function collectTeamStateTargets(stateRoot) {
|
|
172
|
+
const targets = [];
|
|
173
|
+
const rootStateFile = join(stateRoot, TEAM_STATE_FILE_NAME);
|
|
174
|
+
if (existsSync(rootStateFile)) {
|
|
175
|
+
targets.push({
|
|
176
|
+
scope: "root",
|
|
177
|
+
sessionId: "root",
|
|
178
|
+
stateFile: rootStateFile,
|
|
179
|
+
cleanupPath: rootStateFile,
|
|
180
|
+
cleanupType: "file",
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const sessionsDir = join(stateRoot, "sessions");
|
|
185
|
+
const sessionsStat = safeStat(sessionsDir);
|
|
186
|
+
if (!sessionsStat?.isDirectory()) {
|
|
187
|
+
return targets;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
for (const entry of readdirSync(sessionsDir, { withFileTypes: true })) {
|
|
191
|
+
if (!entry.isDirectory()) continue;
|
|
192
|
+
const sessionDir = join(sessionsDir, entry.name);
|
|
193
|
+
const stateFile = join(sessionDir, TEAM_STATE_FILE_NAME);
|
|
194
|
+
if (!existsSync(stateFile)) continue;
|
|
195
|
+
|
|
196
|
+
targets.push({
|
|
197
|
+
scope: "session",
|
|
198
|
+
sessionId: entry.name,
|
|
199
|
+
stateFile,
|
|
200
|
+
cleanupPath: sessionDir,
|
|
201
|
+
cleanupType: "dir",
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return targets;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function findNearestOmcStateDir(startDir = process.cwd()) {
|
|
209
|
+
let currentDir = resolve(startDir);
|
|
210
|
+
|
|
211
|
+
while (true) {
|
|
212
|
+
const candidate = join(currentDir, ".omc", "state");
|
|
213
|
+
const candidateStat = safeStat(candidate);
|
|
214
|
+
if (candidateStat?.isDirectory()) {
|
|
215
|
+
return candidate;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const parentDir = dirname(currentDir);
|
|
219
|
+
if (parentDir === currentDir) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
currentDir = parentDir;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function inspectStaleOmcTeams(options = {}) {
|
|
227
|
+
const stateRoot = options.stateRoot || findNearestOmcStateDir(options.startDir || process.cwd());
|
|
228
|
+
if (!stateRoot) {
|
|
229
|
+
return { stateRoot: null, entries: [] };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const liveSessionNames = new Set(options.liveSessionNames || []);
|
|
233
|
+
const processEntries = normalizeProcessEntries(options.processEntries || readProcessEntries());
|
|
234
|
+
const nowMs = Number.isFinite(options.nowMs) ? options.nowMs : Date.now();
|
|
235
|
+
const maxAgeMs = Number.isFinite(options.maxAgeMs) ? options.maxAgeMs : STALE_TEAM_MAX_AGE_MS;
|
|
236
|
+
const targets = collectTeamStateTargets(stateRoot);
|
|
237
|
+
const entries = [];
|
|
238
|
+
|
|
239
|
+
for (const target of targets) {
|
|
240
|
+
let state = null;
|
|
241
|
+
try {
|
|
242
|
+
state = JSON.parse(readFileSync(target.stateFile, "utf8"));
|
|
243
|
+
} catch {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const fileStat = safeStat(target.stateFile);
|
|
248
|
+
const startedAtMs = parseStartedAtMs(state?.started_at)
|
|
249
|
+
?? parseStartedAtMs(state?.startedAt)
|
|
250
|
+
?? fileStat?.mtimeMs
|
|
251
|
+
?? null;
|
|
252
|
+
const ageMs = startedAtMs == null ? null : Math.max(0, nowMs - startedAtMs);
|
|
253
|
+
const liveness = resolveLiveness(state, target.sessionId, liveSessionNames, processEntries);
|
|
254
|
+
const stale = ageMs != null && ageMs >= maxAgeMs && !liveness.active;
|
|
255
|
+
|
|
256
|
+
entries.push({
|
|
257
|
+
...target,
|
|
258
|
+
teamName: state?.teamName || state?.team_name || state?.native?.teamName || state?.name || null,
|
|
259
|
+
state,
|
|
260
|
+
startedAtMs,
|
|
261
|
+
ageMs,
|
|
262
|
+
ageSec: ageMs == null ? null : Math.floor(ageMs / 1000),
|
|
263
|
+
active: liveness.active,
|
|
264
|
+
activeReason: liveness.reason,
|
|
265
|
+
stale,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
stateRoot,
|
|
271
|
+
entries: entries
|
|
272
|
+
.filter((entry) => entry.stale)
|
|
273
|
+
.sort((left, right) => (right.ageMs || 0) - (left.ageMs || 0)),
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function cleanupStaleOmcTeams(entries = []) {
|
|
278
|
+
let cleaned = 0;
|
|
279
|
+
let failed = 0;
|
|
280
|
+
const results = [];
|
|
281
|
+
|
|
282
|
+
for (const entry of entries) {
|
|
283
|
+
try {
|
|
284
|
+
if (entry.cleanupType === "dir") {
|
|
285
|
+
rmSync(entry.cleanupPath, { recursive: true, force: true });
|
|
286
|
+
} else {
|
|
287
|
+
unlinkSync(entry.cleanupPath);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
cleaned += 1;
|
|
291
|
+
results.push({ ok: true, entry });
|
|
292
|
+
} catch (error) {
|
|
293
|
+
failed += 1;
|
|
294
|
+
results.push({ ok: false, entry, error });
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return { cleaned, failed, results };
|
|
299
|
+
}
|
package/hub/tools.mjs
CHANGED
|
@@ -8,15 +8,25 @@ import {
|
|
|
8
8
|
teamTaskUpdate,
|
|
9
9
|
teamSendMessage,
|
|
10
10
|
} from './team/nativeProxy.mjs';
|
|
11
|
+
import {
|
|
12
|
+
ensurePipelineTable,
|
|
13
|
+
createPipeline,
|
|
14
|
+
} from './pipeline/index.mjs';
|
|
15
|
+
import {
|
|
16
|
+
readPipelineState,
|
|
17
|
+
initPipelineState,
|
|
18
|
+
listPipelineStates,
|
|
19
|
+
} from './pipeline/state.mjs';
|
|
11
20
|
|
|
12
21
|
/**
|
|
13
22
|
* MCP 도구 목록 생성
|
|
14
23
|
* @param {object} store — createStore() 반환
|
|
15
24
|
* @param {object} router — createRouter() 반환
|
|
16
25
|
* @param {object} hitl — createHitlManager() 반환
|
|
26
|
+
* @param {object} pipe — createPipeServer() 반환
|
|
17
27
|
* @returns {Array<{name, description, inputSchema, handler}>}
|
|
18
28
|
*/
|
|
19
|
-
export function createTools(store, router, hitl) {
|
|
29
|
+
export function createTools(store, router, hitl, pipe = null) {
|
|
20
30
|
/** 도구 핸들러 래퍼 — 에러 처리 + MCP content 형식 변환 */
|
|
21
31
|
function wrap(code, fn) {
|
|
22
32
|
return async (args) => {
|
|
@@ -49,7 +59,7 @@ export function createTools(store, router, hitl) {
|
|
|
49
59
|
},
|
|
50
60
|
},
|
|
51
61
|
handler: wrap('REGISTER_FAILED', (args) => {
|
|
52
|
-
const data =
|
|
62
|
+
const data = router.registerAgent(args);
|
|
53
63
|
return { ok: true, data };
|
|
54
64
|
}),
|
|
55
65
|
},
|
|
@@ -124,7 +134,7 @@ export function createTools(store, router, hitl) {
|
|
|
124
134
|
// ── 5. poll_messages ──
|
|
125
135
|
{
|
|
126
136
|
name: 'poll_messages',
|
|
127
|
-
description: '
|
|
137
|
+
description: 'Deprecated. poll_messages 대신 Named Pipe subscribe/publish 채널을 사용합니다',
|
|
128
138
|
inputSchema: {
|
|
129
139
|
type: 'object',
|
|
130
140
|
required: ['agent_id'],
|
|
@@ -137,41 +147,29 @@ export function createTools(store, router, hitl) {
|
|
|
137
147
|
auto_ack: { type: 'boolean', default: false },
|
|
138
148
|
},
|
|
139
149
|
},
|
|
140
|
-
handler: wrap('
|
|
141
|
-
|
|
142
|
-
const ackedIds = [];
|
|
143
|
-
if (args.ack_ids?.length) {
|
|
144
|
-
store.ackMessages(args.ack_ids, args.agent_id);
|
|
145
|
-
ackedIds.push(...args.ack_ids);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// 1차 폴링
|
|
149
|
-
let messages = store.pollForAgent(args.agent_id, {
|
|
150
|
+
handler: wrap('POLL_DEPRECATED', async (args) => {
|
|
151
|
+
const replay = router.drainAgent(args.agent_id, {
|
|
150
152
|
max_messages: args.max_messages,
|
|
151
153
|
include_topics: args.include_topics,
|
|
152
154
|
auto_ack: args.auto_ack,
|
|
153
155
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (!messages.length && args.wait_ms > 0) {
|
|
157
|
-
const interval = Math.min(args.wait_ms, 500);
|
|
158
|
-
const deadline = Date.now() + Math.min(args.wait_ms, 30000);
|
|
159
|
-
while (!messages.length && Date.now() < deadline) {
|
|
160
|
-
await new Promise(r => setTimeout(r, interval));
|
|
161
|
-
messages = store.pollForAgent(args.agent_id, {
|
|
162
|
-
max_messages: args.max_messages,
|
|
163
|
-
include_topics: args.include_topics,
|
|
164
|
-
auto_ack: args.auto_ack,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
156
|
+
if (args.ack_ids?.length) {
|
|
157
|
+
router.ackMessages(args.ack_ids, args.agent_id);
|
|
167
158
|
}
|
|
168
|
-
|
|
169
159
|
return {
|
|
170
|
-
ok:
|
|
160
|
+
ok: false,
|
|
161
|
+
error: {
|
|
162
|
+
code: 'POLL_DEPRECATED',
|
|
163
|
+
message: 'poll_messages는 deprecated 되었습니다. pipe subscribe/publish 채널을 사용하세요.',
|
|
164
|
+
},
|
|
171
165
|
data: {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
166
|
+
pipe_path: pipe?.path || null,
|
|
167
|
+
delivery_mode: 'pipe_push',
|
|
168
|
+
protocol: 'ndjson',
|
|
169
|
+
replay: {
|
|
170
|
+
messages: replay,
|
|
171
|
+
count: replay.length,
|
|
172
|
+
},
|
|
175
173
|
server_time_ms: Date.now(),
|
|
176
174
|
},
|
|
177
175
|
};
|
|
@@ -336,5 +334,81 @@ export function createTools(store, router, hitl) {
|
|
|
336
334
|
return teamSendMessage(args);
|
|
337
335
|
}),
|
|
338
336
|
},
|
|
337
|
+
|
|
338
|
+
// ── 13. pipeline_state ──
|
|
339
|
+
{
|
|
340
|
+
name: 'pipeline_state',
|
|
341
|
+
description: '파이프라인 상태를 조회합니다 (--thorough 모드)',
|
|
342
|
+
inputSchema: {
|
|
343
|
+
type: 'object',
|
|
344
|
+
required: ['team_name'],
|
|
345
|
+
properties: {
|
|
346
|
+
team_name: { type: 'string', pattern: '^[a-z0-9][a-z0-9-]*$' },
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
handler: wrap('PIPELINE_STATE_FAILED', (args) => {
|
|
350
|
+
ensurePipelineTable(store.db);
|
|
351
|
+
const state = readPipelineState(store.db, args.team_name);
|
|
352
|
+
return state
|
|
353
|
+
? { ok: true, data: state }
|
|
354
|
+
: { ok: false, error: { code: 'PIPELINE_NOT_FOUND', message: `파이프라인 없음: ${args.team_name}` } };
|
|
355
|
+
}),
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
// ── 14. pipeline_advance ──
|
|
359
|
+
{
|
|
360
|
+
name: 'pipeline_advance',
|
|
361
|
+
description: '파이프라인을 다음 단계로 전이합니다 (전이 규칙 + fix loop 바운딩 적용)',
|
|
362
|
+
inputSchema: {
|
|
363
|
+
type: 'object',
|
|
364
|
+
required: ['team_name', 'phase'],
|
|
365
|
+
properties: {
|
|
366
|
+
team_name: { type: 'string', pattern: '^[a-z0-9][a-z0-9-]*$' },
|
|
367
|
+
phase: { type: 'string', enum: ['plan', 'prd', 'exec', 'verify', 'fix', 'complete', 'failed'] },
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
handler: wrap('PIPELINE_ADVANCE_FAILED', (args) => {
|
|
371
|
+
ensurePipelineTable(store.db);
|
|
372
|
+
const pipeline = createPipeline(store.db, args.team_name);
|
|
373
|
+
return pipeline.advance(args.phase);
|
|
374
|
+
}),
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
// ── 15. pipeline_init ──
|
|
378
|
+
{
|
|
379
|
+
name: 'pipeline_init',
|
|
380
|
+
description: '새 파이프라인을 초기화합니다 (기존 상태 덮어쓰기)',
|
|
381
|
+
inputSchema: {
|
|
382
|
+
type: 'object',
|
|
383
|
+
required: ['team_name'],
|
|
384
|
+
properties: {
|
|
385
|
+
team_name: { type: 'string', pattern: '^[a-z0-9][a-z0-9-]*$' },
|
|
386
|
+
fix_max: { type: 'integer', minimum: 1, maximum: 20, default: 3 },
|
|
387
|
+
ralph_max: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
handler: wrap('PIPELINE_INIT_FAILED', (args) => {
|
|
391
|
+
ensurePipelineTable(store.db);
|
|
392
|
+
const state = initPipelineState(store.db, args.team_name, {
|
|
393
|
+
fix_max: args.fix_max,
|
|
394
|
+
ralph_max: args.ralph_max,
|
|
395
|
+
});
|
|
396
|
+
return { ok: true, data: state };
|
|
397
|
+
}),
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
// ── 16. pipeline_list ──
|
|
401
|
+
{
|
|
402
|
+
name: 'pipeline_list',
|
|
403
|
+
description: '활성 파이프라인 목록을 조회합니다',
|
|
404
|
+
inputSchema: {
|
|
405
|
+
type: 'object',
|
|
406
|
+
properties: {},
|
|
407
|
+
},
|
|
408
|
+
handler: wrap('PIPELINE_LIST_FAILED', () => {
|
|
409
|
+
ensurePipelineTable(store.db);
|
|
410
|
+
return { ok: true, data: listPipelineStates(store.db) };
|
|
411
|
+
}),
|
|
412
|
+
},
|
|
339
413
|
];
|
|
340
414
|
}
|