@4onstudios/iris-agent 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 (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +690 -0
  3. package/dist/api/acp/acpServer.d.ts +23 -0
  4. package/dist/api/acp/acpServer.js +814 -0
  5. package/dist/api/acp/index.d.ts +2 -0
  6. package/dist/api/acp/index.js +2 -0
  7. package/dist/api/acp/irisClient.d.ts +58 -0
  8. package/dist/api/acp/irisClient.js +214 -0
  9. package/dist/api/agent.d.ts +14 -0
  10. package/dist/api/agent.js +4171 -0
  11. package/dist/api/backendService.d.ts +4 -0
  12. package/dist/api/backendService.js +14 -0
  13. package/dist/api/core/agent/host/AgentContract.d.ts +82 -0
  14. package/dist/api/core/agent/host/AgentContract.js +1 -0
  15. package/dist/api/core/agent/host/AgentRegistry.d.ts +24 -0
  16. package/dist/api/core/agent/host/AgentRegistry.js +125 -0
  17. package/dist/api/core/agent/host/defaultRegistry.d.ts +15 -0
  18. package/dist/api/core/agent/host/defaultRegistry.js +46 -0
  19. package/dist/api/core/agent/host/externalAgentLifecycle.d.ts +65 -0
  20. package/dist/api/core/agent/host/externalAgentLifecycle.js +117 -0
  21. package/dist/api/core/agent/host/hostSessionManager.d.ts +111 -0
  22. package/dist/api/core/agent/host/hostSessionManager.js +352 -0
  23. package/dist/api/core/agent/host/index.d.ts +5 -0
  24. package/dist/api/core/agent/host/index.js +5 -0
  25. package/dist/api/core/agent/index.d.ts +87 -0
  26. package/dist/api/core/agent/index.js +1024 -0
  27. package/dist/api/core/agent/publicContracts.d.ts +35 -0
  28. package/dist/api/core/agent/publicContracts.js +103 -0
  29. package/dist/api/core/agent/tools/applyDiff.d.ts +51 -0
  30. package/dist/api/core/agent/tools/applyDiff.js +131 -0
  31. package/dist/api/core/agent/tools/backgroundTasks.d.ts +240 -0
  32. package/dist/api/core/agent/tools/backgroundTasks.js +313 -0
  33. package/dist/api/core/agent/tools/createDirectory.d.ts +43 -0
  34. package/dist/api/core/agent/tools/createDirectory.js +77 -0
  35. package/dist/api/core/agent/tools/deleteFile.d.ts +37 -0
  36. package/dist/api/core/agent/tools/deleteFile.js +66 -0
  37. package/dist/api/core/agent/tools/editFile.d.ts +73 -0
  38. package/dist/api/core/agent/tools/editFile.js +173 -0
  39. package/dist/api/core/agent/tools/executeCommand.d.ts +59 -0
  40. package/dist/api/core/agent/tools/executeCommand.js +250 -0
  41. package/dist/api/core/agent/tools/fileContent.d.ts +54 -0
  42. package/dist/api/core/agent/tools/fileContent.js +227 -0
  43. package/dist/api/core/agent/tools/findDefinition.d.ts +72 -0
  44. package/dist/api/core/agent/tools/findDefinition.js +109 -0
  45. package/dist/api/core/agent/tools/findReferences.d.ts +86 -0
  46. package/dist/api/core/agent/tools/findReferences.js +135 -0
  47. package/dist/api/core/agent/tools/formatDocument.d.ts +67 -0
  48. package/dist/api/core/agent/tools/formatDocument.js +90 -0
  49. package/dist/api/core/agent/tools/getCodeActions.d.ts +77 -0
  50. package/dist/api/core/agent/tools/getCodeActions.js +97 -0
  51. package/dist/api/core/agent/tools/getCodeCompletion.d.ts +77 -0
  52. package/dist/api/core/agent/tools/getCodeCompletion.js +174 -0
  53. package/dist/api/core/agent/tools/getCodeContext.d.ts +14 -0
  54. package/dist/api/core/agent/tools/getCodeContext.js +282 -0
  55. package/dist/api/core/agent/tools/getSignatureHelp.d.ts +61 -0
  56. package/dist/api/core/agent/tools/getSignatureHelp.js +85 -0
  57. package/dist/api/core/agent/tools/getSymbols.d.ts +50 -0
  58. package/dist/api/core/agent/tools/getSymbols.js +164 -0
  59. package/dist/api/core/agent/tools/getSymbolsLSP.d.ts +58 -0
  60. package/dist/api/core/agent/tools/getSymbolsLSP.js +147 -0
  61. package/dist/api/core/agent/tools/getTypeInfo.d.ts +70 -0
  62. package/dist/api/core/agent/tools/getTypeInfo.js +84 -0
  63. package/dist/api/core/agent/tools/getWorkspaceInfo.d.ts +80 -0
  64. package/dist/api/core/agent/tools/getWorkspaceInfo.js +281 -0
  65. package/dist/api/core/agent/tools/getWorkspaceSymbols.d.ts +53 -0
  66. package/dist/api/core/agent/tools/getWorkspaceSymbols.js +97 -0
  67. package/dist/api/core/agent/tools/grepSearch.d.ts +100 -0
  68. package/dist/api/core/agent/tools/grepSearch.js +211 -0
  69. package/dist/api/core/agent/tools/languageModelToolsIntegration.d.ts +13 -0
  70. package/dist/api/core/agent/tools/languageModelToolsIntegration.js +22 -0
  71. package/dist/api/core/agent/tools/listDirectory.d.ts +66 -0
  72. package/dist/api/core/agent/tools/listDirectory.js +161 -0
  73. package/dist/api/core/agent/tools/mcpTools.d.ts +48 -0
  74. package/dist/api/core/agent/tools/mcpTools.js +442 -0
  75. package/dist/api/core/agent/tools/queryKnowledgeGraph.d.ts +120 -0
  76. package/dist/api/core/agent/tools/queryKnowledgeGraph.js +306 -0
  77. package/dist/api/core/agent/tools/readFile.d.ts +92 -0
  78. package/dist/api/core/agent/tools/readFile.js +337 -0
  79. package/dist/api/core/agent/tools/renameFile.d.ts +49 -0
  80. package/dist/api/core/agent/tools/renameFile.js +86 -0
  81. package/dist/api/core/agent/tools/renameSymbol.d.ts +70 -0
  82. package/dist/api/core/agent/tools/renameSymbol.js +106 -0
  83. package/dist/api/core/agent/tools/runTerminalCommand.d.ts +72 -0
  84. package/dist/api/core/agent/tools/runTerminalCommand.js +69 -0
  85. package/dist/api/core/agent/tools/searchFiles.d.ts +82 -0
  86. package/dist/api/core/agent/tools/searchFiles.js +280 -0
  87. package/dist/api/core/agent/tools/terminalAutoApprove.d.ts +3 -0
  88. package/dist/api/core/agent/tools/terminalAutoApprove.js +676 -0
  89. package/dist/api/core/agent/tools/treeTraversal.d.ts +60 -0
  90. package/dist/api/core/agent/tools/treeTraversal.js +217 -0
  91. package/dist/api/core/agent/tools/webSearch.d.ts +37 -0
  92. package/dist/api/core/agent/tools/webSearch.js +80 -0
  93. package/dist/api/core/agent/tools/writeFile.d.ts +59 -0
  94. package/dist/api/core/agent/tools/writeFile.js +97 -0
  95. package/dist/api/core/agent/utils/capturedWorkspaceMutationBridge.d.ts +12 -0
  96. package/dist/api/core/agent/utils/capturedWorkspaceMutationBridge.js +67 -0
  97. package/dist/api/core/agent/utils/diffUtils.d.ts +14 -0
  98. package/dist/api/core/agent/utils/diffUtils.js +39 -0
  99. package/dist/api/core/agent/utils/environmentSnapshot.d.ts +42 -0
  100. package/dist/api/core/agent/utils/environmentSnapshot.js +213 -0
  101. package/dist/api/core/agent/utils/errorRecovery.d.ts +49 -0
  102. package/dist/api/core/agent/utils/errorRecovery.js +229 -0
  103. package/dist/api/core/agent/utils/multimodalTokenLimiter.d.ts +8 -0
  104. package/dist/api/core/agent/utils/multimodalTokenLimiter.js +238 -0
  105. package/dist/api/core/agent/utils/openRouterModelSettings.d.ts +12 -0
  106. package/dist/api/core/agent/utils/openRouterModelSettings.js +34 -0
  107. package/dist/api/core/agent/utils/pathRecovery.d.ts +1 -0
  108. package/dist/api/core/agent/utils/pathRecovery.js +29 -0
  109. package/dist/api/core/agent/utils/repoMapIndex.d.ts +3 -0
  110. package/dist/api/core/agent/utils/repoMapIndex.js +197 -0
  111. package/dist/api/core/agent/utils/skillsDiscovery.d.ts +10 -0
  112. package/dist/api/core/agent/utils/skillsDiscovery.js +50 -0
  113. package/dist/api/core/agent/utils/toolCallBudget.d.ts +9 -0
  114. package/dist/api/core/agent/utils/toolCallBudget.js +55 -0
  115. package/dist/api/core/agent/utils/toolLifecycle.d.ts +30 -0
  116. package/dist/api/core/agent/utils/toolLifecycle.js +361 -0
  117. package/dist/api/core/agent/utils/toolResultSafetyProcessor.d.ts +12 -0
  118. package/dist/api/core/agent/utils/toolResultSafetyProcessor.js +57 -0
  119. package/dist/api/core/agent/utils/workspaceMutationBridge.d.ts +13 -0
  120. package/dist/api/core/agent/utils/workspaceMutationBridge.js +149 -0
  121. package/dist/api/core/agent/utils/workspacePathGuard.d.ts +7 -0
  122. package/dist/api/core/agent/utils/workspacePathGuard.js +79 -0
  123. package/dist/api/core/containers/chat/toolResultSerialization.d.ts +8 -0
  124. package/dist/api/core/containers/chat/toolResultSerialization.js +71 -0
  125. package/dist/api/core/library/BrowserManager.d.ts +11 -0
  126. package/dist/api/core/library/BrowserManager.js +66 -0
  127. package/dist/api/core/library/desktopWorkspace.d.ts +1 -0
  128. package/dist/api/core/library/desktopWorkspace.js +3 -0
  129. package/dist/api/core/library/extensionManager.d.ts +10 -0
  130. package/dist/api/core/library/extensionManager.js +27 -0
  131. package/dist/api/core/library/knowledgeGraph.d.ts +268 -0
  132. package/dist/api/core/library/knowledgeGraph.js +989 -0
  133. package/dist/api/core/library/languageModelTools.d.ts +141 -0
  134. package/dist/api/core/library/languageModelTools.js +207 -0
  135. package/dist/api/core/library/localRuntime.d.ts +23 -0
  136. package/dist/api/core/library/localRuntime.js +144 -0
  137. package/dist/api/core/library/lsp/coreLsp.d.ts +367 -0
  138. package/dist/api/core/library/lsp/coreLsp.js +2076 -0
  139. package/dist/api/core/library/lsp/protocol.d.ts +25 -0
  140. package/dist/api/core/library/lsp/protocol.js +1 -0
  141. package/dist/api/core/library/lsp/serverManager.d.ts +37 -0
  142. package/dist/api/core/library/lsp/serverManager.js +427 -0
  143. package/dist/api/core/library/mcpServerProvider.d.ts +69 -0
  144. package/dist/api/core/library/mcpServerProvider.js +152 -0
  145. package/dist/api/core/library/mcpSettings.d.ts +20 -0
  146. package/dist/api/core/library/mcpSettings.js +131 -0
  147. package/dist/api/core/library/patternMatcher.d.ts +66 -0
  148. package/dist/api/core/library/patternMatcher.js +284 -0
  149. package/dist/api/core/library/regexEscape.d.ts +4 -0
  150. package/dist/api/core/library/regexEscape.js +4 -0
  151. package/dist/api/core/library/runtimeEventBus.d.ts +27 -0
  152. package/dist/api/core/library/runtimeEventBus.js +78 -0
  153. package/dist/api/core/library/safetyMiddleware.d.ts +98 -0
  154. package/dist/api/core/library/safetyMiddleware.js +215 -0
  155. package/dist/api/core/library/tauri.d.ts +71 -0
  156. package/dist/api/core/library/tauri.js +222 -0
  157. package/dist/api/core/library/tauriImport.d.ts +5 -0
  158. package/dist/api/core/library/tauriImport.js +7 -0
  159. package/dist/api/core/library/terminalAutoApproveSettings.d.ts +32 -0
  160. package/dist/api/core/library/terminalAutoApproveSettings.js +529 -0
  161. package/dist/api/core/library/workspaceIdentity.d.ts +10 -0
  162. package/dist/api/core/library/workspaceIdentity.js +49 -0
  163. package/dist/api/core/library/workspaceSummary.d.ts +19 -0
  164. package/dist/api/core/library/workspaceSummary.js +35 -0
  165. package/dist/api/core/skills/agent-customization/SKILL.md +27 -0
  166. package/dist/api/core/skills/bug-fix/SKILL.md +21 -0
  167. package/dist/api/core/skills/create-pr/SKILL.md +32 -0
  168. package/dist/api/core/skills/dev-server/SKILL.md +20 -0
  169. package/dist/api/core/skills/fix-suggestions/SKILL.md +21 -0
  170. package/dist/api/core/skills/github-search/SKILL.md +21 -0
  171. package/dist/api/core/skills/github-summary/SKILL.md +25 -0
  172. package/dist/api/core/skills/integration-tests/SKILL.md +29 -0
  173. package/dist/api/core/skills/pr-comments/SKILL.md +23 -0
  174. package/dist/api/core/skills/project-setup/SKILL.md +20 -0
  175. package/dist/api/core/skills/search-integration/SKILL.md +19 -0
  176. package/dist/api/core/skills/search-results/SKILL.md +19 -0
  177. package/dist/api/core/skills/typescript-upgrade/SKILL.md +21 -0
  178. package/dist/api/data/runStore.d.ts +46 -0
  179. package/dist/api/data/runStore.js +244 -0
  180. package/dist/api/helpers/agentUtils.d.ts +11 -0
  181. package/dist/api/helpers/agentUtils.js +23 -0
  182. package/dist/api/helpers/modelTokenLimits.d.ts +2 -0
  183. package/dist/api/helpers/modelTokenLimits.js +158 -0
  184. package/dist/api/helpers/observationalMemory.d.ts +10 -0
  185. package/dist/api/helpers/observationalMemory.js +36 -0
  186. package/dist/api/helpers/promptBudget.d.ts +30 -0
  187. package/dist/api/helpers/promptBudget.js +216 -0
  188. package/dist/api/helpers/resolveImageMessageParts.d.ts +9 -0
  189. package/dist/api/helpers/resolveImageMessageParts.js +140 -0
  190. package/dist/api/helpers/slashCommands.d.ts +31 -0
  191. package/dist/api/helpers/slashCommands.js +129 -0
  192. package/dist/api/helpers/tokenUsage.d.ts +19 -0
  193. package/dist/api/helpers/tokenUsage.js +81 -0
  194. package/dist/api/routes/fileRoutes.d.ts +2 -0
  195. package/dist/api/routes/fileRoutes.js +108 -0
  196. package/dist/api/routes/lspDocumentRoutes.d.ts +4 -0
  197. package/dist/api/routes/lspDocumentRoutes.js +84 -0
  198. package/dist/api/routes/lspHierarchyRoutes.d.ts +4 -0
  199. package/dist/api/routes/lspHierarchyRoutes.js +122 -0
  200. package/dist/api/routes/lspPositionRoutes.d.ts +4 -0
  201. package/dist/api/routes/lspPositionRoutes.js +263 -0
  202. package/dist/api/routes/lspQueryRoutes.d.ts +4 -0
  203. package/dist/api/routes/lspQueryRoutes.js +679 -0
  204. package/dist/api/routes/lspResolveRoutes.d.ts +4 -0
  205. package/dist/api/routes/lspResolveRoutes.js +143 -0
  206. package/dist/api/routes/lspSemanticDocumentRoutes.d.ts +4 -0
  207. package/dist/api/routes/lspSemanticDocumentRoutes.js +98 -0
  208. package/dist/api/routes/semanticRoutes.d.ts +2 -0
  209. package/dist/api/routes/semanticRoutes.js +126 -0
  210. package/dist/cli.d.ts +8 -0
  211. package/dist/cli.js +160 -0
  212. package/dist/index.d.ts +1 -0
  213. package/dist/index.js +1 -0
  214. package/dist/server.d.ts +2 -0
  215. package/dist/server.js +38 -0
  216. package/package.json +100 -0
@@ -0,0 +1,263 @@
1
+ import path from "path";
2
+ import { coreLsp } from "../core/library/lsp/coreLsp.js";
3
+ const resolveAbsolutePath = (workspacePath, filePath) => path.isAbsolute(filePath) ? filePath : path.join(workspacePath, filePath);
4
+ const normalizeLocationResults = (raw) => {
5
+ const rawLocations = (Array.isArray(raw) ? raw : raw ? [raw] : []);
6
+ return rawLocations.map((loc) => {
7
+ const uri = loc.uri || loc.targetUri || "";
8
+ const range = loc.range || loc.targetRange;
9
+ return {
10
+ filePath: uri.replace("file://", ""),
11
+ uri,
12
+ line: (range?.start?.line ?? 0) + 1,
13
+ character: (range?.start?.character ?? 0) + 1,
14
+ };
15
+ });
16
+ };
17
+ export const registerLspPositionRoutes = (router, requireDesktopAuth) => {
18
+ router.post("/lsp/hover", requireDesktopAuth, async (req, res) => {
19
+ try {
20
+ const { filePath, workspaceRoot, line, character } = req.body;
21
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
22
+ return res.status(400).json({ success: false, error: "filePath is required" });
23
+ }
24
+ if (typeof line !== "number" || typeof character !== "number") {
25
+ return res.status(400).json({ success: false, error: "line and character are required" });
26
+ }
27
+ const workspacePath = workspaceRoot || process.cwd();
28
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
29
+ coreLsp.setRootPath(workspacePath);
30
+ const result = await coreLsp.getHover(absolutePath, line, character);
31
+ return res.json({ success: true, hover: result });
32
+ }
33
+ catch (error) {
34
+ const err = error;
35
+ return res.status(500).json({ success: false, error: err.message || "Failed to get hover" });
36
+ }
37
+ });
38
+ router.post("/lsp/definition", requireDesktopAuth, async (req, res) => {
39
+ try {
40
+ const { filePath, workspaceRoot, line, character, text } = req.body;
41
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
42
+ return res.status(400).json({ success: false, error: "filePath is required" });
43
+ }
44
+ if (typeof line !== "number" || typeof character !== "number") {
45
+ return res.status(400).json({ success: false, error: "line and character are required" });
46
+ }
47
+ const workspacePath = workspaceRoot || process.cwd();
48
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
49
+ coreLsp.setRootPath(workspacePath);
50
+ const raw = await coreLsp.getDefinition(absolutePath, line, character, text);
51
+ const locations = normalizeLocationResults(raw);
52
+ return res.json({ success: true, locations });
53
+ }
54
+ catch (error) {
55
+ const err = error;
56
+ return res.status(500).json({ success: false, error: err.message || "Failed to get definition" });
57
+ }
58
+ });
59
+ router.post("/lsp/declaration", requireDesktopAuth, async (req, res) => {
60
+ try {
61
+ const { filePath, workspaceRoot, line, character, text } = req.body;
62
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
63
+ return res.status(400).json({ success: false, error: "filePath is required" });
64
+ }
65
+ if (typeof line !== "number" || typeof character !== "number") {
66
+ return res.status(400).json({ success: false, error: "line and character are required" });
67
+ }
68
+ const workspacePath = workspaceRoot || process.cwd();
69
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
70
+ coreLsp.setRootPath(workspacePath);
71
+ const raw = await coreLsp.getDeclaration(absolutePath, line, character, text);
72
+ const locations = normalizeLocationResults(raw);
73
+ return res.json({ success: true, locations });
74
+ }
75
+ catch (error) {
76
+ const err = error;
77
+ return res.status(500).json({ success: false, error: err.message || "Failed to get declaration" });
78
+ }
79
+ });
80
+ router.post("/lsp/type-definition", requireDesktopAuth, async (req, res) => {
81
+ try {
82
+ const { filePath, workspaceRoot, line, character } = req.body;
83
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
84
+ return res.status(400).json({ success: false, error: "filePath is required" });
85
+ }
86
+ if (typeof line !== "number" || typeof character !== "number") {
87
+ return res.status(400).json({ success: false, error: "line and character are required" });
88
+ }
89
+ const workspacePath = workspaceRoot || process.cwd();
90
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
91
+ coreLsp.setRootPath(workspacePath);
92
+ const raw = await coreLsp.getTypeDefinition(absolutePath, line, character);
93
+ const locations = normalizeLocationResults(raw);
94
+ return res.json({ success: true, locations });
95
+ }
96
+ catch (error) {
97
+ const err = error;
98
+ return res.status(500).json({
99
+ success: false,
100
+ error: err.message || "Failed to get type definition",
101
+ });
102
+ }
103
+ });
104
+ router.post("/lsp/implementation", requireDesktopAuth, async (req, res) => {
105
+ try {
106
+ const { filePath, workspaceRoot, line, character } = req.body;
107
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
108
+ return res.status(400).json({ success: false, error: "filePath is required" });
109
+ }
110
+ if (typeof line !== "number" || typeof character !== "number") {
111
+ return res.status(400).json({ success: false, error: "line and character are required" });
112
+ }
113
+ const workspacePath = workspaceRoot || process.cwd();
114
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
115
+ coreLsp.setRootPath(workspacePath);
116
+ const raw = await coreLsp.getImplementation(absolutePath, line, character);
117
+ const locations = normalizeLocationResults(raw);
118
+ return res.json({ success: true, locations });
119
+ }
120
+ catch (error) {
121
+ const err = error;
122
+ return res.status(500).json({
123
+ success: false,
124
+ error: err.message || "Failed to get implementation",
125
+ });
126
+ }
127
+ });
128
+ router.post("/lsp/references", requireDesktopAuth, async (req, res) => {
129
+ try {
130
+ const { filePath, workspaceRoot, line, character } = req.body;
131
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
132
+ return res.status(400).json({ success: false, error: "filePath is required" });
133
+ }
134
+ if (typeof line !== "number" || typeof character !== "number") {
135
+ return res.status(400).json({ success: false, error: "line and character are required" });
136
+ }
137
+ const workspacePath = workspaceRoot || process.cwd();
138
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
139
+ coreLsp.setRootPath(workspacePath);
140
+ const raw = (await coreLsp.getReferences(absolutePath, line, character));
141
+ const references = (raw || []).map((ref) => ({
142
+ filePath: (ref.uri || "").replace("file://", ""),
143
+ uri: ref.uri || "",
144
+ line: (ref.range?.start?.line ?? 0) + 1,
145
+ character: (ref.range?.start?.character ?? 0) + 1,
146
+ }));
147
+ return res.json({ success: true, count: references.length, references });
148
+ }
149
+ catch (error) {
150
+ const err = error;
151
+ return res.status(500).json({ success: false, error: err.message || "Failed to get references" });
152
+ }
153
+ });
154
+ router.post("/lsp/document-highlight", requireDesktopAuth, async (req, res) => {
155
+ try {
156
+ const { filePath, workspaceRoot, line, character } = req.body;
157
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
158
+ return res.status(400).json({ success: false, error: "filePath is required" });
159
+ }
160
+ if (typeof line !== "number" || typeof character !== "number") {
161
+ return res.status(400).json({ success: false, error: "line and character are required" });
162
+ }
163
+ const workspacePath = workspaceRoot || process.cwd();
164
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
165
+ coreLsp.setRootPath(workspacePath);
166
+ const highlights = await coreLsp.getDocumentHighlight(absolutePath, line, character);
167
+ return res.json({ success: true, highlights: Array.isArray(highlights) ? highlights : [] });
168
+ }
169
+ catch (error) {
170
+ const err = error;
171
+ return res.status(500).json({
172
+ success: false,
173
+ error: err.message || "Failed to get document highlights",
174
+ });
175
+ }
176
+ });
177
+ router.post("/lsp/moniker", requireDesktopAuth, async (req, res) => {
178
+ try {
179
+ const { filePath, workspaceRoot, line, character } = req.body;
180
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
181
+ return res.status(400).json({ success: false, error: "filePath is required" });
182
+ }
183
+ if (typeof line !== "number" || typeof character !== "number") {
184
+ return res.status(400).json({ success: false, error: "line and character are required" });
185
+ }
186
+ const workspacePath = workspaceRoot || process.cwd();
187
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
188
+ coreLsp.setRootPath(workspacePath);
189
+ const monikers = await coreLsp.getMoniker(absolutePath, line, character);
190
+ return res.json({ success: true, monikers: Array.isArray(monikers) ? monikers : [] });
191
+ }
192
+ catch (error) {
193
+ const err = error;
194
+ return res.status(500).json({ success: false, error: err.message || "Failed to get moniker" });
195
+ }
196
+ });
197
+ router.post("/lsp/completion", requireDesktopAuth, async (req, res) => {
198
+ try {
199
+ const { filePath, workspaceRoot, line, character } = req.body;
200
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
201
+ return res.status(400).json({ success: false, error: "filePath is required" });
202
+ }
203
+ if (typeof line !== "number" || typeof character !== "number") {
204
+ return res.status(400).json({ success: false, error: "line and character are required" });
205
+ }
206
+ const workspacePath = workspaceRoot || process.cwd();
207
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
208
+ coreLsp.setRootPath(workspacePath);
209
+ const completion = await coreLsp.getCompletion(absolutePath, line, character);
210
+ return res.json({ success: true, completion });
211
+ }
212
+ catch (error) {
213
+ const err = error;
214
+ return res.status(500).json({ success: false, error: err.message || "Failed to get completion" });
215
+ }
216
+ });
217
+ router.post("/lsp/selection-range", requireDesktopAuth, async (req, res) => {
218
+ try {
219
+ const { filePath, workspaceRoot, line, character } = req.body;
220
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
221
+ return res.status(400).json({ success: false, error: "filePath is required" });
222
+ }
223
+ if (typeof line !== "number" || typeof character !== "number") {
224
+ return res.status(400).json({ success: false, error: "line and character are required" });
225
+ }
226
+ const workspacePath = workspaceRoot || process.cwd();
227
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
228
+ coreLsp.setRootPath(workspacePath);
229
+ const ranges = await coreLsp.getSelectionRange(absolutePath, line, character);
230
+ return res.json({ success: true, ranges: Array.isArray(ranges) ? ranges : [] });
231
+ }
232
+ catch (error) {
233
+ const err = error;
234
+ return res.status(500).json({
235
+ success: false,
236
+ error: err.message || "Failed to get selection range",
237
+ });
238
+ }
239
+ });
240
+ router.post("/lsp/linked-editing-range", requireDesktopAuth, async (req, res) => {
241
+ try {
242
+ const { filePath, workspaceRoot, line, character } = req.body;
243
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
244
+ return res.status(400).json({ success: false, error: "filePath is required" });
245
+ }
246
+ if (typeof line !== "number" || typeof character !== "number") {
247
+ return res.status(400).json({ success: false, error: "line and character are required" });
248
+ }
249
+ const workspacePath = workspaceRoot || process.cwd();
250
+ const absolutePath = resolveAbsolutePath(workspacePath, filePath);
251
+ coreLsp.setRootPath(workspacePath);
252
+ const ranges = await coreLsp.getLinkedEditingRange(absolutePath, line, character);
253
+ return res.json({ success: true, ranges });
254
+ }
255
+ catch (error) {
256
+ const err = error;
257
+ return res.status(500).json({
258
+ success: false,
259
+ error: err.message || "Failed to get linked editing range",
260
+ });
261
+ }
262
+ });
263
+ };
@@ -0,0 +1,4 @@
1
+ import type { NextFunction, Request, Response, Router } from "express";
2
+ type AuthMiddleware = (req: Request, res: Response, next: NextFunction) => void;
3
+ export declare const registerLspQueryRoutes: (router: Router, requireDesktopAuth: AuthMiddleware) => void;
4
+ export {};