@chatroomcp/chatroom 0.1.7 → 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.
Files changed (51) hide show
  1. package/dist/app/application.d.ts +1 -0
  2. package/dist/app/application.js +4 -0
  3. package/dist/app/event-bus.d.ts +4 -0
  4. package/dist/auth/ingress-policy.d.ts +2 -0
  5. package/dist/auth/ingress-policy.js +7 -1
  6. package/dist/infrastructure/database/app-database.js +7 -0
  7. package/dist/infrastructure/http/http-server.js +5 -1
  8. package/dist/mcp/server/plugin-mcp-registrar.d.ts +6 -1
  9. package/dist/mcp/server/plugin-mcp-registrar.js +4 -4
  10. package/dist/mcp/server/request-context.d.ts +3 -0
  11. package/dist/mcp/server/request-context.js +8 -0
  12. package/dist/mcp/server/tool-support.d.ts +1 -1
  13. package/dist/mcp/server/tool-support.js +3 -1
  14. package/dist/native/linux/chatroom-computer-helper +0 -0
  15. package/dist/native/macos/ChatRoomComputerHelper.app/Contents/Info.plist +14 -0
  16. package/dist/native/macos/ChatRoomComputerHelper.app/Contents/MacOS/chatroom-computer-helper +0 -0
  17. package/dist/native/macos/ChatRoomComputerHelper.app/Contents/_CodeSignature/CodeResources +115 -0
  18. package/dist/native/windows/chatroom-computer-helper.exe +0 -0
  19. package/dist/plugins/computer/audit.d.ts +34 -0
  20. package/dist/plugins/computer/audit.js +42 -0
  21. package/dist/plugins/computer/computer-native-backend.d.ts +11 -0
  22. package/dist/plugins/computer/computer-native-backend.js +58 -0
  23. package/dist/plugins/computer/computer-native-host.d.ts +27 -0
  24. package/dist/plugins/computer/computer-native-host.js +335 -0
  25. package/dist/plugins/computer/computer-protocol.d.ts +21 -0
  26. package/dist/plugins/computer/computer-protocol.js +72 -0
  27. package/dist/plugins/computer/computer-schemas.d.ts +318 -0
  28. package/dist/plugins/computer/computer-schemas.js +152 -0
  29. package/dist/plugins/computer/computer-service.d.ts +27 -0
  30. package/dist/plugins/computer/computer-service.js +108 -0
  31. package/dist/plugins/computer/computer-settings-repository.d.ts +8 -0
  32. package/dist/plugins/computer/computer-settings-repository.js +41 -0
  33. package/dist/plugins/computer/mcp.d.ts +3 -0
  34. package/dist/plugins/computer/mcp.js +126 -0
  35. package/dist/plugins/computer/plugin.d.ts +4 -0
  36. package/dist/plugins/computer/plugin.js +29 -0
  37. package/dist/plugins/computer/types.d.ts +174 -0
  38. package/dist/plugins/computer/types.js +1 -0
  39. package/dist/plugins/web/api-types.d.ts +15 -1
  40. package/dist/plugins/web/http/api-router.js +2 -0
  41. package/dist/plugins/web/http/computer-api-router.d.ts +5 -0
  42. package/dist/plugins/web/http/computer-api-router.js +68 -0
  43. package/dist/plugins/web/plugin.js +3 -1
  44. package/dist/plugins/web/runtime.d.ts +3 -1
  45. package/dist/plugins/web/runtime.js +3 -1
  46. package/dist/web/assets/index-B4vO7wVS.css +1 -0
  47. package/dist/web/assets/index-BU7LCgKB.js +26 -0
  48. package/dist/web/index.html +2 -2
  49. package/package.json +6 -3
  50. package/dist/web/assets/index-B7jL3mhD.css +0 -1
  51. package/dist/web/assets/index-L4-YdZVN.js +0 -26
@@ -13,6 +13,7 @@ export interface ApplicationComponents {
13
13
  application: import("../plugins/web/runtime.js").WebRuntime;
14
14
  processes: import("../plugins/process/process-supervisor.js").ProcessSupervisor;
15
15
  cloud: import("../plugins/cloud/controller.js").CloudController;
16
+ computer: import("../plugins/computer/computer-service.js").ComputerService;
16
17
  http: HttpServer;
17
18
  }
18
19
  export declare function createApplication(config: ChatRoomConfig): Promise<ApplicationComponents>;
