@triflux/remote 10.0.0-alpha.1 → 10.0.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/index.mjs +21 -0
- package/hub/pipe.mjs +98 -13
- package/hub/server.mjs +1245 -1124
- package/hub/store-adapter.mjs +14 -747
- package/hub/store.mjs +4 -44
- package/hub/team/backend.mjs +1 -1
- package/hub/team/cli/services/hub-client.mjs +38 -19
- package/hub/team/cli/services/native-control.mjs +1 -1
- package/hub/team/conductor.mjs +671 -0
- package/hub/team/event-log.mjs +76 -0
- package/hub/team/headless.mjs +8 -6
- package/hub/team/health-probe.mjs +272 -0
- package/hub/team/launcher-template.mjs +95 -0
- package/hub/team/lead-control.mjs +104 -0
- package/hub/team/nativeProxy.mjs +9 -2
- package/hub/team/notify.mjs +293 -0
- package/hub/team/pane.mjs +1 -1
- package/hub/team/process-cleanup.mjs +342 -0
- package/hub/team/psmux.mjs +1 -1
- package/hub/team/remote-probe.mjs +276 -0
- package/hub/team/remote-session.mjs +296 -0
- package/hub/team/remote-watcher.mjs +478 -0
- package/hub/team/session-sync.mjs +169 -0
- package/hub/team/staleState.mjs +1 -1
- package/hub/team/tui-remote-adapter.mjs +393 -0
- package/hub/team/tui.mjs +206 -2
- package/hub/tools.mjs +94 -12
- package/hub/tray.mjs +1 -1
- package/hub/workers/codex-mcp.mjs +8 -2
- package/hub/workers/gemini-worker.mjs +2 -1
- package/package.json +1 -1
package/hub/store.mjs
CHANGED
|
@@ -1,56 +1,16 @@
|
|
|
1
1
|
// hub/store.mjs — SQLite 감사 로그/메타데이터 저장소
|
|
2
2
|
// 실시간 배달 큐는 router/pipe가 담당하고, SQLite는 재생/감사 용도로만 유지한다.
|
|
3
|
-
import { recalcConfidence } from '
|
|
3
|
+
import { recalcConfidence } from '@triflux/core/hub/reflexion.mjs';
|
|
4
4
|
import { readFileSync, mkdirSync } from 'node:fs';
|
|
5
5
|
import { join, dirname } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import { randomBytes } from 'node:crypto';
|
|
8
7
|
import { createRequire } from 'node:module';
|
|
8
|
+
import { uuidv7 } from '@triflux/core/hub/lib/uuidv7.mjs';
|
|
9
|
+
|
|
10
|
+
export { uuidv7 };
|
|
9
11
|
|
|
10
12
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
13
|
const require = createRequire(import.meta.url);
|
|
12
|
-
let _rndPool = Buffer.alloc(0), _rndOff = 0;
|
|
13
|
-
|
|
14
|
-
function pooledRandom(n) {
|
|
15
|
-
if (_rndOff + n > _rndPool.length) {
|
|
16
|
-
_rndPool = randomBytes(256);
|
|
17
|
-
_rndOff = 0;
|
|
18
|
-
}
|
|
19
|
-
const out = Buffer.from(_rndPool.subarray(_rndOff, _rndOff + n));
|
|
20
|
-
_rndOff += n;
|
|
21
|
-
return out;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** UUIDv7 생성 (RFC 9562, 단조 증가 보장) */
|
|
25
|
-
let _lastMs = 0n;
|
|
26
|
-
let _seq = 0;
|
|
27
|
-
export function uuidv7() {
|
|
28
|
-
let now = BigInt(Date.now());
|
|
29
|
-
if (now <= _lastMs) {
|
|
30
|
-
_seq++;
|
|
31
|
-
// _seq > 0xfff (4095): 시퀀스 공간 소진 시 타임스탬프를 1ms 앞당겨 단조 증가를 보장.
|
|
32
|
-
// 고처리량 환경에서는 타임스탬프가 실제 벽시계보다 앞서 드리프트될 수 있음 (설계상 의도).
|
|
33
|
-
if (_seq > 0xfff) {
|
|
34
|
-
now = _lastMs + 1n;
|
|
35
|
-
_seq = 0;
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
_seq = 0;
|
|
39
|
-
}
|
|
40
|
-
_lastMs = now;
|
|
41
|
-
const buf = pooledRandom(16);
|
|
42
|
-
buf[0] = Number((now >> 40n) & 0xffn);
|
|
43
|
-
buf[1] = Number((now >> 32n) & 0xffn);
|
|
44
|
-
buf[2] = Number((now >> 24n) & 0xffn);
|
|
45
|
-
buf[3] = Number((now >> 16n) & 0xffn);
|
|
46
|
-
buf[4] = Number((now >> 8n) & 0xffn);
|
|
47
|
-
buf[5] = Number(now & 0xffn);
|
|
48
|
-
buf[6] = ((_seq >> 8) & 0x0f) | 0x70;
|
|
49
|
-
buf[7] = _seq & 0xff;
|
|
50
|
-
buf[8] = (buf[8] & 0x3f) | 0x80;
|
|
51
|
-
const h = buf.toString('hex');
|
|
52
|
-
return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;
|
|
53
|
-
}
|
|
54
14
|
|
|
55
15
|
function parseJson(str, fallback = null) {
|
|
56
16
|
if (str == null) return fallback;
|
package/hub/team/backend.mjs
CHANGED
|
@@ -2,6 +2,8 @@ import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
|
|
5
|
+
import { publishLeadControl as publishLeadControlBridge } from "../../lead-control.mjs";
|
|
6
|
+
import { getTeamStatus as fetchTeamStatus, subscribeToLeadCommands as pullLeadCommands } from "../../session-sync.mjs";
|
|
5
7
|
import { HUB_PID_DIR, PKG_ROOT } from "./state-store.mjs";
|
|
6
8
|
export { nativeGetStatus } from "./native-control.mjs";
|
|
7
9
|
|
|
@@ -185,24 +187,41 @@ export async function fetchHubTaskList(state) {
|
|
|
185
187
|
export async function publishLeadControl(state, targetMember, command, reason = "") {
|
|
186
188
|
const hubBase = (state?.hubUrl || getDefaultHubUrl()).replace(/\/mcp$/, "");
|
|
187
189
|
const leadAgent = (state?.members || []).find((member) => member.role === "lead")?.agentId || "lead";
|
|
190
|
+
const targetAgent = typeof targetMember === "string" ? targetMember : targetMember?.agentId;
|
|
191
|
+
|
|
192
|
+
const result = await publishLeadControlBridge({
|
|
193
|
+
hubUrl: hubBase,
|
|
194
|
+
fromAgent: leadAgent,
|
|
195
|
+
toAgent: targetAgent,
|
|
196
|
+
command,
|
|
197
|
+
reason,
|
|
198
|
+
payload: {
|
|
199
|
+
issued_by: leadAgent,
|
|
200
|
+
issued_at: Date.now(),
|
|
201
|
+
},
|
|
202
|
+
});
|
|
188
203
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
return !!result?.ok;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export async function subscribeToLeadCommands(state, member, options = {}) {
|
|
208
|
+
const hubBase = (state?.hubUrl || getDefaultHubUrl()).replace(/\/mcp$/, "");
|
|
209
|
+
const fallbackAgentId = (state?.members || []).find((candidate) => candidate.role === "lead")?.agentId || null;
|
|
210
|
+
const agentId = typeof member === "string"
|
|
211
|
+
? member
|
|
212
|
+
: member?.agentId || options?.agentId || fallbackAgentId;
|
|
213
|
+
|
|
214
|
+
return await pullLeadCommands({
|
|
215
|
+
hubUrl: hubBase,
|
|
216
|
+
agentId,
|
|
217
|
+
...options,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export async function getTeamStatus(state, options = {}) {
|
|
222
|
+
const hubBase = (state?.hubUrl || getDefaultHubUrl()).replace(/\/mcp$/, "");
|
|
223
|
+
return await fetchTeamStatus({
|
|
224
|
+
hubUrl: hubBase,
|
|
225
|
+
...options,
|
|
226
|
+
});
|
|
208
227
|
}
|
|
@@ -5,7 +5,7 @@ import { spawn } from "node:child_process";
|
|
|
5
5
|
import { buildLeadPrompt, buildPrompt } from "../../orchestrator.mjs";
|
|
6
6
|
import { HUB_PID_DIR, PKG_ROOT } from "./state-store.mjs";
|
|
7
7
|
|
|
8
|
-
import { buildExecArgs } from "
|
|
8
|
+
import { buildExecArgs } from "@triflux/core/hub/codex-adapter.mjs";
|
|
9
9
|
|
|
10
10
|
export function buildNativeCliCommand(cli) {
|
|
11
11
|
switch (cli) {
|