awb-agent-manager 1.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/LICENSE +21 -0
- package/README.md +246 -0
- package/dist/lib/agent-lockfile.d.ts +37 -0
- package/dist/lib/agent-lockfile.js +205 -0
- package/dist/lib/agent-lockfile.js.map +1 -0
- package/dist/lib/agent-manager-commands.d.ts +34 -0
- package/dist/lib/agent-manager-commands.js +531 -0
- package/dist/lib/agent-manager-commands.js.map +1 -0
- package/dist/lib/base-session-manager.d.ts +127 -0
- package/dist/lib/base-session-manager.js +667 -0
- package/dist/lib/base-session-manager.js.map +1 -0
- package/dist/lib/chat-attachment-prep.d.ts +35 -0
- package/dist/lib/chat-attachment-prep.js +180 -0
- package/dist/lib/chat-attachment-prep.js.map +1 -0
- package/dist/lib/chat-session-manager.d.ts +29 -0
- package/dist/lib/chat-session-manager.js +400 -0
- package/dist/lib/chat-session-manager.js.map +1 -0
- package/dist/lib/circuit-breaker.d.ts +34 -0
- package/dist/lib/circuit-breaker.js +146 -0
- package/dist/lib/circuit-breaker.js.map +1 -0
- package/dist/lib/cli-adapters/antigravity.d.ts +15 -0
- package/dist/lib/cli-adapters/antigravity.js +114 -0
- package/dist/lib/cli-adapters/antigravity.js.map +1 -0
- package/dist/lib/cli-adapters/base.d.ts +115 -0
- package/dist/lib/cli-adapters/base.js +111 -0
- package/dist/lib/cli-adapters/base.js.map +1 -0
- package/dist/lib/cli-adapters/claude.d.ts +19 -0
- package/dist/lib/cli-adapters/claude.js +233 -0
- package/dist/lib/cli-adapters/claude.js.map +1 -0
- package/dist/lib/cli-adapters/codex.d.ts +14 -0
- package/dist/lib/cli-adapters/codex.js +152 -0
- package/dist/lib/cli-adapters/codex.js.map +1 -0
- package/dist/lib/cli-adapters/deepseek.d.ts +15 -0
- package/dist/lib/cli-adapters/deepseek.js +70 -0
- package/dist/lib/cli-adapters/deepseek.js.map +1 -0
- package/dist/lib/cli-adapters/index.d.ts +8 -0
- package/dist/lib/cli-adapters/index.js +27 -0
- package/dist/lib/cli-adapters/index.js.map +1 -0
- package/dist/lib/cli-adapters/model-introspect.d.ts +3 -0
- package/dist/lib/cli-adapters/model-introspect.js +65 -0
- package/dist/lib/cli-adapters/model-introspect.js.map +1 -0
- package/dist/lib/cli-error-signatures.d.ts +9 -0
- package/dist/lib/cli-error-signatures.js +22 -0
- package/dist/lib/cli-error-signatures.js.map +1 -0
- package/dist/lib/cli-output-summary.d.ts +2 -0
- package/dist/lib/cli-output-summary.js +104 -0
- package/dist/lib/cli-output-summary.js.map +1 -0
- package/dist/lib/cli-resolver.d.ts +2 -0
- package/dist/lib/cli-resolver.js +177 -0
- package/dist/lib/cli-resolver.js.map +1 -0
- package/dist/lib/config.d.ts +13 -0
- package/dist/lib/config.js +124 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/constants.d.ts +36 -0
- package/dist/lib/constants.js +51 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/environment-provisioner.d.ts +31 -0
- package/dist/lib/environment-provisioner.js +182 -0
- package/dist/lib/environment-provisioner.js.map +1 -0
- package/dist/lib/error-log-uploader.d.ts +19 -0
- package/dist/lib/error-log-uploader.js +138 -0
- package/dist/lib/error-log-uploader.js.map +1 -0
- package/dist/lib/event-dispatcher.d.ts +149 -0
- package/dist/lib/event-dispatcher.js +799 -0
- package/dist/lib/event-dispatcher.js.map +1 -0
- package/dist/lib/event-log-recorder.d.ts +11 -0
- package/dist/lib/event-log-recorder.js +77 -0
- package/dist/lib/event-log-recorder.js.map +1 -0
- package/dist/lib/event-stream.d.ts +26 -0
- package/dist/lib/event-stream.js +177 -0
- package/dist/lib/event-stream.js.map +1 -0
- package/dist/lib/fs-browser.d.ts +30 -0
- package/dist/lib/fs-browser.js +287 -0
- package/dist/lib/fs-browser.js.map +1 -0
- package/dist/lib/host-mcp/logs.d.ts +19 -0
- package/dist/lib/host-mcp/logs.js +102 -0
- package/dist/lib/host-mcp/logs.js.map +1 -0
- package/dist/lib/host-mcp/platform.d.ts +24 -0
- package/dist/lib/host-mcp/platform.js +133 -0
- package/dist/lib/host-mcp/platform.js.map +1 -0
- package/dist/lib/host-mcp/screens.d.ts +22 -0
- package/dist/lib/host-mcp/screens.js +172 -0
- package/dist/lib/host-mcp/screens.js.map +1 -0
- package/dist/lib/host-mcp/server.d.ts +3 -0
- package/dist/lib/host-mcp/server.js +233 -0
- package/dist/lib/host-mcp/server.js.map +1 -0
- package/dist/lib/host-mcp/tools.d.ts +172 -0
- package/dist/lib/host-mcp/tools.js +1241 -0
- package/dist/lib/host-mcp/tools.js.map +1 -0
- package/dist/lib/instance-heartbeat.d.ts +55 -0
- package/dist/lib/instance-heartbeat.js +118 -0
- package/dist/lib/instance-heartbeat.js.map +1 -0
- package/dist/lib/legacy-import.d.ts +17 -0
- package/dist/lib/legacy-import.js +70 -0
- package/dist/lib/legacy-import.js.map +1 -0
- package/dist/lib/logging.d.ts +3 -0
- package/dist/lib/logging.js +65 -0
- package/dist/lib/logging.js.map +1 -0
- package/dist/lib/managed-agent-context.d.ts +25 -0
- package/dist/lib/managed-agent-context.js +33 -0
- package/dist/lib/managed-agent-context.js.map +1 -0
- package/dist/lib/managed-agent-store.d.ts +34 -0
- package/dist/lib/managed-agent-store.js +160 -0
- package/dist/lib/managed-agent-store.js.map +1 -0
- package/dist/lib/managed-agents.d.ts +24 -0
- package/dist/lib/managed-agents.js +87 -0
- package/dist/lib/managed-agents.js.map +1 -0
- package/dist/lib/mcp-client.d.ts +8 -0
- package/dist/lib/mcp-client.js +122 -0
- package/dist/lib/mcp-client.js.map +1 -0
- package/dist/lib/orphan-cleanup.d.ts +6 -0
- package/dist/lib/orphan-cleanup.js +108 -0
- package/dist/lib/orphan-cleanup.js.map +1 -0
- package/dist/lib/presence-heartbeat.d.ts +8 -0
- package/dist/lib/presence-heartbeat.js +61 -0
- package/dist/lib/presence-heartbeat.js.map +1 -0
- package/dist/lib/prompts.d.ts +29 -0
- package/dist/lib/prompts.js +208 -0
- package/dist/lib/prompts.js.map +1 -0
- package/dist/lib/rest.d.ts +61 -0
- package/dist/lib/rest.js +307 -0
- package/dist/lib/rest.js.map +1 -0
- package/dist/lib/run-provisioner.d.ts +21 -0
- package/dist/lib/run-provisioner.js +115 -0
- package/dist/lib/run-provisioner.js.map +1 -0
- package/dist/lib/self-path.d.ts +7 -0
- package/dist/lib/self-path.js +29 -0
- package/dist/lib/self-path.js.map +1 -0
- package/dist/lib/self-update.d.ts +46 -0
- package/dist/lib/self-update.js +482 -0
- package/dist/lib/self-update.js.map +1 -0
- package/dist/lib/service-install.d.ts +23 -0
- package/dist/lib/service-install.js +673 -0
- package/dist/lib/service-install.js.map +1 -0
- package/dist/lib/setup.d.ts +16 -0
- package/dist/lib/setup.js +157 -0
- package/dist/lib/setup.js.map +1 -0
- package/dist/lib/subagent-manager.d.ts +84 -0
- package/dist/lib/subagent-manager.js +793 -0
- package/dist/lib/subagent-manager.js.map +1 -0
- package/dist/lib/subagent-monitor.d.ts +43 -0
- package/dist/lib/subagent-monitor.js +229 -0
- package/dist/lib/subagent-monitor.js.map +1 -0
- package/dist/lib/ticket-session-manager.d.ts +23 -0
- package/dist/lib/ticket-session-manager.js +471 -0
- package/dist/lib/ticket-session-manager.js.map +1 -0
- package/dist/lib/worktree-manager.d.ts +39 -0
- package/dist/lib/worktree-manager.js +226 -0
- package/dist/lib/worktree-manager.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +670 -0
- package/dist/main.js.map +1 -0
- package/dist/package.json +57 -0
- package/package.json +57 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { findBinary, hostPlatform, isWayland, runCommand, runPowerShell } from './platform.js';
|
|
2
|
+
export async function listScreens() {
|
|
3
|
+
const plat = hostPlatform();
|
|
4
|
+
try {
|
|
5
|
+
if (plat === 'win32')
|
|
6
|
+
return await listScreensWin();
|
|
7
|
+
if (plat === 'darwin')
|
|
8
|
+
return await listScreensMac();
|
|
9
|
+
return isWayland() ? await listScreensWayland() : await listScreensX11();
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
return { ok: false, error: `list_screens failed: ${err?.message ?? err}` };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function listScreensWin() {
|
|
16
|
+
const script = `
|
|
17
|
+
$ErrorActionPreference = 'Stop'
|
|
18
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
19
|
+
$idx = 0
|
|
20
|
+
$out = foreach ($s in [System.Windows.Forms.Screen]::AllScreens) {
|
|
21
|
+
$row = [pscustomobject]@{
|
|
22
|
+
index = $idx
|
|
23
|
+
x = $s.Bounds.X
|
|
24
|
+
y = $s.Bounds.Y
|
|
25
|
+
width = $s.Bounds.Width
|
|
26
|
+
height = $s.Bounds.Height
|
|
27
|
+
primary = [bool]$s.Primary
|
|
28
|
+
scale = $null
|
|
29
|
+
name = $s.DeviceName
|
|
30
|
+
}
|
|
31
|
+
$idx++
|
|
32
|
+
$row
|
|
33
|
+
}
|
|
34
|
+
$out | ConvertTo-Json -Depth 3 -Compress
|
|
35
|
+
`;
|
|
36
|
+
const r = await runPowerShell(script, { timeoutMs: 8000 });
|
|
37
|
+
if (r.spawnFailed)
|
|
38
|
+
return { ok: false, error: 'PowerShell not available', hint: 'Install PowerShell or pwsh' };
|
|
39
|
+
if (r.code !== 0)
|
|
40
|
+
return { ok: false, error: `Screen.AllScreens failed: ${r.stderr.trim() || `exit ${r.code}`}` };
|
|
41
|
+
return parseMonitors(r.stdout, 'win32');
|
|
42
|
+
}
|
|
43
|
+
async function listScreensMac() {
|
|
44
|
+
const script = `
|
|
45
|
+
import json, sys
|
|
46
|
+
try:
|
|
47
|
+
import AppKit
|
|
48
|
+
except Exception as e:
|
|
49
|
+
print('[]')
|
|
50
|
+
sys.exit(0)
|
|
51
|
+
main = AppKit.NSScreen.mainScreen()
|
|
52
|
+
out = []
|
|
53
|
+
for i, s in enumerate(AppKit.NSScreen.screens()):
|
|
54
|
+
f = s.frame()
|
|
55
|
+
out.append({
|
|
56
|
+
'index': i,
|
|
57
|
+
'x': int(f.origin.x),
|
|
58
|
+
'y': int(f.origin.y),
|
|
59
|
+
'width': int(f.size.width),
|
|
60
|
+
'height': int(f.size.height),
|
|
61
|
+
'primary': bool(s == main),
|
|
62
|
+
'scale': float(s.backingScaleFactor()),
|
|
63
|
+
'name': str(s.localizedName()) if hasattr(s, 'localizedName') else None,
|
|
64
|
+
})
|
|
65
|
+
print(json.dumps(out))
|
|
66
|
+
`;
|
|
67
|
+
const r = await runCommand('/usr/bin/python3', ['-c', script], { timeoutMs: 6000 });
|
|
68
|
+
if (r.spawnFailed) {
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
error: 'python3 not available for AppKit display enumeration',
|
|
72
|
+
hint: 'Install python3 (xcode-select --install) or use display=0 implicitly',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (r.code !== 0) {
|
|
76
|
+
return { ok: false, error: `AppKit enumeration exited ${r.code}: ${r.stderr.trim()}` };
|
|
77
|
+
}
|
|
78
|
+
return parseMonitors(r.stdout, 'darwin');
|
|
79
|
+
}
|
|
80
|
+
async function listScreensX11() {
|
|
81
|
+
const bin = await findBinary(['xrandr']);
|
|
82
|
+
if (!bin) {
|
|
83
|
+
return {
|
|
84
|
+
ok: false,
|
|
85
|
+
error: 'xrandr not installed',
|
|
86
|
+
hint: 'apt install x11-xserver-utils',
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const r = await runCommand('xrandr', ['--listmonitors'], { timeoutMs: 5000 });
|
|
90
|
+
if (r.spawnFailed || r.code !== 0) {
|
|
91
|
+
return { ok: false, error: `xrandr failed: ${r.stderr.trim() || `exit ${r.code}`}` };
|
|
92
|
+
}
|
|
93
|
+
const monitors = [];
|
|
94
|
+
for (const line of r.stdout.split('\n')) {
|
|
95
|
+
const m = /^\s*(\d+):\s*\+(\*?)\S+\s+(\d+)\/\d+x(\d+)\/\d+\+(-?\d+)\+(-?\d+)\s+(\S+)/.exec(line);
|
|
96
|
+
if (!m)
|
|
97
|
+
continue;
|
|
98
|
+
monitors.push({
|
|
99
|
+
index: Number(m[1]),
|
|
100
|
+
x: Number(m[5]),
|
|
101
|
+
y: Number(m[6]),
|
|
102
|
+
width: Number(m[3]),
|
|
103
|
+
height: Number(m[4]),
|
|
104
|
+
primary: m[2] === '*',
|
|
105
|
+
scale: null,
|
|
106
|
+
name: m[7],
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
ok: true,
|
|
111
|
+
monitors,
|
|
112
|
+
platform: 'linux',
|
|
113
|
+
warning: monitors.length === 0 ? 'xrandr returned no monitor rows' : undefined,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
async function listScreensWayland() {
|
|
117
|
+
const wlr = await findBinary(['wlr-randr']);
|
|
118
|
+
if (wlr) {
|
|
119
|
+
const r = await runCommand('wlr-randr', ['--json'], { timeoutMs: 5000 });
|
|
120
|
+
if (!r.spawnFailed && r.code === 0 && r.stdout.trim()) {
|
|
121
|
+
try {
|
|
122
|
+
const data = JSON.parse(r.stdout);
|
|
123
|
+
const monitors = [];
|
|
124
|
+
let idx = 0;
|
|
125
|
+
for (const dev of Array.isArray(data) ? data : []) {
|
|
126
|
+
const currentMode = (dev.modes || []).find((m) => m.current) || (dev.modes || [])[0];
|
|
127
|
+
const pos = dev.position || { x: 0, y: 0 };
|
|
128
|
+
monitors.push({
|
|
129
|
+
index: idx++,
|
|
130
|
+
x: Number(pos.x ?? 0),
|
|
131
|
+
y: Number(pos.y ?? 0),
|
|
132
|
+
width: Number(currentMode?.width ?? 0),
|
|
133
|
+
height: Number(currentMode?.height ?? 0),
|
|
134
|
+
primary: idx === 1 && !!dev.enabled,
|
|
135
|
+
scale: typeof dev.scale === 'number' ? dev.scale : null,
|
|
136
|
+
name: dev.name || dev.make || null,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return { ok: true, monitors, platform: 'linux' };
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
return { ok: false, error: `wlr-randr JSON parse: ${err?.message ?? err}` };
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return listScreensX11();
|
|
147
|
+
}
|
|
148
|
+
function parseMonitors(stdout, platform) {
|
|
149
|
+
const trimmed = stdout.trim();
|
|
150
|
+
if (!trimmed)
|
|
151
|
+
return { ok: true, monitors: [], platform, warning: 'enumeration returned empty output' };
|
|
152
|
+
let parsed;
|
|
153
|
+
try {
|
|
154
|
+
parsed = JSON.parse(trimmed);
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
return { ok: false, error: `JSON parse failed: ${err?.message ?? err}` };
|
|
158
|
+
}
|
|
159
|
+
const list = Array.isArray(parsed) ? parsed : [parsed];
|
|
160
|
+
const monitors = list.map((r, i) => ({
|
|
161
|
+
index: typeof r.index === 'number' ? r.index : i,
|
|
162
|
+
x: Number(r.x ?? 0),
|
|
163
|
+
y: Number(r.y ?? 0),
|
|
164
|
+
width: Number(r.width ?? 0),
|
|
165
|
+
height: Number(r.height ?? 0),
|
|
166
|
+
primary: !!r.primary,
|
|
167
|
+
scale: typeof r.scale === 'number' ? r.scale : null,
|
|
168
|
+
name: typeof r.name === 'string' ? r.name : null,
|
|
169
|
+
}));
|
|
170
|
+
return { ok: true, monitors, platform };
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=screens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screens.js","sourceRoot":"","sources":["../../../src/lib/host-mcp/screens.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AA8B/F,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;IAC5B,IAAI,CAAC;QACH,IAAI,I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C;QAC3B,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;QAC7B,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO;QACpB,KAAK,EAAE,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;QACnD,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;KACjD,CAAC,CAAC,CAAC;IACJ,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { clipboardRead, clipboardWrite, focusWindow, killProcess, launchProcess, listProcesses, listWindows, mouseClick, mouseMove, osInfo, readFileTail, screenshotWindow, sendKeys, shellExec, takeScreenshot, waitForFile, } from './tools.js';
|
|
5
|
+
import { listScreens } from './screens.js';
|
|
6
|
+
import { findUnityLogs } from './logs.js';
|
|
7
|
+
function okText(payload) {
|
|
8
|
+
return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
|
|
9
|
+
}
|
|
10
|
+
function errText(message, extra) {
|
|
11
|
+
const payload = extra ? { error: message, ...extra } : { error: message };
|
|
12
|
+
return { content: [{ type: 'text', text: JSON.stringify(payload) }], isError: true };
|
|
13
|
+
}
|
|
14
|
+
function imageReply(base64Png, meta) {
|
|
15
|
+
return {
|
|
16
|
+
content: [
|
|
17
|
+
{ type: 'image', data: base64Png, mimeType: 'image/png' },
|
|
18
|
+
{ type: 'text', text: JSON.stringify(meta, null, 2) },
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const HOST_MCP_SERVER_NAME = 'awb-host';
|
|
23
|
+
const HOST_MCP_SERVER_VERSION = '1.0.0';
|
|
24
|
+
export function createHostMcpServer() {
|
|
25
|
+
const server = new McpServer({ name: HOST_MCP_SERVER_NAME, version: HOST_MCP_SERVER_VERSION }, { capabilities: {} });
|
|
26
|
+
server.tool('screenshot', 'Capture a full-screen screenshot of the host the agent-manager is running on. ' +
|
|
27
|
+
'Returns the PNG inline as an image content block (the model can see it directly) plus a JSON text block with width, height, saved_path, platform, backend. ' +
|
|
28
|
+
'Use this when you suspect a GUI tool (Unity Editor, browser, IDE) has popped up a modal, crashed, or otherwise stalled — a screenshot will tell you what state the screen is in. ' +
|
|
29
|
+
'Cross-OS: Windows uses System.Drawing, macOS uses screencapture, Linux uses grim / scrot / gnome-screenshot / import depending on what is installed.', {
|
|
30
|
+
save_path: z.string().optional().describe('Optional absolute path to also write the PNG to (in addition to returning base64).'),
|
|
31
|
+
display: z.number().int().optional().describe('Display index, 0 = primary. Honored on Windows / Linux X11.'),
|
|
32
|
+
}, async (args) => {
|
|
33
|
+
const result = await takeScreenshot(args);
|
|
34
|
+
if (!result.ok)
|
|
35
|
+
return errText(result.error, { hint: result.hint, details: result.details });
|
|
36
|
+
return imageReply(result.base64_png, {
|
|
37
|
+
width: result.width,
|
|
38
|
+
height: result.height,
|
|
39
|
+
saved_path: result.saved_path,
|
|
40
|
+
platform: result.platform,
|
|
41
|
+
backend: result.backend,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
server.tool('window_screenshot', 'Capture a screenshot of the first visible window whose title matches a regex pattern. ' +
|
|
45
|
+
'Useful when the agent needs to focus on a single app (e.g. Unity Editor, Visual Studio) without the rest of the desktop in frame. ' +
|
|
46
|
+
'On Linux Wayland (no per-window capture API) the implementation falls back to a full-screen capture and marks the backend with `wayland-fallback-fullscreen`. ' +
|
|
47
|
+
'Default `focus_first=true` brings the window to the foreground before capturing.', {
|
|
48
|
+
title_pattern: z.string().describe('Regex (JS syntax, case-insensitive) matched against window titles. First visible match wins.'),
|
|
49
|
+
save_path: z.string().optional().describe('Optional absolute path to also write the PNG to.'),
|
|
50
|
+
focus_first: z.boolean().optional().describe('Focus the target window before capture. Default true.'),
|
|
51
|
+
}, async (args) => {
|
|
52
|
+
const result = await screenshotWindow(args);
|
|
53
|
+
if (!result.ok)
|
|
54
|
+
return errText(result.error, { hint: result.hint, details: result.details });
|
|
55
|
+
return imageReply(result.base64_png, {
|
|
56
|
+
width: result.width,
|
|
57
|
+
height: result.height,
|
|
58
|
+
saved_path: result.saved_path,
|
|
59
|
+
platform: result.platform,
|
|
60
|
+
backend: result.backend,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
server.tool('list_windows', 'List visible windows on the host with their pid, title, and geometry. ' +
|
|
64
|
+
'Pass `title_pattern` to filter by regex. Use this to discover which window to target with `focus_window` / `window_screenshot` / `send_keys`. ' +
|
|
65
|
+
'On Linux Wayland this returns an empty list (no portable API).', {
|
|
66
|
+
title_pattern: z.string().optional().describe('Optional regex (JS syntax) to filter by window title.'),
|
|
67
|
+
include_hidden: z.boolean().optional().describe('Include not-currently-visible windows. Default false. Honored only on Windows.'),
|
|
68
|
+
}, async (args) => {
|
|
69
|
+
const result = await listWindows(args);
|
|
70
|
+
if (!result.ok)
|
|
71
|
+
return errText(result.error);
|
|
72
|
+
return okText({ count: result.windows.length, windows: result.windows, platform: result.platform });
|
|
73
|
+
});
|
|
74
|
+
server.tool('focus_window', 'Bring the first visible window matching `title_pattern` to the foreground. ' +
|
|
75
|
+
'Required as a precondition for `send_keys` / `mouse_click` on most platforms — input gets routed to whatever window currently has focus.', {
|
|
76
|
+
title_pattern: z.string().describe('Regex (JS syntax, case-insensitive) matched against window titles. First visible match wins.'),
|
|
77
|
+
}, async (args) => {
|
|
78
|
+
const result = await focusWindow(args);
|
|
79
|
+
if (!result.ok)
|
|
80
|
+
return errText(result.error, { hint: result.hint });
|
|
81
|
+
return okText({ title: result.title, platform: result.platform });
|
|
82
|
+
});
|
|
83
|
+
server.tool('send_keys', 'Send keystrokes to the currently-focused window (or focus a window first by passing `focus_window`). ' +
|
|
84
|
+
'Two modes: literal typing (default — `keys` is typed verbatim) OR hotkey chord (`chord:true` — `keys` is parsed as `ctrl+shift+p`, `cmd+s`, `f5`, `enter`, etc.). ' +
|
|
85
|
+
'On macOS, `cmd` maps to Command; on Windows, `cmd` falls back to Ctrl (Win key is not exposed via SendKeys). ' +
|
|
86
|
+
'Linux Wayland requires `wtype` (or `ydotool` with the daemon running).', {
|
|
87
|
+
keys: z.string().describe('Text to type, or hotkey chord like "ctrl+p" when `chord` is true.'),
|
|
88
|
+
chord: z.boolean().optional().describe('Parse `keys` as a hotkey chord instead of literal text. Default false.'),
|
|
89
|
+
focus_window: z.string().optional().describe('Optional title regex — focus this window before sending keys.'),
|
|
90
|
+
}, async (args) => {
|
|
91
|
+
const result = await sendKeys(args);
|
|
92
|
+
if (!result.ok)
|
|
93
|
+
return errText(result.error, { hint: result.hint });
|
|
94
|
+
return okText({ sent: true, platform: result.platform });
|
|
95
|
+
});
|
|
96
|
+
server.tool('mouse_click', 'Click at absolute screen coordinates (x, y). Use with prior `window_screenshot` to figure out where buttons are. ' +
|
|
97
|
+
'macOS requires `cliclick` (brew install cliclick) for non-left-click. Linux Wayland requires `ydotool`.', {
|
|
98
|
+
x: z.number().int().describe('Absolute screen x coordinate.'),
|
|
99
|
+
y: z.number().int().describe('Absolute screen y coordinate.'),
|
|
100
|
+
button: z.enum(['left', 'middle', 'right']).optional().describe('Button. Default left.'),
|
|
101
|
+
count: z.number().int().min(1).max(5).optional().describe('Click count (1 = single, 2 = double). Default 1.'),
|
|
102
|
+
}, async (args) => {
|
|
103
|
+
const result = await mouseClick(args);
|
|
104
|
+
if (!result.ok)
|
|
105
|
+
return errText(result.error, { hint: result.hint });
|
|
106
|
+
return okText({ clicked: true, platform: result.platform });
|
|
107
|
+
});
|
|
108
|
+
server.tool('mouse_move', 'Move the mouse cursor to absolute screen coordinates without clicking. Useful to hover before screenshotting (some IDE/editor surfaces only render tooltips on hover).', {
|
|
109
|
+
x: z.number().int().describe('Absolute screen x coordinate.'),
|
|
110
|
+
y: z.number().int().describe('Absolute screen y coordinate.'),
|
|
111
|
+
}, async (args) => {
|
|
112
|
+
const result = await mouseMove(args);
|
|
113
|
+
if (!result.ok)
|
|
114
|
+
return errText(result.error, { hint: result.hint });
|
|
115
|
+
return okText({ moved: true, platform: result.platform });
|
|
116
|
+
});
|
|
117
|
+
server.tool('list_processes', 'List running processes on the host (pid, name, cpu, mem_kb, ppid, user when available). ' +
|
|
118
|
+
'Pass `name_pattern` to filter by regex. Use this to check whether Unity / Editor / a build tool is still alive, find PIDs to kill, etc.', {
|
|
119
|
+
name_pattern: z.string().optional().describe('Regex (JS syntax) to filter process names / cmdlines.'),
|
|
120
|
+
}, async (args) => {
|
|
121
|
+
const result = await listProcesses(args);
|
|
122
|
+
if (!result.ok)
|
|
123
|
+
return errText(result.error);
|
|
124
|
+
return okText({ count: result.processes.length, processes: result.processes, platform: result.platform });
|
|
125
|
+
});
|
|
126
|
+
server.tool('kill_process', 'Kill a process by pid or by name regex. Default uses SIGTERM (graceful); pass `force:true` to use SIGKILL / `taskkill /F`. ' +
|
|
127
|
+
'Returns the list of pids actually killed. Common usage: after detecting Unity has frozen via `list_processes`, kill and then `launch_process` to relaunch it.', {
|
|
128
|
+
pid: z.number().int().optional().describe('PID to kill.'),
|
|
129
|
+
name_pattern: z.string().optional().describe('Regex matching process names — kills all matching processes.'),
|
|
130
|
+
force: z.boolean().optional().describe('Force kill (SIGKILL / taskkill /F). Default false (SIGTERM).'),
|
|
131
|
+
}, async (args) => {
|
|
132
|
+
const result = await killProcess(args);
|
|
133
|
+
if (!result.ok)
|
|
134
|
+
return errText(result.error);
|
|
135
|
+
return okText({ killed: result.killed, count: result.killed.length, platform: result.platform });
|
|
136
|
+
});
|
|
137
|
+
server.tool('launch_process', 'Launch a program on the host. Returns the pid (when available). The launched process is detached by default so it outlives the agent-manager; pass `detach:false` to tie its lifetime to the manager.', {
|
|
138
|
+
command: z.string().describe('Executable path or name on PATH.'),
|
|
139
|
+
args: z.array(z.string()).optional().describe('Command-line arguments.'),
|
|
140
|
+
cwd: z.string().optional().describe('Working directory.'),
|
|
141
|
+
env: z.record(z.string(), z.string()).optional().describe('Environment variables to set/override.'),
|
|
142
|
+
detach: z.boolean().optional().describe('Detach the launched process. Default true.'),
|
|
143
|
+
}, async (args) => {
|
|
144
|
+
const result = await launchProcess(args);
|
|
145
|
+
if (!result.ok)
|
|
146
|
+
return errText(result.error);
|
|
147
|
+
return okText({ pid: result.pid, platform: result.platform });
|
|
148
|
+
});
|
|
149
|
+
server.tool('wait_for_file', 'Poll for a file to appear (and optionally satisfy a content regex) within a timeout. Used to synchronize with external tools that signal completion via a file — e.g. Unity Editor writes a play-ready JSON signal once the play-mode loop has stabilized.', {
|
|
150
|
+
path: z.string().describe('Absolute path to wait for.'),
|
|
151
|
+
timeout_seconds: z.number().int().min(1).max(600).optional().describe('Max wait time. Default 30s, cap 600s.'),
|
|
152
|
+
poll_ms: z.number().int().min(50).max(10_000).optional().describe('Poll interval. Default 500ms.'),
|
|
153
|
+
newer_than_ms: z.number().int().optional().describe('Only succeed if the file mtime is at least this Unix-ms timestamp. Use to skip stale signal files.'),
|
|
154
|
+
content_pattern: z.string().optional().describe('Only succeed if file content matches this regex (first 64 KiB checked).'),
|
|
155
|
+
}, async (args) => {
|
|
156
|
+
const result = await waitForFile(args);
|
|
157
|
+
if (!result.ok)
|
|
158
|
+
return errText(result.error);
|
|
159
|
+
return okText(result);
|
|
160
|
+
});
|
|
161
|
+
server.tool('read_file_tail', 'Read the tail of a text file (default last 8 KiB, max 1 MiB). Use to inspect Unity Editor.log, build logs, error logs, etc., without paging through the whole file.', {
|
|
162
|
+
path: z.string().describe('Absolute path to read.'),
|
|
163
|
+
bytes: z.number().int().min(1).max(1024 * 1024).optional().describe('Bytes from end. Default 8192, max 1 MiB.'),
|
|
164
|
+
}, async (args) => {
|
|
165
|
+
const result = await readFileTail(args);
|
|
166
|
+
if (!result.ok)
|
|
167
|
+
return errText(result.error);
|
|
168
|
+
return okText(result);
|
|
169
|
+
});
|
|
170
|
+
server.tool('clipboard_read', 'Read the system clipboard as text. Cross-OS: PowerShell on Windows, pbpaste on macOS, wl-paste / xclip / xsel on Linux.', {}, async () => {
|
|
171
|
+
const result = await clipboardRead();
|
|
172
|
+
if (!result.ok)
|
|
173
|
+
return errText(result.error, { hint: result.hint });
|
|
174
|
+
return okText({ text: result.text, length: result.text.length, platform: result.platform });
|
|
175
|
+
});
|
|
176
|
+
server.tool('clipboard_write', 'Write text to the system clipboard. Useful when the agent has prepared a code snippet / answer for a human to paste somewhere the agent cannot directly type into.', {
|
|
177
|
+
text: z.string().describe('Text to put on the clipboard.'),
|
|
178
|
+
}, async (args) => {
|
|
179
|
+
const result = await clipboardWrite(args);
|
|
180
|
+
if (!result.ok)
|
|
181
|
+
return errText(result.error, { hint: result.hint });
|
|
182
|
+
return okText({ written: true, length: args.text.length, platform: result.platform });
|
|
183
|
+
});
|
|
184
|
+
server.tool('os_info', 'Report basic info about the host the agent-manager is running on (platform, hostname, user, OS release, arch, cpu count, memory, DISPLAY / WAYLAND_DISPLAY). ' +
|
|
185
|
+
'Use this once at the start of a session that needs to drive the GUI — different OS branches need different follow-up tools.', {}, async () => {
|
|
186
|
+
const result = await osInfo();
|
|
187
|
+
return okText(result.info);
|
|
188
|
+
});
|
|
189
|
+
server.tool('list_screens', 'Enumerate attached monitors with their virtual-desktop position, size, scale, and primary flag. Coordinates are in the same space `screenshot` / `mouse_click` / `mouse_move` expect, so use this before computing absolute pixel positions on a multi-monitor host.', {}, async () => {
|
|
190
|
+
const result = await listScreens();
|
|
191
|
+
if (!result.ok)
|
|
192
|
+
return errText(result.error, { hint: result.hint });
|
|
193
|
+
return okText({
|
|
194
|
+
count: result.monitors.length,
|
|
195
|
+
monitors: result.monitors,
|
|
196
|
+
platform: result.platform,
|
|
197
|
+
warning: result.warning,
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
server.tool('find_unity_logs', 'Resolve canonical Unity log paths for the host OS (Editor.log, Editor-prev.log, crash dir, Hub log). When `project_path` is supplied, also computes Player.log / Player-prev.log from the project\'s ProjectSettings companyName + productName. Pair with `read_file_tail` to inspect the contents. Use this when investigating a stuck Unity Editor — different OSes put Unity logs in completely different places.', {
|
|
201
|
+
project_path: z.string().optional().describe('Absolute path to a Unity project (the dir containing ProjectSettings/). Required for Player.log resolution.'),
|
|
202
|
+
}, async (args) => {
|
|
203
|
+
const result = await findUnityLogs(args);
|
|
204
|
+
return okText(result);
|
|
205
|
+
});
|
|
206
|
+
server.tool('shell_exec', 'Execute an arbitrary command on the host and return its stdout / stderr / exit code. Use as an escape hatch when a host_* tool above does not cover the workflow (e.g. Unity Editor batch mode invocation, custom build script). ' +
|
|
207
|
+
'Default timeout 30s; clamped to 600s. The command runs with the agent-manager process credentials.', {
|
|
208
|
+
command: z.string().describe('Executable path or name.'),
|
|
209
|
+
args: z.array(z.string()).optional().describe('Arguments.'),
|
|
210
|
+
cwd: z.string().optional().describe('Working directory.'),
|
|
211
|
+
timeout_seconds: z.number().int().min(1).max(600).optional().describe('Timeout. Default 30s, max 600s.'),
|
|
212
|
+
stdin: z.string().optional().describe('String to pipe into the child stdin.'),
|
|
213
|
+
}, async (args) => {
|
|
214
|
+
const result = await shellExec(args);
|
|
215
|
+
if (!result.ok)
|
|
216
|
+
return errText(result.error);
|
|
217
|
+
return okText({ code: result.code, stdout: result.stdout, stderr: result.stderr });
|
|
218
|
+
});
|
|
219
|
+
return server;
|
|
220
|
+
}
|
|
221
|
+
export async function runHostMcpServerOverStdio() {
|
|
222
|
+
const server = createHostMcpServer();
|
|
223
|
+
const transport = new StdioServerTransport();
|
|
224
|
+
await server.connect(transport);
|
|
225
|
+
process.stderr.write(`[awb-host-mcp] ${HOST_MCP_SERVER_NAME} v${HOST_MCP_SERVER_VERSION} running on stdio (platform=${process.platform})\n`);
|
|
226
|
+
await new Promise((resolve) => {
|
|
227
|
+
const close = () => resolve();
|
|
228
|
+
process.on('SIGTERM', close);
|
|
229
|
+
process.on('SIGINT', close);
|
|
230
|
+
transport.onclose = close;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/lib/host-mcp/server.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,cAAc,EACd,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAU1C,SAAS,MAAM,CAAC,OAAgB;IAC9B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC1F,CAAC;AAED,SAAS,OAAO,CAAC,OAAe,EAAE,KAA+B;IAC/D,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC1E,OAAO,EAA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
error: string;
|
|
4
|
+
hint?: string;
|
|
5
|
+
details?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export interface ScreenshotResult {
|
|
8
|
+
ok: true;
|
|
9
|
+
base64_png: string;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
saved_path?: string;
|
|
13
|
+
platform: string;
|
|
14
|
+
backend: string;
|
|
15
|
+
}
|
|
16
|
+
export interface WindowInfo {
|
|
17
|
+
id?: string;
|
|
18
|
+
title: string;
|
|
19
|
+
pid?: number;
|
|
20
|
+
app?: string;
|
|
21
|
+
x?: number;
|
|
22
|
+
y?: number;
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
25
|
+
focused?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface ProcessInfo {
|
|
28
|
+
pid: number;
|
|
29
|
+
name: string;
|
|
30
|
+
ppid?: number;
|
|
31
|
+
user?: string;
|
|
32
|
+
cpu?: number;
|
|
33
|
+
mem_kb?: number;
|
|
34
|
+
cmdline?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ScreenshotArgs {
|
|
37
|
+
save_path?: string;
|
|
38
|
+
display?: number;
|
|
39
|
+
}
|
|
40
|
+
export declare function takeScreenshot(args?: ScreenshotArgs): Promise<ScreenshotResult | ToolError>;
|
|
41
|
+
export interface WindowScreenshotArgs {
|
|
42
|
+
title_pattern: string;
|
|
43
|
+
save_path?: string;
|
|
44
|
+
focus_first?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare function screenshotWindow(args: WindowScreenshotArgs): Promise<ScreenshotResult | ToolError>;
|
|
47
|
+
export interface ListWindowsArgs {
|
|
48
|
+
title_pattern?: string;
|
|
49
|
+
include_hidden?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare function listWindows(args?: ListWindowsArgs): Promise<{
|
|
52
|
+
ok: true;
|
|
53
|
+
windows: WindowInfo[];
|
|
54
|
+
platform: string;
|
|
55
|
+
} | ToolError>;
|
|
56
|
+
export interface FocusWindowArgs {
|
|
57
|
+
title_pattern: string;
|
|
58
|
+
}
|
|
59
|
+
export declare function focusWindow(args: FocusWindowArgs): Promise<{
|
|
60
|
+
ok: true;
|
|
61
|
+
title: string;
|
|
62
|
+
platform: string;
|
|
63
|
+
} | ToolError>;
|
|
64
|
+
export interface SendKeysArgs {
|
|
65
|
+
keys: string;
|
|
66
|
+
chord?: boolean;
|
|
67
|
+
focus_window?: string;
|
|
68
|
+
}
|
|
69
|
+
export declare function sendKeys(args: SendKeysArgs): Promise<{
|
|
70
|
+
ok: true;
|
|
71
|
+
platform: string;
|
|
72
|
+
} | ToolError>;
|
|
73
|
+
export interface MouseClickArgs {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
button?: 'left' | 'middle' | 'right';
|
|
77
|
+
count?: number;
|
|
78
|
+
}
|
|
79
|
+
export declare function mouseClick(args: MouseClickArgs): Promise<{
|
|
80
|
+
ok: true;
|
|
81
|
+
platform: string;
|
|
82
|
+
} | ToolError>;
|
|
83
|
+
export interface MouseMoveArgs {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}
|
|
87
|
+
export declare function mouseMove(args: MouseMoveArgs): Promise<{
|
|
88
|
+
ok: true;
|
|
89
|
+
platform: string;
|
|
90
|
+
} | ToolError>;
|
|
91
|
+
export interface ListProcessesArgs {
|
|
92
|
+
name_pattern?: string;
|
|
93
|
+
}
|
|
94
|
+
export declare function listProcesses(args?: ListProcessesArgs): Promise<{
|
|
95
|
+
ok: true;
|
|
96
|
+
processes: ProcessInfo[];
|
|
97
|
+
platform: string;
|
|
98
|
+
} | ToolError>;
|
|
99
|
+
export interface KillProcessArgs {
|
|
100
|
+
pid?: number;
|
|
101
|
+
name_pattern?: string;
|
|
102
|
+
force?: boolean;
|
|
103
|
+
}
|
|
104
|
+
export declare function killProcess(args: KillProcessArgs): Promise<{
|
|
105
|
+
ok: true;
|
|
106
|
+
killed: number[];
|
|
107
|
+
platform: string;
|
|
108
|
+
} | ToolError>;
|
|
109
|
+
export interface LaunchProcessArgs {
|
|
110
|
+
command: string;
|
|
111
|
+
args?: string[];
|
|
112
|
+
cwd?: string;
|
|
113
|
+
env?: Record<string, string>;
|
|
114
|
+
detach?: boolean;
|
|
115
|
+
}
|
|
116
|
+
export declare function launchProcess(args: LaunchProcessArgs): Promise<{
|
|
117
|
+
ok: true;
|
|
118
|
+
pid: number | null;
|
|
119
|
+
platform: string;
|
|
120
|
+
} | ToolError>;
|
|
121
|
+
export interface WaitForFileArgs {
|
|
122
|
+
path: string;
|
|
123
|
+
timeout_seconds?: number;
|
|
124
|
+
poll_ms?: number;
|
|
125
|
+
newer_than_ms?: number;
|
|
126
|
+
content_pattern?: string;
|
|
127
|
+
}
|
|
128
|
+
export declare function waitForFile(args: WaitForFileArgs): Promise<{
|
|
129
|
+
ok: true;
|
|
130
|
+
appeared_at: string;
|
|
131
|
+
size: number;
|
|
132
|
+
content?: string;
|
|
133
|
+
} | ToolError>;
|
|
134
|
+
export interface ReadFileTailArgs {
|
|
135
|
+
path: string;
|
|
136
|
+
bytes?: number;
|
|
137
|
+
}
|
|
138
|
+
export declare function readFileTail(args: ReadFileTailArgs): Promise<{
|
|
139
|
+
ok: true;
|
|
140
|
+
content: string;
|
|
141
|
+
size: number;
|
|
142
|
+
mtime: string;
|
|
143
|
+
} | ToolError>;
|
|
144
|
+
export declare function clipboardRead(): Promise<{
|
|
145
|
+
ok: true;
|
|
146
|
+
text: string;
|
|
147
|
+
platform: string;
|
|
148
|
+
} | ToolError>;
|
|
149
|
+
export interface ClipboardWriteArgs {
|
|
150
|
+
text: string;
|
|
151
|
+
}
|
|
152
|
+
export declare function clipboardWrite(args: ClipboardWriteArgs): Promise<{
|
|
153
|
+
ok: true;
|
|
154
|
+
platform: string;
|
|
155
|
+
} | ToolError>;
|
|
156
|
+
export declare function osInfo(): Promise<{
|
|
157
|
+
ok: true;
|
|
158
|
+
info: Record<string, unknown>;
|
|
159
|
+
}>;
|
|
160
|
+
export interface ShellExecArgs {
|
|
161
|
+
command: string;
|
|
162
|
+
args?: string[];
|
|
163
|
+
cwd?: string;
|
|
164
|
+
timeout_seconds?: number;
|
|
165
|
+
stdin?: string;
|
|
166
|
+
}
|
|
167
|
+
export declare function shellExec(args: ShellExecArgs): Promise<{
|
|
168
|
+
ok: true;
|
|
169
|
+
code: number;
|
|
170
|
+
stdout: string;
|
|
171
|
+
stderr: string;
|
|
172
|
+
} | ToolError>;
|