localmcp-cli 0.0.0-stage → 0.0.11
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 +104 -2
- package/bin/cli.js +27 -0
- package/package.json +28 -4
- package/src/agents/hub.js +663 -0
- package/src/agents/providers.js +840 -0
- package/src/agents/store.js +524 -0
- package/src/cli/options.js +177 -0
- package/src/cli/runtime.js +126 -0
- package/src/cli/service.js +29 -0
- package/src/cli/tunnel.js +242 -0
- package/src/core/audit.js +105 -0
- package/src/core/auth.js +326 -0
- package/src/core/bounded-log.js +39 -0
- package/src/core/config.js +319 -0
- package/src/core/context-discovery.js +245 -0
- package/src/core/mesh.js +103 -0
- package/src/core/protocol.js +112 -0
- package/src/core/updater-client.js +165 -0
- package/src/server.js +260 -0
- package/src/tools/agents.js +149 -0
- package/src/tools/apply-patch.js +454 -0
- package/src/tools/diagnostics.js +158 -0
- package/src/tools/filesystem.js +1122 -0
- package/src/tools/gui-windows.js +268 -0
- package/src/tools/registry.js +119 -0
- package/src/tools/system.js +591 -0
package/src/server.js
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { createServer } from "node:http";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
5
|
+
import { createAgentHub } from "./agents/hub.js";
|
|
6
|
+
import { createAuditLogger } from "./core/audit.js";
|
|
7
|
+
import { createAuthService } from "./core/auth.js";
|
|
8
|
+
import { createRuntimeConfig } from "./core/config.js";
|
|
9
|
+
import { corsHeaders, handleModernRpc, readRpcBody, sendJson } from "./core/protocol.js";
|
|
10
|
+
import { createToolRegistry } from "./tools/registry.js";
|
|
11
|
+
|
|
12
|
+
const config = createRuntimeConfig();
|
|
13
|
+
const audit = createAuditLogger({ auditDir: config.state.auditDir });
|
|
14
|
+
const auth = createAuthService({ config });
|
|
15
|
+
|
|
16
|
+
const legacyHubBase = path.join(config.state.artifactDir, "agent-hub");
|
|
17
|
+
const agentHub = createAgentHub({
|
|
18
|
+
baseDir: existsSync(path.join(legacyHubBase, "agent-hub", "tasks")) ? legacyHubBase : config.state.artifactDir,
|
|
19
|
+
defaultCwd: config.state.allowedRoots[0] || config.state.cwd,
|
|
20
|
+
resolveAllowedCwd: async (candidate) =>
|
|
21
|
+
config.resolveAllowedPath(candidate || config.state.allowedRoots[0] || ".", { mustExist: true }),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const registry = createToolRegistry({ config, auth, audit, agentHub });
|
|
25
|
+
|
|
26
|
+
function handleLocalAdmin(req, res, url) {
|
|
27
|
+
if (!auth.isDirectLoopback(req)) {
|
|
28
|
+
res.writeHead(404).end("Not Found");
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (!auth.hasValidSecretKey(req, url)) {
|
|
32
|
+
sendJson(res, 401, { error: "Local admin requires a valid secret key." });
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (req.method === "POST" && url.pathname === "/__local_admin/reload") {
|
|
37
|
+
const reloaded = config.reload({ force: true });
|
|
38
|
+
sendJson(res, 200, {
|
|
39
|
+
ok: true,
|
|
40
|
+
reloaded,
|
|
41
|
+
name: config.state.serverName,
|
|
42
|
+
port: config.state.port,
|
|
43
|
+
allowedRoots: config.state.allowedRoots,
|
|
44
|
+
publicMcpUrl: config.state.publicMcpUrl,
|
|
45
|
+
quickTunnel: config.state.quickTunnel,
|
|
46
|
+
capabilities: config.getCapabilities(),
|
|
47
|
+
});
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (req.method === "GET" && url.pathname === "/__local_admin/state") {
|
|
52
|
+
sendJson(res, 200, {
|
|
53
|
+
ok: true,
|
|
54
|
+
pid: process.pid,
|
|
55
|
+
name: config.state.serverName,
|
|
56
|
+
version: config.state.version,
|
|
57
|
+
port: config.state.port,
|
|
58
|
+
host: config.state.host,
|
|
59
|
+
mcpPath: config.state.mcpPath,
|
|
60
|
+
startedAt: config.state.startedAt.toISOString(),
|
|
61
|
+
uptimeSeconds: Math.round(process.uptime()),
|
|
62
|
+
allowedRoots: config.state.allowedRoots,
|
|
63
|
+
publicMcpUrl: config.state.publicMcpUrl,
|
|
64
|
+
quickTunnel: config.state.quickTunnel,
|
|
65
|
+
capabilities: config.getCapabilities(),
|
|
66
|
+
recentEvents: audit.recent(100),
|
|
67
|
+
});
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (req.method === "GET" && url.pathname === "/__local_admin/events") {
|
|
72
|
+
res.writeHead(200, {
|
|
73
|
+
"content-type": "text/event-stream",
|
|
74
|
+
"cache-control": "no-cache",
|
|
75
|
+
connection: "keep-alive",
|
|
76
|
+
});
|
|
77
|
+
res.write(`data: ${JSON.stringify({ type: "connected", time: new Date().toISOString() })}\n\n`);
|
|
78
|
+
audit.addSseClient(res);
|
|
79
|
+
req.on("close", () => audit.removeSseClient(res));
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
res.writeHead(404).end("Not Found");
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function route(req, res) {
|
|
88
|
+
if (!req.url) {
|
|
89
|
+
res.writeHead(400).end("Missing URL");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
config.reload();
|
|
94
|
+
const { mcpPath, port, quickTunnel } = config.state;
|
|
95
|
+
const url = new URL(req.url, "http://localhost");
|
|
96
|
+
if (config.state.connectionMode === "local") {
|
|
97
|
+
const hosts = ["localhost", "127.0.0.1"].map(host => port === 80 ? host : host + ":" + port);
|
|
98
|
+
const host = req.headers.host?.toLowerCase();
|
|
99
|
+
const origins = hosts.map(value => "http://" + value);
|
|
100
|
+
if (!auth.isDirectLoopback(req) || !hosts.includes(host) ||
|
|
101
|
+
(req.headers.origin !== undefined && !origins.includes(req.headers.origin)) ||
|
|
102
|
+
req.headers["sec-fetch-site"] === "cross-site") return res.writeHead(403).end();
|
|
103
|
+
if (url.pathname.startsWith("/oauth/") || url.pathname.startsWith("/.well-known/")) return res.writeHead(404).end();
|
|
104
|
+
} else if (req.headers.origin) {
|
|
105
|
+
const allowed = [`http://127.0.0.1:${port}`, `http://localhost:${port}`];
|
|
106
|
+
if (config.state.publicMcpUrl) allowed.push(new URL(config.state.publicMcpUrl).origin);
|
|
107
|
+
if (!allowed.includes(req.headers.origin)) return sendJson(res, 403, { error: "Invalid origin" });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (url.pathname.startsWith("/__local_admin/")) {
|
|
111
|
+
handleLocalAdmin(req, res, url);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (
|
|
116
|
+
req.method === "OPTIONS" &&
|
|
117
|
+
(url.pathname.startsWith(mcpPath) || url.pathname.startsWith("/oauth/") || url.pathname.startsWith("/.well-known/"))
|
|
118
|
+
) {
|
|
119
|
+
res.writeHead(204, corsHeaders()).end();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (quickTunnel && url.pathname !== "/health" && !auth.hasValidSecretKey(req, url)) {
|
|
124
|
+
sendJson(res, 401, { error: "A valid secret key is required in quick tunnel mode." });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (req.method === "GET" && url.pathname === "/") {
|
|
129
|
+
if (auth.authenticateRequest(req, url).kind === "anonymous") return sendJson(res, 401, { error: "Authorization required" });
|
|
130
|
+
sendJson(res, 200, {
|
|
131
|
+
name: config.state.serverName,
|
|
132
|
+
version: config.state.version,
|
|
133
|
+
ok: true,
|
|
134
|
+
mcp: mcpPath,
|
|
135
|
+
allowedRoots: config.state.allowedRoots,
|
|
136
|
+
capabilities: config.getCapabilities(),
|
|
137
|
+
});
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (req.method === "GET" && url.pathname === "/health") {
|
|
142
|
+
sendJson(res, 200, {
|
|
143
|
+
ok: true,
|
|
144
|
+
name: config.state.serverName,
|
|
145
|
+
version: config.state.version,
|
|
146
|
+
mcpPath,
|
|
147
|
+
|
|
148
|
+
quickTunnelProtected: quickTunnel,
|
|
149
|
+
oauth: config.state.connectionMode !== "local" && !quickTunnel,
|
|
150
|
+
});
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (
|
|
155
|
+
req.method === "GET" &&
|
|
156
|
+
(url.pathname === "/.well-known/oauth-protected-resource" ||
|
|
157
|
+
url.pathname === `/.well-known/oauth-protected-resource${mcpPath}`)
|
|
158
|
+
) {
|
|
159
|
+
sendJson(res, 200, auth.protectedResourceMetadata(req));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (
|
|
164
|
+
req.method === "GET" &&
|
|
165
|
+
(url.pathname === "/.well-known/oauth-authorization-server" ||
|
|
166
|
+
url.pathname === "/.well-known/openid-configuration")
|
|
167
|
+
) {
|
|
168
|
+
sendJson(res, 200, auth.oauthMetadata(req));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (req.method === "POST" && url.pathname === "/oauth/register") {
|
|
173
|
+
await auth.handleRegister(req, res);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (["GET", "POST"].includes(req.method) && url.pathname === "/oauth/authorize") {
|
|
177
|
+
await auth.handleAuthorize(req, res, url);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (req.method === "POST" && url.pathname === "/oauth/token") {
|
|
181
|
+
await auth.handleToken(req, res);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Stateless MCP 2026-07-28: reject standalone GET SSE stream immediately with 405
|
|
186
|
+
if (url.pathname === mcpPath && req.method === "GET") {
|
|
187
|
+
sendJson(
|
|
188
|
+
res,
|
|
189
|
+
405,
|
|
190
|
+
{
|
|
191
|
+
jsonrpc: "2.0",
|
|
192
|
+
error: {
|
|
193
|
+
code: -32000,
|
|
194
|
+
message: "Method Not Allowed: LocalMCP runs in stateless JSON POST mode and does not expose GET SSE streams.",
|
|
195
|
+
},
|
|
196
|
+
id: null,
|
|
197
|
+
},
|
|
198
|
+
{ Allow: "POST, DELETE, OPTIONS" }
|
|
199
|
+
);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (url.pathname === mcpPath && (req.method === "POST" || req.method === "DELETE")) {
|
|
204
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
205
|
+
res.setHeader("Access-Control-Expose-Headers", "Mcp-Session-Id");
|
|
206
|
+
|
|
207
|
+
const authContext = auth.authenticateRequest(req, url);
|
|
208
|
+
let body;
|
|
209
|
+
if (req.method === "POST") {
|
|
210
|
+
if (req.headers["content-type"]?.split(";")[0].trim() !== "application/json") return sendJson(res, 415, { error: "Expected JSON" });
|
|
211
|
+
try { body = await readRpcBody(req); } catch (error) {
|
|
212
|
+
return sendJson(res, error instanceof RangeError ? 413 : 400, { jsonrpc: "2.0", id: null, error: { code: -32700, message: "Invalid request body" } });
|
|
213
|
+
}
|
|
214
|
+
if (await handleModernRpc(req, res, body, registry, authContext, config.state)) return;
|
|
215
|
+
}
|
|
216
|
+
const server = registry.createStatelessMcpServer(authContext);
|
|
217
|
+
const transport = new StreamableHTTPServerTransport({
|
|
218
|
+
sessionIdGenerator: undefined,
|
|
219
|
+
enableJsonResponse: true,
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
res.on("close", () => {
|
|
223
|
+
transport.close().catch(() => {});
|
|
224
|
+
server.close().catch(() => {});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
await server.connect(transport);
|
|
229
|
+
await transport.handleRequest(req, res, body);
|
|
230
|
+
} catch (error) {
|
|
231
|
+
|
|
232
|
+
if (!res.headersSent) {
|
|
233
|
+
sendJson(res, 500, { error: "Internal server error" });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
res.writeHead(404).end("Not Found");
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const httpServer = createServer((req, res) => {
|
|
243
|
+
route(req, res).catch(() => {
|
|
244
|
+
if (res.headersSent) res.end();
|
|
245
|
+
else sendJson(res, 500, { error: "Internal server error" });
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
httpServer.listen(config.state.port, config.state.host, () => {
|
|
250
|
+
console.log("LocalMCP ready.");
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
const shutdown = () => {
|
|
254
|
+
httpServer.close(() => process.exit(0));
|
|
255
|
+
setTimeout(() => process.exit(0), 2000).unref();
|
|
256
|
+
};
|
|
257
|
+
process.on("SIGTERM", shutdown);
|
|
258
|
+
process.on("SIGINT", shutdown);
|
|
259
|
+
|
|
260
|
+
export { httpServer, config, agentHub };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { CONTROL_SECURITY_SCHEMES, okResult, toolMeta } from "../core/protocol.js";
|
|
2
|
+
|
|
3
|
+
export function createAgentTools({ config, auth, agentHub }) {
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
name: "agent_list",
|
|
7
|
+
title: "List local and registered agents",
|
|
8
|
+
description:
|
|
9
|
+
"List detected local agent engines (Antigravity, Codex CLI, Claude Code, Gemini CLI, DSH, WorkBuddy), registered multi-instance agents (e.g. agent1, agent2, pm), discovered local sessions, and recent tasks. Passing from_agent auto-registers/renews the caller and returns unread inbox reminders.",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
from_agent: { type: "string", description: "Caller agent_id for implicit registration and unread inbox piggyback." },
|
|
14
|
+
engine: { type: "string", description: "Optional engine filter (antigravity, codex, claude, gemini, dsh, workbuddy, custom)." },
|
|
15
|
+
include_sessions: { type: "boolean", description: "Include discovered local sessions (default true)." },
|
|
16
|
+
limit: { type: "integer", minimum: 1, maximum: 30, description: "Max discovered sessions/tasks to return (default 12)." },
|
|
17
|
+
control_pin: { type: "string", description: "Optional fallback PIN." },
|
|
18
|
+
},
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
},
|
|
21
|
+
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false, idempotentHint: true },
|
|
22
|
+
_meta: toolMeta("Listing local agents", "Agent directory ready", CONTROL_SECURITY_SCHEMES),
|
|
23
|
+
async handler(args, { authContext }) {
|
|
24
|
+
auth.requireCapability("ALLOW_AGENTS", config.state.allowAgents, args.control_pin, authContext);
|
|
25
|
+
const result = await agentHub.listAgents(args);
|
|
26
|
+
return okResult(JSON.stringify(result, null, 2), result);
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "agent_register",
|
|
31
|
+
title: "Register or renew an agent",
|
|
32
|
+
description:
|
|
33
|
+
"Register or renew a named agent instance (e.g. agent1, agent2, pm) in the central directory with aliases, role, workspace, delivery_mode ('push' or 'inbox'), optional target_id, and TTL.",
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: "object",
|
|
36
|
+
properties: {
|
|
37
|
+
agent_id: { type: "string", description: "Unique agent identifier such as agent1, agent2, or pm." },
|
|
38
|
+
aliases: { type: "array", items: { type: "string" }, description: "Optional alias names." },
|
|
39
|
+
engine: { type: "string", description: "Engine type (antigravity, codex, claude, gemini, dsh, workbuddy, custom)." },
|
|
40
|
+
role: { type: "string", description: "Short role description." },
|
|
41
|
+
workspace: { type: "string", description: "Optional workspace directory inside LOCAL_CONTROL_ROOTS." },
|
|
42
|
+
delivery_mode: { type: "string", enum: ["push", "inbox"], description: "Notification mode: push or inbox." },
|
|
43
|
+
target_id: { type: "string", description: "Underlying session/conversation ID for push-capable engines." },
|
|
44
|
+
status: { type: "string", description: "Optional status label (idle, busy, waiting)." },
|
|
45
|
+
ttl_seconds: { type: "integer", minimum: 60, maximum: 604800, description: "TTL in seconds (default 86400)." },
|
|
46
|
+
from_agent: { type: "string", description: "Caller agent_id for unread inbox piggyback." },
|
|
47
|
+
control_pin: { type: "string", description: "Optional fallback PIN." },
|
|
48
|
+
},
|
|
49
|
+
required: ["agent_id"],
|
|
50
|
+
additionalProperties: false,
|
|
51
|
+
},
|
|
52
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false, idempotentHint: true },
|
|
53
|
+
_meta: toolMeta("Registering agent", "Agent registered", CONTROL_SECURITY_SCHEMES),
|
|
54
|
+
async handler(args, { authContext }) {
|
|
55
|
+
auth.requireCapability("ALLOW_AGENTS", config.state.allowAgents, args.control_pin, authContext);
|
|
56
|
+
const result = await agentHub.registerAgent(args);
|
|
57
|
+
return okResult(JSON.stringify(result, null, 2), result);
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "agent_dispatch",
|
|
62
|
+
title: "Dispatch task to an agent",
|
|
63
|
+
description:
|
|
64
|
+
"Asynchronously dispatch a task to a registered agent, a raw Antigravity conversation UUID, or a local engine (antigravity, codex, claude, gemini, auto). Immediately returns a durable MCP-2026-07-28-aligned taskId handle.",
|
|
65
|
+
inputSchema: {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
target: { type: "string", description: "Target agent_id, alias, Antigravity conversation UUID, or engine name." },
|
|
69
|
+
engine: { type: "string", description: "Explicit engine when creating a new instance (antigravity, codex, claude, gemini, auto)." },
|
|
70
|
+
prompt: { type: "string", description: "Task instructions to send to the target agent." },
|
|
71
|
+
cwd: { type: "string", description: "Optional working directory inside LOCAL_CONTROL_ROOTS." },
|
|
72
|
+
title: { type: "string", description: "Short task or conversation title." },
|
|
73
|
+
model: { type: "string", description: "Optional model override supported by the target engine." },
|
|
74
|
+
profile: { type: "string", description: "Optional profile override (e.g. Antigravity profile)." },
|
|
75
|
+
wait_seconds: { type: "integer", minimum: 0, maximum: 20, description: "Optional short wait (0-20s) before returning handle." },
|
|
76
|
+
ttl_seconds: { type: "integer", minimum: 60, maximum: 604800, description: "Task retention TTL in seconds." },
|
|
77
|
+
from_agent: { type: "string", description: "Caller agent_id for tracking, completion callback, and inbox piggyback." },
|
|
78
|
+
control_pin: { type: "string", description: "Optional fallback PIN." },
|
|
79
|
+
},
|
|
80
|
+
required: ["prompt"],
|
|
81
|
+
additionalProperties: false,
|
|
82
|
+
},
|
|
83
|
+
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true, idempotentHint: false },
|
|
84
|
+
_meta: toolMeta("Dispatching agent task", "Agent task dispatched", CONTROL_SECURITY_SCHEMES),
|
|
85
|
+
async handler(args, { authContext }) {
|
|
86
|
+
auth.requireCapability("ALLOW_AGENTS", config.state.allowAgents, args.control_pin, authContext);
|
|
87
|
+
const result = await agentHub.dispatchTask(args);
|
|
88
|
+
return okResult(JSON.stringify(result, null, 2), result);
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "agent_result",
|
|
93
|
+
title: "Query, cancel, or update an agent task",
|
|
94
|
+
description:
|
|
95
|
+
"Check non-blocking task status and paginated output by task_id (aligned with MCP 2026-07-28 Tasks: working / input_required / completed / failed / cancelled), cancel a running task, or report completion/failure/input_required.",
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: "object",
|
|
98
|
+
properties: {
|
|
99
|
+
task_id: { type: "string", description: "Durable taskId returned by agent_dispatch." },
|
|
100
|
+
action: { type: "string", enum: ["get", "cancel", "complete", "fail", "input_required"], description: "Operation (default 'get')." },
|
|
101
|
+
message: { type: "string", description: "Optional status message, cancel reason, or input prompt." },
|
|
102
|
+
result_text: { type: "string", description: "Final result text when action is 'complete' or error detail on 'fail'." },
|
|
103
|
+
output_cursor: { type: "integer", minimum: 0, description: "Character offset cursor for paginated output retrieval." },
|
|
104
|
+
max_chars: { type: "integer", minimum: 200, maximum: 32000, description: "Max output characters to return (default 4000)." },
|
|
105
|
+
from_agent: { type: "string", description: "Caller agent_id for implicit renewal and unread inbox piggyback." },
|
|
106
|
+
control_pin: { type: "string", description: "Optional fallback PIN." },
|
|
107
|
+
},
|
|
108
|
+
required: ["task_id"],
|
|
109
|
+
additionalProperties: false,
|
|
110
|
+
},
|
|
111
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false, idempotentHint: false },
|
|
112
|
+
_meta: toolMeta("Checking agent task result", "Agent task status ready", CONTROL_SECURITY_SCHEMES),
|
|
113
|
+
async handler(args, { authContext }) {
|
|
114
|
+
auth.requireCapability("ALLOW_AGENTS", config.state.allowAgents, args.control_pin, authContext);
|
|
115
|
+
const result = await agentHub.getOrUpdateResult(args);
|
|
116
|
+
return okResult(JSON.stringify(result, null, 2), result);
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "agent_notify",
|
|
121
|
+
title: "Send agent notification or read inbox",
|
|
122
|
+
description:
|
|
123
|
+
"Dual-mode cross-agent messaging: action='send' pushes directly to wake push-capable targets or persists to local inbox; action='inbox' reads and marks unread messages for from_agent.",
|
|
124
|
+
inputSchema: {
|
|
125
|
+
type: "object",
|
|
126
|
+
properties: {
|
|
127
|
+
action: { type: "string", enum: ["send", "inbox"], description: "Send a notification or read inbox messages." },
|
|
128
|
+
to_agent: { type: "string", description: "Recipient agent_id, alias, or Antigravity conversation UUID (for send)." },
|
|
129
|
+
message: { type: "string", description: "Notification or follow-up message content (for send)." },
|
|
130
|
+
title: { type: "string", description: "Optional short title." },
|
|
131
|
+
task_id: { type: "string", description: "Optional related task_id (also resumes input_required tasks)." },
|
|
132
|
+
from_agent: { type: "string", description: "Sender/owner agent_id (auto-registers and returns unread piggyback on send)." },
|
|
133
|
+
mark_read: { type: "boolean", description: "Mark returned messages as read when action='inbox' (default true)." },
|
|
134
|
+
include_read: { type: "boolean", description: "Include previously read messages when action='inbox' (default false)." },
|
|
135
|
+
limit: { type: "integer", minimum: 1, maximum: 100, description: "Max inbox messages to return (default 20)." },
|
|
136
|
+
control_pin: { type: "string", description: "Optional fallback PIN." },
|
|
137
|
+
},
|
|
138
|
+
additionalProperties: false,
|
|
139
|
+
},
|
|
140
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true, idempotentHint: false },
|
|
141
|
+
_meta: toolMeta("Delivering agent notification", "Agent notification complete", CONTROL_SECURITY_SCHEMES),
|
|
142
|
+
async handler(args, { authContext }) {
|
|
143
|
+
auth.requireCapability("ALLOW_AGENTS", config.state.allowAgents, args.control_pin, authContext);
|
|
144
|
+
const result = await agentHub.notifyOrInbox(args);
|
|
145
|
+
return okResult(JSON.stringify(result, null, 2), result);
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
}
|