@@ -13,6 +13,7 @@ import { PluginManager } from "../plugins/plugin-manager.js";
13
13
  import { createWorkspacePlugin } from "../plugins/workspace/plugin.js";
14
14
  import { createProcessPlugin, ProcessService, } from "../plugins/process/plugin.js";
15
15
  import { createCloudPlugin, CloudService } from "../plugins/cloud/plugin.js";
16
+ import { createComputerPlugin, ComputerServiceToken, } from "../plugins/computer/plugin.js";
16
17
  import { createWebPlugin, WebServiceToken } from "../plugins/web/plugin.js";
17
18
  import { createChatRoomMcpHandler } from "../mcp/server/create-mcp-server.js";
18
19
  import { HttpServer } from "../infrastructure/http/http-server.js";
@@ -36,6 +37,7 @@ export async function createApplication(config) {
36
37
  }, [
37
38
  createWorkspacePlugin(),
38
39
  createProcessPlugin(),
40
+ createComputerPlugin(),
39
41
  createCloudPlugin(),
40
42
  createWebPlugin(),
41
43
  ]);
@@ -43,6 +45,7 @@ export async function createApplication(config) {
43
45
  const web = services.require(WebServiceToken);
44
46
  const processes = services.require(ProcessService);
45
47
  const cloud = services.require(CloudService);
48
+ const computer = services.require(ComputerServiceToken);
46
49
  const mcp = createChatRoomMcpHandler(plugins);
47
50
  const http = new HttpServer(config, web.application, eventBus, auth, passkeys, mcp, externalAccess, cloud);
48
51
  return {
@@ -53,6 +56,7 @@ export async function createApplication(config) {
53
56
  application: web.application,
54
57
  processes,
55
58
  cloud,
59
+ computer,
56
60
  http,
57
61
  };
58
62
  }
@@ -1,5 +1,6 @@
1
1
  import type { Operation } from "../core/operations/types.js";
2
2
  import type { ProcessSnapshot } from "../plugins/process/types.js";
3
+ import type { ComputerSettings } from "../plugins/computer/types.js";
3
4
  export type RuntimeEvent = {
4
5
  type: "operation";
5
6
  operation: Operation;
@@ -10,6 +11,9 @@ export type RuntimeEvent = {
10
11
  } | {
11
12
  type: "process";
12
13
  process: ProcessSnapshot;
14
+ } | {
15
+ type: "computer-settings";
16
+ settings: ComputerSettings;
13
17
  } | {
14
18
  type: "process-output";
15
19
  processId: string;
@@ -12,7 +12,9 @@ export declare class IngressPolicy {
12
12
  constructor(config: ChatRoomConfig, externalAccess: ExternalAccessRegistry);
13
13
  allowedHosts(): ReadonlySet<string>;
14
14
  requiresWebAuth(req: Request): boolean;
15
+ isExternalWeb(req: Request): boolean;
15
16
  requiresMcpAuth(req: Request): boolean;
17
+ isExternalMcp(req: Request): boolean;
16
18
  secureWebCookie(req: Request): boolean;
17
19
  expectedWebOrigin(req: Request): string | null;
18
20
  webAuthnOrigin(req: Request): WebAuthnOrigin | null;
@@ -16,11 +16,17 @@ export class IngressPolicy {
16
16
  return allowed;
17
17
  }
18
18
  requiresWebAuth(req) {
19
- if (this.externalAccess.matches("web", req.hostname))
19
+ if (this.isExternalWeb(req))
20
20
  return true;
21
21
  return this.config.auth.localWebAuth;
22
22
  }
23
+ isExternalWeb(req) {
24
+ return this.externalAccess.matches("web", req.hostname);
25
+ }
23
26
  requiresMcpAuth(req) {
27
+ return this.isExternalMcp(req);
28
+ }
29
+ isExternalMcp(req) {
24
30
  return this.externalAccess.matches("mcp", req.hostname);
25
31
  }
26
32
  secureWebCookie(req) {
@@ -89,6 +89,13 @@ const SCHEMA = `
89
89
  );
90
90
  CREATE INDEX IF NOT EXISTS passkeys_last_used_idx ON passkeys(last_used_at DESC);
91
91
 
92
+ CREATE TABLE IF NOT EXISTS computer_settings (
93
+ id INTEGER PRIMARY KEY CHECK(id = 1),
94
+ enabled INTEGER NOT NULL DEFAULT 0,
95
+ remote_access INTEGER NOT NULL DEFAULT 1,
96
+ updated_at TEXT NOT NULL
97
+ );
98
+
92
99
  `;
93
100
  export class AppDatabase {
94
101
  raw;
@@ -10,6 +10,7 @@ import { createOAuthRouter } from "../../presentation/http/oauth-router.js";
10
10
  import { errorMiddleware } from "../../presentation/http/http-utils.js";
11
11
  import { IngressPolicy } from "../../auth/ingress-policy.js";
12
12
  import { CHATROOM_VERSION } from "../../core/runtime/identity.js";
13
+ import { runWithMcpAccessScope } from "../../mcp/server/request-context.js";
13
14
  const WEB_UI_RESERVED_PREFIXES = [
14
15
  "/api",
15
16
  "/mcp",
@@ -60,7 +61,10 @@ export class HttpServer {
60
61
  this.mcpRequestCount += 1;
61
62
  next();
62
63
  }, mcpAuthentication(this.auth, this.ingress), (req, res) => {
63
- void nodeMcp(req, res, req.body);
64
+ const scope = this.ingress.isExternalMcp(req) ? "remote" : "local";
65
+ runWithMcpAccessScope(scope, () => {
66
+ void nodeMcp(req, res, req.body);
67
+ });
64
68
  });
65
69
  const webRoot = fileURLToPath(new URL("../../web/", import.meta.url));
66
70
  const webIndexPath = path.join(webRoot, "index.html");
@@ -1,4 +1,4 @@
1
- import type { McpServer, StandardSchemaWithJSON, ToolAnnotations } from "@modelcontextprotocol/server";
1
+ import type { McpServer, StandardSchemaWithJSON, ToolAnnotations, CallToolResult } from "@modelcontextprotocol/server";
2
2
  import type { OperationLog } from "../../operations/operation-log.js";
3
3
  type PluginToolInput<Schema extends StandardSchemaWithJSON> = StandardSchemaWithJSON.InferOutput<Schema>;
4
4
  type PluginToolAction<Input> = string | ((input: Input) => string);
@@ -14,6 +14,11 @@ export interface PluginToolConfig<InputSchema extends StandardSchemaWithJSON, Ou
14
14
  outputSchema: OutputSchema;
15
15
  annotations: ToolAnnotations;
16
16
  action: PluginToolAction<PluginToolInput<InputSchema>>;
17
+ audit?: {
18
+ input?: (input: PluginToolInput<InputSchema>) => unknown;
19
+ output?: (output: unknown) => unknown;
20
+ };
21
+ present?: (output: unknown) => CallToolResult;
17
22
  }
18
23
  /** Framework-owned MCP registration boundary that guarantees every plugin tool is audited. */
19
24
  export declare class PluginMcpRegistrar {
@@ -11,13 +11,13 @@ export class PluginMcpRegistrar {
11
11
  this.pluginId = pluginId;
12
12
  }
13
13
  registerTool(name, config, handler) {
14
- const { action, ...toolConfig } = config;
14
+ const { action, audit, present, ...toolConfig } = config;
15
15
  const callback = mcpTool(async (input) => {
16
16
  const operation = this.operations.start({
17
17
  pluginId: this.pluginId,
18
18
  source: "mcp",
19
19
  action: typeof action === "function" ? action(input) : action,
20
- input,
20
+ input: audit?.input ? audit.input(input) : input,
21
21
  ...operationReferences(input),
22
22
  });
23
23
  let deferred = false;
@@ -30,7 +30,7 @@ export class PluginMcpRegistrar {
30
30
  try {
31
31
  const result = await handler(input, execution);
32
32
  if (!deferred)
33
- this.operations.finish(operation.operationId, "success", result);
33
+ this.operations.finish(operation.operationId, "success", audit?.output ? audit.output(result) : result);
34
34
  return result;
35
35
  }
36
36
  catch (error) {
@@ -44,7 +44,7 @@ export class PluginMcpRegistrar {
44
44
  }
45
45
  throw error;
46
46
  }
47
- });
47
+ }, present);
48
48
  this.server.registerTool(name, toolConfig, callback);
49
49
  }
50
50
  }
@@ -0,0 +1,3 @@
1
+ import type { ComputerAccessScope } from "../../plugins/computer/types.js";
2
+ export declare function runWithMcpAccessScope<T>(scope: ComputerAccessScope, action: () => T): T;
3
+ export declare function currentMcpAccessScope(): ComputerAccessScope;
@@ -0,0 +1,8 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ const storage = new AsyncLocalStorage();
3
+ export function runWithMcpAccessScope(scope, action) {
4
+ return storage.run(scope, action);
5
+ }
6
+ export function currentMcpAccessScope() {
7
+ return storage.getStore() ?? "local";
8
+ }
@@ -102,4 +102,4 @@ export declare const processSnapshotSchema: z.ZodObject<{
102
102
  timedOut: z.ZodBoolean;
103
103
  operationId: z.ZodString;
104
104
  }, z.core.$strip>;
105
- export declare function mcpTool<T>(operation: (input: T) => Promise<unknown> | unknown): (input: T) => Promise<CallToolResult>;
105
+ export declare function mcpTool<T>(operation: (input: T) => Promise<unknown> | unknown, present?: (value: unknown) => CallToolResult): (input: T) => Promise<CallToolResult>;
@@ -90,10 +90,12 @@ export const processSnapshotSchema = z.object({
90
90
  timedOut: z.boolean(),
91
91
  operationId: z.string(),
92
92
  });
93
- export function mcpTool(operation) {
93
+ export function mcpTool(operation, present) {
94
94
  return async (input) => {
95
95
  try {
96
96
  const value = await operation(input);
97
+ if (present)
98
+ return present(value);
97
99
  return {
98
100
  content: [{ type: "text", text: JSON.stringify(value, null, 2) }],
99
101
  structuredContent: asRecord(value),
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0"><dict>
4
+ <key>CFBundleIdentifier</key><string>com.chatroomcp.computer</string>
5
+ <key>CFBundleName</key><string>ChatRoom Computer Helper</string>
6
+ <key>CFBundleDisplayName</key><string>ChatRoom Computer Helper</string>
7
+ <key>CFBundleExecutable</key><string>chatroom-computer-helper</string>
8
+ <key>CFBundlePackageType</key><string>APPL</string>
9
+ <key>CFBundleVersion</key><string>1</string>
10
+ <key>CFBundleShortVersionString</key><string>1.0</string>
11
+ <key>LSMinimumSystemVersion</key><string>15.2</string>
12
+ <key>LSUIElement</key><true/>
13
+ <key>NSHumanReadableCopyright</key><string>ChatRoom</string>
14
+ </dict></plist>
@@ -0,0 +1,115 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>files</key>
6
+ <dict/>
7
+ <key>files2</key>
8
+ <dict/>
9
+ <key>rules</key>
10
+ <dict>
11
+ <key>^Resources/</key>
12
+ <true/>
13
+ <key>^Resources/.*\.lproj/</key>
14
+ <dict>
15
+ <key>optional</key>
16
+ <true/>
17
+ <key>weight</key>
18
+ <real>1000</real>
19
+ </dict>
20
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
21
+ <dict>
22
+ <key>omit</key>
23
+ <true/>
24
+ <key>weight</key>
25
+ <real>1100</real>
26
+ </dict>
27
+ <key>^Resources/Base\.lproj/</key>
28
+ <dict>
29
+ <key>weight</key>
30
+ <real>1010</real>
31
+ </dict>
32
+ <key>^version.plist$</key>
33
+ <true/>
34
+ </dict>
35
+ <key>rules2</key>
36
+ <dict>
37
+ <key>.*\.dSYM($|/)</key>
38
+ <dict>
39
+ <key>weight</key>
40
+ <real>11</real>
41
+ </dict>
42
+ <key>^(.*/)?\.DS_Store$</key>
43
+ <dict>
44
+ <key>omit</key>
45
+ <true/>
46
+ <key>weight</key>
47
+ <real>2000</real>
48
+ </dict>
49
+ <key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
50
+ <dict>
51
+ <key>nested</key>
52
+ <true/>
53
+ <key>weight</key>
54
+ <real>10</real>
55
+ </dict>
56
+ <key>^.*</key>
57
+ <true/>
58
+ <key>^Info\.plist$</key>
59
+ <dict>
60
+ <key>omit</key>
61
+ <true/>
62
+ <key>weight</key>
63
+ <real>20</real>
64
+ </dict>
65
+ <key>^PkgInfo$</key>
66
+ <dict>
67
+ <key>omit</key>
68
+ <true/>
69
+ <key>weight</key>
70
+ <real>20</real>
71
+ </dict>
72
+ <key>^Resources/</key>
73
+ <dict>
74
+ <key>weight</key>
75
+ <real>20</real>
76
+ </dict>
77
+ <key>^Resources/.*\.lproj/</key>
78
+ <dict>
79
+ <key>optional</key>
80
+ <true/>
81
+ <key>weight</key>
82
+ <real>1000</real>
83
+ </dict>
84
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
85
+ <dict>
86
+ <key>omit</key>
87
+ <true/>
88
+ <key>weight</key>
89
+ <real>1100</real>
90
+ </dict>
91
+ <key>^Resources/Base\.lproj/</key>
92
+ <dict>
93
+ <key>weight</key>
94
+ <real>1010</real>
95
+ </dict>
96
+ <key>^[^/]+$</key>
97
+ <dict>
98
+ <key>nested</key>
99
+ <true/>
100
+ <key>weight</key>
101
+ <real>10</real>
102
+ </dict>
103
+ <key>^embedded\.provisionprofile$</key>
104
+ <dict>
105
+ <key>weight</key>
106
+ <real>20</real>
107
+ </dict>
108
+ <key>^version\.plist$</key>
109
+ <dict>
110
+ <key>weight</key>
111
+ <real>20</real>
112
+ </dict>
113
+ </dict>
114
+ </dict>
115
+ </plist>
@@ -0,0 +1,34 @@
1
+ import type { ComputerAction, ComputerActionResult, ComputerSnapshot } from "./types.js";
2
+ export declare function auditComputerActions(input: {
3
+ snapshotId?: string;
4
+ actions: ComputerAction[];
5
+ observeAfter?: boolean;
6
+ }): {
7
+ snapshotId: string | null;
8
+ observeAfter: boolean;
9
+ actions: unknown[];
10
+ };
11
+ export declare function auditSnapshotOutput(value: ComputerSnapshot): {
12
+ snapshotId: string;
13
+ revision: number;
14
+ display: import("./types.js").ComputerDisplay | null;
15
+ activeApp: string | null;
16
+ activeWindow: string | null;
17
+ elementCount: number;
18
+ screenshot: boolean;
19
+ };
20
+ export declare function auditActionOutput(value: ComputerActionResult): {
21
+ success: true;
22
+ revision: number;
23
+ executionMode: "semantic" | "background" | "foreground" | "mixed";
24
+ focusChanged: boolean;
25
+ snapshot: {
26
+ snapshotId: string;
27
+ revision: number;
28
+ display: import("./types.js").ComputerDisplay | null;
29
+ activeApp: string | null;
30
+ activeWindow: string | null;
31
+ elementCount: number;
32
+ screenshot: boolean;
33
+ } | null;
34
+ };
@@ -0,0 +1,42 @@
1
+ export function auditComputerActions(input) {
2
+ return {
3
+ snapshotId: input.snapshotId ?? null,
4
+ observeAfter: input.observeAfter ?? true,
5
+ actions: input.actions.map((action) => sanitizeAction(action)),
6
+ };
7
+ }
8
+ function sanitizeAction(action) {
9
+ if (action.type === "type_text")
10
+ return {
11
+ type: action.type,
12
+ characters: action.text.length,
13
+ elementId: action.elementId ?? null,
14
+ };
15
+ if (action.type === "set_value")
16
+ return {
17
+ type: action.type,
18
+ characters: action.value.length,
19
+ elementId: action.elementId,
20
+ };
21
+ return action;
22
+ }
23
+ export function auditSnapshotOutput(value) {
24
+ return {
25
+ snapshotId: value.snapshotId,
26
+ revision: value.revision,
27
+ display: value.display,
28
+ activeApp: value.activeApp,
29
+ activeWindow: value.activeWindow,
30
+ elementCount: value.elements.length,
31
+ screenshot: Boolean(value.screenshot),
32
+ };
33
+ }
34
+ export function auditActionOutput(value) {
35
+ return {
36
+ success: value.success,
37
+ revision: value.revision,
38
+ executionMode: value.executionMode,
39
+ focusChanged: value.focusChanged,
40
+ snapshot: value.snapshot ? auditSnapshotOutput(value.snapshot) : null,
41
+ };
42
+ }
@@ -0,0 +1,11 @@
1
+ import type { ComputerActionRequest, ComputerActionResult, ComputerBackend, ComputerPermission, ComputerSnapshot, ComputerSnapshotRequest, ComputerStatus } from "./types.js";
2
+ export declare class NativeComputerBackend implements ComputerBackend {
3
+ private readonly host;
4
+ private readonly restartWhenGranted;
5
+ status(): Promise<Omit<ComputerStatus, "settings">>;
6
+ requestPermission(permission: ComputerPermission): Promise<Omit<ComputerStatus, "settings">>;
7
+ snapshot(request: ComputerSnapshotRequest, revision: number): Promise<ComputerSnapshot>;
8
+ action(request: ComputerActionRequest, revision: number): Promise<ComputerActionResult>;
9
+ dispose(): Promise<void>;
10
+ private readStatus;
11
+ }
@@ -0,0 +1,58 @@
1
+ import { ChatRoomError } from "../../core/errors/chatroom-error.js";
2
+ import { ComputerNativeHost } from "./computer-native-host.js";
3
+ import { parseNativeResult } from "./computer-protocol.js";
4
+ export class NativeComputerBackend {
5
+ host = new ComputerNativeHost();
6
+ restartWhenGranted = new Set();
7
+ async status() {
8
+ const value = await this.readStatus().catch(() => ({
9
+ platform: this.host.platform,
10
+ helper: "unavailable",
11
+ permissions: {
12
+ accessibility: "unknown",
13
+ screenRecording: "unknown",
14
+ },
15
+ displays: [],
16
+ }));
17
+ if (this.host.platform !== "macos" || value.helper !== "running")
18
+ return value;
19
+ const newlyGranted = [...this.restartWhenGranted].filter((permission) => value.permissions[permission] === "granted");
20
+ if (!newlyGranted.length || !this.host.idle)
21
+ return value;
22
+ for (const permission of newlyGranted)
23
+ this.restartWhenGranted.delete(permission);
24
+ this.host.restart("Computer helper restarting after permission change");
25
+ return this.readStatus();
26
+ }
27
+ async requestPermission(permission) {
28
+ if (this.host.platform !== "macos")
29
+ throw new ChatRoomError("UNSUPPORTED", "Permission requests are currently supported only on macOS");
30
+ const result = await this.host.request("requestPermission", { permission });
31
+ const value = parseNativeResult("requestPermission", result);
32
+ if (value.permissions[permission] !== "granted") {
33
+ this.restartWhenGranted.add(permission);
34
+ return value;
35
+ }
36
+ this.restartWhenGranted.delete(permission);
37
+ this.host.restart("Computer helper restarting after permission change");
38
+ return this.readStatus();
39
+ }
40
+ async snapshot(request, revision) {
41
+ const result = await this.host.request("snapshot", {
42
+ ...request,
43
+ revision,
44
+ });
45
+ return parseNativeResult("snapshot", result);
46
+ }
47
+ async action(request, revision) {
48
+ const result = await this.host.request("action", { ...request, revision });
49
+ return parseNativeResult("action", result);
50
+ }
51
+ async dispose() {
52
+ this.restartWhenGranted.clear();
53
+ await this.host.dispose();
54
+ }
55
+ async readStatus() {
56
+ return parseNativeResult("status", await this.host.request("status", {}));
57
+ }
58
+ }
@@ -0,0 +1,27 @@
1
+ import { type ComputerNativeMethod } from "./computer-protocol.js";
2
+ import type { ComputerPlatform } from "./types.js";
3
+ export declare class ComputerNativeHost {
4
+ private child;
5
+ private socket;
6
+ private socketServer;
7
+ private socketPath;
8
+ private lines;
9
+ private starting;
10
+ private readonly pending;
11
+ private sequence;
12
+ get platform(): ComputerPlatform;
13
+ get idle(): boolean;
14
+ request(method: ComputerNativeMethod, params: unknown): Promise<unknown>;
15
+ restart(reason?: string): void;
16
+ dispose(): Promise<void>;
17
+ private ensureStarted;
18
+ private startHelper;
19
+ private startMacHelper;
20
+ private attachSocket;
21
+ private startPipeHelper;
22
+ private failTransport;
23
+ private reset;
24
+ private rejectPending;
25
+ private cleanupSocketPath;
26
+ private handleLine;
27
+ }