@zhijiewang/openharness 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/CONTRIBUTING.md +55 -0
- package/LICENSE +21 -0
- package/README.md +154 -0
- package/data/models.json +74 -0
- package/data/prompts/system.md +25 -0
- package/data/skills/code-review.md +19 -0
- package/data/skills/commit.md +17 -0
- package/data/skills/debug.md +24 -0
- package/data/skills/tdd.md +22 -0
- package/dist/Tool.d.ts +45 -0
- package/dist/Tool.d.ts.map +1 -0
- package/dist/Tool.js +62 -0
- package/dist/Tool.js.map +1 -0
- package/dist/components/App.d.ts +16 -0
- package/dist/components/App.d.ts.map +1 -0
- package/dist/components/App.js +25 -0
- package/dist/components/App.js.map +1 -0
- package/dist/components/Messages.d.ts +9 -0
- package/dist/components/Messages.d.ts.map +1 -0
- package/dist/components/Messages.js +23 -0
- package/dist/components/Messages.js.map +1 -0
- package/dist/components/PermissionPrompt.d.ts +9 -0
- package/dist/components/PermissionPrompt.d.ts.map +1 -0
- package/dist/components/PermissionPrompt.js +18 -0
- package/dist/components/PermissionPrompt.js.map +1 -0
- package/dist/components/REPL.d.ts +15 -0
- package/dist/components/REPL.d.ts.map +1 -0
- package/dist/components/REPL.js +114 -0
- package/dist/components/REPL.js.map +1 -0
- package/dist/components/Spinner.d.ts +7 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +7 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/TextInput.d.ts +7 -0
- package/dist/components/TextInput.d.ts.map +1 -0
- package/dist/components/TextInput.js +37 -0
- package/dist/components/TextInput.js.map +1 -0
- package/dist/components/ToolCallDisplay.d.ts +12 -0
- package/dist/components/ToolCallDisplay.d.ts.map +1 -0
- package/dist/components/ToolCallDisplay.js +16 -0
- package/dist/components/ToolCallDisplay.js.map +1 -0
- package/dist/harness/cost.d.ts +33 -0
- package/dist/harness/cost.d.ts.map +1 -0
- package/dist/harness/cost.js +68 -0
- package/dist/harness/cost.js.map +1 -0
- package/dist/harness/onboarding.d.ts +17 -0
- package/dist/harness/onboarding.d.ts.map +1 -0
- package/dist/harness/onboarding.js +99 -0
- package/dist/harness/onboarding.js.map +1 -0
- package/dist/harness/rules.d.ts +8 -0
- package/dist/harness/rules.d.ts.map +1 -0
- package/dist/harness/rules.js +66 -0
- package/dist/harness/rules.js.map +1 -0
- package/dist/harness/session.d.ts +24 -0
- package/dist/harness/session.d.ts.map +1 -0
- package/dist/harness/session.js +56 -0
- package/dist/harness/session.js.map +1 -0
- package/dist/main.d.ts +12 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +177 -0
- package/dist/main.js.map +1 -0
- package/dist/providers/anthropic.d.ts +27 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +291 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/base.d.ts +41 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +5 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/index.d.ts +12 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +57 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/ollama.d.ts +19 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +233 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +21 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +242 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/openrouter.d.ts +25 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +278 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/query.d.ts +35 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +185 -0
- package/dist/query.js.map +1 -0
- package/dist/tools/BashTool/index.d.ts +15 -0
- package/dist/tools/BashTool/index.d.ts.map +1 -0
- package/dist/tools/BashTool/index.js +78 -0
- package/dist/tools/BashTool/index.js.map +1 -0
- package/dist/tools/FileEditTool/index.d.ts +21 -0
- package/dist/tools/FileEditTool/index.d.ts.map +1 -0
- package/dist/tools/FileEditTool/index.js +70 -0
- package/dist/tools/FileEditTool/index.js.map +1 -0
- package/dist/tools/FileReadTool/index.d.ts +18 -0
- package/dist/tools/FileReadTool/index.d.ts.map +1 -0
- package/dist/tools/FileReadTool/index.js +63 -0
- package/dist/tools/FileReadTool/index.js.map +1 -0
- package/dist/tools/FileWriteTool/index.d.ts +15 -0
- package/dist/tools/FileWriteTool/index.d.ts.map +1 -0
- package/dist/tools/FileWriteTool/index.js +42 -0
- package/dist/tools/FileWriteTool/index.js.map +1 -0
- package/dist/tools/GlobTool/index.d.ts +15 -0
- package/dist/tools/GlobTool/index.d.ts.map +1 -0
- package/dist/tools/GlobTool/index.js +126 -0
- package/dist/tools/GlobTool/index.js.map +1 -0
- package/dist/tools/GrepTool/index.d.ts +21 -0
- package/dist/tools/GrepTool/index.d.ts.map +1 -0
- package/dist/tools/GrepTool/index.js +125 -0
- package/dist/tools/GrepTool/index.js.map +1 -0
- package/dist/tools/WebFetchTool/index.d.ts +12 -0
- package/dist/tools/WebFetchTool/index.d.ts.map +1 -0
- package/dist/tools/WebFetchTool/index.js +98 -0
- package/dist/tools/WebFetchTool/index.js.map +1 -0
- package/dist/tools.d.ts +9 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +25 -0
- package/dist/tools.js.map +1 -0
- package/dist/types/events.d.ts +49 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +5 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/message.d.ts +27 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +22 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/permissions.d.ts +22 -0
- package/dist/types/permissions.d.ts.map +1 -0
- package/dist/types/permissions.js +27 -0
- package/dist/types/permissions.js.map +1 -0
- package/package.json +55 -0
package/dist/query.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent loop — the core LLM-to-Tool orchestration cycle.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors Claude Code's query.ts while(true) pattern:
|
|
5
|
+
* 1. Send messages to LLM
|
|
6
|
+
* 2. If LLM requests tool calls → execute them → loop back
|
|
7
|
+
* 3. If LLM returns text only → yield to UI → done
|
|
8
|
+
*
|
|
9
|
+
* Uses async generators for streaming events to the React UI.
|
|
10
|
+
*/
|
|
11
|
+
import { findToolByName, toolToAPIFormat } from "./Tool.js";
|
|
12
|
+
import { createAssistantMessage, createToolResultMessage, createUserMessage, } from "./types/message.js";
|
|
13
|
+
import { checkPermission } from "./types/permissions.js";
|
|
14
|
+
const DEFAULT_MAX_TURNS = 50;
|
|
15
|
+
/**
|
|
16
|
+
* Main agent loop. Yields streaming events to the UI.
|
|
17
|
+
*/
|
|
18
|
+
export async function* query(userMessage, config, existingMessages = []) {
|
|
19
|
+
const maxTurns = config.maxTurns ?? DEFAULT_MAX_TURNS;
|
|
20
|
+
const toolContext = { workingDir: process.cwd() };
|
|
21
|
+
const state = {
|
|
22
|
+
messages: [
|
|
23
|
+
...existingMessages,
|
|
24
|
+
createUserMessage(userMessage),
|
|
25
|
+
],
|
|
26
|
+
turn: 0,
|
|
27
|
+
totalCost: 0,
|
|
28
|
+
};
|
|
29
|
+
// Build system prompt with tool descriptions
|
|
30
|
+
const toolPrompts = config.tools.map((t) => t.prompt()).join("\n\n");
|
|
31
|
+
const fullSystemPrompt = config.systemPrompt + "\n\n# Available Tools\n\n" + toolPrompts;
|
|
32
|
+
// API tool definitions
|
|
33
|
+
const apiTools = config.tools.map(toolToAPIFormat);
|
|
34
|
+
while (state.turn < maxTurns) {
|
|
35
|
+
state.turn++;
|
|
36
|
+
// Budget check
|
|
37
|
+
if (config.maxCost && state.totalCost >= config.maxCost) {
|
|
38
|
+
yield { type: "error", message: `Budget exceeded: $${state.totalCost.toFixed(4)}` };
|
|
39
|
+
yield { type: "turn_complete", reason: "budget_exceeded" };
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// Call LLM with streaming
|
|
43
|
+
let assistantContent = "";
|
|
44
|
+
const toolCalls = [];
|
|
45
|
+
for await (const event of config.provider.stream(state.messages, fullSystemPrompt, apiTools)) {
|
|
46
|
+
if (event.type === "text_delta") {
|
|
47
|
+
assistantContent += event.content;
|
|
48
|
+
yield event;
|
|
49
|
+
}
|
|
50
|
+
else if (event.type === "tool_call_start") {
|
|
51
|
+
// Placeholder — arguments populated by tool_call_complete
|
|
52
|
+
toolCalls.push({
|
|
53
|
+
id: event.callId,
|
|
54
|
+
toolName: event.toolName,
|
|
55
|
+
arguments: {},
|
|
56
|
+
});
|
|
57
|
+
yield event;
|
|
58
|
+
}
|
|
59
|
+
else if (event.type === "tool_call_complete") {
|
|
60
|
+
// Update the matching tool call with final parsed arguments
|
|
61
|
+
const tc = toolCalls.find((t) => t.id === event.callId);
|
|
62
|
+
if (tc) {
|
|
63
|
+
// ToolCall is readonly, so replace in-place
|
|
64
|
+
const idx = toolCalls.indexOf(tc);
|
|
65
|
+
toolCalls[idx] = { ...tc, arguments: event.arguments };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (event.type === "cost_update") {
|
|
69
|
+
state.totalCost += event.cost;
|
|
70
|
+
yield event;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Add assistant message to history
|
|
74
|
+
state.messages.push(createAssistantMessage(assistantContent, toolCalls.length > 0 ? toolCalls : undefined));
|
|
75
|
+
// No tool calls → done
|
|
76
|
+
if (toolCalls.length === 0) {
|
|
77
|
+
yield { type: "turn_complete", reason: "completed" };
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Execute tool calls with concurrency control
|
|
81
|
+
yield* executeToolCalls(toolCalls, config.tools, toolContext, config.permissionMode, config.askUser, state);
|
|
82
|
+
}
|
|
83
|
+
yield { type: "turn_complete", reason: "max_turns" };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Execute tool calls, yielding events in real time.
|
|
87
|
+
* Read-only tools run in parallel; write tools run serially.
|
|
88
|
+
*/
|
|
89
|
+
async function* executeToolCalls(toolCalls, tools, context, permissionMode, askUser, state) {
|
|
90
|
+
// Partition into batches
|
|
91
|
+
const batches = partitionToolCalls(toolCalls, tools);
|
|
92
|
+
for (const batch of batches) {
|
|
93
|
+
if (batch.concurrent) {
|
|
94
|
+
// Yield all starts
|
|
95
|
+
for (const tc of batch.calls) {
|
|
96
|
+
yield { type: "tool_call_start", toolName: tc.toolName, callId: tc.id };
|
|
97
|
+
}
|
|
98
|
+
// Run in parallel
|
|
99
|
+
const results = await Promise.all(batch.calls.map((tc) => executeSingleTool(tc, tools, context, permissionMode, askUser)));
|
|
100
|
+
// Yield all ends + add to messages
|
|
101
|
+
for (let i = 0; i < batch.calls.length; i++) {
|
|
102
|
+
const tc = batch.calls[i];
|
|
103
|
+
const result = results[i];
|
|
104
|
+
yield {
|
|
105
|
+
type: "tool_call_end",
|
|
106
|
+
callId: tc.id,
|
|
107
|
+
output: result.output,
|
|
108
|
+
isError: result.isError,
|
|
109
|
+
};
|
|
110
|
+
state?.messages.push(createToolResultMessage({ callId: tc.id, output: result.output, isError: result.isError }));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// Serial execution
|
|
115
|
+
for (const tc of batch.calls) {
|
|
116
|
+
yield { type: "tool_call_start", toolName: tc.toolName, callId: tc.id };
|
|
117
|
+
const result = await executeSingleTool(tc, tools, context, permissionMode, askUser);
|
|
118
|
+
yield {
|
|
119
|
+
type: "tool_call_end",
|
|
120
|
+
callId: tc.id,
|
|
121
|
+
output: result.output,
|
|
122
|
+
isError: result.isError,
|
|
123
|
+
};
|
|
124
|
+
state?.messages.push(createToolResultMessage({ callId: tc.id, output: result.output, isError: result.isError }));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function executeSingleTool(toolCall, tools, context, permissionMode, askUser) {
|
|
130
|
+
const tool = findToolByName(tools, toolCall.toolName);
|
|
131
|
+
if (!tool) {
|
|
132
|
+
return { output: `Error: Unknown tool '${toolCall.toolName}'`, isError: true };
|
|
133
|
+
}
|
|
134
|
+
// Parse input
|
|
135
|
+
const parsed = tool.inputSchema.safeParse(toolCall.arguments);
|
|
136
|
+
if (!parsed.success) {
|
|
137
|
+
return { output: `Validation error: ${parsed.error.message}`, isError: true };
|
|
138
|
+
}
|
|
139
|
+
// Check permissions
|
|
140
|
+
const perm = checkPermission(permissionMode, tool.riskLevel, tool.isReadOnly(parsed.data));
|
|
141
|
+
if (!perm.allowed && perm.reason === "needs-approval") {
|
|
142
|
+
if (askUser) {
|
|
143
|
+
const allowed = await askUser(tool.name, JSON.stringify(toolCall.arguments).slice(0, 200));
|
|
144
|
+
if (!allowed) {
|
|
145
|
+
return { output: "Permission denied by user.", isError: true };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
return { output: `Permission denied: ${perm.reason}`, isError: true };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else if (!perm.allowed) {
|
|
153
|
+
return { output: `Permission denied: ${perm.reason}`, isError: true };
|
|
154
|
+
}
|
|
155
|
+
// Execute
|
|
156
|
+
try {
|
|
157
|
+
return await tool.call(parsed.data, context);
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
return { output: `Tool error: ${err instanceof Error ? err.message : String(err)}`, isError: true };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function partitionToolCalls(toolCalls, tools) {
|
|
164
|
+
const batches = [];
|
|
165
|
+
let currentConcurrent = [];
|
|
166
|
+
for (const tc of toolCalls) {
|
|
167
|
+
const tool = findToolByName(tools, tc.toolName);
|
|
168
|
+
const isSafe = tool ? tool.isConcurrencySafe(tc.arguments) : false;
|
|
169
|
+
if (isSafe) {
|
|
170
|
+
currentConcurrent.push(tc);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
if (currentConcurrent.length > 0) {
|
|
174
|
+
batches.push({ concurrent: true, calls: currentConcurrent });
|
|
175
|
+
currentConcurrent = [];
|
|
176
|
+
}
|
|
177
|
+
batches.push({ concurrent: false, calls: [tc] });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (currentConcurrent.length > 0) {
|
|
181
|
+
batches.push({ concurrent: true, calls: currentConcurrent });
|
|
182
|
+
}
|
|
183
|
+
return batches;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAO5D,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAmBzD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,KAAK,CAC1B,WAAmB,EACnB,MAAmB,EACnB,mBAA8B,EAAE;IAEhC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,iBAAiB,CAAC;IACtD,MAAM,WAAW,GAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;IAE/D,MAAM,KAAK,GAAU;QACnB,QAAQ,EAAE;YACR,GAAG,gBAAgB;YACnB,iBAAiB,CAAC,WAAW,CAAC;SAC/B;QACD,IAAI,EAAE,CAAC;QACP,SAAS,EAAE,CAAC;KACb,CAAC;IAEF,6CAA6C;IAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,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,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Tool } from "../../Tool.js";
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
command: z.ZodString;
|
|
5
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
command: string;
|
|
8
|
+
timeout?: number | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
command: string;
|
|
11
|
+
timeout?: number | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const BashTool: Tool<typeof inputSchema>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/BashTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAA2B,MAAM,eAAe,CAAC;AAEnE,QAAA,MAAM,WAAW;;;;;;;;;EAGf,CAAC;AAMH,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,OAAO,WAAW,CA+E7C,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
const inputSchema = z.object({
|
|
4
|
+
command: z.string(),
|
|
5
|
+
timeout: z.number().optional(),
|
|
6
|
+
});
|
|
7
|
+
const MAX_OUTPUT = 100_000;
|
|
8
|
+
const DEFAULT_TIMEOUT = 120_000;
|
|
9
|
+
const MAX_TIMEOUT = 600_000;
|
|
10
|
+
export const BashTool = {
|
|
11
|
+
name: "Bash",
|
|
12
|
+
description: "Execute a shell command and return its output.",
|
|
13
|
+
inputSchema,
|
|
14
|
+
riskLevel: "high",
|
|
15
|
+
isReadOnly() {
|
|
16
|
+
return false;
|
|
17
|
+
},
|
|
18
|
+
isConcurrencySafe() {
|
|
19
|
+
return false;
|
|
20
|
+
},
|
|
21
|
+
call(input, context) {
|
|
22
|
+
// input.timeout is in seconds; convert to ms. Default 120s.
|
|
23
|
+
const timeoutMs = Math.min((input.timeout ?? 120) * 1000, MAX_TIMEOUT);
|
|
24
|
+
const isWin = process.platform === "win32";
|
|
25
|
+
const shell = isWin ? "cmd.exe" : "/bin/bash";
|
|
26
|
+
const shellArgs = isWin ? ["/c", input.command] : ["-c", input.command];
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
|
+
let stdout = "";
|
|
29
|
+
let stderr = "";
|
|
30
|
+
let killed = false;
|
|
31
|
+
const proc = spawn(shell, shellArgs, {
|
|
32
|
+
cwd: context.workingDir,
|
|
33
|
+
env: process.env,
|
|
34
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
35
|
+
});
|
|
36
|
+
const timer = setTimeout(() => {
|
|
37
|
+
killed = true;
|
|
38
|
+
proc.kill("SIGTERM");
|
|
39
|
+
}, timeoutMs);
|
|
40
|
+
proc.stdout.on("data", (chunk) => {
|
|
41
|
+
stdout += chunk.toString();
|
|
42
|
+
});
|
|
43
|
+
proc.stderr.on("data", (chunk) => {
|
|
44
|
+
stderr += chunk.toString();
|
|
45
|
+
});
|
|
46
|
+
if (context.abortSignal) {
|
|
47
|
+
context.abortSignal.addEventListener("abort", () => {
|
|
48
|
+
proc.kill("SIGTERM");
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
proc.on("close", (code) => {
|
|
52
|
+
clearTimeout(timer);
|
|
53
|
+
let output = stdout + (stderr ? "\n[stderr]\n" + stderr : "");
|
|
54
|
+
if (output.length > MAX_OUTPUT) {
|
|
55
|
+
output = output.slice(0, MAX_OUTPUT) + "\n... [truncated]";
|
|
56
|
+
}
|
|
57
|
+
if (killed) {
|
|
58
|
+
output += "\n[timed out]";
|
|
59
|
+
}
|
|
60
|
+
resolve({
|
|
61
|
+
output: output || `(exit code ${code})`,
|
|
62
|
+
isError: code !== 0,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
proc.on("error", (err) => {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
resolve({ output: `Error spawning process: ${err.message}`, isError: true });
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
prompt() {
|
|
72
|
+
return `Execute a bash command and return stdout/stderr. Parameters:
|
|
73
|
+
- command (string, required): The shell command to run.
|
|
74
|
+
- timeout (number, optional): Timeout in seconds (default 120, max 600).
|
|
75
|
+
Output is truncated at 100K characters.`;
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/BashTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,OAAO,CAAC;AAC3B,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,MAAM,CAAC,MAAM,QAAQ,GAA6B;IAChD,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,gDAAgD;IAC7D,WAAW;IACX,SAAS,EAAE,MAAM;IAEjB,UAAU;QACR,OAAO,KAAK,CAAC;IACf,CAAC;IAED,iBAAiB;QACf,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,OAAO;QACjB,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
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Tool } from "../../Tool.js";
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
file_path: z.ZodString;
|
|
5
|
+
old_string: z.ZodString;
|
|
6
|
+
new_string: z.ZodString;
|
|
7
|
+
replace_all: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
file_path: string;
|
|
10
|
+
old_string: string;
|
|
11
|
+
new_string: string;
|
|
12
|
+
replace_all?: boolean | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
file_path: string;
|
|
15
|
+
old_string: string;
|
|
16
|
+
new_string: string;
|
|
17
|
+
replace_all?: boolean | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const FileEditTool: Tool<typeof inputSchema>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/FileEditTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,IAAI,EAA2B,MAAM,eAAe,CAAC;AAEnE,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;EAKf,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,IAAI,CAAC,OAAO,WAAW,CAqEjD,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import * as fs from "fs/promises";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
const inputSchema = z.object({
|
|
5
|
+
file_path: z.string(),
|
|
6
|
+
old_string: z.string(),
|
|
7
|
+
new_string: z.string(),
|
|
8
|
+
replace_all: z.boolean().optional(),
|
|
9
|
+
});
|
|
10
|
+
export const FileEditTool = {
|
|
11
|
+
name: "Edit",
|
|
12
|
+
description: "Perform string replacement in a file.",
|
|
13
|
+
inputSchema,
|
|
14
|
+
riskLevel: "medium",
|
|
15
|
+
isReadOnly() {
|
|
16
|
+
return false;
|
|
17
|
+
},
|
|
18
|
+
isConcurrencySafe() {
|
|
19
|
+
return false;
|
|
20
|
+
},
|
|
21
|
+
async call(input, context) {
|
|
22
|
+
const filePath = path.isAbsolute(input.file_path)
|
|
23
|
+
? input.file_path
|
|
24
|
+
: path.resolve(context.workingDir, input.file_path);
|
|
25
|
+
try {
|
|
26
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
27
|
+
if (!content.includes(input.old_string)) {
|
|
28
|
+
return {
|
|
29
|
+
output: `Error: old_string not found in ${filePath}.`,
|
|
30
|
+
isError: true,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (!input.replace_all) {
|
|
34
|
+
const firstIdx = content.indexOf(input.old_string);
|
|
35
|
+
const lastIdx = content.lastIndexOf(input.old_string);
|
|
36
|
+
if (firstIdx !== lastIdx) {
|
|
37
|
+
return {
|
|
38
|
+
output: `Error: old_string is not unique in ${filePath} (found multiple occurrences). Use replace_all: true to replace all, or provide more context to make it unique.`,
|
|
39
|
+
isError: true,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const newContent = input.replace_all
|
|
44
|
+
? content.split(input.old_string).join(input.new_string)
|
|
45
|
+
: content.replace(input.old_string, input.new_string);
|
|
46
|
+
await fs.writeFile(filePath, newContent, "utf-8");
|
|
47
|
+
const occurrences = input.replace_all
|
|
48
|
+
? content.split(input.old_string).length - 1
|
|
49
|
+
: 1;
|
|
50
|
+
return {
|
|
51
|
+
output: `Edited ${filePath}: replaced ${occurrences} occurrence(s).\n--- old\n${input.old_string}\n+++ new\n${input.new_string}`,
|
|
52
|
+
isError: false,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
if (err.code === "ENOENT") {
|
|
57
|
+
return { output: `Error: File not found: ${filePath}`, isError: true };
|
|
58
|
+
}
|
|
59
|
+
return { output: `Error editing file: ${err.message}`, isError: true };
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
prompt() {
|
|
63
|
+
return `Perform exact string replacement in a file. Parameters:
|
|
64
|
+
- file_path (string, required): Path to the file to edit.
|
|
65
|
+
- old_string (string, required): The exact text to find and replace.
|
|
66
|
+
- new_string (string, required): The replacement text.
|
|
67
|
+
- replace_all (boolean, optional): Replace all occurrences (default false). If false, old_string must be unique.`;
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/FileEditTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAA6B;IACpD,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,uCAAuC;IACpD,WAAW;IACX,SAAS,EAAE,QAAQ;IAEnB,UAAU;QACR,OAAO,KAAK,CAAC;IACf,CAAC;IAED,iBAAiB;QACf,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC;YAC/C,CAAC,CAAC,KAAK,CAAC,SAAS;YACjB,CAAC,CAA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N,OAAO;gBACL,MAAM,EAAE,UAAU,QAAQ,cAAc,WAAW,6BAA6B,KAAK,CAAC,UAAU,cAAc,KAAK,CAAC,UAAU,EAAE;gBAChI,OAAO,EAAE,KAAK;aACf,CAAC;QACJ,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC1B,OAAO,EAAE,MAAM,EAAE,0BAA0B,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YACzE,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,uBAAuB,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;;;;iHAIsG,CAAC;IAChH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Tool } from "../../Tool.js";
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
file_path: z.ZodString;
|
|
5
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
file_path: string;
|
|
9
|
+
offset?: number | undefined;
|
|
10
|
+
limit?: number | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
file_path: string;
|
|
13
|
+
offset?: number | undefined;
|
|
14
|
+
limit?: number | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const FileReadTool: Tool<typeof inputSchema>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/FileReadTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,IAAI,EAA2B,MAAM,eAAe,CAAC;AAEnE,QAAA,MAAM,WAAW;;;;;;;;;;;;EAIf,CAAC;AAIH,eAAO,MAAM,YAAY,EAAE,IAAI,CAAC,OAAO,WAAW,CA4DjD,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import * as fs from "fs/promises";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
const inputSchema = z.object({
|
|
5
|
+
file_path: z.string(),
|
|
6
|
+
offset: z.number().optional(),
|
|
7
|
+
limit: z.number().optional(),
|
|
8
|
+
});
|
|
9
|
+
const DEFAULT_LIMIT = 2000;
|
|
10
|
+
export const FileReadTool = {
|
|
11
|
+
name: "Read",
|
|
12
|
+
description: "Read a file from the filesystem with optional line range.",
|
|
13
|
+
inputSchema,
|
|
14
|
+
riskLevel: "low",
|
|
15
|
+
isReadOnly() {
|
|
16
|
+
return true;
|
|
17
|
+
},
|
|
18
|
+
isConcurrencySafe() {
|
|
19
|
+
return true;
|
|
20
|
+
},
|
|
21
|
+
async call(input, context) {
|
|
22
|
+
const filePath = path.isAbsolute(input.file_path)
|
|
23
|
+
? input.file_path
|
|
24
|
+
: path.resolve(context.workingDir, input.file_path);
|
|
25
|
+
try {
|
|
26
|
+
const stat = await fs.stat(filePath);
|
|
27
|
+
if (stat.isDirectory()) {
|
|
28
|
+
return { output: `Error: ${filePath} is a directory, not a file.`, isError: true };
|
|
29
|
+
}
|
|
30
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
31
|
+
const allLines = content.split("\n");
|
|
32
|
+
const offset = Math.max(0, (input.offset ?? 1) - 1);
|
|
33
|
+
const limit = input.limit ?? DEFAULT_LIMIT;
|
|
34
|
+
const lines = allLines.slice(offset, offset + limit);
|
|
35
|
+
const numbered = lines
|
|
36
|
+
.map((line, i) => `${offset + i + 1}\t${line}`)
|
|
37
|
+
.join("\n");
|
|
38
|
+
const total = allLines.length;
|
|
39
|
+
const shown = lines.length;
|
|
40
|
+
let result = numbered;
|
|
41
|
+
if (shown < total) {
|
|
42
|
+
result += `\n\n(Showing lines ${offset + 1}-${offset + shown} of ${total})`;
|
|
43
|
+
}
|
|
44
|
+
return { output: result, isError: false };
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
if (err.code === "ENOENT") {
|
|
48
|
+
return { output: `Error: File not found: ${filePath}`, isError: true };
|
|
49
|
+
}
|
|
50
|
+
if (err.code === "EACCES") {
|
|
51
|
+
return { output: `Error: Permission denied: ${filePath}`, isError: true };
|
|
52
|
+
}
|
|
53
|
+
return { output: `Error reading file: ${err.message}`, isError: true };
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
prompt() {
|
|
57
|
+
return `Read a file and return its contents with line numbers. Parameters:
|
|
58
|
+
- file_path (string, required): Absolute or relative path to the file.
|
|
59
|
+
- offset (number, optional): Line number to start from (1-based, default 1).
|
|
60
|
+
- limit (number, optional): Maximum number of lines to return (default 2000).`;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/FileReadTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,MAAM,CAAC,MAAM,YAAY,GAA6B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AC,KAAK,IAAI,EAAE,CAAC;iBAC9C,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC;YAC9B,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;YAC3B,IAAI,MAAM,GAAG,QAAQ,CAAC;YACtB,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC;gBAClB,MAAM,IAAI,sBAAsB,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,KAAK,OAAO,KAAK,GAAG,CAAC;YAC9E,CAAC;YAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5C,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC1B,OAAO,EAAE,MAAM,EAAE,0BAA0B,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YACzE,CAAC;YACD,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC1B,OAAO,EAAE,MAAM,EAAE,6BAA6B,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC5E,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,uBAAuB,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;;;8EAGmE,CAAC;IAC7E,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Tool } from "../../Tool.js";
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
file_path: z.ZodString;
|
|
5
|
+
content: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
content: string;
|
|
8
|
+
file_path: string;
|
|
9
|
+
}, {
|
|
10
|
+
content: string;
|
|
11
|
+
file_path: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const FileWriteTool: Tool<typeof inputSchema>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/FileWriteTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,IAAI,EAA2B,MAAM,eAAe,CAAC;AAEnE,QAAA,MAAM,WAAW;;;;;;;;;EAGf,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,IAAI,CAAC,OAAO,WAAW,CAqClD,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import * as fs from "fs/promises";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
const inputSchema = z.object({
|
|
5
|
+
file_path: z.string(),
|
|
6
|
+
content: z.string(),
|
|
7
|
+
});
|
|
8
|
+
export const FileWriteTool = {
|
|
9
|
+
name: "Write",
|
|
10
|
+
description: "Write content to a file, creating parent directories as needed.",
|
|
11
|
+
inputSchema,
|
|
12
|
+
riskLevel: "medium",
|
|
13
|
+
isReadOnly() {
|
|
14
|
+
return false;
|
|
15
|
+
},
|
|
16
|
+
isConcurrencySafe() {
|
|
17
|
+
return false;
|
|
18
|
+
},
|
|
19
|
+
async call(input, context) {
|
|
20
|
+
const filePath = path.isAbsolute(input.file_path)
|
|
21
|
+
? input.file_path
|
|
22
|
+
: path.resolve(context.workingDir, input.file_path);
|
|
23
|
+
try {
|
|
24
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
25
|
+
await fs.writeFile(filePath, input.content, "utf-8");
|
|
26
|
+
const lineCount = input.content.split("\n").length;
|
|
27
|
+
return {
|
|
28
|
+
output: `Wrote ${filePath} (${lineCount} lines).`,
|
|
29
|
+
isError: false,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
return { output: `Error writing file: ${err.message}`, isError: true };
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
prompt() {
|
|
37
|
+
return `Write content to a file, creating parent directories if needed. Parameters:
|
|
38
|
+
- file_path (string, required): Absolute or relative path to the file.
|
|
39
|
+
- content (string, required): The full content to write.`;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/FileWriteTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAA6B;IACrD,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,iEAAiE;IAC9E,WAAW;IACX,SAAS,EAAE,QAAQ;IAEnB,UAAU;QACR,OAAO,KAAK,CAAC;IACf,CAAC;IAED,iBAAiB;QACf,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC;YAC/C,CAAC,CAAC,KAAK,CAAC,SAAS;YACjB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;QAEtD,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC5D,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACrD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;YACnD,OAAO;gBACL,MAAM,EAAE,SAAS,QAAQ,KAAK,SAAS,UAAU;gBACjD,OAAO,EAAE,KAAK;aACf,CAAC;QACJ,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,MAAM,EAAE,uBAAuB,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;;yDAE8C,CAAC;IACxD,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Tool } from "../../Tool.js";
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
pattern: z.ZodString;
|
|
5
|
+
path: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
pattern: string;
|
|
8
|
+
path?: string | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
pattern: string;
|
|
11
|
+
path?: string | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const GlobTool: Tool<typeof inputSchema>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/GlobTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,IAAI,EAA2B,MAAM,eAAe,CAAC;AAEnE,QAAA,MAAM,WAAW;;;;;;;;;EAGf,CAAC;AAuDH,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,OAAO,WAAW,CA+D7C,CAAC"}
|