@agentvault/agentvault 0.17.3 → 0.17.5

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.
Files changed (62) hide show
  1. package/dist/cli.js +141 -4
  2. package/dist/cli.js.map +4 -4
  3. package/dist/index.js +159 -16
  4. package/dist/index.js.map +4 -4
  5. package/dist/openclaw-entry.js +598 -142
  6. package/dist/openclaw-entry.js.map +4 -4
  7. package/openclaw.plugin.json +1 -1
  8. package/package.json +1 -1
  9. package/dist/_cp.d.ts +0 -10
  10. package/dist/_cp.d.ts.map +0 -1
  11. package/dist/account-config.d.ts +0 -20
  12. package/dist/account-config.d.ts.map +0 -1
  13. package/dist/channel.d.ts +0 -350
  14. package/dist/channel.d.ts.map +0 -1
  15. package/dist/cli.d.ts +0 -2
  16. package/dist/cli.d.ts.map +0 -1
  17. package/dist/create-agent.d.ts +0 -28
  18. package/dist/create-agent.d.ts.map +0 -1
  19. package/dist/crypto-helpers.d.ts +0 -2
  20. package/dist/crypto-helpers.d.ts.map +0 -1
  21. package/dist/doctor.d.ts +0 -41
  22. package/dist/doctor.d.ts.map +0 -1
  23. package/dist/fetch-interceptor.d.ts +0 -32
  24. package/dist/fetch-interceptor.d.ts.map +0 -1
  25. package/dist/gateway-send.d.ts +0 -98
  26. package/dist/gateway-send.d.ts.map +0 -1
  27. package/dist/http-handlers.d.ts +0 -42
  28. package/dist/http-handlers.d.ts.map +0 -1
  29. package/dist/index.d.ts +0 -25
  30. package/dist/index.d.ts.map +0 -1
  31. package/dist/mcp-handlers.d.ts +0 -26
  32. package/dist/mcp-handlers.d.ts.map +0 -1
  33. package/dist/mcp-server.d.ts +0 -88
  34. package/dist/mcp-server.d.ts.map +0 -1
  35. package/dist/openclaw-compat.d.ts +0 -33
  36. package/dist/openclaw-compat.d.ts.map +0 -1
  37. package/dist/openclaw-entry.d.ts +0 -27
  38. package/dist/openclaw-entry.d.ts.map +0 -1
  39. package/dist/openclaw-plugin.d.ts +0 -102
  40. package/dist/openclaw-plugin.d.ts.map +0 -1
  41. package/dist/openclaw-types.d.ts +0 -155
  42. package/dist/openclaw-types.d.ts.map +0 -1
  43. package/dist/policy-enforcer.d.ts +0 -78
  44. package/dist/policy-enforcer.d.ts.map +0 -1
  45. package/dist/setup.d.ts +0 -27
  46. package/dist/setup.d.ts.map +0 -1
  47. package/dist/skill-invoker.d.ts +0 -30
  48. package/dist/skill-invoker.d.ts.map +0 -1
  49. package/dist/skill-manifest.d.ts +0 -25
  50. package/dist/skill-manifest.d.ts.map +0 -1
  51. package/dist/skill-telemetry.d.ts +0 -36
  52. package/dist/skill-telemetry.d.ts.map +0 -1
  53. package/dist/skills-publish.d.ts +0 -8
  54. package/dist/skills-publish.d.ts.map +0 -1
  55. package/dist/state.d.ts +0 -32
  56. package/dist/state.d.ts.map +0 -1
  57. package/dist/transport.d.ts +0 -24
  58. package/dist/transport.d.ts.map +0 -1
  59. package/dist/types.d.ts +0 -379
  60. package/dist/types.d.ts.map +0 -1
  61. package/dist/workspace-handlers.d.ts +0 -62
  62. package/dist/workspace-handlers.d.ts.map +0 -1
package/dist/cli.js CHANGED
@@ -46477,6 +46477,7 @@ var http_handlers_exports = {};
46477
46477
  __export(http_handlers_exports, {
46478
46478
  handleActionRequest: () => handleActionRequest,
46479
46479
  handleDecisionRequest: () => handleDecisionRequest,
46480
+ handleMcpConfigRequest: () => handleMcpConfigRequest,
46480
46481
  handleSendRequest: () => handleSendRequest,
46481
46482
  handleStatusRequest: () => handleStatusRequest,
46482
46483
  handleTargetsRequest: () => handleTargetsRequest
@@ -46618,12 +46619,90 @@ function handleTargetsRequest(channel2) {
46618
46619
  }
46619
46620
  };
46620
46621
  }
