@dexto/server 1.13.5 → 1.14.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.
Files changed (35) hide show
  1. package/dist/hono/index.cjs +3 -2
  2. package/dist/hono/index.d.ts.map +1 -1
  3. package/dist/hono/index.js +7 -3
  4. package/dist/hono/middleware/auth.cjs +42 -32
  5. package/dist/hono/middleware/auth.d.ts +15 -1
  6. package/dist/hono/middleware/auth.d.ts.map +1 -1
  7. package/dist/hono/middleware/auth.js +39 -31
  8. package/dist/hono/node/index.cjs +33 -22
  9. package/dist/hono/node/index.d.ts +1 -0
  10. package/dist/hono/node/index.d.ts.map +1 -1
  11. package/dist/hono/node/index.js +33 -22
  12. package/dist/hono/routes/agents.d.ts +14 -14
  13. package/dist/hono/routes/greeting.d.ts +13 -13
  14. package/dist/hono/routes/key.d.ts +4 -4
  15. package/dist/hono/routes/llm.d.ts +54 -54
  16. package/dist/hono/routes/memory.d.ts +10 -10
  17. package/dist/hono/routes/messages.d.ts +8 -8
  18. package/dist/hono/routes/models.d.ts +6 -6
  19. package/dist/hono/routes/openrouter.d.ts +6 -6
  20. package/dist/hono/routes/prompts.d.ts +2 -2
  21. package/dist/hono/routes/queue.d.ts +16 -16
  22. package/dist/hono/routes/resources.d.ts +2 -2
  23. package/dist/hono/routes/schedules.d.ts +12 -12
  24. package/dist/hono/routes/search.d.ts +4 -4
  25. package/dist/hono/routes/sessions.d.ts +24 -24
  26. package/dist/hono/routes/system-prompt.d.ts +2 -2
  27. package/dist/hono/routes/webhooks.d.ts +2 -2
  28. package/dist/hono/routes/workspaces.d.ts +2 -2
  29. package/dist/hono/types.d.ts +2 -0
  30. package/dist/hono/types.d.ts.map +1 -1
  31. package/dist/mcp/mcp-handler.cjs +32 -32
  32. package/dist/mcp/mcp-handler.d.ts +9 -3
  33. package/dist/mcp/mcp-handler.d.ts.map +1 -1
  34. package/dist/mcp/mcp-handler.js +32 -32
  35. package/package.json +15 -10
@@ -20,7 +20,7 @@ async function createMcpTransport(transportType = "http") {
20
20
  }
21
21
  }
22
22
  }
