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,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,62 +0,0 @@
1
- import type { PortableTool } from "../portable-tool.js";
2
- export declare const IMAGE_GENERATE_TOOL_NAME: "image_generate";
3
- export interface ImageGenerateToolParams {
4
- prompt: string;
5
- purpose?: string;
6
- style?: string;
7
- size?: string;
8
- image_url?: string;
9
- n?: number;
10
- }
11
- export declare const IMAGE_GENERATE_TOOL_SCHEMA: {
12
- readonly type: "object";
13
- readonly properties: {
14
- readonly prompt: {
15
- readonly type: "string";
16
- readonly description: "Image generation prompt. Enrich vague requests with style, lighting, composition, color, mood details.";
17
- };
18
- readonly purpose: {
19
- readonly type: "string";
20
- readonly description: "Intended use: 'social-media', 'short-video-cover', 'phone-wallpaper', 'avatar', 'poster', etc.";
21
- };
22
- readonly style: {
23
- readonly type: "string";
24
- readonly description: "Visual art style: 'photorealistic', 'anime', 'watercolor', 'oil-painting', '3d-render', etc.";
25
- };
26
- readonly size: {
27
- readonly type: "string";
28
- readonly description: "Dimensions: e.g. '1024x1792' (portrait), '1792x1024' (landscape), '1024x1024' (square). Default: '1024x1024'.";
29
- };
30
- readonly image_url: {
31
- readonly type: "string";
32
- readonly description: "Reference image URL for image-to-image generation (img2img). Character reference sheet or style transfer.";
33
- };
34
- readonly n: {
35
- readonly type: "number";
36
- readonly description: "Number of images to generate (1-4). Default: 1.";
37
- };
38
- };
39
- readonly required: readonly ["prompt"];
40
- };
41
- export interface ImageGenerateResult {
42
- mediaUrls: string[];
43
- model?: string;
44
- size?: string;
45
- durationMs?: number;
46
- }
47
- /** Deps injected by the host runtime for image generation. */
48
- export interface ImageGenerateToolDeps {
49
- /**
50
- * Generate images via the configured backend (relay, direct API, etc.).
51
- * The host handles model selection, failover, watermark, and storage.
52
- */
53
- generateImage(params: {
54
- prompt: string;
55
- purpose?: string;
56
- style?: string;
57
- size?: string;
58
- imageUrl?: string;
59
- n?: number;
60
- }): Promise<ImageGenerateResult>;
61
- }
62
- export declare function createImageGenerateTool(deps: ImageGenerateToolDeps): PortableTool<ImageGenerateToolParams>;
@@ -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,103 +0,0 @@
1
- import type { PortableTool } from "../portable-tool.js";
2
- /** A single instruction file entry. */
3
- export interface InstructionFileInfo {
4
- filename: string;
5
- path: string;
6
- size: number;
7
- updatedAt: string;
8
- }
9
- /** Full instruction file (with content). */
10
- export interface InstructionFileContent extends InstructionFileInfo {
11
- content: string;
12
- }
13
- /** Deps injected by the host runtime for instructions CRUD. */
14
- export interface InstructionsToolDeps {
15
- /** List all instruction files for a project (recursive). */
16
- list(projectId: string): InstructionFileInfo[];
17
- /** Read a single instruction file. Returns null if not found. */
18
- read(projectId: string, filename: string): InstructionFileContent | null;
19
- /** Write (create or overwrite) an instruction file. */
20
- write(projectId: string, filename: string, content: string): InstructionFileContent;
21
- /** Remove an instruction file. Returns true if deleted. */
22
- remove(projectId: string, filename: string): boolean;
23
- }
24
- export declare const INSTRUCTIONS_LIST_TOOL_NAME: "instructions_list";
25
- export interface InstructionsListParams {
26
- project_id: string;
27
- }
28
- export declare const INSTRUCTIONS_LIST_SCHEMA: {
29
- readonly type: "object";
30
- readonly properties: {
31
- readonly project_id: {
32
- readonly type: "string";
33
- readonly description: "Project ID to list instructions for. Use \"default\" for the default project.";
34
- };
35
- };
36
- readonly required: readonly ["project_id"];
37
- };
38
- export declare function createInstructionsListTool(deps: InstructionsToolDeps): PortableTool<InstructionsListParams>;
39
- export declare const INSTRUCTIONS_READ_TOOL_NAME: "instructions_read";
40
- export interface InstructionsReadParams {
41
- project_id: string;
42
- filename: string;
43
- }
44
- export declare const INSTRUCTIONS_READ_SCHEMA: {
45
- readonly type: "object";
46
- readonly properties: {
47
- readonly project_id: {
48
- readonly type: "string";
49
- readonly description: "Project ID. Use \"default\" for the default project.";
50
- };
51
- readonly filename: {
52
- readonly type: "string";
53
- readonly description: "Instruction file name (e.g. \"code-style.md\"). Supports sub-paths like \"testing/unit-test.md\".";
54
- };
55
- };
56
- readonly required: readonly ["project_id", "filename"];
57
- };
58
- export declare function createInstructionsReadTool(deps: InstructionsToolDeps): PortableTool<InstructionsReadParams>;
59
- export declare const INSTRUCTIONS_WRITE_TOOL_NAME: "instructions_write";
60
- export interface InstructionsWriteParams {
61
- project_id: string;
62
- filename: string;
63
- content: string;
64
- }
65
- export declare const INSTRUCTIONS_WRITE_SCHEMA: {
66
- readonly type: "object";
67
- readonly properties: {
68
- readonly project_id: {
69
- readonly type: "string";
70
- readonly description: "Project ID. Use \"default\" for the default project.";
71
- };
72
- readonly filename: {
73
- readonly type: "string";
74
- readonly description: "Instruction file name ending in .md (e.g. \"code-style.md\"). Sub-paths like \"testing/unit-test.md\" are supported.";
75
- };
76
- readonly content: {
77
- readonly type: "string";
78
- readonly description: "Markdown content for the instruction file.";
79
- };
80
- };
81
- readonly required: readonly ["project_id", "filename", "content"];
82
- };
83
- export declare function createInstructionsWriteTool(deps: InstructionsToolDeps): PortableTool<InstructionsWriteParams>;
84
- export declare const INSTRUCTIONS_DELETE_TOOL_NAME: "instructions_delete";
85
- export interface InstructionsDeleteParams {
86
- project_id: string;
87
- filename: string;
88
- }
89
- export declare const INSTRUCTIONS_DELETE_SCHEMA: {
90
- readonly type: "object";
91
- readonly properties: {
92
- readonly project_id: {
93
- readonly type: "string";
94
- readonly description: "Project ID. Use \"default\" for the default project.";
95
- };
96
- readonly filename: {
97
- readonly type: "string";
98
- readonly description: "Instruction file name to delete (e.g. \"code-style.md\").";
99
- };
100
- };
101
- readonly required: readonly ["project_id", "filename"];
102
- };
103
- export declare function createInstructionsDeleteTool(deps: InstructionsToolDeps): PortableTool<InstructionsDeleteParams>;
@@ -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
- }