@morphllm/morphsdk 0.2.125 → 0.2.127
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/{chunk-DGYWACHC.js → chunk-3ZA7Y66U.js} +2 -2
- package/dist/{chunk-5L3TPS6A.js → chunk-6DRIR7AI.js} +5 -4
- package/dist/chunk-6DRIR7AI.js.map +1 -0
- package/dist/{chunk-G5YJDK5S.js → chunk-ADHGSV2D.js} +2 -2
- package/dist/{chunk-5PNMAWLC.js → chunk-DKODF3YG.js} +2 -2
- package/dist/{chunk-5PNMAWLC.js.map → chunk-DKODF3YG.js.map} +1 -1
- package/dist/{chunk-BQO3WODX.js → chunk-DS7YL4V3.js} +8 -13
- package/dist/chunk-DS7YL4V3.js.map +1 -0
- package/dist/{chunk-FEQJCZJQ.js → chunk-EGOCFCAH.js} +2 -2
- package/dist/{chunk-TFK4UOUE.js → chunk-EL6CCK7C.js} +6 -6
- package/dist/{chunk-IB4MEIQG.js → chunk-GDCVK6SP.js} +2 -2
- package/dist/{chunk-UGSV5LPO.js → chunk-GVF4Q75N.js} +2 -2
- package/dist/{chunk-TS3E6IRI.js → chunk-GWKCMFD6.js} +2 -2
- package/dist/{chunk-WZAZFW77.js → chunk-HZK5TEUK.js} +1 -1
- package/dist/{chunk-EF7ZYLA2.js → chunk-HZOTLGJH.js} +19 -12
- package/dist/chunk-HZOTLGJH.js.map +1 -0
- package/dist/{chunk-3MLWXJTJ.js → chunk-K2FXHDX2.js} +15 -10
- package/dist/chunk-K2FXHDX2.js.map +1 -0
- package/dist/{chunk-FAZO2LNY.js → chunk-K6YSD3DR.js} +2 -2
- package/dist/{chunk-ACHEU2V3.js → chunk-LX34ZO3N.js} +2 -2
- package/dist/{chunk-OFQRY3RM.js → chunk-LXBIP5FI.js} +18 -23
- package/dist/chunk-LXBIP5FI.js.map +1 -0
- package/dist/{chunk-F6HNFC2H.js → chunk-MJHAVXFK.js} +2 -2
- package/dist/{chunk-PUGSTXLO.js → chunk-NF2QWJDY.js} +6 -7
- package/dist/chunk-NF2QWJDY.js.map +1 -0
- package/dist/{chunk-6TH3VNCF.js → chunk-NQQS5BZZ.js} +3 -3
- package/dist/{chunk-V3HLOZK2.js → chunk-QLBRTLEI.js} +1 -1
- package/dist/{chunk-V3HLOZK2.js.map → chunk-QLBRTLEI.js.map} +1 -1
- package/dist/{chunk-57PXQ6IS.js → chunk-QOE522DB.js} +15 -15
- package/dist/chunk-QRXG5CAZ.js +27 -0
- package/dist/chunk-QRXG5CAZ.js.map +1 -0
- package/dist/{chunk-7RTJCQWB.js → chunk-QUULFOWB.js} +10 -5
- package/dist/chunk-QUULFOWB.js.map +1 -0
- package/dist/{chunk-33CP5QCC.js → chunk-R5IFI552.js} +3 -3
- package/dist/{chunk-33CP5QCC.js.map → chunk-R5IFI552.js.map} +1 -1
- package/dist/{chunk-IRNUW2DB.js → chunk-REJNS3OW.js} +8 -13
- package/dist/chunk-REJNS3OW.js.map +1 -0
- package/dist/{chunk-2S7ZQFIB.js → chunk-U73OIAJC.js} +2 -2
- package/dist/{chunk-OQGX4RZP.js → chunk-UAQ7UWZB.js} +2 -2
- package/dist/chunk-VCKJ22DX.js +131 -0
- package/dist/chunk-VCKJ22DX.js.map +1 -0
- package/dist/{chunk-2MK64KK4.js → chunk-YTUQEDWH.js} +2 -2
- package/dist/{chunk-H6KT7IXW.js → chunk-ZVAXTR2V.js} +2 -2
- package/dist/{chunk-BGL35LL6.js → chunk-ZYD2SEQK.js} +2 -2
- package/dist/{client-JHPwle1Z.d.ts → client-CNYzlN_6.d.ts} +6 -7
- package/dist/client.cjs +166 -579
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -2
- package/dist/client.js +27 -28
- package/dist/edge.cjs +2 -2
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +4 -4
- package/dist/{finish-pPJfB0uO.d.ts → finish-DBKuo8yj.d.ts} +2 -0
- package/dist/index.cjs +166 -579
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +29 -30
- package/dist/modelrouter/core.cjs +2 -2
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +3 -3
- package/dist/modelrouter/index.cjs +2 -2
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +3 -3
- package/dist/tools/browser/anthropic.cjs +2 -2
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +5 -5
- package/dist/tools/browser/core.cjs +2 -2
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +4 -4
- package/dist/tools/browser/index.cjs +2 -2
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +7 -7
- package/dist/tools/browser/openai.cjs +2 -2
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +5 -5
- package/dist/tools/browser/profiles/core.cjs +2 -2
- package/dist/tools/browser/profiles/core.cjs.map +1 -1
- package/dist/tools/browser/profiles/core.js +3 -3
- package/dist/tools/browser/profiles/index.cjs +2 -2
- package/dist/tools/browser/profiles/index.cjs.map +1 -1
- package/dist/tools/browser/profiles/index.js +3 -3
- package/dist/tools/browser/vercel.cjs +2 -2
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +5 -5
- package/dist/tools/codebase_search/anthropic.cjs +2 -2
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +4 -4
- package/dist/tools/codebase_search/core.cjs +2 -2
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.js +3 -3
- package/dist/tools/codebase_search/index.cjs +2 -2
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +6 -6
- package/dist/tools/codebase_search/openai.cjs +2 -2
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +4 -4
- package/dist/tools/codebase_search/vercel.cjs +2 -2
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +4 -4
- package/dist/tools/fastapply/anthropic.cjs +2 -2
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +4 -4
- package/dist/tools/fastapply/apply.cjs +2 -2
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +2 -2
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +3 -3
- package/dist/tools/fastapply/index.cjs +2 -2
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +6 -6
- package/dist/tools/fastapply/openai.cjs +2 -2
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +4 -4
- package/dist/tools/fastapply/vercel.cjs +2 -2
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +4 -4
- package/dist/tools/index.cjs +2 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +6 -6
- package/dist/tools/utils/resilience.cjs +2 -2
- package/dist/tools/utils/resilience.cjs.map +1 -1
- package/dist/tools/utils/resilience.js +2 -2
- package/dist/tools/warp_grep/agent/config.cjs +1 -1
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/config.d.ts +1 -1
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/formatter.cjs +3 -74
- package/dist/tools/warp_grep/agent/formatter.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/formatter.d.ts +1 -5
- package/dist/tools/warp_grep/agent/formatter.js +1 -1
- package/dist/tools/warp_grep/agent/parser.cjs +91 -242
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/parser.d.ts +0 -8
- package/dist/tools/warp_grep/agent/parser.js +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs +122 -543
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +6 -7
- package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/types.d.ts +2 -0
- package/dist/tools/warp_grep/anthropic.cjs +152 -570
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +2 -4
- package/dist/tools/warp_grep/anthropic.js +11 -15
- package/dist/tools/warp_grep/client.cjs +143 -558
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +9 -10
- package/dist/tools/warp_grep/gemini.cjs +152 -570
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +2 -4
- package/dist/tools/warp_grep/gemini.js +18 -23
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/harness.cjs +124 -540
- package/dist/tools/warp_grep/harness.cjs.map +1 -1
- package/dist/tools/warp_grep/harness.d.ts +4 -5
- package/dist/tools/warp_grep/harness.js +5 -11
- package/dist/tools/warp_grep/harness.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +147 -565
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +7 -4
- package/dist/tools/warp_grep/index.js +14 -20
- package/dist/tools/warp_grep/openai.cjs +152 -570
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +2 -4
- package/dist/tools/warp_grep/openai.js +11 -15
- package/dist/tools/warp_grep/providers/local.cjs +17 -10
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.d.ts +6 -1
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/providers/remote.cjs +4 -5
- package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/remote.js +2 -2
- package/dist/tools/warp_grep/providers/types.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/types.d.ts +2 -0
- package/dist/tools/warp_grep/vercel.cjs +151 -563
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +2 -2
- package/dist/tools/warp_grep/vercel.js +11 -15
- package/dist/version.cjs +2 -2
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-3MLWXJTJ.js.map +0 -1
- package/dist/chunk-5L3TPS6A.js.map +0 -1
- package/dist/chunk-7RTJCQWB.js.map +0 -1
- package/dist/chunk-APP75CBN.js +0 -98
- package/dist/chunk-APP75CBN.js.map +0 -1
- package/dist/chunk-BQO3WODX.js.map +0 -1
- package/dist/chunk-EF7ZYLA2.js.map +0 -1
- package/dist/chunk-FMLHRJDF.js +0 -207
- package/dist/chunk-FMLHRJDF.js.map +0 -1
- package/dist/chunk-GHGJAQSJ.js +0 -282
- package/dist/chunk-GHGJAQSJ.js.map +0 -1
- package/dist/chunk-IRNUW2DB.js.map +0 -1
- package/dist/chunk-OFQRY3RM.js.map +0 -1
- package/dist/chunk-PUGSTXLO.js.map +0 -1
- package/dist/tools/warp_grep/agent/prompt.cjs +0 -232
- package/dist/tools/warp_grep/agent/prompt.cjs.map +0 -1
- package/dist/tools/warp_grep/agent/prompt.d.ts +0 -4
- package/dist/tools/warp_grep/agent/prompt.js +0 -10
- package/dist/tools/warp_grep/agent/prompt.js.map +0 -1
- /package/dist/{chunk-DGYWACHC.js.map → chunk-3ZA7Y66U.js.map} +0 -0
- /package/dist/{chunk-G5YJDK5S.js.map → chunk-ADHGSV2D.js.map} +0 -0
- /package/dist/{chunk-FEQJCZJQ.js.map → chunk-EGOCFCAH.js.map} +0 -0
- /package/dist/{chunk-TFK4UOUE.js.map → chunk-EL6CCK7C.js.map} +0 -0
- /package/dist/{chunk-IB4MEIQG.js.map → chunk-GDCVK6SP.js.map} +0 -0
- /package/dist/{chunk-UGSV5LPO.js.map → chunk-GVF4Q75N.js.map} +0 -0
- /package/dist/{chunk-TS3E6IRI.js.map → chunk-GWKCMFD6.js.map} +0 -0
- /package/dist/{chunk-WZAZFW77.js.map → chunk-HZK5TEUK.js.map} +0 -0
- /package/dist/{chunk-FAZO2LNY.js.map → chunk-K6YSD3DR.js.map} +0 -0
- /package/dist/{chunk-ACHEU2V3.js.map → chunk-LX34ZO3N.js.map} +0 -0
- /package/dist/{chunk-F6HNFC2H.js.map → chunk-MJHAVXFK.js.map} +0 -0
- /package/dist/{chunk-6TH3VNCF.js.map → chunk-NQQS5BZZ.js.map} +0 -0
- /package/dist/{chunk-57PXQ6IS.js.map → chunk-QOE522DB.js.map} +0 -0
- /package/dist/{chunk-2S7ZQFIB.js.map → chunk-U73OIAJC.js.map} +0 -0
- /package/dist/{chunk-OQGX4RZP.js.map → chunk-UAQ7UWZB.js.map} +0 -0
- /package/dist/{chunk-2MK64KK4.js.map → chunk-YTUQEDWH.js.map} +0 -0
- /package/dist/{chunk-H6KT7IXW.js.map → chunk-ZVAXTR2V.js.map} +0 -0
- /package/dist/{chunk-BGL35LL6.js.map → chunk-ZYD2SEQK.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fetchWithRetry,
|
|
3
3
|
withTimeout
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ADHGSV2D.js";
|
|
5
5
|
|
|
6
6
|
// tools/codebase_search/core.ts
|
|
7
7
|
var CodebaseSearchClient = class {
|
|
@@ -102,4 +102,4 @@ export {
|
|
|
102
102
|
CodebaseSearchClient,
|
|
103
103
|
executeCodebaseSearch
|
|
104
104
|
};
|
|
105
|
-
//# sourceMappingURL=chunk-
|
|
105
|
+
//# sourceMappingURL=chunk-3ZA7Y66U.js.map
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
var WARP_GREP_TOOL_NAME = "warpgrep_codebase_search";
|
|
3
3
|
var WARP_GREP_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase to gather context, and the task does not involve a single file or function which is provided by name, you should ALWAYS use the warpgrep codebase search tool first instead of running search commands. When the task requires exploration beyond a single known file, invoke warpgrep first with a natural-language query describing the target functionality, bug, or architectural concern. Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. Keep queries action-oriented (e.g., "Find where billing invoices are generated and emailed"), and after reviewing the summarized results, you may verify important findings with other search tools or direct file reads to ensure completeness. Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task requires exploration beyond a single known file, ALWAYS default to warpgrep codebase search before other search mechanisms.';
|
|
4
4
|
var GITHUB_WARP_GREP_SEARCH_TOOL_NAME = "warpgrep_github_search";
|
|
5
|
-
var GITHUB_WARP_GREP_SEARCH_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase of a public GitHub repository (not your local workspace), use warpgrep_github_search instead of warpgrep_codebase_search. ONLY use this tool when the task requires understanding code in an external repo, and invoke warpgrep_github_search with a
|
|
5
|
+
var GITHUB_WARP_GREP_SEARCH_DESCRIPTION = 'IMPORTANT: If you need to explore the codebase of a public GitHub repository (not your local workspace), use warpgrep_github_search instead of warpgrep_codebase_search. ONLY use this tool when the task requires understanding code in an external repo, and invoke warpgrep_github_search with a natural-language query describing the target functionality, bug, or architectural concern. DO NOT use this tool when the task requires understanding code in your local workspace. Use warpgrep_codebase_search instead.Useful when you suspect a library or framework is being used in a way that is not documented, or if you suspect an update or a bug in the library or framework.WarpGrep searches GitHub repos the same way it searches local codebases: fast and accurate. Keep queries action-oriented (e.g., "Find where how the new use workflow directive works"), and after reviewing the results, you may verify important findings with other tools or direct file reads. WarpGrep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. When a task involves exploring code in an external public repo, ALWAYS use warpgrep_github_search. You must provide either a github_url or owner_repo parameter (at least one is required).';
|
|
6
6
|
var GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA = {
|
|
7
7
|
type: "object",
|
|
8
8
|
properties: {
|
|
9
9
|
query: { type: "string", description: "Natural language search query describing what to find in the repository" },
|
|
10
|
-
|
|
10
|
+
github_url: { type: "string", description: 'GitHub repository URL to search (e.g. "https://github.com/vercel/next.js"). You must provide either github_url or owner_repo.' },
|
|
11
|
+
owner_repo: { type: "string", description: 'Repository owner/repo shorthand (e.g. "vercel/next.js"). You must provide either github_url or owner_repo.' },
|
|
11
12
|
branch: { type: "string", description: "Branch to search (defaults to the repository default branch)" }
|
|
12
13
|
},
|
|
13
|
-
required: ["query"
|
|
14
|
+
required: ["query"]
|
|
14
15
|
};
|
|
15
16
|
var GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;
|
|
16
17
|
var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
|
|
@@ -39,4 +40,4 @@ export {
|
|
|
39
40
|
GITHUB_READ_FILE_DESCRIPTION,
|
|
40
41
|
GITHUB_READ_FILE_INPUT_SCHEMA
|
|
41
42
|
};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-6DRIR7AI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/prompts.ts"],"sourcesContent":["/**\n * Prompts and descriptions for warpgrep_codebase_search\n */\n\n/**\n * Default tool name for the warp grep tool\n */\nexport const WARP_GREP_TOOL_NAME = 'warpgrep_codebase_search';\n\n/**\n * Default tool description for the warp grep tool\n */\nexport const WARP_GREP_DESCRIPTION = \n 'IMPORTANT: If you need to explore the codebase to gather context, and the task does not involve a single file or function which is provided by name, you should ALWAYS use the warpgrep codebase search tool first instead of running search commands. ' +\n 'When the task requires exploration beyond a single known file, invoke warpgrep first with a natural-language query describing the target functionality, bug, or architectural concern. ' +\n 'Warp Grep is a fast and accurate tool that can search for all relevant context in a codebase. ' +\n 'Keep queries action-oriented (e.g., \"Find where billing invoices are generated and emailed\"), and after reviewing the summarized results, you may verify important findings with other search tools or direct file reads to ensure completeness. ' +\n 'Warp Grep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. ' +\n 'When a task requires exploration beyond a single known file, ALWAYS default to warpgrep codebase search before other search mechanisms.'\n\nexport const GITHUB_WARP_GREP_SEARCH_TOOL_NAME = 'warpgrep_github_search';\n\nexport const GITHUB_WARP_GREP_SEARCH_DESCRIPTION =\n 'IMPORTANT: If you need to explore the codebase of a public GitHub repository (not your local workspace), use warpgrep_github_search instead of warpgrep_codebase_search. ' +\n 'ONLY use this tool when the task requires understanding code in an external repo, and invoke warpgrep_github_search with a natural-language query describing the target functionality, bug, or architectural concern. ' +\n 'DO NOT use this tool when the task requires understanding code in your local workspace. Use warpgrep_codebase_search instead.' +\n 'Useful when you suspect a library or framework is being used in a way that is not documented, or if you suspect an update or a bug in the library or framework.' +\n 'WarpGrep searches GitHub repos the same way it searches local codebases: fast and accurate. ' +\n 'Keep queries action-oriented (e.g., \"Find where how the new use workflow directive works\"), and after reviewing the results, you may verify important findings with other tools or direct file reads. ' +\n 'WarpGrep can be used for query types like: find function responsible for <small feature>; find code that does <description>; find code path for <big feature>; Where does <minimal error message> come from?; or any query of that type. ' +\n 'When a task involves exploring code in an external public repo, ALWAYS use warpgrep_github_search. ' +\n 'You must provide either a github_url or owner_repo parameter (at least one is required).';\n\nexport const GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA = {\n type: 'object' as const,\n properties: {\n query: { type: 'string' as const, description: 'Natural language search query describing what to find in the repository' },\n github_url: { type: 'string' as const, description: 'GitHub repository URL to search (e.g. \"https://github.com/vercel/next.js\"). You must provide either github_url or owner_repo.' },\n owner_repo: { type: 'string' as const, description: 'Repository owner/repo shorthand (e.g. \"vercel/next.js\"). You must provide either github_url or owner_repo.' },\n branch: { type: 'string' as const, description: 'Branch to search (defaults to the repository default branch)' },\n },\n required: ['query'] as const,\n};\n\nexport const GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;\nexport const GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;\nexport const GITHUB_SEARCH_INPUT_SCHEMA = GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA;\n\nexport const GITHUB_READ_FILE_TOOL_NAME = 'readfile_github_search';\n\nexport const GITHUB_READ_FILE_DESCRIPTION =\n 'Read a single file (or a line range) from a public GitHub repository. ' +\n 'ONLY USE THIS WHEN YOU ALREADY KNOW THE EXACT FILE PATH YOU WANT TO READ, for example after finding it via warpgrep_github_search results. ' +\n 'Takes owner/repo shorthand and the file path within the repo. Optionally specify startLine and endLine (1-based) to read a specific range. ' +\n 'Returns the file content with line numbers.';\n\nexport const GITHUB_READ_FILE_INPUT_SCHEMA = {\n type: 'object' as const,\n properties: {\n github: { type: 'string' as const, description: 'owner/repo shorthand (e.g., \"vercel/next.js\")' },\n path: { type: 'string' as const, description: 'File path within the repository (e.g., \"src/server/index.ts\")' },\n startLine: { type: 'number' as const, description: 'Start line number (1-based). Omit to start from beginning.' },\n endLine: { type: 'number' as const, description: 'End line number (1-based, inclusive). Omit to read to the end.' },\n branch: { type: 'string' as const, description: 'Branch to read from (defaults to the repository default branch)' },\n },\n required: ['github', 'path'] as const,\n};\n"],"mappings":";AAOO,IAAM,sBAAsB;AAK5B,IAAM,wBACX;AAOK,IAAM,oCAAoC;AAE1C,IAAM,sCACX;AAUK,IAAM,uCAAuC;AAAA,EAClD,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO,EAAE,MAAM,UAAmB,aAAa,0EAA0E;AAAA,IACzH,YAAY,EAAE,MAAM,UAAmB,aAAa,gIAAgI;AAAA,IACpL,YAAY,EAAE,MAAM,UAAmB,aAAa,6GAA6G;AAAA,IACjK,QAAQ,EAAE,MAAM,UAAmB,aAAa,+DAA+D;AAAA,EACjH;AAAA,EACA,UAAU,CAAC,OAAO;AACpB;AAEO,IAAM,0BAA0B;AAChC,IAAM,4BAA4B;AAClC,IAAM,6BAA6B;AAEnC,IAAM,6BAA6B;AAEnC,IAAM,+BACX;AAKK,IAAM,gCAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,YAAY;AAAA,IACV,QAAQ,EAAE,MAAM,UAAmB,aAAa,gDAAgD;AAAA,IAChG,MAAM,EAAE,MAAM,UAAmB,aAAa,gEAAgE;AAAA,IAC9G,WAAW,EAAE,MAAM,UAAmB,aAAa,6DAA6D;AAAA,IAChH,SAAS,EAAE,MAAM,UAAmB,aAAa,iEAAiE;AAAA,IAClH,QAAQ,EAAE,MAAM,UAAmB,aAAa,kEAAkE;AAAA,EACpH;AAAA,EACA,UAAU,CAAC,UAAU,MAAM;AAC7B;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SDK_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-R5IFI552.js";
|
|
4
4
|
|
|
5
5
|
// tools/utils/resilience.ts
|
|
6
6
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -91,4 +91,4 @@ export {
|
|
|
91
91
|
withTimeout,
|
|
92
92
|
MorphError
|
|
93
93
|
};
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-ADHGSV2D.js.map
|
|
@@ -94,11 +94,11 @@ var BUILTIN_EXCLUDES = [
|
|
|
94
94
|
".*"
|
|
95
95
|
];
|
|
96
96
|
var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
|
|
97
|
-
var DEFAULT_MODEL = "morph-warp-grep-
|
|
97
|
+
var DEFAULT_MODEL = "morph-warp-grep-v2";
|
|
98
98
|
|
|
99
99
|
export {
|
|
100
100
|
AGENT_CONFIG,
|
|
101
101
|
DEFAULT_EXCLUDES,
|
|
102
102
|
DEFAULT_MODEL
|
|
103
103
|
};
|
|
104
|
-
//# sourceMappingURL=chunk-
|
|
104
|
+
//# sourceMappingURL=chunk-DKODF3YG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../tools/warp_grep/agent/config.ts"],"sourcesContent":["// Parse timeout from env, defaulting to 30 seconds\nconst parseEnvTimeout = (envValue: string | undefined, defaultMs: number): number => {\n if (!envValue) return defaultMs;\n const parsed = parseInt(envValue, 10);\n return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;\n};\n\nexport const AGENT_CONFIG = {\n MAX_TURNS: 4,\n /** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */\n TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 30_000),\n MAX_CONTEXT_CHARS: 540_000,\n MAX_OUTPUT_LINES: 200,\n MAX_READ_LINES: 800,\n MAX_LIST_DEPTH: 3,\n LIST_TIMEOUT_MS: 2_000,\n};\n\n/**\n * Comprehensive exclusion list for directories and files\n * These patterns are used with ripgrep's -g flag\n */\nconst BUILTIN_EXCLUDES = [\n // Version control\n '.git', '.svn', '.hg', '.bzr',\n \n // Dependencies\n 'node_modules', 'bower_components', '.pnpm', '.yarn',\n 'vendor', 'packages', 'Pods', '.bundle',\n \n // Python\n '__pycache__', '.pytest_cache', '.mypy_cache', '.ruff_cache',\n '.venv', 'venv', '.tox', '.nox', '.eggs', '*.egg-info',\n \n // Build outputs\n 'dist', 'build', 'out', 'output', 'target', '_build',\n '.next', '.nuxt', '.output', '.vercel', '.netlify',\n \n // Cache directories\n '.cache', '.parcel-cache', '.turbo', '.nx', '.gradle',\n \n // IDE/Editor\n '.idea', '.vscode', '.vs',\n \n // Coverage\n 'coverage', '.coverage', 'htmlcov', '.nyc_output',\n \n // Temporary\n 'tmp', 'temp', '.tmp', '.temp',\n \n // Lock files\n 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb',\n 'Cargo.lock', 'Gemfile.lock', 'poetry.lock',\n \n // Binary/minified\n '*.min.js', '*.min.css', '*.bundle.js',\n '*.wasm', '*.so', '*.dll', '*.pyc',\n '*.map', '*.js.map',\n \n // Hidden directories catch-all\n '.*',\n];\n\nexport const DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || '')\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n .concat(BUILTIN_EXCLUDES);\n\nexport const DEFAULT_MODEL = 'morph-warp-grep-
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/agent/config.ts"],"sourcesContent":["// Parse timeout from env, defaulting to 30 seconds\nconst parseEnvTimeout = (envValue: string | undefined, defaultMs: number): number => {\n if (!envValue) return defaultMs;\n const parsed = parseInt(envValue, 10);\n return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;\n};\n\nexport const AGENT_CONFIG = {\n MAX_TURNS: 4,\n /** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */\n TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 30_000),\n MAX_CONTEXT_CHARS: 540_000,\n MAX_OUTPUT_LINES: 200,\n MAX_READ_LINES: 800,\n MAX_LIST_DEPTH: 3,\n LIST_TIMEOUT_MS: 2_000,\n};\n\n/**\n * Comprehensive exclusion list for directories and files\n * These patterns are used with ripgrep's -g flag\n */\nconst BUILTIN_EXCLUDES = [\n // Version control\n '.git', '.svn', '.hg', '.bzr',\n \n // Dependencies\n 'node_modules', 'bower_components', '.pnpm', '.yarn',\n 'vendor', 'packages', 'Pods', '.bundle',\n \n // Python\n '__pycache__', '.pytest_cache', '.mypy_cache', '.ruff_cache',\n '.venv', 'venv', '.tox', '.nox', '.eggs', '*.egg-info',\n \n // Build outputs\n 'dist', 'build', 'out', 'output', 'target', '_build',\n '.next', '.nuxt', '.output', '.vercel', '.netlify',\n \n // Cache directories\n '.cache', '.parcel-cache', '.turbo', '.nx', '.gradle',\n \n // IDE/Editor\n '.idea', '.vscode', '.vs',\n \n // Coverage\n 'coverage', '.coverage', 'htmlcov', '.nyc_output',\n \n // Temporary\n 'tmp', 'temp', '.tmp', '.temp',\n \n // Lock files\n 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb',\n 'Cargo.lock', 'Gemfile.lock', 'poetry.lock',\n \n // Binary/minified\n '*.min.js', '*.min.css', '*.bundle.js',\n '*.wasm', '*.so', '*.dll', '*.pyc',\n '*.map', '*.js.map',\n \n // Hidden directories catch-all\n '.*',\n];\n\nexport const DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || '')\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n .concat(BUILTIN_EXCLUDES);\n\nexport const DEFAULT_MODEL = 'morph-warp-grep-v2';\n"],"mappings":";AACA,IAAM,kBAAkB,CAAC,UAA8B,cAA8B;AACnF,MAAI,CAAC,SAAU,QAAO;AACtB,QAAM,SAAS,SAAS,UAAU,EAAE;AACpC,SAAO,MAAM,MAAM,KAAK,UAAU,IAAI,YAAY;AACpD;AAEO,IAAM,eAAe;AAAA,EAC1B,WAAW;AAAA;AAAA,EAEX,YAAY,gBAAgB,QAAQ,IAAI,yBAAyB,GAAM;AAAA,EACvE,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,iBAAiB;AACnB;AAMA,IAAM,mBAAmB;AAAA;AAAA,EAEvB;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAO;AAAA;AAAA,EAGvB;AAAA,EAAgB;AAAA,EAAoB;AAAA,EAAS;AAAA,EAC7C;AAAA,EAAU;AAAA,EAAY;AAAA,EAAQ;AAAA;AAAA,EAG9B;AAAA,EAAe;AAAA,EAAiB;AAAA,EAAe;AAAA,EAC/C;AAAA,EAAS;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAS;AAAA;AAAA,EAG1C;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAO;AAAA,EAAU;AAAA,EAAU;AAAA,EAC5C;AAAA,EAAS;AAAA,EAAS;AAAA,EAAW;AAAA,EAAW;AAAA;AAAA,EAGxC;AAAA,EAAU;AAAA,EAAiB;AAAA,EAAU;AAAA,EAAO;AAAA;AAAA,EAG5C;AAAA,EAAS;AAAA,EAAW;AAAA;AAAA,EAGpB;AAAA,EAAY;AAAA,EAAa;AAAA,EAAW;AAAA;AAAA,EAGpC;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAQ;AAAA;AAAA,EAGvB;AAAA,EAAqB;AAAA,EAAa;AAAA,EAAkB;AAAA,EACpD;AAAA,EAAc;AAAA,EAAgB;AAAA;AAAA,EAG9B;AAAA,EAAY;AAAA,EAAa;AAAA,EACzB;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAS;AAAA,EAC3B;AAAA,EAAS;AAAA;AAAA,EAGT;AACF;AAEO,IAAM,oBAAoB,QAAQ,IAAI,2BAA2B,IACrE,MAAM,GAAG,EACT,IAAI,OAAK,EAAE,KAAK,CAAC,EACjB,OAAO,OAAO,EACd,OAAO,gBAAgB;AAEnB,IAAM,gBAAgB;","names":[]}
|
|
@@ -7,17 +7,14 @@ import {
|
|
|
7
7
|
GITHUB_SEARCH_TOOL_NAME,
|
|
8
8
|
WARP_GREP_DESCRIPTION,
|
|
9
9
|
WARP_GREP_TOOL_NAME
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6DRIR7AI.js";
|
|
11
11
|
import {
|
|
12
12
|
WarpGrepClient,
|
|
13
13
|
executeGitHubReadFile,
|
|
14
14
|
executeToolCall,
|
|
15
15
|
formatGitHubReadFileResult,
|
|
16
16
|
formatResult
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import {
|
|
19
|
-
getSystemPrompt
|
|
20
|
-
} from "./chunk-FMLHRJDF.js";
|
|
17
|
+
} from "./chunk-EL6CCK7C.js";
|
|
21
18
|
|
|
22
19
|
// tools/warp_grep/anthropic.ts
|
|
23
20
|
var INPUT_SCHEMA = {
|
|
@@ -47,9 +44,6 @@ function createWarpGrepTool(config) {
|
|
|
47
44
|
},
|
|
48
45
|
formatResult: (result) => {
|
|
49
46
|
return formatResult(result);
|
|
50
|
-
},
|
|
51
|
-
getSystemPrompt: () => {
|
|
52
|
-
return getSystemPrompt();
|
|
53
47
|
}
|
|
54
48
|
});
|
|
55
49
|
}
|
|
@@ -62,13 +56,14 @@ function createGitHubSearchTool(config) {
|
|
|
62
56
|
};
|
|
63
57
|
return Object.assign(tool, {
|
|
64
58
|
execute: async (input) => {
|
|
65
|
-
|
|
59
|
+
const github = input.github_url || input.owner_repo;
|
|
60
|
+
if (!github) {
|
|
61
|
+
throw new Error("Please provide github search url or owner/repo id");
|
|
62
|
+
}
|
|
63
|
+
return client.searchGitHub({ query: input.query, github, branch: input.branch });
|
|
66
64
|
},
|
|
67
65
|
formatResult: (result) => {
|
|
68
66
|
return formatResult(result);
|
|
69
|
-
},
|
|
70
|
-
getSystemPrompt: () => {
|
|
71
|
-
return getSystemPrompt();
|
|
72
67
|
}
|
|
73
68
|
});
|
|
74
69
|
}
|
|
@@ -95,4 +90,4 @@ export {
|
|
|
95
90
|
createGitHubSearchTool,
|
|
96
91
|
createGitHubReadFileTool
|
|
97
92
|
};
|
|
98
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-DS7YL4V3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/anthropic.ts"],"sourcesContent":["/**\n * Anthropic SDK adapter for morph-warp-grep tool\n */\n\nimport type { Tool } from '@anthropic-ai/sdk/resources/messages';\nimport { executeToolCall, formatResult, WarpGrepClient, executeGitHubReadFile, formatGitHubReadFileResult } from './client.js';\nimport { WARP_GREP_DESCRIPTION, WARP_GREP_TOOL_NAME, GITHUB_SEARCH_TOOL_NAME, GITHUB_SEARCH_DESCRIPTION, GITHUB_SEARCH_INPUT_SCHEMA, GITHUB_READ_FILE_TOOL_NAME, GITHUB_READ_FILE_DESCRIPTION, GITHUB_READ_FILE_INPUT_SCHEMA } from './prompts.js';\nimport type { WarpGrepToolConfig, WarpGrepResult, GitHubSearchToolConfig, GitHubReadFileInput, GitHubReadFileResult, GitHubReadFileToolConfig } from './types.js';\n\n/**\n * Input schema for the warp grep tool\n */\nconst INPUT_SCHEMA = {\n type: 'object',\n properties: {\n query: { type: 'string', description: 'Free-form repository question' },\n },\n required: ['query'],\n} as const;\n\n/**\n * Anthropic-native warp grep tool definition\n * \n * @example\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { warpGrepTool, execute } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n * \n * const client = new Anthropic();\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [warpGrepTool],\n * messages: [{ role: 'user', content: 'Find authentication middleware' }]\n * });\n * \n * // Execute the tool call\n * const result = await execute({ query: '...' }, { repoRoot: '.' });\n * ```\n */\nexport const warpGrepTool: Tool = {\n name: WARP_GREP_TOOL_NAME,\n description: WARP_GREP_DESCRIPTION,\n input_schema: INPUT_SCHEMA,\n};\n\n/**\n * Execute warp grep search\n * \n * @param input - Tool input with query\n * @param config - Configuration with repoRoot and optional provider\n * @returns Search results\n */\nexport async function execute(\n input: { query: string } | string,\n config: WarpGrepToolConfig\n): Promise<WarpGrepResult> {\n return executeToolCall(input, config);\n}\n\n// Re-export formatResult for convenience\nexport { formatResult };\n\n/**\n * Create a custom warp grep tool with configuration and methods\n * \n * @param config - Configuration options\n * @returns Tool definition with execute and formatResult methods\n * \n * @example Local usage\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { createWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n * \n * const tool = createWarpGrepTool({ repoRoot: '.' });\n * \n * const client = new Anthropic();\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'Find authentication middleware' }]\n * });\n * ```\n * \n * @example Remote sandbox (E2B, Modal, etc.)\n * ```typescript\n * const tool = createMorphWarpGrepTool({\n * repoRoot: '/home/repo',\n * remoteCommands: {\n * grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout,\n * read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout,\n * listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout,\n * },\n * });\n * ```\n */\nexport function createWarpGrepTool(config: WarpGrepToolConfig) {\n const tool: Tool = {\n name: config.name ?? WARP_GREP_TOOL_NAME,\n description: config.description ?? WARP_GREP_DESCRIPTION,\n input_schema: INPUT_SCHEMA,\n };\n\n return Object.assign(tool, {\n execute: async (input: unknown): Promise<WarpGrepResult> => {\n return executeToolCall(input as { query: string } | string, config);\n },\n formatResult: (result: WarpGrepResult): string => {\n return formatResult(result);\n },\n });\n}\n\n/**\n * Create a GitHub search tool for Anthropic SDK\n *\n * @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout)\n * @returns Anthropic Tool with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n *\n * const tool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY });\n *\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'How does auth work in vercel/next.js?' }]\n * });\n *\n * // Execute\n * const result = await tool.execute({ query: 'auth middleware', github: 'vercel/next.js' });\n * console.log(tool.formatResult(result));\n * ```\n */\nexport function createGitHubSearchTool(config: GitHubSearchToolConfig) {\n const client = new WarpGrepClient(config);\n\n const tool: Tool = {\n name: GITHUB_SEARCH_TOOL_NAME,\n description: GITHUB_SEARCH_DESCRIPTION,\n input_schema: GITHUB_SEARCH_INPUT_SCHEMA,\n };\n\n return Object.assign(tool, {\n execute: async (input: { query: string; github_url?: string; owner_repo?: string; branch?: string }): Promise<WarpGrepResult> => {\n const github = input.github_url || input.owner_repo;\n if (!github) {\n throw new Error('Please provide github search url or owner/repo id');\n }\n return client.searchGitHub({ query: input.query, github, branch: input.branch });\n },\n formatResult: (result: WarpGrepResult): string => {\n return formatResult(result);\n },\n });\n}\n\n/**\n * Create a GitHub read file tool for Anthropic SDK\n *\n * @param config - Optional configuration (timeout)\n * @returns Anthropic Tool with execute and formatResult methods\n *\n * @example\n * ```typescript\n * import Anthropic from '@anthropic-ai/sdk';\n * import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/anthropic';\n *\n * const tool = createGitHubReadFileTool();\n *\n * const response = await client.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [tool],\n * messages: [{ role: 'user', content: 'Read the package.json from vercel/next.js' }]\n * });\n *\n * const result = await tool.execute({ github: 'vercel/next.js', path: 'package.json' });\n * console.log(tool.formatResult(result));\n * ```\n */\nexport function createGitHubReadFileTool(config?: GitHubReadFileToolConfig) {\n const tool: Tool = {\n name: GITHUB_READ_FILE_TOOL_NAME,\n description: GITHUB_READ_FILE_DESCRIPTION,\n input_schema: GITHUB_READ_FILE_INPUT_SCHEMA,\n };\n\n return Object.assign(tool, {\n execute: async (input: GitHubReadFileInput): Promise<GitHubReadFileResult> => {\n return executeGitHubReadFile(input, config);\n },\n formatResult: (result: GitHubReadFileResult): string => {\n return formatGitHubReadFileResult(result);\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAYA,IAAM,eAAe;AAAA,EACnB,MAAM;AAAA,EACN,YAAY;AAAA,IACV,OAAO,EAAE,MAAM,UAAU,aAAa,gCAAgC;AAAA,EACxE;AAAA,EACA,UAAU,CAAC,OAAO;AACpB;AAqBO,IAA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A2B,MAAM;AAAA,IAC1C;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-2HMEZZKK.js";
|
|
4
4
|
import {
|
|
5
5
|
executeBrowserTask
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NQQS5BZZ.js";
|
|
7
7
|
import {
|
|
8
8
|
__export
|
|
9
9
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -54,4 +54,4 @@ export {
|
|
|
54
54
|
browserTool,
|
|
55
55
|
vercel_exports
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-EGOCFCAH.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createCodeStorageHttpCommands
|
|
3
|
-
} from "./chunk-GVGJIXV2.js";
|
|
4
1
|
import {
|
|
5
2
|
RemoteCommandsProvider
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NF2QWJDY.js";
|
|
7
4
|
import {
|
|
8
5
|
parseGitHubUrl
|
|
9
6
|
} from "./chunk-63VHBANJ.js";
|
|
10
7
|
import {
|
|
11
8
|
runWarpGrep,
|
|
12
9
|
runWarpGrepStreaming
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LXBIP5FI.js";
|
|
11
|
+
import {
|
|
12
|
+
createCodeStorageHttpCommands
|
|
13
|
+
} from "./chunk-GVGJIXV2.js";
|
|
14
14
|
|
|
15
15
|
// tools/warp_grep/client.ts
|
|
16
16
|
var DEFAULT_CODE_SEARCH_URL = "https://morphllm.com";
|
|
@@ -284,4 +284,4 @@ export {
|
|
|
284
284
|
formatGitHubReadFileResult,
|
|
285
285
|
formatResult
|
|
286
286
|
};
|
|
287
|
-
//# sourceMappingURL=chunk-
|
|
287
|
+
//# sourceMappingURL=chunk-EL6CCK7C.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeEditFile
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HZK5TEUK.js";
|
|
4
4
|
import {
|
|
5
5
|
EDIT_FILE_SYSTEM_PROMPT,
|
|
6
6
|
EDIT_FILE_TOOL_DESCRIPTION
|
|
@@ -79,4 +79,4 @@ export {
|
|
|
79
79
|
getSystemPrompt,
|
|
80
80
|
anthropic_exports
|
|
81
81
|
};
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-GDCVK6SP.js.map
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-2VERUKO2.js";
|
|
13
13
|
import {
|
|
14
14
|
fetchWithRetry
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ADHGSV2D.js";
|
|
16
16
|
|
|
17
17
|
// tools/browser/profiles/core.ts
|
|
18
18
|
var DEFAULT_API_URL = process.env.MORPH_ENVIRONMENT === "DEV" ? "http://localhost:8000" : "https://browser.morphllm.com";
|
|
@@ -386,4 +386,4 @@ export {
|
|
|
386
386
|
listRepos,
|
|
387
387
|
getProfileState
|
|
388
388
|
};
|
|
389
|
-
//# sourceMappingURL=chunk-
|
|
389
|
+
//# sourceMappingURL=chunk-GVF4Q75N.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-YQMPVJ2L.js";
|
|
5
5
|
import {
|
|
6
6
|
executeCodebaseSearch
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3ZA7Y66U.js";
|
|
8
8
|
|
|
9
9
|
// tools/codebase_search/anthropic.ts
|
|
10
10
|
function createCodebaseSearchTool(config) {
|
|
@@ -80,4 +80,4 @@ function formatResult(result) {
|
|
|
80
80
|
export {
|
|
81
81
|
createCodebaseSearchTool
|
|
82
82
|
};
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
83
|
+
//# sourceMappingURL=chunk-GWKCMFD6.js.map
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
AGENT_CONFIG,
|
|
16
16
|
DEFAULT_EXCLUDES
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-DKODF3YG.js";
|
|
18
18
|
|
|
19
19
|
// tools/warp_grep/providers/local.ts
|
|
20
20
|
import fs from "fs/promises";
|
|
@@ -95,7 +95,8 @@ var SKIP_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
95
95
|
".map",
|
|
96
96
|
".js.map"
|
|
97
97
|
]);
|
|
98
|
-
function shouldSkip(name) {
|
|
98
|
+
function shouldSkip(name, allowNames) {
|
|
99
|
+
if (allowNames?.has(name)) return false;
|
|
99
100
|
if (SKIP_NAMES.has(name)) return true;
|
|
100
101
|
if (name.startsWith(".")) return true;
|
|
101
102
|
for (const ext of SKIP_EXTENSIONS) {
|
|
@@ -104,10 +105,14 @@ function shouldSkip(name) {
|
|
|
104
105
|
return false;
|
|
105
106
|
}
|
|
106
107
|
var LocalRipgrepProvider = class {
|
|
107
|
-
constructor(repoRoot, excludes = DEFAULT_EXCLUDES) {
|
|
108
|
+
constructor(repoRoot, excludes = DEFAULT_EXCLUDES, options) {
|
|
108
109
|
this.repoRoot = repoRoot;
|
|
109
110
|
this.excludes = excludes;
|
|
111
|
+
if (options?.allowNames?.length) {
|
|
112
|
+
this.allowNames = new Set(options.allowNames);
|
|
113
|
+
}
|
|
110
114
|
}
|
|
115
|
+
allowNames;
|
|
111
116
|
async grep(params) {
|
|
112
117
|
let abs;
|
|
113
118
|
try {
|
|
@@ -121,6 +126,7 @@ var LocalRipgrepProvider = class {
|
|
|
121
126
|
const stat = await fs.stat(abs).catch(() => null);
|
|
122
127
|
if (!stat) return { lines: [] };
|
|
123
128
|
const targetArg = abs === path.resolve(this.repoRoot) ? "." : toRepoRelative(this.repoRoot, abs);
|
|
129
|
+
const contextLines = params.context_lines !== void 0 ? String(params.context_lines) : "1";
|
|
124
130
|
const args = [
|
|
125
131
|
"--no-config",
|
|
126
132
|
"--no-heading",
|
|
@@ -130,9 +136,10 @@ var LocalRipgrepProvider = class {
|
|
|
130
136
|
"--trim",
|
|
131
137
|
"--max-columns=400",
|
|
132
138
|
"-C",
|
|
133
|
-
|
|
139
|
+
contextLines,
|
|
140
|
+
...params.case_sensitive === false ? ["--ignore-case"] : [],
|
|
134
141
|
...params.glob ? ["--glob", params.glob] : [],
|
|
135
|
-
...this.excludes.flatMap((e) => ["-g", `!${e}`]),
|
|
142
|
+
...this.excludes.filter((e) => !this.allowNames?.has(e)).flatMap((e) => ["-g", `!${e}`]),
|
|
136
143
|
params.pattern,
|
|
137
144
|
targetArg || "."
|
|
138
145
|
];
|
|
@@ -157,10 +164,9 @@ Details: ${res.stderr}` : ""}`
|
|
|
157
164
|
}
|
|
158
165
|
const lines = (res.stdout || "").trim().split(/\r?\n/).filter((l) => l.length > 0);
|
|
159
166
|
if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
};
|
|
167
|
+
const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);
|
|
168
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);
|
|
169
|
+
return { lines: truncated };
|
|
164
170
|
}
|
|
165
171
|
return { lines };
|
|
166
172
|
}
|
|
@@ -234,7 +240,7 @@ Details: ${res.stderr}` : ""}`
|
|
|
234
240
|
}
|
|
235
241
|
if (out.length > AGENT_CONFIG.MAX_READ_LINES) {
|
|
236
242
|
const truncated = out.slice(0, AGENT_CONFIG.MAX_READ_LINES);
|
|
237
|
-
truncated.push(`...
|
|
243
|
+
truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines)`);
|
|
238
244
|
return { lines: truncated };
|
|
239
245
|
}
|
|
240
246
|
return { lines: out };
|
|
@@ -254,6 +260,7 @@ Details: ${res.stderr}` : ""}`
|
|
|
254
260
|
const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;
|
|
255
261
|
const regex = params.pattern ? new RegExp(params.pattern) : null;
|
|
256
262
|
const repoRoot = this.repoRoot;
|
|
263
|
+
const allowNames = this.allowNames;
|
|
257
264
|
const results = [];
|
|
258
265
|
let timedOut = false;
|
|
259
266
|
const startTime = Date.now();
|
|
@@ -271,7 +278,7 @@ Details: ${res.stderr}` : ""}`
|
|
|
271
278
|
}
|
|
272
279
|
for (const entry of entries) {
|
|
273
280
|
if (timedOut || results.length >= maxResults) break;
|
|
274
|
-
if (shouldSkip(entry.name)) continue;
|
|
281
|
+
if (shouldSkip(entry.name, allowNames)) continue;
|
|
275
282
|
if (regex && !regex.test(entry.name)) continue;
|
|
276
283
|
const full = path.join(dir, entry.name);
|
|
277
284
|
const isDir = entry.isDirectory();
|
|
@@ -294,4 +301,4 @@ Details: ${res.stderr}` : ""}`
|
|
|
294
301
|
export {
|
|
295
302
|
LocalRipgrepProvider
|
|
296
303
|
};
|
|
297
|
-
//# sourceMappingURL=chunk-
|
|
304
|
+
//# sourceMappingURL=chunk-HZOTLGJH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/providers/local.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport fssync from 'fs';\nimport path from 'path';\nimport { runRipgrep } from '../utils/ripgrep.js';\nimport { ensureWithinRepo, resolveUnderRepo, toRepoRelative, isSymlink, isTextualFile, fixPathRepetition } from '../utils/paths.js';\nimport type { WarpGrepProvider, GrepResult, ReadResult, ListDirectoryEntry } from './types.js';\nimport { readAllLines } from '../utils/files.js';\nimport { DEFAULT_EXCLUDES, AGENT_CONFIG } from '../agent/config.js';\n\n/**\n * Directories/files to always skip (exact name match)\n */\nconst SKIP_NAMES = new Set([\n // Version control\n '.git', '.svn', '.hg', '.bzr',\n // Dependencies\n 'node_modules', 'bower_components', '.pnpm', '.yarn',\n 'vendor', 'Pods', '.bundle',\n // Python\n '__pycache__', '.pytest_cache', '.mypy_cache', '.ruff_cache',\n '.venv', 'venv', '.tox', '.nox', '.eggs',\n // Build outputs\n 'dist', 'build', 'out', 'output', 'target', '_build',\n '.next', '.nuxt', '.output', '.vercel', '.netlify',\n // Cache\n '.cache', '.parcel-cache', '.turbo', '.nx', '.gradle',\n // IDE\n '.idea', '.vscode', '.vs',\n // Coverage\n 'coverage', '.coverage', 'htmlcov', '.nyc_output',\n // Temp\n 'tmp', 'temp', '.tmp', '.temp',\n // Lock files\n 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb',\n 'Cargo.lock', 'Gemfile.lock', 'poetry.lock',\n]);\n\n/**\n * File extensions to skip\n */\nconst SKIP_EXTENSIONS = new Set([\n '.min.js', '.min.css', '.bundle.js',\n '.wasm', '.so', '.dll', '.pyc',\n '.map', '.js.map',\n]);\n\n/**\n * Check if a filename should be skipped\n */\nfunction shouldSkip(name: string, allowNames?: Set<string>): boolean {\n // Allow explicitly permitted names through\n if (allowNames?.has(name)) return false;\n\n // Skip exact name matches\n if (SKIP_NAMES.has(name)) return true;\n\n // Skip hidden files/directories (start with .)\n if (name.startsWith('.')) return true;\n\n // Skip files with certain extensions\n for (const ext of SKIP_EXTENSIONS) {\n if (name.endsWith(ext)) return true;\n }\n\n return false;\n}\n\nexport class LocalRipgrepProvider implements WarpGrepProvider {\n private readonly allowNames?: Set<string>;\n\n constructor(\n private readonly repoRoot: string,\n private readonly excludes: string[] = DEFAULT_EXCLUDES,\n options?: { allowNames?: string[] },\n ) {\n if (options?.allowNames?.length) {\n this.allowNames = new Set(options.allowNames);\n }\n }\n\n async grep(params: { pattern: string; path: string; glob?: string; context_lines?: number; case_sensitive?: boolean }): Promise<GrepResult> {\n let abs: string;\n try {\n abs = resolveUnderRepo(this.repoRoot, params.path);\n } catch (err) {\n return {\n lines: [],\n error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n const stat = await fs.stat(abs).catch(() => null);\n if (!stat) return { lines: [] };\n const targetArg = abs === path.resolve(this.repoRoot) ? '.' : toRepoRelative(this.repoRoot, abs);\n const contextLines = params.context_lines !== undefined ? String(params.context_lines) : '1';\n const args = [\n '--no-config',\n '--no-heading',\n '--with-filename',\n '--line-number',\n '--color=never',\n '--trim',\n '--max-columns=400',\n '-C', contextLines,\n ...(params.case_sensitive === false ? ['--ignore-case'] : []),\n ...(params.glob ? ['--glob', params.glob] : []),\n ...this.excludes.filter(e => !this.allowNames?.has(e)).flatMap((e) => ['-g', `!${e}`]),\n params.pattern,\n targetArg || '.',\n ];\n const res = await runRipgrep(args, { cwd: this.repoRoot });\n \n // Gracefully handle ripgrep not being available\n if (res.exitCode === -1) {\n return {\n lines: [],\n error: `[RIPGREP NOT AVAILABLE] ripgrep (rg) is required but failed to execute. Please install it:\\n` +\n ` • macOS: brew install ripgrep\\n` +\n ` • Ubuntu/Debian: apt install ripgrep\\n` +\n ` • Windows: choco install ripgrep\\n` +\n ` • Or visit: https://github.com/BurntSushi/ripgrep#installation\\n` +\n `Exit code: ${res.exitCode}${res.stderr ? `\\nDetails: ${res.stderr}` : ''}`,\n };\n }\n \n // Handle other ripgrep errors gracefully\n if (res.exitCode !== 0 && res.exitCode !== 1) {\n return {\n lines: [],\n error: `[RIPGREP ERROR] grep failed with exit code ${res.exitCode}${res.stderr ? `: ${res.stderr}` : ''}`,\n };\n }\n \n const lines = (res.stdout || '')\n .trim()\n .split(/\\r?\\n/)\n .filter((l) => l.length > 0);\n if (lines.length > AGENT_CONFIG.MAX_OUTPUT_LINES) {\n const truncated = lines.slice(0, AGENT_CONFIG.MAX_OUTPUT_LINES);\n truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_OUTPUT_LINES} of ${lines.length} lines)`);\n return { lines: truncated };\n }\n \n return { lines };\n }\n\n async read(params: { path: string; start?: number; end?: number }): Promise<ReadResult> {\n let abs: string;\n try {\n abs = resolveUnderRepo(this.repoRoot, params.path);\n } catch (err) {\n return {\n lines: [],\n error: `[PATH ERROR] ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n let stat = await fs.stat(abs).catch(() => null);\n\n // Handle duplicate path segments from model predictions\n if (!stat || !stat.isFile()) {\n const fixedPath = fixPathRepetition(abs);\n if (fixedPath) {\n const fixedStat = await fs.stat(fixedPath).catch(() => null);\n if (fixedStat?.isFile()) {\n abs = fixedPath;\n stat = fixedStat;\n }\n }\n }\n\n // Gracefully handle file not found / not a file\n if (!stat || !stat.isFile()) {\n return {\n lines: [],\n error: `[FILE NOT FOUND] You tried to read \"${params.path}\" but there is no file at this path. ` +\n `Double-check the path exists and is spelled correctly.`,\n };\n }\n \n // Gracefully handle symlinks\n if (isSymlink(abs)) {\n return {\n lines: [],\n error: `[SYMLINK] You tried to read \"${params.path}\" but this is a symlink. ` +\n `Try reading the actual file it points to instead.`,\n };\n }\n \n // Gracefully handle non-text or too-large files\n if (!isTextualFile(abs)) {\n return {\n lines: [],\n error: `[UNREADABLE FILE] You tried to read \"${params.path}\" but this file is either too large ` +\n `or not a text file, so it cannot be read. Try a different file.`,\n };\n }\n \n let lines: string[];\n try {\n lines = await readAllLines(abs);\n } catch (err) {\n return {\n lines: [],\n error: `[READ ERROR] Failed to read \"${params.path}\": ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n const total = lines.length;\n const rawStart = params.start;\n const rawEnd = params.end;\n \n let s = 1;\n let e = total;\n \n const startValid = rawStart === undefined || (Number.isFinite(rawStart) && rawStart > 0);\n const endValid = rawEnd === undefined || (Number.isFinite(rawEnd) && rawEnd > 0);\n \n if (startValid && endValid) {\n s = rawStart ?? 1;\n e = Math.min(rawEnd ?? total, total);\n if ((s > total && total > 0) || (s > e)) {\n s = 1;\n e = total;\n }\n }\n const out: string[] = [];\n for (let i = s; i <= e; i += 1) {\n const content = lines[i - 1] ?? '';\n out.push(`${i}|${content}`);\n }\n if (out.length > AGENT_CONFIG.MAX_READ_LINES) {\n const truncated = out.slice(0, AGENT_CONFIG.MAX_READ_LINES);\n truncated.push(`... (output truncated at ${AGENT_CONFIG.MAX_READ_LINES} of ${out.length} lines)`);\n return { lines: truncated };\n }\n \n return { lines: out };\n }\n\n async listDirectory(params: { path: string; pattern?: string | null; maxResults?: number; maxDepth?: number }): Promise<ListDirectoryEntry[]> {\n let abs: string;\n try {\n abs = resolveUnderRepo(this.repoRoot, params.path);\n } catch {\n // Path outside repo - return empty (graceful failure)\n return [];\n }\n const stat = await fs.stat(abs).catch(() => null);\n if (!stat || !stat.isDirectory()) {\n return [];\n }\n const maxResults = params.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;\n const maxDepth = params.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;\n const regex = params.pattern ? new RegExp(params.pattern) : null;\n const repoRoot = this.repoRoot;\n const allowNames = this.allowNames;\n\n const results: ListDirectoryEntry[] = [];\n let timedOut = false;\n const startTime = Date.now();\n\n async function walk(dir: string, depth: number) {\n if (Date.now() - startTime > AGENT_CONFIG.LIST_TIMEOUT_MS) {\n timedOut = true;\n return;\n }\n if (depth > maxDepth || results.length >= maxResults) return;\n let entries: import('fs').Dirent[];\n try {\n entries = await fs.readdir(dir, { withFileTypes: true });\n } catch {\n return; // skip unreadable directories (ENOENT, EACCES, etc.)\n }\n for (const entry of entries) {\n if (timedOut || results.length >= maxResults) break;\n\n // Simple name-based filtering - skip junk dirs/files\n if (shouldSkip(entry.name, allowNames)) continue;\n \n // Apply user-provided pattern filter\n if (regex && !regex.test(entry.name)) continue;\n \n const full = path.join(dir, entry.name);\n const isDir = entry.isDirectory();\n \n results.push({\n name: entry.name,\n path: toRepoRelative(repoRoot, full),\n type: isDir ? 'dir' : 'file',\n depth,\n });\n if (isDir) {\n await walk(full, depth + 1);\n }\n }\n }\n await walk(abs, 0);\n return results;\n }\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AAEf,OAAO,UAAU;AAUjB,IAAM,aAAa,oBAAI,IAAI;AAAA;AAAA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IAAI;AACtC,cAAM,QAAQ,MAAM,YAAY;AAEhC,gBAAQ,KAAK;AAAA,UACX,MAAM,MAAM;AAAA,UACZ,MAAM,eAAe,UAAU,IAAI;AAAA,UACnC,MAAM,QAAQ,QAAQ;AAAA,UACtB;AAAA,QACF,CAAC;AACD,YAAI,OAAO;AACT,gBAAM,KAAK,MAAM,QAAQ,CAAC;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AACA,UAAM,KAAK,KAAK,CAAC;AACjB,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AGENT_CONFIG
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DKODF3YG.js";
|
|
4
4
|
|
|
5
5
|
// tools/warp_grep/agent/tools/grep.ts
|
|
6
6
|
async function toolGrep(provider, args) {
|
|
@@ -67,14 +67,12 @@ async function toolListDirectory(provider, args) {
|
|
|
67
67
|
}
|
|
68
68
|
const { entries: list } = await getListRecursive(initialDepth);
|
|
69
69
|
if (!list.length) return "empty";
|
|
70
|
-
|
|
71
|
-
return "query not specific enough, tool called tried to return too much context and failed";
|
|
72
|
-
}
|
|
73
|
-
return list.map((e) => {
|
|
70
|
+
const tree = list.map((e) => {
|
|
74
71
|
const indent = " ".repeat(e.depth);
|
|
75
72
|
const name = e.type === "dir" ? `${e.name}/` : e.name;
|
|
76
73
|
return `${indent}${name}`;
|
|
77
74
|
}).join("\n");
|
|
75
|
+
return tree;
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
// tools/warp_grep/agent/tools/finish.ts
|
|
@@ -163,12 +161,15 @@ function calculateContextBudget(messages) {
|
|
|
163
161
|
const maxK = Math.round(maxChars / 1e3);
|
|
164
162
|
return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;
|
|
165
163
|
}
|
|
166
|
-
async function buildInitialState(repoRoot, query, provider) {
|
|
164
|
+
async function buildInitialState(repoRoot, query, provider, options) {
|
|
165
|
+
const budget = calculateContextBudget([]);
|
|
166
|
+
const turnTag = `Turn 0/${AGENT_CONFIG.MAX_TURNS}`;
|
|
167
|
+
const treeDepth = options?.query_type === "node_modules" ? 1 : 2;
|
|
167
168
|
try {
|
|
168
169
|
const entries = await provider.listDirectory({
|
|
169
170
|
path: ".",
|
|
170
171
|
maxResults: AGENT_CONFIG.MAX_OUTPUT_LINES,
|
|
171
|
-
maxDepth:
|
|
172
|
+
maxDepth: treeDepth
|
|
172
173
|
});
|
|
173
174
|
const treeLines = entries.map((e) => {
|
|
174
175
|
const indent = " ".repeat(e.depth);
|
|
@@ -184,7 +185,9 @@ ${treeOutput}
|
|
|
184
185
|
|
|
185
186
|
<search_string>
|
|
186
187
|
${query}
|
|
187
|
-
</search_string
|
|
188
|
+
</search_string>
|
|
189
|
+
${budget}
|
|
190
|
+
${turnTag}`;
|
|
188
191
|
} catch {
|
|
189
192
|
const repoName = path.basename(repoRoot);
|
|
190
193
|
return `<repo_structure>
|
|
@@ -193,7 +196,9 @@ ${repoName}/
|
|
|
193
196
|
|
|
194
197
|
<search_string>
|
|
195
198
|
${query}
|
|
196
|
-
</search_string
|
|
199
|
+
</search_string>
|
|
200
|
+
${budget}
|
|
201
|
+
${turnTag}`;
|
|
197
202
|
}
|
|
198
203
|
}
|
|
199
204
|
function formatListDirectoryTree(entries) {
|
|
@@ -243,4 +248,4 @@ export {
|
|
|
243
248
|
formatListDirectoryTree,
|
|
244
249
|
enforceContextLimit
|
|
245
250
|
};
|
|
246
|
-
//# sourceMappingURL=chunk-
|
|
251
|
+
//# sourceMappingURL=chunk-K2FXHDX2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../tools/warp_grep/agent/tools/grep.ts","../tools/warp_grep/agent/tools/read.ts","../tools/warp_grep/agent/tools/list_directory.ts","../tools/warp_grep/agent/tools/finish.ts","../tools/warp_grep/agent/helpers.ts"],"sourcesContent":["import type { WarpGrepProvider } from '../../providers/types.js';\n\nexport async function toolGrep(\n provider: WarpGrepProvider,\n args: { pattern: string; path: string; glob?: string; context_lines?: number; case_sensitive?: boolean }\n): Promise<{ output: string }> {\n const res = await provider.grep(args);\n \n // Return errors as output - let the model see and handle them\n if (res.error) {\n return { output: res.error };\n }\n \n if (!res.lines.length) {\n return { output: 'no matches' };\n }\n \n return { output: res.lines.join('\\n') };\n}\n\n","import type { WarpGrepProvider } from '../../providers/types.js';\n\nfunction isValidRange(start: unknown, end: unknown): boolean {\n return (\n typeof start === 'number' &&\n typeof end === 'number' &&\n Number.isFinite(start) &&\n Number.isFinite(end) &&\n start > 0 &&\n end >= start\n );\n}\n\nexport async function toolRead(\n provider: WarpGrepProvider,\n args: { path: string; start?: number; end?: number; lines?: Array<[number, number]> }\n): Promise<string> {\n if (args.lines && Array.isArray(args.lines) && args.lines.length > 0) {\n const validRanges: Array<[number, number]> = [];\n for (const range of args.lines) {\n if (Array.isArray(range) && range.length >= 2 && isValidRange(range[0], range[1])) {\n validRanges.push([range[0], range[1]]);\n }\n }\n \n if (validRanges.length === 0) {\n const res = await provider.read({ path: args.path });\n if (res.error) return res.error;\n if (!res.lines.length) return '(empty file)';\n return res.lines.join('\\n');\n }\n \n const chunks: string[] = [];\n for (const [start, end] of validRanges) {\n const res = await provider.read({ path: args.path, start, end });\n if (res.error) return res.error;\n chunks.push(res.lines.join('\\n'));\n }\n if (chunks.every(c => c === '')) return '(empty file)';\n return chunks.join('\\n...\\n');\n }\n\n const res = await provider.read({ path: args.path, start: args.start, end: args.end });\n if (res.error) {\n return res.error;\n }\n if (!res.lines.length) return '(empty file)';\n return res.lines.join('\\n');\n}\n\n","import type { WarpGrepProvider } from '../../providers/types.js';\nimport { AGENT_CONFIG } from '../config.js';\n\nexport async function toolListDirectory(\n provider: WarpGrepProvider,\n args: { path: string; pattern?: string | null; maxResults?: number; maxDepth?: number }\n): Promise<string> {\n\n const maxResults = args.maxResults ?? AGENT_CONFIG.MAX_OUTPUT_LINES;\n const initialDepth = args.maxDepth ?? AGENT_CONFIG.MAX_LIST_DEPTH;\n\n type DirectoryEntries = Awaited<ReturnType<typeof provider.listDirectory>>;\n async function getListRecursive(currentDepth: number): Promise<{ entries: DirectoryEntries; }> {\n const entries = await provider.listDirectory({\n path: args.path,\n pattern: args.pattern ?? null,\n maxResults,\n maxDepth: currentDepth,\n });\n\n if (entries.length >= maxResults && currentDepth > 0) {\n return getListRecursive(currentDepth - 1);\n }\n\n return { entries };\n }\n const { entries: list } = await getListRecursive(initialDepth);\n\n if (!list.length) return 'empty';\n\n const tree = list\n .map((e) => {\n const indent = ' '.repeat(e.depth);\n const name = e.type === 'dir' ? `${e.name}/` : e.name;\n return `${indent}${name}`;\n })\n .join('\\n');\n\n return tree;\n}\n","import type { FinishFileSpec } from '../types.js';\n\nfunction isValidRange(range: unknown): range is [number, number] {\n return (\n Array.isArray(range) &&\n range.length >= 2 &&\n typeof range[0] === 'number' &&\n typeof range[1] === 'number' &&\n Number.isFinite(range[0]) &&\n Number.isFinite(range[1]) &&\n range[0] > 0 &&\n range[1] >= range[0]\n );\n}\n\nfunction extractValidRanges(lines: unknown): Array<[number, number]> | null {\n if (!Array.isArray(lines)) return null;\n const valid: Array<[number, number]> = [];\n for (const range of lines) {\n if (isValidRange(range)) {\n valid.push([range[0], range[1]]);\n }\n }\n return valid.length > 0 ? valid : null;\n}\n\nexport function normalizeFinishFiles(files: FinishFileSpec[]): FinishFileSpec[] {\n return files.map((f) => {\n if (f.lines === '*') return { path: f.path, lines: '*' };\n const validRanges = extractValidRanges(f.lines);\n if (!validRanges) return { path: f.path, lines: '*' };\n return { path: f.path, lines: mergeRanges(validRanges) };\n });\n}\n\nexport async function readFinishFiles(\n repoRoot: string,\n files: FinishFileSpec[],\n reader: (path: string, start?: number, end?: number) => Promise<string[]>\n): Promise<{ path: string; ranges: '*' | Array<[number, number]>; content: string }[]> {\n const out: { path: string; ranges: '*' | Array<[number, number]>; content: string }[] = [];\n for (const f of files) {\n const validRanges = f.lines === '*' ? null : extractValidRanges(f.lines);\n if (f.lines === '*' || !validRanges) {\n const lines = await reader(f.path);\n out.push({ path: f.path, ranges: '*', content: lines.join('\\n') });\n } else {\n const ranges = mergeRanges(validRanges);\n const chunks: string[] = [];\n for (let i = 0; i < ranges.length; i++) {\n const [s, e] = ranges[i];\n if (i === 0 && s > 1) {\n chunks.push(`// ... existing code, block starting at line ${s} ...`);\n } else if (i > 0) {\n chunks.push(`// ... existing code, block starting at line ${s} ...`);\n }\n const lines = await reader(f.path, s, e);\n chunks.push(lines.join('\\n'));\n }\n out.push({ path: f.path, ranges, content: chunks.join('\\n') });\n }\n }\n return out;\n}\n\nfunction mergeRanges(ranges: Array<[number, number]>): Array<[number, number]> {\n if (!ranges.length) return [];\n const sorted = [...ranges].sort((a, b) => a[0] - b[0]);\n const merged: Array<[number, number]> = [];\n let [cs, ce] = sorted[0];\n for (let i = 1; i < sorted.length; i++) {\n const [s, e] = sorted[i];\n if (s <= ce + 1) {\n ce = Math.max(ce, e);\n } else {\n merged.push([cs, ce]);\n cs = s;\n ce = e;\n }\n }\n merged.push([cs, ce]);\n return merged;\n}\n\n","/**\n * Shared helper functions for warp-grep agent loop.\n * Used by both the internal runner and exported for harness users.\n */\n\nimport path from 'path';\nimport { AGENT_CONFIG } from './config.js';\nimport type { ChatMessage } from './types.js';\nimport type { WarpGrepProvider, ListDirectoryEntry } from '../providers/types.js';\n\nconst TRUNCATED_MARKER = '[truncated for context limit]';\n\n/**\n * Format the turn counter message shown to the model.\n */\nexport function formatTurnMessage(turnsUsed: number, maxTurns: number): string {\n const turnsRemaining = maxTurns - turnsUsed;\n if (turnsRemaining === 1) {\n return `\\nYou have used ${turnsUsed} turns, you only have 1 turn remaining. You have run out of turns to explore the code base and MUST call the finish tool now`;\n }\n return `\\nYou have used ${turnsUsed} turn${turnsUsed === 1 ? '' : 's'} and have ${turnsRemaining} remaining`;\n}\n\n/**\n * Calculate and format the context budget indicator.\n */\nexport function calculateContextBudget(messages: ChatMessage[]): string {\n const totalChars = messages.reduce((sum, m) => sum + m.content.length, 0);\n const maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS;\n const percent = Math.round((totalChars / maxChars) * 100);\n const usedK = Math.round(totalChars / 1000);\n const maxK = Math.round(maxChars / 1000);\n return `<context_budget>${percent}% (${usedK}K/${maxK}K chars)</context_budget>`;\n}\n\n/**\n * Build the initial state message containing repo structure and query.\n */\nexport async function buildInitialState(\n repoRoot: string,\n query: string,\n provider: WarpGrepProvider,\n options?: { query_type?: string },\n): Promise<string> {\n const budget = calculateContextBudget([]);\n const turnTag = `Turn 0/${AGENT_CONFIG.MAX_TURNS}`;\n const treeDepth = options?.query_type === 'node_modules' ? 1 : 2;\n\n try {\n const entries = await provider.listDirectory({\n path: '.',\n maxResults: AGENT_CONFIG.MAX_OUTPUT_LINES,\n maxDepth: treeDepth,\n });\n const treeLines = entries.map((e) => {\n const indent = ' '.repeat(e.depth);\n const name = e.type === 'dir' ? `${e.name}/` : e.name;\n return `${indent}${name}`;\n });\n\n const repoName = path.basename(repoRoot);\n const treeOutput =\n treeLines.length > 0 ? `${repoName}/\\n${treeLines.join('\\n')}` : `${repoName}/`;\n\n return `<repo_structure>\\n${treeOutput}\\n</repo_structure>\\n\\n<search_string>\\n${query}\\n</search_string>\\n${budget}\\n${turnTag}`;\n } catch {\n const repoName = path.basename(repoRoot);\n return `<repo_structure>\\n${repoName}/\\n</repo_structure>\\n\\n<search_string>\\n${query}\\n</search_string>\\n${budget}\\n${turnTag}`;\n }\n}\n\n/**\n * Format directory entries as an indented tree string.\n */\nexport function formatListDirectoryTree(entries: ListDirectoryEntry[]): string {\n if (!entries.length) return 'empty';\n return entries\n .map((e) => {\n const indent = ' '.repeat(e.depth);\n const name = e.type === 'dir' ? `${e.name}/` : e.name;\n return `${indent}${name}`;\n })\n .join('\\n');\n}\n\n/**\n * Enforce hard context limit by truncating user messages.\n * Preserves system prompt, first user message (initial query), and all assistant messages.\n * Removes tool result user messages from oldest to newest until under the threshold.\n * \n * @param messages - The conversation messages array (mutated in place)\n * @param maxChars - Maximum total character count (defaults to AGENT_CONFIG.MAX_CONTEXT_CHARS)\n * @returns The same messages array, truncated if necessary\n */\nexport function enforceContextLimit(\n messages: ChatMessage[],\n maxChars: number = AGENT_CONFIG.MAX_CONTEXT_CHARS\n): ChatMessage[] {\n const getTotalChars = () => messages.reduce((sum, m) => sum + m.content.length, 0);\n \n if (getTotalChars() <= maxChars) {\n return messages;\n }\n\n // Find indices of user messages, skipping the first one (initial query with repo structure)\n // We truncate tool result messages from oldest to newest\n const userIndices: number[] = [];\n let firstUserSkipped = false;\n for (let i = 0; i < messages.length; i++) {\n if (messages[i].role === 'user') {\n if (!firstUserSkipped) {\n firstUserSkipped = true;\n continue; // Skip first user message (contains the search query)\n }\n userIndices.push(i);\n }\n }\n\n // Truncate user messages from oldest to newest until under limit\n for (const idx of userIndices) {\n if (getTotalChars() <= maxChars) {\n break;\n }\n // Only truncate if not already truncated\n if (messages[idx].content !== TRUNCATED_MARKER) {\n messages[idx] = { role: 'user', content: TRUNCATED_MARKER };\n }\n }\n\n return messages;\n}\n\n"],"mappings":";;;;;AAEA,eAAsB,SACpB,UACA,MAC6B;AAC7B,QAAM,MAAM,MAAM,SAAS,KAAK,IAAI;AAGpC,MAAI,IAAI,OAAO;AACb,WAAO,EAAE,QAAQ,IAAI,MAAM;AAAA,EAC7B;AAEA,MAAI,CAAC,IAAI,MAAM,QAAQ;AACrB,WAAO,EAAE,QAAQ,aAAa;AAAA,EAChC;AAEA,SAAO,EAAE,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE;AACxC;;;AChBA,SAAS,aAAa,OAAgB,KAAuB;AAC3D,SACE,OAAO,UAAU,YACjB,OAAO,QAAQ,YACf,OAAO,SAAS,KAAK,KACrB,OAAO,SAAS,GAAG,KACnB,QAAQ,KACR,OAAO;AAEX;AAEA,eAAsB,SACpB,UACA,MACiB;AACjB,MAAI,KAAK,SAAS,MAAM,QAAQ,KAAK,KAAK,KAAK,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AAAA,EACT;AAIA,QAAM,cAAwB,CAAC;AAC/B,MAAI,mBAAmB;AACvB,WAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACxC,QAAI,SAAS,CAAC,EAAE,SAAS,QAAQ;AAC/B,UAAI,CAAC,kBAAkB;AACrB,2BAAmB;AACnB;AAAA,MACF;AACA,kBAAY,KAAK,CAAC;AAAA,IACpB;AAAA,EACF;AAGA,aAAW,OAAO,aAAa;AAC7B,QAAI,cAAc,KAAK,UAAU;AAC/B;AAAA,IACF;AAEA,QAAI,SAAS,GAAG,EAAE,YAAY,kBAAkB;AAC9C,eAAS,GAAG,IAAI,EAAE,MAAM,QAAQ,SAAS,iBAAiB;AAAA,IAC5D;AAAA,EACF;AAEA,SAAO;AACT;","names":["res","isValidRange"]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-2HMEZZKK.js";
|
|
5
5
|
import {
|
|
6
6
|
executeBrowserTask
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NQQS5BZZ.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -93,4 +93,4 @@ export {
|
|
|
93
93
|
createBrowserTool,
|
|
94
94
|
openai_exports
|
|
95
95
|
};
|
|
96
|
-
//# sourceMappingURL=chunk-
|
|
96
|
+
//# sourceMappingURL=chunk-K6YSD3DR.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-2HMEZZKK.js";
|
|
5
5
|
import {
|
|
6
6
|
executeBrowserTask
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NQQS5BZZ.js";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-PZ5AY32C.js";
|
|
@@ -77,4 +77,4 @@ export {
|
|
|
77
77
|
createBrowserTool,
|
|
78
78
|
anthropic_exports
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-LX34ZO3N.js.map
|