23
- async function initializeMcpServer(agent, agentCardData, mcpTransport) {
23
+ async function initializeMcpServer(agent, agentCardData, mcpTransport, context = { getAgent: () => agent, getAgentCard: () => agentCardData }) {
24
24
  const mcpServer = new McpServer(
25
25
  { name: agentCardData.name, version: agentCardData.version },
26
26
  {
@@ -31,36 +31,33 @@ async function initializeMcpServer(agent, agentCardData, mcpTransport) {
31
31
  );
32
32
  const toolName = "chat_with_agent";
33
33
  const toolDescription = "Allows you to chat with the an AI agent. Send a message to interact.";
34
- mcpServer.tool(
34
+ mcpServer.registerTool(
35
35
  toolName,
36
- toolDescription,
37
- { message: z.string() },
36
+ { description: toolDescription, inputSchema: { message: z.string() } },
38
37
  async ({ message }) => {
39
- agent.logger.info(
40
- `MCP tool '${toolName}' received message: ${message.substring(0, 100)}${message.length > 100 ? "..." : ""}`
41
- );
42
- const session = await agent.createSession(`mcp-${randomUUID()}`);
38
+ const agent2 = context.getAgent();
39
+ agent2.logger.info(`MCP tool '${toolName}' call started`);
40
+ const session = await agent2.createSession(`mcp-${randomUUID()}`);
43
41
  try {
44
- const text = await agent.run(message, void 0, void 0, session.id);
45
- agent.logger.info(
46
- `MCP tool '${toolName}' sending response: ${text?.substring(0, 100)}${(text?.length ?? 0) > 100 ? "..." : ""}`
47
- );
42
+ const text = await agent2.run(message, void 0, void 0, session.id);
43
+ agent2.logger.info(`MCP tool '${toolName}' call completed`);
48
44
  return { content: [{ type: "text", text: text ?? "" }] };
49
45
  } finally {
50
- await agent.deleteSession(session.id).catch(
51
- (err) => agent.logger.warn(`Failed to cleanup MCP session ${session.id}: ${err}`)
52
- );
46
+ await agent2.deleteSession(session.id).catch(() => agent2.logger.warn(`Failed to cleanup MCP session ${session.id}`));
53
47
  }
54
48
  }
55
49
  );
56
50
  agent.logger.info(`Registered MCP tool: '${toolName}'`);
57
- await initializeAgentCardResource(mcpServer, agentCardData, agent.logger);
51
+ await registerAgentCardResource(mcpServer, () => context.getAgentCard(), agent.logger);
58
52
  agent.logger.info(`Initializing MCP protocol server connection...`);
59
53
  await mcpServer.connect(mcpTransport);
60
54
  agent.logger.info(`\u2705 MCP server protocol connected via transport.`);
61
55
  return mcpServer;
62
56
  }
63
- async function initializeAgentCardResource(mcpServer, agentCardData, agentLogger) {
57
+ function initializeAgentCardResource(mcpServer, agentCardData, agentLogger) {
58
+ return registerAgentCardResource(mcpServer, () => agentCardData, agentLogger);
59
+ }
60
+ async function registerAgentCardResource(mcpServer, getAgentCard, agentLogger) {
64
61
  const agentCardResourceProgrammaticName = "agentCard";
65
62
  const agentCardResourceUri = "dexto://agent/card";
66
63
  try {
@@ -71,12 +68,17 @@ async function initializeAgentCardResource(mcpServer, agentCardData, agentLogger
71
68
  {
72
69
  uri: uri.href,
73
70
  type: "application/json",
74
- text: JSON.stringify(agentCardData, null, 2)
71
+ text: JSON.stringify(getAgentCard(), null, 2)
75
72
  }
76
73
  ]
77
74
  };
78
75
  };
79
- mcpServer.resource(agentCardResourceProgrammaticName, agentCardResourceUri, readCallback);
76
+ mcpServer.registerResource(
77
+ agentCardResourceProgrammaticName,
78
+ agentCardResourceUri,
79
+ {},
80
+ readCallback
81
+ );
80
82
  agentLogger.info(
81
83
  `Registered MCP Resource: '${agentCardResourceProgrammaticName}' at URI '${agentCardResourceUri}'`
82
84
  );
@@ -91,23 +93,21 @@ function createMcpHttpHandlers(mcpTransport) {
91
93
  logger.info("Non-HTTP transport detected. Skipping HTTP route setup.");
92
94
  return null;
93
95
  }
94
- const handlePost = async (req, res, body) => {
95
- logger.info(`MCP POST /mcp received request body: ${JSON.stringify(body)}`);
96
+ const handleRequest = async (req, res, body) => {
97
+ logger.info(`MCP ${req.method} request received`);
96
98
  try {
97
99
  await mcpTransport.handleRequest(req, res, body);
98
- } catch (err) {
99
- logger.error(`MCP POST error: ${JSON.stringify(err, null, 2)}`);
100
- }
101
- };
102
- const handleGet = async (req, res) => {
103
- logger.info("MCP GET /mcp received request, attempting to establish SSE connection.");
104
- try {
105
- await mcpTransport.handleRequest(req, res);
106
- } catch (err) {
107
- logger.error(`MCP GET error: ${JSON.stringify(err, null, 2)}`);
100
+ } catch {
101
+ logger.error("MCP HTTP request failed");
102
+ if (!res.headersSent) {
103
+ res.writeHead(500, { "Content-Type": "application/json" });
104
+ res.end(JSON.stringify({ error: "Internal Server Error" }));
105
+ } else if (!res.writableEnded) {
106
+ res.destroy();
107
+ }
108
108
  }
109
109
  };
110
- return { handlePost, handleGet };
110
+ return { handlePost: handleRequest, handleGet: handleRequest, handleDelete: handleRequest };
111
111
  }
112
112
  export {
113
113
  createMcpHttpHandlers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexto/server",
3
- "version": "1.13.5",
3
+ "version": "1.14.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -22,7 +22,12 @@
22
22
  "import": "./dist/hono/node/index.js",
23
23
  "require": "./dist/hono/node/index.cjs"
24
24
  },
25
- "./package.json": "./package.json"
25
+ "./package.json": "./package.json",
26
+ "./hono/auth": {
27
+ "types": "./dist/hono/middleware/auth.d.ts",
28
+ "import": "./dist/hono/middleware/auth.js",
29
+ "require": "./dist/hono/middleware/auth.cjs"
30
+ }
26
31
  },
27
32
  "dependencies": {
28
33
  "@hono/node-server": "1.19.13",
@@ -30,14 +35,14 @@
30
35
  "hono": "^4.12.12",
31
36
  "ws": "^8.18.1",
32
37
  "yaml": "^2.8.3",
33
- "@modelcontextprotocol/sdk": "^1.28.0",
34
- "@dexto/agent-config": "1.13.5",
35
- "@dexto/agent-management": "1.13.5",
36
- "@dexto/core": "1.13.5",
37
- "@dexto/image-local": "1.13.5",
38
- "@dexto/llm": "1.13.5",
39
- "@dexto/storage": "1.13.5",
40
- "@dexto/tools-scheduler": "1.13.5"
38
+ "@modelcontextprotocol/sdk": "^1.32.1",
39
+ "@dexto/agent-config": "1.14.0",
40
+ "@dexto/agent-management": "1.14.0",
41
+ "@dexto/core": "1.14.0",
42
+ "@dexto/image-local": "1.14.0",
43
+ "@dexto/llm": "1.14.0",
44
+ "@dexto/storage": "1.14.0",
45
+ "@dexto/tools-scheduler": "1.14.0"
41
46
  },
42
47
  "files": [
43
48
  "dist",