mandala-computer-mcp 0.1.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 (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +544 -0
  3. package/dist/api.d.ts +186 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +932 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/cli.d.ts +55 -0
  8. package/dist/cli.d.ts.map +1 -0
  9. package/dist/cli.js +292 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/errors.d.ts +560 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +873 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/events.d.ts +406 -0
  16. package/dist/events.d.ts.map +1 -0
  17. package/dist/events.js +1679 -0
  18. package/dist/events.js.map +1 -0
  19. package/dist/format.d.ts +125 -0
  20. package/dist/format.d.ts.map +1 -0
  21. package/dist/format.js +180 -0
  22. package/dist/format.js.map +1 -0
  23. package/dist/http.d.ts +46 -0
  24. package/dist/http.d.ts.map +1 -0
  25. package/dist/http.js +792 -0
  26. package/dist/http.js.map +1 -0
  27. package/dist/index.d.ts +13 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +12 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/paths.d.ts +394 -0
  32. package/dist/paths.d.ts.map +1 -0
  33. package/dist/paths.js +677 -0
  34. package/dist/paths.js.map +1 -0
  35. package/dist/server.d.ts +18 -0
  36. package/dist/server.d.ts.map +1 -0
  37. package/dist/server.js +97 -0
  38. package/dist/server.js.map +1 -0
  39. package/dist/session.d.ts +78 -0
  40. package/dist/session.d.ts.map +1 -0
  41. package/dist/session.js +166 -0
  42. package/dist/session.js.map +1 -0
  43. package/dist/stdio.d.ts +11 -0
  44. package/dist/stdio.d.ts.map +1 -0
  45. package/dist/stdio.js +43 -0
  46. package/dist/stdio.js.map +1 -0
  47. package/dist/tools/agent.d.ts +16 -0
  48. package/dist/tools/agent.d.ts.map +1 -0
  49. package/dist/tools/agent.js +147 -0
  50. package/dist/tools/agent.js.map +1 -0
  51. package/dist/tools/computers.d.ts +3 -0
  52. package/dist/tools/computers.d.ts.map +1 -0
  53. package/dist/tools/computers.js +1037 -0
  54. package/dist/tools/computers.js.map +1 -0
  55. package/dist/tools/events.d.ts +3 -0
  56. package/dist/tools/events.d.ts.map +1 -0
  57. package/dist/tools/events.js +1077 -0
  58. package/dist/tools/events.js.map +1 -0
  59. package/dist/tools/guest.d.ts +3 -0
  60. package/dist/tools/guest.d.ts.map +1 -0
  61. package/dist/tools/guest.js +761 -0
  62. package/dist/tools/guest.js.map +1 -0
  63. package/dist/tools/input.d.ts +3 -0
  64. package/dist/tools/input.d.ts.map +1 -0
  65. package/dist/tools/input.js +240 -0
  66. package/dist/tools/input.js.map +1 -0
  67. package/dist/tools/snapshots.d.ts +3 -0
  68. package/dist/tools/snapshots.d.ts.map +1 -0
  69. package/dist/tools/snapshots.js +333 -0
  70. package/dist/tools/snapshots.js.map +1 -0
  71. package/dist/tools/templates.d.ts +3 -0
  72. package/dist/tools/templates.d.ts.map +1 -0
  73. package/dist/tools/templates.js +492 -0
  74. package/dist/tools/templates.js.map +1 -0
  75. package/dist/tools/types.d.ts +18 -0
  76. package/dist/tools/types.d.ts.map +1 -0
  77. package/dist/tools/types.js +2 -0
  78. package/dist/tools/types.js.map +1 -0
  79. package/dist/tools/webhooks.d.ts +3 -0
  80. package/dist/tools/webhooks.d.ts.map +1 -0
  81. package/dist/tools/webhooks.js +260 -0
  82. package/dist/tools/webhooks.js.map +1 -0
  83. package/package.json +59 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,uEAAuE;AACvE,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAA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CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,qBAAqB,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CACb,mBAAmB,SAAS,CAAC,MAAM,0CAA0C,qBAAqB,mCAAmC,CACtI,CAAC;IACJ,CAAC;IACD,OAAO,aAAa,CAAC;QACnB,GAAG;QACH,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,MAAM;QACN,SAAS;QACT,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { type SessionConfig } from './session.js';
3
+ import type { ToolOptions } from './tools/types.js';
4
+ export declare const SERVER_NAME = "mandala-computer";
5
+ export declare const SERVER_VERSION = "0.1.0";
6
+ export type ServerConfig = SessionConfig & Partial<ToolOptions> & {
7
+ /** Internal HTTP hook: hold a session active for the real tool callback lifetime. */
8
+ activity?: () => () => void;
9
+ };
10
+ /**
11
+ * One MCP server over one account's API key.
12
+ *
13
+ * Built per session rather than once per process, because the HTTP transport
14
+ * gives every caller their own key and their own selected computer. The stdio
15
+ * transport builds exactly one and that is the same thing with n=1.
16
+ */
17
+ export declare function createServer(cfg: ServerConfig): McpServer;
18
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAW,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAQ3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAC9C,eAAO,MAAM,cAAc,UAAU,CAAC;AAoCtC,MAAM,MAAM,YAAY,GAAG,aAAa,GACtC,OAAO,CAAC,WAAW,CAAC,GAAG;IACrB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,MAAM,IAAI,CAAC;CAC7B,CAAC;AAEJ;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,YAAY,GAAG,SAAS,CAmDzD"}
package/dist/server.js ADDED
@@ -0,0 +1,97 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { Session } from './session.js';
3
+ import { registerAgent } from './tools/agent.js';
4
+ import { registerComputers } from './tools/computers.js';
5
+ import { registerEvents } from './tools/events.js';
6
+ import { registerGuest } from './tools/guest.js';
7
+ import { registerInput } from './tools/input.js';
8
+ import { registerSnapshots } from './tools/snapshots.js';
9
+ import { registerTemplates } from './tools/templates.js';
10
+ import { registerWebhooks } from './tools/webhooks.js';
11
+ export const SERVER_NAME = 'mandala-computer';
12
+ export const SERVER_VERSION = '0.1.0';
13
+ /**
14
+ * Told to the client on connect, and shown to the model before any tool is
15
+ * called. It is the only place to say the things that are true of the whole
16
+ * server rather than of one tool — chiefly that a screenshot is how you find
17
+ * out what happened, because nothing on a desktop reports back on its own.
18
+ *
19
+ * Built from `lifecycle` rather than written out flat, because under
20
+ * MANDALA_NO_LIFECYCLE `create_computer` is not registered at all — and the
21
+ * reason it is withheld rather than left to refuse is that a tool a model can
22
+ * see is a tool it will try. Naming it in the very first line of the
23
+ * instructions gave the model the same idea by a different route, in the one
24
+ * text it reads before it has a tool list to check against.
25
+ */
26
+ const instructions = (lifecycle) => `Mandala Computer gives you a real Linux desktop in the cloud that you can see and drive.
27
+
28
+ How to work with one:
29
+
30
+ 1. ${lifecycle ? 'use_computer (or create_computer) binds' : 'use_computer binds'} a machine to this session. Every other tool then leaves computer_id out.
31
+ 2. wait_for_computer with until="guest" before the first screenshot or exec. A computer that reports "running" is a VM the hypervisor has started; the desktop inside it comes up seconds later.
32
+ 3. screenshot, look, act, screenshot again. The desktop does not tell you whether a click landed — the only way to know is to look. Take a fresh screenshot after anything you expect to change the screen.
33
+ 4. Coordinates are the pixels of the full-size screenshot, and the screen size is on the computer record as "resolution".
34
+
35
+ Things that are true here and are not obvious:
36
+
37
+ - exec runs as root with NO display. A GUI application started without desktop: true cannot draw. open_url is the reliable way to put a web page on the screen.
38
+ - Anything slower than a few seconds wants exec with background: true — a build or an install run in the foreground comes back as a timeout with the work still going and its output unreadable. Sixteen of them run at once per computer, and a slot is held until its command exits; exec_kill on a pid you no longer need is what frees one.
39
+ - The computer says what it is doing, so you do not have to look in order to find out. wait_for_event blocks until something is reported — a background command exiting, a window opening, the desktop coming up, the machine going idle — and poll_events hands you whatever was reported while you were busy with something else. The stream is held open between your turns, so nothing that happens between two calls is missed and a wait that times out has cost you nothing. Use these in place of a screenshot loop: a screenshot is for seeing what the screen LOOKS like, not for finding out whether anything changed.
40
+ - Waiting for a FILE is its own call, because a directory has to be nominated before the machine reports anything under it: wait_for_file_change takes an absolute directory in the guest, makes sure the guest is genuinely watching it, and then blocks until something under it is created, changed or deleted. Use it for a build's output or a download landing, in place of running ls in a loop. Nominate the narrowest directory you care about — a home directory under a build reports one "too much changed" marker instead of the changes — and read that marker as "list the directory again", not as a failure.
41
+ - list_windows tells you what is on the screen as data. It is how you distinguish an application that failed to start from one that has not painted yet, which a screenshot alone cannot do.
42
+ - A computer suspends itself when nobody uses it — 30 minutes by default. Input, exec and file transfers all count as use and resume it. Screenshots deliberately do not, so a loop that only watches can see its own machine go down.
43
+ - A 409 is not one thing, and retrying blindly is how a turn gets burned. Most describe a passing state and clear on their own: a guest still booting, a guest agent busy with another call. Some describe a DECISION about what you asked for — a size the host cannot run, a computer that has to be stopped first — and those answer the same way forever; the message says which, and usually says what to do instead. A 400 never clears.
44
+ - Growing a computer past what its host can run is the refusal worth knowing by name: update_computer says a move is possible, and move_computer is how you take that up. It moves the machine to different hardware and copies its disk, so say what it costs before you call it.`;
45
+ /**
46
+ * One MCP server over one account's API key.
47
+ *
48
+ * Built per session rather than once per process, because the HTTP transport
49
+ * gives every caller their own key and their own selected computer. The stdio
50
+ * transport builds exactly one and that is the same thing with n=1.
51
+ */
52
+ export function createServer(cfg) {
53
+ const session = new Session(cfg);
54
+ const opts = { lifecycle: cfg.lifecycle ?? true };
55
+ const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, { capabilities: { logging: {} }, instructions: instructions(opts.lifecycle) });
56
+ // A cancelled Streamable HTTP response can let transport.handleRequest()
57
+ // settle while the tool callback is still awaiting platform work. Wrap tool
58
+ // registration once so the HTTP session lease follows that real lifetime.
59
+ // Stdio has no hook and pays no cost beyond this branch.
60
+ if (cfg.activity) {
61
+ const register = server.registerTool.bind(server);
62
+ server.registerTool = ((...args) => {
63
+ const handlerIndex = args.length - 1;
64
+ const handler = args[handlerIndex];
65
+ args[handlerIndex] = async (...handlerArgs) => {
66
+ const release = cfg.activity?.();
67
+ try {
68
+ return await handler(...handlerArgs);
69
+ }
70
+ finally {
71
+ release?.();
72
+ }
73
+ };
74
+ return register(...args);
75
+ });
76
+ }
77
+ registerComputers(server, session, opts);
78
+ registerInput(server, session, opts);
79
+ registerGuest(server, session, opts);
80
+ registerSnapshots(server, session, opts);
81
+ registerTemplates(server, session, opts);
82
+ registerEvents(server, session, opts);
83
+ registerWebhooks(server, session, opts);
84
+ registerAgent(server, session, opts);
85
+ // The event sockets outlive every tool call by design (OPL-3926), so nothing
86
+ // in a tool can be the thing that closes them. This is the end of the
87
+ // session, which is the lifetime they actually have — without it an HTTP
88
+ // transport whose client went away leaves a websocket per computer open,
89
+ // reconnecting, for as long as the process lives.
90
+ const closed = server.server.onclose;
91
+ server.server.onclose = () => {
92
+ session.events.closeAll();
93
+ closed?.();
94
+ };
95
+ return server;
96
+ }
97
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"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,CAAC;IAErC,6EAA6E;IAC7E,sEAAsE;IACtE,yEAAyE;IACzE,yEAAyE;IACzE,kDAAkD;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IACrC,MAAM,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;QAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC1B,MAAM,EAAE,EAAE,CAAC;IACb,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { Api } from './api.js';
2
+ import { EventHub, type EventSocketFactory } from './events.js';
3
+ export type SessionConfig = {
4
+ apiKey: string;
5
+ baseUrl?: string;
6
+ /** A computer bound at startup, so a single-machine setup never calls use_computer. */
7
+ computerId?: string;
8
+ /**
9
+ * The caller's Anthropic key, for the one route that runs a model.
10
+ *
11
+ * Absent is the ordinary case and is not an error: the `run_agent` tool is
12
+ * simply not registered, rather than being offered and then failing on use.
13
+ * A tool a model can see is a tool it will try.
14
+ */
15
+ modelKey?: string;
16
+ /**
17
+ * How the event stream opens a websocket. Defaults to undici's.
18
+ *
19
+ * A seam rather than a knob: the platform's event socket is the one part of
20
+ * this server that is not `fetch`, so it is the one part a test cannot stand
21
+ * in for by replacing the global.
22
+ */
23
+ webSocket?: EventSocketFactory;
24
+ };
25
+ /**
26
+ * One MCP session's state: whose account, and which computer.
27
+ *
28
+ * Per-session and not per-process, which matters for the HTTP transport. There,
29
+ * every caller arrives with their own `com_…` key and gets their own Session;
30
+ * a module-level client would mean the second caller to connect drove the
31
+ * first one's computers with the first one's key.
32
+ */
33
+ export declare class Session {
34
+ #private;
35
+ readonly api: Api;
36
+ /**
37
+ * The event sockets this session is holding open (OPL-3926).
38
+ *
39
+ * On the session and not on a tool, because that is the whole shape of the
40
+ * decision: the socket outlives the call that opened it, and the next turn's
41
+ * `poll_events` is a different tool invocation reading the same buffer.
42
+ */
43
+ readonly events: EventHub;
44
+ readonly modelKey?: string;
45
+ constructor(cfg: SessionConfig);
46
+ get current(): string | undefined;
47
+ get screen(): string | undefined;
48
+ bind(computerId: string, resolution?: string): void;
49
+ /** Snapshot the delete generation before use_computer starts its confirming read. */
50
+ selectionVersion(computerId: string): number;
51
+ /**
52
+ * Pin this id's generation for one in-flight `use_computer`.
53
+ *
54
+ * The confirming GET can outlive hundreds of other deletes. Evicting this
55
+ * id's entry in that window would reset the generation to 0 and let
56
+ * `bindIfCurrent` succeed against a computer that was already destroyed.
57
+ */
58
+ beginSelection(computerId: string): number;
59
+ /** Drop one pin taken by {@link beginSelection}. */
60
+ endSelection(computerId: string): void;
61
+ /** Bind only if no concurrent delete completed while the id was being checked. */
62
+ bindIfCurrent(computerId: string, resolution: string | undefined, version: number): boolean;
63
+ /** Forget the binding — after a delete, so the next call does not drive a ghost. */
64
+ unbind(computerId: string): void;
65
+ /** Remember the screen without changing which computer is bound. */
66
+ noteResolution(computerId: string, resolution?: string): void;
67
+ /**
68
+ * Which computer a call is about.
69
+ *
70
+ * An explicit id always wins, so a session binding never silently redirects a
71
+ * call that named its target. Without one, the binding answers; without a
72
+ * binding, this refuses and says how to make one — a model that gets "no
73
+ * computer selected" and a next step recovers in one turn, where a bare
74
+ * "missing computer_id" sends it hunting through the tool list.
75
+ */
76
+ resolve(explicit?: string): string;
77
+ }
78
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAoB,MAAM,UAAU,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,kBAAkB,CAAC;CAChC,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,OAAO;;IAClB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAWf,GAAG,EAAE,aAAa;IAO9B,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAKnD,qFAAqF;IACrF,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAI5C;;;;;;OAMG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAQ1C,oDAAoD;IACpD,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQtC,kFAAkF;IAClF,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAO3F,oFAAoF;IACpF,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IA8BhC,oEAAoE;IACpE,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAI7D;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;CAUnC"}
@@ -0,0 +1,166 @@
1
+ import { Api, DEFAULT_BASE_URL } from './api.js';
2
+ import { MandalaError } from './errors.js';
3
+ import { EventHub } from './events.js';
4
+ /**
5
+ * One MCP session's state: whose account, and which computer.
6
+ *
7
+ * Per-session and not per-process, which matters for the HTTP transport. There,
8
+ * every caller arrives with their own `com_…` key and gets their own Session;
9
+ * a module-level client would mean the second caller to connect drove the
10
+ * first one's computers with the first one's key.
11
+ */
12
+ export class Session {
13
+ api;
14
+ /**
15
+ * The event sockets this session is holding open (OPL-3926).
16
+ *
17
+ * On the session and not on a tool, because that is the whole shape of the
18
+ * decision: the socket outlives the call that opened it, and the next turn's
19
+ * `poll_events` is a different tool invocation reading the same buffer.
20
+ */
21
+ events;
22
+ modelKey;
23
+ #current;
24
+ /** WIDTHxHEIGHT of the bound computer, remembered from the last read of it. */
25
+ #screen;
26
+ /** Successful deletes invalidate selections of the same id already in flight. */
27
+ #selectionVersions = new Map();
28
+ /** In-flight `use_computer` reads, so their generation cannot be evicted. */
29
+ #selectionPins = new Map();
30
+ /** Bound so a long-lived stdio session cannot grow one entry per deleted id. */
31
+ static #MAX_SELECTION_VERSIONS = 256;
32
+ constructor(cfg) {
33
+ this.api = new Api(cfg.apiKey, cfg.baseUrl ?? DEFAULT_BASE_URL);
34
+ this.events = new EventHub(this.api, cfg.webSocket);
35
+ this.modelKey = cfg.modelKey;
36
+ this.#current = id(cfg.computerId);
37
+ }
38
+ get current() {
39
+ return this.#current;
40
+ }
41
+ get screen() {
42
+ return this.#screen;
43
+ }
44
+ bind(computerId, resolution) {
45
+ this.#current = id(computerId);
46
+ this.#screen = resolution;
47
+ }
48
+ /** Snapshot the delete generation before use_computer starts its confirming read. */
49
+ selectionVersion(computerId) {
50
+ return this.#selectionVersions.get(id(computerId) ?? '') ?? 0;
51
+ }
52
+ /**
53
+ * Pin this id's generation for one in-flight `use_computer`.
54
+ *
55
+ * The confirming GET can outlive hundreds of other deletes. Evicting this
56
+ * id's entry in that window would reset the generation to 0 and let
57
+ * `bindIfCurrent` succeed against a computer that was already destroyed.
58
+ */
59
+ beginSelection(computerId) {
60
+ const normalized = id(computerId);
61
+ if (normalized) {
62
+ this.#selectionPins.set(normalized, (this.#selectionPins.get(normalized) ?? 0) + 1);
63
+ }
64
+ return this.selectionVersion(computerId);
65
+ }
66
+ /** Drop one pin taken by {@link beginSelection}. */
67
+ endSelection(computerId) {
68
+ const normalized = id(computerId);
69
+ if (!normalized)
70
+ return;
71
+ const held = this.#selectionPins.get(normalized) ?? 0;
72
+ if (held <= 1)
73
+ this.#selectionPins.delete(normalized);
74
+ else
75
+ this.#selectionPins.set(normalized, held - 1);
76
+ }
77
+ /** Bind only if no concurrent delete completed while the id was being checked. */
78
+ bindIfCurrent(computerId, resolution, version) {
79
+ const normalized = id(computerId);
80
+ if (!normalized || this.selectionVersion(normalized) !== version)
81
+ return false;
82
+ this.bind(normalized, resolution);
83
+ return true;
84
+ }
85
+ /** Forget the binding — after a delete, so the next call does not drive a ghost. */
86
+ unbind(computerId) {
87
+ const normalized = id(computerId);
88
+ if (!normalized)
89
+ return;
90
+ // A destroyed computer has no more events, and its socket would otherwise
91
+ // reconnect against a 404 until the idle sweep took it. The buffer goes
92
+ // too: what it holds is the history of a machine that no longer exists.
93
+ this.events.drop(normalized, `${normalized} was deleted`);
94
+ // Increment even when another computer is selected: an earlier
95
+ // use_computer for this id may still be waiting on its GET response.
96
+ // Recency is delete-then-set so a repeated id is the newest entry and an
97
+ // old deletion can be evicted first. The value itself has to stay: dropping
98
+ // it would reset the generation to 0 and let that in-flight bind succeed.
99
+ // A pinned id is never evicted, even if it is the oldest — that pin is
100
+ // exactly an in-flight bindIfCurrent that still needs the generation.
101
+ const next = this.selectionVersion(normalized) + 1;
102
+ this.#selectionVersions.delete(normalized);
103
+ this.#selectionVersions.set(normalized, next);
104
+ if (this.#selectionVersions.size > Session.#MAX_SELECTION_VERSIONS) {
105
+ for (const key of this.#selectionVersions.keys()) {
106
+ if (key === normalized || key === this.#current || this.#selectionPins.has(key))
107
+ continue;
108
+ this.#selectionVersions.delete(key);
109
+ if (this.#selectionVersions.size <= Session.#MAX_SELECTION_VERSIONS)
110
+ break;
111
+ }
112
+ }
113
+ if (this.#current !== undefined && this.#current === normalized) {
114
+ this.#current = undefined;
115
+ this.#screen = undefined;
116
+ }
117
+ }
118
+ /** Remember the screen without changing which computer is bound. */
119
+ noteResolution(computerId, resolution) {
120
+ if (id(computerId) === this.#current && resolution)
121
+ this.#screen = resolution;
122
+ }
123
+ /**
124
+ * Which computer a call is about.
125
+ *
126
+ * An explicit id always wins, so a session binding never silently redirects a
127
+ * call that named its target. Without one, the binding answers; without a
128
+ * binding, this refuses and says how to make one — a model that gets "no
129
+ * computer selected" and a next step recovers in one turn, where a bare
130
+ * "missing computer_id" sends it hunting through the tool list.
131
+ */
132
+ resolve(explicit) {
133
+ const chosen = id(explicit) ?? this.#current;
134
+ if (!chosen) {
135
+ throw new MandalaError('No computer selected. Call list_computers to see what is on this account, ' +
136
+ 'then use_computer to pick one — or pass computer_id on this call.');
137
+ }
138
+ return chosen;
139
+ }
140
+ }
141
+ /**
142
+ * A computer id as this session compares it: trimmed, and absent when that
143
+ * leaves nothing.
144
+ *
145
+ * Every id here ends up in a URL through `paths.segment`, which trims before it
146
+ * encodes — so `" vm-1"` and `"vm-1"` have always named the same machine to the
147
+ * platform while being two different strings to `===`. Every consequence of
148
+ * that gap was silent and pointed the wrong way:
149
+ *
150
+ * - `delete_computer(" vm-1")` destroyed vm-1 and then failed to unbind it,
151
+ * leaving the session driving a machine that no longer exists — the exact
152
+ * ghost `unbind` was written to prevent.
153
+ * - `noteResolution(" vm-1", …)` dropped the screen size, so the next click was
154
+ * scaled against a resolution from some other computer, or none.
155
+ * - A `MANDALA_COMPUTER_ID` with the trailing newline a `.env` file or a
156
+ * `docker run --env-file` leaves on it was stored as-is, so a session started
157
+ * that way could never be unbound by any id a model could type.
158
+ *
159
+ * Normalising at this boundary rather than at each call site is the point: the
160
+ * comparisons are the thing that was wrong, and there are four of them.
161
+ */
162
+ function id(value) {
163
+ const v = value?.trim();
164
+ return v ? v : undefined;
165
+ }
166
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.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,CAAC;IAED,oEAAoE;IACpE,cAAc,CAAC,UAAkB,EAAE,UAAmB;QACpD,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,QAAQ,IAAI,UAAU;YAAE,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;IAChF,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAiB;QACvB,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC;QAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,YAAY,CACpB,4EAA4E;gBAC1E,mEAAmE,CACtE,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;;AAGH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,EAAE,CAAC,KAAyB;IACnC,MAAM,CAAC,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IACxB,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type ServerConfig } from './server.js';
2
+ /**
3
+ * The local install: one process, one key, spawned by the MCP client.
4
+ *
5
+ * Nothing is hosted and nothing is operated — the client starts this as a
6
+ * subprocess and talks to it over stdin and stdout. Which is also why nothing
7
+ * here may ever write to stdout: that stream is the protocol, and one stray
8
+ * console.log is a parse error at the other end. Diagnostics go to stderr.
9
+ */
10
+ export declare function runStdio(cfg: ServerConfig): Promise<void>;
11
+ //# sourceMappingURL=stdio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgC/D"}
package/dist/stdio.js ADDED
@@ -0,0 +1,43 @@
1
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
2
+ import { DEFAULT_BASE_URL } from './api.js';
3
+ import { createServer } from './server.js';
4
+ /**
5
+ * The local install: one process, one key, spawned by the MCP client.
6
+ *
7
+ * Nothing is hosted and nothing is operated — the client starts this as a
8
+ * subprocess and talks to it over stdin and stdout. Which is also why nothing
9
+ * here may ever write to stdout: that stream is the protocol, and one stray
10
+ * console.log is a parse error at the other end. Diagnostics go to stderr.
11
+ */
12
+ export async function runStdio(cfg) {
13
+ const server = createServer(cfg);
14
+ const transport = new StdioServerTransport();
15
+ await server.connect(transport);
16
+ // The end of the client, and therefore the end of this process.
17
+ //
18
+ // The SDK's transport does not do it. `StdioServerTransport.start()` registers
19
+ // `data` and `error` on stdin and nothing else, so stdin reaching EOF — the
20
+ // ordinary way an MCP client goes away, since it closes the pipe rather than
21
+ // sending a shutdown — never calls `close()`, never fires the server's
22
+ // `onclose`, and so never runs the `session.events.closeAll()` that
23
+ // `createServer` hangs there. The HTTP transport was given that teardown in so
24
+ // many words; stdio had nothing.
25
+ //
26
+ // What is left behind is not a tidiness problem. A `poll_events` opens a
27
+ // websocket to the platform that outlives the tool call by design, and an open
28
+ // socket holds the event loop by itself — so the process stays up after its
29
+ // client is gone, reconnecting and talking to the platform with the user's
30
+ // API key, until something kills it. Measured: a child was still alive and
31
+ // still holding the socket ten seconds after its stdin closed.
32
+ //
33
+ // `once` on both spellings because they are not the same event and either can
34
+ // be the one that arrives: `end` is the stream reaching EOF, `close` is the
35
+ // handle going away, and a pipe whose writer dies can produce the second
36
+ // without the first. `server.close()` closes the transport, which is what
37
+ // reaches `onclose`.
38
+ const shutdown = () => void server.close().catch(() => { });
39
+ process.stdin.once('end', shutdown);
40
+ process.stdin.once('close', shutdown);
41
+ console.error(`mandala-computer-mcp on stdio → ${new URL(cfg.baseUrl ?? DEFAULT_BASE_URL).origin}`);
42
+ }
43
+ //# sourceM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16 @@
1
+ import type { Registrar } from './types.js';
2
+ /**
3
+ * The platform's own agent loop, as one tool.
4
+ *
5
+ * Registered only when a model key is configured, and that is the point of the
6
+ * conditional: a tool a model can see is a tool it will try, and one that fails
7
+ * on every call with "no model key" costs a turn to discover. Absent is a
8
+ * clearer answer than present-and-broken.
9
+ *
10
+ * Worth having even though the caller is already a model with eyes. The outer
11
+ * agent pays for every screenshot in context; this route runs the pixel-level
12
+ * loop inside the platform on the caller's own Anthropic key and hands back a
13
+ * sentence. Ten clicks stop being ten images.
14
+ */
15
+ export declare const registerAgent: Registrar;
16
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/tools/agent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,EAAE,SAwI3B,CAAC"}