@agentvault/agentvault 0.17.3 → 0.17.4
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/dist/channel.d.ts +8 -0
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +162 -23
- package/dist/cli.js.map +4 -4
- package/dist/http-handlers.d.ts +7 -0
- package/dist/http-handlers.d.ts.map +1 -1
- package/dist/index.js +213 -68
- package/dist/index.js.map +4 -4
- package/dist/mcp-proxy-helpers.d.ts +9 -0
- package/dist/mcp-proxy-helpers.d.ts.map +1 -0
- package/dist/mcp-server.d.ts +2 -0
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/openclaw-entry.d.ts.map +1 -1
- package/dist/openclaw-entry.js +16423 -179
- package/dist/openclaw-entry.js.map +4 -4
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/http-handlers.d.ts
CHANGED
|
@@ -39,4 +39,11 @@ export declare function handleStatusRequest(channel: SecureChannel): HandlerResu
|
|
|
39
39
|
* Handle GET /targets — return available delivery destinations.
|
|
40
40
|
*/
|
|
41
41
|
export declare function handleTargetsRequest(channel: SecureChannel): HandlerResult;
|
|
42
|
+
/**
|
|
43
|
+
* Handle GET /mcp-config — return MCP connection config for this agent.
|
|
44
|
+
*
|
|
45
|
+
* Returns JSON suitable for adding to Claude Code, Cursor, or other MCP host
|
|
46
|
+
* configuration files.
|
|
47
|
+
*/
|
|
48
|
+
export declare function handleMcpConfigRequest(agentName: string, port: number, mcpSkillCount: number): HandlerResult;
|
|
42
49
|
//# sourceMappingURL=http-handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-handlers.d.ts","sourceRoot":"","sources":["../src/http-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,aAAa,CAAC,CAqExB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,aAAa,CAAC,CAmCxB;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,aAAa,CAAC,CA8BxB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAUzE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAW1E"}
|
|
1
|
+
{"version":3,"file":"http-handlers.d.ts","sourceRoot":"","sources":["../src/http-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,aAAa,CAAC,CAqExB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,aAAa,CAAC,CAmCxB;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,aAAa,CAAC,CA8BxB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAUzE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAW1E;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,GACpB,aAAa,CAkBf"}
|
package/dist/index.js
CHANGED
|
@@ -46538,6 +46538,7 @@ var http_handlers_exports = {};
|
|
|
46538
46538
|
__export(http_handlers_exports, {
|
|
46539
46539
|
handleActionRequest: () => handleActionRequest,
|
|
46540
46540
|
handleDecisionRequest: () => handleDecisionRequest,
|
|
46541
|
+
handleMcpConfigRequest: () => handleMcpConfigRequest,
|
|
46541
46542
|
handleSendRequest: () => handleSendRequest,
|
|
46542
46543
|
handleStatusRequest: () => handleStatusRequest,
|
|
46543
46544
|
handleTargetsRequest: () => handleTargetsRequest
|
|
@@ -46679,12 +46680,90 @@ function handleTargetsRequest(channel) {
|
|
|
46679
46680
|
}
|
|
46680
46681
|
};
|
|
46681
46682
|
}
|
|
46683
|
+
function handleMcpConfigRequest(agentName, port, mcpSkillCount) {
|
|
46684
|
+
return {
|
|
46685
|
+
status: 200,
|
|
46686
|
+
body: {
|
|
46687
|
+
mcpServers: {
|
|
46688
|
+
[`agentvault-${agentName}`]: {
|
|
46689
|
+
url: `http://127.0.0.1:${port}/mcp`
|
|
46690
|
+
}
|
|
46691
|
+
},
|
|
46692
|
+
_meta: {
|
|
46693
|
+
agent: agentName,
|
|
46694
|
+
skills_count: mcpSkillCount,
|
|
46695
|
+
transport: "streamable-http",
|
|
46696
|
+
auth: "none (localhost)",
|
|
46697
|
+
instructions: "Add the mcpServers block to your MCP configuration file (e.g., .mcp.json or mcp_config.json)"
|
|
46698
|
+
}
|
|
46699
|
+
}
|
|
46700
|
+
};
|
|
46701
|
+
}
|
|
46682
46702
|
var init_http_handlers = __esm({
|
|
46683
46703
|
"src/http-handlers.ts"() {
|
|
46684
46704
|
"use strict";
|
|
46685
46705
|
}
|
|
46686
46706
|
});
|
|
46687
46707
|
|
|
46708
|
+
// src/mcp-proxy-helpers.ts
|
|
46709
|
+
var mcp_proxy_helpers_exports = {};
|
|
46710
|
+
__export(mcp_proxy_helpers_exports, {
|
|
46711
|
+
createMcpProxyRequest: () => createMcpProxyRequest
|
|
46712
|
+
});
|
|
46713
|
+
import { Readable } from "node:stream";
|
|
46714
|
+
async function createMcpProxyRequest(mcpServer, payload) {
|
|
46715
|
+
const bodyStr = JSON.stringify(payload);
|
|
46716
|
+
const req = Object.assign(new Readable({ read() {
|
|
46717
|
+
} }), {
|
|
46718
|
+
method: "POST",
|
|
46719
|
+
url: "/mcp",
|
|
46720
|
+
headers: {
|
|
46721
|
+
"content-type": "application/json",
|
|
46722
|
+
"content-length": String(Buffer.byteLength(bodyStr)),
|
|
46723
|
+
// Use localhost to bypass SPT validation (WS already authenticated)
|
|
46724
|
+
host: "localhost"
|
|
46725
|
+
},
|
|
46726
|
+
socket: { remoteAddress: "127.0.0.1" }
|
|
46727
|
+
});
|
|
46728
|
+
req.push(bodyStr);
|
|
46729
|
+
req.push(null);
|
|
46730
|
+
let responseStatus = 200;
|
|
46731
|
+
let responseBody = "";
|
|
46732
|
+
const chunks = [];
|
|
46733
|
+
const res = {
|
|
46734
|
+
writeHead: (status) => {
|
|
46735
|
+
responseStatus = status;
|
|
46736
|
+
},
|
|
46737
|
+
write: (chunk) => {
|
|
46738
|
+
chunks.push(typeof chunk === "string" ? chunk : chunk.toString());
|
|
46739
|
+
return true;
|
|
46740
|
+
},
|
|
46741
|
+
end: (data) => {
|
|
46742
|
+
if (data) chunks.push(typeof data === "string" ? data : data.toString());
|
|
46743
|
+
responseBody = chunks.join("");
|
|
46744
|
+
},
|
|
46745
|
+
setHeader: () => {
|
|
46746
|
+
},
|
|
46747
|
+
getHeader: () => void 0,
|
|
46748
|
+
statusCode: 200,
|
|
46749
|
+
headersSent: false
|
|
46750
|
+
};
|
|
46751
|
+
await mcpServer.handleRequest(req, res);
|
|
46752
|
+
if (responseBody) {
|
|
46753
|
+
try {
|
|
46754
|
+
return JSON.parse(responseBody);
|
|
46755
|
+
} catch {
|
|
46756
|
+
return { jsonrpc: "2.0", error: { code: -32603, message: responseBody } };
|
|
46757
|
+
}
|
|
46758
|
+
}
|
|
46759
|
+
return null;
|
|
46760
|
+
}
|
|
46761
|
+
var init_mcp_proxy_helpers = __esm({
|
|
46762
|
+
"src/mcp-proxy-helpers.ts"() {
|
|
46763
|
+
"use strict";
|
|
46764
|
+
}
|
|
46765
|
+
});
|
|
46766
|
+
|
|
46688
46767
|
// src/workspace-handlers.ts
|
|
46689
46768
|
var workspace_handlers_exports = {};
|
|
46690
46769
|
__export(workspace_handlers_exports, {
|
|
@@ -46900,6 +46979,7 @@ var init_channel = __esm({
|
|
|
46900
46979
|
_stopped = false;
|
|
46901
46980
|
_persisted = null;
|
|
46902
46981
|
_httpServer = null;
|
|
46982
|
+
_mcpServer = null;
|
|
46903
46983
|
_pollFallbackTimer = null;
|
|
46904
46984
|
_heartbeatTimer = null;
|
|
46905
46985
|
_heartbeatCallback = null;
|
|
@@ -47951,9 +48031,28 @@ var init_channel = __esm({
|
|
|
47951
48031
|
const result = handlers.handleTargetsRequest(this);
|
|
47952
48032
|
res.writeHead(result.status, { "Content-Type": "application/json" });
|
|
47953
48033
|
res.end(JSON.stringify(result.body));
|
|
48034
|
+
} else if (req.url === "/mcp" && (req.method === "POST" || req.method === "GET" || req.method === "DELETE")) {
|
|
48035
|
+
if (!this._mcpServer) {
|
|
48036
|
+
res.writeHead(503, { "Content-Type": "application/json" });
|
|
48037
|
+
res.end(JSON.stringify({ ok: false, error: "MCP server not initialized" }));
|
|
48038
|
+
return;
|
|
48039
|
+
}
|
|
48040
|
+
this._mcpServer.handleRequest(req, res).catch((err) => {
|
|
48041
|
+
console.error("[MCP] Request handling error:", err);
|
|
48042
|
+
if (!res.headersSent) {
|
|
48043
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
48044
|
+
res.end(JSON.stringify({ ok: false, error: "Internal MCP error" }));
|
|
48045
|
+
}
|
|
48046
|
+
});
|
|
48047
|
+
} else if (req.method === "GET" && req.url === "/mcp-config") {
|
|
48048
|
+
const agentName = this.config.agentName ?? "agent";
|
|
48049
|
+
const mcpSkillCount = this._mcpServer?.skillCount ?? 0;
|
|
48050
|
+
const result = handlers.handleMcpConfigRequest(agentName, port, mcpSkillCount);
|
|
48051
|
+
res.writeHead(result.status, { "Content-Type": "application/json" });
|
|
48052
|
+
res.end(JSON.stringify(result.body));
|
|
47954
48053
|
} else {
|
|
47955
48054
|
res.writeHead(404, { "Content-Type": "application/json" });
|
|
47956
|
-
res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send, POST /decision, POST /action, GET /status,
|
|
48055
|
+
res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send, POST /decision, POST /action, GET /status, GET /targets, or /mcp" }));
|
|
47957
48056
|
}
|
|
47958
48057
|
});
|
|
47959
48058
|
this._httpServer.listen(port, "127.0.0.1", () => {
|
|
@@ -47966,6 +48065,17 @@ var init_channel = __esm({
|
|
|
47966
48065
|
this._httpServer = null;
|
|
47967
48066
|
}
|
|
47968
48067
|
}
|
|
48068
|
+
/**
|
|
48069
|
+
* Attach an MCP server instance to this channel.
|
|
48070
|
+
* The MCP server will be served at /mcp on the local HTTP server.
|
|
48071
|
+
*/
|
|
48072
|
+
setMcpServer(mcpServer) {
|
|
48073
|
+
this._mcpServer = mcpServer;
|
|
48074
|
+
}
|
|
48075
|
+
/** The attached MCP server, if any. */
|
|
48076
|
+
get mcpServer() {
|
|
48077
|
+
return this._mcpServer;
|
|
48078
|
+
}
|
|
47969
48079
|
// --- Topic management ---
|
|
47970
48080
|
/**
|
|
47971
48081
|
* Create a new topic within the conversation group.
|
|
@@ -48560,6 +48670,33 @@ var init_channel = __esm({
|
|
|
48560
48670
|
await this._fetchScanRules();
|
|
48561
48671
|
return;
|
|
48562
48672
|
}
|
|
48673
|
+
if (data.event === "mcp_request") {
|
|
48674
|
+
const requestId = data.data?.request_id;
|
|
48675
|
+
const mcpPayload = data.data?.mcp_payload;
|
|
48676
|
+
if (requestId && mcpPayload && this._mcpServer) {
|
|
48677
|
+
try {
|
|
48678
|
+
const { createMcpProxyRequest: createMcpProxyRequest2 } = await Promise.resolve().then(() => (init_mcp_proxy_helpers(), mcp_proxy_helpers_exports));
|
|
48679
|
+
const mcpResponse = await createMcpProxyRequest2(this._mcpServer, mcpPayload);
|
|
48680
|
+
ws.send(JSON.stringify({
|
|
48681
|
+
event: "mcp_response",
|
|
48682
|
+
data: { request_id: requestId, mcp_payload: mcpResponse }
|
|
48683
|
+
}));
|
|
48684
|
+
} catch (err) {
|
|
48685
|
+
ws.send(JSON.stringify({
|
|
48686
|
+
event: "mcp_response",
|
|
48687
|
+
data: {
|
|
48688
|
+
request_id: requestId,
|
|
48689
|
+
mcp_payload: {
|
|
48690
|
+
jsonrpc: "2.0",
|
|
48691
|
+
id: mcpPayload?.id ?? null,
|
|
48692
|
+
error: { code: -32603, message: String(err) }
|
|
48693
|
+
}
|
|
48694
|
+
}
|
|
48695
|
+
}));
|
|
48696
|
+
}
|
|
48697
|
+
}
|
|
48698
|
+
return;
|
|
48699
|
+
}
|
|
48563
48700
|
if (data.event === "hub_identity_sync") {
|
|
48564
48701
|
if (this._persisted && data.data?.hub_id) {
|
|
48565
48702
|
const changed = this._persisted.hubId !== data.data.hub_id || this._persisted.agentRole !== (data.data.agent_role ?? "peer");
|
|
@@ -50870,20 +51007,6 @@ var init_fetch_interceptor = __esm({
|
|
|
50870
51007
|
}
|
|
50871
51008
|
});
|
|
50872
51009
|
|
|
50873
|
-
// src/openclaw-entry.ts
|
|
50874
|
-
var isUsingManagedRoutes;
|
|
50875
|
-
var init_openclaw_entry = __esm({
|
|
50876
|
-
"src/openclaw-entry.ts"() {
|
|
50877
|
-
"use strict";
|
|
50878
|
-
init_account_config();
|
|
50879
|
-
init_fetch_interceptor();
|
|
50880
|
-
init_http_handlers();
|
|
50881
|
-
init_openclaw_compat();
|
|
50882
|
-
init_types();
|
|
50883
|
-
isUsingManagedRoutes = false;
|
|
50884
|
-
}
|
|
50885
|
-
});
|
|
50886
|
-
|
|
50887
51010
|
// ../../node_modules/zod/v3/helpers/util.js
|
|
50888
51011
|
var util, objectUtil, ZodParsedType, getParsedType;
|
|
50889
51012
|
var init_util = __esm({
|
|
@@ -74952,7 +75075,7 @@ var init_mcp = __esm({
|
|
|
74952
75075
|
// ../../node_modules/@hono/node-server/dist/index.mjs
|
|
74953
75076
|
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
|
|
74954
75077
|
import { Http2ServerRequest } from "http2";
|
|
74955
|
-
import { Readable } from "stream";
|
|
75078
|
+
import { Readable as Readable2 } from "stream";
|
|
74956
75079
|
import crypto2 from "crypto";
|
|
74957
75080
|
async function readWithoutBlocking(readPromise) {
|
|
74958
75081
|
return Promise.race([readPromise, Promise.resolve().then(() => Promise.resolve(void 0))]);
|
|
@@ -75069,7 +75192,7 @@ var init_dist2 = __esm({
|
|
|
75069
75192
|
init.body = new ReadableStream({
|
|
75070
75193
|
async pull(controller) {
|
|
75071
75194
|
try {
|
|
75072
|
-
reader ||=
|
|
75195
|
+
reader ||= Readable2.toWeb(incoming).getReader();
|
|
75073
75196
|
const { done, value } = await reader.read();
|
|
75074
75197
|
if (done) {
|
|
75075
75198
|
controller.close();
|
|
@@ -75082,7 +75205,7 @@ var init_dist2 = __esm({
|
|
|
75082
75205
|
}
|
|
75083
75206
|
});
|
|
75084
75207
|
} else {
|
|
75085
|
-
init.body =
|
|
75208
|
+
init.body = Readable2.toWeb(incoming);
|
|
75086
75209
|
}
|
|
75087
75210
|
}
|
|
75088
75211
|
return new Request2(url2, init);
|
|
@@ -76278,23 +76401,29 @@ var init_mcp_server2 = __esm({
|
|
|
76278
76401
|
* Each request gets a fresh stateless transport; after the response is
|
|
76279
76402
|
* flushed the transport + underlying protocol connection are torn down
|
|
76280
76403
|
* so the single McpServer instance is ready for the next caller.
|
|
76404
|
+
*
|
|
76405
|
+
* Local requests from 127.0.0.1/::1 bypass SPT validation (owner access).
|
|
76281
76406
|
*/
|
|
76282
76407
|
async handleRequest(req, res) {
|
|
76283
76408
|
if (!this.initialized) {
|
|
76284
76409
|
this.initialize();
|
|
76285
76410
|
}
|
|
76286
|
-
const
|
|
76287
|
-
|
|
76288
|
-
|
|
76289
|
-
|
|
76290
|
-
|
|
76291
|
-
|
|
76292
|
-
|
|
76293
|
-
|
|
76294
|
-
|
|
76295
|
-
|
|
76296
|
-
|
|
76297
|
-
|
|
76411
|
+
const remote = req.socket?.remoteAddress;
|
|
76412
|
+
const isLocal = remote === "127.0.0.1" || remote === "::1" || remote === "::ffff:127.0.0.1";
|
|
76413
|
+
if (!isLocal) {
|
|
76414
|
+
const authHeader = req.headers.authorization;
|
|
76415
|
+
if (!authHeader?.startsWith("Bearer ")) {
|
|
76416
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
76417
|
+
res.end(JSON.stringify({ error: "Missing or invalid Authorization header" }));
|
|
76418
|
+
return;
|
|
76419
|
+
}
|
|
76420
|
+
const token = authHeader.slice(7);
|
|
76421
|
+
const valid = await this.validateSpt(token);
|
|
76422
|
+
if (!valid) {
|
|
76423
|
+
res.writeHead(403, { "Content-Type": "application/json" });
|
|
76424
|
+
res.end(JSON.stringify({ error: "Invalid or expired SPT token" }));
|
|
76425
|
+
return;
|
|
76426
|
+
}
|
|
76298
76427
|
}
|
|
76299
76428
|
const transport = new StreamableHTTPServerTransport({
|
|
76300
76429
|
sessionIdGenerator: void 0
|
|
@@ -76378,44 +76507,6 @@ var init_mcp_server2 = __esm({
|
|
|
76378
76507
|
}
|
|
76379
76508
|
});
|
|
76380
76509
|
|
|
76381
|
-
// src/mcp-handlers.ts
|
|
76382
|
-
function createMcpHandler(mcpServer, basePath = "/mcp") {
|
|
76383
|
-
return (req, res, next) => {
|
|
76384
|
-
const url2 = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
|
|
76385
|
-
const pathname = url2.pathname;
|
|
76386
|
-
if (!pathname.startsWith(basePath)) {
|
|
76387
|
-
if (next) next();
|
|
76388
|
-
return;
|
|
76389
|
-
}
|
|
76390
|
-
if (!mcpServer) {
|
|
76391
|
-
res.writeHead(503, { "Content-Type": "application/json" });
|
|
76392
|
-
res.end(JSON.stringify({ error: "MCP server not initialized" }));
|
|
76393
|
-
return;
|
|
76394
|
-
}
|
|
76395
|
-
mcpServer.handleRequest(req, res).catch((err) => {
|
|
76396
|
-
console.error("[MCP] Request handling error:", err);
|
|
76397
|
-
if (!res.headersSent) {
|
|
76398
|
-
res.writeHead(500, { "Content-Type": "application/json" });
|
|
76399
|
-
res.end(JSON.stringify({ error: "Internal MCP error" }));
|
|
76400
|
-
}
|
|
76401
|
-
});
|
|
76402
|
-
};
|
|
76403
|
-
}
|
|
76404
|
-
function getMcpStatus(mcpServer) {
|
|
76405
|
-
if (!mcpServer) {
|
|
76406
|
-
return { mcp_enabled: false, mcp_skills_count: 0 };
|
|
76407
|
-
}
|
|
76408
|
-
return {
|
|
76409
|
-
mcp_enabled: true,
|
|
76410
|
-
mcp_skills_count: mcpServer.skillCount
|
|
76411
|
-
};
|
|
76412
|
-
}
|
|
76413
|
-
var init_mcp_handlers = __esm({
|
|
76414
|
-
"src/mcp-handlers.ts"() {
|
|
76415
|
-
"use strict";
|
|
76416
|
-
}
|
|
76417
|
-
});
|
|
76418
|
-
|
|
76419
76510
|
// src/skill-manifest.ts
|
|
76420
76511
|
import { readFileSync, existsSync, readdirSync } from "node:fs";
|
|
76421
76512
|
import { resolve as resolve2, join as join4 } from "node:path";
|
|
@@ -76583,6 +76674,60 @@ var init_skill_manifest = __esm({
|
|
|
76583
76674
|
}
|
|
76584
76675
|
});
|
|
76585
76676
|
|
|
76677
|
+
// src/openclaw-entry.ts
|
|
76678
|
+
var isUsingManagedRoutes;
|
|
76679
|
+
var init_openclaw_entry = __esm({
|
|
76680
|
+
"src/openclaw-entry.ts"() {
|
|
76681
|
+
"use strict";
|
|
76682
|
+
init_account_config();
|
|
76683
|
+
init_fetch_interceptor();
|
|
76684
|
+
init_http_handlers();
|
|
76685
|
+
init_openclaw_compat();
|
|
76686
|
+
init_types();
|
|
76687
|
+
init_mcp_server2();
|
|
76688
|
+
init_skill_manifest();
|
|
76689
|
+
isUsingManagedRoutes = false;
|
|
76690
|
+
}
|
|
76691
|
+
});
|
|
76692
|
+
|
|
76693
|
+
// src/mcp-handlers.ts
|
|
76694
|
+
function createMcpHandler(mcpServer, basePath = "/mcp") {
|
|
76695
|
+
return (req, res, next) => {
|
|
76696
|
+
const url2 = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
|
|
76697
|
+
const pathname = url2.pathname;
|
|
76698
|
+
if (!pathname.startsWith(basePath)) {
|
|
76699
|
+
if (next) next();
|
|
76700
|
+
return;
|
|
76701
|
+
}
|
|
76702
|
+
if (!mcpServer) {
|
|
76703
|
+
res.writeHead(503, { "Content-Type": "application/json" });
|
|
76704
|
+
res.end(JSON.stringify({ error: "MCP server not initialized" }));
|
|
76705
|
+
return;
|
|
76706
|
+
}
|
|
76707
|
+
mcpServer.handleRequest(req, res).catch((err) => {
|
|
76708
|
+
console.error("[MCP] Request handling error:", err);
|
|
76709
|
+
if (!res.headersSent) {
|
|
76710
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
76711
|
+
res.end(JSON.stringify({ error: "Internal MCP error" }));
|
|
76712
|
+
}
|
|
76713
|
+
});
|
|
76714
|
+
};
|
|
76715
|
+
}
|
|
76716
|
+
function getMcpStatus(mcpServer) {
|
|
76717
|
+
if (!mcpServer) {
|
|
76718
|
+
return { mcp_enabled: false, mcp_skills_count: 0 };
|
|
76719
|
+
}
|
|
76720
|
+
return {
|
|
76721
|
+
mcp_enabled: true,
|
|
76722
|
+
mcp_skills_count: mcpServer.skillCount
|
|
76723
|
+
};
|
|
76724
|
+
}
|
|
76725
|
+
var init_mcp_handlers = __esm({
|
|
76726
|
+
"src/mcp-handlers.ts"() {
|
|
76727
|
+
"use strict";
|
|
76728
|
+
}
|
|
76729
|
+
});
|
|
76730
|
+
|
|
76586
76731
|
// src/skill-invoker.ts
|
|
76587
76732
|
async function invokeSkill(opts, handler) {
|
|
76588
76733
|
const start = Date.now();
|