@morphllm/morphsdk 0.2.66 → 0.2.68
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/dist/anthropic-B6my2oBx.d.ts +56 -0
- package/dist/{chunk-ZO4PPFCZ.js → chunk-223ZMZP6.js} +30 -5
- package/dist/chunk-223ZMZP6.js.map +1 -0
- package/dist/{chunk-GGYMQZXI.js → chunk-6RFT7K7F.js} +23 -3
- package/dist/chunk-6RFT7K7F.js.map +1 -0
- package/dist/chunk-AAIUUX4Y.js +80 -0
- package/dist/chunk-AAIUUX4Y.js.map +1 -0
- package/dist/chunk-BYNVJ4ON.js +57 -0
- package/dist/chunk-BYNVJ4ON.js.map +1 -0
- package/dist/{chunk-ASO5YWQ4.js → chunk-FURFQDXF.js} +7 -4
- package/dist/{chunk-ASO5YWQ4.js.map → chunk-FURFQDXF.js.map} +1 -1
- package/dist/{chunk-QZNGKOCZ.js → chunk-HBWJLKNM.js} +2 -2
- package/dist/chunk-HKJ2B2AA.js +15 -0
- package/dist/{chunk-XLSODV6H.js → chunk-JPGX6WEV.js} +3 -3
- package/dist/{chunk-AQD2JCLI.js → chunk-K3EHH3C4.js} +3 -3
- package/dist/{chunk-IZISG7DL.js → chunk-MFZP347Z.js} +10 -7
- package/dist/chunk-MFZP347Z.js.map +1 -0
- package/dist/{chunk-7V2KIZT5.js → chunk-QEGH3CWQ.js} +3 -3
- package/dist/{chunk-5QIWYEHJ.js → chunk-RTDKF6NS.js} +2 -2
- package/dist/chunk-S6KU22MU.js +396 -0
- package/dist/chunk-S6KU22MU.js.map +1 -0
- package/dist/{chunk-SU5CKH4F.js → chunk-SXE54MIC.js} +9 -9
- package/dist/chunk-VDJGZIQ5.js +96 -0
- package/dist/chunk-VDJGZIQ5.js.map +1 -0
- package/dist/{chunk-7JEL2VZO.js → chunk-VLZEBK7S.js} +3 -3
- package/dist/{chunk-IUG2FHNN.js → chunk-W76ICQKY.js} +2 -2
- package/dist/client.cjs +443 -11
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +13 -12
- package/dist/{gemini-DPFWWG3k.d.ts → gemini-BIFBiIjY.d.ts} +5 -3
- package/dist/git/client.js +1 -1
- package/dist/git/config.js +1 -1
- package/dist/git/index.js +1 -1
- package/dist/index.cjs +443 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -13
- package/dist/modelrouter/core.js +1 -1
- package/dist/modelrouter/index.js +1 -1
- package/dist/openai-BQMeDFef.d.ts +81 -0
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.d.ts +3 -50
- package/dist/tools/browser/anthropic.js +6 -65
- package/dist/tools/browser/anthropic.js.map +1 -1
- package/dist/tools/browser/core.cjs +9 -6
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.d.ts +6 -6
- package/dist/tools/browser/core.js +2 -2
- package/dist/tools/browser/index.cjs +278 -6
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.d.ts +125 -1
- package/dist/tools/browser/index.js +98 -2
- package/dist/tools/browser/index.js.map +1 -1
- package/dist/tools/browser/live.js +1 -1
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.d.ts +3 -72
- package/dist/tools/browser/openai.js +9 -75
- package/dist/tools/browser/openai.js.map +1 -1
- package/dist/tools/browser/prompts.js +1 -1
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.d.ts +3 -68
- package/dist/tools/browser/vercel.js +6 -42
- package/dist/tools/browser/vercel.js.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +1 -1
- package/dist/tools/codebase_search/core.js +1 -1
- package/dist/tools/codebase_search/index.js +1 -1
- package/dist/tools/codebase_search/openai.js +1 -1
- package/dist/tools/codebase_search/prompts.js +1 -1
- package/dist/tools/codebase_search/vercel.js +1 -1
- package/dist/tools/fastapply/anthropic.js +2 -2
- package/dist/tools/fastapply/core.js +1 -1
- package/dist/tools/fastapply/index.js +4 -4
- package/dist/tools/fastapply/openai.js +2 -2
- package/dist/tools/fastapply/prompts.js +1 -1
- package/dist/tools/fastapply/vercel.js +2 -2
- package/dist/tools/index.js +4 -4
- package/dist/tools/utils/resilience.js +1 -1
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/formatter.js +1 -1
- package/dist/tools/warp_grep/agent/parser.js +1 -1
- package/dist/tools/warp_grep/agent/prompt.js +1 -1
- package/dist/tools/warp_grep/agent/runner.js +1 -1
- package/dist/tools/warp_grep/anthropic.cjs +434 -5
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +6 -5
- package/dist/tools/warp_grep/client.cjs +434 -5
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +5 -4
- package/dist/tools/warp_grep/gemini.cjs +438 -6
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +1 -1
- package/dist/tools/warp_grep/gemini.js +8 -5
- package/dist/tools/warp_grep/harness.cjs +417 -4
- package/dist/tools/warp_grep/harness.cjs.map +1 -1
- package/dist/tools/warp_grep/harness.js +3 -2
- package/dist/tools/warp_grep/harness.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +437 -6
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +1 -1
- package/dist/tools/warp_grep/index.js +9 -8
- package/dist/tools/warp_grep/openai.cjs +434 -5
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +6 -5
- package/dist/tools/warp_grep/providers/local.cjs +417 -4
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.d.ts +6 -0
- package/dist/tools/warp_grep/providers/local.js +3 -2
- package/dist/tools/warp_grep/providers/remote.cjs +408 -1
- package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/remote.d.ts +7 -0
- package/dist/tools/warp_grep/providers/remote.js +3 -2
- package/dist/tools/warp_grep/utils/files.js +1 -1
- package/dist/tools/warp_grep/utils/paths.js +1 -1
- package/dist/tools/warp_grep/utils/ripgrep.js +1 -1
- package/dist/tools/warp_grep/vercel.cjs +434 -5
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +6 -5
- package/dist/vercel-CsnNSdze.d.ts +74 -0
- package/package.json +1 -1
- package/dist/chunk-GGYMQZXI.js.map +0 -1
- package/dist/chunk-IZISG7DL.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-ZO4PPFCZ.js.map +0 -1
- /package/dist/{chunk-QZNGKOCZ.js.map → chunk-HBWJLKNM.js.map} +0 -0
- /package/dist/{chunk-PZ5AY32C.js.map → chunk-HKJ2B2AA.js.map} +0 -0
- /package/dist/{chunk-XLSODV6H.js.map → chunk-JPGX6WEV.js.map} +0 -0
- /package/dist/{chunk-AQD2JCLI.js.map → chunk-K3EHH3C4.js.map} +0 -0
- /package/dist/{chunk-7V2KIZT5.js.map → chunk-QEGH3CWQ.js.map} +0 -0
- /package/dist/{chunk-5QIWYEHJ.js.map → chunk-RTDKF6NS.js.map} +0 -0
- /package/dist/{chunk-SU5CKH4F.js.map → chunk-SXE54MIC.js.map} +0 -0
- /package/dist/{chunk-7JEL2VZO.js.map → chunk-VLZEBK7S.js.map} +0 -0
- /package/dist/{chunk-IUG2FHNN.js.map → chunk-W76ICQKY.js.map} +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BROWSER_SYSTEM_PROMPT,
|
|
3
|
+
BROWSER_TOOL_DESCRIPTION
|
|
4
|
+
} from "./chunk-EI4UKP24.js";
|
|
5
|
+
import {
|
|
6
|
+
executeBrowserTask
|
|
7
|
+
} from "./chunk-MFZP347Z.js";
|
|
8
|
+
import {
|
|
9
|
+
__export
|
|
10
|
+
} from "./chunk-HKJ2B2AA.js";
|
|
11
|
+
|
|
12
|
+
// tools/browser/openai.ts
|
|
13
|
+
var openai_exports = {};
|
|
14
|
+
__export(openai_exports, {
|
|
15
|
+
browserTool: () => browserTool,
|
|
16
|
+
createBrowserTool: () => createBrowserTool,
|
|
17
|
+
execute: () => execute,
|
|
18
|
+
formatResult: () => formatResult,
|
|
19
|
+
getSystemPrompt: () => getSystemPrompt
|
|
20
|
+
});
|
|
21
|
+
var browserTool = {
|
|
22
|
+
type: "function",
|
|
23
|
+
function: {
|
|
24
|
+
name: "browser_task",
|
|
25
|
+
description: BROWSER_TOOL_DESCRIPTION,
|
|
26
|
+
parameters: {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: {
|
|
29
|
+
task: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: 'Natural language description of what to do (e.g., "Test checkout flow for buying a pineapple")'
|
|
32
|
+
},
|
|
33
|
+
url: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "Starting URL (e.g., https://3000-xyz.e2b.dev). Required if navigating to a specific page."
|
|
36
|
+
},
|
|
37
|
+
max_steps: {
|
|
38
|
+
type: "number",
|
|
39
|
+
description: "Maximum number of browser actions to take (1-50). Default: 10. Use 15-30 for complex flows.",
|
|
40
|
+
default: 10
|
|
41
|
+
},
|
|
42
|
+
region: {
|
|
43
|
+
type: "string",
|
|
44
|
+
enum: ["sfo", "lon"],
|
|
45
|
+
description: "Browserless region: sfo (US West Coast) or lon (Europe). Default: sfo.",
|
|
46
|
+
default: "sfo"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
required: ["task"]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
async function execute(input, config) {
|
|
54
|
+
const parsedInput = typeof input === "string" ? JSON.parse(input) : input;
|
|
55
|
+
return executeBrowserTask(parsedInput, config);
|
|
56
|
+
}
|
|
57
|
+
function formatResult(result) {
|
|
58
|
+
if (result.success) {
|
|
59
|
+
const parts = [
|
|
60
|
+
"\u2705 Browser task completed successfully",
|
|
61
|
+
`Steps taken: ${result.steps_taken ?? 0}`,
|
|
62
|
+
result.execution_time_ms ? `Execution time: ${result.execution_time_ms}ms` : null,
|
|
63
|
+
"",
|
|
64
|
+
"Result:",
|
|
65
|
+
result.result || "Task completed"
|
|
66
|
+
];
|
|
67
|
+
return parts.filter(Boolean).join("\n");
|
|
68
|
+
}
|
|
69
|
+
return `\u274C Browser task failed: ${result.error || "Unknown error"}`;
|
|
70
|
+
}
|
|
71
|
+
function getSystemPrompt() {
|
|
72
|
+
return BROWSER_SYSTEM_PROMPT;
|
|
73
|
+
}
|
|
74
|
+
function createBrowserTool(config) {
|
|
75
|
+
return Object.assign({}, browserTool, {
|
|
76
|
+
execute: async (input) => {
|
|
77
|
+
return execute(input, config);
|
|
78
|
+
},
|
|
79
|
+
formatResult: (result) => {
|
|
80
|
+
return formatResult(result);
|
|
81
|
+
},
|
|
82
|
+
getSystemPrompt: () => {
|
|
83
|
+
return getSystemPrompt();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
browserTool,
|
|
90
|
+
execute,
|
|
91
|
+
formatResult,
|
|
92
|
+
getSystemPrompt,
|
|
93
|
+
createBrowserTool,
|
|
94
|
+
openai_exports
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=chunk-VDJGZIQ5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/browser/openai.ts"],"sourcesContent":["/**\n * OpenAI SDK adapter for browser automation tool\n */\n\nimport type { ChatCompletionTool } from 'openai/resources/chat/completions.mjs';\nimport { executeBrowserTask } from './core.js';\nimport type {\n BrowserConfig,\n BrowserTaskInput,\n BrowserTaskResult,\n} from './types.js';\nimport { BROWSER_TOOL_DESCRIPTION, BROWSER_SYSTEM_PROMPT } from './prompts.js';\n\n/**\n * OpenAI tool definition for browser automation\n */\nexport const browserTool: ChatCompletionTool = {\n type: 'function',\n function: {\n name: 'browser_task',\n description: BROWSER_TOOL_DESCRIPTION,\n parameters: {\n type: 'object',\n properties: {\n task: {\n type: 'string',\n description: 'Natural language description of what to do (e.g., \"Test checkout flow for buying a pineapple\")',\n },\n url: {\n type: 'string',\n description: 'Starting URL (e.g., https://3000-xyz.e2b.dev). Required if navigating to a specific page.',\n },\n max_steps: {\n type: 'number',\n description: 'Maximum number of browser actions to take (1-50). Default: 10. Use 15-30 for complex flows.',\n default: 10,\n },\n region: {\n type: 'string',\n enum: ['sfo', 'lon'],\n description: 'Browserless region: sfo (US West Coast) or lon (Europe). Default: sfo.',\n default: 'sfo',\n },\n },\n required: ['task'],\n },\n },\n};\n\n/**\n * Execute a browser task (for use in tool call handling)\n * \n * @param input - Tool input parameters (may be JSON string)\n * @param config - Optional browser worker configuration\n * @returns Task execution result\n */\nexport async function execute(\n input: BrowserTaskInput | string,\n config?: BrowserConfig\n): Promise<BrowserTaskResult> {\n // Parse input if it's a JSON string (from OpenAI tool call)\n const parsedInput = typeof input === 'string' ? JSON.parse(input) : input;\n return executeBrowserTask(parsedInput, config);\n}\n\n/**\n * Format browser task result for OpenAI tool result\n * \n * Returns a concise summary suitable for agent context. The full result object\n * (with urls, errors, action_history, judgement, etc.) is available when calling\n * execute() directly, but this formatted string omits those details to save tokens.\n * \n * @param result - Browser task result with full history data\n * @returns Formatted string summary for tool result\n */\nexport function formatResult(result: BrowserTaskResult): string {\n if (result.success) {\n const parts = [\n '✅ Browser task completed successfully',\n `Steps taken: ${result.steps_taken ?? 0}`,\n result.execution_time_ms ? `Execution time: ${result.execution_time_ms}ms` : null,\n '',\n 'Result:',\n result.result || 'Task completed',\n ];\n return parts.filter(Boolean).join('\\n');\n }\n\n return `❌ Browser task failed: ${result.error || 'Unknown error'}`;\n}\n\n/**\n * Get system prompt for browser automation\n */\nexport function getSystemPrompt(): string {\n return BROWSER_SYSTEM_PROMPT;\n}\n\n/**\n * Create a configured browser tool with execute and formatResult methods\n * \n * @param config - Browser worker configuration\n * @returns Tool definition with execute and formatResult methods\n * \n * @example\n * ```typescript\n * import OpenAI from 'openai';\n * import { createBrowserTool } from 'morphsdk/tools/browser/openai';\n * \n * const tool = createBrowserTool({\n * apiUrl: 'https://browser-worker.example.com'\n * });\n * \n * const client = new OpenAI();\n * \n * const response = await client.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [tool], // tool itself is the ChatCompletionTool\n * messages: [{\n * role: 'user',\n * content: 'Test the checkout at https://3000-abc.e2b.dev'\n * }]\n * });\n * \n * // Execute and format\n * const result = await tool.execute(toolCallArgs);\n * const formatted = tool.formatResult(result);\n * ```\n */\nexport function createBrowserTool(config?: BrowserConfig) {\n return Object.assign({}, browserTool, {\n execute: async (input: BrowserTaskInput | string): Promise<BrowserTaskResult> => {\n return execute(input, config);\n },\n formatResult: (result: BrowserTaskResult): string => {\n return formatResult(result);\n },\n getSystemPrompt: (): string => {\n return getSystemPrompt();\n },\n });\n}\n\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,IAAM,cAAkC;AAAA,EAC7C,MAAM;AAAA,EACN,UAAU;AAAA,IACR,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY;AAAA,MACV,MAAM;AAAA,MACN,YAAY;AAAA,QACV,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,KAAK;AAAA,UACH,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,QACA,QAAQ;AAAA,UACN,MAAM;AAAA,UACN,MAAM,CAAC,OAAO,KAAK;AAAA,UACnB,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU,CAAC,MAAM;AAAA,IACnB;AAAA,EACF;AACF;AASA,eAAsB,QACpB,OACA,QAC4B;AAE5B,QAAM,cAAc,OAAO,UAAU,WAAW,KAAK,MAAM,KAAK,IAAI;AACpE,SAAO,mBAAmB,aAAa,MAAM;AAC/C;AAYO,SAAS,aAAa,QAAmC;AAC9D,MAAI,OAAO,SAAS;AAClB,UAAM,QAAQ;AAAA,MACZ;AAAA,MACA,gBAAgB,OAAO,eAAe,CAAC;AAAA,MACvC,OAAO,oBAAoB,mBAAmB,OAAO,iBAAiB,OAAO;AAAA,MAC7E;AAAA,MACA;AAAA,MACA,OAAO,UAAU;AAAA,IACnB;AACA,WAAO,MAAM,OAAO,OAAO,EAAE,KAAK,IAAI;AAAA,EACxC;AAEA,SAAO,+BAA0B,OAAO,SAAS,eAAe;AAClE;AAKO,SAAS,kBAA0B;AACxC,SAAO;AACT;AAiCO,SAAS,kBAAkB,QAAwB;AACxD,SAAO,OAAO,OAAO,CAAC,GAAG,aAAa;AAAA,IACpC,SAAS,OAAO,UAAiE;AAC/E,aAAO,QAAQ,OAAO,MAAM;AAAA,IAC9B;AAAA,IACA,cAAc,CAAC,WAAsC;AACnD,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,iBAAiB,MAAc;AAC7B,aAAO,gBAAgB;AAAA,IACzB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-SUBBMTMY.js";
|
|
4
4
|
import {
|
|
5
5
|
RemoteCommandsProvider
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6RFT7K7F.js";
|
|
7
7
|
import {
|
|
8
8
|
LocalRipgrepProvider
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-223ZMZP6.js";
|
|
10
10
|
|
|
11
11
|
// tools/warp_grep/client.ts
|
|
12
12
|
var WarpGrepClient = class {
|
|
@@ -115,4 +115,4 @@ export {
|
|
|
115
115
|
executeToolCall,
|
|
116
116
|
formatResult
|
|
117
117
|
};
|
|
118
|
-
//# sourceMappingURL=chunk-
|
|
118
|
+
//# sourceMappingURL=chunk-VLZEBK7S.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-63WE2C5R.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HKJ2B2AA.js";
|
|
11
11
|
|
|
12
12
|
// tools/fastapply/anthropic.ts
|
|
13
13
|
var anthropic_exports = {};
|
|
@@ -91,4 +91,4 @@ export {
|
|
|
91
91
|
getSystemPrompt,
|
|
92
92
|
anthropic_exports
|
|
93
93
|
};
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-W76ICQKY.js.map
|
package/dist/client.cjs
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +30,394 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// node_modules/ignore/index.js
|
|
34
|
+
var require_ignore = __commonJS({
|
|
35
|
+
"node_modules/ignore/index.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
function makeArray(subject) {
|
|
38
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
39
|
+
}
|
|
40
|
+
var EMPTY = "";
|
|
41
|
+
var SPACE = " ";
|
|
42
|
+
var ESCAPE = "\\";
|
|
43
|
+
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
44
|
+
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
45
|
+
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
46
|
+
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
47
|
+
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
48
|
+
var REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
|
|
49
|
+
var SLASH = "/";
|
|
50
|
+
var TMP_KEY_IGNORE = "node-ignore";
|
|
51
|
+
if (typeof Symbol !== "undefined") {
|
|
52
|
+
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
53
|
+
}
|
|
54
|
+
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
55
|
+
var define = (object, key, value) => Object.defineProperty(object, key, { value });
|
|
56
|
+
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
57
|
+
var RETURN_FALSE = () => false;
|
|
58
|
+
var sanitizeRange = (range) => range.replace(
|
|
59
|
+
REGEX_REGEXP_RANGE,
|
|
60
|
+
(match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
|
|
61
|
+
);
|
|
62
|
+
var cleanRangeBackSlash = (slashes) => {
|
|
63
|
+
const { length } = slashes;
|
|
64
|
+
return slashes.slice(0, length - length % 2);
|
|
65
|
+
};
|
|
66
|
+
var REPLACERS = [
|
|
67
|
+
[
|
|
68
|
+
// remove BOM
|
|
69
|
+
// TODO:
|
|
70
|
+
// Other similar zero-width characters?
|
|
71
|
+
/^\uFEFF/,
|
|
72
|
+
() => EMPTY
|
|
73
|
+
],
|
|
74
|
+
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
75
|
+
[
|
|
76
|
+
// (a\ ) -> (a )
|
|
77
|
+
// (a ) -> (a)
|
|
78
|
+
// (a ) -> (a)
|
|
79
|
+
// (a \ ) -> (a )
|
|
80
|
+
/((?:\\\\)*?)(\\?\s+)$/,
|
|
81
|
+
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
|
|
82
|
+
],
|
|
83
|
+
// replace (\ ) with ' '
|
|
84
|
+
// (\ ) -> ' '
|
|
85
|
+
// (\\ ) -> '\\ '
|
|
86
|
+
// (\\\ ) -> '\\ '
|
|
87
|
+
[
|
|
88
|
+
/(\\+?)\s/g,
|
|
89
|
+
(_, m1) => {
|
|
90
|
+
const { length } = m1;
|
|
91
|
+
return m1.slice(0, length - length % 2) + SPACE;
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
// Escape metacharacters
|
|
95
|
+
// which is written down by users but means special for regular expressions.
|
|
96
|
+
// > There are 12 characters with special meanings:
|
|
97
|
+
// > - the backslash \,
|
|
98
|
+
// > - the caret ^,
|
|
99
|
+
// > - the dollar sign $,
|
|
100
|
+
// > - the period or dot .,
|
|
101
|
+
// > - the vertical bar or pipe symbol |,
|
|
102
|
+
// > - the question mark ?,
|
|
103
|
+
// > - the asterisk or star *,
|
|
104
|
+
// > - the plus sign +,
|
|
105
|
+
// > - the opening parenthesis (,
|
|
106
|
+
// > - the closing parenthesis ),
|
|
107
|
+
// > - and the opening square bracket [,
|
|
108
|
+
// > - the opening curly brace {,
|
|
109
|
+
// > These special characters are often called "metacharacters".
|
|
110
|
+
[
|
|
111
|
+
/[\\$.|*+(){^]/g,
|
|
112
|
+
(match) => `\\${match}`
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
// > a question mark (?) matches a single character
|
|
116
|
+
/(?!\\)\?/g,
|
|
117
|
+
() => "[^/]"
|
|
118
|
+
],
|
|
119
|
+
// leading slash
|
|
120
|
+
[
|
|
121
|
+
// > A leading slash matches the beginning of the pathname.
|
|
122
|
+
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
123
|
+
// A leading slash matches the beginning of the pathname
|
|
124
|
+
/^\//,
|
|
125
|
+
() => "^"
|
|
126
|
+
],
|
|
127
|
+
// replace special metacharacter slash after the leading slash
|
|
128
|
+
[
|
|
129
|
+
/\//g,
|
|
130
|
+
() => "\\/"
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
// > A leading "**" followed by a slash means match in all directories.
|
|
134
|
+
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
135
|
+
// > the same as pattern "foo".
|
|
136
|
+
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
137
|
+
// > under directory "foo".
|
|
138
|
+
// Notice that the '*'s have been replaced as '\\*'
|
|
139
|
+
/^\^*\\\*\\\*\\\//,
|
|
140
|
+
// '**/foo' <-> 'foo'
|
|
141
|
+
() => "^(?:.*\\/)?"
|
|
142
|
+
],
|
|
143
|
+
// starting
|
|
144
|
+
[
|
|
145
|
+
// there will be no leading '/'
|
|
146
|
+
// (which has been replaced by section "leading slash")
|
|
147
|
+
// If starts with '**', adding a '^' to the regular expression also works
|
|
148
|
+
/^(?=[^^])/,
|
|
149
|
+
function startingReplacer() {
|
|
150
|
+
return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
// two globstars
|
|
154
|
+
[
|
|
155
|
+
// Use lookahead assertions so that we could match more than one `'/**'`
|
|
156
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
157
|
+
// Zero, one or several directories
|
|
158
|
+
// should not use '*', or it will be replaced by the next replacer
|
|
159
|
+
// Check if it is not the last `'/**'`
|
|
160
|
+
(_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
|
|
161
|
+
],
|
|
162
|
+
// normal intermediate wildcards
|
|
163
|
+
[
|
|
164
|
+
// Never replace escaped '*'
|
|
165
|
+
// ignore rule '\*' will match the path '*'
|
|
166
|
+
// 'abc.*/' -> go
|
|
167
|
+
// 'abc.*' -> skip this rule,
|
|
168
|
+
// coz trailing single wildcard will be handed by [trailing wildcard]
|
|
169
|
+
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
170
|
+
// '*.js' matches '.js'
|
|
171
|
+
// '*.js' doesn't match 'abc'
|
|
172
|
+
(_, p1, p2) => {
|
|
173
|
+
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
174
|
+
return p1 + unescaped;
|
|
175
|
+
}
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
// unescape, revert step 3 except for back slash
|
|
179
|
+
// For example, if a user escape a '\\*',
|
|
180
|
+
// after step 3, the result will be '\\\\\\*'
|
|
181
|
+
/\\\\\\(?=[$.|*+(){^])/g,
|
|
182
|
+
() => ESCAPE
|
|
183
|
+
],
|
|
184
|
+
[
|
|
185
|
+
// '\\\\' -> '\\'
|
|
186
|
+
/\\\\/g,
|
|
187
|
+
() => ESCAPE
|
|
188
|
+
],
|
|
189
|
+
[
|
|
190
|
+
// > The range notation, e.g. [a-zA-Z],
|
|
191
|
+
// > can be used to match one of the characters in a range.
|
|
192
|
+
// `\` is escaped by step 3
|
|
193
|
+
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
|
|
194
|
+
(match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
|
|
195
|
+
],
|
|
196
|
+
// ending
|
|
197
|
+
[
|
|
198
|
+
// 'js' will not match 'js.'
|
|
199
|
+
// 'ab' will not match 'abc'
|
|
200
|
+
/(?:[^*])$/,
|
|
201
|
+
// WTF!
|
|
202
|
+
// https://git-scm.com/docs/gitignore
|
|
203
|
+
// changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
|
|
204
|
+
// which re-fixes #24, #38
|
|
205
|
+
// > If there is a separator at the end of the pattern then the pattern
|
|
206
|
+
// > will only match directories, otherwise the pattern can match both
|
|
207
|
+
// > files and directories.
|
|
208
|
+
// 'js*' will not match 'a.js'
|
|
209
|
+
// 'js/' will not match 'a.js'
|
|
210
|
+
// 'js' will match 'a.js' and 'a.js/'
|
|
211
|
+
(match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
|
|
212
|
+
],
|
|
213
|
+
// trailing wildcard
|
|
214
|
+
[
|
|
215
|
+
/(\^|\\\/)?\\\*$/,
|
|
216
|
+
(_, p1) => {
|
|
217
|
+
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
218
|
+
return `${prefix}(?=$|\\/$)`;
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
];
|
|
222
|
+
var regexCache = /* @__PURE__ */ Object.create(null);
|
|
223
|
+
var makeRegex = (pattern, ignoreCase) => {
|
|
224
|
+
let source = regexCache[pattern];
|
|
225
|
+
if (!source) {
|
|
226
|
+
source = REPLACERS.reduce(
|
|
227
|
+
(prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
|
|
228
|
+
pattern
|
|
229
|
+
);
|
|
230
|
+
regexCache[pattern] = source;
|
|
231
|
+
}
|
|
232
|
+
return ignoreCase ? new RegExp(source, "i") : new RegExp(source);
|
|
233
|
+
};
|
|
234
|
+
var isString = (subject) => typeof subject === "string";
|
|
235
|
+
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
236
|
+
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF);
|
|
237
|
+
var IgnoreRule = class {
|
|
238
|
+
constructor(origin, pattern, negative, regex) {
|
|
239
|
+
this.origin = origin;
|
|
240
|
+
this.pattern = pattern;
|
|
241
|
+
this.negative = negative;
|
|
242
|
+
this.regex = regex;
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
var createRule = (pattern, ignoreCase) => {
|
|
246
|
+
const origin = pattern;
|
|
247
|
+
let negative = false;
|
|
248
|
+
if (pattern.indexOf("!") === 0) {
|
|
249
|
+
negative = true;
|
|
250
|
+
pattern = pattern.substr(1);
|
|
251
|
+
}
|
|
252
|
+
pattern = pattern.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
253
|
+
const regex = makeRegex(pattern, ignoreCase);
|
|
254
|
+
return new IgnoreRule(
|
|
255
|
+
origin,
|
|
256
|
+
pattern,
|
|
257
|
+
negative,
|
|
258
|
+
regex
|
|
259
|
+
);
|
|
260
|
+
};
|
|
261
|
+
var throwError = (message, Ctor) => {
|
|
262
|
+
throw new Ctor(message);
|
|
263
|
+
};
|
|
264
|
+
var checkPath = (path5, originalPath, doThrow) => {
|
|
265
|
+
if (!isString(path5)) {
|
|
266
|
+
return doThrow(
|
|
267
|
+
`path must be a string, but got \`${originalPath}\``,
|
|
268
|
+
TypeError
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
if (!path5) {
|
|
272
|
+
return doThrow(`path must not be empty`, TypeError);
|
|
273
|
+
}
|
|
274
|
+
if (checkPath.isNotRelative(path5)) {
|
|
275
|
+
const r = "`path.relative()`d";
|
|
276
|
+
return doThrow(
|
|
277
|
+
`path should be a ${r} string, but got "${originalPath}"`,
|
|
278
|
+
RangeError
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
return true;
|
|
282
|
+
};
|
|
283
|
+
var isNotRelative = (path5) => REGEX_TEST_INVALID_PATH.test(path5);
|
|
284
|
+
checkPath.isNotRelative = isNotRelative;
|
|
285
|
+
checkPath.convert = (p) => p;
|
|
286
|
+
var Ignore = class {
|
|
287
|
+
constructor({
|
|
288
|
+
ignorecase = true,
|
|
289
|
+
ignoreCase = ignorecase,
|
|
290
|
+
allowRelativePaths = false
|
|
291
|
+
} = {}) {
|
|
292
|
+
define(this, KEY_IGNORE, true);
|
|
293
|
+
this._rules = [];
|
|
294
|
+
this._ignoreCase = ignoreCase;
|
|
295
|
+
this._allowRelativePaths = allowRelativePaths;
|
|
296
|
+
this._initCache();
|
|
297
|
+
}
|
|
298
|
+
_initCache() {
|
|
299
|
+
this._ignoreCache = /* @__PURE__ */ Object.create(null);
|
|
300
|
+
this._testCache = /* @__PURE__ */ Object.create(null);
|
|
301
|
+
}
|
|
302
|
+
_addPattern(pattern) {
|
|
303
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
304
|
+
this._rules = this._rules.concat(pattern._rules);
|
|
305
|
+
this._added = true;
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (checkPattern(pattern)) {
|
|
309
|
+
const rule = createRule(pattern, this._ignoreCase);
|
|
310
|
+
this._added = true;
|
|
311
|
+
this._rules.push(rule);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// @param {Array<string> | string | Ignore} pattern
|
|
315
|
+
add(pattern) {
|
|
316
|
+
this._added = false;
|
|
317
|
+
makeArray(
|
|
318
|
+
isString(pattern) ? splitPattern(pattern) : pattern
|
|
319
|
+
).forEach(this._addPattern, this);
|
|
320
|
+
if (this._added) {
|
|
321
|
+
this._initCache();
|
|
322
|
+
}
|
|
323
|
+
return this;
|
|
324
|
+
}
|
|
325
|
+
// legacy
|
|
326
|
+
addPattern(pattern) {
|
|
327
|
+
return this.add(pattern);
|
|
328
|
+
}
|
|
329
|
+
// | ignored : unignored
|
|
330
|
+
// negative | 0:0 | 0:1 | 1:0 | 1:1
|
|
331
|
+
// -------- | ------- | ------- | ------- | --------
|
|
332
|
+
// 0 | TEST | TEST | SKIP | X
|
|
333
|
+
// 1 | TESTIF | SKIP | TEST | X
|
|
334
|
+
// - SKIP: always skip
|
|
335
|
+
// - TEST: always test
|
|
336
|
+
// - TESTIF: only test if checkUnignored
|
|
337
|
+
// - X: that never happen
|
|
338
|
+
// @param {boolean} whether should check if the path is unignored,
|
|
339
|
+
// setting `checkUnignored` to `false` could reduce additional
|
|
340
|
+
// path matching.
|
|
341
|
+
// @returns {TestResult} true if a file is ignored
|
|
342
|
+
_testOne(path5, checkUnignored) {
|
|
343
|
+
let ignored = false;
|
|
344
|
+
let unignored = false;
|
|
345
|
+
this._rules.forEach((rule) => {
|
|
346
|
+
const { negative } = rule;
|
|
347
|
+
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const matched = rule.regex.test(path5);
|
|
351
|
+
if (matched) {
|
|
352
|
+
ignored = !negative;
|
|
353
|
+
unignored = negative;
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
return {
|
|
357
|
+
ignored,
|
|
358
|
+
unignored
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
// @returns {TestResult}
|
|
362
|
+
_test(originalPath, cache, checkUnignored, slices) {
|
|
363
|
+
const path5 = originalPath && checkPath.convert(originalPath);
|
|
364
|
+
checkPath(
|
|
365
|
+
path5,
|
|
366
|
+
originalPath,
|
|
367
|
+
this._allowRelativePaths ? RETURN_FALSE : throwError
|
|
368
|
+
);
|
|
369
|
+
return this._t(path5, cache, checkUnignored, slices);
|
|
370
|
+
}
|
|
371
|
+
_t(path5, cache, checkUnignored, slices) {
|
|
372
|
+
if (path5 in cache) {
|
|
373
|
+
return cache[path5];
|
|
374
|
+
}
|
|
375
|
+
if (!slices) {
|
|
376
|
+
slices = path5.split(SLASH);
|
|
377
|
+
}
|
|
378
|
+
slices.pop();
|
|
379
|
+
if (!slices.length) {
|
|
380
|
+
return cache[path5] = this._testOne(path5, checkUnignored);
|
|
381
|
+
}
|
|
382
|
+
const parent = this._t(
|
|
383
|
+
slices.join(SLASH) + SLASH,
|
|
384
|
+
cache,
|
|
385
|
+
checkUnignored,
|
|
386
|
+
slices
|
|
387
|
+
);
|
|
388
|
+
return cache[path5] = parent.ignored ? parent : this._testOne(path5, checkUnignored);
|
|
389
|
+
}
|
|
390
|
+
ignores(path5) {
|
|
391
|
+
return this._test(path5, this._ignoreCache, false).ignored;
|
|
392
|
+
}
|
|
393
|
+
createFilter() {
|
|
394
|
+
return (path5) => !this.ignores(path5);
|
|
395
|
+
}
|
|
396
|
+
filter(paths) {
|
|
397
|
+
return makeArray(paths).filter(this.createFilter());
|
|
398
|
+
}
|
|
399
|
+
// @returns {TestResult}
|
|
400
|
+
test(path5) {
|
|
401
|
+
return this._test(path5, this._testCache, true);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
var factory = (options) => new Ignore(options);
|
|
405
|
+
var isPathValid = (path5) => checkPath(path5 && checkPath.convert(path5), path5, RETURN_FALSE);
|
|
406
|
+
factory.isPathValid = isPathValid;
|
|
407
|
+
factory.default = factory;
|
|
408
|
+
module2.exports = factory;
|
|
409
|
+
if (
|
|
410
|
+
// Detect `process` so that it can run in browsers.
|
|
411
|
+
typeof process !== "undefined" && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === "win32")
|
|
412
|
+
) {
|
|
413
|
+
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
414
|
+
checkPath.convert = makePosix;
|
|
415
|
+
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
416
|
+
checkPath.isNotRelative = (path5) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path5) || isNotRelative(path5);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
30
421
|
// client.ts
|
|
31
422
|
var client_exports = {};
|
|
32
423
|
__export(client_exports, {
|
|
@@ -737,14 +1128,17 @@ async function executeWithRecording(input, config = {}) {
|
|
|
737
1128
|
recording
|
|
738
1129
|
};
|
|
739
1130
|
} catch (error) {
|
|
1131
|
+
const errorRecording = {
|
|
1132
|
+
id: taskResult.recording_id,
|
|
1133
|
+
status: "ERROR",
|
|
1134
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1135
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1136
|
+
getWebp: (options) => getWebp(taskResult.recording_id, config, options),
|
|
1137
|
+
getErrors: () => getErrors(taskResult.recording_id, config)
|
|
1138
|
+
};
|
|
740
1139
|
return {
|
|
741
1140
|
...taskResult,
|
|
742
|
-
recording:
|
|
743
|
-
id: taskResult.recording_id,
|
|
744
|
-
status: "ERROR",
|
|
745
|
-
error: error instanceof Error ? error.message : String(error),
|
|
746
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
747
|
-
}
|
|
1141
|
+
recording: errorRecording
|
|
748
1142
|
};
|
|
749
1143
|
}
|
|
750
1144
|
}
|
|
@@ -2079,11 +2473,30 @@ async function readAllLines(filePath) {
|
|
|
2079
2473
|
}
|
|
2080
2474
|
|
|
2081
2475
|
// tools/warp_grep/providers/local.ts
|
|
2476
|
+
var ignore = require_ignore().default || require_ignore();
|
|
2082
2477
|
var LocalRipgrepProvider = class {
|
|
2083
2478
|
constructor(repoRoot, excludes = DEFAULT_EXCLUDES) {
|
|
2084
2479
|
this.repoRoot = repoRoot;
|
|
2085
2480
|
this.excludes = excludes;
|
|
2086
2481
|
}
|
|
2482
|
+
ignoreFilter = null;
|
|
2483
|
+
/**
|
|
2484
|
+
* Build an ignore filter that combines DEFAULT_EXCLUDES and .gitignore patterns.
|
|
2485
|
+
* Cached after first call.
|
|
2486
|
+
*/
|
|
2487
|
+
async getIgnoreFilter() {
|
|
2488
|
+
if (this.ignoreFilter) return this.ignoreFilter;
|
|
2489
|
+
const ig = ignore();
|
|
2490
|
+
ig.add(this.excludes);
|
|
2491
|
+
try {
|
|
2492
|
+
const gitignorePath = import_path5.default.join(this.repoRoot, ".gitignore");
|
|
2493
|
+
const gitignoreContent = await import_promises3.default.readFile(gitignorePath, "utf-8");
|
|
2494
|
+
ig.add(gitignoreContent);
|
|
2495
|
+
} catch {
|
|
2496
|
+
}
|
|
2497
|
+
this.ignoreFilter = ig;
|
|
2498
|
+
return ig;
|
|
2499
|
+
}
|
|
2087
2500
|
async grep(params) {
|
|
2088
2501
|
let abs;
|
|
2089
2502
|
try {
|
|
@@ -2211,9 +2624,11 @@ Details: ${res.stderr}` : ""}`
|
|
|
2211
2624
|
const maxResults = params.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;
|
|
2212
2625
|
const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
|
|
2213
2626
|
const regex = params.pattern ? new RegExp(params.pattern) : null;
|
|
2627
|
+
const ig = await this.getIgnoreFilter();
|
|
2214
2628
|
const results = [];
|
|
2215
2629
|
let timedOut = false;
|
|
2216
2630
|
const startTime = Date.now();
|
|
2631
|
+
const repoRoot = this.repoRoot;
|
|
2217
2632
|
async function walk(dir, depth) {
|
|
2218
2633
|
if (Date.now() - startTime > AGENT_CONFIG.LIST_TIMEOUT_MS) {
|
|
2219
2634
|
timedOut = true;
|
|
@@ -2224,17 +2639,18 @@ Details: ${res.stderr}` : ""}`
|
|
|
2224
2639
|
for (const entry of entries) {
|
|
2225
2640
|
if (timedOut || results.length >= maxResults) break;
|
|
2226
2641
|
const full = import_path5.default.join(dir, entry.name);
|
|
2227
|
-
const
|
|
2228
|
-
|
|
2642
|
+
const relToRepo = toRepoRelative(repoRoot, full).replace(/^[.][/\\]?/, "");
|
|
2643
|
+
const isDir = entry.isDirectory();
|
|
2644
|
+
if (ig.ignores(relToRepo) || isDir && ig.ignores(relToRepo + "/")) continue;
|
|
2229
2645
|
if (regex && !regex.test(entry.name)) continue;
|
|
2230
2646
|
results.push({
|
|
2231
2647
|
name: entry.name,
|
|
2232
2648
|
path: toRepoRelative(import_path5.default.resolve(""), full),
|
|
2233
2649
|
// relative display
|
|
2234
|
-
type:
|
|
2650
|
+
type: isDir ? "dir" : "file",
|
|
2235
2651
|
depth
|
|
2236
2652
|
});
|
|
2237
|
-
if (
|
|
2653
|
+
if (isDir) {
|
|
2238
2654
|
await walk(full, depth + 1);
|
|
2239
2655
|
}
|
|
2240
2656
|
}
|
|
@@ -2245,11 +2661,25 @@ Details: ${res.stderr}` : ""}`
|
|
|
2245
2661
|
};
|
|
2246
2662
|
|
|
2247
2663
|
// tools/warp_grep/providers/remote.ts
|
|
2664
|
+
var ignore2 = require_ignore().default || require_ignore();
|
|
2248
2665
|
var RemoteCommandsProvider = class {
|
|
2249
2666
|
constructor(repoRoot, commands) {
|
|
2250
2667
|
this.repoRoot = repoRoot;
|
|
2251
2668
|
this.commands = commands;
|
|
2252
2669
|
}
|
|
2670
|
+
ignoreFilter = null;
|
|
2671
|
+
/**
|
|
2672
|
+
* Build an ignore filter from DEFAULT_EXCLUDES.
|
|
2673
|
+
* Note: For remote providers, we can't read .gitignore from the remote sandbox,
|
|
2674
|
+
* so we only use the built-in excludes.
|
|
2675
|
+
*/
|
|
2676
|
+
getIgnoreFilter() {
|
|
2677
|
+
if (this.ignoreFilter) return this.ignoreFilter;
|
|
2678
|
+
const ig = ignore2();
|
|
2679
|
+
ig.add(DEFAULT_EXCLUDES);
|
|
2680
|
+
this.ignoreFilter = ig;
|
|
2681
|
+
return ig;
|
|
2682
|
+
}
|
|
2253
2683
|
/**
|
|
2254
2684
|
* Run grep command and parse ripgrep output
|
|
2255
2685
|
*/
|
|
@@ -2303,6 +2733,7 @@ var RemoteCommandsProvider = class {
|
|
|
2303
2733
|
async listDirectory(params) {
|
|
2304
2734
|
const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
|
|
2305
2735
|
const maxResults = params.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;
|
|
2736
|
+
const ig = this.getIgnoreFilter();
|
|
2306
2737
|
try {
|
|
2307
2738
|
const stdout = await this.commands.listDir(params.path, maxDepth);
|
|
2308
2739
|
const paths = (stdout || "").trim().split(/\r?\n/).filter((p) => p.length > 0);
|
|
@@ -2311,11 +2742,12 @@ var RemoteCommandsProvider = class {
|
|
|
2311
2742
|
for (const fullPath of paths) {
|
|
2312
2743
|
if (fullPath === params.path || fullPath === this.repoRoot) continue;
|
|
2313
2744
|
const name = fullPath.split("/").pop() || "";
|
|
2314
|
-
if (regex && !regex.test(name)) continue;
|
|
2315
2745
|
let relativePath = fullPath;
|
|
2316
2746
|
if (fullPath.startsWith(this.repoRoot)) {
|
|
2317
2747
|
relativePath = fullPath.slice(this.repoRoot.length).replace(/^\//, "");
|
|
2318
2748
|
}
|
|
2749
|
+
if (ig.ignores(relativePath)) continue;
|
|
2750
|
+
if (regex && !regex.test(name)) continue;
|
|
2319
2751
|
const depth = relativePath.split("/").filter(Boolean).length - 1;
|
|
2320
2752
|
const hasExtension = name.includes(".") && !name.startsWith(".");
|
|
2321
2753
|
const type = hasExtension ? "file" : "dir";
|