46622
+ function handleMcpConfigRequest(agentName, port, mcpSkillCount) {
46623
+ return {
46624
+ status: 200,
46625
+ body: {
46626
+ mcpServers: {
46627
+ [`agentvault-${agentName}`]: {
46628
+ url: `http://127.0.0.1:${port}/mcp`
46629
+ }
46630
+ },
46631
+ _meta: {
46632
+ agent: agentName,
46633
+ skills_count: mcpSkillCount,
46634
+ transport: "streamable-http",
46635
+ auth: "none (localhost)",
46636
+ instructions: "Add the mcpServers block to your MCP configuration file (e.g., .mcp.json or mcp_config.json)"
46637
+ }
46638
+ }
46639
+ };
46640
+ }
46621
46641
  var init_http_handlers = __esm({
46622
46642
  "src/http-handlers.ts"() {
46623
46643
  "use strict";
46624
46644
  }
46625
46645
  });
46626
46646
 
46647
+ // src/mcp-proxy-helpers.ts
46648
+ var mcp_proxy_helpers_exports = {};
46649
+ __export(mcp_proxy_helpers_exports, {
46650
+ createMcpProxyRequest: () => createMcpProxyRequest
46651
+ });
46652
+ import { Readable } from "node:stream";
46653
+ async function createMcpProxyRequest(mcpServer, payload) {
46654
+ const bodyStr = JSON.stringify(payload);
46655
+ const req = Object.assign(new Readable({ read() {
46656
+ } }), {
46657
+ method: "POST",
46658
+ url: "/mcp",
46659
+ headers: {
46660
+ "content-type": "application/json",
46661
+ "content-length": String(Buffer.byteLength(bodyStr)),
46662
+ // Use localhost to bypass SPT validation (WS already authenticated)
46663
+ host: "localhost"
46664
+ },
46665
+ socket: { remoteAddress: "127.0.0.1" }
46666
+ });
46667
+ req.push(bodyStr);
46668
+ req.push(null);
46669
+ let responseStatus = 200;
46670
+ let responseBody = "";
46671
+ const chunks = [];
46672
+ const res = {
46673
+ writeHead: (status) => {
46674
+ responseStatus = status;
46675
+ },
46676
+ write: (chunk) => {
46677
+ chunks.push(typeof chunk === "string" ? chunk : chunk.toString());
46678
+ return true;
46679
+ },
46680
+ end: (data) => {
46681
+ if (data) chunks.push(typeof data === "string" ? data : data.toString());
46682
+ responseBody = chunks.join("");
46683
+ },
46684
+ setHeader: () => {
46685
+ },
46686
+ getHeader: () => void 0,
46687
+ statusCode: 200,
46688
+ headersSent: false
46689
+ };
46690
+ await mcpServer.handleRequest(req, res);
46691
+ if (responseBody) {
46692
+ try {
46693
+ return JSON.parse(responseBody);
46694
+ } catch {
46695
+ return { jsonrpc: "2.0", error: { code: -32603, message: responseBody } };
46696
+ }
46697
+ }
46698
+ return null;
46699
+ }
46700
+ var init_mcp_proxy_helpers = __esm({
46701
+ "src/mcp-proxy-helpers.ts"() {
46702
+ "use strict";
46703
+ }
46704
+ });
46705
+
46627
46706
  // src/workspace-handlers.ts
46628
46707
  var workspace_handlers_exports = {};
