@agentvault/agentvault 0.17.2 → 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/README.md +195 -94
- package/dist/channel.d.ts +16 -0
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +208 -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 +259 -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/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/openclaw.plugin.json +19 -6
- 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;
|
|
@@ -46980,6 +47060,12 @@ var init_channel = __esm({
|
|
|
46980
47060
|
get telemetry() {
|
|
46981
47061
|
return this._telemetryReporter;
|
|
46982
47062
|
}
|
|
47063
|
+
/**
|
|
47064
|
+
* Check if a skill is in shadow mode. Returns the shadow config if active, undefined otherwise.
|
|
47065
|
+
*/
|
|
47066
|
+
getShadowConfig(skillName) {
|
|
47067
|
+
return this._persisted?.shadowSkills?.[skillName];
|
|
47068
|
+
}
|
|
46983
47069
|
async start() {
|
|
46984
47070
|
this._stopped = false;
|
|
46985
47071
|
await libsodium_wrappers_default.ready;
|
|
@@ -47945,9 +48031,28 @@ var init_channel = __esm({
|
|
|
47945
48031
|
const result = handlers.handleTargetsRequest(this);
|
|
47946
48032
|
res.writeHead(result.status, { "Content-Type": "application/json" });
|
|
47947
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));
|
|
47948
48053
|
} else {
|
|
47949
48054
|
res.writeHead(404, { "Content-Type": "application/json" });
|
|
47950
|
-
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" }));
|
|
47951
48056
|
}
|
|
47952
48057
|
});
|
|
47953
48058
|
this._httpServer.listen(port, "127.0.0.1", () => {
|
|
@@ -47960,6 +48065,17 @@ var init_channel = __esm({
|
|
|
47960
48065
|
this._httpServer = null;
|
|
47961
48066
|
}
|
|
47962
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
|
+
}
|
|
47963
48079
|
// --- Topic management ---
|
|
47964
48080
|
/**
|
|
47965
48081
|
* Create a new topic within the conversation group.
|
|
@@ -48554,6 +48670,33 @@ var init_channel = __esm({
|
|
|
48554
48670
|
await this._fetchScanRules();
|
|
48555
48671
|
return;
|
|
48556
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
|
+
}
|
|
48557
48700
|
if (data.event === "hub_identity_sync") {
|
|
48558
48701
|
if (this._persisted && data.data?.hub_id) {
|
|
48559
48702
|
const changed = this._persisted.hubId !== data.data.hub_id || this._persisted.agentRole !== (data.data.agent_role ?? "peer");
|
|
@@ -48590,6 +48733,46 @@ var init_channel = __esm({
|
|
|
48590
48733
|
}
|
|
48591
48734
|
this.emit("hub_identity_role_changed", data.data);
|
|
48592
48735
|
}
|
|
48736
|
+
if (data.event === "shadow_config_sync") {
|
|
48737
|
+
if (this._persisted && data.data?.skills) {
|
|
48738
|
+
this._persisted.shadowSkills = data.data.skills;
|
|
48739
|
+
this._persistState();
|
|
48740
|
+
console.log(`[SecureChannel] Shadow config synced: ${Object.keys(data.data.skills).length} skill(s)`);
|
|
48741
|
+
}
|
|
48742
|
+
}
|
|
48743
|
+
if (data.event === "shadow_session_created") {
|
|
48744
|
+
if (this._persisted && data.data?.skill_name) {
|
|
48745
|
+
if (!this._persisted.shadowSkills) this._persisted.shadowSkills = {};
|
|
48746
|
+
this._persisted.shadowSkills[data.data.skill_name] = {
|
|
48747
|
+
sessionId: data.data.session_id,
|
|
48748
|
+
autonomyLevel: data.data.autonomy_level,
|
|
48749
|
+
decisionClass: data.data.decision_class
|
|
48750
|
+
};
|
|
48751
|
+
this._persistState();
|
|
48752
|
+
console.log(`[SecureChannel] Shadow session created for skill: ${data.data.skill_name}`);
|
|
48753
|
+
}
|
|
48754
|
+
this.emit("shadow_session_created", data.data);
|
|
48755
|
+
}
|
|
48756
|
+
if (data.event === "shadow_session_graduated") {
|
|
48757
|
+
if (this._persisted?.shadowSkills && data.data?.skill_name) {
|
|
48758
|
+
if (data.data.autonomy_level === "autonomous") {
|
|
48759
|
+
delete this._persisted.shadowSkills[data.data.skill_name];
|
|
48760
|
+
} else {
|
|
48761
|
+
const entry = this._persisted.shadowSkills[data.data.skill_name];
|
|
48762
|
+
if (entry) entry.autonomyLevel = data.data.autonomy_level;
|
|
48763
|
+
}
|
|
48764
|
+
this._persistState();
|
|
48765
|
+
console.log(`[SecureChannel] Shadow session graduated: ${data.data.skill_name} \u2192 ${data.data.autonomy_level}`);
|
|
48766
|
+
}
|
|
48767
|
+
this.emit("shadow_session_graduated", data.data);
|
|
48768
|
+
}
|
|
48769
|
+
if (data.event === "shadow_session_deleted") {
|
|
48770
|
+
if (this._persisted?.shadowSkills && data.data?.skill_name) {
|
|
48771
|
+
delete this._persisted.shadowSkills[data.data.skill_name];
|
|
48772
|
+
this._persistState();
|
|
48773
|
+
}
|
|
48774
|
+
this.emit("shadow_session_deleted", data.data);
|
|
48775
|
+
}
|
|
48593
48776
|
if (data.event === "hub_identity_removed") {
|
|
48594
48777
|
if (this._persisted) {
|
|
48595
48778
|
delete this._persisted.hubAddress;
|
|
@@ -50824,20 +51007,6 @@ var init_fetch_interceptor = __esm({
|
|
|
50824
51007
|
}
|
|
50825
51008
|
});
|
|
50826
51009
|
|
|
50827
|
-
// src/openclaw-entry.ts
|
|
50828
|
-
var isUsingManagedRoutes;
|
|
50829
|
-
var init_openclaw_entry = __esm({
|
|
50830
|
-
"src/openclaw-entry.ts"() {
|
|
50831
|
-
"use strict";
|
|
50832
|
-
init_account_config();
|
|
50833
|
-
init_fetch_interceptor();
|
|
50834
|
-
init_http_handlers();
|
|
50835
|
-
init_openclaw_compat();
|
|
50836
|
-
init_types();
|
|
50837
|
-
isUsingManagedRoutes = false;
|
|
50838
|
-
}
|
|
50839
|
-
});
|
|
50840
|
-
|
|
50841
51010
|
// ../../node_modules/zod/v3/helpers/util.js
|
|
50842
51011
|
var util, objectUtil, ZodParsedType, getParsedType;
|
|
50843
51012
|
var init_util = __esm({
|
|
@@ -74906,7 +75075,7 @@ var init_mcp = __esm({
|
|
|
74906
75075
|
// ../../node_modules/@hono/node-server/dist/index.mjs
|
|
74907
75076
|
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
|
|
74908
75077
|
import { Http2ServerRequest } from "http2";
|
|
74909
|
-
import { Readable } from "stream";
|
|
75078
|
+
import { Readable as Readable2 } from "stream";
|
|
74910
75079
|
import crypto2 from "crypto";
|
|
74911
75080
|
async function readWithoutBlocking(readPromise) {
|
|
74912
75081
|
return Promise.race([readPromise, Promise.resolve().then(() => Promise.resolve(void 0))]);
|
|
@@ -75023,7 +75192,7 @@ var init_dist2 = __esm({
|
|
|
75023
75192
|
init.body = new ReadableStream({
|
|
75024
75193
|
async pull(controller) {
|
|
75025
75194
|
try {
|
|
75026
|
-
reader ||=
|
|
75195
|
+
reader ||= Readable2.toWeb(incoming).getReader();
|
|
75027
75196
|
const { done, value } = await reader.read();
|
|
75028
75197
|
if (done) {
|
|
75029
75198
|
controller.close();
|
|
@@ -75036,7 +75205,7 @@ var init_dist2 = __esm({
|
|
|
75036
75205
|
}
|
|
75037
75206
|
});
|
|
75038
75207
|
} else {
|
|
75039
|
-
init.body =
|
|
75208
|
+
init.body = Readable2.toWeb(incoming);
|
|
75040
75209
|
}
|
|
75041
75210
|
}
|
|
75042
75211
|
return new Request2(url2, init);
|
|
@@ -76232,23 +76401,29 @@ var init_mcp_server2 = __esm({
|
|
|
76232
76401
|
* Each request gets a fresh stateless transport; after the response is
|
|
76233
76402
|
* flushed the transport + underlying protocol connection are torn down
|
|
76234
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).
|
|
76235
76406
|
*/
|
|
76236
76407
|
async handleRequest(req, res) {
|
|
76237
76408
|
if (!this.initialized) {
|
|
76238
76409
|
this.initialize();
|
|
76239
76410
|
}
|
|
76240
|
-
const
|
|
76241
|
-
|
|
76242
|
-
|
|
76243
|
-
|
|
76244
|
-
|
|
76245
|
-
|
|
76246
|
-
|
|
76247
|
-
|
|
76248
|
-
|
|
76249
|
-
|
|
76250
|
-
|
|
76251
|
-
|
|
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
|
+
}
|
|
76252
76427
|
}
|
|
76253
76428
|
const transport = new StreamableHTTPServerTransport({
|
|
76254
76429
|
sessionIdGenerator: void 0
|
|
@@ -76332,44 +76507,6 @@ var init_mcp_server2 = __esm({
|
|
|
76332
76507
|
}
|
|
76333
76508
|
});
|
|
76334
76509
|
|
|
76335
|
-
// src/mcp-handlers.ts
|
|
76336
|
-
function createMcpHandler(mcpServer, basePath = "/mcp") {
|
|
76337
|
-
return (req, res, next) => {
|
|
76338
|
-
const url2 = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
|
|
76339
|
-
const pathname = url2.pathname;
|
|
76340
|
-
if (!pathname.startsWith(basePath)) {
|
|
76341
|
-
if (next) next();
|
|
76342
|
-
return;
|
|
76343
|
-
}
|
|
76344
|
-
if (!mcpServer) {
|
|
76345
|
-
res.writeHead(503, { "Content-Type": "application/json" });
|
|
76346
|
-
res.end(JSON.stringify({ error: "MCP server not initialized" }));
|
|
76347
|
-
return;
|
|
76348
|
-
}
|
|
76349
|
-
mcpServer.handleRequest(req, res).catch((err) => {
|
|
76350
|
-
console.error("[MCP] Request handling error:", err);
|
|
76351
|
-
if (!res.headersSent) {
|
|
76352
|
-
res.writeHead(500, { "Content-Type": "application/json" });
|
|
76353
|
-
res.end(JSON.stringify({ error: "Internal MCP error" }));
|
|
76354
|
-
}
|
|
76355
|
-
});
|
|
76356
|
-
};
|
|
76357
|
-
}
|
|
76358
|
-
function getMcpStatus(mcpServer) {
|
|
76359
|
-
if (!mcpServer) {
|
|
76360
|
-
return { mcp_enabled: false, mcp_skills_count: 0 };
|
|
76361
|
-
}
|
|
76362
|
-
return {
|
|
76363
|
-
mcp_enabled: true,
|
|
76364
|
-
mcp_skills_count: mcpServer.skillCount
|
|
76365
|
-
};
|
|
76366
|
-
}
|
|
76367
|
-
var init_mcp_handlers = __esm({
|
|
76368
|
-
"src/mcp-handlers.ts"() {
|
|
76369
|
-
"use strict";
|
|
76370
|
-
}
|
|
76371
|
-
});
|
|
76372
|
-
|
|
76373
76510
|
// src/skill-manifest.ts
|
|
76374
76511
|
import { readFileSync, existsSync, readdirSync } from "node:fs";
|
|
76375
76512
|
import { resolve as resolve2, join as join4 } from "node:path";
|
|
@@ -76537,6 +76674,60 @@ var init_skill_manifest = __esm({
|
|
|
76537
76674
|
}
|
|
76538
76675
|
});
|
|
76539
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
|
+
|
|
76540
76731
|
// src/skill-invoker.ts
|
|
76541
76732
|
async function invokeSkill(opts, handler) {
|
|
76542
76733
|
const start = Date.now();
|