qlogicagent 0.2.1 → 0.3.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 (229) hide show
  1. package/dist/agent.js +1 -0
  2. package/dist/cli.js +9 -0
  3. package/dist/contracts.js +1 -0
  4. package/dist/index.js +5 -15
  5. package/dist/orchestration.js +118 -0
  6. package/package.json +56 -42
  7. package/dist/agent/agent.js +0 -113
  8. package/dist/agent/tool-loop.js +0 -575
  9. package/dist/agent/types.js +0 -14
  10. package/dist/cli/main.js +0 -23
  11. package/dist/cli/stdio-server.js +0 -463
  12. package/dist/config/config.js +0 -21
  13. package/dist/contracts/hooks.js +0 -7
  14. package/dist/contracts/index.js +0 -10
  15. package/dist/contracts/planner.js +0 -2
  16. package/dist/contracts/skill-candidate.js +0 -195
  17. package/dist/contracts/todo.js +0 -9
  18. package/dist/llm/builtin-providers.js +0 -531
  19. package/dist/llm/index.js +0 -14
  20. package/dist/llm/llm-client.js +0 -67
  21. package/dist/llm/model-catalog.js +0 -191
  22. package/dist/llm/provider-def.js +0 -12
  23. package/dist/llm/provider-registry.js +0 -147
  24. package/dist/llm/transport.js +0 -27
  25. package/dist/llm/transports/anthropic-messages.js +0 -293
  26. package/dist/llm/transports/openai-chat.js +0 -165
  27. package/dist/orchestration/agent-registry.js +0 -116
  28. package/dist/orchestration/approval-aware-tool-plan.js +0 -87
  29. package/dist/orchestration/context-compression.js +0 -583
  30. package/dist/orchestration/conversation-repair.js +0 -429
  31. package/dist/orchestration/curator-scheduler.js +0 -135
  32. package/dist/orchestration/embedded-failover-policy.js +0 -168
  33. package/dist/orchestration/error-classification.js +0 -77
  34. package/dist/orchestration/failover-classification.js +0 -381
  35. package/dist/orchestration/failover-error.js +0 -198
  36. package/dist/orchestration/fork-subagent.js +0 -98
  37. package/dist/orchestration/index.js +0 -267
  38. package/dist/orchestration/memory-flush-policy.js +0 -85
  39. package/dist/orchestration/memory-provider.js +0 -2
  40. package/dist/orchestration/parallel-tool-calls.js +0 -59
  41. package/dist/orchestration/prompt-cache-strategy.js +0 -228
  42. package/dist/orchestration/reactive-compact.js +0 -78
  43. package/dist/orchestration/retry-loop.js +0 -24
  44. package/dist/orchestration/skill-candidate.js +0 -141
  45. package/dist/orchestration/skill-consolidation.js +0 -220
  46. package/dist/orchestration/skill-improvement.js +0 -66
  47. package/dist/orchestration/skill-similarity.js +0 -131
  48. package/dist/orchestration/streaming-tool-executor.js +0 -96
  49. package/dist/orchestration/team-orchestration.js +0 -369
  50. package/dist/orchestration/team-tool-loop-wiring.js +0 -147
  51. package/dist/orchestration/tool-choice-policy.js +0 -164
  52. package/dist/orchestration/tool-loop-state.js +0 -133
  53. package/dist/orchestration/tool-schema.js +0 -297
  54. package/dist/orchestration/transcript-repair.js +0 -426
  55. package/dist/orchestration/turn-loop-guard.js +0 -92
  56. package/dist/orchestration/web-browser-policy.js +0 -39
  57. package/dist/runtime/context-compression.js +0 -274
  58. package/dist/runtime/hook-registry.js +0 -53
  59. package/dist/runtime/memory-hooks.js +0 -65
  60. package/dist/runtime/tool-eligibility.js +0 -111
  61. package/dist/skills/index.js +0 -82
  62. package/dist/skills/memory-extractor.js +0 -173
  63. package/dist/skills/memory-query-tool.js +0 -127
  64. package/dist/skills/memory-store.js +0 -228
  65. package/dist/skills/memory-tool.js +0 -192
  66. package/dist/skills/portable-tool.js +0 -14
  67. package/dist/skills/qmemory-adapter.js +0 -165
  68. package/dist/skills/skill-frontmatter.js +0 -344
  69. package/dist/skills/skill-guard.js +0 -229
  70. package/dist/skills/skill-loader.js +0 -303
  71. package/dist/skills/skill-source.js +0 -126
  72. package/dist/skills/skill-types.js +0 -6
  73. package/dist/skills/think-tool.js +0 -59
  74. package/dist/skills/todo-tool.js +0 -114
  75. package/dist/skills/tools/agent-tool.js +0 -142
  76. package/dist/skills/tools/apply-patch-tool.js +0 -184
  77. package/dist/skills/tools/ask-user-tool.js +0 -121
  78. package/dist/skills/tools/brief-tool.js +0 -95
  79. package/dist/skills/tools/browser-tool.js +0 -155
  80. package/dist/skills/tools/checkpoint-tool.js +0 -102
  81. package/dist/skills/tools/config-tool.js +0 -143
  82. package/dist/skills/tools/cron-tool.js +0 -175
  83. package/dist/skills/tools/edit-tool.js +0 -70
  84. package/dist/skills/tools/exec-tool.js +0 -133
  85. package/dist/skills/tools/image-generate-tool.js +0 -67
  86. package/dist/skills/tools/instructions-tool.js +0 -187
  87. package/dist/skills/tools/lsp-tool.js +0 -227
  88. package/dist/skills/tools/mcp-client-types.js +0 -53
  89. package/dist/skills/tools/mcp-tool.js +0 -503
  90. package/dist/skills/tools/memory-tool.js +0 -88
  91. package/dist/skills/tools/monitor-tool.js +0 -131
  92. package/dist/skills/tools/music-generate-tool.js +0 -62
  93. package/dist/skills/tools/notify-tool.js +0 -62
  94. package/dist/skills/tools/patch-tool.js +0 -505
  95. package/dist/skills/tools/pdf-tool.js +0 -88
  96. package/dist/skills/tools/plan-mode-tool.js +0 -122
  97. package/dist/skills/tools/read-tool.js +0 -84
  98. package/dist/skills/tools/repl-tool.js +0 -69
  99. package/dist/skills/tools/search-tool.js +0 -225
  100. package/dist/skills/tools/send-message-tool.js +0 -76
  101. package/dist/skills/tools/skill-list-tool.js +0 -54
  102. package/dist/skills/tools/skill-manage-tool.js +0 -153
  103. package/dist/skills/tools/skill-view-tool.js +0 -72
  104. package/dist/skills/tools/sleep-tool.js +0 -81
  105. package/dist/skills/tools/structured-output-tool.js +0 -176
  106. package/dist/skills/tools/task-tool.js +0 -161
  107. package/dist/skills/tools/team-tool.js +0 -105
  108. package/dist/skills/tools/tool-search-tool.js +0 -110
  109. package/dist/skills/tools/tts-tool.js +0 -45
  110. package/dist/skills/tools/video-edit-tool.js +0 -74
  111. package/dist/skills/tools/video-generate-tool.js +0 -66
  112. package/dist/skills/tools/video-merge-tool.js +0 -92
  113. package/dist/skills/tools/video-upscale-tool.js +0 -52
  114. package/dist/skills/tools/web-fetch-tool.js +0 -92
  115. package/dist/skills/tools/web-search-tool.js +0 -86
  116. package/dist/skills/tools/worktree-tool.js +0 -147
  117. package/dist/skills/tools/write-tool.js +0 -81
  118. /package/dist/{agent → types/agent}/agent.d.ts +0 -0
  119. /package/dist/{agent → types/agent}/tool-loop.d.ts +0 -0
  120. /package/dist/{agent → types/agent}/types.d.ts +0 -0
  121. /package/dist/{cli → types/cli}/main.d.ts +0 -0
  122. /package/dist/{cli → types/cli}/stdio-server.d.ts +0 -0
  123. /package/dist/{config → types/config}/config.d.ts +0 -0
  124. /package/dist/{contracts → types/contracts}/hooks.d.ts +0 -0
  125. /package/dist/{contracts → types/contracts}/index.d.ts +0 -0
  126. /package/dist/{contracts → types/contracts}/planner.d.ts +0 -0
  127. /package/dist/{contracts → types/contracts}/skill-candidate.d.ts +0 -0
  128. /package/dist/{contracts → types/contracts}/todo.d.ts +0 -0
  129. /package/dist/{index.d.ts → types/index.d.ts} +0 -0
  130. /package/dist/{llm → types/llm}/builtin-providers.d.ts +0 -0
  131. /package/dist/{llm → types/llm}/index.d.ts +0 -0
  132. /package/dist/{llm → types/llm}/llm-client.d.ts +0 -0
  133. /package/dist/{llm → types/llm}/model-catalog.d.ts +0 -0
  134. /package/dist/{llm → types/llm}/provider-def.d.ts +0 -0
  135. /package/dist/{llm → types/llm}/provider-registry.d.ts +0 -0
  136. /package/dist/{llm → types/llm}/transport.d.ts +0 -0
  137. /package/dist/{llm → types/llm}/transports/anthropic-messages.d.ts +0 -0
  138. /package/dist/{llm → types/llm}/transports/openai-chat.d.ts +0 -0
  139. /package/dist/{orchestration → types/orchestration}/agent-registry.d.ts +0 -0
  140. /package/dist/{orchestration → types/orchestration}/approval-aware-tool-plan.d.ts +0 -0
  141. /package/dist/{orchestration → types/orchestration}/context-compression.d.ts +0 -0
  142. /package/dist/{orchestration → types/orchestration}/conversation-repair.d.ts +0 -0
  143. /package/dist/{orchestration → types/orchestration}/curator-scheduler.d.ts +0 -0
  144. /package/dist/{orchestration → types/orchestration}/embedded-failover-policy.d.ts +0 -0
  145. /package/dist/{orchestration → types/orchestration}/error-classification.d.ts +0 -0
  146. /package/dist/{orchestration → types/orchestration}/failover-classification.d.ts +0 -0
  147. /package/dist/{orchestration → types/orchestration}/failover-error.d.ts +0 -0
  148. /package/dist/{orchestration → types/orchestration}/fork-subagent.d.ts +0 -0
  149. /package/dist/{orchestration → types/orchestration}/index.d.ts +0 -0
  150. /package/dist/{orchestration → types/orchestration}/memory-flush-policy.d.ts +0 -0
  151. /package/dist/{orchestration → types/orchestration}/memory-provider.d.ts +0 -0
  152. /package/dist/{orchestration → types/orchestration}/parallel-tool-calls.d.ts +0 -0
  153. /package/dist/{orchestration → types/orchestration}/prompt-cache-strategy.d.ts +0 -0
  154. /package/dist/{orchestration → types/orchestration}/reactive-compact.d.ts +0 -0
  155. /package/dist/{orchestration → types/orchestration}/retry-loop.d.ts +0 -0
  156. /package/dist/{orchestration → types/orchestration}/skill-candidate.d.ts +0 -0
  157. /package/dist/{orchestration → types/orchestration}/skill-consolidation.d.ts +0 -0
  158. /package/dist/{orchestration → types/orchestration}/skill-improvement.d.ts +0 -0
  159. /package/dist/{orchestration → types/orchestration}/skill-similarity.d.ts +0 -0
  160. /package/dist/{orchestration → types/orchestration}/streaming-tool-executor.d.ts +0 -0
  161. /package/dist/{orchestration → types/orchestration}/team-orchestration.d.ts +0 -0
  162. /package/dist/{orchestration → types/orchestration}/team-tool-loop-wiring.d.ts +0 -0
  163. /package/dist/{orchestration → types/orchestration}/tool-choice-policy.d.ts +0 -0
  164. /package/dist/{orchestration → types/orchestration}/tool-loop-state.d.ts +0 -0
  165. /package/dist/{orchestration → types/orchestration}/tool-schema.d.ts +0 -0
  166. /package/dist/{orchestration → types/orchestration}/transcript-repair.d.ts +0 -0
  167. /package/dist/{orchestration → types/orchestration}/turn-loop-guard.d.ts +0 -0
  168. /package/dist/{orchestration → types/orchestration}/web-browser-policy.d.ts +0 -0
  169. /package/dist/{runtime → types/runtime}/context-compression.d.ts +0 -0
  170. /package/dist/{runtime → types/runtime}/hook-registry.d.ts +0 -0
  171. /package/dist/{runtime → types/runtime}/memory-hooks.d.ts +0 -0
  172. /package/dist/{runtime → types/runtime}/tool-eligibility.d.ts +0 -0
  173. /package/dist/{skills → types/skills}/index.d.ts +0 -0
  174. /package/dist/{skills → types/skills}/memory-extractor.d.ts +0 -0
  175. /package/dist/{skills → types/skills}/memory-query-tool.d.ts +0 -0
  176. /package/dist/{skills → types/skills}/memory-store.d.ts +0 -0
  177. /package/dist/{skills → types/skills}/memory-tool.d.ts +0 -0
  178. /package/dist/{skills → types/skills}/portable-tool.d.ts +0 -0
  179. /package/dist/{skills → types/skills}/qmemory-adapter.d.ts +0 -0
  180. /package/dist/{skills → types/skills}/skill-frontmatter.d.ts +0 -0
  181. /package/dist/{skills → types/skills}/skill-guard.d.ts +0 -0
  182. /package/dist/{skills → types/skills}/skill-loader.d.ts +0 -0
  183. /package/dist/{skills → types/skills}/skill-source.d.ts +0 -0
  184. /package/dist/{skills → types/skills}/skill-types.d.ts +0 -0
  185. /package/dist/{skills → types/skills}/think-tool.d.ts +0 -0
  186. /package/dist/{skills → types/skills}/todo-tool.d.ts +0 -0
  187. /package/dist/{skills → types/skills}/tools/agent-tool.d.ts +0 -0
  188. /package/dist/{skills → types/skills}/tools/apply-patch-tool.d.ts +0 -0
  189. /package/dist/{skills → types/skills}/tools/ask-user-tool.d.ts +0 -0
  190. /package/dist/{skills → types/skills}/tools/brief-tool.d.ts +0 -0
  191. /package/dist/{skills → types/skills}/tools/browser-tool.d.ts +0 -0
  192. /package/dist/{skills → types/skills}/tools/checkpoint-tool.d.ts +0 -0
  193. /package/dist/{skills → types/skills}/tools/config-tool.d.ts +0 -0
  194. /package/dist/{skills → types/skills}/tools/cron-tool.d.ts +0 -0
  195. /package/dist/{skills → types/skills}/tools/edit-tool.d.ts +0 -0
  196. /package/dist/{skills → types/skills}/tools/exec-tool.d.ts +0 -0
  197. /package/dist/{skills → types/skills}/tools/image-generate-tool.d.ts +0 -0
  198. /package/dist/{skills → types/skills}/tools/instructions-tool.d.ts +0 -0
  199. /package/dist/{skills → types/skills}/tools/lsp-tool.d.ts +0 -0
  200. /package/dist/{skills → types/skills}/tools/mcp-client-types.d.ts +0 -0
  201. /package/dist/{skills → types/skills}/tools/mcp-tool.d.ts +0 -0
  202. /package/dist/{skills → types/skills}/tools/memory-tool.d.ts +0 -0
  203. /package/dist/{skills → types/skills}/tools/monitor-tool.d.ts +0 -0
  204. /package/dist/{skills → types/skills}/tools/music-generate-tool.d.ts +0 -0
  205. /package/dist/{skills → types/skills}/tools/notify-tool.d.ts +0 -0
  206. /package/dist/{skills → types/skills}/tools/patch-tool.d.ts +0 -0
  207. /package/dist/{skills → types/skills}/tools/pdf-tool.d.ts +0 -0
  208. /package/dist/{skills → types/skills}/tools/plan-mode-tool.d.ts +0 -0
  209. /package/dist/{skills → types/skills}/tools/read-tool.d.ts +0 -0
  210. /package/dist/{skills → types/skills}/tools/repl-tool.d.ts +0 -0
  211. /package/dist/{skills → types/skills}/tools/search-tool.d.ts +0 -0
  212. /package/dist/{skills → types/skills}/tools/send-message-tool.d.ts +0 -0
  213. /package/dist/{skills → types/skills}/tools/skill-list-tool.d.ts +0 -0
  214. /package/dist/{skills → types/skills}/tools/skill-manage-tool.d.ts +0 -0
  215. /package/dist/{skills → types/skills}/tools/skill-view-tool.d.ts +0 -0
  216. /package/dist/{skills → types/skills}/tools/sleep-tool.d.ts +0 -0
  217. /package/dist/{skills → types/skills}/tools/structured-output-tool.d.ts +0 -0
  218. /package/dist/{skills → types/skills}/tools/task-tool.d.ts +0 -0
  219. /package/dist/{skills → types/skills}/tools/team-tool.d.ts +0 -0
  220. /package/dist/{skills → types/skills}/tools/tool-search-tool.d.ts +0 -0
  221. /package/dist/{skills → types/skills}/tools/tts-tool.d.ts +0 -0
  222. /package/dist/{skills → types/skills}/tools/video-edit-tool.d.ts +0 -0
  223. /package/dist/{skills → types/skills}/tools/video-generate-tool.d.ts +0 -0
  224. /package/dist/{skills → types/skills}/tools/video-merge-tool.d.ts +0 -0
  225. /package/dist/{skills → types/skills}/tools/video-upscale-tool.d.ts +0 -0
  226. /package/dist/{skills → types/skills}/tools/web-fetch-tool.d.ts +0 -0
  227. /package/dist/{skills → types/skills}/tools/web-search-tool.d.ts +0 -0
  228. /package/dist/{skills → types/skills}/tools/worktree-tool.d.ts +0 -0
  229. /package/dist/{skills → types/skills}/tools/write-tool.d.ts +0 -0