46629
46708
  __export(workspace_handlers_exports, {
@@ -46839,6 +46918,7 @@ var init_channel = __esm({
46839
46918
  _stopped = false;
46840
46919
  _persisted = null;
46841
46920
  _httpServer = null;
46921
+ _mcpServer = null;
46842
46922
  _pollFallbackTimer = null;
46843
46923
  _heartbeatTimer = null;
46844
46924
  _heartbeatCallback = null;
@@ -47890,9 +47970,28 @@ var init_channel = __esm({
47890
47970
  const result = handlers.handleTargetsRequest(this);
47891
47971
  res.writeHead(result.status, { "Content-Type": "application/json" });
47892
47972
  res.end(JSON.stringify(result.body));
47973
+ } else if (req.url === "/mcp" && (req.method === "POST" || req.method === "GET" || req.method === "DELETE")) {
47974
+ if (!this._mcpServer) {
47975
+ res.writeHead(503, { "Content-Type": "application/json" });
47976
+ res.end(JSON.stringify({ ok: false, error: "MCP server not initialized" }));
47977
+ return;
47978
+ }
47979
+ this._mcpServer.handleRequest(req, res).catch((err) => {
47980
+ console.error("[MCP] Request handling error:", err);
47981
+ if (!res.headersSent) {
47982
+ res.writeHead(500, { "Content-Type": "application/json" });
47983
+ res.end(JSON.stringify({ ok: false, error: "Internal MCP error" }));
47984
+ }
47985
+ });
47986
+ } else if (req.method === "GET" && req.url === "/mcp-config") {
47987
+ const agentName = this.config.agentName ?? "agent";
47988
+ const mcpSkillCount = this._mcpServer?.skillCount ?? 0;
47989
+ const result = handlers.handleMcpConfigRequest(agentName, port, mcpSkillCount);
47990
+ res.writeHead(result.status, { "Content-Type": "application/json" });
47991
+ res.end(JSON.stringify(result.body));
47893
47992
  } else {
47894
47993
  res.writeHead(404, { "Content-Type": "application/json" });
47895
- res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send, POST /decision, POST /action, GET /status, or GET /targets" }));
47994
+ res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send, POST /decision, POST /action, GET /status, GET /targets, or /mcp" }));
47896
47995
  }
47897
47996
  });
47898
47997
  this._httpServer.listen(port, "127.0.0.1", () => {
@@ -47905,6 +48004,17 @@ var init_channel = __esm({
47905
48004
  this._httpServer = null;
47906
48005
  }
47907
48006
  }
48007
+ /**
48008
+ * Attach an MCP server instance to this channel.
48009
+ * The MCP server will be served at /mcp on the local HTTP server.
48010
+ */
48011
+ setMcpServer(mcpServer) {
48012
+ this._mcpServer = mcpServer;
48013
+ }
48014
+ /** The attached MCP server, if any. */
48015
+ get mcpServer() {
48016
+ return this._mcpServer;
48017
+ }
47908
48018
  // --- Topic management ---
47909
48019
  /**
47910
48020
  * Create a new topic within the conversation group.
@@ -48499,6 +48609,33 @@ var init_channel = __esm({
48499
48609
  await this._fetchScanRules();
48500
48610
  return;
48501
48611
  }
48612
+ if (data.event === "mcp_request") {
48613
+ const requestId = data.data?.request_id;
48614
+ const mcpPayload = data.data?.mcp_payload;
48615
+ if (requestId && mcpPayload && this._mcpServer) {
48616
+ try {
48617
+ const { createMcpProxyRequest: createMcpProxyRequest2 } = await Promise.resolve().then(() => (init_mcp_proxy_helpers(), mcp_proxy_helpers_exports));
48618
+ const mcpResponse = await createMcpProxyRequest2(this._mcpServer, mcpPayload);
48619
+ ws.send(JSON.stringify({
48620
+ event: "mcp_response",
48621
+ data: { request_id: requestId, mcp_payload: mcpResponse }
48622
+ }));
48623
+ } catch (err) {
48624
+ ws.send(JSON.stringify({
48625
+ event: "mcp_response",
48626
+ data: {
48627
+ request_id: requestId,
48628
+ mcp_payload: {
48629
+ jsonrpc: "2.0",
48630
+ id: mcpPayload?.id ?? null,
48631
+ error: { code: -32603, message: String(err) }
48632
+ }
48633
+ }
48634
+ }));
48635
+ }
48636
+ }
48637
+ return;
48638
+ }
48502
48639
  if (data.event === "hub_identity_sync") {
48503
48640
  if (this._persisted && data.data?.hub_id) {
48504
48641
  const changed = this._persisted.hubId !== data.data.hub_id || this._persisted.agentRole !== (data.data.agent_role ?? "peer");
@@ -70636,7 +70773,7 @@ var init_mcp = __esm({
70636
70773
  });
70637
70774
 
70638
70775
  // ../../node_modules/@hono/node-server/dist/index.mjs
70639
- import { Readable } from "stream";
70776
+ import { Readable as Readable2 } from "stream";
70640
70777
  import crypto2 from "crypto";
70641
70778
  var GlobalRequest, Request2, newHeadersFromIncoming, wrapBodyStream, newRequestFromIncoming, getRequestCache, requestCache, incomingKey, urlKey, headersKey, abortControllerKey, getAbortController, requestPrototype, responseCache, getResponseCache, cacheKey, GlobalResponse, Response2;
70642
70779
  var init_dist2 = __esm({
@@ -70696,7 +70833,7 @@ var init_dist2 = __esm({
70696
70833
  init.body = new ReadableStream({
70697
70834
  async pull(controller) {
70698
70835
  try {
70699
- reader ||= Readable.toWeb(incoming).getReader();
70836
+ reader ||= Readable2.toWeb(incoming).getReader();
70700
70837
  const { done, value } = await reader.read();
70701
70838
  if (done) {
70702
70839
  controller.close();
@@ -70709,7 +70846,7 @@ var init_dist2 = __esm({
70709
70846
  }
70710
70847
  });
70711
70848
  } else {
70712
- init.body = Readable.toWeb(incoming);
70849
+ init.body = Readable2.toWeb(incoming);
70713
70850
  }
70714
70851
  }
70715
70852
  return new Request2(url2, init);