@triflux/core 10.1.0 → 10.26.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/hooks/agent-route-guard.mjs +14 -10
- package/hooks/cross-review-tracker.mjs +21 -8
- package/hooks/error-context.mjs +20 -8
- package/hooks/hook-adaptive-collector.mjs +18 -16
- package/hooks/hook-manager.mjs +93 -32
- package/hooks/hook-orchestrator.mjs +267 -35
- package/hooks/hook-registry.json +343 -256
- package/hooks/hooks.json +49 -1
- package/hooks/keyword-rules.json +191 -31
- package/hooks/lib/resolve-root.mjs +1 -1
- package/hooks/mcp-config-watcher.mjs +6 -2
- package/hooks/permission-safe-allow.mjs +233 -0
- package/hooks/pipeline-stop.mjs +369 -22
- package/hooks/post-tool-tips.mjs +306 -0
- package/hooks/pre-compact-snapshot.mjs +181 -0
- package/hooks/safety-guard.mjs +262 -34
- package/hooks/session-end-cleanup.mjs +345 -0
- package/hooks/session-start-fast.mjs +214 -0
- package/hooks/subagent-tracker.mjs +267 -0
- package/hooks/subagent-verifier.mjs +9 -4
- package/hub/account-broker.mjs +1036 -66
- package/hub/adaptive-diagnostic.mjs +75 -48
- package/hub/adaptive-inject.mjs +96 -58
- package/hub/adaptive-memory.mjs +156 -42
- package/hub/adaptive.mjs +60 -31
- package/hub/assign-callbacks.mjs +163 -126
- package/hub/bridge.mjs +1051 -290
- package/hub/cli-adapter-base.mjs +321 -97
- package/hub/codex-adapter.mjs +179 -93
- package/hub/codex-compat.mjs +4 -4
- package/hub/codex-preflight.mjs +113 -37
- package/hub/delegator/contracts.mjs +22 -21
- package/hub/delegator/index.mjs +14 -14
- package/hub/delegator/schema/delegator-tools.schema.json +1 -1
- package/hub/delegator/service.mjs +93 -64
- package/hub/delegator/tool-definitions.mjs +35 -35
- package/hub/dynamic-routing-engine.mjs +511 -0
- package/hub/fullcycle.mjs +34 -18
- package/hub/gemini-adapter.mjs +82 -108
- package/hub/hitl.mjs +202 -143
- package/hub/intent.mjs +167 -38
- package/hub/lib/bash-path.mjs +73 -0
- package/hub/lib/cache-guard.mjs +43 -17
- package/hub/lib/env-detect.mjs +145 -0
- package/hub/lib/hosts-compat.mjs +319 -0
- package/hub/lib/mcp-response-cache.mjs +239 -0
- package/hub/lib/memory-store.mjs +285 -111
- package/hub/lib/path-utils.mjs +165 -0
- package/hub/lib/phase-manager.mjs +493 -0
- package/hub/lib/process-utils.mjs +797 -104
- package/hub/lib/prompt-tmp.mjs +33 -0
- package/hub/lib/risk-tier.mjs +53 -0
- package/hub/lib/spawn-trace.mjs +561 -0
- package/hub/lib/ssh-command.mjs +44 -24
- package/hub/lib/ssh-retry.mjs +5 -1
- package/hub/lib/staged-file-detect.mjs +43 -0
- package/hub/lib/state-snapshot.mjs +293 -0
- package/hub/lib/tfx-route-args.mjs +309 -0
- package/hub/lib/timeline-adapter.mjs +190 -0
- package/hub/lib/trace-recorder.mjs +153 -0
- package/hub/lib/uuidv7.mjs +4 -3
- package/hub/memory-doctor.mjs +266 -106
- package/hub/middleware/quota-middleware.mjs +70 -0
- package/hub/middleware/request-logger.mjs +61 -34
- package/hub/paths.mjs +9 -9
- package/hub/pipeline/gates/confidence.mjs +34 -15
- package/hub/pipeline/gates/consensus.mjs +27 -15
- package/hub/pipeline/gates/index.mjs +7 -3
- package/hub/pipeline/gates/selfcheck.mjs +57 -19
- package/hub/pipeline/index.mjs +77 -42
- package/hub/pipeline/state.mjs +10 -10
- package/hub/pipeline/transitions.mjs +40 -23
- package/hub/platform.mjs +65 -48
- package/hub/quality/deslop.mjs +70 -49
- package/hub/reflexion.mjs +87 -13
- package/hub/research.mjs +33 -25
- package/hub/router.mjs +941 -791
- package/hub/routing/complexity.mjs +132 -29
- package/hub/routing/index.mjs +17 -12
- package/hub/routing/q-learning.mjs +78 -30
- package/hub/routing-snapshot.mjs +261 -0
- package/hub/session-fingerprint.mjs +127 -61
- package/hub/state.mjs +86 -44
- package/hub/team/claude-daemon-control.mjs +1130 -0
- package/hub/team/retry-state-machine.mjs +336 -0
- package/hub/token-mode.mjs +72 -71
- package/hub/workers/worker-utils.mjs +23 -17
- package/hud/colors.mjs +27 -9
- package/hud/constants.mjs +190 -27
- package/hud/context-monitor.mjs +133 -44
- package/hud/hud-qos-status.mjs +157 -50
- package/hud/mission-board.mjs +56 -0
- package/hud/providers/claude.mjs +398 -114
- package/hud/providers/codex.mjs +96 -21
- package/hud/providers/gemini.mjs +210 -52
- package/hud/renderers.mjs +440 -127
- package/hud/terminal.mjs +101 -31
- package/hud/utils.mjs +81 -39
- package/mesh/index.mjs +69 -0
- package/mesh/mesh-budget.mjs +137 -0
- package/mesh/mesh-heartbeat.mjs +100 -0
- package/mesh/mesh-protocol.mjs +96 -0
- package/mesh/mesh-queue.mjs +163 -0
- package/mesh/mesh-registry.mjs +78 -0
- package/mesh/mesh-router.mjs +77 -0
- package/package.json +5 -1
- package/scripts/lib/agent-json.mjs +27 -0
- package/scripts/lib/async.mjs +174 -0
- package/scripts/lib/claudemd-scanner.mjs +6 -1
- package/scripts/lib/cli-agy.mjs +62 -0
- package/scripts/lib/cli-claude.mjs +78 -0
- package/scripts/lib/cli-codex.mjs +199 -0
- package/scripts/lib/cli-gemini.mjs +37 -0
- package/scripts/lib/codex-recovery.sh +50 -0
- package/scripts/lib/context.mjs +3 -3
- package/scripts/lib/cross-review-utils.mjs +13 -5
- package/scripts/lib/doctor-env-checks.mjs +121 -0
- package/scripts/lib/dynamic-route-cli.mjs +107 -0
- package/scripts/lib/env-probe.mjs +58 -30
- package/scripts/lib/env.mjs +14 -0
- package/scripts/lib/gemini-profiles.mjs +44 -10
- package/scripts/lib/handoff.mjs +33 -17
- package/scripts/lib/hook-utils.mjs +8 -6
- package/scripts/lib/hub.mjs +48 -0
- package/scripts/lib/keyword-rules.mjs +49 -20
- package/scripts/lib/logger.mjs +24 -24
- package/scripts/lib/mcp-filter.mjs +391 -247
- package/scripts/lib/mcp-gateway-health-check.mjs +159 -0
- package/scripts/lib/mcp-gateway-servers.mjs +70 -0
- package/scripts/lib/mcp-gateway-wrapper-check.mjs +35 -0
- package/scripts/lib/mcp-guard-engine.mjs +1281 -115
- package/scripts/lib/mcp-health.mjs +773 -0
- package/scripts/lib/mcp-manifest.mjs +24 -14
- package/scripts/lib/mcp-server-catalog.mjs +355 -118
- package/scripts/lib/pid.mjs +63 -0
- package/scripts/lib/process-utils.mjs +26 -0
- package/scripts/lib/psmux-info.mjs +117 -12
- package/scripts/lib/quota.mjs +47 -0
- package/scripts/lib/remote-spawn-transfer.mjs +44 -14
- package/scripts/lib/skill-state.mjs +220 -0
- package/scripts/lib/skill-template.mjs +32 -7
- package/scripts/lib/team.mjs +75 -0
- package/scripts/lib/timeout.mjs +66 -0
- package/scripts/lib/tmp.mjs +26 -0
- package/scripts/lib/toml.mjs +113 -0
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
export const DELEGATOR_MCP_SERVER_INFO = Object.freeze({
|
|
2
|
-
name:
|
|
3
|
-
version:
|
|
2
|
+
name: "triflux-delegator",
|
|
3
|
+
version: "0.1.0",
|
|
4
4
|
});
|
|
5
5
|
|
|
6
6
|
export const DELEGATOR_TOOL_NAMES = Object.freeze({
|
|
7
|
-
delegate:
|
|
8
|
-
delegateReply:
|
|
9
|
-
status:
|
|
7
|
+
delegate: "delegate",
|
|
8
|
+
delegateReply: "delegate-reply",
|
|
9
|
+
status: "status",
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
export const DELEGATOR_PIPE_ACTIONS = Object.freeze({
|
|
13
|
-
delegate:
|
|
14
|
-
delegateReply:
|
|
15
|
-
status:
|
|
13
|
+
delegate: "delegator_delegate",
|
|
14
|
+
delegateReply: "delegator_reply",
|
|
15
|
+
status: "delegator_status",
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
export const DELEGATOR_JOB_STATUSES = Object.freeze([
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
"queued",
|
|
20
|
+
"running",
|
|
21
|
+
"waiting_reply",
|
|
22
|
+
"completed",
|
|
23
|
+
"failed",
|
|
24
24
|
]);
|
|
25
25
|
|
|
26
|
-
export const DELEGATOR_MODES = Object.freeze([
|
|
27
|
-
'sync',
|
|
28
|
-
'async',
|
|
29
|
-
]);
|
|
26
|
+
export const DELEGATOR_MODES = Object.freeze(["sync", "async"]);
|
|
30
27
|
|
|
31
28
|
export const DELEGATOR_PROVIDERS = Object.freeze([
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
"auto",
|
|
30
|
+
"codex",
|
|
31
|
+
"antigravity",
|
|
32
|
+
"gemini",
|
|
35
33
|
]);
|
|
36
34
|
|
|
37
|
-
export const DELEGATOR_SCHEMA_URL = new URL(
|
|
35
|
+
export const DELEGATOR_SCHEMA_URL = new URL(
|
|
36
|
+
"./schema/delegator-tools.schema.json",
|
|
37
|
+
import.meta.url,
|
|
38
|
+
);
|
package/hub/delegator/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export {
|
|
2
|
-
DELEGATOR_JOB_STATUSES,
|
|
3
|
-
DELEGATOR_MCP_SERVER_INFO,
|
|
4
|
-
DELEGATOR_MODES,
|
|
5
|
-
DELEGATOR_PIPE_ACTIONS,
|
|
6
|
-
DELEGATOR_PROVIDERS,
|
|
7
|
-
DELEGATOR_SCHEMA_URL,
|
|
8
|
-
DELEGATOR_TOOL_NAMES,
|
|
9
|
-
} from
|
|
10
|
-
export { DelegatorService } from
|
|
11
|
-
export {
|
|
12
|
-
getDelegatorMcpToolDefinitions,
|
|
13
|
-
loadDelegatorSchemaBundle,
|
|
14
|
-
} from
|
|
1
|
+
export {
|
|
2
|
+
DELEGATOR_JOB_STATUSES,
|
|
3
|
+
DELEGATOR_MCP_SERVER_INFO,
|
|
4
|
+
DELEGATOR_MODES,
|
|
5
|
+
DELEGATOR_PIPE_ACTIONS,
|
|
6
|
+
DELEGATOR_PROVIDERS,
|
|
7
|
+
DELEGATOR_SCHEMA_URL,
|
|
8
|
+
DELEGATOR_TOOL_NAMES,
|
|
9
|
+
} from "./contracts.mjs";
|
|
10
|
+
export { DelegatorService } from "./service.mjs";
|
|
11
|
+
export {
|
|
12
|
+
getDelegatorMcpToolDefinitions,
|
|
13
|
+
loadDelegatorSchemaBundle,
|
|
14
|
+
} from "./tool-definitions.mjs";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { randomUUID } from
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
DELEGATOR_JOB_STATUSES,
|
|
5
5
|
DELEGATOR_MODES,
|
|
6
6
|
DELEGATOR_PROVIDERS,
|
|
7
|
-
} from
|
|
8
|
-
import { getDelegatorMcpToolDefinitions } from
|
|
7
|
+
} from "./contracts.mjs";
|
|
8
|
+
import { getDelegatorMcpToolDefinitions } from "./tool-definitions.mjs";
|
|
9
9
|
|
|
10
10
|
function deepClone(value) {
|
|
11
11
|
if (value == null) return value;
|
|
@@ -19,6 +19,11 @@ function assertKnown(enumValues, value, fieldName) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
function normalizeProvider(provider = "auto") {
|
|
23
|
+
const value = provider || "auto";
|
|
24
|
+
return value === "gemini" ? "antigravity" : value;
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
export class DelegatorService {
|
|
23
28
|
constructor({
|
|
24
29
|
idFactory = randomUUID,
|
|
@@ -39,28 +44,28 @@ export class DelegatorService {
|
|
|
39
44
|
createJobSnapshot(input = {}) {
|
|
40
45
|
const timestamp = this.now().toISOString();
|
|
41
46
|
const jobId = input.job_id || this.idFactory();
|
|
42
|
-
const mode = input.mode ||
|
|
43
|
-
const providerRequested = input.provider
|
|
47
|
+
const mode = input.mode || "sync";
|
|
48
|
+
const providerRequested = normalizeProvider(input.provider);
|
|
44
49
|
|
|
45
|
-
assertKnown(DELEGATOR_MODES, mode,
|
|
46
|
-
assertKnown(DELEGATOR_PROVIDERS, providerRequested,
|
|
50
|
+
assertKnown(DELEGATOR_MODES, mode, "mode");
|
|
51
|
+
assertKnown(DELEGATOR_PROVIDERS, providerRequested, "provider");
|
|
47
52
|
|
|
48
53
|
return {
|
|
49
54
|
ok: true,
|
|
50
55
|
job_id: jobId,
|
|
51
|
-
status:
|
|
56
|
+
status: "queued",
|
|
52
57
|
mode,
|
|
53
58
|
provider_requested: providerRequested,
|
|
54
59
|
provider_resolved: null,
|
|
55
|
-
agent_type: input.agent_type ||
|
|
56
|
-
transport:
|
|
60
|
+
agent_type: input.agent_type || "executor",
|
|
61
|
+
transport: "resident-pending",
|
|
57
62
|
created_at: timestamp,
|
|
58
63
|
started_at: null,
|
|
59
64
|
updated_at: timestamp,
|
|
60
65
|
completed_at: null,
|
|
61
|
-
output:
|
|
62
|
-
stderr:
|
|
63
|
-
error:
|
|
66
|
+
output: "",
|
|
67
|
+
stderr: "",
|
|
68
|
+
error: "",
|
|
64
69
|
thread_id: input.thread_id || null,
|
|
65
70
|
session_key: input.session_key || null,
|
|
66
71
|
conversation_open: false,
|
|
@@ -69,9 +74,9 @@ export class DelegatorService {
|
|
|
69
74
|
|
|
70
75
|
recordJob(snapshot) {
|
|
71
76
|
if (!snapshot?.job_id) {
|
|
72
|
-
throw new Error(
|
|
77
|
+
throw new Error("job_id is required");
|
|
73
78
|
}
|
|
74
|
-
assertKnown(DELEGATOR_JOB_STATUSES, snapshot.status,
|
|
79
|
+
assertKnown(DELEGATOR_JOB_STATUSES, snapshot.status, "status");
|
|
75
80
|
this.jobs.set(snapshot.job_id, deepClone(snapshot));
|
|
76
81
|
return this.getStatusSnapshot(snapshot.job_id);
|
|
77
82
|
}
|
|
@@ -86,19 +91,20 @@ export class DelegatorService {
|
|
|
86
91
|
_normalizeInput(input = {}) {
|
|
87
92
|
return {
|
|
88
93
|
prompt: input.prompt,
|
|
89
|
-
provider: input.provider
|
|
90
|
-
mode: input.mode ||
|
|
91
|
-
agent_type: input.agent_type || input.agentType ||
|
|
94
|
+
provider: normalizeProvider(input.provider),
|
|
95
|
+
mode: input.mode || "sync",
|
|
96
|
+
agent_type: input.agent_type || input.agentType || "executor",
|
|
92
97
|
cwd: input.cwd || null,
|
|
93
98
|
timeout_ms: input.timeout_ms || input.timeoutMs || null,
|
|
94
99
|
session_key: input.session_key || input.sessionKey || null,
|
|
95
100
|
thread_id: input.thread_id || input.threadId || null,
|
|
96
101
|
reset_session: input.reset_session ?? input.resetSession ?? false,
|
|
97
|
-
mcp_profile: input.mcp_profile || input.mcpProfile ||
|
|
102
|
+
mcp_profile: input.mcp_profile || input.mcpProfile || "auto",
|
|
98
103
|
search_tool: input.search_tool || input.searchTool || null,
|
|
99
104
|
context_file: input.context_file || input.contextFile || null,
|
|
100
105
|
model: input.model || null,
|
|
101
|
-
developer_instructions:
|
|
106
|
+
developer_instructions:
|
|
107
|
+
input.developer_instructions || input.developerInstructions || null,
|
|
102
108
|
compact_prompt: input.compact_prompt || input.compactPrompt || null,
|
|
103
109
|
};
|
|
104
110
|
}
|
|
@@ -131,18 +137,22 @@ export class DelegatorService {
|
|
|
131
137
|
const ok = workerResult.ok !== false;
|
|
132
138
|
|
|
133
139
|
snapshot.ok = ok;
|
|
134
|
-
snapshot.status = workerResult.status || (ok ?
|
|
135
|
-
snapshot.provider_resolved =
|
|
140
|
+
snapshot.status = workerResult.status || (ok ? "completed" : "failed");
|
|
141
|
+
snapshot.provider_resolved =
|
|
142
|
+
workerResult.providerResolved || workerResult.provider_resolved || null;
|
|
136
143
|
snapshot.transport = workerResult.transport || snapshot.transport;
|
|
137
|
-
snapshot.output = workerResult.output ||
|
|
138
|
-
snapshot.stderr = workerResult.stderr ||
|
|
139
|
-
snapshot.error = workerResult.error ||
|
|
140
|
-
snapshot.thread_id =
|
|
141
|
-
|
|
142
|
-
snapshot.
|
|
144
|
+
snapshot.output = workerResult.output || "";
|
|
145
|
+
snapshot.stderr = workerResult.stderr || "";
|
|
146
|
+
snapshot.error = workerResult.error || "";
|
|
147
|
+
snapshot.thread_id =
|
|
148
|
+
workerResult.threadId || workerResult.thread_id || null;
|
|
149
|
+
snapshot.session_key =
|
|
150
|
+
workerResult.sessionKey || workerResult.session_key || null;
|
|
151
|
+
snapshot.conversation_open =
|
|
152
|
+
workerResult.conversationOpen ?? workerResult.conversation_open ?? false;
|
|
143
153
|
snapshot.started_at = snapshot.started_at || timestamp;
|
|
144
154
|
snapshot.updated_at = timestamp;
|
|
145
|
-
if (snapshot.status ===
|
|
155
|
+
if (snapshot.status === "completed" || snapshot.status === "failed") {
|
|
146
156
|
snapshot.completed_at = timestamp;
|
|
147
157
|
}
|
|
148
158
|
|
|
@@ -155,7 +165,7 @@ export class DelegatorService {
|
|
|
155
165
|
if (snapshot) {
|
|
156
166
|
const timestamp = this.now().toISOString();
|
|
157
167
|
snapshot.ok = false;
|
|
158
|
-
snapshot.status =
|
|
168
|
+
snapshot.status = "failed";
|
|
159
169
|
snapshot.error = error;
|
|
160
170
|
snapshot.updated_at = timestamp;
|
|
161
171
|
snapshot.completed_at = timestamp;
|
|
@@ -169,19 +179,19 @@ export class DelegatorService {
|
|
|
169
179
|
const timestamp = this.now().toISOString();
|
|
170
180
|
return {
|
|
171
181
|
ok: false,
|
|
172
|
-
job_id: jobId ||
|
|
173
|
-
status:
|
|
174
|
-
mode:
|
|
175
|
-
provider_requested:
|
|
182
|
+
job_id: jobId || "unknown",
|
|
183
|
+
status: "failed",
|
|
184
|
+
mode: "sync",
|
|
185
|
+
provider_requested: "auto",
|
|
176
186
|
provider_resolved: null,
|
|
177
|
-
agent_type:
|
|
178
|
-
transport:
|
|
187
|
+
agent_type: "executor",
|
|
188
|
+
transport: "resident-pending",
|
|
179
189
|
created_at: timestamp,
|
|
180
190
|
started_at: null,
|
|
181
191
|
updated_at: timestamp,
|
|
182
192
|
completed_at: timestamp,
|
|
183
|
-
output:
|
|
184
|
-
stderr:
|
|
193
|
+
output: "",
|
|
194
|
+
stderr: "",
|
|
185
195
|
error,
|
|
186
196
|
thread_id: null,
|
|
187
197
|
session_key: null,
|
|
@@ -194,15 +204,19 @@ export class DelegatorService {
|
|
|
194
204
|
async delegate(input = {}) {
|
|
195
205
|
const normalized = this._normalizeInput(input);
|
|
196
206
|
|
|
197
|
-
if (
|
|
198
|
-
|
|
207
|
+
if (
|
|
208
|
+
!normalized.prompt ||
|
|
209
|
+
typeof normalized.prompt !== "string" ||
|
|
210
|
+
!normalized.prompt.trim()
|
|
211
|
+
) {
|
|
212
|
+
return this._errorSnapshot(null, "prompt is required");
|
|
199
213
|
}
|
|
200
214
|
|
|
201
215
|
const snapshot = this.createJobSnapshot(normalized);
|
|
202
216
|
this.recordJob(snapshot);
|
|
203
217
|
|
|
204
218
|
if (!this.worker) {
|
|
205
|
-
return this._failJob(snapshot.job_id,
|
|
219
|
+
return this._failJob(snapshot.job_id, "worker가 설정되지 않았습니다");
|
|
206
220
|
}
|
|
207
221
|
|
|
208
222
|
const workerArgs = this._toWorkerArgs(normalized);
|
|
@@ -218,44 +232,53 @@ export class DelegatorService {
|
|
|
218
232
|
|
|
219
233
|
return this._applyWorkerResult(snapshot.job_id, workerResult);
|
|
220
234
|
} catch (err) {
|
|
221
|
-
return this._failJob(
|
|
235
|
+
return this._failJob(
|
|
236
|
+
snapshot.job_id,
|
|
237
|
+
err instanceof Error ? err.message : String(err),
|
|
238
|
+
);
|
|
222
239
|
}
|
|
223
240
|
}
|
|
224
241
|
|
|
225
242
|
async reply(input = {}) {
|
|
226
243
|
const jobId = input.job_id || input.jobId;
|
|
227
244
|
if (!jobId) {
|
|
228
|
-
return this._errorSnapshot(
|
|
245
|
+
return this._errorSnapshot("unknown", "job_id is required");
|
|
229
246
|
}
|
|
230
247
|
|
|
231
248
|
const snapshot = this.jobs.get(jobId);
|
|
232
249
|
if (!snapshot) {
|
|
233
|
-
return this._errorSnapshot(jobId,
|
|
250
|
+
return this._errorSnapshot(jobId, "job not found");
|
|
234
251
|
}
|
|
235
252
|
|
|
236
253
|
if (!snapshot.conversation_open) {
|
|
237
|
-
return this._failJob(jobId,
|
|
254
|
+
return this._failJob(jobId, "conversation is not open");
|
|
238
255
|
}
|
|
239
256
|
|
|
240
257
|
if (!this.worker) {
|
|
241
|
-
return this._failJob(jobId,
|
|
258
|
+
return this._failJob(jobId, "worker가 설정되지 않았습니다");
|
|
242
259
|
}
|
|
243
260
|
|
|
244
261
|
const workerJobId = this._workerJobMap.get(jobId);
|
|
245
262
|
if (!workerJobId) {
|
|
246
|
-
return this._failJob(jobId,
|
|
263
|
+
return this._failJob(jobId, "worker job 매핑을 찾을 수 없습니다");
|
|
247
264
|
}
|
|
248
265
|
|
|
249
266
|
try {
|
|
250
|
-
const workerResult = await this.worker.reply(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
267
|
+
const workerResult = await this.worker.reply(
|
|
268
|
+
{
|
|
269
|
+
job_id: workerJobId,
|
|
270
|
+
reply: input.reply,
|
|
271
|
+
done: input.done ?? false,
|
|
272
|
+
},
|
|
273
|
+
null,
|
|
274
|
+
);
|
|
255
275
|
|
|
256
276
|
return this._applyWorkerResult(jobId, workerResult);
|
|
257
277
|
} catch (err) {
|
|
258
|
-
return this._failJob(
|
|
278
|
+
return this._failJob(
|
|
279
|
+
jobId,
|
|
280
|
+
err instanceof Error ? err.message : String(err),
|
|
281
|
+
);
|
|
259
282
|
}
|
|
260
283
|
}
|
|
261
284
|
|
|
@@ -267,20 +290,20 @@ export class DelegatorService {
|
|
|
267
290
|
const timestamp = this.now().toISOString();
|
|
268
291
|
return {
|
|
269
292
|
ok: false,
|
|
270
|
-
job_id: resolvedId ||
|
|
271
|
-
status:
|
|
272
|
-
mode:
|
|
273
|
-
provider_requested:
|
|
293
|
+
job_id: resolvedId || "unknown-job",
|
|
294
|
+
status: "failed",
|
|
295
|
+
mode: "async",
|
|
296
|
+
provider_requested: "auto",
|
|
274
297
|
provider_resolved: null,
|
|
275
|
-
agent_type:
|
|
276
|
-
transport:
|
|
298
|
+
agent_type: "executor",
|
|
299
|
+
transport: "resident-pending",
|
|
277
300
|
created_at: timestamp,
|
|
278
301
|
started_at: null,
|
|
279
302
|
updated_at: timestamp,
|
|
280
303
|
completed_at: null,
|
|
281
|
-
output:
|
|
282
|
-
stderr:
|
|
283
|
-
error:
|
|
304
|
+
output: "",
|
|
305
|
+
stderr: "",
|
|
306
|
+
error: "job not found",
|
|
284
307
|
thread_id: null,
|
|
285
308
|
session_key: null,
|
|
286
309
|
conversation_open: false,
|
|
@@ -288,11 +311,17 @@ export class DelegatorService {
|
|
|
288
311
|
}
|
|
289
312
|
|
|
290
313
|
// running/queued 상태이면 worker에서 최신 상태 갱신
|
|
291
|
-
if (
|
|
314
|
+
if (
|
|
315
|
+
this.worker &&
|
|
316
|
+
(snapshot.status === "running" || snapshot.status === "queued")
|
|
317
|
+
) {
|
|
292
318
|
const workerJobId = this._workerJobMap.get(resolvedId);
|
|
293
319
|
if (workerJobId) {
|
|
294
320
|
try {
|
|
295
|
-
const workerResult = await this.worker.getJobStatus(
|
|
321
|
+
const workerResult = await this.worker.getJobStatus(
|
|
322
|
+
workerJobId,
|
|
323
|
+
null,
|
|
324
|
+
);
|
|
296
325
|
if (workerResult && workerResult.ok !== undefined) {
|
|
297
326
|
return this._applyWorkerResult(resolvedId, workerResult);
|
|
298
327
|
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { readFileSync } from
|
|
2
|
-
|
|
3
|
-
import { DELEGATOR_SCHEMA_URL } from
|
|
4
|
-
|
|
5
|
-
let schemaBundleCache = null;
|
|
6
|
-
|
|
7
|
-
function deepClone(value) {
|
|
8
|
-
if (value == null) return value;
|
|
9
|
-
return JSON.parse(JSON.stringify(value));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function loadDelegatorSchemaBundle() {
|
|
13
|
-
if (schemaBundleCache) {
|
|
14
|
-
return schemaBundleCache;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
schemaBundleCache = JSON.parse(readFileSync(DELEGATOR_SCHEMA_URL,
|
|
18
|
-
return schemaBundleCache;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getDelegatorMcpToolDefinitions() {
|
|
22
|
-
const bundle = loadDelegatorSchemaBundle();
|
|
23
|
-
const defs = bundle.$defs || {};
|
|
24
|
-
const tools = Array.isArray(bundle[
|
|
25
|
-
? bundle[
|
|
26
|
-
: [];
|
|
27
|
-
|
|
28
|
-
return tools.map((tool) => ({
|
|
29
|
-
name: tool.name,
|
|
30
|
-
description: tool.description,
|
|
31
|
-
inputSchema: deepClone(defs[tool.inputSchemaDef]),
|
|
32
|
-
outputSchema: deepClone(defs[tool.outputSchemaDef]),
|
|
33
|
-
pipeAction: tool.pipeAction,
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
import { DELEGATOR_SCHEMA_URL } from "./contracts.mjs";
|
|
4
|
+
|
|
5
|
+
let schemaBundleCache = null;
|
|
6
|
+
|
|
7
|
+
function deepClone(value) {
|
|
8
|
+
if (value == null) return value;
|
|
9
|
+
return JSON.parse(JSON.stringify(value));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function loadDelegatorSchemaBundle() {
|
|
13
|
+
if (schemaBundleCache) {
|
|
14
|
+
return schemaBundleCache;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
schemaBundleCache = JSON.parse(readFileSync(DELEGATOR_SCHEMA_URL, "utf8"));
|
|
18
|
+
return schemaBundleCache;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getDelegatorMcpToolDefinitions() {
|
|
22
|
+
const bundle = loadDelegatorSchemaBundle();
|
|
23
|
+
const defs = bundle.$defs || {};
|
|
24
|
+
const tools = Array.isArray(bundle["x-triflux-mcp-tools"])
|
|
25
|
+
? bundle["x-triflux-mcp-tools"]
|
|
26
|
+
: [];
|
|
27
|
+
|
|
28
|
+
return tools.map((tool) => ({
|
|
29
|
+
name: tool.name,
|
|
30
|
+
description: tool.description,
|
|
31
|
+
inputSchema: deepClone(defs[tool.inputSchemaDef]),
|
|
32
|
+
outputSchema: deepClone(defs[tool.outputSchemaDef]),
|
|
33
|
+
pipeAction: tool.pipeAction,
|
|
34
|
+
}));
|
|
35
|
+
}
|