@elasto/nyx-cli 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 (167) hide show
  1. package/README.md +136 -0
  2. package/bin/nyx.js +3 -0
  3. package/dist/agent/index.d.ts +29 -0
  4. package/dist/agent/index.d.ts.map +1 -0
  5. package/dist/agent/index.js +362 -0
  6. package/dist/agent/index.js.map +1 -0
  7. package/dist/agent/prompt.d.ts +16 -0
  8. package/dist/agent/prompt.d.ts.map +1 -0
  9. package/dist/agent/prompt.js +487 -0
  10. package/dist/agent/prompt.js.map +1 -0
  11. package/dist/agent/templates/index.d.ts +2 -0
  12. package/dist/agent/templates/index.d.ts.map +1 -0
  13. package/dist/agent/templates/index.js +44 -0
  14. package/dist/agent/templates/index.js.map +1 -0
  15. package/dist/auth/index.d.ts +23 -0
  16. package/dist/auth/index.d.ts.map +1 -0
  17. package/dist/auth/index.js +161 -0
  18. package/dist/auth/index.js.map +1 -0
  19. package/dist/commands/login.d.ts +3 -0
  20. package/dist/commands/login.d.ts.map +1 -0
  21. package/dist/commands/login.js +32 -0
  22. package/dist/commands/login.js.map +1 -0
  23. package/dist/commands/logout.d.ts +3 -0
  24. package/dist/commands/logout.d.ts.map +1 -0
  25. package/dist/commands/logout.js +13 -0
  26. package/dist/commands/logout.js.map +1 -0
  27. package/dist/commands/logs.d.ts +3 -0
  28. package/dist/commands/logs.d.ts.map +1 -0
  29. package/dist/commands/logs.js +29 -0
  30. package/dist/commands/logs.js.map +1 -0
  31. package/dist/commands/root.d.ts +3 -0
  32. package/dist/commands/root.d.ts.map +1 -0
  33. package/dist/commands/root.js +27 -0
  34. package/dist/commands/root.js.map +1 -0
  35. package/dist/commands/run.d.ts +3 -0
  36. package/dist/commands/run.d.ts.map +1 -0
  37. package/dist/commands/run.js +74 -0
  38. package/dist/commands/run.js.map +1 -0
  39. package/dist/commands/session.d.ts +3 -0
  40. package/dist/commands/session.d.ts.map +1 -0
  41. package/dist/commands/session.js +61 -0
  42. package/dist/commands/session.js.map +1 -0
  43. package/dist/config/index.d.ts +22 -0
  44. package/dist/config/index.d.ts.map +1 -0
  45. package/dist/config/index.js +110 -0
  46. package/dist/config/index.js.map +1 -0
  47. package/dist/db/index.d.ts +5 -0
  48. package/dist/db/index.d.ts.map +1 -0
  49. package/dist/db/index.js +72 -0
  50. package/dist/db/index.js.map +1 -0
  51. package/dist/events/index.d.ts +3 -0
  52. package/dist/events/index.d.ts.map +1 -0
  53. package/dist/events/index.js +45 -0
  54. package/dist/events/index.js.map +1 -0
  55. package/dist/filetracker/index.d.ts +8 -0
  56. package/dist/filetracker/index.d.ts.map +1 -0
  57. package/dist/filetracker/index.js +21 -0
  58. package/dist/filetracker/index.js.map +1 -0
  59. package/dist/hooks/index.d.ts +13 -0
  60. package/dist/hooks/index.d.ts.map +1 -0
  61. package/dist/hooks/index.js +42 -0
  62. package/dist/hooks/index.js.map +1 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +140 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/logging/index.d.ts +16 -0
  68. package/dist/logging/index.d.ts.map +1 -0
  69. package/dist/logging/index.js +76 -0
  70. package/dist/logging/index.js.map +1 -0
  71. package/dist/lsp/index.d.ts +10 -0
  72. package/dist/lsp/index.d.ts.map +1 -0
  73. package/dist/lsp/index.js +130 -0
  74. package/dist/lsp/index.js.map +1 -0
  75. package/dist/mcp/index.d.ts +11 -0
  76. package/dist/mcp/index.d.ts.map +1 -0
  77. package/dist/mcp/index.js +102 -0
  78. package/dist/mcp/index.js.map +1 -0
  79. package/dist/permissions/index.d.ts +13 -0
  80. package/dist/permissions/index.d.ts.map +1 -0
  81. package/dist/permissions/index.js +96 -0
  82. package/dist/permissions/index.js.map +1 -0
  83. package/dist/session/index.d.ts +25 -0
  84. package/dist/session/index.d.ts.map +1 -0
  85. package/dist/session/index.js +100 -0
  86. package/dist/session/index.js.map +1 -0
  87. package/dist/shell/index.d.ts +8 -0
  88. package/dist/shell/index.d.ts.map +1 -0
  89. package/dist/shell/index.js +29 -0
  90. package/dist/shell/index.js.map +1 -0
  91. package/dist/skills/index.d.ts +9 -0
  92. package/dist/skills/index.d.ts.map +1 -0
  93. package/dist/skills/index.js +53 -0
  94. package/dist/skills/index.js.map +1 -0
  95. package/dist/tools/bash.d.ts +35 -0
  96. package/dist/tools/bash.d.ts.map +1 -0
  97. package/dist/tools/bash.js +44 -0
  98. package/dist/tools/bash.js.map +1 -0
  99. package/dist/tools/diagnostics.d.ts +19 -0
  100. package/dist/tools/diagnostics.d.ts.map +1 -0
  101. package/dist/tools/diagnostics.js +45 -0
  102. package/dist/tools/diagnostics.js.map +1 -0
  103. package/dist/tools/edit.d.ts +31 -0
  104. package/dist/tools/edit.d.ts.map +1 -0
  105. package/dist/tools/edit.js +72 -0
  106. package/dist/tools/edit.js.map +1 -0
  107. package/dist/tools/glob.d.ts +23 -0
  108. package/dist/tools/glob.d.ts.map +1 -0
  109. package/dist/tools/glob.js +40 -0
  110. package/dist/tools/glob.js.map +1 -0
  111. package/dist/tools/grep.d.ts +31 -0
  112. package/dist/tools/grep.d.ts.map +1 -0
  113. package/dist/tools/grep.js +72 -0
  114. package/dist/tools/grep.js.map +1 -0
  115. package/dist/tools/index.d.ts +9 -0
  116. package/dist/tools/index.d.ts.map +1 -0
  117. package/dist/tools/index.js +78 -0
  118. package/dist/tools/index.js.map +1 -0
  119. package/dist/tools/job_output.d.ts +49 -0
  120. package/dist/tools/job_output.d.ts.map +1 -0
  121. package/dist/tools/job_output.js +57 -0
  122. package/dist/tools/job_output.js.map +1 -0
  123. package/dist/tools/ls.d.ts +19 -0
  124. package/dist/tools/ls.d.ts.map +1 -0
  125. package/dist/tools/ls.js +55 -0
  126. package/dist/tools/ls.js.map +1 -0
  127. package/dist/tools/todos.d.ts +41 -0
  128. package/dist/tools/todos.d.ts.map +1 -0
  129. package/dist/tools/todos.js +54 -0
  130. package/dist/tools/todos.js.map +1 -0
  131. package/dist/tools/view.d.ts +27 -0
  132. package/dist/tools/view.d.ts.map +1 -0
  133. package/dist/tools/view.js +59 -0
  134. package/dist/tools/view.js.map +1 -0
  135. package/dist/tools/web_fetch.d.ts +24 -0
  136. package/dist/tools/web_fetch.d.ts.map +1 -0
  137. package/dist/tools/web_fetch.js +43 -0
  138. package/dist/tools/web_fetch.js.map +1 -0
  139. package/dist/tools/web_search.d.ts +23 -0
  140. package/dist/tools/web_search.d.ts.map +1 -0
  141. package/dist/tools/web_search.js +41 -0
  142. package/dist/tools/web_search.js.map +1 -0
  143. package/dist/tools/write.d.ts +23 -0
  144. package/dist/tools/write.d.ts.map +1 -0
  145. package/dist/tools/write.js +39 -0
  146. package/dist/tools/write.js.map +1 -0
  147. package/dist/types/index.d.ts +136 -0
  148. package/dist/types/index.d.ts.map +1 -0
  149. package/dist/types/index.js +3 -0
  150. package/dist/types/index.js.map +1 -0
  151. package/dist/ui/index.d.ts +3 -0
  152. package/dist/ui/index.d.ts.map +1 -0
  153. package/dist/ui/index.js +318 -0
  154. package/dist/ui/index.js.map +1 -0
  155. package/dist/util/diff.d.ts +17 -0
  156. package/dist/util/diff.d.ts.map +1 -0
  157. package/dist/util/diff.js +74 -0
  158. package/dist/util/diff.js.map +1 -0
  159. package/dist/util/index.d.ts +6 -0
  160. package/dist/util/index.d.ts.map +1 -0
  161. package/dist/util/index.js +33 -0
  162. package/dist/util/index.js.map +1 -0
  163. package/dist/workspace/index.d.ts +6 -0
  164. package/dist/workspace/index.d.ts.map +1 -0
  165. package/dist/workspace/index.js +133 -0
  166. package/dist/workspace/index.js.map +1 -0
  167. package/package.json +47 -0
