qlogicagent 0.2.1 → 0.4.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 (226) hide show
  1. package/README.md +45 -45
  2. package/package.json +56 -42
  3. package/dist/agent/agent.d.ts +0 -43
  4. package/dist/agent/agent.js +0 -113
  5. package/dist/agent/tool-loop.d.ts +0 -64
  6. package/dist/agent/tool-loop.js +0 -575
  7. package/dist/agent/types.d.ts +0 -175
  8. package/dist/agent/types.js +0 -14
  9. package/dist/cli/main.d.ts +0 -11
  10. package/dist/cli/main.js +0 -23
  11. package/dist/cli/stdio-server.d.ts +0 -45
  12. package/dist/cli/stdio-server.js +0 -463
  13. package/dist/config/config.d.ts +0 -17
  14. package/dist/config/config.js +0 -21
  15. package/dist/contracts/hooks.d.ts +0 -120
  16. package/dist/contracts/hooks.js +0 -7
  17. package/dist/contracts/index.d.ts +0 -10
  18. package/dist/contracts/index.js +0 -10
  19. package/dist/contracts/planner.d.ts +0 -35
  20. package/dist/contracts/planner.js +0 -2
  21. package/dist/contracts/skill-candidate.d.ts +0 -63
  22. package/dist/contracts/skill-candidate.js +0 -195
  23. package/dist/contracts/todo.d.ts +0 -14
  24. package/dist/contracts/todo.js +0 -9
  25. package/dist/index.d.ts +0 -13
  26. package/dist/index.js +0 -15
  27. package/dist/llm/builtin-providers.d.ts +0 -10
  28. package/dist/llm/builtin-providers.js +0 -531
  29. package/dist/llm/index.d.ts +0 -15
  30. package/dist/llm/index.js +0 -14
  31. package/dist/llm/llm-client.d.ts +0 -43
  32. package/dist/llm/llm-client.js +0 -67
  33. package/dist/llm/model-catalog.d.ts +0 -53
  34. package/dist/llm/model-catalog.js +0 -191
  35. package/dist/llm/provider-def.d.ts +0 -59
  36. package/dist/llm/provider-def.js +0 -12
  37. package/dist/llm/provider-registry.d.ts +0 -54
  38. package/dist/llm/provider-registry.js +0 -147
  39. package/dist/llm/transport.d.ts +0 -62
  40. package/dist/llm/transport.js +0 -27
  41. package/dist/llm/transports/anthropic-messages.d.ts +0 -31
  42. package/dist/llm/transports/anthropic-messages.js +0 -293
  43. package/dist/llm/transports/openai-chat.d.ts +0 -36
  44. package/dist/llm/transports/openai-chat.js +0 -165
  45. package/dist/orchestration/agent-registry.d.ts +0 -41
  46. package/dist/orchestration/agent-registry.js +0 -116
  47. package/dist/orchestration/approval-aware-tool-plan.d.ts +0 -32
  48. package/dist/orchestration/approval-aware-tool-plan.js +0 -87
  49. package/dist/orchestration/context-compression.d.ts +0 -220
  50. package/dist/orchestration/context-compression.js +0 -583
  51. package/dist/orchestration/conversation-repair.d.ts +0 -61
  52. package/dist/orchestration/conversation-repair.js +0 -429
  53. package/dist/orchestration/curator-scheduler.d.ts +0 -119
  54. package/dist/orchestration/curator-scheduler.js +0 -135
  55. package/dist/orchestration/embedded-failover-policy.d.ts +0 -110
  56. package/dist/orchestration/embedded-failover-policy.js +0 -168
  57. package/dist/orchestration/error-classification.d.ts +0 -12
  58. package/dist/orchestration/error-classification.js +0 -77
  59. package/dist/orchestration/failover-classification.d.ts +0 -8
  60. package/dist/orchestration/failover-classification.js +0 -381
  61. package/dist/orchestration/failover-error.d.ts +0 -33
  62. package/dist/orchestration/failover-error.js +0 -198
  63. package/dist/orchestration/fork-subagent.d.ts +0 -100
  64. package/dist/orchestration/fork-subagent.js +0 -98
  65. package/dist/orchestration/index.d.ts +0 -120
  66. package/dist/orchestration/index.js +0 -267
  67. package/dist/orchestration/memory-flush-policy.d.ts +0 -57
  68. package/dist/orchestration/memory-flush-policy.js +0 -85
  69. package/dist/orchestration/memory-provider.d.ts +0 -14
  70. package/dist/orchestration/memory-provider.js +0 -2
  71. package/dist/orchestration/parallel-tool-calls.d.ts +0 -41
  72. package/dist/orchestration/parallel-tool-calls.js +0 -59
  73. package/dist/orchestration/prompt-cache-strategy.d.ts +0 -126
  74. package/dist/orchestration/prompt-cache-strategy.js +0 -228
  75. package/dist/orchestration/reactive-compact.d.ts +0 -73
  76. package/dist/orchestration/reactive-compact.js +0 -78
  77. package/dist/orchestration/retry-loop.d.ts +0 -22
  78. package/dist/orchestration/retry-loop.js +0 -24
  79. package/dist/orchestration/skill-candidate.d.ts +0 -52
  80. package/dist/orchestration/skill-candidate.js +0 -141
  81. package/dist/orchestration/skill-consolidation.d.ts +0 -123
  82. package/dist/orchestration/skill-consolidation.js +0 -220
  83. package/dist/orchestration/skill-improvement.d.ts +0 -59
  84. package/dist/orchestration/skill-improvement.js +0 -66
  85. package/dist/orchestration/skill-similarity.d.ts +0 -98
  86. package/dist/orchestration/skill-similarity.js +0 -131
  87. package/dist/orchestration/streaming-tool-executor.d.ts +0 -73
  88. package/dist/orchestration/streaming-tool-executor.js +0 -96
  89. package/dist/orchestration/team-orchestration.d.ts +0 -195
  90. package/dist/orchestration/team-orchestration.js +0 -369
  91. package/dist/orchestration/team-tool-loop-wiring.d.ts +0 -92
  92. package/dist/orchestration/team-tool-loop-wiring.js +0 -147
  93. package/dist/orchestration/tool-choice-policy.d.ts +0 -54
  94. package/dist/orchestration/tool-choice-policy.js +0 -164
  95. package/dist/orchestration/tool-loop-state.d.ts +0 -50
  96. package/dist/orchestration/tool-loop-state.js +0 -133
  97. package/dist/orchestration/tool-schema.d.ts +0 -39
  98. package/dist/orchestration/tool-schema.js +0 -297
  99. package/dist/orchestration/transcript-repair.d.ts +0 -42
  100. package/dist/orchestration/transcript-repair.js +0 -426
  101. package/dist/orchestration/turn-loop-guard.d.ts +0 -86
  102. package/dist/orchestration/turn-loop-guard.js +0 -92
  103. package/dist/orchestration/web-browser-policy.d.ts +0 -17
  104. package/dist/orchestration/web-browser-policy.js +0 -39
  105. package/dist/runtime/context-compression.d.ts +0 -61
  106. package/dist/runtime/context-compression.js +0 -274
  107. package/dist/runtime/hook-registry.d.ts +0 -12
  108. package/dist/runtime/hook-registry.js +0 -53
  109. package/dist/runtime/memory-hooks.d.ts +0 -23
  110. package/dist/runtime/memory-hooks.js +0 -65
  111. package/dist/runtime/tool-eligibility.d.ts +0 -59
  112. package/dist/runtime/tool-eligibility.js +0 -111
  113. package/dist/skills/index.d.ts +0 -108
  114. package/dist/skills/index.js +0 -82
  115. package/dist/skills/memory-extractor.d.ts +0 -64
  116. package/dist/skills/memory-extractor.js +0 -173
  117. package/dist/skills/memory-query-tool.d.ts +0 -43
  118. package/dist/skills/memory-query-tool.js +0 -127
  119. package/dist/skills/memory-store.d.ts +0 -66
  120. package/dist/skills/memory-store.js +0 -228
  121. package/dist/skills/memory-tool.d.ts +0 -67
  122. package/dist/skills/memory-tool.js +0 -192
  123. package/dist/skills/portable-tool.d.ts +0 -71
  124. package/dist/skills/portable-tool.js +0 -14
  125. package/dist/skills/qmemory-adapter.d.ts +0 -52
  126. package/dist/skills/qmemory-adapter.js +0 -165
  127. package/dist/skills/skill-frontmatter.d.ts +0 -19
  128. package/dist/skills/skill-frontmatter.js +0 -344
  129. package/dist/skills/skill-guard.d.ts +0 -23
  130. package/dist/skills/skill-guard.js +0 -229
  131. package/dist/skills/skill-loader.d.ts +0 -16
  132. package/dist/skills/skill-loader.js +0 -303
  133. package/dist/skills/skill-source.d.ts +0 -119
  134. package/dist/skills/skill-source.js +0 -126
  135. package/dist/skills/skill-types.d.ts +0 -199
  136. package/dist/skills/skill-types.js +0 -6
  137. package/dist/skills/think-tool.d.ts +0 -16
  138. package/dist/skills/think-tool.js +0 -59
  139. package/dist/skills/todo-tool.d.ts +0 -63
  140. package/dist/skills/todo-tool.js +0 -114
  141. package/dist/skills/tools/agent-tool.d.ts +0 -91
  142. package/dist/skills/tools/agent-tool.js +0 -142
  143. package/dist/skills/tools/apply-patch-tool.d.ts +0 -29
  144. package/dist/skills/tools/apply-patch-tool.js +0 -184
  145. package/dist/skills/tools/ask-user-tool.d.ts +0 -80
  146. package/dist/skills/tools/ask-user-tool.js +0 -121
  147. package/dist/skills/tools/brief-tool.d.ts +0 -74
  148. package/dist/skills/tools/brief-tool.js +0 -95
  149. package/dist/skills/tools/browser-tool.d.ts +0 -114
  150. package/dist/skills/tools/browser-tool.js +0 -155
  151. package/dist/skills/tools/checkpoint-tool.d.ts +0 -66
  152. package/dist/skills/tools/checkpoint-tool.js +0 -102
  153. package/dist/skills/tools/config-tool.d.ts +0 -63
  154. package/dist/skills/tools/config-tool.js +0 -143
  155. package/dist/skills/tools/cron-tool.d.ts +0 -116
  156. package/dist/skills/tools/cron-tool.js +0 -175
  157. package/dist/skills/tools/edit-tool.d.ts +0 -43
  158. package/dist/skills/tools/edit-tool.js +0 -70
  159. package/dist/skills/tools/exec-tool.d.ts +0 -102
  160. package/dist/skills/tools/exec-tool.js +0 -133
  161. package/dist/skills/tools/image-generate-tool.d.ts +0 -62
  162. package/dist/skills/tools/image-generate-tool.js +0 -67
  163. package/dist/skills/tools/instructions-tool.d.ts +0 -103
  164. package/dist/skills/tools/instructions-tool.js +0 -187
  165. package/dist/skills/tools/lsp-tool.d.ts +0 -153
  166. package/dist/skills/tools/lsp-tool.js +0 -227
  167. package/dist/skills/tools/mcp-client-types.d.ts +0 -269
  168. package/dist/skills/tools/mcp-client-types.js +0 -53
  169. package/dist/skills/tools/mcp-tool.d.ts +0 -249
  170. package/dist/skills/tools/mcp-tool.js +0 -503
  171. package/dist/skills/tools/memory-tool.d.ts +0 -74
  172. package/dist/skills/tools/memory-tool.js +0 -88
  173. package/dist/skills/tools/monitor-tool.d.ts +0 -113
  174. package/dist/skills/tools/monitor-tool.js +0 -131
  175. package/dist/skills/tools/music-generate-tool.d.ts +0 -55
  176. package/dist/skills/tools/music-generate-tool.js +0 -62
  177. package/dist/skills/tools/notify-tool.d.ts +0 -53
  178. package/dist/skills/tools/notify-tool.js +0 -62
  179. package/dist/skills/tools/patch-tool.d.ts +0 -45
  180. package/dist/skills/tools/patch-tool.js +0 -505
  181. package/dist/skills/tools/pdf-tool.d.ts +0 -66
  182. package/dist/skills/tools/pdf-tool.js +0 -88
  183. package/dist/skills/tools/plan-mode-tool.d.ts +0 -59
  184. package/dist/skills/tools/plan-mode-tool.js +0 -122
  185. package/dist/skills/tools/read-tool.d.ts +0 -51
  186. package/dist/skills/tools/read-tool.js +0 -84
  187. package/dist/skills/tools/repl-tool.d.ts +0 -70
  188. package/dist/skills/tools/repl-tool.js +0 -69
  189. package/dist/skills/tools/search-tool.d.ts +0 -112
  190. package/dist/skills/tools/search-tool.js +0 -225
  191. package/dist/skills/tools/send-message-tool.d.ts +0 -51
  192. package/dist/skills/tools/send-message-tool.js +0 -76
  193. package/dist/skills/tools/skill-list-tool.d.ts +0 -33
  194. package/dist/skills/tools/skill-list-tool.js +0 -54
  195. package/dist/skills/tools/skill-manage-tool.d.ts +0 -73
  196. package/dist/skills/tools/skill-manage-tool.js +0 -153
  197. package/dist/skills/tools/skill-view-tool.d.ts +0 -37
  198. package/dist/skills/tools/skill-view-tool.js +0 -72
  199. package/dist/skills/tools/sleep-tool.d.ts +0 -49
  200. package/dist/skills/tools/sleep-tool.js +0 -81
  201. package/dist/skills/tools/structured-output-tool.d.ts +0 -116
  202. package/dist/skills/tools/structured-output-tool.js +0 -176
  203. package/dist/skills/tools/task-tool.d.ts +0 -104
  204. package/dist/skills/tools/task-tool.js +0 -161
  205. package/dist/skills/tools/team-tool.d.ts +0 -89
  206. package/dist/skills/tools/team-tool.js +0 -105
  207. package/dist/skills/tools/tool-search-tool.d.ts +0 -51
  208. package/dist/skills/tools/tool-search-tool.js +0 -110
  209. package/dist/skills/tools/tts-tool.d.ts +0 -38
  210. package/dist/skills/tools/tts-tool.js +0 -45
  211. package/dist/skills/tools/video-edit-tool.d.ts +0 -69
  212. package/dist/skills/tools/video-edit-tool.js +0 -74
  213. package/dist/skills/tools/video-generate-tool.d.ts +0 -62
  214. package/dist/skills/tools/video-generate-tool.js +0 -66
  215. package/dist/skills/tools/video-merge-tool.d.ts +0 -105
  216. package/dist/skills/tools/video-merge-tool.js +0 -92
  217. package/dist/skills/tools/video-upscale-tool.d.ts +0 -45
  218. package/dist/skills/tools/video-upscale-tool.js +0 -52
  219. package/dist/skills/tools/web-fetch-tool.d.ts +0 -78
  220. package/dist/skills/tools/web-fetch-tool.js +0 -92
  221. package/dist/skills/tools/web-search-tool.d.ts +0 -57
  222. package/dist/skills/tools/web-search-tool.js +0 -86
  223. package/dist/skills/tools/worktree-tool.d.ts +0 -69
  224. package/dist/skills/tools/worktree-tool.js +0 -147
  225. package/dist/skills/tools/write-tool.d.ts +0 -45
  226. package/dist/skills/tools/write-tool.js +0 -81
