@n8n/fs-proxy 0.1.0-rc1

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 (106) hide show
  1. package/LICENSE.md +88 -0
  2. package/README.md +267 -0
  3. package/dist/build.tsbuildinfo +1 -0
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.js +189 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/config-templates.d.ts +10 -0
  8. package/dist/config-templates.js +39 -0
  9. package/dist/config-templates.js.map +1 -0
  10. package/dist/config.d.ts +67 -0
  11. package/dist/config.js +285 -0
  12. package/dist/config.js.map +1 -0
  13. package/dist/confirm-resource-cli.d.ts +4 -0
  14. package/dist/confirm-resource-cli.js +28 -0
  15. package/dist/confirm-resource-cli.js.map +1 -0
  16. package/dist/daemon.d.ts +11 -0
  17. package/dist/daemon.js +249 -0
  18. package/dist/daemon.js.map +1 -0
  19. package/dist/gateway-client.d.ts +38 -0
  20. package/dist/gateway-client.js +401 -0
  21. package/dist/gateway-client.js.map +1 -0
  22. package/dist/logger.d.ts +26 -0
  23. package/dist/logger.js +350 -0
  24. package/dist/logger.js.map +1 -0
  25. package/dist/settings-store.d.ts +29 -0
  26. package/dist/settings-store.js +224 -0
  27. package/dist/settings-store.js.map +1 -0
  28. package/dist/startup-config-cli.d.ts +5 -0
  29. package/dist/startup-config-cli.js +185 -0
  30. package/dist/startup-config-cli.js.map +1 -0
  31. package/dist/tools/browser/index.d.ts +14 -0
  32. package/dist/tools/browser/index.js +72 -0
  33. package/dist/tools/browser/index.js.map +1 -0
  34. package/dist/tools/filesystem/constants.d.ts +1 -0
  35. package/dist/tools/filesystem/constants.js +5 -0
  36. package/dist/tools/filesystem/constants.js.map +1 -0
  37. package/dist/tools/filesystem/copy-file.d.ts +14 -0
  38. package/dist/tools/filesystem/copy-file.js +65 -0
  39. package/dist/tools/filesystem/copy-file.js.map +1 -0
  40. package/dist/tools/filesystem/create-directory.d.ts +11 -0
  41. package/dist/tools/filesystem/create-directory.js +60 -0
  42. package/dist/tools/filesystem/create-directory.js.map +1 -0
  43. package/dist/tools/filesystem/delete.d.ts +11 -0
  44. package/dist/tools/filesystem/delete.js +64 -0
  45. package/dist/tools/filesystem/delete.js.map +1 -0
  46. package/dist/tools/filesystem/edit-file.d.ts +17 -0
  47. package/dist/tools/filesystem/edit-file.js +71 -0
  48. package/dist/tools/filesystem/edit-file.js.map +1 -0
  49. package/dist/tools/filesystem/fs-utils.d.ts +15 -0
  50. package/dist/tools/filesystem/fs-utils.js +178 -0
  51. package/dist/tools/filesystem/fs-utils.js.map +1 -0
  52. package/dist/tools/filesystem/get-file-tree.d.ts +14 -0
  53. package/dist/tools/filesystem/get-file-tree.js +38 -0
  54. package/dist/tools/filesystem/get-file-tree.js.map +1 -0
  55. package/dist/tools/filesystem/index.d.ts +3 -0
  56. package/dist/tools/filesystem/index.js +28 -0
  57. package/dist/tools/filesystem/index.js.map +1 -0
  58. package/dist/tools/filesystem/list-files.d.ts +17 -0
  59. package/dist/tools/filesystem/list-files.js +76 -0
  60. package/dist/tools/filesystem/list-files.js.map +1 -0
  61. package/dist/tools/filesystem/move.d.ts +14 -0
  62. package/dist/tools/filesystem/move.js +65 -0
  63. package/dist/tools/filesystem/move.js.map +1 -0
  64. package/dist/tools/filesystem/read-file.d.ts +17 -0
  65. package/dist/tools/filesystem/read-file.js +86 -0
  66. package/dist/tools/filesystem/read-file.js.map +1 -0
  67. package/dist/tools/filesystem/search-files.d.ts +23 -0
  68. package/dist/tools/filesystem/search-files.js +128 -0
  69. package/dist/tools/filesystem/search-files.js.map +1 -0
  70. package/dist/tools/filesystem/write-file.d.ts +14 -0
  71. package/dist/tools/filesystem/write-file.js +68 -0
  72. package/dist/tools/filesystem/write-file.js.map +1 -0
  73. package/dist/tools/monitor-utils.d.ts +2 -0
  74. package/dist/tools/monitor-utils.js +11 -0
  75. package/dist/tools/monitor-utils.js.map +1 -0
  76. package/dist/tools/mouse-keyboard/index.d.ts +2 -0
  77. package/dist/tools/mouse-keyboard/index.js +70 -0
  78. package/dist/tools/mouse-keyboard/index.js.map +1 -0
  79. package/dist/tools/mouse-keyboard/mouse-keyboard.d.ts +130 -0
  80. package/dist/tools/mouse-keyboard/mouse-keyboard.js +249 -0
  81. package/dist/tools/mouse-keyboard/mouse-keyboard.js.map +1 -0
  82. package/dist/tools/screenshot/index.d.ts +2 -0
  83. package/dist/tools/screenshot/index.js +26 -0
  84. package/dist/tools/screenshot/index.js.map +1 -0
  85. package/dist/tools/screenshot/screenshot.d.ts +22 -0
  86. package/dist/tools/screenshot/screenshot.js +91 -0
  87. package/dist/tools/screenshot/screenshot.js.map +1 -0
  88. package/dist/tools/shell/build-shell-resource.d.ts +1 -0
  89. package/dist/tools/shell/build-shell-resource.js +70 -0
  90. package/dist/tools/shell/build-shell-resource.js.map +1 -0
  91. package/dist/tools/shell/index.d.ts +2 -0
  92. package/dist/tools/shell/index.js +11 -0
  93. package/dist/tools/shell/index.js.map +1 -0
  94. package/dist/tools/shell/shell-execute.d.ts +17 -0
  95. package/dist/tools/shell/shell-execute.js +88 -0
  96. package/dist/tools/shell/shell-execute.js.map +1 -0
  97. package/dist/tools/test-utils.d.ts +3 -0
  98. package/dist/tools/test-utils.js +16 -0
  99. package/dist/tools/test-utils.js.map +1 -0
  100. package/dist/tools/types.d.ts +43 -0
  101. package/dist/tools/types.js +3 -0
  102. package/dist/tools/types.js.map +1 -0
  103. package/dist/tools/utils.d.ts +3 -0
  104. package/dist/tools/utils.js +19 -0
  105. package/dist/tools/utils.js.map +1 -0
  106. package/package.json +55 -0
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.searchFilesTool = void 0;
37
+ const fs = __importStar(require("node:fs/promises"));
38
+ const path = __importStar(require("node:path"));
39
+ const zod_1 = require("zod");
40
+ const utils_1 = require("../utils");
41
+ const constants_1 = require("./constants");
42
+ const fs_utils_1 = require("./fs-utils");
43
+ const inputSchema = zod_1.z.object({
44
+ dirPath: zod_1.z.string().describe('Directory to search in'),
45
+ query: zod_1.z.string().describe('Regular expression pattern to search for'),
46
+ filePattern: zod_1.z.string().optional().describe('Glob pattern to filter files (e.g. "**/*.ts")'),
47
+ ignoreCase: zod_1.z.boolean().optional().describe('Case-insensitive search (default: false)'),
48
+ maxResults: zod_1.z.number().int().optional().describe('Maximum number of results (default: 50)'),
49
+ });
50
+ exports.searchFilesTool = {
51
+ name: 'search_files',
52
+ description: 'Search for text patterns across files using a regex query',
53
+ inputSchema,
54
+ annotations: { readOnlyHint: true },
55
+ async getAffectedResources({ dirPath }, { dir }) {
56
+ return [
57
+ await (0, fs_utils_1.buildFilesystemResource)(dir, dirPath, 'filesystemRead', `Search files in: ${dirPath}`),
58
+ ];
59
+ },
60
+ async execute({ dirPath, query, filePattern, ignoreCase, maxResults }, { dir }) {
61
+ const resolvedDir = await (0, fs_utils_1.resolveSafePath)(dir, dirPath);
62
+ const limit = maxResults ?? 50;
63
+ const flags = ignoreCase ? 'gi' : 'g';
64
+ const regex = new RegExp(escapeRegex(query), flags);
65
+ const matches = [];
66
+ let totalMatches = 0;
67
+ const filePaths = await collectFiles(resolvedDir, dir, filePattern);
68
+ for (const fp of filePaths) {
69
+ if (matches.length >= limit)
70
+ break;
71
+ try {
72
+ const fullPath = path.join(dir, fp);
73
+ const stat = await fs.stat(fullPath);
74
+ if (stat.size > constants_1.MAX_FILE_SIZE)
75
+ continue;
76
+ const content = await fs.readFile(fullPath, 'utf-8');
77
+ const lines = content.split('\n');
78
+ for (let i = 0; i < lines.length; i++) {
79
+ if (regex.test(lines[i])) {
80
+ totalMatches++;
81
+ if (matches.length < limit) {
82
+ matches.push({ path: fp, lineNumber: i + 1, line: lines[i].substring(0, 200) });
83
+ }
84
+ }
85
+ regex.lastIndex = 0;
86
+ }
87
+ }
88
+ catch {
89
+ }
90
+ }
91
+ return (0, utils_1.formatCallToolResult)({ query, matches, truncated: totalMatches > limit, totalMatches });
92
+ },
93
+ };
94
+ async function collectFiles(dir, basePath, pattern, collected = [], depth = 0) {
95
+ if (depth > 10 || collected.length > 5000)
96
+ return collected;
97
+ const entries = await fs.readdir(dir, { withFileTypes: true });
98
+ for (const entry of entries) {
99
+ if (fs_utils_1.EXCLUDED_DIRS.has(entry.name) && entry.isDirectory())
100
+ continue;
101
+ const fullPath = path.join(dir, entry.name);
102
+ const relativePath = path.relative(basePath, fullPath);
103
+ if (entry.isDirectory()) {
104
+ await collectFiles(fullPath, basePath, pattern, collected, depth + 1);
105
+ }
106
+ else if (entry.isFile()) {
107
+ if (pattern) {
108
+ const regex = globToRegex(pattern);
109
+ if (!regex.test(entry.name) && !regex.test(relativePath))
110
+ continue;
111
+ }
112
+ collected.push(relativePath);
113
+ }
114
+ }
115
+ return collected;
116
+ }
117
+ function escapeRegex(str) {
118
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
119
+ }
120
+ function globToRegex(pattern) {
121
+ const escaped = pattern
122
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&')
123
+ .replace(/\*\*/g, '{{GLOBSTAR}}')
124
+ .replace(/\*/g, '[^/]*')
125
+ .replace(/\{\{GLOBSTAR\}\}/g, '.*');
126
+ return new RegExp(`^${escaped}$`);
127
+ }
128
+ //# sourceMappingURL=search-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-files.js","sourceRoot":"","sources":["../../../src/tools/filesystem/search-files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,gDAAkC;AAClC,6BAAwB;AAGxB,oCAAgD;AAChD,2CAA4C;AAC5C,yCAAqF;AAErF,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IACtD,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IACtE,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;IAC5F,UAAU,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IACvF,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;CAC3F,CAAC,CAAC;AAEU,QAAA,eAAe,GAAuC;IAClE,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,2DAA2D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14 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types';
3
+ declare const inputSchema: z.ZodObject<{
4
+ filePath: z.ZodString;
5
+ content: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ content: string;
8
+ filePath: string;
9
+ }, {
10
+ content: string;
11
+ filePath: string;
12
+ }>;
13
+ export declare const writeFileTool: ToolDefinition<typeof inputSchema>;
14
+ export {};
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.writeFileTool = void 0;
37
+ const fs = __importStar(require("node:fs/promises"));
38
+ const path = __importStar(require("node:path"));
39
+ const zod_1 = require("zod");
40
+ const utils_1 = require("../utils");
41
+ const constants_1 = require("./constants");
42
+ const fs_utils_1 = require("./fs-utils");
43
+ const inputSchema = zod_1.z.object({
44
+ filePath: zod_1.z.string().describe('File path relative to root'),
45
+ content: zod_1.z.string().describe('Text content to write'),
46
+ });
47
+ exports.writeFileTool = {
48
+ name: 'write_file',
49
+ description: 'Create a new file with the given content. Overwrites if the file already exists. Content must not exceed 512 KB.',
50
+ inputSchema,
51
+ annotations: {},
52
+ async getAffectedResources({ filePath }, { dir }) {
53
+ return [
54
+ await (0, fs_utils_1.buildFilesystemResource)(dir, filePath, 'filesystemWrite', `Write file: ${filePath}`),
55
+ ];
56
+ },
57
+ async execute({ filePath, content }, { dir }) {
58
+ const resolvedPath = await (0, fs_utils_1.resolveSafePath)(dir, filePath);
59
+ const byteSize = Buffer.byteLength(content, 'utf-8');
60
+ if (byteSize > constants_1.MAX_FILE_SIZE) {
61
+ throw new Error(`Content too large: ${byteSize} bytes (max ${constants_1.MAX_FILE_SIZE} bytes).`);
62
+ }
63
+ await fs.mkdir(path.dirname(resolvedPath), { recursive: true });
64
+ await fs.writeFile(resolvedPath, content, 'utf-8');
65
+ return (0, utils_1.formatCallToolResult)({ path: filePath });
66
+ },
67
+ };
68
+ //# sourceMappingURL=write-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-file.js","sourceRoot":"","sources":["../../../src/tools/filesystem/write-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,gDAAkC;AAClC,6BAAwB;AAGxB,oCAAgD;AAChD,2CAA4C;AAC5C,yCAAsE;AAEtE,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IAC3D,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;CACrD,CAAC,CAAC;AAEU,QAAA,aAAa,GAAuC;IAChE,IAAI,EAAE,YAAY;IAClB,WAAW,EACV,kHAAkH;IACnH,WAAW;IACX,WAAW,EAAE,EAAE;IACf,KAAK,CAAC,oBAAoB,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE;QAC/C,OAAO;YACN,MAAM,IAAA,kCAAuB,EAAC,GAAG,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,QAAQ,EAAE,CAAC;SAC1F,CAAC;IACH,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE;QAC3C,MAAM,YAAY,GAAG,MAAM,IAAA,0BAAe,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAE1D,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACrD,IAAI,QAAQ,GAAG,yBAAa,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,eAAe,yBAAa,UAAU,CAAC,CAAC;QACvF,CAAC;QAED,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,MAAM,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAEnD,OAAO,IAAA,4BAAoB,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;CACD,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Monitor } from 'node-screenshots';
2
+ export declare function getPrimaryMonitor(): Monitor;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPrimaryMonitor = getPrimaryMonitor;
4
+ const node_screenshots_1 = require("node-screenshots");
5
+ function getPrimaryMonitor() {
6
+ const monitors = node_screenshots_1.Monitor.all();
7
+ if (monitors.length === 0)
8
+ throw new Error('No monitors available');
9
+ return monitors.find((m) => m.isPrimary()) ?? monitors[0];
10
+ }
11
+ //# sourceMappingURL=monitor-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor-utils.js","sourceRoot":"","sources":["../../src/tools/monitor-utils.ts"],"names":[],"mappings":";;AAEA,8CAIC;AAND,uDAA2C;AAE3C,SAAgB,iBAAiB;IAChC,MAAM,QAAQ,GAAG,0BAAO,CAAC,GAAG,EAAE,CAAC;IAC/B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACpE,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ToolModule } from '../types';
2
+ export declare const MouseKeyboardModule: ToolModule;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.MouseKeyboardModule = void 0;
37
+ const logger_1 = require("../../logger");
38
+ const mouse_keyboard_1 = require("./mouse-keyboard");
39
+ exports.MouseKeyboardModule = {
40
+ async isSupported() {
41
+ if (process.env.WAYLAND_DISPLAY && !process.env.DISPLAY) {
42
+ logger_1.logger.info('Mouse/keyboard module not supported', {
43
+ reason: 'Wayland without X11 compatibility layer',
44
+ });
45
+ return false;
46
+ }
47
+ try {
48
+ const robot = await Promise.resolve().then(() => __importStar(require('@jitsi/robotjs')));
49
+ robot.default.getMousePos();
50
+ return true;
51
+ }
52
+ catch (error) {
53
+ logger_1.logger.info('Mouse/keyboard module not supported', {
54
+ error: error instanceof Error ? error.message : String(error),
55
+ });
56
+ return false;
57
+ }
58
+ },
59
+ definitions: [
60
+ mouse_keyboard_1.mouseMoveTool,
61
+ mouse_keyboard_1.mouseClickTool,
62
+ mouse_keyboard_1.mouseDoubleClickTool,
63
+ mouse_keyboard_1.mouseDragTool,
64
+ mouse_keyboard_1.mouseScrollTool,
65
+ mouse_keyboard_1.keyboardTypeTool,
66
+ mouse_keyboard_1.keyboardKeyTapTool,
67
+ mouse_keyboard_1.keyboardShortcutTool,
68
+ ],
69
+ };
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/mouse-keyboard/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAsC;AAEtC,qDAS0B;AAEb,QAAA,mBAAmB,GAAe;IAC9C,KAAK,CAAC,WAAW;QAEhB,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACzD,eAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE;gBAClD,MAAM,EAAE,yCAAyC;aACjD,CAAC,CAAC;YACH,OAAO,KAAK,CAAC;QACd,CAAC;QACD,IAAI,CAAC;YACJ,MAAM,KAAK,GAAG,wDAAa,gBAAgB,GAAC,CAAC;YAC7C,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACb,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,eAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE;gBAClD,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC7D,CAAC,CAAC;YACH,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,WAAW,EAAE;QACZ,8BAAa;QACb,+BAAc;QACd,qCAAoB;QACpB,8BAAa;QACb,gCAAe;QACf,iCAAgB;QAChB,mCAAkB;QAClB,qCAAoB;KACpB;CACD,CAAC"}
@@ -0,0 +1,130 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types';
3
+ declare const mouseMoveSchema: z.ZodObject<{
4
+ screenWidth: z.ZodOptional<z.ZodNumber>;
5
+ screenHeight: z.ZodOptional<z.ZodNumber>;
6
+ x: z.ZodNumber;
7
+ y: z.ZodNumber;
8
+ }, "strip", z.ZodTypeAny, {
9
+ x: number;
10
+ y: number;
11
+ screenWidth?: number | undefined;
12
+ screenHeight?: number | undefined;
13
+ }, {
14
+ x: number;
15
+ y: number;
16
+ screenWidth?: number | undefined;
17
+ screenHeight?: number | undefined;
18
+ }>;
19
+ export declare const mouseMoveTool: ToolDefinition<typeof mouseMoveSchema>;
20
+ declare const mouseClickSchema: z.ZodObject<{
21
+ screenWidth: z.ZodOptional<z.ZodNumber>;
22
+ screenHeight: z.ZodOptional<z.ZodNumber>;
23
+ x: z.ZodNumber;
24
+ y: z.ZodNumber;
25
+ button: z.ZodOptional<z.ZodEnum<["left", "right", "middle"]>>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ x: number;
28
+ y: number;
29
+ screenWidth?: number | undefined;
30
+ screenHeight?: number | undefined;
31
+ button?: "left" | "right" | "middle" | undefined;
32
+ }, {
33
+ x: number;
34
+ y: number;
35
+ screenWidth?: number | undefined;
36
+ screenHeight?: number | undefined;
37
+ button?: "left" | "right" | "middle" | undefined;
38
+ }>;
39
+ export declare const mouseClickTool: ToolDefinition<typeof mouseClickSchema>;
40
+ declare const mouseDoubleClickSchema: z.ZodObject<{
41
+ screenWidth: z.ZodOptional<z.ZodNumber>;
42
+ screenHeight: z.ZodOptional<z.ZodNumber>;
43
+ x: z.ZodNumber;
44
+ y: z.ZodNumber;
45
+ }, "strip", z.ZodTypeAny, {
46
+ x: number;
47
+ y: number;
48
+ screenWidth?: number | undefined;
49
+ screenHeight?: number | undefined;
50
+ }, {
51
+ x: number;
52
+ y: number;
53
+ screenWidth?: number | undefined;
54
+ screenHeight?: number | undefined;
55
+ }>;
56
+ export declare const mouseDoubleClickTool: ToolDefinition<typeof mouseDoubleClickSchema>;
57
+ declare const mouseDragSchema: z.ZodObject<{
58
+ screenWidth: z.ZodOptional<z.ZodNumber>;
59
+ screenHeight: z.ZodOptional<z.ZodNumber>;
60
+ fromX: z.ZodNumber;
61
+ fromY: z.ZodNumber;
62
+ toX: z.ZodNumber;
63
+ toY: z.ZodNumber;
64
+ }, "strip", z.ZodTypeAny, {
65
+ fromX: number;
66
+ fromY: number;
67
+ toX: number;
68
+ toY: number;
69
+ screenWidth?: number | undefined;
70
+ screenHeight?: number | undefined;
71
+ }, {
72
+ fromX: number;
73
+ fromY: number;
74
+ toX: number;
75
+ toY: number;
76
+ screenWidth?: number | undefined;
77
+ screenHeight?: number | undefined;
78
+ }>;
79
+ export declare const mouseDragTool: ToolDefinition<typeof mouseDragSchema>;
80
+ declare const mouseScrollSchema: z.ZodObject<{
81
+ screenWidth: z.ZodOptional<z.ZodNumber>;
82
+ screenHeight: z.ZodOptional<z.ZodNumber>;
83
+ x: z.ZodNumber;
84
+ y: z.ZodNumber;
85
+ direction: z.ZodEnum<["up", "down", "left", "right"]>;
86
+ amount: z.ZodNumber;
87
+ }, "strip", z.ZodTypeAny, {
88
+ x: number;
89
+ y: number;
90
+ direction: "left" | "right" | "up" | "down";
91
+ amount: number;
92
+ screenWidth?: number | undefined;
93
+ screenHeight?: number | undefined;
94
+ }, {
95
+ x: number;
96
+ y: number;
97
+ direction: "left" | "right" | "up" | "down";
98
+ amount: number;
99
+ screenWidth?: number | undefined;
100
+ screenHeight?: number | undefined;
101
+ }>;
102
+ export declare const mouseScrollTool: ToolDefinition<typeof mouseScrollSchema>;
103
+ declare const keyboardTypeSchema: z.ZodObject<{
104
+ text: z.ZodString;
105
+ delayMs: z.ZodOptional<z.ZodNumber>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ text: string;
108
+ delayMs?: number | undefined;
109
+ }, {
110
+ text: string;
111
+ delayMs?: number | undefined;
112
+ }>;
113
+ export declare const keyboardTypeTool: ToolDefinition<typeof keyboardTypeSchema>;
114
+ declare const keyboardKeyTapSchema: z.ZodObject<{
115
+ key: z.ZodString;
116
+ }, "strip", z.ZodTypeAny, {
117
+ key: string;
118
+ }, {
119
+ key: string;
120
+ }>;
121
+ export declare const keyboardKeyTapTool: ToolDefinition<typeof keyboardKeyTapSchema>;
122
+ declare const keyboardShortcutSchema: z.ZodObject<{
123
+ keys: z.ZodArray<z.ZodString, "many">;
124
+ }, "strip", z.ZodTypeAny, {
125
+ keys: string[];
126
+ }, {
127
+ keys: string[];
128
+ }>;
129
+ export declare const keyboardShortcutTool: ToolDefinition<typeof keyboardShortcutSchema>;
130
+ export {};