@@ -1,133 +0,0 @@
1
- // ============================================================
2
- // Exec Tool — execute shell commands in a sandbox/host env.
3
- // Reference: claude-code-haha/src/tools/BashTool/BashTool.tsx
4
- // Category: system
5
- // ============================================================
6
- export const EXEC_TOOL_NAME = "exec";
7
- export const EXEC_TOOL_SCHEMA = {
8
- type: "object",
9
- properties: {
10
- command: {
11
- type: "string",
12
- description: "Shell command to execute. On Windows uses PowerShell, on Unix uses bash.",
13
- },
14
- description: {
15
- type: "string",
16
- description: "Brief human-readable description of what this command does (e.g. \"Install dependencies\", " +
17
- "\"Run unit tests\"). Used for UI display. For simple commands keep it 5-10 words; " +
18
- "for complex piped/flagged commands add enough context to clarify intent.",
19
- },
20
- workdir: {
21
- type: "string",
22
- description: "Working directory for the command.",
23
- },
24
- timeout: {
25
- type: "number",
26
- description: "Timeout in seconds (default: 120). Only applies to foreground commands.",
27
- },
28
- background: {
29
- type: "boolean",
30
- description: "If true, start the command in the background and return immediately " +
31
- "with a process ID. Use getOutput to check on it later. " +
32
- "Good for dev servers, watchers, long builds. Default: false.",
33
- },
34
- },
35
- required: ["command"],
36
- };
37
- const DEFAULT_TIMEOUT = 120;
38
- const MAX_OUTPUT_CHARS = 50_000;
39
- function truncateOutput(text, limit) {
40
- if (text.length <= limit)
41
- return text;
42
- const half = Math.floor(limit / 2) - 50;
43
- return `${text.slice(0, half)}\n\n... [truncated ${text.length - limit} chars] ...\n\n${text.slice(-half)}`;
44
- }
45
- export function createExecTool(deps) {
46
- return {
47
- name: EXEC_TOOL_NAME,
48
- label: "Execute Command",
49
- description: "Execute a shell command. Supports foreground (blocking, returns output) " +
50
- "and background (non-blocking, returns pid) modes. " +
51
- "On Windows uses PowerShell, on Unix uses bash. " +
52
- "Output is truncated if too long.",
53
- parameters: EXEC_TOOL_SCHEMA,
54
- execute: async (_toolCallId, params) => {
55
- // ── Validate command (skill-guard) ──────────────────
56
- if (deps.validateCommand) {
57
- const blocked = await deps.validateCommand(params.command);
58
- if (blocked) {
59
- return {
60
- content: [{ type: "text", text: `Command blocked: ${blocked}` }],
61
- details: { type: "exec", error: "blocked_by_guard", reason: blocked },
62
- };
63
- }
64
- }
65
- // ── Background mode ─────────────────────────────────
66
- if (params.background) {
67
- if (!deps.execBackground) {
68
- return {
69
- content: [{ type: "text", text: "Background execution is not supported by the current host." }],
70
- details: { type: "exec", error: "background_not_supported" },
71
- };
72
- }
73
- const bgResult = await deps.execBackground(params.command, {
74
- workdir: params.workdir,
75
- });
76
- const text = bgResult.started
77
- ? `Background process started (pid: ${bgResult.pid}).${bgResult.hint ? ` ${bgResult.hint}` : ""}\nUse getOutput with this pid to check on it later.`
78
- : `Failed to start background process.`;
79
- return {
80
- content: [{ type: "text", text }],
81
- details: {
82
- type: "exec_background",
83
- pid: bgResult.pid,
84
- started: bgResult.started,
85
- description: params.description,
86
- },
87
- };
88
- }
89
- // ── Foreground mode ─────────────────────────────────
90
- const timeout = params.timeout ?? DEFAULT_TIMEOUT;
91
- const result = await deps.exec(params.command, {
92
- workdir: params.workdir,
93
- timeout,
94
- });
95
- const fullOutput = (result.stdout || "") + (result.stderr || "");
96
- const parts = [];
97
- // Large output persistence
98
- let persistedUri;
99
- if (fullOutput.length > MAX_OUTPUT_CHARS && deps.persistOutput) {
100
- persistedUri = await deps.persistOutput(fullOutput, { command: params.command, exitCode: result.exitCode });
101
- }
102
- if (result.stdout) {
103
- parts.push(persistedUri
104
- ? truncateOutput(result.stdout, MAX_OUTPUT_CHARS / 2)
105
- : truncateOutput(result.stdout, MAX_OUTPUT_CHARS));
106
- }
107
- if (result.stderr)
108
- parts.push(`[stderr]\n${truncateOutput(result.stderr, MAX_OUTPUT_CHARS / 4)}`);
109
- if (result.timedOut)
110
- parts.push(`[timed out after ${timeout}s]`);
111
- if (persistedUri)
112
- parts.push(`[full output persisted: ${persistedUri}]`);
113
- // Semantic exit code interpretation
114
- if (result.exitCode !== 0 && deps.interpretExitCode) {
115
- const hint = deps.interpretExitCode(result.exitCode, result.stderr || "");
116
- if (hint)
117
- parts.push(`[exit ${result.exitCode}: ${hint}]`);
118
- }
119
- if (parts.length === 0)
120
- parts.push(`(exit code ${result.exitCode}, no output)`);
121
- return {
122
- content: [{ type: "text", text: parts.join("\n") }],
123
- details: {
124
- type: "exec",
125
- exitCode: result.exitCode,
126
- timedOut: result.timedOut ?? false,
127
- description: params.description,
128
- persistedUri,
129
- },
130
- };
131
- },
132
- };
133
- }
@@ -1,67 +0,0 @@
1
- // ============================================================
2
- // Image Generate Tool — generate images via backend adapter.
3
- // Category: media
4
- // ============================================================
5
- export const IMAGE_GENERATE_TOOL_NAME = "image_generate";
6
- export const IMAGE_GENERATE_TOOL_SCHEMA = {
7
- type: "object",
8
- properties: {
9
- prompt: {
10
- type: "string",
11
- description: "Image generation prompt. Enrich vague requests with style, lighting, composition, color, mood details.",
12
- },
13
- purpose: {
14
- type: "string",
15
- description: "Intended use: 'social-media', 'short-video-cover', 'phone-wallpaper', 'avatar', 'poster', etc.",
16
- },
17
- style: {
18
- type: "string",
19
- description: "Visual art style: 'photorealistic', 'anime', 'watercolor', 'oil-painting', '3d-render', etc.",
20
- },
21
- size: {
22
- type: "string",
23
- description: "Dimensions: e.g. '1024x1792' (portrait), '1792x1024' (landscape), '1024x1024' (square). Default: '1024x1024'.",
24
- },
25
- image_url: {
26
- type: "string",
27
- description: "Reference image URL for image-to-image generation (img2img). Character reference sheet or style transfer.",
28
- },
29
- n: {
30
- type: "number",
31
- description: "Number of images to generate (1-4). Default: 1.",
32
- },
33
- },
34
- required: ["prompt"],
35
- };
36
- export function createImageGenerateTool(deps) {
37
- return {
38
- name: IMAGE_GENERATE_TOOL_NAME,
39
- label: "Image Generate",
40
- description: "Generate images from a text prompt. You MUST enrich vague prompts with details about style, lighting, " +
41
- "composition, color, and mood before calling. Supports img2img via image_url reference. " +
42
- "All generated images are saved locally and can be viewed immediately.",
43
- parameters: IMAGE_GENERATE_TOOL_SCHEMA,
44
- execute: async (_toolCallId, params) => {
45
- const result = await deps.generateImage({
46
- prompt: params.prompt,
47
- purpose: params.purpose,
48
- style: params.style,
49
- size: params.size,
50
- imageUrl: params.image_url,
51
- n: params.n,
52
- });
53
- const count = result.mediaUrls.length;
54
- const text = `Generated ${count} image${count > 1 ? "s" : ""}${result.model ? ` (model: ${result.model})` : ""}`;
55
- return {
56
- content: [{ type: "text", text }],
57
- details: {
58
- type: "image_generate",
59
- model: result.model,
60
- size: result.size,
61
- durationMs: result.durationMs,
62
- mediaUrls: result.mediaUrls,
63
- },
64
- };
65
- },
66
- };
67
- }
@@ -1,187 +0,0 @@
1
- // ============================================================
2
- // Instructions Tool — CRUD for project instruction files (.md).
3
- //
4
- // Runtime-agnostic: the actual file I/O is injected via deps.
5
- // Gateway provides InstructionsModule; Hub provides HTTP client;
6
- // Electron provides IPC bridge.
7
- //
8
- // Category: project-management
9
- // ============================================================
10
- // ── instructions_list ───────────────────────────────────────
11
- export const INSTRUCTIONS_LIST_TOOL_NAME = "instructions_list";
12
- export const INSTRUCTIONS_LIST_SCHEMA = {
13
- type: "object",
14
- properties: {
15
- project_id: {
16
- type: "string",
17
- description: 'Project ID to list instructions for. Use "default" for the default project.',
18
- },
19
- },
20
- required: ["project_id"],
21
- };
22
- export function createInstructionsListTool(deps) {
23
- return {
24
- name: INSTRUCTIONS_LIST_TOOL_NAME,
25
- label: "List Instructions",
26
- description: "List all instruction files (.md) in a project's .instructions/ directory. " +
27
- "Instructions define agent behavior rules, coding standards, and project context. " +
28
- "Returns filename, path, size, and last modified time for each file.",
29
- parameters: INSTRUCTIONS_LIST_SCHEMA,
30
- isReadOnly: true,
31
- isConcurrencySafe: true,
32
- searchHint: "list project instructions rules coding standards behavior guidelines",
33
- execute: async (_toolCallId, params) => {
34
- const files = deps.list(params.project_id);
35
- if (files.length === 0) {
36
- return {
37
- content: [{ type: "text", text: "No instruction files found for this project." }],
38
- details: { projectId: params.project_id, count: 0 },
39
- };
40
- }
41
- const listing = files
42
- .map((f) => `- ${f.filename} (${f.size} bytes, updated ${f.updatedAt})`)
43
- .join("\n");
44
- return {
45
- content: [{ type: "text", text: `Found ${files.length} instruction file(s):\n${listing}` }],
46
- details: { projectId: params.project_id, count: files.length, files },
47
- };
48
- },
49
- };
50
- }
51
- // ── instructions_read ───────────────────────────────────────
52
- export const INSTRUCTIONS_READ_TOOL_NAME = "instructions_read";
53
- export const INSTRUCTIONS_READ_SCHEMA = {
54
- type: "object",
55
- properties: {
56
- project_id: {
57
- type: "string",
58
- description: 'Project ID. Use "default" for the default project.',
59
- },
60
- filename: {
61
- type: "string",
62
- description: 'Instruction file name (e.g. "code-style.md"). Supports sub-paths like "testing/unit-test.md".',
63
- },
64
- },
65
- required: ["project_id", "filename"],
66
- };
67
- export function createInstructionsReadTool(deps) {
68
- return {
69
- name: INSTRUCTIONS_READ_TOOL_NAME,
70
- label: "Read Instruction",
71
- description: "Read the content of a specific instruction file (.md) from a project. " +
72
- "Use instructions_list first to discover available files.",
73
- parameters: INSTRUCTIONS_READ_SCHEMA,
74
- isReadOnly: true,
75
- isConcurrencySafe: true,
76
- searchHint: "read instruction file content rules coding standard",
77
- execute: async (_toolCallId, params) => {
78
- const file = deps.read(params.project_id, params.filename);
79
- if (!file) {
80
- return {
81
- content: [{ type: "text", text: `Instruction file not found: ${params.filename}` }],
82
- details: { projectId: params.project_id, filename: params.filename, error: "not_found" },
83
- };
84
- }
85
- return {
86
- content: [{ type: "text", text: file.content }],
87
- details: { projectId: params.project_id, filename: file.filename, size: file.size },
88
- };
89
- },
90
- };
91
- }
92
- // ── instructions_write ──────────────────────────────────────
93
- export const INSTRUCTIONS_WRITE_TOOL_NAME = "instructions_write";
94
- export const INSTRUCTIONS_WRITE_SCHEMA = {
95
- type: "object",
96
- properties: {
97
- project_id: {
98
- type: "string",
99
- description: 'Project ID. Use "default" for the default project.',
100
- },
101
- filename: {
102
- type: "string",
103
- description: 'Instruction file name ending in .md (e.g. "code-style.md"). Sub-paths like "testing/unit-test.md" are supported.',
104
- },
105
- content: {
106
- type: "string",
107
- description: "Markdown content for the instruction file.",
108
- },
109
- },
110
- required: ["project_id", "filename", "content"],
111
- };
112
- export function createInstructionsWriteTool(deps) {
113
- return {
114
- name: INSTRUCTIONS_WRITE_TOOL_NAME,
115
- label: "Write Instruction",
116
- description: "Create or overwrite an instruction file (.md) in a project. " +
117
- "Instructions define agent behavior rules, coding standards, and project context. " +
118
- "The file must end in .md. Sub-directories are created automatically.",
119
- parameters: INSTRUCTIONS_WRITE_SCHEMA,
120
- searchHint: "write create instruction file rules coding standard",
121
- execute: async (_toolCallId, params) => {
122
- if (!params.filename.endsWith(".md")) {
123
- return {
124
- content: [{ type: "text", text: "Filename must end with .md" }],
125
- details: { error: "invalid_filename" },
126
- };
127
- }
128
- if (params.filename.includes("..")) {
129
- return {
130
- content: [{ type: "text", text: "Path traversal not allowed" }],
131
- details: { error: "path_traversal" },
132
- };
133
- }
134
- const file = deps.write(params.project_id, params.filename, params.content);
135
- return {
136
- content: [
137
- { type: "text", text: `Instruction file written: ${file.filename} (${file.size} bytes)` },
138
- ],
139
- details: { projectId: params.project_id, filename: file.filename, size: file.size },
140
- };
141
- },
142
- };
143
- }
144
- // ── instructions_delete ─────────────────────────────────────
145
- export const INSTRUCTIONS_DELETE_TOOL_NAME = "instructions_delete";
146
- export const INSTRUCTIONS_DELETE_SCHEMA = {
147
- type: "object",
148
- properties: {
149
- project_id: {
150
- type: "string",
151
- description: 'Project ID. Use "default" for the default project.',
152
- },
153
- filename: {
154
- type: "string",
155
- description: "Instruction file name to delete (e.g. \"code-style.md\").",
156
- },
157
- },
158
- required: ["project_id", "filename"],
159
- };
160
- export function createInstructionsDeleteTool(deps) {
161
- return {
162
- name: INSTRUCTIONS_DELETE_TOOL_NAME,
163
- label: "Delete Instruction",
164
- description: "Delete an instruction file (.md) from a project. This cannot be undone.",
165
- parameters: INSTRUCTIONS_DELETE_SCHEMA,
166
- searchHint: "delete remove instruction file",
167
- execute: async (_toolCallId, params) => {
168
- if (params.filename.includes("..")) {
169
- return {
170
- content: [{ type: "text", text: "Path traversal not allowed" }],
171
- details: { error: "path_traversal" },
172
- };
173
- }
174
- const ok = deps.remove(params.project_id, params.filename);
175
- if (!ok) {
176
- return {
177
- content: [{ type: "text", text: `Instruction file not found: ${params.filename}` }],
178
- details: { projectId: params.project_id, filename: params.filename, error: "not_found" },
179
- };
180
- }
181
- return {
182
- content: [{ type: "text", text: `Instruction file deleted: ${params.filename}` }],
183
- details: { projectId: params.project_id, filename: params.filename },
184
- };
185
- },
186
- };
187
- }
@@ -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,53 +0,0 @@
1
- // ============================================================
2
- // MCP Client SDK Types — Full Model Context Protocol client contract.
3
- //
4
- // Defines the complete type system for MCP server connections,
5
- // transports, authentication, dynamic tool injection, prompts,
6
- // and lifecycle management.
7
- //
8
- // Reference: @modelcontextprotocol/sdk + Claude Code services/mcp/
9
- // ============================================================
10
- // ── Client Lifecycle Constants ──────────────────────────────
11
- export const MCP_CONNECTION_TIMEOUT_MS = 30_000;
12
- export const MCP_REQUEST_TIMEOUT_MS = 60_000;
13
- export const MCP_TOOL_CALL_TIMEOUT_MS = 100_000;
14
- export const MCP_MAX_RECONNECT_ATTEMPTS = 5;
15
- export const MCP_RECONNECT_BASE_DELAY_MS = 1_000;
16
- export const MCP_RECONNECT_MAX_DELAY_MS = 30_000;
17
- export const MCP_MAX_DESCRIPTION_LENGTH = 2048;
18
- export const MCP_AUTH_CACHE_TTL_MS = 15 * 60 * 1000;
19
- export const MCP_BATCH_SIZE_LOCAL = 3;
20
- export const MCP_BATCH_SIZE_REMOTE = 20;
21
- // ── Name Utilities ──────────────────────────────────────────
22
- const MCP_PREFIX = "mcp__";
23
- const MCP_SEPARATOR = "__";
24
- /** Normalize a name for use in the prefixed tool name format */
25
- export function normalizeNameForMcp(name) {
26
- return name.replace(/[^a-zA-Z0-9_-]/g, "_");
27
- }
28
- /** Build a prefixed tool name: mcp__{server}__{tool} */
29
- export function buildMcpToolName(serverName, toolName) {
30
- return `${MCP_PREFIX}${normalizeNameForMcp(serverName)}${MCP_SEPARATOR}${normalizeNameForMcp(toolName)}`;
31
- }
32
- /** Get the prefix for a server (for batch removal) */
33
- export function getMcpServerPrefix(serverName) {
34
- return `${MCP_PREFIX}${normalizeNameForMcp(serverName)}${MCP_SEPARATOR}`;
35
- }
36
- /** Parse a prefixed tool name back into server + tool */
37
- export function parseMcpToolName(prefixedName) {
38
- if (!prefixedName.startsWith(MCP_PREFIX))
39
- return null;
40
- const rest = prefixedName.slice(MCP_PREFIX.length);
41
- const sepIndex = rest.indexOf(MCP_SEPARATOR);
42
- if (sepIndex < 0)
43
- return null;
44
- return {
45
- serverName: rest.slice(0, sepIndex),
46
- toolName: rest.slice(sepIndex + MCP_SEPARATOR.length),
47
- prefixedName,
48
- };
49
- }
50
- /** Check if a tool name is an MCP-injected tool */
51
- export function isMcpToolName(name) {
52
- return name.startsWith(MCP_PREFIX);
53
- }