@zhanguym/chatroom 1.0.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.
- package/LICENSE +202 -0
- package/README.md +52 -0
- package/assets/chatroom.svg +15 -0
- package/chatroom.config.example.json +24 -0
- package/dist/app/application.d.ts +20 -0
- package/dist/app/application.js +75 -0
- package/dist/app/event-bus.d.ts +25 -0
- package/dist/app/event-bus.js +11 -0
- package/dist/app/external-access-registry.d.ts +17 -0
- package/dist/app/external-access-registry.js +41 -0
- package/dist/app/lifecycle.d.ts +14 -0
- package/dist/app/lifecycle.js +130 -0
- package/dist/auth/auth-service.d.ts +88 -0
- package/dist/auth/auth-service.js +221 -0
- package/dist/auth/ingress-policy.d.ts +23 -0
- package/dist/auth/ingress-policy.js +61 -0
- package/dist/auth/passkey-service.d.ts +39 -0
- package/dist/auth/passkey-service.js +145 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +10 -0
- package/dist/cli/run-cli.d.ts +1 -0
- package/dist/cli/run-cli.js +41 -0
- package/dist/config/load-config.d.ts +7 -0
- package/dist/config/load-config.js +197 -0
- package/dist/config/platform-paths.d.ts +7 -0
- package/dist/config/platform-paths.js +34 -0
- package/dist/config/types.d.ts +24 -0
- package/dist/config/types.js +1 -0
- package/dist/core/auth/passkey-repository.d.ts +18 -0
- package/dist/core/auth/passkey-repository.js +1 -0
- package/dist/core/auth/repository.d.ts +36 -0
- package/dist/core/auth/repository.js +1 -0
- package/dist/core/auth/session-repository.d.ts +6 -0
- package/dist/core/auth/session-repository.js +1 -0
- package/dist/core/errors/chatroom-error.d.ts +9 -0
- package/dist/core/errors/chatroom-error.js +31 -0
- package/dist/core/logging/types.d.ts +31 -0
- package/dist/core/logging/types.js +1 -0
- package/dist/core/operations/bounded-value.d.ts +6 -0
- package/dist/core/operations/bounded-value.js +57 -0
- package/dist/core/operations/redactor.d.ts +4 -0
- package/dist/core/operations/redactor.js +69 -0
- package/dist/core/operations/repository.d.ts +18 -0
- package/dist/core/operations/repository.js +1 -0
- package/dist/core/operations/types.d.ts +28 -0
- package/dist/core/operations/types.js +8 -0
- package/dist/core/runtime/child-environment.d.ts +1 -0
- package/dist/core/runtime/child-environment.js +39 -0
- package/dist/core/runtime/command-runner.d.ts +16 -0
- package/dist/core/runtime/command-runner.js +48 -0
- package/dist/core/runtime/identity.d.ts +2 -0
- package/dist/core/runtime/identity.js +9 -0
- package/dist/infrastructure/database/app-database.d.ts +6 -0
- package/dist/infrastructure/database/app-database.js +22 -0
- package/dist/infrastructure/database/mcp-tool-settings-repository.d.ts +8 -0
- package/dist/infrastructure/database/mcp-tool-settings-repository.js +22 -0
- package/dist/infrastructure/database/oauth-repository.d.ts +20 -0
- package/dist/infrastructure/database/oauth-repository.js +140 -0
- package/dist/infrastructure/database/operation-repository.d.ts +16 -0
- package/dist/infrastructure/database/operation-repository.js +120 -0
- package/dist/infrastructure/database/passkey-repository.d.ts +11 -0
- package/dist/infrastructure/database/passkey-repository.js +57 -0
- package/dist/infrastructure/database/schema.d.ts +1 -0
- package/dist/infrastructure/database/schema.js +90 -0
- package/dist/infrastructure/database/web-session-repository.d.ts +10 -0
- package/dist/infrastructure/database/web-session-repository.js +26 -0
- package/dist/infrastructure/http/http-server.d.ts +28 -0
- package/dist/infrastructure/http/http-server.js +146 -0
- package/dist/infrastructure/http/ingress-middleware.d.ts +6 -0
- package/dist/infrastructure/http/ingress-middleware.js +58 -0
- package/dist/infrastructure/logging/file-log-store.d.ts +9 -0
- package/dist/infrastructure/logging/file-log-store.js +173 -0
- package/dist/infrastructure/logging/system-log.d.ts +22 -0
- package/dist/infrastructure/logging/system-log.js +117 -0
- package/dist/mcp/server/create-mcp-server.d.ts +3 -0
- package/dist/mcp/server/create-mcp-server.js +16 -0
- package/dist/mcp/server/plugin-mcp-registrar.d.ts +31 -0
- package/dist/mcp/server/plugin-mcp-registrar.js +70 -0
- package/dist/mcp/server/request-context.d.ts +3 -0
- package/dist/mcp/server/request-context.js +8 -0
- package/dist/mcp/server/tool-control.d.ts +31 -0
- package/dist/mcp/server/tool-control.js +76 -0
- package/dist/mcp/server/tool-support.d.ts +44 -0
- package/dist/mcp/server/tool-support.js +72 -0
- package/dist/native/linux/chatroom-computer-helper +0 -0
- package/dist/native/macos/ChatRoomComputerHelper.app/Contents/Info.plist +14 -0
- package/dist/native/macos/ChatRoomComputerHelper.app/Contents/MacOS/chatroom-computer-helper +0 -0
- package/dist/native/macos/ChatRoomComputerHelper.app/Contents/_CodeSignature/CodeResources +115 -0
- package/dist/native/windows/chatroom-computer-helper.exe +0 -0
- package/dist/operations/operation-log.d.ts +24 -0
- package/dist/operations/operation-log.js +98 -0
- package/dist/plugins/cloud/api-client.d.ts +50 -0
- package/dist/plugins/cloud/api-client.js +112 -0
- package/dist/plugins/cloud/controller.d.ts +58 -0
- package/dist/plugins/cloud/controller.js +425 -0
- package/dist/plugins/cloud/device-proof.d.ts +9 -0
- package/dist/plugins/cloud/device-proof.js +17 -0
- package/dist/plugins/cloud/plugin.d.ts +4 -0
- package/dist/plugins/cloud/plugin.js +17 -0
- package/dist/plugins/cloud/state-store.d.ts +7 -0
- package/dist/plugins/cloud/state-store.js +79 -0
- package/dist/plugins/cloud/tunnel-client.d.ts +84 -0
- package/dist/plugins/cloud/tunnel-client.js +427 -0
- package/dist/plugins/cloud/types.d.ts +72 -0
- package/dist/plugins/cloud/types.js +60 -0
- package/dist/plugins/computer/audit.d.ts +34 -0
- package/dist/plugins/computer/audit.js +42 -0
- package/dist/plugins/computer/computer-native-backend.d.ts +11 -0
- package/dist/plugins/computer/computer-native-backend.js +58 -0
- package/dist/plugins/computer/computer-native-host.d.ts +30 -0
- package/dist/plugins/computer/computer-native-host.js +411 -0
- package/dist/plugins/computer/computer-protocol.d.ts +22 -0
- package/dist/plugins/computer/computer-protocol.js +74 -0
- package/dist/plugins/computer/computer-schemas.d.ts +285 -0
- package/dist/plugins/computer/computer-schemas.js +152 -0
- package/dist/plugins/computer/computer-service.d.ts +29 -0
- package/dist/plugins/computer/computer-service.js +117 -0
- package/dist/plugins/computer/computer-settings-repository.d.ts +8 -0
- package/dist/plugins/computer/computer-settings-repository.js +41 -0
- package/dist/plugins/computer/mcp.d.ts +3 -0
- package/dist/plugins/computer/mcp.js +126 -0
- package/dist/plugins/computer/plugin.d.ts +4 -0
- package/dist/plugins/computer/plugin.js +29 -0
- package/dist/plugins/computer/types.d.ts +174 -0
- package/dist/plugins/computer/types.js +1 -0
- package/dist/plugins/git/git-service.d.ts +30 -0
- package/dist/plugins/git/git-service.js +428 -0
- package/dist/plugins/git/plugin.d.ts +4 -0
- package/dist/plugins/git/plugin.js +12 -0
- package/dist/plugins/git/types.d.ts +32 -0
- package/dist/plugins/git/types.js +1 -0
- package/dist/plugins/plugin-manager.d.ts +11 -0
- package/dist/plugins/plugin-manager.js +63 -0
- package/dist/plugins/process/backend.d.ts +18 -0
- package/dist/plugins/process/backend.js +1 -0
- package/dist/plugins/process/head-tail-buffer.d.ts +17 -0
- package/dist/plugins/process/head-tail-buffer.js +49 -0
- package/dist/plugins/process/infrastructure/pipe-process-backend.d.ts +8 -0
- package/dist/plugins/process/infrastructure/pipe-process-backend.js +71 -0
- package/dist/plugins/process/infrastructure/pty-process-backend.d.ts +8 -0
- package/dist/plugins/process/infrastructure/pty-process-backend.js +51 -0
- package/dist/plugins/process/mcp.d.ts +3 -0
- package/dist/plugins/process/mcp.js +58 -0
- package/dist/plugins/process/plugin.d.ts +4 -0
- package/dist/plugins/process/plugin.js +25 -0
- package/dist/plugins/process/process-supervisor.d.ts +39 -0
- package/dist/plugins/process/process-supervisor.js +244 -0
- package/dist/plugins/process/types.d.ts +30 -0
- package/dist/plugins/process/types.js +1 -0
- package/dist/plugins/types.d.ts +35 -0
- package/dist/plugins/types.js +17 -0
- package/dist/plugins/web/api-types.d.ts +56 -0
- package/dist/plugins/web/api-types.js +1 -0
- package/dist/plugins/web/http/api-router.d.ts +13 -0
- package/dist/plugins/web/http/api-router.js +47 -0
- package/dist/plugins/web/http/auth-api-router.d.ts +8 -0
- package/dist/plugins/web/http/auth-api-router.js +123 -0
- package/dist/plugins/web/http/cloud-api-router.d.ts +4 -0
- package/dist/plugins/web/http/cloud-api-router.js +29 -0
- package/dist/plugins/web/http/computer-api-router.d.ts +5 -0
- package/dist/plugins/web/http/computer-api-router.js +69 -0
- package/dist/plugins/web/http/git-api-router.d.ts +3 -0
- package/dist/plugins/web/http/git-api-router.js +85 -0
- package/dist/plugins/web/http/logs-api-router.d.ts +3 -0
- package/dist/plugins/web/http/logs-api-router.js +49 -0
- package/dist/plugins/web/http/process-api-router.d.ts +3 -0
- package/dist/plugins/web/http/process-api-router.js +16 -0
- package/dist/plugins/web/http/runtime-api-router.d.ts +10 -0
- package/dist/plugins/web/http/runtime-api-router.js +34 -0
- package/dist/plugins/web/http/workspace-api-router.d.ts +3 -0
- package/dist/plugins/web/http/workspace-api-router.js +91 -0
- package/dist/plugins/web/plugin.d.ts +8 -0
- package/dist/plugins/web/plugin.js +17 -0
- package/dist/plugins/web/runtime.d.ts +18 -0
- package/dist/plugins/web/runtime.js +31 -0
- package/dist/plugins/workspace/mcp.d.ts +3 -0
- package/dist/plugins/workspace/mcp.js +24 -0
- package/dist/plugins/workspace/metadata.d.ts +6 -0
- package/dist/plugins/workspace/metadata.js +111 -0
- package/dist/plugins/workspace/plugin.d.ts +4 -0
- package/dist/plugins/workspace/plugin.js +22 -0
- package/dist/plugins/workspace/types.d.ts +23 -0
- package/dist/plugins/workspace/types.js +1 -0
- package/dist/plugins/workspace/workspace-fs.d.ts +28 -0
- package/dist/plugins/workspace/workspace-fs.js +200 -0
- package/dist/plugins/workspace/workspace-service.d.ts +15 -0
- package/dist/plugins/workspace/workspace-service.js +140 -0
- package/dist/presentation/http/http-utils.d.ts +9 -0
- package/dist/presentation/http/http-utils.js +89 -0
- package/dist/presentation/http/oauth-router.d.ts +5 -0
- package/dist/presentation/http/oauth-router.js +172 -0
- package/dist/web/assets/CloudView-CHjVbp-5.css +1 -0
- package/dist/web/assets/CloudView-CvX0dkgu.js +1 -0
- package/dist/web/assets/CodeViewer-CH1DEJge.css +1 -0
- package/dist/web/assets/CodeViewer.vue_vue_type_script_setup_true_lang-B5TxGkUW.js +3 -0
- package/dist/web/assets/ComputerView-91Z9Cefw.css +1 -0
- package/dist/web/assets/ComputerView-OOyEqWml.js +1 -0
- package/dist/web/assets/McpToolsView-BTnolyS6.css +1 -0
- package/dist/web/assets/McpToolsView-DjXWTKrZ.js +1 -0
- package/dist/web/assets/OperationsView-DqTY51Cr.js +4 -0
- package/dist/web/assets/ProcessesView-C13BykIa.js +4 -0
- package/dist/web/assets/StateChip.vue_vue_type_script_setup_true_lang-DyOhJmR6.js +1 -0
- package/dist/web/assets/SystemLogsView-Ci0u4BTb.js +1 -0
- package/dist/web/assets/VSelect-CAxEESw-.css +1 -0
- package/dist/web/assets/VSelect-DrRpKyYI.js +1 -0
- package/dist/web/assets/VSpacer-C3wAY3F0.js +1 -0
- package/dist/web/assets/VSpacer-DfbUir7X.css +1 -0
- package/dist/web/assets/VSwitch-Cos8PNSP.css +1 -0
- package/dist/web/assets/VSwitch-CxusR4iO.js +1 -0
- package/dist/web/assets/VTabs-DSWgbwhc.css +1 -0
- package/dist/web/assets/VTabs-qBcuuXh3.js +1 -0
- package/dist/web/assets/WorkspacesView-BzQ0aH74.css +1 -0
- package/dist/web/assets/WorkspacesView-CijIvfsp.js +2 -0
- package/dist/web/assets/_plugin-vue_export-helper-DlAUqK2U.js +1 -0
- package/dist/web/assets/chatroom-B5p-5n3y.svg +15 -0
- package/dist/web/assets/index-BDkarAkX.js +2 -0
- package/dist/web/assets/index-BegKQ3Yd.js +19 -0
- package/dist/web/assets/index-CkjqXRSj.css +1 -0
- package/dist/web/assets/syntax-highlight-B5ArnyrC.js +3 -0
- package/dist/web/assets/useOperationLabels-BDjzGDkT.js +1 -0
- package/dist/web/assets/utils-rtPwWNel.js +1 -0
- package/dist/web/index.html +19 -0
- package/package.json +125 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class ComputerSettingsRepository {
|
|
2
|
+
database;
|
|
3
|
+
constructor(database) {
|
|
4
|
+
this.database = database;
|
|
5
|
+
}
|
|
6
|
+
get() {
|
|
7
|
+
const row = this.database.raw
|
|
8
|
+
.prepare("SELECT enabled, remote_access, updated_at FROM computer_settings WHERE id = 1")
|
|
9
|
+
.get();
|
|
10
|
+
if (row)
|
|
11
|
+
return fromRow(row);
|
|
12
|
+
const value = {
|
|
13
|
+
enabled: false,
|
|
14
|
+
remoteAccess: true,
|
|
15
|
+
updatedAt: new Date().toISOString(),
|
|
16
|
+
};
|
|
17
|
+
this.set(value);
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
set(value) {
|
|
21
|
+
const updatedAt = new Date().toISOString();
|
|
22
|
+
this.database.raw
|
|
23
|
+
.prepare(`
|
|
24
|
+
INSERT INTO computer_settings(id, enabled, remote_access, updated_at)
|
|
25
|
+
VALUES(1, ?, ?, ?)
|
|
26
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
27
|
+
enabled = excluded.enabled,
|
|
28
|
+
remote_access = excluded.remote_access,
|
|
29
|
+
updated_at = excluded.updated_at
|
|
30
|
+
`)
|
|
31
|
+
.run(value.enabled ? 1 : 0, value.remoteAccess ? 1 : 0, updatedAt);
|
|
32
|
+
return { ...value, updatedAt };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function fromRow(row) {
|
|
36
|
+
return {
|
|
37
|
+
enabled: Boolean(row.enabled),
|
|
38
|
+
remoteAccess: Boolean(row.remote_access),
|
|
39
|
+
updatedAt: String(row.updated_at),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { closedRead, openWorldMutation } from "#mcp/server/tool-support";
|
|
3
|
+
import { currentMcpAccessScope } from "#mcp/server/request-context";
|
|
4
|
+
import { auditActionOutput, auditComputerActions, auditSnapshotOutput, } from "./audit.js";
|
|
5
|
+
import { computerActionMetadataSchema, computerActionSchema, computerSnapshotMetadataSchema, computerSnapshotTargetSchema, } from "./computer-schemas.js";
|
|
6
|
+
export function registerComputerTools(mcp, service) {
|
|
7
|
+
mcp.registerTool("computer_snapshot", {
|
|
8
|
+
title: "Observe computer",
|
|
9
|
+
description: "Observe the current desktop using a screenshot and compact accessibility elements. Element IDs are valid only for the returned snapshotId.",
|
|
10
|
+
inputSchema: z.object({
|
|
11
|
+
target: computerSnapshotTargetSchema.optional(),
|
|
12
|
+
includeScreenshot: z.boolean().default(true),
|
|
13
|
+
includeElements: z.boolean().default(true),
|
|
14
|
+
}),
|
|
15
|
+
outputSchema: computerSnapshotMetadataSchema,
|
|
16
|
+
annotations: closedRead,
|
|
17
|
+
action: "snapshot",
|
|
18
|
+
audit: {
|
|
19
|
+
output: (value) => auditSnapshotOutput(value),
|
|
20
|
+
},
|
|
21
|
+
present: presentSnapshot,
|
|
22
|
+
}, (input) => service.snapshot(currentMcpAccessScope(), {
|
|
23
|
+
includeScreenshot: input.includeScreenshot,
|
|
24
|
+
includeElements: input.includeElements,
|
|
25
|
+
...(input.target === undefined
|
|
26
|
+
? {}
|
|
27
|
+
: { target: normalizeSnapshotTarget(input.target) }),
|
|
28
|
+
}));
|
|
29
|
+
mcp.registerTool("computer_action", {
|
|
30
|
+
title: "Control computer",
|
|
31
|
+
description: "Execute a bounded batch of semantic or coordinate desktop actions. Prefer elementId from the latest snapshot; elementId actions require that snapshotId.",
|
|
32
|
+
inputSchema: z.object({
|
|
33
|
+
snapshotId: z.string().optional(),
|
|
34
|
+
actions: z.array(computerActionSchema).min(1).max(50),
|
|
35
|
+
observeAfter: z.boolean().default(true),
|
|
36
|
+
}),
|
|
37
|
+
outputSchema: computerActionMetadataSchema,
|
|
38
|
+
annotations: openWorldMutation,
|
|
39
|
+
action: "action",
|
|
40
|
+
audit: {
|
|
41
|
+
input: (value) => auditComputerActions(value),
|
|
42
|
+
output: (value) => auditActionOutput(value),
|
|
43
|
+
},
|
|
44
|
+
present: presentAction,
|
|
45
|
+
}, (input) => service.action(currentMcpAccessScope(), {
|
|
46
|
+
actions: input.actions,
|
|
47
|
+
observeAfter: input.observeAfter,
|
|
48
|
+
...(input.snapshotId === undefined
|
|
49
|
+
? {}
|
|
50
|
+
: { snapshotId: input.snapshotId }),
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
function presentSnapshot(value) {
|
|
54
|
+
const snapshot = value;
|
|
55
|
+
const { screenshot, ...metadata } = snapshot;
|
|
56
|
+
return {
|
|
57
|
+
content: [
|
|
58
|
+
{ type: "text", text: JSON.stringify(metadata, null, 2) },
|
|
59
|
+
...(screenshot
|
|
60
|
+
? [
|
|
61
|
+
{
|
|
62
|
+
type: "image",
|
|
63
|
+
data: screenshot.data,
|
|
64
|
+
mimeType: screenshot.mimeType,
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
: []),
|
|
68
|
+
],
|
|
69
|
+
structuredContent: metadata,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function presentAction(value) {
|
|
73
|
+
const result = value;
|
|
74
|
+
const screenshot = result.snapshot?.screenshot;
|
|
75
|
+
const snapshot = result.snapshot
|
|
76
|
+
? (({ screenshot: _screenshot, ...metadata }) => metadata)(result.snapshot)
|
|
77
|
+
: undefined;
|
|
78
|
+
const safe = {
|
|
79
|
+
success: result.success,
|
|
80
|
+
revision: result.revision,
|
|
81
|
+
executionMode: result.executionMode,
|
|
82
|
+
focusChanged: result.focusChanged,
|
|
83
|
+
...(snapshot === undefined ? {} : { snapshot }),
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
content: [
|
|
87
|
+
{ type: "text", text: JSON.stringify(safe, null, 2) },
|
|
88
|
+
...(screenshot
|
|
89
|
+
? [
|
|
90
|
+
{
|
|
91
|
+
type: "image",
|
|
92
|
+
data: screenshot.data,
|
|
93
|
+
mimeType: screenshot.mimeType,
|
|
94
|
+
},
|
|
95
|
+
]
|
|
96
|
+
: []),
|
|
97
|
+
],
|
|
98
|
+
structuredContent: safe,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function normalizeSnapshotTarget(input) {
|
|
102
|
+
switch (input.type) {
|
|
103
|
+
case "desktop":
|
|
104
|
+
return { type: "desktop" };
|
|
105
|
+
case "display":
|
|
106
|
+
return input.displayId === undefined
|
|
107
|
+
? { type: "display" }
|
|
108
|
+
: { type: "display", displayId: input.displayId };
|
|
109
|
+
case "app":
|
|
110
|
+
return { type: "app", app: input.app };
|
|
111
|
+
case "window":
|
|
112
|
+
return { type: "window", elementId: input.elementId };
|
|
113
|
+
case "region": {
|
|
114
|
+
const region = {
|
|
115
|
+
type: "region",
|
|
116
|
+
x: input.x,
|
|
117
|
+
y: input.y,
|
|
118
|
+
width: input.width,
|
|
119
|
+
height: input.height,
|
|
120
|
+
};
|
|
121
|
+
return input.displayId === undefined
|
|
122
|
+
? region
|
|
123
|
+
: { ...region, displayId: input.displayId };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InternalPlugin } from "#plugins/types";
|
|
2
|
+
import { ComputerService } from "./computer-service.js";
|
|
3
|
+
export declare const ComputerServiceToken: import("#plugins/types").ServiceToken<ComputerService>;
|
|
4
|
+
export declare function createComputerPlugin(): InternalPlugin;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createServiceToken } from "#plugins/types";
|
|
2
|
+
import { NativeComputerBackend } from "./computer-native-backend.js";
|
|
3
|
+
import { ComputerService } from "./computer-service.js";
|
|
4
|
+
import { ComputerSettingsRepository } from "./computer-settings-repository.js";
|
|
5
|
+
import { registerComputerTools } from "./mcp.js";
|
|
6
|
+
import { currentMcpAccessScope } from "#mcp/server/request-context";
|
|
7
|
+
export const ComputerServiceToken = createServiceToken("computer");
|
|
8
|
+
export function createComputerPlugin() {
|
|
9
|
+
let service = null;
|
|
10
|
+
return {
|
|
11
|
+
id: "computer",
|
|
12
|
+
activate(context) {
|
|
13
|
+
service = new ComputerService(new NativeComputerBackend(), new ComputerSettingsRepository(context.database), context.events);
|
|
14
|
+
context.services.provide(ComputerServiceToken, service);
|
|
15
|
+
},
|
|
16
|
+
registerMcp(mcp) {
|
|
17
|
+
if (!service)
|
|
18
|
+
throw new Error("Computer plugin is not active");
|
|
19
|
+
if (currentMcpAccessScope() === "remote" &&
|
|
20
|
+
!service.settings().remoteAccess)
|
|
21
|
+
return;
|
|
22
|
+
registerComputerTools(mcp, service);
|
|
23
|
+
},
|
|
24
|
+
async deactivate() {
|
|
25
|
+
await service?.shutdown();
|
|
26
|
+
service = null;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export type ComputerAccessScope = "local" | "remote";
|
|
2
|
+
export type ComputerPlatform = "macos" | "windows" | "linux" | "unsupported";
|
|
3
|
+
export type ComputerHelperState = "running" | "stopped" | "unavailable";
|
|
4
|
+
export type ComputerPermissionState = "granted" | "denied" | "unknown" | "not-required";
|
|
5
|
+
export type ComputerPermission = "accessibility" | "screenRecording";
|
|
6
|
+
export interface ComputerSettings {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
remoteAccess: boolean;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ComputerPermissions {
|
|
12
|
+
accessibility: ComputerPermissionState;
|
|
13
|
+
screenRecording: ComputerPermissionState;
|
|
14
|
+
}
|
|
15
|
+
export interface ComputerDisplay {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
scale: number;
|
|
21
|
+
primary: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ComputerStatus {
|
|
24
|
+
platform: ComputerPlatform;
|
|
25
|
+
helper: ComputerHelperState;
|
|
26
|
+
permissions: ComputerPermissions;
|
|
27
|
+
displays: ComputerDisplay[];
|
|
28
|
+
settings: ComputerSettings;
|
|
29
|
+
}
|
|
30
|
+
export interface ComputerElement {
|
|
31
|
+
id: number;
|
|
32
|
+
role: string;
|
|
33
|
+
name: string | null;
|
|
34
|
+
value: string | null;
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
focused: boolean;
|
|
37
|
+
selected: boolean;
|
|
38
|
+
sensitive: boolean;
|
|
39
|
+
bounds: [number, number, number, number] | null;
|
|
40
|
+
actions: string[];
|
|
41
|
+
}
|
|
42
|
+
export type ComputerSnapshotTarget = {
|
|
43
|
+
type: "desktop";
|
|
44
|
+
} | {
|
|
45
|
+
type: "display";
|
|
46
|
+
displayId?: string;
|
|
47
|
+
} | {
|
|
48
|
+
type: "app";
|
|
49
|
+
app: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: "window";
|
|
52
|
+
elementId: number;
|
|
53
|
+
} | {
|
|
54
|
+
type: "region";
|
|
55
|
+
displayId?: string;
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
};
|
|
61
|
+
export interface ComputerSnapshotRequest {
|
|
62
|
+
target?: ComputerSnapshotTarget;
|
|
63
|
+
includeScreenshot: boolean;
|
|
64
|
+
includeElements: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface ComputerSnapshot {
|
|
67
|
+
snapshotId: string;
|
|
68
|
+
revision: number;
|
|
69
|
+
display: ComputerDisplay | null;
|
|
70
|
+
activeApp: string | null;
|
|
71
|
+
activeWindow: string | null;
|
|
72
|
+
cursor: {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
} | null;
|
|
76
|
+
elements: ComputerElement[];
|
|
77
|
+
screenshot?: {
|
|
78
|
+
mimeType: "image/jpeg" | "image/png";
|
|
79
|
+
data: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export type ComputerAction = {
|
|
83
|
+
type: "move";
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
} | {
|
|
87
|
+
type: "click";
|
|
88
|
+
x?: number;
|
|
89
|
+
y?: number;
|
|
90
|
+
elementId?: number;
|
|
91
|
+
} | {
|
|
92
|
+
type: "double_click";
|
|
93
|
+
x?: number;
|
|
94
|
+
y?: number;
|
|
95
|
+
elementId?: number;
|
|
96
|
+
} | {
|
|
97
|
+
type: "right_click";
|
|
98
|
+
x?: number;
|
|
99
|
+
y?: number;
|
|
100
|
+
elementId?: number;
|
|
101
|
+
} | {
|
|
102
|
+
type: "drag";
|
|
103
|
+
from: {
|
|
104
|
+
x: number;
|
|
105
|
+
y: number;
|
|
106
|
+
};
|
|
107
|
+
to: {
|
|
108
|
+
x: number;
|
|
109
|
+
y: number;
|
|
110
|
+
};
|
|
111
|
+
durationMs?: number;
|
|
112
|
+
} | {
|
|
113
|
+
type: "scroll";
|
|
114
|
+
deltaX?: number;
|
|
115
|
+
deltaY: number;
|
|
116
|
+
elementId?: number;
|
|
117
|
+
} | {
|
|
118
|
+
type: "keypress";
|
|
119
|
+
keys: string[];
|
|
120
|
+
} | {
|
|
121
|
+
type: "type_text";
|
|
122
|
+
text: string;
|
|
123
|
+
elementId?: number;
|
|
124
|
+
} | {
|
|
125
|
+
type: "invoke";
|
|
126
|
+
elementId: number;
|
|
127
|
+
} | {
|
|
128
|
+
type: "set_value";
|
|
129
|
+
elementId: number;
|
|
130
|
+
value: string;
|
|
131
|
+
} | {
|
|
132
|
+
type: "select_text";
|
|
133
|
+
elementId: number;
|
|
134
|
+
start: number;
|
|
135
|
+
length: number;
|
|
136
|
+
} | {
|
|
137
|
+
type: "activate_app";
|
|
138
|
+
app: string;
|
|
139
|
+
} | {
|
|
140
|
+
type: "activate_window";
|
|
141
|
+
elementId: number;
|
|
142
|
+
} | {
|
|
143
|
+
type: "move_window";
|
|
144
|
+
elementId: number;
|
|
145
|
+
x: number;
|
|
146
|
+
y: number;
|
|
147
|
+
} | {
|
|
148
|
+
type: "resize_window";
|
|
149
|
+
elementId: number;
|
|
150
|
+
width: number;
|
|
151
|
+
height: number;
|
|
152
|
+
} | {
|
|
153
|
+
type: "wait";
|
|
154
|
+
ms: number;
|
|
155
|
+
};
|
|
156
|
+
export interface ComputerActionRequest {
|
|
157
|
+
snapshotId?: string;
|
|
158
|
+
actions: ComputerAction[];
|
|
159
|
+
observeAfter: boolean;
|
|
160
|
+
}
|
|
161
|
+
export interface ComputerActionResult {
|
|
162
|
+
success: true;
|
|
163
|
+
revision: number;
|
|
164
|
+
snapshot?: ComputerSnapshot;
|
|
165
|
+
executionMode: "semantic" | "background" | "foreground" | "mixed";
|
|
166
|
+
focusChanged: boolean;
|
|
167
|
+
}
|
|
168
|
+
export interface ComputerBackend {
|
|
169
|
+
status(): Promise<Omit<ComputerStatus, "settings">>;
|
|
170
|
+
requestPermission(permission: ComputerPermission): Promise<Omit<ComputerStatus, "settings">>;
|
|
171
|
+
snapshot(request: ComputerSnapshotRequest, revision: number): Promise<ComputerSnapshot>;
|
|
172
|
+
action(request: ComputerActionRequest, revision: number): Promise<ComputerActionResult>;
|
|
173
|
+
dispose(): Promise<void>;
|
|
174
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CommandRunner } from "#core/runtime/command-runner";
|
|
2
|
+
import type { GitBranch, GitCommit, GitDiff, GitStatus } from "./types.js";
|
|
3
|
+
export declare class GitService {
|
|
4
|
+
private readonly commands;
|
|
5
|
+
constructor(commands: CommandRunner);
|
|
6
|
+
status(cwd: string): Promise<GitStatus | null>;
|
|
7
|
+
diff(cwd: string, filePath?: string, maxPreviewBytes?: number): Promise<GitDiff>;
|
|
8
|
+
stage(cwd: string, paths: string[]): Promise<GitStatus>;
|
|
9
|
+
unstage(cwd: string, paths: string[]): Promise<GitStatus>;
|
|
10
|
+
restore(cwd: string, filePath: string): Promise<GitStatus>;
|
|
11
|
+
commit(cwd: string, message: string): Promise<GitStatus>;
|
|
12
|
+
branches(cwd: string): Promise<GitBranch[]>;
|
|
13
|
+
createBranch(cwd: string, name: string): Promise<GitStatus>;
|
|
14
|
+
switchBranch(cwd: string, name: string): Promise<GitStatus>;
|
|
15
|
+
deleteBranch(cwd: string, name: string): Promise<GitStatus>;
|
|
16
|
+
log(cwd: string, limit?: number): Promise<GitCommit[]>;
|
|
17
|
+
fetch(cwd: string): Promise<GitStatus>;
|
|
18
|
+
pull(cwd: string): Promise<GitStatus>;
|
|
19
|
+
push(cwd: string): Promise<GitStatus>;
|
|
20
|
+
private run;
|
|
21
|
+
private repositoryRoot;
|
|
22
|
+
private requireRepository;
|
|
23
|
+
private requireStatus;
|
|
24
|
+
private head;
|
|
25
|
+
private requireHead;
|
|
26
|
+
private relatedPaths;
|
|
27
|
+
private pathExistsInHead;
|
|
28
|
+
private validateBranchName;
|
|
29
|
+
private withSnapshotIndex;
|
|
30
|
+
}
|