@@ -0,0 +1,35 @@
1
+ import type { ToolResult } from '../types/index.js';
2
+ export declare const bashTool: {
3
+ definition: {
4
+ name: string;
5
+ description: string;
6
+ parameters: {
7
+ type: string;
8
+ properties: {
9
+ description: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ command: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ working_dir: {
18
+ type: string;
19
+ description: string;
20
+ };
21
+ run_in_background: {
22
+ type: string;
23
+ description: string;
24
+ };
25
+ auto_background_after: {
26
+ type: string;
27
+ description: string;
28
+ };
29
+ };
30
+ required: string[];
31
+ };
32
+ };
33
+ execute: (args: any, cwd: string) => Promise<ToolResult>;
34
+ };
35
+ //# sourceMappingURL=bash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAInE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAgBG,GAAG,OAAO,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;CAkB7D,CAAA"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bashTool = void 0;
4
+ const index_js_1 = require("../shell/index.js");
5
+ const BANNED_COMMANDS = ['sudo ', 'su ', 'doas ', 'curl ', 'wget ', 'ssh ', ' apt ', 'apt-get ', 'dnf ', 'yum ', 'pacman ', 'apk ', 'npm install -g ', 'pip install ', 'pip3 install '];
6
+ exports.bashTool = {
7
+ definition: {
8
+ name: 'bash',
9
+ description: `Execute shell commands; long-running commands automatically move to background and return a shell ID.`,
10
+ parameters: {
11
+ type: 'object',
12
+ properties: {
13
+ description: { type: 'string', description: 'A brief description of what the command does, try to keep it under 30 characters or so' },
14
+ command: { type: 'string', description: 'The command to execute' },
15
+ working_dir: { type: 'string', description: 'The working directory to execute the command in (defaults to current directory)' },
16
+ run_in_background: { type: 'boolean', description: 'Set to true to run this command in the background. Use job_output to read the output later.' },
17
+ auto_background_after: { type: 'number', description: 'Seconds to wait before automatically moving the command to a background job (default: 60)' },
18
+ },
19
+ required: ['command'],
20
+ },
21
+ },
22
+ execute: async (args, cwd) => {
23
+ const cmdLower = args.command.toLowerCase();
24
+ for (const banned of BANNED_COMMANDS) {
25
+ if (cmdLower.includes(banned)) {
26
+ return { id: '', success: false, output: '', error: `Command "${args.command}" is not allowed for security reasons.`, tool: 'bash', args };
27
+ }
28
+ }
29
+ const result = (0, index_js_1.runCommand)(args.command, args.working_dir || cwd, (args.auto_background_after || 60) * 1000);
30
+ let output = result.stdout || result.stderr || '';
31
+ if (output.length > 30000) {
32
+ const half = 15000;
33
+ output = output.substring(0, half) + `\n\n... [${countLines(output.substring(half, output.length - half))} lines truncated] ...\n\n` + output.substring(output.length - half);
34
+ }
35
+ if (result.success) {
36
+ output += `\n\n<cwd>${args.working_dir || cwd}</cwd>`;
37
+ }
38
+ return { id: '', success: result.success, output, error: result.success ? undefined : `Exit code ${result.exitCode}: ${result.stderr.substring(0, 500)}`, tool: 'bash', args };
39
+ },
40
+ };
41
+ function countLines(s) {
42
+ return s ? s.split('\n').length : 0;
43
+ }
44
+ //# sourceMappingURL=bash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash.js","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":";;;AAAA,gDAA8C;AAG9C,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,CAAC,CAAA;AAE1K,QAAA,QAAQ,GAAG;IACtB,UAAU,EAAE;QACV,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,uGAAuG;QACpH,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,wFAAwF,EAAE;gBACtI,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,wBAAwB,EAAE;gB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AAG,IAAI,CAAC,CAAC,2BAA2B,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;QAC/K,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,IAAI,YAAY,IAAI,CAAC,WAAW,IAAI,GAAG,QAAQ,CAAA;QACvD,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IAChL,CAAC;CACF,CAAA;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACrC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { ToolResult } from '../types/index.js';
2
+ export declare const diagnosticsTool: {
3
+ definition: {
4
+ name: string;
5
+ description: string;
6
+ parameters: {
7
+ type: string;
8
+ properties: {
9
+ path: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ };
14
+ required: string[];
15
+ };
16
+ };
17
+ execute: (args: any, cwd: string) => Promise<ToolResult>;
18
+ };
19
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/tools/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;oBAYJ,GAAG,OAAO,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;CAyB7D,CAAA"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.diagnosticsTool = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const index_js_1 = require("../shell/index.js");
7
+ exports.diagnosticsTool = {
8
+ definition: {
9
+ name: 'diagnostics',
10
+ description: 'Run TypeScript and ESLint diagnostics on the project. Returns any errors or warnings found.',
11
+ parameters: {
12
+ type: 'object',
13
+ properties: {
14
+ path: { type: 'string', description: 'Project root path' },
15
+ },
16
+ required: ['path'],
17
+ },
18
+ },
19
+ execute: async (args, cwd) => {
20
+ const projectPath = (0, path_1.resolve)(cwd, args.path);
21
+ const results = [];
22
+ if ((0, fs_1.existsSync)((0, path_1.resolve)(projectPath, 'tsconfig.json'))) {
23
+ const tsResult = (0, index_js_1.runCommand)('npx tsc --noEmit 2>&1', projectPath, 60000);
24
+ if (tsResult.stdout)
25
+ results.push('TypeScript:\n' + tsResult.stdout.substring(0, 2000));
26
+ if (tsResult.stderr && !tsResult.success)
27
+ results.push('TypeScript Error:\n' + tsResult.stderr.substring(0, 500));
28
+ }
29
+ const eslintConfigs = ['eslint.config.js', 'eslint.config.mjs', '.eslintrc.js', '.eslintrc.json'];
30
+ const hasEslint = eslintConfigs.some((f) => (0, fs_1.existsSync)((0, path_1.resolve)(projectPath, f)));
31
+ if (hasEslint) {
32
+ const eslintResult = (0, index_js_1.runCommand)('npx eslint . --format compact 2>&1', projectPath, 60000);
33
+ if (eslintResult.stdout)
34
+ results.push('ESLint:\n' + eslintResult.stdout.substring(0, 2000));
35
+ }
36
+ return {
37
+ id: '',
38
+ success: true,
39
+ output: results.join('\n\n') || 'No diagnostics available',
40
+ tool: 'diagnostics',
41
+ args,
42
+ };
43
+ },
44
+ };
45
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","sourceRoot":"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,EAAE,CAAC,IAAA,eAAU,EAAC,IAAA,cAAO,EAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;QAChF,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,YAAY,GAAG,IAAA,qBAAU,EAAC,oCAAoC,EAAE,WAAW,EAAE,KAAK,CAAC,CAAA;YACzF,IAAI,YAAY,CAAC,MAAM;gBAAE,OAAO,CAAC,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;QAC7F,CAAC;QAED,OAAO;YACL,EAAE,EAAE,EAAE;YACN,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,0BAA0B;YAC1D,IAAI,EAAE,aAAa;YACnB,IAAI;SACL,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,31 @@
1
+ import type { ToolResult } from '../types/index.js';
2
+ export declare const editTool: {
3
+ definition: {
4
+ name: string;
5
+ description: string;
6
+ parameters: {
7
+ type: string;
8
+ properties: {
9
+ file_path: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ old_string: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ new_string: {
18
+ type: string;
19
+ description: string;
20
+ };
21
+ replace_all: {
22
+ type: string;
23
+ description: string;
24
+ };
25
+ };
26
+ required: string[];
27
+ };
28
+ };
29
+ execute: (args: any, cwd: string) => Promise<ToolResult>;
30
+ };
31
+ //# sourceMappingURL=edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/tools/edit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAeG,GAAG,OAAO,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;CAiD7D,CAAA"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.editTool = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ exports.editTool = {
7
+ definition: {
8
+ name: 'edit',
9
+ description: 'Edit a file by exact find-and-replace; can also create or delete content. For renames/moves use bash. For large edits use write.',
10
+ parameters: {
11
+ type: 'object',
12
+ properties: {
13
+ file_path: { type: 'string', description: 'The absolute path to the file to modify' },
14
+ old_string: { type: 'string', description: 'The text to replace' },
15
+ new_string: { type: 'string', description: 'The text to replace it with' },
16
+ replace_all: { type: 'boolean', description: 'Replace all occurrences of old_string (default false)' },
17
+ },
18
+ required: ['file_path'],
19
+ },
20
+ },
21
+ execute: async (args, cwd) => {
22
+ if (!args.file_path) {
23
+ return { id: '', success: false, output: '', error: 'file_path is required', tool: 'edit', args };
24
+ }
25
+ const filePath = (0, path_1.resolve)(cwd, args.file_path);
26
+ // Create new file (no old_string, has new_string)
27
+ if (args.new_string !== undefined && !args.old_string) {
28
+ (0, fs_1.mkdirSync)((0, path_1.dirname)(filePath), { recursive: true });
29
+ (0, fs_1.writeFileSync)(filePath, args.new_string, 'utf-8');
30
+ return { id: '', success: true, output: `<result>\nFile created: ${args.file_path}\n</result>`, tool: 'edit', args };
31
+ }
32
+ let stat;
33
+ try {
34
+ stat = (0, fs_1.statSync)(filePath);
35
+ }
36
+ catch {
37
+ return { id: '', success: false, output: '', error: `File not found: ${args.file_path}`, tool: 'edit', args };
38
+ }
39
+ if (stat.isDirectory()) {
40
+ return { id: '', success: false, output: '', error: `Path is a directory, not a file: ${args.file_path}`, tool: 'edit', args };
41
+ }
42
+ const content = (0, fs_1.readFileSync)(filePath, 'utf-8');
43
+ // Delete content (has old_string, no new_string)
44
+ if (args.old_string && args.new_string === undefined) {
45
+ const idx = content.indexOf(args.old_string);
46
+ if (idx === -1)
47
+ return { id: '', success: false, output: '', error: 'old_string not found in file. Make sure it matches exactly, including whitespace and line breaks.', tool: 'edit', args };
48
+ const lastIdx = content.lastIndexOf(args.old_string);
49
+ if (idx !== lastIdx && !args.replace_all) {
50
+ return { id: '', success: false, output: '', error: 'old_string appears multiple times in the file. Please provide more context to ensure a unique match, or set replace_all to true', tool: 'edit', args };
51
+ }
52
+ const newContent = args.replace_all ? content.split(args.old_string).join('') : content.replace(args.old_string, '');
53
+ (0, fs_1.writeFileSync)(filePath, newContent, 'utf-8');
54
+ return { id: '', success: true, output: `<result>\nContent deleted from file: ${args.file_path}\n</result>`, tool: 'edit', args };
55
+ }
56
+ // Replace content (has old_string and new_string)
57
+ const idx = content.indexOf(args.old_string);
58
+ if (idx === -1)
59
+ return { id: '', success: false, output: '', error: 'old_string not found in file. Make sure it matches exactly, including whitespace and line breaks.', tool: 'edit', args };
60
+ const lastIdx = content.lastIndexOf(args.old_string);
61
+ if (idx !== lastIdx && !args.replace_all) {
62
+ return { id: '', success: false, output: '', error: 'old_string appears multiple times in the file. Please provide more context to ensure a unique match, or set replace_all to true', tool: 'edit', args };
63
+ }
64
+ if (args.old_string === args.new_string) {
65
+ return { id: '', success: false, output: '', error: 'new content is the same as old content. No changes made.', tool: 'edit', args };
66
+ }
67
+ const newContent = args.replace_all ? content.split(args.old_string).join(args.new_string) : content.replace(args.old_string, args.new_string);
68
+ (0, fs_1.writeFileSync)(filePath, newContent, 'utf-8');
69
+ return { id: '', success: true, output: `<result>\nContent replaced in file: ${args.file_path}\n</result>`, tool: 'edit', args };
70
+ },
71
+ };
72
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/tools/edit.ts"],"names":[],"mappings":";;;AAAA,2BAAqE;AACrE,+BAAuC;AAG1B,QAAA,QAAQ,GAAG;IACtB,UAAU,EAAE;QACV,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kIAAkI;QAC/I,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gB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AAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,0DAA0D,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;QACtI,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;QAC9I,IAAA,kBAAa,EAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;QAC5C,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,uCAAuC,IAAI,CAAC,SAAS,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IAClI,CAAC;CACF,CAAA"}
@@ -0,0 +1,23 @@
1
+ import type { ToolResult } from '../types/index.js';
2
+ export declare const globTool: {
3
+ definition: {
4
+ name: string;
5
+ description: string;
6
+ parameters: {
7
+ type: string;
8
+ properties: {
9
+ pattern: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ basePath: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ };
18
+ required: string[];
19
+ };
20
+ };
21
+ execute: (args: any, cwd: string) => Promise<ToolResult>;
22
+ };
23
+ //# sourceMappingURL=glob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/tools/glob.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;oBAaG,GAAG,OAAO,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;CAiB7D,CAAA"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.globTool = void 0;
7
+ const fast_glob_1 = __importDefault(require("fast-glob"));
8
+ const path_1 = require("path");
9
+ exports.globTool = {
10
+ definition: {
11
+ name: 'glob',
12
+ description: 'Find files by glob pattern. Use this to discover files matching a pattern.',
13
+ parameters: {
14
+ type: 'object',
15
+ properties: {
16
+ pattern: { type: 'string', description: 'Glob pattern like **/*.ts' },
17
+ basePath: { type: 'string', description: 'Base directory to search from' },
18
+ },
19
+ required: ['pattern'],
20
+ },
21
+ },
22
+ execute: async (args, cwd) => {
23
+ const basePath = (0, path_1.resolve)(cwd, args.basePath || '.');
24
+ const pattern = args.pattern;
25
+ const results = await (0, fast_glob_1.default)(pattern, {
26
+ cwd: basePath,
27
+ absolute: true,
28
+ ignore: ['**/node_modules/**', '**/.git/**', '**/dist/**', '**/build/**'],
29
+ });
30
+ const output = results.slice(0, 100).join('\n');
31
+ return {
32
+ id: '',
33
+ success: true,
34
+ output: output || 'No matches found',
35
+ tool: 'glob',
36
+ args,
37
+ };
38
+ },
39
+ };
40
+ //# sourceMappingURL=glob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/tools/glob.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA0B;AAC1B,+BAA8B;AAGjB,QAAA,QAAQ,GAAG;IACtB,UAAU,EAAE;QACV,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,4EAA4E;QACzF,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2BAA2B,EAAE;gBACrE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+BAA+B,EAAE;aAC3E;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;KACF;IACD,OAAO,EAAE,KAAK,EAAE,IAAS,EAAE,GAAW,EAAuB,EAAE;QAC7D,MAAM,QAAQ,GAAG,IAAA,cAAO,EAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAA;QACnD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC5B,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAE,EAAC,OAAO,EAAE;YAChC,GAAG,EAAE,QAAQ;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,CAAC,oBAAoB,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,CAAC;SAC1E,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/C,OAAO;YACL,EAAE,EAAE,EAAE;YACN,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,MAAM,IAAI,kBAAkB;YACpC,IAAI,EAAE,MAAM;YACZ,IAAI;SACL,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,31 @@
1
+ import type { ToolResult } from '../types/index.js';
2
+ export declare const grepTool: {
3
+ definition: {
4
+ name: string;
5
+ description: string;
6
+ parameters: {
7
+ type: string;
8
+ properties: {
9
+ pattern: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ path: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ include: {
18
+ type: string;
19
+ description: string;
20
+ };
21
+ maxResults: {
22
+ type: string;
23
+ description: string;
24
+ };
25
+ };
26
+ required: string[];
27
+ };
28
+ };
29
+ execute: (args: any, cwd: string) => Promise<ToolResult>;
30
+ };
31
+ //# sourceMappingURL=grep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAeG,GAAG,OAAO,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;CAyC7D,CAAA"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.grepTool = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const index_js_1 = require("../util/index.js");
7
+ exports.grepTool = {
8
+ definition: {
9
+ name: 'grep',
10
+ description: 'Search file contents using a regular expression. Returns matching file paths and line numbers.',
11
+ parameters: {
12
+ type: 'object',
13
+ properties: {
14
+ pattern: { type: 'string', description: 'Regular expression pattern to search for' },
15
+ path: { type: 'string', description: 'Directory or file to search in' },
16
+ include: { type: 'string', description: 'File glob pattern to include (e.g., *.ts)' },
17
+ maxResults: { type: 'number', description: 'Maximum results to return' },
18
+ },
19
+ required: ['pattern'],
20
+ },
21
+ },
22
+ execute: async (args, cwd) => {
23
+ const pattern = new RegExp(args.pattern, 'gi');
24
+ const searchPath = (0, path_1.resolve)(cwd, args.path || '.');
25
+ const maxResults = args.maxResults || 50;
26
+ const matches = [];
27
+ function search(dir, depth = 0) {
28
+ if (depth > 5 || matches.length >= maxResults)
29
+ return;
30
+ let entries;
31
+ try {
32
+ entries = (0, fs_1.readdirSync)(dir);
33
+ }
34
+ catch {
35
+ return;
36
+ }
37
+ for (const entry of entries) {
38
+ if (entry.startsWith('.') || (0, index_js_1.isIgnoredDir)(entry))
39
+ continue;
40
+ const full = (0, path_1.join)(dir, entry);
41
+ try {
42
+ const stat = (0, fs_1.statSync)(full);
43
+ if (stat.isDirectory()) {
44
+ search(full, depth + 1);
45
+ }
46
+ else if (stat.isFile() && stat.size < 50000) {
47
+ if (args.include && !entry.endsWith(args.include.replace('*', '')))
48
+ continue;
49
+ const content = (0, fs_1.readFileSync)(full, 'utf-8');
50
+ const lines = content.split('\n');
51
+ for (let i = 0; i < lines.length; i++) {
52
+ if (pattern.test(lines[i]) && matches.length < maxResults) {
53
+ const rel = full.replace(searchPath, '').replace(/^[/\\]/, '');
54
+ matches.push(`${rel}:${i + 1}: ${lines[i].trim().substring(0, 120)}`);
55
+ }
56
+ }
57
+ }
58
+ }
59
+ catch { }
60
+ }
61
+ }
62
+ search(searchPath);
63
+ return {
64
+ id: '',
65
+ success: true,
66
+ output: matches.length > 0 ? matches.join('\n') : 'No matches found',
67
+ tool: 'grep',
68
+ args,
69
+ };
70
+ },
71
+ };
72
+ //# sourceMappingURL=grep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grep.js","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":";;;AAAA,2BAAwD;AACxD,+BAAoC;AACpC,+CAA+C;AAGlC,QAAA,QAAQ,GAAG;IACtB,UAAU,EAAE;QACV,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,gGAAgG;QAC7G,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0CAA0C,EAAE;gBACpF,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gCAAgC,EAAE;gBACvE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2CAA2C,EAAE;gBACrF,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2BAA2B,EAAE;aACzE;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;KACF;IACD,OAAO,EAAE,KAAK,EAAE,IAAS,EAAE,GAAW,EAAuB,EAAE;QAC7D,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC9C,MAAM,UAAU,GAAG,IAAA,cAAO,EAAC,GAAG,EAAE,IAAI,CAAC,I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AAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;4BACtC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;gCAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;gCAC9D,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;4BACvE,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC,CAAA,CAAC;YACZ,CAAC;QACH,CAAC;QAED,MAAM,CAAC,UAAU,CAAC,CAAA;QAClB,OAAO;YACL,EAAE,EAAE,EAAE;YACN,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB;YACpE,IAAI,EAAE,MAAM;YACZ,IAAI;SACL,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { ToolDefinition, ToolCall, ToolResult } from '../types/index.js';
2
+ export declare const ALL_TOOL_DEFINITIONS: ToolDefinition[];
3
+ export declare const toolMap: Map<string, {
4
+ definition: ToolDefinition;
5
+ execute: (args: any, cwd: string) => Promise<ToolResult>;
6
+ }>;
7
+ export declare function executeTool(tool: ToolCall, cwd: string): Promise<ToolResult>;
8
+ export declare function getToolDefinitions(disabled?: string[]): ToolDefinition[];
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAc7E,eAAO,MAAM,oBAAoB,EAAE,cAAc,EAchD,CAAA;AAED,eAAO,MAAM,OAAO;gBAAiC,cAAc;aAAW,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC;EAgB3H,CAAA;AAQF,wBAAsB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAiBlF;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,GAAE,MAAM,EAAO,GAAG,cAAc,EAAE,CAE5E"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toolMap = exports.ALL_TOOL_DEFINITIONS = void 0;
4
+ exports.executeTool = executeTool;
5
+ exports.getToolDefinitions = getToolDefinitions;
6
+ const view_js_1 = require("./view.js");
7
+ const write_js_1 = require("./write.js");
8
+ const edit_js_1 = require("./edit.js");
9
+ const ls_js_1 = require("./ls.js");
10
+ const grep_js_1 = require("./grep.js");
11
+ const glob_js_1 = require("./glob.js");
12
+ const bash_js_1 = require("./bash.js");
13
+ const diagnostics_js_1 = require("./diagnostics.js");
14
+ const web_fetch_js_1 = require("./web_fetch.js");
15
+ const web_search_js_1 = require("./web_search.js");
16
+ const todos_js_1 = require("./todos.js");
17
+ const job_output_js_1 = require("./job_output.js");
18
+ exports.ALL_TOOL_DEFINITIONS = [
19
+ view_js_1.viewTool.definition,
20
+ write_js_1.writeTool.definition,
21
+ edit_js_1.editTool.definition,
22
+ ls_js_1.lsTool.definition,
23
+ grep_js_1.grepTool.definition,
24
+ glob_js_1.globTool.definition,
25
+ bash_js_1.bashTool.definition,
26
+ diagnostics_js_1.diagnosticsTool.definition,
27
+ web_fetch_js_1.webFetchTool.definition,
28
+ web_search_js_1.webSearchTool.definition,
29
+ todos_js_1.todosTool.definition,
30
+ job_output_js_1.jobOutputTool.definition,
31
+ job_output_js_1.jobKillTool.definition,
32
+ ];
33
+ exports.toolMap = new Map([
34
+ ['view', view_js_1.viewTool],
35
+ ['write', write_js_1.writeTool],
36
+ ['edit', edit_js_1.editTool],
37
+ ['ls', ls_js_1.lsTool],
38
+ ['grep', grep_js_1.grepTool],
39
+ ['glob', glob_js_1.globTool],
40
+ ['bash', bash_js_1.bashTool],
41
+ ['diagnostics', diagnostics_js_1.diagnosticsTool],
42
+ ['lsp_diagnostics', diagnostics_js_1.diagnosticsTool],
43
+ ['web_fetch', web_fetch_js_1.webFetchTool],
44
+ ['fetch', web_fetch_js_1.webFetchTool],
45
+ ['web_search', web_search_js_1.webSearchTool],
46
+ ['todos', todos_js_1.todosTool],
47
+ ['job_output', job_output_js_1.jobOutputTool],
48
+ ['job_kill', job_output_js_1.jobKillTool],
49
+ ]);
50
+ function normalizeToolName(name) {
51
+ // Strip prefixes like "functions." from tool names
52
+ if (name.includes('.'))
53
+ return name.split('.').pop() || name;
54
+ return name;
55
+ }
56
+ async function executeTool(tool, cwd) {
57
+ tool.tool = normalizeToolName(tool.tool);
58
+ const handler = exports.toolMap.get(tool.tool);
59
+ if (!handler) {
60
+ return {
61
+ id: tool.id, success: false, output: '', error: `Unknown tool: ${tool.tool}`,
62
+ tool: tool.tool, args: tool.args,
63
+ };
64
+ }
65
+ try {
66
+ return await handler.execute(tool.args, cwd);
67
+ }
68
+ catch (err) {
69
+ return {
70
+ id: tool.id, success: false, output: '', error: err.message,
71
+ tool: tool.tool, args: tool.args,
72
+ };
73
+ }
74
+ }
75
+ function getToolDefinitions(disabled = []) {
76
+ return exports.ALL_TOOL_DEFINITIONS.filter((t) => !disabled.includes(t.name));
77
+ }
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+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CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AACvE,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { ToolResult } from '../types/index.js';
2
+ export declare function registerJob(id: string, job: {
3
+ stdout: string;
4
+ stderr: string;
5
+ done: boolean;
6
+ exitCode: number;
7
+ }): void;
8
+ export declare function getJob(id: string): {
9
+ stdout: string;
10
+ stderr: string;
11
+ done: boolean;
12
+ exitCode: number;
13
+ } | undefined;
14
+ export declare function removeJob(id: string): void;
15
+ export declare const jobOutputTool: {
16
+ definition: {
17
+ name: string;
18
+ description: string;
19
+ parameters: {
20
+ type: string;
21
+ properties: {
22
+ shell_id: {
23
+ type: string;
24
+ description: string;
25
+ };
26
+ };
27
+ required: string[];
28
+ };
29
+ };
30
+ execute: (args: any, _cwd: string) => Promise<ToolResult>;
31
+ };
32
+ export declare const jobKillTool: {
33
+ definition: {
34
+ name: string;
35
+ description: string;
36
+ parameters: {
37
+ type: string;
38
+ properties: {
39
+ shell_id: {
40
+ type: string;
41
+ description: string;
42
+ };
43
+ };
44
+ required: string[];
45
+ };
46
+ };
47
+ execute: (args: any, _cwd: string) => Promise<ToolResult>;
48
+ };
49
+ //# sourceMappingURL=job_output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job_output.d.ts","sourceRoot":"","sources":["../../src/tools/job_output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAInE,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,QAE/G;AAED,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM;YANQ,MAAM;YAAU,MAAM;UAAQ,OAAO;cAAY,MAAM;cAMpC;AAC5D,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,QAAuB;AAE3D,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;oBAYF,GAAG,QAAQ,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;CAS9D,CAAA;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;oBAYA,GAAG,QAAQ,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;CAS9D,CAAA"}