@@ -1,153 +0,0 @@
1
- import type { PortableTool } from "../portable-tool.js";
2
- export declare const LSP_TOOL_NAME: "lsp";
3
- export type LspOperation = "goToDefinition" | "findReferences" | "hover" | "documentSymbol" | "diagnostics" | "completion" | "signatureHelp" | "rename" | "codeAction";
4
- export interface LspToolParams {
5
- /** LSP operation to perform */
6
- operation: LspOperation;
7
- /** File path (absolute or relative to workspace root) */
8
- filePath: string;
9
- /** Line number (1-indexed) */
10
- line?: number;
11
- /** Character position (1-indexed) */
12
- character?: number;
13
- /** New name (for rename operation) */
14
- newName?: string;
15
- /** Include context lines around results */
16
- includeContext?: boolean;
17
- }
18
- export declare const LSP_TOOL_SCHEMA: {
19
- readonly type: "object";
20
- readonly properties: {
21
- readonly operation: {
22
- readonly type: "string";
23
- readonly enum: readonly ["goToDefinition", "findReferences", "hover", "documentSymbol", "diagnostics", "completion", "signatureHelp", "rename", "codeAction"];
24
- readonly description: string;
25
- };
26
- readonly filePath: {
27
- readonly type: "string";
28
- readonly description: "File path. Absolute or relative to workspace root.";
29
- };
30
- readonly line: {
31
- readonly type: "number";
32
- readonly description: "Line number (1-indexed). Required for positional operations.";
33
- };
34
- readonly character: {
35
- readonly type: "number";
36
- readonly description: "Character position (1-indexed). Required for positional operations.";
37
- };
38
- readonly newName: {
39
- readonly type: "string";
40
- readonly description: "New name for rename operation.";
41
- };
42
- readonly includeContext: {
43
- readonly type: "boolean";
44
- readonly description: "Include surrounding code context in results (default: true).";
45
- };
46
- };
47
- readonly required: readonly ["operation", "filePath"];
48
- };
49
- export interface LspLocation {
50
- filePath: string;
51
- line: number;
52
- character: number;
53
- endLine?: number;
54
- endCharacter?: number;
55
- context?: string;
56
- }
57
- export interface LspSymbol {
58
- name: string;
59
- kind: string;
60
- range: {
61
- startLine: number;
62
- endLine: number;
63
- };
64
- children?: LspSymbol[];
65
- }
66
- export interface LspDiagnostic {
67
- message: string;
68
- severity: "error" | "warning" | "info" | "hint";
69
- line: number;
70
- character: number;
71
- source?: string;
72
- code?: string | number;
73
- }
74
- export interface LspHoverInfo {
75
- contents: string;
76
- range?: {
77
- startLine: number;
78
- startCharacter: number;
79
- endLine: number;
80
- endCharacter: number;
81
- };
82
- }
83
- export interface LspCompletion {
84
- label: string;
85
- kind: string;
86
- detail?: string;
87
- insertText?: string;
88
- }
89
- export interface LspRenameEdit {
90
- filePath: string;
91
- edits: Array<{
92
- line: number;
93
- character: number;
94
- endLine: number;
95
- endCharacter: number;
96
- newText: string;
97
- }>;
98
- }
99
- export interface LspCodeAction {
100
- title: string;
101
- kind?: string;
102
- isPreferred?: boolean;
103
- }
104
- export type LspResult = {
105
- type: "locations";
106
- locations: LspLocation[];
107
- } | {
108
- type: "symbols";
109
- symbols: LspSymbol[];
110
- } | {
111
- type: "diagnostics";
112
- diagnostics: LspDiagnostic[];
113
- } | {
114
- type: "hover";
115
- hover: LspHoverInfo | null;
116
- } | {
117
- type: "completions";
118
- completions: LspCompletion[];
119
- } | {
120
- type: "rename";
121
- edits: LspRenameEdit[];
122
- } | {
123
- type: "codeActions";
124
- actions: LspCodeAction[];
125
- } | {
126
- type: "signatureHelp";
127
- signatures: string[];
128
- };
129
- /**
130
- * Host-provided LSP backend.
131
- * The host manages language server lifecycle and connections.
132
- */
133
- export interface LspToolDeps {
134
- /** Execute an LSP operation. Host dispatches to appropriate language server. */
135
- executeOperation(params: {
136
- operation: LspOperation;
137
- filePath: string;
138
- line?: number;
139
- character?: number;
140
- newName?: string;
141
- includeContext?: boolean;
142
- }): Promise<LspResult>;
143
- /** Check if file exists and get its size */
144
- statFile?(filePath: string): Promise<{
145
- exists: boolean;
146
- size: number;
147
- } | null>;
148
- /** Resolve relative path to absolute */
149
- resolvePath(filePath: string): string;
150
- /** List supported language IDs (e.g. ['typescript', 'python', 'rust']) */
151
- supportedLanguages?(): string[];
152
- }
153
- export declare function createLspTool(deps: LspToolDeps): PortableTool<LspToolParams>;
@@ -1,227 +0,0 @@
1
- // ============================================================
2
- // LSP Tool — Language Server Protocol code intelligence.
3
- // Reference: claude-code-haha/src/tools/LSPTool/LSPTool.ts
4
- // Category: coding (read-only)
5
- // ============================================================
6
- export const LSP_TOOL_NAME = "lsp";
7
- export const LSP_TOOL_SCHEMA = {
8
- type: "object",
9
- properties: {
10
- operation: {
11
- type: "string",
12
- enum: [
13
- "goToDefinition",
14
- "findReferences",
15
- "hover",
16
- "documentSymbol",
17
- "diagnostics",
18
- "completion",
19
- "signatureHelp",
20
- "rename",
21
- "codeAction",
22
- ],
23
- description: "LSP operation:\n" +
24
- "- goToDefinition: jump to symbol definition\n" +
25
- "- findReferences: find all usages of a symbol\n" +
26
- "- hover: get type/docs for symbol at position\n" +
27
- "- documentSymbol: list all symbols in file (classes, functions, etc)\n" +
28
- "- diagnostics: get errors/warnings for a file\n" +
29
- "- completion: get completions at position\n" +
30
- "- signatureHelp: get function signature at call site\n" +
31
- "- rename: preview rename of symbol\n" +
32
- "- codeAction: get available quick-fixes/refactorings",
33
- },
34
- filePath: {
35
- type: "string",
36
- description: "File path. Absolute or relative to workspace root.",
37
- },
38
- line: {
39
- type: "number",
40
- description: "Line number (1-indexed). Required for positional operations.",
41
- },
42
- character: {
43
- type: "number",
44
- description: "Character position (1-indexed). Required for positional operations.",
45
- },
46
- newName: {
47
- type: "string",
48
- description: "New name for rename operation.",
49
- },
50
- includeContext: {
51
- type: "boolean",
52
- description: "Include surrounding code context in results (default: true).",
53
- },
54
- },
55
- required: ["operation", "filePath"],
56
- };
57
- // ── Dependencies ────────────────────────────────────────────
58
- const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
59
- // Positional operations require line and character
60
- const POSITIONAL_OPS = [
61
- "goToDefinition",
62
- "findReferences",
63
- "hover",
64
- "completion",
65
- "signatureHelp",
66
- "rename",
67
- "codeAction",
68
- ];
69
- export function createLspTool(deps) {
70
- return {
71
- name: LSP_TOOL_NAME,
72
- label: "LSP",
73
- description: "Query language servers for code intelligence. Supports go-to-definition, find-references, " +
74
- "hover (type info), document symbols, diagnostics (errors/warnings), completions, " +
75
- "signature help, rename preview, and code actions. Read-only — does not modify files.",
76
- parameters: LSP_TOOL_SCHEMA,
77
- execute: async (_toolCallId, params) => {
78
- if (!params.filePath || params.filePath.trim().length === 0) {
79
- return {
80
- content: [{ type: "text", text: "Error: filePath is required." }],
81
- details: { type: "lsp", error: "missing_filePath" },
82
- };
83
- }
84
- // Block UNC paths (NTLM credential leak risk on Windows)
85
- if (params.filePath.startsWith("\\\\") || params.filePath.startsWith("//")) {
86
- return {
87
- content: [{ type: "text", text: "Error: UNC paths are not allowed." }],
88
- details: { type: "lsp", error: "unc_blocked" },
89
- };
90
- }
91
- // Validate positional params
92
- if (POSITIONAL_OPS.includes(params.operation)) {
93
- if (params.line == null || params.character == null) {
94
- return {
95
- content: [{ type: "text", text: `Error: line and character are required for ${params.operation}.` }],
96
- details: { type: "lsp", error: "missing_position" },
97
- };
98
- }
99
- if (params.line < 1 || params.character < 1) {
100
- return {
101
- content: [{ type: "text", text: "Error: line and character must be ≥ 1." }],
102
- details: { type: "lsp", error: "invalid_position" },
103
- };
104
- }
105
- }
106
- // Rename requires newName
107
- if (params.operation === "rename" && !params.newName) {
108
- return {
109
- content: [{ type: "text", text: "Error: newName is required for rename operation." }],
110
- details: { type: "lsp", error: "missing_newName" },
111
- };
112
- }
113
- const resolved = deps.resolvePath(params.filePath);
114
- // File size check
115
- if (deps.statFile) {
116
- const stat = await deps.statFile(resolved);
117
- if (!stat || !stat.exists) {
118
- return {
119
- content: [{ type: "text", text: `Error: file not found: ${params.filePath}` }],
120
- details: { type: "lsp", error: "file_not_found" },
121
- };
122
- }
123
- if (stat.size > MAX_FILE_SIZE) {
124
- return {
125
- content: [{ type: "text", text: `Error: file too large (${(stat.size / 1024 / 1024).toFixed(1)}MB, max 10MB).` }],
126
- details: { type: "lsp", error: "file_too_large" },
127
- };
128
- }
129
- }
130
- const result = await deps.executeOperation({
131
- operation: params.operation,
132
- filePath: resolved,
133
- line: params.line,
134
- character: params.character,
135
- newName: params.newName,
136
- includeContext: params.includeContext ?? true,
137
- });
138
- return { content: [{ type: "text", text: formatLspResult(params.operation, result) }], details: { type: "lsp", operation: params.operation } };
139
- },
140
- };
141
- }
142
- // ── Output formatting ───────────────────────────────────────
143
- function formatLspResult(operation, result) {
144
- switch (result.type) {
145
- case "locations": {
146
- if (result.locations.length === 0)
147
- return "No results found.";
148
- const lines = [`Found ${result.locations.length} location(s):`, ""];
149
- for (const loc of result.locations.slice(0, 50)) {
150
- lines.push(` ${loc.filePath}:${loc.line}:${loc.character}`);
151
- if (loc.context)
152
- lines.push(` ${loc.context.trim()}`);
153
- }
154
- if (result.locations.length > 50)
155
- lines.push(` ... and ${result.locations.length - 50} more`);
156
- return lines.join("\n");
157
- }
158
- case "symbols": {
159
- if (result.symbols.length === 0)
160
- return "No symbols found.";
161
- const lines = [`Document symbols (${result.symbols.length}):`, ""];
162
- for (const sym of result.symbols) {
163
- lines.push(` ${sym.kind} ${sym.name} (L${sym.range.startLine}-${sym.range.endLine})`);
164
- if (sym.children) {
165
- for (const child of sym.children.slice(0, 10)) {
166
- lines.push(` ${child.kind} ${child.name} (L${child.range.startLine})`);
167
- }
168
- if (sym.children.length > 10)
169
- lines.push(` ... and ${sym.children.length - 10} more`);
170
- }
171
- }
172
- return lines.join("\n");
173
- }
174
- case "diagnostics": {
175
- if (result.diagnostics.length === 0)
176
- return "No diagnostics (clean file).";
177
- const lines = [`Diagnostics (${result.diagnostics.length}):`, ""];
178
- for (const d of result.diagnostics) {
179
- const icon = d.severity === "error" ? "❌" : d.severity === "warning" ? "⚠️" : "ℹ️";
180
- lines.push(` ${icon} L${d.line}:${d.character} [${d.source || ""}${d.code ? `:${d.code}` : ""}] ${d.message}`);
181
- }
182
- return lines.join("\n");
183
- }
184
- case "hover": {
185
- if (!result.hover)
186
- return "No hover information available.";
187
- return result.hover.contents;
188
- }
189
- case "completions": {
190
- if (result.completions.length === 0)
191
- return "No completions available.";
192
- const lines = [`Completions (${result.completions.length}):`, ""];
193
- for (const c of result.completions.slice(0, 20)) {
194
- lines.push(` [${c.kind}] ${c.label}${c.detail ? ` — ${c.detail}` : ""}`);
195
- }
196
- if (result.completions.length > 20)
197
- lines.push(` ... and ${result.completions.length - 20} more`);
198
- return lines.join("\n");
199
- }
200
- case "signatureHelp": {
201
- if (result.signatures.length === 0)
202
- return "No signature information available.";
203
- return result.signatures.join("\n");
204
- }
205
- case "rename": {
206
- if (result.edits.length === 0)
207
- return "No edits generated for rename.";
208
- const total = result.edits.reduce((sum, f) => sum + f.edits.length, 0);
209
- const lines = [`Rename would affect ${total} location(s) in ${result.edits.length} file(s):`, ""];
210
- for (const file of result.edits) {
211
- lines.push(` ${file.filePath} (${file.edits.length} edits)`);
212
- }
213
- return lines.join("\n");
214
- }
215
- case "codeActions": {
216
- if (result.actions.length === 0)
217
- return "No code actions available.";
218
- const lines = [`Available code actions (${result.actions.length}):`, ""];
219
- for (const a of result.actions) {
220
- lines.push(` ${a.isPreferred ? "★" : "-"} ${a.title}${a.kind ? ` [${a.kind}]` : ""}`);
221
- }
222
- return lines.join("\n");
223
- }
224
- default:
225
- return "Unknown result type.";
226
- }
227
- }
@@ -1,269 +0,0 @@
1
- /** Supported MCP transport types */
2
- export type McpTransportType = "stdio" | "sse" | "http" | "ws" | "in-process";
3
- /** Stdio transport configuration */
4
- export interface McpStdioConfig {
5
- type: "stdio";
6
- command: string;
7
- args?: string[];
8
- env?: Record<string, string>;
9
- cwd?: string;
10
- }
11
- /** SSE transport configuration */
12
- export interface McpSseConfig {
13
- type: "sse";
14
- url: string;
15
- headers?: Record<string, string>;
16
- /** OAuth config for auth-required SSE servers */
17
- oauth?: McpOAuthConfig;
18
- }
19
- /** Streamable HTTP transport configuration (MCP 2025-03-26) */
20
- export interface McpHttpConfig {
21
- type: "http";
22
- url: string;
23
- headers?: Record<string, string>;
24
- /** OAuth config for auth-required HTTP servers */
25
- oauth?: McpOAuthConfig;
26
- }
27
- /** WebSocket transport configuration */
28
- export interface McpWsConfig {
29
- type: "ws";
30
- url: string;
31
- headers?: Record<string, string>;
32
- }
33
- /** In-process transport (bundled MCP servers) */
34
- export interface McpInProcessConfig {
35
- type: "in-process";
36
- /** Module identifier to load */
37
- moduleId: string;
38
- /** Init args passed to the in-process server */
39
- initArgs?: Record<string, unknown>;
40
- }
41
- /** Union of all transport configurations */
42
- export type McpServerConfig = McpStdioConfig | McpSseConfig | McpHttpConfig | McpWsConfig | McpInProcessConfig;
43
- /** OAuth configuration for remote MCP servers */
44
- export interface McpOAuthConfig {
45
- /** Client ID (or URL-based client_id per CIMD/SEP-991) */
46
- clientId?: string;
47
- /** Client secret (optional, for confidential clients) */
48
- clientSecret?: string;
49
- /** Override authorization endpoint (otherwise discovered via RFC 8414) */
50
- authorizationEndpoint?: string;
51
- /** Override token endpoint */
52
- tokenEndpoint?: string;
53
- /** Requested scopes */
54
- scopes?: string[];
55
- /** Fixed callback port (otherwise picks random available port) */
56
- callbackPort?: number;
57
- /** Audience for token exchange (RFC 8693) */
58
- audience?: string;
59
- }
60
- /** OAuth token set */
61
- export interface McpOAuthTokens {
62
- accessToken: string;
63
- tokenType: string;
64
- refreshToken?: string;
65
- expiresAt?: number;
66
- scope?: string;
67
- }
68
- /** Authentication state of a server */
69
- export type McpAuthState = {
70
- status: "authenticated";
71
- tokens: McpOAuthTokens;
72
- } | {
73
- status: "needs-auth";
74
- authUrl?: string;
75
- message?: string;
76
- } | {
77
- status: "refreshing";
78
- } | {
79
- status: "step-up-required";
80
- scope: string;
81
- authUrl?: string;
82
- } | {
83
- status: "not-applicable";
84
- };
85
- /** Server connection status */
86
- export type McpConnectionStatus = "connected" | "connecting" | "disconnected" | "failed" | "needs-auth" | "disabled";
87
- /** Server capabilities (as reported by initialize) */
88
- export interface McpServerCapabilities {
89
- tools?: {
90
- listChanged?: boolean;
91
- };
92
- resources?: {
93
- subscribe?: boolean;
94
- listChanged?: boolean;
95
- };
96
- prompts?: {
97
- listChanged?: boolean;
98
- };
99
- logging?: Record<string, unknown>;
100
- experimental?: Record<string, unknown>;
101
- }
102
- /** Full server connection state */
103
- export interface McpServerState {
104
- name: string;
105
- config: McpServerConfig;
106
- status: McpConnectionStatus;
107
- capabilities?: McpServerCapabilities;
108
- serverVersion?: string;
109
- serverInstructions?: string;
110
- error?: string;
111
- /** Timestamp of last successful connection */
112
- connectedAt?: number;
113
- /** Number of reconnect attempts since last disconnect */
114
- reconnectAttempts?: number;
115
- }
116
- /**
117
- * An MCP tool definition as reported by tools/list.
118
- * The host converts these into PortableTool entries for the LLM.
119
- */
120
- export interface McpExternalTool {
121
- /** Tool name on the MCP server (original) */
122
- name: string;
123
- /** Tool description */
124
- description?: string;
125
- /** JSON Schema for input parameters */
126
- inputSchema?: Record<string, unknown>;
127
- /** Annotations from the server (readOnlyHint, destructiveHint, etc.) */
128
- annotations?: McpToolAnnotations;
129
- }
130
- /** Tool behavior annotations (MCP 2025-03-26 spec) */
131
- export interface McpToolAnnotations {
132
- /** Hints that the tool performs only reads */
133
- readOnlyHint?: boolean;
134
- /** Hints that the tool may be destructive */
135
- destructiveHint?: boolean;
136
- /** Hints that the tool is idempotent */
137
- idempotentHint?: boolean;
138
- /** Hints about concurrency safety */
139
- openWorldHint?: boolean;
140
- /** Human-readable title for UI display */
141
- title?: string;
142
- }
143
- /**
144
- * Prefixed tool name format: mcp__{normalizedServer}__{normalizedTool}
145
- * This ensures no collisions with built-in tools.
146
- */
147
- export interface McpToolIdentifier {
148
- serverName: string;
149
- toolName: string;
150
- /** Full prefixed name: mcp__{server}__{tool} */
151
- prefixedName: string;
152
- }
153
- /**
154
- * Notification payload when a server's tool list changes.
155
- * The host should re-fetch tools/list and hot-swap the tool set.
156
- */
157
- export interface McpToolsChangedEvent {
158
- serverName: string;
159
- /** Previous tool names (for diff-based cleanup) */
160
- previousTools: string[];
161
- /** Updated tool list */
162
- currentTools: McpExternalTool[];
163
- }
164
- /** MCP Resource definition */
165
- export interface McpResourceDefinition {
166
- uri: string;
167
- name: string;
168
- mimeType?: string;
169
- description?: string;
170
- /** Size in bytes (if known) */
171
- size?: number;
172
- }
173
- /** Resource template (parameterized URI) */
174
- export interface McpResourceTemplate {
175
- uriTemplate: string;
176
- name: string;
177
- mimeType?: string;
178
- description?: string;
179
- }
180
- /** Content of a read resource */
181
- export interface McpResourceContentItem {
182
- uri: string;
183
- mimeType?: string;
184
- /** Text content (mutually exclusive with blob) */
185
- text?: string;
186
- /** Base64-encoded binary (mutually exclusive with text) */
187
- blob?: string;
188
- }
189
- /** Persisted resource content (after binary blob handling) */
190
- export interface McpPersistedResourceContent {
191
- uri: string;
192
- mimeType?: string;
193
- text?: string;
194
- /** Path where binary was saved to disk */
195
- blobSavedTo?: string;
196
- /** Size of persisted binary in bytes */
197
- blobSize?: number;
198
- }
199
- /** MCP Prompt definition from prompts/list */
200
- export interface McpPromptDefinition {
201
- name: string;
202
- description?: string;
203
- arguments?: McpPromptArgument[];
204
- }
205
- /** Argument for an MCP prompt */
206
- export interface McpPromptArgument {
207
- name: string;
208
- description?: string;
209
- required?: boolean;
210
- }
211
- /** Result of prompts/get — prompt content messages */
212
- export interface McpPromptMessage {
213
- role: "user" | "assistant";
214
- content: McpPromptContent;
215
- }
216
- export type McpPromptContent = {
217
- type: "text";
218
- text: string;
219
- } | {
220
- type: "image";
221
- data: string;
222
- mimeType: string;
223
- } | {
224
- type: "resource";
225
- resource: {
226
- uri: string;
227
- text?: string;
228
- blob?: string;
229
- mimeType?: string;
230
- };
231
- };
232
- /** MCP Elicitation request (server asks user for input) */
233
- export interface McpElicitRequest {
234
- message: string;
235
- requestedSchema?: Record<string, unknown>;
236
- }
237
- /** Elicitation response */
238
- export interface McpElicitResult {
239
- action: "accept" | "deny" | "cancel";
240
- content?: Record<string, unknown>;
241
- }
242
- export type McpLogLevel = "debug" | "info" | "warning" | "error" | "critical";
243
- export interface McpLogEntry {
244
- serverName: string;
245
- level: McpLogLevel;
246
- logger?: string;
247
- data: unknown;
248
- timestamp: number;
249
- }
250
- export declare const MCP_CONNECTION_TIMEOUT_MS = 30000;
251
- export declare const MCP_REQUEST_TIMEOUT_MS = 60000;
252
- export declare const MCP_TOOL_CALL_TIMEOUT_MS = 100000;
253
- export declare const MCP_MAX_RECONNECT_ATTEMPTS = 5;
254
- export declare const MCP_RECONNECT_BASE_DELAY_MS = 1000;
255
- export declare const MCP_RECONNECT_MAX_DELAY_MS = 30000;
256
- export declare const MCP_MAX_DESCRIPTION_LENGTH = 2048;
257
- export declare const MCP_AUTH_CACHE_TTL_MS: number;
258
- export declare const MCP_BATCH_SIZE_LOCAL = 3;
259
- export declare const MCP_BATCH_SIZE_REMOTE = 20;
260
- /** Normalize a name for use in the prefixed tool name format */
261
- export declare function normalizeNameForMcp(name: string): string;
262
- /** Build a prefixed tool name: mcp__{server}__{tool} */
263
- export declare function buildMcpToolName(serverName: string, toolName: string): string;
264
- /** Get the prefix for a server (for batch removal) */
265
- export declare function getMcpServerPrefix(serverName: string): string;
266
- /** Parse a prefixed tool name back into server + tool */
267
- export declare function parseMcpToolName(prefixedName: string): McpToolIdentifier | null;
268
- /** Check if a tool name is an MCP-injected tool */
269
- export declare function isMcpToolName(name: string): boolean;