triflux 10.2.1 → 10.3.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/README.md +236 -156
- package/hub/bridge.mjs +638 -290
- package/hub/codex-compat.mjs +1 -1
- package/hub/fullcycle.mjs +1 -1
- package/hub/intent.mjs +1 -0
- package/hub/lib/mcp-response-cache.mjs +205 -0
- package/hub/pipe.mjs +228 -119
- package/hub/reflexion.mjs +87 -13
- package/hub/research.mjs +1 -0
- package/hub/server.mjs +997 -611
- package/hub/team/conductor-registry.mjs +121 -0
- package/hub/team/conductor.mjs +256 -125
- package/hub/team/execution-mode.mjs +105 -0
- package/hub/team/headless.mjs +686 -252
- package/hub/team/lead-control.mjs +91 -4
- package/hub/team/mcp-selector.mjs +145 -0
- package/hub/team/session-sync.mjs +153 -6
- package/hub/team/swarm-hypervisor.mjs +208 -86
- package/hub/token-mode.mjs +1 -0
- package/hub/tools.mjs +474 -252
- package/package.json +5 -5
- package/scripts/codex-gateway-preflight.mjs +133 -0
- package/scripts/codex-mcp-gateway-sync.mjs +199 -0
- package/skills/star-prompt/SKILL.md +169 -69
- package/skills/tfx-setup/SKILL.md +124 -0
- package/skills/tfx-swarm/SKILL.md +124 -72
|
@@ -1,23 +1,35 @@
|
|
|
1
|
+
import { readState } from "../state.mjs";
|
|
2
|
+
|
|
1
3
|
const DEFAULT_TIMEOUT_MS = 2500;
|
|
2
4
|
const CONTROL_COMMAND_ALIASES = Object.freeze({
|
|
3
5
|
stop: "abort",
|
|
4
6
|
interrupt: "abort",
|
|
5
7
|
});
|
|
6
8
|
|
|
7
|
-
export const LEAD_CONTROL_COMMANDS = Object.freeze([
|
|
9
|
+
export const LEAD_CONTROL_COMMANDS = Object.freeze([
|
|
10
|
+
"pause",
|
|
11
|
+
"resume",
|
|
12
|
+
"abort",
|
|
13
|
+
"reassign",
|
|
14
|
+
]);
|
|
8
15
|
|
|
9
16
|
function resolveFetch(fetchImpl) {
|
|
10
17
|
if (typeof fetchImpl === "function") return fetchImpl;
|
|
11
|
-
if (typeof globalThis.fetch === "function")
|
|
18
|
+
if (typeof globalThis.fetch === "function")
|
|
19
|
+
return globalThis.fetch.bind(globalThis);
|
|
12
20
|
return null;
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
function normalizeHubBaseUrl(hubUrl) {
|
|
16
|
-
return String(hubUrl || "")
|
|
24
|
+
return String(hubUrl || "")
|
|
25
|
+
.replace(/\/+$/, "")
|
|
26
|
+
.replace(/\/mcp$/, "");
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
function normalizeCommand(command) {
|
|
20
|
-
const raw = String(command || "")
|
|
30
|
+
const raw = String(command || "")
|
|
31
|
+
.trim()
|
|
32
|
+
.toLowerCase();
|
|
21
33
|
if (!raw) return "";
|
|
22
34
|
return CONTROL_COMMAND_ALIASES[raw] || raw;
|
|
23
35
|
}
|
|
@@ -27,6 +39,39 @@ function safeAbortSignal(timeoutMs) {
|
|
|
27
39
|
return AbortSignal.timeout(timeoutMs);
|
|
28
40
|
}
|
|
29
41
|
|
|
42
|
+
function isPidAlive(pid) {
|
|
43
|
+
const resolvedPid = Number(pid);
|
|
44
|
+
if (!Number.isFinite(resolvedPid) || resolvedPid <= 0) return false;
|
|
45
|
+
try {
|
|
46
|
+
process.kill(resolvedPid, 0);
|
|
47
|
+
return true;
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function resolveHeadlessHubUrl() {
|
|
54
|
+
const stateUrl = normalizeHubBaseUrl(readState()?.url);
|
|
55
|
+
if (stateUrl) return stateUrl;
|
|
56
|
+
|
|
57
|
+
const envHubUrl = normalizeHubBaseUrl(process.env.TFX_HUB_URL);
|
|
58
|
+
if (envHubUrl) return envHubUrl;
|
|
59
|
+
|
|
60
|
+
const envPort = Number(process.env.TFX_HUB_PORT || "27888");
|
|
61
|
+
const port = Number.isFinite(envPort) && envPort > 0 ? envPort : 27888;
|
|
62
|
+
return `http://127.0.0.1:${port}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function hasLiveHubState() {
|
|
66
|
+
const state = readState();
|
|
67
|
+
return !!normalizeHubBaseUrl(state?.url) && isPidAlive(state?.pid);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function toHeadlessSessionAgentId(sessionName) {
|
|
71
|
+
const normalizedSessionName = String(sessionName || "").trim();
|
|
72
|
+
return normalizedSessionName ? `session:${normalizedSessionName}` : "";
|
|
73
|
+
}
|
|
74
|
+
|
|
30
75
|
function safeJson(res) {
|
|
31
76
|
return res.json().catch(() => ({}));
|
|
32
77
|
}
|
|
@@ -102,3 +147,45 @@ export async function publishLeadControl({
|
|
|
102
147
|
};
|
|
103
148
|
}
|
|
104
149
|
}
|
|
150
|
+
|
|
151
|
+
export async function publishHeadlessControl(
|
|
152
|
+
sessionName,
|
|
153
|
+
command,
|
|
154
|
+
targetWorker = "*",
|
|
155
|
+
) {
|
|
156
|
+
const sessionAgentId = toHeadlessSessionAgentId(sessionName);
|
|
157
|
+
if (!sessionAgentId) {
|
|
158
|
+
return {
|
|
159
|
+
ok: false,
|
|
160
|
+
noop: true,
|
|
161
|
+
error: "SESSION_NAME_REQUIRED",
|
|
162
|
+
command: String(command || "")
|
|
163
|
+
.trim()
|
|
164
|
+
.toLowerCase(),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!normalizeHubBaseUrl(process.env.TFX_HUB_URL) && !hasLiveHubState()) {
|
|
169
|
+
return {
|
|
170
|
+
ok: false,
|
|
171
|
+
noop: true,
|
|
172
|
+
error: "HUB_UNAVAILABLE",
|
|
173
|
+
command: String(command || "")
|
|
174
|
+
.trim()
|
|
175
|
+
.toLowerCase(),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return await publishLeadControl({
|
|
180
|
+
hubUrl: resolveHeadlessHubUrl(),
|
|
181
|
+
fromAgent: "lead",
|
|
182
|
+
toAgent: sessionAgentId,
|
|
183
|
+
command,
|
|
184
|
+
payload: {
|
|
185
|
+
session_name: String(sessionName || "").trim(),
|
|
186
|
+
target_worker: String(targetWorker || "*").trim() || "*",
|
|
187
|
+
issued_by: "lead",
|
|
188
|
+
issued_at: Date.now(),
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const TASK_TYPES = Object.freeze([
|
|
2
|
+
"implement",
|
|
3
|
+
"review",
|
|
4
|
+
"research",
|
|
5
|
+
"qa",
|
|
6
|
+
"ship",
|
|
7
|
+
"multi",
|
|
8
|
+
"swarm",
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const CLI_TYPES = Object.freeze(["codex", "gemini"]);
|
|
12
|
+
|
|
13
|
+
export const MCP_CATALOG = Object.freeze([
|
|
14
|
+
Object.freeze({
|
|
15
|
+
name: "filesystem",
|
|
16
|
+
purpose: "Read and write workspace files",
|
|
17
|
+
taskTypes: Object.freeze(["implement", "review", "qa", "ship"]),
|
|
18
|
+
cli: Object.freeze(["codex", "gemini"]),
|
|
19
|
+
}),
|
|
20
|
+
Object.freeze({
|
|
21
|
+
name: "github",
|
|
22
|
+
purpose: "Inspect PRs, issues, and release state",
|
|
23
|
+
taskTypes: Object.freeze(["review", "ship"]),
|
|
24
|
+
cli: Object.freeze(["codex"]),
|
|
25
|
+
}),
|
|
26
|
+
Object.freeze({
|
|
27
|
+
name: "browser",
|
|
28
|
+
purpose: "Research web pages and verify browser flows",
|
|
29
|
+
taskTypes: Object.freeze(["research", "qa"]),
|
|
30
|
+
cli: Object.freeze(["codex", "gemini"]),
|
|
31
|
+
}),
|
|
32
|
+
Object.freeze({
|
|
33
|
+
name: "context7",
|
|
34
|
+
purpose: "Fetch current SDK and API documentation",
|
|
35
|
+
taskTypes: Object.freeze(["implement", "review", "research"]),
|
|
36
|
+
cli: Object.freeze(["codex", "gemini"]),
|
|
37
|
+
}),
|
|
38
|
+
Object.freeze({
|
|
39
|
+
name: "exa",
|
|
40
|
+
purpose: "Search code examples and repositories",
|
|
41
|
+
taskTypes: Object.freeze(["research", "review"]),
|
|
42
|
+
cli: Object.freeze(["codex", "gemini"]),
|
|
43
|
+
}),
|
|
44
|
+
Object.freeze({
|
|
45
|
+
name: "tavily",
|
|
46
|
+
purpose: "Verify current external facts and search results",
|
|
47
|
+
taskTypes: Object.freeze(["research", "qa"]),
|
|
48
|
+
cli: Object.freeze(["gemini"]),
|
|
49
|
+
}),
|
|
50
|
+
Object.freeze({
|
|
51
|
+
name: "sequential-thinking",
|
|
52
|
+
purpose: "Structured reasoning for audits and review",
|
|
53
|
+
taskTypes: Object.freeze(["review"]),
|
|
54
|
+
cli: Object.freeze(["codex"]),
|
|
55
|
+
}),
|
|
56
|
+
Object.freeze({
|
|
57
|
+
name: "tfx-hub",
|
|
58
|
+
purpose: "Coordinate triflux hub, multi-agent, and swarm work",
|
|
59
|
+
taskTypes: Object.freeze(["ship", "multi", "swarm"]),
|
|
60
|
+
cli: Object.freeze(["codex", "gemini"]),
|
|
61
|
+
}),
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
function uniqueStrings(values = []) {
|
|
65
|
+
return [
|
|
66
|
+
...new Set(
|
|
67
|
+
(Array.isArray(values) ? values : [])
|
|
68
|
+
.map((value) => String(value ?? "").trim())
|
|
69
|
+
.filter(Boolean),
|
|
70
|
+
),
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function assertOneOf(label, value, allowed) {
|
|
75
|
+
if (!allowed.includes(value)) {
|
|
76
|
+
throw new TypeError(`${label} must be one of: ${allowed.join(", ")}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function selectMcpServers(opts = {}) {
|
|
81
|
+
const taskType = String(opts.taskType ?? "").trim();
|
|
82
|
+
const cli = String(opts.cli ?? "").trim();
|
|
83
|
+
assertOneOf("taskType", taskType, TASK_TYPES);
|
|
84
|
+
assertOneOf("cli", cli, CLI_TYPES);
|
|
85
|
+
|
|
86
|
+
const allCatalogNames = MCP_CATALOG.map((server) => server.name);
|
|
87
|
+
const available = new Set(
|
|
88
|
+
uniqueStrings(opts.available?.length ? opts.available : allCatalogNames),
|
|
89
|
+
);
|
|
90
|
+
const exclude = new Set(uniqueStrings(opts.exclude));
|
|
91
|
+
const force = uniqueStrings(opts.force);
|
|
92
|
+
|
|
93
|
+
const taskMatched = MCP_CATALOG.filter((server) =>
|
|
94
|
+
server.taskTypes.includes(taskType),
|
|
95
|
+
);
|
|
96
|
+
const compatible = taskMatched.filter((server) => server.cli.includes(cli));
|
|
97
|
+
const incompatible = taskMatched.filter(
|
|
98
|
+
(server) => !server.cli.includes(cli),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const selected = uniqueStrings([
|
|
102
|
+
...compatible
|
|
103
|
+
.map((server) => server.name)
|
|
104
|
+
.filter((name) => available.has(name) && !exclude.has(name)),
|
|
105
|
+
...force.filter((name) => available.has(name) && !exclude.has(name)),
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
const reasonParts = [
|
|
109
|
+
`task=${taskType}`,
|
|
110
|
+
`cli=${cli}`,
|
|
111
|
+
`selected=${selected.length ? selected.join(", ") : "none"}`,
|
|
112
|
+
];
|
|
113
|
+
if (incompatible.length) {
|
|
114
|
+
reasonParts.push(
|
|
115
|
+
`cli-filtered=${incompatible.map((server) => server.name).join(", ")}`,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
if (force.length) reasonParts.push(`forced=${force.join(", ")}`);
|
|
119
|
+
if (exclude.size) reasonParts.push(`excluded=${[...exclude].join(", ")}`);
|
|
120
|
+
if (opts.available?.length) {
|
|
121
|
+
reasonParts.push(`available=${[...available].join(", ")}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
selected,
|
|
126
|
+
reason: reasonParts.join(" | "),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function buildMcpArgs(servers = [], cli) {
|
|
131
|
+
const resolvedCli = String(cli ?? "").trim();
|
|
132
|
+
assertOneOf("cli", resolvedCli, CLI_TYPES);
|
|
133
|
+
|
|
134
|
+
const selected = uniqueStrings(servers);
|
|
135
|
+
if (!selected.length) return [];
|
|
136
|
+
|
|
137
|
+
if (resolvedCli === "codex") {
|
|
138
|
+
return selected.flatMap((server) => [
|
|
139
|
+
"-c",
|
|
140
|
+
`mcp_servers.${server}.enabled=true`,
|
|
141
|
+
]);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return ["--allowed-mcp-server-names", ...selected];
|
|
145
|
+
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import { readState } from "../state.mjs";
|
|
2
|
+
|
|
1
3
|
const DEFAULT_TIMEOUT_MS = 2500;
|
|
4
|
+
const DEFAULT_HEADLESS_POLL_MS = 1000;
|
|
2
5
|
|
|
3
6
|
function resolveFetch(fetchImpl) {
|
|
4
7
|
if (typeof fetchImpl === "function") return fetchImpl;
|
|
5
|
-
if (typeof globalThis.fetch === "function")
|
|
8
|
+
if (typeof globalThis.fetch === "function")
|
|
9
|
+
return globalThis.fetch.bind(globalThis);
|
|
6
10
|
return null;
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
function normalizeHubBaseUrl(hubUrl) {
|
|
10
|
-
return String(hubUrl || "")
|
|
14
|
+
return String(hubUrl || "")
|
|
15
|
+
.replace(/\/+$/, "")
|
|
16
|
+
.replace(/\/mcp$/, "");
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
function safeAbortSignal(timeoutMs) {
|
|
@@ -15,6 +21,55 @@ function safeAbortSignal(timeoutMs) {
|
|
|
15
21
|
return AbortSignal.timeout(timeoutMs);
|
|
16
22
|
}
|
|
17
23
|
|
|
24
|
+
function isPidAlive(pid) {
|
|
25
|
+
const resolvedPid = Number(pid);
|
|
26
|
+
if (!Number.isFinite(resolvedPid) || resolvedPid <= 0) return false;
|
|
27
|
+
try {
|
|
28
|
+
process.kill(resolvedPid, 0);
|
|
29
|
+
return true;
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function resolveHeadlessHubUrl(hubUrl) {
|
|
36
|
+
const normalized = normalizeHubBaseUrl(hubUrl);
|
|
37
|
+
if (normalized) return normalized;
|
|
38
|
+
|
|
39
|
+
const stateUrl = normalizeHubBaseUrl(readState()?.url);
|
|
40
|
+
if (stateUrl) return stateUrl;
|
|
41
|
+
|
|
42
|
+
const envHubUrl = normalizeHubBaseUrl(process.env.TFX_HUB_URL);
|
|
43
|
+
if (envHubUrl) return envHubUrl;
|
|
44
|
+
|
|
45
|
+
const envPort = Number(process.env.TFX_HUB_PORT || "27888");
|
|
46
|
+
const port = Number.isFinite(envPort) && envPort > 0 ? envPort : 27888;
|
|
47
|
+
return `http://127.0.0.1:${port}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function hasLiveHubState() {
|
|
51
|
+
const state = readState();
|
|
52
|
+
return !!normalizeHubBaseUrl(state?.url) && isPidAlive(state?.pid);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function toHeadlessSessionAgentId(sessionName) {
|
|
56
|
+
const normalizedSessionName = String(sessionName || "").trim();
|
|
57
|
+
return normalizedSessionName ? `session:${normalizedSessionName}` : "";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function dispatchHeadlessCommand(command, callbacks) {
|
|
61
|
+
const callbackMap = {
|
|
62
|
+
pause: callbacks.onPause,
|
|
63
|
+
resume: callbacks.onResume,
|
|
64
|
+
abort: callbacks.onAbort,
|
|
65
|
+
reassign: callbacks.onReassign,
|
|
66
|
+
};
|
|
67
|
+
const handler = callbackMap[command?.command];
|
|
68
|
+
if (typeof handler === "function") {
|
|
69
|
+
await handler(command);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
18
73
|
async function safeJson(res) {
|
|
19
74
|
try {
|
|
20
75
|
return await res.json();
|
|
@@ -24,8 +79,13 @@ async function safeJson(res) {
|
|
|
24
79
|
}
|
|
25
80
|
|
|
26
81
|
function normalizeLeadCommandMessage(message) {
|
|
27
|
-
const payload =
|
|
28
|
-
|
|
82
|
+
const payload =
|
|
83
|
+
message?.payload && typeof message.payload === "object"
|
|
84
|
+
? message.payload
|
|
85
|
+
: {};
|
|
86
|
+
const command = String(payload.command || "")
|
|
87
|
+
.trim()
|
|
88
|
+
.toLowerCase();
|
|
29
89
|
if (!command) return null;
|
|
30
90
|
return {
|
|
31
91
|
messageId: message.id || null,
|
|
@@ -79,7 +139,9 @@ export async function subscribeToLeadCommands({
|
|
|
79
139
|
});
|
|
80
140
|
|
|
81
141
|
const body = await safeJson(res);
|
|
82
|
-
const messages = Array.isArray(body?.data?.messages)
|
|
142
|
+
const messages = Array.isArray(body?.data?.messages)
|
|
143
|
+
? body.data.messages
|
|
144
|
+
: [];
|
|
83
145
|
const commands = messages
|
|
84
146
|
.filter((message) => message?.topic === "lead.control")
|
|
85
147
|
.map(normalizeLeadCommandMessage)
|
|
@@ -108,6 +170,90 @@ export async function subscribeToLeadCommands({
|
|
|
108
170
|
}
|
|
109
171
|
}
|
|
110
172
|
|
|
173
|
+
export function createHeadlessControlSubscriber(
|
|
174
|
+
sessionName,
|
|
175
|
+
{
|
|
176
|
+
onPause,
|
|
177
|
+
onResume,
|
|
178
|
+
onAbort,
|
|
179
|
+
onReassign,
|
|
180
|
+
hubUrl,
|
|
181
|
+
pollIntervalMs = DEFAULT_HEADLESS_POLL_MS,
|
|
182
|
+
maxMessages = 10,
|
|
183
|
+
autoAck = true,
|
|
184
|
+
timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
185
|
+
fetchImpl,
|
|
186
|
+
} = {},
|
|
187
|
+
) {
|
|
188
|
+
const sessionAgentId = toHeadlessSessionAgentId(sessionName);
|
|
189
|
+
if (!sessionAgentId) {
|
|
190
|
+
return { stop() {} };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const explicitHubUrl =
|
|
194
|
+
normalizeHubBaseUrl(hubUrl) || normalizeHubBaseUrl(process.env.TFX_HUB_URL);
|
|
195
|
+
if (!explicitHubUrl && !hasLiveHubState()) {
|
|
196
|
+
return { stop() {} };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const resolvedHubUrl = explicitHubUrl || resolveHeadlessHubUrl(hubUrl);
|
|
200
|
+
const callbacks = { onPause, onResume, onAbort, onReassign };
|
|
201
|
+
const intervalMs = Math.max(
|
|
202
|
+
50,
|
|
203
|
+
Number(pollIntervalMs) || DEFAULT_HEADLESS_POLL_MS,
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
let stopped = false;
|
|
207
|
+
let timer = null;
|
|
208
|
+
let pending = false;
|
|
209
|
+
|
|
210
|
+
const stop = () => {
|
|
211
|
+
stopped = true;
|
|
212
|
+
if (timer) clearTimeout(timer);
|
|
213
|
+
timer = null;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const scheduleNext = () => {
|
|
217
|
+
if (stopped) return;
|
|
218
|
+
timer = setTimeout(tick, intervalMs);
|
|
219
|
+
if (typeof timer?.unref === "function") timer.unref();
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const tick = async () => {
|
|
223
|
+
if (stopped || pending) {
|
|
224
|
+
scheduleNext();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
pending = true;
|
|
229
|
+
try {
|
|
230
|
+
const result = await subscribeToLeadCommands({
|
|
231
|
+
hubUrl: resolvedHubUrl,
|
|
232
|
+
agentId: sessionAgentId,
|
|
233
|
+
maxMessages,
|
|
234
|
+
autoAck,
|
|
235
|
+
timeoutMs,
|
|
236
|
+
fetchImpl,
|
|
237
|
+
onCommand: async (command) => {
|
|
238
|
+
await dispatchHeadlessCommand(command, callbacks);
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
if (!result?.ok && result?.error === "LEAD_COMMAND_SUBSCRIBE_FAILED") {
|
|
243
|
+
stop();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
} finally {
|
|
247
|
+
pending = false;
|
|
248
|
+
scheduleNext();
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
void tick();
|
|
253
|
+
|
|
254
|
+
return { stop };
|
|
255
|
+
}
|
|
256
|
+
|
|
111
257
|
export async function getTeamStatus({
|
|
112
258
|
hubUrl,
|
|
113
259
|
scope = "hub",
|
|
@@ -127,7 +273,8 @@ export async function getTeamStatus({
|
|
|
127
273
|
return { ok: false, error: "HUB_URL_REQUIRED" };
|
|
128
274
|
}
|
|
129
275
|
|
|
130
|
-
const normalizedMethod =
|
|
276
|
+
const normalizedMethod =
|
|
277
|
+
String(method || "GET").toUpperCase() === "POST" ? "POST" : "GET";
|
|
131
278
|
const statusScope = String(scope || "hub").trim() || "hub";
|
|
132
279
|
|
|
133
280
|
let endpoint = `${hubBase}/bridge/status`;
|