@vortex-os/computer-use 0.2.0 → 0.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vortex-os/computer-use",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Add-on — read-only screen perception (structured UIA tree + pixel fallback + change watch) exposed as an MCP server, layered on @vortex-os/base. Windows-first. Control (mouse/keyboard) is intentionally out of scope.",
5
5
  "license": "MIT",
6
6
  "author": "vortex-os-project",
@@ -5,11 +5,8 @@
5
5
  // - default: run the stdio server (what an MCP host launches).
6
6
  // - `install`: self-register into the project `.mcp.json` under the non-reserved key
7
7
  // `vortex-computer-use` (merge-safe). e.g. `npx vortex-mcp-computer-use install`.
8
- // Optional dep: @modelcontextprotocol/sdk (declared optional; imported by this entry `install`
9
- // just registers and exits without connecting a transport).
10
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
11
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
12
- import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
8
+ // Optional dep: @modelcontextprotocol/sdk loaded DYNAMICALLY only on the serve path (see the
9
+ // bottom dispatch), so `install` registers and exits without needing the SDK present.
13
10
  import { spawnSync, spawn } from 'node:child_process';
14
11
  import { fileURLToPath } from 'node:url';
15
12
  import { dirname, join } from 'node:path';
@@ -412,11 +409,8 @@ const TOOLS = [
412
409
  },
413
410
  ];
414
411
 
415
- const server = new Server({ name: 'computer-use', version: '0.0.1-poc' }, { capabilities: { tools: {} } });
416
-
417
- server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
418
-
419
- server.setRequestHandler(CallToolRequestSchema, async (req) => {
412
+ // The CallTool handler — standalone (no SDK types), wired to the server only on the serve path.
413
+ async function handleCallTool(req) {
420
414
  const { name, arguments: a = {} } = req.params;
421
415
  const useWorker = plat === 'win32'; // the resident worker is Windows PowerShell backend only
422
416
  let result;
@@ -538,7 +532,7 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
538
532
  } finally {
539
533
  if (reqDir) { try { rmSync(reqDir, { recursive: true, force: true }); } catch {} }
540
534
  }
541
- });
535
+ }
542
536
 
543
537
  // Clean up the worker on server shutdown (it would also auto-terminate via stdin EOF when the parent dies, but do it explicitly).
544
538
  process.on('exit', () => workerMgr.dispose());
@@ -611,7 +605,13 @@ function runInstall(argv) {
611
605
  if (process.argv.slice(2).includes('install')) {
612
606
  runInstall(process.argv.slice(2));
613
607
  } else {
614
- const transport = new StdioServerTransport();
615
- await server.connect(transport);
608
+ // Serve path: load the MCP SDK dynamically (so `install` never requires it), wire the handlers, connect.
609
+ const { Server } = await import('@modelcontextprotocol/sdk/server/index.js');
610
+ const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
611
+ const { ListToolsRequestSchema, CallToolRequestSchema } = await import('@modelcontextprotocol/sdk/types.js');
612
+ const server = new Server({ name: 'computer-use', version: '0.2.1' }, { capabilities: { tools: {} } });
613
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
614
+ server.setRequestHandler(CallToolRequestSchema, handleCallTool);
615
+ await server.connect(new StdioServerTransport());
616
616
  process.stderr.write(`[computer-use MCP] ready on stdio (worker=${plat === 'win32' ? 'on' : 'off'}; tools: probe, read_ui, capture_screen, watch_capture, poll_change, beep)\n`);
617
617
  }