@winmatrix/daemon 0.2.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 +59 -0
- package/bin/winmatrix-daemon.js +6 -0
- package/dist/core/AgentProcessManager.d.ts +99 -0
- package/dist/core/AgentProcessManager.d.ts.map +1 -0
- package/dist/core/AgentProcessManager.js +292 -0
- package/dist/core/AgentProcessManager.js.map +1 -0
- package/dist/core/ConfigLoader.d.ts +92 -0
- package/dist/core/ConfigLoader.d.ts.map +1 -0
- package/dist/core/ConfigLoader.js +240 -0
- package/dist/core/ConfigLoader.js.map +1 -0
- package/dist/core/DaemonFileLogger.d.ts +34 -0
- package/dist/core/DaemonFileLogger.d.ts.map +1 -0
- package/dist/core/DaemonFileLogger.js +157 -0
- package/dist/core/DaemonFileLogger.js.map +1 -0
- package/dist/core/DaemonLifecycle.d.ts +22 -0
- package/dist/core/DaemonLifecycle.d.ts.map +1 -0
- package/dist/core/DaemonLifecycle.js +155 -0
- package/dist/core/DaemonLifecycle.js.map +1 -0
- package/dist/core/DiagnosticsServer.d.ts +28 -0
- package/dist/core/DiagnosticsServer.d.ts.map +1 -0
- package/dist/core/DiagnosticsServer.js +155 -0
- package/dist/core/DiagnosticsServer.js.map +1 -0
- package/dist/core/InstallationId.d.ts +14 -0
- package/dist/core/InstallationId.d.ts.map +1 -0
- package/dist/core/InstallationId.js +50 -0
- package/dist/core/InstallationId.js.map +1 -0
- package/dist/core/RuntimeAvailabilityReporter.d.ts +27 -0
- package/dist/core/RuntimeAvailabilityReporter.d.ts.map +1 -0
- package/dist/core/RuntimeAvailabilityReporter.js +79 -0
- package/dist/core/RuntimeAvailabilityReporter.js.map +1 -0
- package/dist/core/WorkspaceScanner.d.ts +45 -0
- package/dist/core/WorkspaceScanner.d.ts.map +1 -0
- package/dist/core/WorkspaceScanner.js +166 -0
- package/dist/core/WorkspaceScanner.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +238 -0
- package/dist/index.js.map +1 -0
- package/dist/wrapper/AgentWrapper.d.ts +23 -0
- package/dist/wrapper/AgentWrapper.d.ts.map +1 -0
- package/dist/wrapper/AgentWrapper.js +873 -0
- package/dist/wrapper/AgentWrapper.js.map +1 -0
- package/dist/wrapper/ClaudeStreamParser.d.ts +63 -0
- package/dist/wrapper/ClaudeStreamParser.d.ts.map +1 -0
- package/dist/wrapper/ClaudeStreamParser.js +104 -0
- package/dist/wrapper/ClaudeStreamParser.js.map +1 -0
- package/dist/wrapper/supportedAgentTypes.d.ts +7 -0
- package/dist/wrapper/supportedAgentTypes.d.ts.map +1 -0
- package/dist/wrapper/supportedAgentTypes.js +6 -0
- package/dist/wrapper/supportedAgentTypes.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,873 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated 方案 B 下不再使用(adapter 在 daemon 进程内直接运行,不再 spawn 子进程)。
|
|
3
|
+
* 保留供未来 multiprocess 模式参考,所有维护性修改应在此注明原因。
|
|
4
|
+
*
|
|
5
|
+
* Agent Wrapper - Daemon 子进程入口
|
|
6
|
+
*
|
|
7
|
+
* 由 Daemon 通过 agent.create 信令 spawn 启动。
|
|
8
|
+
* 通过 stdin/stdout JSON 帧与 Daemon 通信,Daemon 负责通过 WS 多路复用转发给 Server。
|
|
9
|
+
*
|
|
10
|
+
* 协议(stdin/stdout 均为 JSON Lines):
|
|
11
|
+
* stdin: {"type":"fwd","data":<Server 发来的帧>}
|
|
12
|
+
* stdout: {"type":"fwd","agentId":"...","data":<发往 Server 的帧>}
|
|
13
|
+
* stdout: {"type":"event","event":"agent.ready","payload":{...}}
|
|
14
|
+
* stdout: {"type":"event","event":"agent.stopped","payload":{...}}
|
|
15
|
+
* stdout: {"type":"event","event":"agent.error","payload":{...}}
|
|
16
|
+
*
|
|
17
|
+
* 任务模型:按 agentType 分发到不同执行模式:
|
|
18
|
+
* claude-code → spawn claude --print --output-format stream-json ...
|
|
19
|
+
* hermes → fetch() POST 到 HTTP endpoint
|
|
20
|
+
* default → spawn(runtime, ['--print', '--output-format', 'json', input])
|
|
21
|
+
*/
|
|
22
|
+
import { spawn } from 'node:child_process';
|
|
23
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
24
|
+
import { join } from 'node:path';
|
|
25
|
+
import { homedir } from 'node:os';
|
|
26
|
+
import { randomUUID } from 'node:crypto';
|
|
27
|
+
import { unwrapOpenClawPayloads } from '@winmatrix/agent-sdk';
|
|
28
|
+
import { parseClaudeLine, splitLines } from './ClaudeStreamParser.js';
|
|
29
|
+
import { scanWorkDir, detectRuntimeInfo } from '../core/WorkspaceScanner.js';
|
|
30
|
+
/* ── State ── */
|
|
31
|
+
let config = null;
|
|
32
|
+
const runningTasks = new Map();
|
|
33
|
+
/* ── Helpers ── */
|
|
34
|
+
function send(frame) {
|
|
35
|
+
process.stdout.write(JSON.stringify(frame) + '\n');
|
|
36
|
+
}
|
|
37
|
+
function parseStdin(line) {
|
|
38
|
+
try {
|
|
39
|
+
const parsed = JSON.parse(line);
|
|
40
|
+
if (parsed && typeof parsed === 'object') {
|
|
41
|
+
// Handle tool_result frames from daemon (Tool Proxy Fallback)
|
|
42
|
+
if (parsed.type === 'tool_result') {
|
|
43
|
+
handleToolResult(parsed);
|
|
44
|
+
return null; // Not a server frame, don't forward
|
|
45
|
+
}
|
|
46
|
+
if (parsed.type === 'fwd') {
|
|
47
|
+
return parsed;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// ignore malformed lines
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function sendTaskError(taskId, error) {
|
|
57
|
+
if (!config)
|
|
58
|
+
return;
|
|
59
|
+
send({
|
|
60
|
+
type: 'fwd',
|
|
61
|
+
agentId: config.agentId,
|
|
62
|
+
data: {
|
|
63
|
+
type: 'event',
|
|
64
|
+
event: 'task.error',
|
|
65
|
+
payload: { taskId, error },
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function sendTaskDelta(taskId, content, meta) {
|
|
70
|
+
if (!config)
|
|
71
|
+
return;
|
|
72
|
+
const payload = { taskId, content };
|
|
73
|
+
if (meta)
|
|
74
|
+
payload.meta = meta;
|
|
75
|
+
send({
|
|
76
|
+
type: 'fwd',
|
|
77
|
+
agentId: config.agentId,
|
|
78
|
+
data: {
|
|
79
|
+
type: 'event',
|
|
80
|
+
event: 'task.delta',
|
|
81
|
+
payload,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function sendTaskComplete(taskId, result, sessionId, usage) {
|
|
86
|
+
if (!config)
|
|
87
|
+
return;
|
|
88
|
+
const payload = { taskId, result };
|
|
89
|
+
if (sessionId)
|
|
90
|
+
payload.sessionId = sessionId;
|
|
91
|
+
if (usage)
|
|
92
|
+
payload.usage = usage;
|
|
93
|
+
send({
|
|
94
|
+
type: 'fwd',
|
|
95
|
+
agentId: config.agentId,
|
|
96
|
+
data: {
|
|
97
|
+
type: 'event',
|
|
98
|
+
event: 'task.complete',
|
|
99
|
+
payload,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function cleanupTask(taskId) {
|
|
104
|
+
const entry = runningTasks.get(taskId);
|
|
105
|
+
if (!entry)
|
|
106
|
+
return;
|
|
107
|
+
runningTasks.delete(taskId);
|
|
108
|
+
}
|
|
109
|
+
/* ── Task Routing ── */
|
|
110
|
+
function routeTask(task) {
|
|
111
|
+
if (!config)
|
|
112
|
+
return;
|
|
113
|
+
const taskId = task.taskId;
|
|
114
|
+
if (runningTasks.has(taskId)) {
|
|
115
|
+
sendTaskError(taskId, 'Task already running');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
switch (config.agentType) {
|
|
119
|
+
case 'claude-code':
|
|
120
|
+
spawnClaudeCodeTask(task);
|
|
121
|
+
break;
|
|
122
|
+
case 'hermes':
|
|
123
|
+
spawnHermesTask(task);
|
|
124
|
+
break;
|
|
125
|
+
case 'openclaw':
|
|
126
|
+
spawnOpenClawTask(task);
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
spawnGenericTask(task);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/* ── Claude Code Task ── */
|
|
134
|
+
/**
|
|
135
|
+
* 在 workDir 下生成 .claude/mcp.json 配置,让 Claude Code 能通过 MCP Bridge 调用 WinMatrix 工具。
|
|
136
|
+
* 如果 .claude/mcp.json 已存在,使用 mcp.winmatrix.json 并通过 --mcp-config 指定。
|
|
137
|
+
*/
|
|
138
|
+
function generateClaudeMcpConfig(mcpBridgeUrl, mcpApiKey, workDir) {
|
|
139
|
+
const mcpConfig = {
|
|
140
|
+
mcpServers: {
|
|
141
|
+
winmatrix: {
|
|
142
|
+
type: 'http',
|
|
143
|
+
url: mcpBridgeUrl,
|
|
144
|
+
...(mcpApiKey ? { headers: { Authorization: `Bearer ${mcpApiKey}` } } : {}),
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
const configDir = workDir ? join(workDir, '.claude') : join(homedir(), '.claude');
|
|
149
|
+
const primaryPath = join(configDir, 'mcp.json');
|
|
150
|
+
const fallbackPath = join(configDir, 'mcp.winmatrix.json');
|
|
151
|
+
try {
|
|
152
|
+
if (!existsSync(configDir)) {
|
|
153
|
+
mkdirSync(configDir, { recursive: true });
|
|
154
|
+
}
|
|
155
|
+
if (existsSync(primaryPath)) {
|
|
156
|
+
writeFileSync(fallbackPath, JSON.stringify(mcpConfig, null, 2), 'utf-8');
|
|
157
|
+
return ['--mcp-config', fallbackPath];
|
|
158
|
+
}
|
|
159
|
+
writeFileSync(primaryPath, JSON.stringify(mcpConfig, null, 2), 'utf-8');
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
console.warn(`MCP 配置写入失败: ${err instanceof Error ? err.message : String(err)}`);
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const CLAUDE_BASE_ARGS = [
|
|
168
|
+
'--print',
|
|
169
|
+
'--verbose',
|
|
170
|
+
'--input-format', 'stream-json',
|
|
171
|
+
'--output-format', 'stream-json',
|
|
172
|
+
'--include-partial-messages',
|
|
173
|
+
];
|
|
174
|
+
function spawnClaudeCodeTask(task) {
|
|
175
|
+
if (!config)
|
|
176
|
+
return;
|
|
177
|
+
const taskId = task.taskId;
|
|
178
|
+
const workDir = task.workDir ?? config.workDir;
|
|
179
|
+
const claude = task.claude ?? {};
|
|
180
|
+
// Validate workDir
|
|
181
|
+
if (workDir && !existsSync(workDir)) {
|
|
182
|
+
sendTaskError(taskId, `Work directory does not exist: ${workDir}`);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// Assemble CLI args
|
|
186
|
+
const args = [...CLAUDE_BASE_ARGS];
|
|
187
|
+
// Permission mode (from task config, default 'auto')
|
|
188
|
+
const permissionMode = claude.permissionMode ?? 'bypassPermissions';
|
|
189
|
+
args.push('--permission-mode', permissionMode);
|
|
190
|
+
// workDir → --add-dir
|
|
191
|
+
if (workDir) {
|
|
192
|
+
args.push('--add-dir', workDir);
|
|
193
|
+
}
|
|
194
|
+
// Session management: oneshot skips --session-id entirely
|
|
195
|
+
const isOneshot = task.mode === 'oneshot';
|
|
196
|
+
let sessionId;
|
|
197
|
+
if (!isOneshot) {
|
|
198
|
+
if (claude.forkSession) {
|
|
199
|
+
sessionId = randomUUID();
|
|
200
|
+
args.push('--session-id', sessionId);
|
|
201
|
+
}
|
|
202
|
+
else if (claude.resumeSession && claude.sessionId) {
|
|
203
|
+
sessionId = claude.sessionId;
|
|
204
|
+
args.push('--resume', sessionId);
|
|
205
|
+
}
|
|
206
|
+
else if (claude.sessionId) {
|
|
207
|
+
sessionId = claude.sessionId;
|
|
208
|
+
args.push('--session-id', sessionId);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
sessionId = randomUUID();
|
|
212
|
+
args.push('--session-id', sessionId);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// Tool restriction
|
|
216
|
+
if (claude.tools && claude.tools.length > 0) {
|
|
217
|
+
args.push('--allowedTools', claude.tools.join(','));
|
|
218
|
+
}
|
|
219
|
+
if (claude.disallowedTools && claude.disallowedTools.length > 0) {
|
|
220
|
+
args.push('--disallowedTools', claude.disallowedTools.join(','));
|
|
221
|
+
}
|
|
222
|
+
// Budget
|
|
223
|
+
if (claude.maxBudgetUsd !== undefined) {
|
|
224
|
+
args.push('--max-budget-usd', String(claude.maxBudgetUsd));
|
|
225
|
+
}
|
|
226
|
+
// System prompt: task.systemPrompt 优先于 claude.systemPrompt
|
|
227
|
+
const effectiveSystemPrompt = task.systemPrompt ?? claude.systemPrompt;
|
|
228
|
+
if (effectiveSystemPrompt) {
|
|
229
|
+
args.push('--append-system-prompt', effectiveSystemPrompt);
|
|
230
|
+
}
|
|
231
|
+
// MCP Bridge 配置:在 workDir 下生成 .claude/mcp.json 或 mcp.winmatrix.json
|
|
232
|
+
if (config.mcpBridgeUrl) {
|
|
233
|
+
const effectiveMcpKey = task.mcpToken ?? config.mcpApiKey;
|
|
234
|
+
const mcpArgs = generateClaudeMcpConfig(config.mcpBridgeUrl, effectiveMcpKey, workDir);
|
|
235
|
+
if (mcpArgs) {
|
|
236
|
+
args.push(...mcpArgs);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// Build env
|
|
240
|
+
const env = {
|
|
241
|
+
...process.env,
|
|
242
|
+
WINMATRIX_AGENT_ID: config.agentId,
|
|
243
|
+
WINMATRIX_API_KEY: config.apiKey,
|
|
244
|
+
WINMATRIX_AGENT_NAME: config.name,
|
|
245
|
+
WINMATRIX_AGENT_TYPE: config.agentType,
|
|
246
|
+
WINMATRIX_TASK_ID: taskId,
|
|
247
|
+
...task.env,
|
|
248
|
+
};
|
|
249
|
+
let proc;
|
|
250
|
+
try {
|
|
251
|
+
proc = spawn(config.runtime, args, {
|
|
252
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
253
|
+
env,
|
|
254
|
+
cwd: workDir ?? process.cwd(),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
259
|
+
sendTaskError(taskId, `Failed to spawn Claude Code: ${message}`);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const entry = {
|
|
263
|
+
taskId,
|
|
264
|
+
process: proc,
|
|
265
|
+
abortController: null,
|
|
266
|
+
startedAt: Date.now(),
|
|
267
|
+
stdoutChunks: [],
|
|
268
|
+
completed: false,
|
|
269
|
+
};
|
|
270
|
+
runningTasks.set(taskId, entry);
|
|
271
|
+
// Send user message via stdin (stream-json protocol)
|
|
272
|
+
const userMessage = JSON.stringify({
|
|
273
|
+
type: 'user',
|
|
274
|
+
message: { role: 'user', content: task.input },
|
|
275
|
+
}) + '\n';
|
|
276
|
+
proc.stdin?.write(userMessage);
|
|
277
|
+
proc.stdin?.end();
|
|
278
|
+
// Track extracted fields from result event for task.complete
|
|
279
|
+
let extractedSessionId;
|
|
280
|
+
let extractedResultText;
|
|
281
|
+
let extractedUsage;
|
|
282
|
+
// Parse stdout stream-json events
|
|
283
|
+
let stdoutBuffer = '';
|
|
284
|
+
proc.stdout?.on('data', (data) => {
|
|
285
|
+
const chunk = data.toString('utf-8');
|
|
286
|
+
const { lines, remainder } = splitLines(stdoutBuffer, chunk);
|
|
287
|
+
stdoutBuffer = remainder;
|
|
288
|
+
for (const line of lines) {
|
|
289
|
+
entry.stdoutChunks.push(line + '\n');
|
|
290
|
+
const action = parseClaudeLine(line);
|
|
291
|
+
switch (action.type) {
|
|
292
|
+
case 'delta':
|
|
293
|
+
sendTaskDelta(taskId, action.text);
|
|
294
|
+
break;
|
|
295
|
+
case 'tool_use':
|
|
296
|
+
sendTaskDelta(taskId, `[调用工具: ${action.toolName}]`, { toolUse: { name: action.toolName, input: action.toolInput } });
|
|
297
|
+
break;
|
|
298
|
+
case 'result':
|
|
299
|
+
if (action.sessionId) {
|
|
300
|
+
extractedSessionId = action.sessionId;
|
|
301
|
+
}
|
|
302
|
+
if (action.result) {
|
|
303
|
+
extractedResultText = action.result;
|
|
304
|
+
}
|
|
305
|
+
if (action.usage) {
|
|
306
|
+
extractedUsage = action.usage;
|
|
307
|
+
}
|
|
308
|
+
break;
|
|
309
|
+
case 'error':
|
|
310
|
+
entry.completed = true;
|
|
311
|
+
sendTaskError(taskId, action.message);
|
|
312
|
+
return;
|
|
313
|
+
case 'skip':
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
// Forward stderr as task.delta with meta marker to distinguish from stdout content
|
|
319
|
+
proc.stderr?.on('data', (data) => {
|
|
320
|
+
const text = data.toString('utf-8').trimEnd();
|
|
321
|
+
if (!text)
|
|
322
|
+
return;
|
|
323
|
+
sendTaskDelta(taskId, text, { source: 'stderr' });
|
|
324
|
+
});
|
|
325
|
+
proc.on('exit', (code, signal) => {
|
|
326
|
+
if (entry.completed)
|
|
327
|
+
return;
|
|
328
|
+
entry.completed = true;
|
|
329
|
+
if (extractedSessionId || code === 0) {
|
|
330
|
+
// Use result text extracted from stream-json result event
|
|
331
|
+
sendTaskComplete(taskId, { result: extractedResultText ?? null, exitCode: code ?? 0 }, isOneshot ? undefined : extractedSessionId, extractedUsage);
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
sendTaskError(taskId, signal
|
|
335
|
+
? `Claude Code killed by signal ${signal}`
|
|
336
|
+
: `Claude Code exited with code ${code ?? 'null'}`);
|
|
337
|
+
}
|
|
338
|
+
cleanupTask(taskId);
|
|
339
|
+
});
|
|
340
|
+
proc.on('error', (err) => {
|
|
341
|
+
if (entry.completed)
|
|
342
|
+
return;
|
|
343
|
+
entry.completed = true;
|
|
344
|
+
sendTaskError(taskId, err.message);
|
|
345
|
+
cleanupTask(taskId);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/* ── HTTP Task (shared by hermes / openclaw) ── */
|
|
349
|
+
const DEFAULT_HTTP_TIMEOUT_MS = 180000;
|
|
350
|
+
/**
|
|
351
|
+
* Shared HTTP POST task execution.
|
|
352
|
+
* Hermes and OpenClaw both POST to an endpoint; OpenClaw additionally unwraps the payload.
|
|
353
|
+
*
|
|
354
|
+
* Tool Proxy Fallback: when the HTTP response contains "unsupported mcp biz type" or
|
|
355
|
+
* errcode 846610, the Wrapper sends tool_call IPC frames to the daemon for each
|
|
356
|
+
* fallback tool call, aggregates results, and completes the task with mode: 'fallback'.
|
|
357
|
+
*/
|
|
358
|
+
function spawnHttpTask(task, options) {
|
|
359
|
+
if (!config)
|
|
360
|
+
return;
|
|
361
|
+
const taskId = task.taskId;
|
|
362
|
+
// Task-level endpoint overrides config-level; fallback to deprecated hermesEndpoint
|
|
363
|
+
const endpoint = task.endpoint ?? config.endpoint ?? config.hermesEndpoint;
|
|
364
|
+
if (!endpoint) {
|
|
365
|
+
sendTaskError(taskId, 'HTTP endpoint not configured');
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const timeoutMs = task.hermes?.timeoutMs ?? DEFAULT_HTTP_TIMEOUT_MS;
|
|
369
|
+
const abortController = new AbortController();
|
|
370
|
+
const timeoutId = setTimeout(() => abortController.abort(), timeoutMs);
|
|
371
|
+
const entry = {
|
|
372
|
+
taskId,
|
|
373
|
+
process: null,
|
|
374
|
+
abortController,
|
|
375
|
+
startedAt: Date.now(),
|
|
376
|
+
stdoutChunks: [],
|
|
377
|
+
completed: false,
|
|
378
|
+
};
|
|
379
|
+
runningTasks.set(taskId, entry);
|
|
380
|
+
// Build request headers
|
|
381
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
382
|
+
const token = task.endpointToken ?? config.endpointToken;
|
|
383
|
+
if (token) {
|
|
384
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
385
|
+
}
|
|
386
|
+
// systemPrompt 拼接到 input 前方(Hermes/OpenClaw Gateway 不支持独立 system prompt 参数)
|
|
387
|
+
const effectiveInput = task.systemPrompt
|
|
388
|
+
? `${task.systemPrompt}\n\n---\n\n${task.input}`
|
|
389
|
+
: task.input;
|
|
390
|
+
entry.completionPromise = fetch(endpoint, {
|
|
391
|
+
method: 'POST',
|
|
392
|
+
headers,
|
|
393
|
+
body: JSON.stringify({
|
|
394
|
+
taskId: task.taskId,
|
|
395
|
+
input: effectiveInput,
|
|
396
|
+
context: task.context,
|
|
397
|
+
...(task.systemPrompt ? { systemPrompt: task.systemPrompt } : {}),
|
|
398
|
+
...(config.mcpBridgeUrl ? { mcpBridgeUrl: config.mcpBridgeUrl } : {}),
|
|
399
|
+
...((task.mcpToken ?? config.mcpApiKey) ? { mcpToken: (task.mcpToken ?? config.mcpApiKey) } : {}),
|
|
400
|
+
}),
|
|
401
|
+
signal: abortController.signal,
|
|
402
|
+
})
|
|
403
|
+
.then(async (res) => {
|
|
404
|
+
clearTimeout(timeoutId);
|
|
405
|
+
if (entry.completed)
|
|
406
|
+
return;
|
|
407
|
+
entry.completed = true;
|
|
408
|
+
if (!res.ok) {
|
|
409
|
+
sendTaskError(taskId, `HTTP ${res.status}: ${res.statusText}`);
|
|
410
|
+
cleanupTask(taskId);
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const bodyText = await res.text();
|
|
414
|
+
let parsed = bodyText;
|
|
415
|
+
try {
|
|
416
|
+
parsed = JSON.parse(bodyText);
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
// Non-JSON response, keep raw text
|
|
420
|
+
}
|
|
421
|
+
// Apply unwrap if configured (openclaw) — unwrap expects raw string, internally JSON.parses
|
|
422
|
+
if (options.unwrap && typeof parsed === 'object' && parsed !== null) {
|
|
423
|
+
try {
|
|
424
|
+
parsed = options.unwrap(bodyText);
|
|
425
|
+
}
|
|
426
|
+
catch {
|
|
427
|
+
// unwrap failed, keep original
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
// Tool Proxy Fallback detection
|
|
431
|
+
const responseStr = typeof parsed === 'string' ? parsed : JSON.stringify(parsed);
|
|
432
|
+
if (/unsupported mcp biz type|errcode.*846610/i.test(responseStr)) {
|
|
433
|
+
const fallbackCalls = extractFallbackToolCalls(parsed);
|
|
434
|
+
if (fallbackCalls.length > 0) {
|
|
435
|
+
await executeFallbackToolCalls(taskId, fallbackCalls);
|
|
436
|
+
cleanupTask(taskId);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
sendTaskComplete(taskId, parsed);
|
|
441
|
+
cleanupTask(taskId);
|
|
442
|
+
})
|
|
443
|
+
.catch((err) => {
|
|
444
|
+
clearTimeout(timeoutId);
|
|
445
|
+
if (entry.completed)
|
|
446
|
+
return;
|
|
447
|
+
entry.completed = true;
|
|
448
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
449
|
+
if (err.name === 'AbortError') {
|
|
450
|
+
sendTaskError(taskId, `HTTP request timed out after ${timeoutMs}ms`);
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
sendTaskError(taskId, `HTTP request failed: ${message}`);
|
|
454
|
+
}
|
|
455
|
+
cleanupTask(taskId);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
function spawnHermesTask(task) {
|
|
459
|
+
spawnHttpTask(task, {});
|
|
460
|
+
}
|
|
461
|
+
function spawnOpenClawTask(task) {
|
|
462
|
+
spawnHttpTask(task, { unwrap: unwrapOpenClawPayloads });
|
|
463
|
+
}
|
|
464
|
+
function extractFallbackToolCalls(parsed) {
|
|
465
|
+
const calls = [];
|
|
466
|
+
// Try to extract from common response shapes
|
|
467
|
+
let data = parsed;
|
|
468
|
+
if (typeof data === 'string') {
|
|
469
|
+
try {
|
|
470
|
+
data = JSON.parse(data);
|
|
471
|
+
}
|
|
472
|
+
catch {
|
|
473
|
+
return calls;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (!data || typeof data !== 'object')
|
|
477
|
+
return calls;
|
|
478
|
+
// Shape: { tool_calls: [{ name, arguments }, ...] }
|
|
479
|
+
const rawCalls = data.tool_calls ?? data.toolCalls ?? data.calls;
|
|
480
|
+
if (Array.isArray(rawCalls)) {
|
|
481
|
+
for (const c of rawCalls) {
|
|
482
|
+
if (typeof c !== 'object' || c === null)
|
|
483
|
+
continue;
|
|
484
|
+
const name = c.name ?? c.tool_name ?? c.function;
|
|
485
|
+
if (typeof name !== 'string')
|
|
486
|
+
continue;
|
|
487
|
+
let args = {};
|
|
488
|
+
const rawArgs = c.arguments ?? c.args ?? c.parameters;
|
|
489
|
+
if (typeof rawArgs === 'string') {
|
|
490
|
+
try {
|
|
491
|
+
args = JSON.parse(rawArgs);
|
|
492
|
+
}
|
|
493
|
+
catch {
|
|
494
|
+
args = { raw: rawArgs };
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
else if (typeof rawArgs === 'object' && rawArgs !== null) {
|
|
498
|
+
args = rawArgs;
|
|
499
|
+
}
|
|
500
|
+
calls.push({ toolName: name, args });
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
// Shape: { tool_query: "..." } → single tool call
|
|
504
|
+
if (calls.length === 0 && typeof data.tool_query === 'string') {
|
|
505
|
+
calls.push({ toolName: 'tool_query', args: { query: data.tool_query } });
|
|
506
|
+
}
|
|
507
|
+
return calls;
|
|
508
|
+
}
|
|
509
|
+
async function executeFallbackToolCalls(taskId, calls) {
|
|
510
|
+
const results = [];
|
|
511
|
+
for (const call of calls) {
|
|
512
|
+
const callId = randomUUID();
|
|
513
|
+
// Send tool_call IPC to daemon
|
|
514
|
+
process.stdout.write(JSON.stringify({
|
|
515
|
+
type: 'tool_call',
|
|
516
|
+
callId,
|
|
517
|
+
taskId,
|
|
518
|
+
toolName: call.toolName,
|
|
519
|
+
args: call.args,
|
|
520
|
+
}) + '\n');
|
|
521
|
+
// Wait for tool_result from daemon via stdin
|
|
522
|
+
try {
|
|
523
|
+
const result = await waitForToolResult(callId, 30000);
|
|
524
|
+
results.push({ toolName: call.toolName, ok: true, result });
|
|
525
|
+
}
|
|
526
|
+
catch (err) {
|
|
527
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
528
|
+
results.push({ toolName: call.toolName, ok: false, error: message });
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
sendTaskComplete(taskId, { mode: 'fallback', calls: results });
|
|
532
|
+
}
|
|
533
|
+
/** Pending tool_result resolvers keyed by callId */
|
|
534
|
+
const toolResultPending = new Map();
|
|
535
|
+
function waitForToolResult(callId, timeoutMs) {
|
|
536
|
+
return new Promise((resolve, reject) => {
|
|
537
|
+
const timer = setTimeout(() => {
|
|
538
|
+
toolResultPending.delete(callId);
|
|
539
|
+
reject(new Error('Tool call timed out'));
|
|
540
|
+
}, timeoutMs);
|
|
541
|
+
toolResultPending.set(callId, { resolve, reject, timer });
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
/** Called from stdin handler when a tool_result frame arrives from daemon */
|
|
545
|
+
function handleToolResult(frame) {
|
|
546
|
+
const pending = toolResultPending.get(frame.callId);
|
|
547
|
+
if (!pending)
|
|
548
|
+
return;
|
|
549
|
+
clearTimeout(pending.timer);
|
|
550
|
+
toolResultPending.delete(frame.callId);
|
|
551
|
+
if (frame.ok) {
|
|
552
|
+
pending.resolve(frame.result);
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
pending.reject(new Error(frame.error ?? 'Tool call failed'));
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
/* ── Generic Task (fallback) ── */
|
|
559
|
+
function spawnGenericTask(task) {
|
|
560
|
+
if (!config)
|
|
561
|
+
return;
|
|
562
|
+
const taskId = task.taskId;
|
|
563
|
+
const workDir = task.workDir ?? config.workDir;
|
|
564
|
+
const args = ['--print', '--output-format', 'json', task.input];
|
|
565
|
+
let proc;
|
|
566
|
+
try {
|
|
567
|
+
proc = spawn(config.runtime, args, {
|
|
568
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
569
|
+
env: {
|
|
570
|
+
...process.env,
|
|
571
|
+
WINMATRIX_AGENT_ID: config.agentId,
|
|
572
|
+
WINMATRIX_API_KEY: config.apiKey,
|
|
573
|
+
WINMATRIX_AGENT_NAME: config.name,
|
|
574
|
+
WINMATRIX_AGENT_TYPE: config.agentType,
|
|
575
|
+
WINMATRIX_TASK_ID: taskId,
|
|
576
|
+
...task.env,
|
|
577
|
+
},
|
|
578
|
+
cwd: workDir ?? process.cwd(),
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
catch (err) {
|
|
582
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
583
|
+
sendTaskError(taskId, `Failed to spawn runtime: ${message}`);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
const entry = {
|
|
587
|
+
taskId,
|
|
588
|
+
process: proc,
|
|
589
|
+
abortController: null,
|
|
590
|
+
startedAt: Date.now(),
|
|
591
|
+
stdoutChunks: [],
|
|
592
|
+
completed: false,
|
|
593
|
+
};
|
|
594
|
+
runningTasks.set(taskId, entry);
|
|
595
|
+
proc.stdout?.on('data', (data) => {
|
|
596
|
+
const text = data.toString('utf-8');
|
|
597
|
+
entry.stdoutChunks.push(text);
|
|
598
|
+
const trimmed = text.trimEnd();
|
|
599
|
+
if (!trimmed)
|
|
600
|
+
return;
|
|
601
|
+
sendTaskDelta(taskId, trimmed);
|
|
602
|
+
});
|
|
603
|
+
proc.stderr?.on('data', (data) => {
|
|
604
|
+
const text = data.toString('utf-8').trimEnd();
|
|
605
|
+
if (!text)
|
|
606
|
+
return;
|
|
607
|
+
sendTaskDelta(taskId, text, { source: 'stderr' });
|
|
608
|
+
});
|
|
609
|
+
proc.on('exit', (code, signal) => {
|
|
610
|
+
if (entry.completed)
|
|
611
|
+
return;
|
|
612
|
+
entry.completed = true;
|
|
613
|
+
if (code === 0) {
|
|
614
|
+
const rawOutput = entry.stdoutChunks.join('');
|
|
615
|
+
let parsedResult = rawOutput;
|
|
616
|
+
try {
|
|
617
|
+
parsedResult = JSON.parse(rawOutput);
|
|
618
|
+
}
|
|
619
|
+
catch {
|
|
620
|
+
// Non-JSON output, keep raw
|
|
621
|
+
}
|
|
622
|
+
sendTaskComplete(taskId, parsedResult);
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
sendTaskError(taskId, signal
|
|
626
|
+
? `Process killed by signal ${signal}`
|
|
627
|
+
: `Process exited with code ${code ?? 'null'}`);
|
|
628
|
+
}
|
|
629
|
+
cleanupTask(taskId);
|
|
630
|
+
});
|
|
631
|
+
proc.on('error', (err) => {
|
|
632
|
+
if (entry.completed)
|
|
633
|
+
return;
|
|
634
|
+
entry.completed = true;
|
|
635
|
+
sendTaskError(taskId, err.message);
|
|
636
|
+
cleanupTask(taskId);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
/* ── Task Cancellation ── */
|
|
640
|
+
function cancelTask(taskId) {
|
|
641
|
+
const entry = runningTasks.get(taskId);
|
|
642
|
+
if (!entry)
|
|
643
|
+
return;
|
|
644
|
+
if (entry.abortController) {
|
|
645
|
+
entry.abortController.abort();
|
|
646
|
+
}
|
|
647
|
+
if (entry.process) {
|
|
648
|
+
try {
|
|
649
|
+
entry.process.kill('SIGTERM');
|
|
650
|
+
setTimeout(() => {
|
|
651
|
+
try {
|
|
652
|
+
entry.process?.kill('SIGKILL');
|
|
653
|
+
}
|
|
654
|
+
catch { /* already dead */ }
|
|
655
|
+
}, 10000);
|
|
656
|
+
}
|
|
657
|
+
catch {
|
|
658
|
+
// process already exited
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
cleanupTask(taskId);
|
|
662
|
+
}
|
|
663
|
+
/* ── Register Flow ── */
|
|
664
|
+
function sendRegister() {
|
|
665
|
+
if (!config)
|
|
666
|
+
return;
|
|
667
|
+
send({
|
|
668
|
+
type: 'fwd',
|
|
669
|
+
agentId: config.agentId,
|
|
670
|
+
data: {
|
|
671
|
+
type: 'req',
|
|
672
|
+
id: `wrapper-reg-${config.agentId}`,
|
|
673
|
+
method: 'register',
|
|
674
|
+
params: {
|
|
675
|
+
agentId: config.agentId,
|
|
676
|
+
apiKey: config.apiKey,
|
|
677
|
+
name: config.name,
|
|
678
|
+
agentType: config.agentType,
|
|
679
|
+
capabilities: {
|
|
680
|
+
streaming: true,
|
|
681
|
+
toolCall: true,
|
|
682
|
+
cancellation: true,
|
|
683
|
+
},
|
|
684
|
+
},
|
|
685
|
+
},
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
/* ── Stdin Event Handling ── */
|
|
689
|
+
async function sendWorkspaceReport() {
|
|
690
|
+
if (!config?.workDir)
|
|
691
|
+
return;
|
|
692
|
+
try {
|
|
693
|
+
const workdir = await scanWorkDir(config.workDir);
|
|
694
|
+
// Detect key runtime versions
|
|
695
|
+
const runtimes = {};
|
|
696
|
+
const runtimeBinaries = config.runtime ? [config.runtime] : [];
|
|
697
|
+
for (const bin of runtimeBinaries) {
|
|
698
|
+
runtimes[bin] = await detectRuntimeInfo(bin);
|
|
699
|
+
}
|
|
700
|
+
const payload = {
|
|
701
|
+
agentId: config.agentId,
|
|
702
|
+
workdir,
|
|
703
|
+
runtimes: Object.keys(runtimes).length > 0 ? runtimes : undefined,
|
|
704
|
+
};
|
|
705
|
+
send({
|
|
706
|
+
type: 'fwd',
|
|
707
|
+
agentId: config.agentId,
|
|
708
|
+
data: {
|
|
709
|
+
type: 'event',
|
|
710
|
+
event: 'workspace.report',
|
|
711
|
+
payload,
|
|
712
|
+
},
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
catch {
|
|
716
|
+
// workspace scan failed silently - workDir may be inaccessible
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
function handleServerFrame(data) {
|
|
720
|
+
if (!config)
|
|
721
|
+
return;
|
|
722
|
+
// Handle register response
|
|
723
|
+
if (data.type === 'res' && data.ok === true) {
|
|
724
|
+
send({
|
|
725
|
+
type: 'event',
|
|
726
|
+
event: 'agent.ready',
|
|
727
|
+
payload: { agentId: config.agentId, pid: process.pid },
|
|
728
|
+
});
|
|
729
|
+
// Fire-and-forget workspace scan after agent is ready
|
|
730
|
+
if (config.workDir) {
|
|
731
|
+
sendWorkspaceReport();
|
|
732
|
+
}
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
if (data.type === 'res' && data.ok === false) {
|
|
736
|
+
send({
|
|
737
|
+
type: 'event',
|
|
738
|
+
event: 'agent.error',
|
|
739
|
+
payload: {
|
|
740
|
+
agentId: config.agentId,
|
|
741
|
+
error: data.error ?? 'registration failed',
|
|
742
|
+
},
|
|
743
|
+
});
|
|
744
|
+
process.exit(1);
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
// Handle task.assign event
|
|
748
|
+
if (data.type === 'event' && data.event === 'task.assign') {
|
|
749
|
+
const payload = (data.payload ?? {});
|
|
750
|
+
if (payload.taskId && payload.input) {
|
|
751
|
+
routeTask(payload);
|
|
752
|
+
}
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
// Handle task.cancel event
|
|
756
|
+
if (data.type === 'event' && data.event === 'task.cancel') {
|
|
757
|
+
const payload = data.payload;
|
|
758
|
+
if (payload?.taskId) {
|
|
759
|
+
cancelTask(payload.taskId);
|
|
760
|
+
}
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
// Handle reconnect event (Daemon reconnected, re-register)
|
|
764
|
+
if (data.type === 'event' && data.event === 'reconnect') {
|
|
765
|
+
sendRegister();
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
/* ── Main ── */
|
|
770
|
+
function main() {
|
|
771
|
+
const args = process.argv.slice(2);
|
|
772
|
+
const parsed = {};
|
|
773
|
+
for (let i = 0; i < args.length; i++) {
|
|
774
|
+
if (args[i].startsWith('--') && i + 1 < args.length) {
|
|
775
|
+
parsed[args[i]] = args[++i];
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
const apiKey = process.env.WINMATRIX_API_KEY ?? '';
|
|
779
|
+
const endpointToken = process.env.WINMATRIX_ENDPOINT_TOKEN ?? undefined;
|
|
780
|
+
config = {
|
|
781
|
+
agentId: parsed['--agent-id'] ?? '',
|
|
782
|
+
apiKey,
|
|
783
|
+
name: parsed['--name'] ?? '',
|
|
784
|
+
agentType: parsed['--agent-type'] ?? '',
|
|
785
|
+
runtime: parsed['--runtime'] ?? '',
|
|
786
|
+
workDir: parsed['--work-dir'] ?? undefined,
|
|
787
|
+
hermesEndpoint: parsed['--hermes-endpoint'] ?? undefined,
|
|
788
|
+
endpoint: parsed['--endpoint'] ?? parsed['--hermes-endpoint'] ?? undefined,
|
|
789
|
+
endpointToken,
|
|
790
|
+
mcpBridgeUrl: parsed['--mcp-bridge-url'] ?? undefined,
|
|
791
|
+
mcpApiKey: parsed['--mcp-api-key'] ?? undefined,
|
|
792
|
+
};
|
|
793
|
+
if (!config.agentId || !config.apiKey) {
|
|
794
|
+
send({
|
|
795
|
+
type: 'event',
|
|
796
|
+
event: 'agent.error',
|
|
797
|
+
payload: {
|
|
798
|
+
error: 'Missing required --agent-id or WINMATRIX_API_KEY env',
|
|
799
|
+
},
|
|
800
|
+
});
|
|
801
|
+
process.exit(1);
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
// Step 1: Send register frame via stdout (Daemon forwards to Server)
|
|
805
|
+
sendRegister();
|
|
806
|
+
// Step 2: Wait for register response and task events via stdin
|
|
807
|
+
process.stdin.setEncoding('utf-8');
|
|
808
|
+
let buffer = '';
|
|
809
|
+
process.stdin.on('data', (chunk) => {
|
|
810
|
+
buffer += chunk;
|
|
811
|
+
const lines = buffer.split('\n');
|
|
812
|
+
buffer = lines.pop() ?? '';
|
|
813
|
+
for (const line of lines) {
|
|
814
|
+
const frame = parseStdin(line);
|
|
815
|
+
if (!frame)
|
|
816
|
+
continue;
|
|
817
|
+
const data = frame.data;
|
|
818
|
+
if (data && typeof data === 'object') {
|
|
819
|
+
handleServerFrame(data);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
process.stdin.on('end', () => {
|
|
824
|
+
shutdown();
|
|
825
|
+
});
|
|
826
|
+
process.stdin.resume();
|
|
827
|
+
// Handle termination signals
|
|
828
|
+
function shutdown() {
|
|
829
|
+
// First pass: abort fetch tasks and SIGTERM child processes
|
|
830
|
+
for (const [, entry] of runningTasks) {
|
|
831
|
+
if (entry.abortController) {
|
|
832
|
+
entry.abortController.abort();
|
|
833
|
+
}
|
|
834
|
+
if (entry.process) {
|
|
835
|
+
try {
|
|
836
|
+
entry.process.kill('SIGTERM');
|
|
837
|
+
}
|
|
838
|
+
catch { /* already dead */ }
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
// Wait for in-flight fetch tasks to settle (with 5s timeout),
|
|
842
|
+
// then SIGKILL any remaining child processes.
|
|
843
|
+
const fetchPromises = [...runningTasks.values()]
|
|
844
|
+
.filter((e) => e.completionPromise)
|
|
845
|
+
.map((e) => e.completionPromise);
|
|
846
|
+
const finalize = () => {
|
|
847
|
+
for (const [, entry] of runningTasks) {
|
|
848
|
+
if (entry.process) {
|
|
849
|
+
try {
|
|
850
|
+
entry.process.kill('SIGKILL');
|
|
851
|
+
}
|
|
852
|
+
catch { /* already dead */ }
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
runningTasks.clear();
|
|
856
|
+
process.exit(0);
|
|
857
|
+
};
|
|
858
|
+
if (fetchPromises.length > 0) {
|
|
859
|
+
Promise.race([
|
|
860
|
+
Promise.allSettled(fetchPromises),
|
|
861
|
+
new Promise((resolve) => setTimeout(resolve, 5000)),
|
|
862
|
+
]).finally(finalize);
|
|
863
|
+
}
|
|
864
|
+
else {
|
|
865
|
+
// No fetch tasks: 10s grace for child process SIGTERM → SIGKILL
|
|
866
|
+
setTimeout(finalize, 10000);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
process.on('SIGTERM', shutdown);
|
|
870
|
+
process.on('SIGINT', shutdown);
|
|
871
|
+
}
|
|
872
|
+
main();
|
|
873
|
+
//# sourceMappingURL=AgentWrapper.js.map
|