@morphllm/morphsdk 0.2.121 → 0.2.123
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-L4PK4VC7.js → chunk-5OJE7GH4.js} +2 -2
- package/dist/chunk-63VHBANJ.js +22 -0
- package/dist/chunk-63VHBANJ.js.map +1 -0
- package/dist/{chunk-BDKXYMU2.js → chunk-ANPZFWYV.js} +2 -2
- package/dist/{chunk-DL3Y3R6A.js → chunk-BJ2764MK.js} +2 -2
- package/dist/{chunk-JBIFS33U.js → chunk-DBSOONOY.js} +2 -2
- package/dist/chunk-ETTCJWJK.js +113 -0
- package/dist/chunk-ETTCJWJK.js.map +1 -0
- package/dist/{chunk-EJYFE73S.js → chunk-FMKJ72KT.js} +3 -3
- package/dist/{chunk-EJYFE73S.js.map → chunk-FMKJ72KT.js.map} +1 -1
- package/dist/{chunk-7QZFNYOH.js → chunk-GXFJLL5O.js} +2 -2
- package/dist/chunk-H3U7J5RI.js +98 -0
- package/dist/chunk-H3U7J5RI.js.map +1 -0
- package/dist/{chunk-MAAULSSQ.js → chunk-HVBJ4UO6.js} +2 -2
- package/dist/{chunk-3HBZXN6E.js → chunk-K74GLGST.js} +2 -2
- package/dist/{chunk-EZFXR52Q.js → chunk-KL3AMLGL.js} +2 -2
- package/dist/{chunk-YMOTJ6ZP.js → chunk-L426IMZD.js} +2 -2
- package/dist/{chunk-C3BQUIFE.js → chunk-MXSGTN7R.js} +145 -9
- package/dist/chunk-MXSGTN7R.js.map +1 -0
- package/dist/{chunk-266SWRHK.js → chunk-OFJYDTQI.js} +2 -2
- package/dist/chunk-OTOVGCG6.js +42 -0
- package/dist/chunk-OTOVGCG6.js.map +1 -0
- package/dist/{chunk-W37KJB25.js → chunk-QD7KPI7A.js} +2 -2
- package/dist/chunk-QGRFAVGK.js +112 -0
- package/dist/chunk-QGRFAVGK.js.map +1 -0
- package/dist/{chunk-WEBUKGPK.js → chunk-UHL2ZEWG.js} +3 -3
- package/dist/{chunk-CIFPLFBQ.js → chunk-UJS3AIWS.js} +2 -2
- package/dist/{chunk-FV3R3JGV.js → chunk-UX65IRCX.js} +2 -2
- package/dist/{chunk-L5C6E32T.js → chunk-V3HLOZK2.js} +1 -1
- package/dist/{chunk-L5C6E32T.js.map → chunk-V3HLOZK2.js.map} +1 -1
- package/dist/{chunk-7IZUNRPZ.js → chunk-V4KBK66V.js} +54 -15
- package/dist/{chunk-7IZUNRPZ.js.map → chunk-V4KBK66V.js.map} +1 -1
- package/dist/{chunk-AI3ZCOCT.js → chunk-WE75QX2B.js} +1 -1
- package/dist/chunk-WYYR2EU6.js +29 -0
- package/dist/chunk-WYYR2EU6.js.map +1 -0
- package/dist/{chunk-GNRMDXJA.js → chunk-XXL62KSJ.js} +2 -2
- package/dist/{chunk-QDGB6FLI.js → chunk-ZZCMAFN7.js} +5 -5
- package/dist/chunk-ZZCMAFN7.js.map +1 -0
- package/dist/{client-Bp3MRcJc.d.ts → client-JHPwle1Z.d.ts} +46 -1
- package/dist/client.cjs +287 -12
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +23 -21
- package/dist/edge.cjs +2 -2
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +4 -4
- package/dist/index.cjs +287 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +24 -22
- 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/runner.cjs +5 -5
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +2 -2
- package/dist/tools/warp_grep/anthropic.cjs +476 -5
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +62 -2
- package/dist/tools/warp_grep/anthropic.js +11 -5
- package/dist/tools/warp_grep/client.cjs +187 -12
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +58 -2
- package/dist/tools/warp_grep/client.js +9 -3
- package/dist/tools/warp_grep/gemini.cjs +475 -5
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +62 -2
- package/dist/tools/warp_grep/gemini.js +69 -4
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/index.cjs +228 -12
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +52 -3
- package/dist/tools/warp_grep/index.js +26 -5
- package/dist/tools/warp_grep/openai.cjs +482 -5
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +62 -2
- package/dist/tools/warp_grep/openai.js +11 -5
- package/dist/tools/warp_grep/providers/code_storage_http.cjs +53 -0
- package/dist/tools/warp_grep/providers/code_storage_http.cjs.map +1 -0
- package/dist/tools/warp_grep/providers/code_storage_http.d.ts +23 -0
- package/dist/tools/warp_grep/providers/code_storage_http.js +8 -0
- package/dist/tools/warp_grep/providers/code_storage_http.js.map +1 -0
- package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
- package/dist/tools/warp_grep/utils/github.cjs +46 -0
- package/dist/tools/warp_grep/utils/github.cjs.map +1 -0
- package/dist/tools/warp_grep/utils/github.d.ts +13 -0
- package/dist/tools/warp_grep/utils/github.js +8 -0
- package/dist/tools/warp_grep/utils/github.js.map +1 -0
- package/dist/tools/warp_grep/vercel.cjs +245 -5
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +60 -2
- package/dist/tools/warp_grep/vercel.js +11 -5
- package/dist/{types-D5p8QErL.d.ts → types-DY_hq2eZ.d.ts} +53 -1
- 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-C3BQUIFE.js.map +0 -1
- package/dist/chunk-CXP63PHW.js +0 -61
- package/dist/chunk-CXP63PHW.js.map +0 -1
- package/dist/chunk-KW7OEGZK.js +0 -9
- package/dist/chunk-KW7OEGZK.js.map +0 -1
- package/dist/chunk-QDGB6FLI.js.map +0 -1
- package/dist/chunk-U5UDFQXK.js +0 -66
- package/dist/chunk-U5UDFQXK.js.map +0 -1
- package/dist/chunk-XERAWJ3H.js +0 -53
- package/dist/chunk-XERAWJ3H.js.map +0 -1
- /package/dist/{chunk-L4PK4VC7.js.map → chunk-5OJE7GH4.js.map} +0 -0
- /package/dist/{chunk-BDKXYMU2.js.map → chunk-ANPZFWYV.js.map} +0 -0
- /package/dist/{chunk-DL3Y3R6A.js.map → chunk-BJ2764MK.js.map} +0 -0
- /package/dist/{chunk-JBIFS33U.js.map → chunk-DBSOONOY.js.map} +0 -0
- /package/dist/{chunk-7QZFNYOH.js.map → chunk-GXFJLL5O.js.map} +0 -0
- /package/dist/{chunk-MAAULSSQ.js.map → chunk-HVBJ4UO6.js.map} +0 -0
- /package/dist/{chunk-3HBZXN6E.js.map → chunk-K74GLGST.js.map} +0 -0
- /package/dist/{chunk-EZFXR52Q.js.map → chunk-KL3AMLGL.js.map} +0 -0
- /package/dist/{chunk-YMOTJ6ZP.js.map → chunk-L426IMZD.js.map} +0 -0
- /package/dist/{chunk-266SWRHK.js.map → chunk-OFJYDTQI.js.map} +0 -0
- /package/dist/{chunk-W37KJB25.js.map → chunk-QD7KPI7A.js.map} +0 -0
- /package/dist/{chunk-WEBUKGPK.js.map → chunk-UHL2ZEWG.js.map} +0 -0
- /package/dist/{chunk-CIFPLFBQ.js.map → chunk-UJS3AIWS.js.map} +0 -0
- /package/dist/{chunk-FV3R3JGV.js.map → chunk-UX65IRCX.js.map} +0 -0
- /package/dist/{chunk-AI3ZCOCT.js.map → chunk-WE75QX2B.js.map} +0 -0
- /package/dist/{chunk-GNRMDXJA.js.map → chunk-XXL62KSJ.js.map} +0 -0
|
@@ -8,7 +8,7 @@ import { CompactClient } from './tools/compact/core.js';
|
|
|
8
8
|
import { OpenAIRouter, AnthropicRouter, GeminiRouter, RawRouter } from './modelrouter/core.js';
|
|
9
9
|
import { EditFileConfig, EditFileInput, EditFileResult, EditChanges } from './tools/fastapply/types.js';
|
|
10
10
|
import { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './tools/codebase_search/types.js';
|
|
11
|
-
import { d as WarpGrepToolConfig, b as WarpGrepResult, c as WarpGrepContext } from './types-
|
|
11
|
+
import { d as WarpGrepToolConfig, b as WarpGrepResult, g as GitHubSearchToolConfig, c as WarpGrepContext } from './types-DY_hq2eZ.js';
|
|
12
12
|
import * as openai_resources_index_mjs from 'openai/resources/index.mjs';
|
|
13
13
|
import * as _anthropic_ai_sdk_resources_messages_mjs from '@anthropic-ai/sdk/resources/messages.mjs';
|
|
14
14
|
import * as ai from 'ai';
|
|
@@ -666,6 +666,21 @@ declare class OpenAIToolFactory {
|
|
|
666
666
|
formatResult: (result: EditFileResult) => string;
|
|
667
667
|
getSystemPrompt: () => string;
|
|
668
668
|
};
|
|
669
|
+
/**
|
|
670
|
+
* Create an OpenAI-compatible GitHub search tool
|
|
671
|
+
*
|
|
672
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
673
|
+
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
674
|
+
*/
|
|
675
|
+
createGitHubSearchTool(toolConfig?: Omit<GitHubSearchToolConfig, 'morphApiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
|
|
676
|
+
execute: (input: {
|
|
677
|
+
query: string;
|
|
678
|
+
github: string;
|
|
679
|
+
branch?: string;
|
|
680
|
+
}) => Promise<WarpGrepResult>;
|
|
681
|
+
formatResult: (result: WarpGrepResult) => string;
|
|
682
|
+
getSystemPrompt: () => string;
|
|
683
|
+
};
|
|
669
684
|
}
|
|
670
685
|
|
|
671
686
|
/**
|
|
@@ -723,6 +738,21 @@ declare class AnthropicToolFactory {
|
|
|
723
738
|
formatResult: (result: EditFileResult) => string;
|
|
724
739
|
getSystemPrompt: () => string;
|
|
725
740
|
};
|
|
741
|
+
/**
|
|
742
|
+
* Create an Anthropic-compatible GitHub search tool
|
|
743
|
+
*
|
|
744
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
745
|
+
* @returns Anthropic Tool with execute and formatResult methods
|
|
746
|
+
*/
|
|
747
|
+
createGitHubSearchTool(toolConfig?: Omit<GitHubSearchToolConfig, 'morphApiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
|
|
748
|
+
execute: (input: {
|
|
749
|
+
query: string;
|
|
750
|
+
github: string;
|
|
751
|
+
branch?: string;
|
|
752
|
+
}) => Promise<WarpGrepResult>;
|
|
753
|
+
formatResult: (result: WarpGrepResult) => string;
|
|
754
|
+
getSystemPrompt: () => string;
|
|
755
|
+
};
|
|
726
756
|
}
|
|
727
757
|
|
|
728
758
|
/**
|
|
@@ -810,6 +840,21 @@ declare class VercelToolFactory {
|
|
|
810
840
|
changes: EditChanges;
|
|
811
841
|
udiff: string | undefined;
|
|
812
842
|
}>;
|
|
843
|
+
/**
|
|
844
|
+
* Create a Vercel AI SDK-compatible GitHub search tool
|
|
845
|
+
*
|
|
846
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
847
|
+
* @returns Vercel AI SDK tool
|
|
848
|
+
*/
|
|
849
|
+
createGitHubSearchTool(toolConfig?: Omit<GitHubSearchToolConfig, 'morphApiKey'>): ai.Tool<{
|
|
850
|
+
query: string;
|
|
851
|
+
github: string;
|
|
852
|
+
branch?: string | undefined;
|
|
853
|
+
}, {
|
|
854
|
+
success: boolean;
|
|
855
|
+
contexts: WarpGrepContext[] | undefined;
|
|
856
|
+
summary: string | undefined;
|
|
857
|
+
}>;
|
|
813
858
|
}
|
|
814
859
|
|
|
815
860
|
/**
|
package/dist/client.cjs
CHANGED
|
@@ -36,7 +36,7 @@ var init_package = __esm({
|
|
|
36
36
|
"package.json"() {
|
|
37
37
|
package_default = {
|
|
38
38
|
name: "@morphllm/morphsdk",
|
|
39
|
-
version: "0.2.
|
|
39
|
+
version: "0.2.123",
|
|
40
40
|
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
41
41
|
type: "module",
|
|
42
42
|
main: "./dist/index.cjs",
|
|
@@ -178,7 +178,7 @@ var init_package = __esm({
|
|
|
178
178
|
"!dist/**/*.test.*"
|
|
179
179
|
],
|
|
180
180
|
scripts: {
|
|
181
|
-
build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/prompt.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
181
|
+
build: "tsup version.ts index.ts edge.ts client.ts tools/index.ts tools/fastapply/index.ts tools/fastapply/core.ts tools/fastapply/apply.ts tools/fastapply/types.ts tools/fastapply/prompts.ts tools/fastapply/anthropic.ts tools/fastapply/openai.ts tools/fastapply/vercel.ts tools/codebase_search/index.ts tools/codebase_search/core.ts tools/codebase_search/types.ts tools/codebase_search/prompts.ts tools/codebase_search/anthropic.ts tools/codebase_search/openai.ts tools/codebase_search/vercel.ts tools/warp_grep/index.ts tools/warp_grep/client.ts tools/warp_grep/openai.ts tools/warp_grep/anthropic.ts tools/warp_grep/vercel.ts tools/warp_grep/gemini.ts tools/warp_grep/harness.ts tools/warp_grep/agent/config.ts tools/warp_grep/agent/prompt.ts tools/warp_grep/agent/parser.ts tools/warp_grep/agent/runner.ts tools/warp_grep/agent/types.ts tools/warp_grep/agent/formatter.ts tools/warp_grep/providers/types.ts tools/warp_grep/providers/local.ts tools/warp_grep/providers/remote.ts tools/warp_grep/providers/code_storage_http.ts tools/warp_grep/tools/grep.ts tools/warp_grep/tools/analyse.ts tools/warp_grep/tools/read.ts tools/warp_grep/tools/finish.ts tools/warp_grep/utils/paths.ts tools/warp_grep/utils/github.ts tools/warp_grep/utils/ripgrep.ts tools/warp_grep/utils/format.ts tools/warp_grep/utils/files.ts git/index.ts git/client.ts git/config.ts git/types.ts tools/browser/index.ts tools/browser/core.ts tools/browser/types.ts tools/browser/prompts.ts tools/browser/anthropic.ts tools/browser/openai.ts tools/browser/vercel.ts tools/browser/live.ts tools/browser/errors.ts tools/browser/profiles/index.ts tools/browser/profiles/core.ts tools/browser/profiles/types.ts modelrouter/index.ts modelrouter/core.ts modelrouter/types.ts tools/compact/index.ts tools/compact/core.ts tools/compact/types.ts tools/utils/resilience.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve",
|
|
182
182
|
prepare: "npm run build",
|
|
183
183
|
typecheck: "tsc --noEmit",
|
|
184
184
|
lint: "eslint .",
|
|
@@ -3287,9 +3287,9 @@ async function callModel(messages, model, options = {}) {
|
|
|
3287
3287
|
});
|
|
3288
3288
|
} catch (error) {
|
|
3289
3289
|
if (error instanceof import_openai2.default.APIError && error.status === 404) {
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
);
|
|
3290
|
+
const defaultMsg = "The endpoint you are trying to call is likely deprecated. Please update with: npm cache clean --force && npx -y @morphllm/morphmcp@latest or visit: https://morphllm.com/mcp";
|
|
3291
|
+
const errorText = error.message?.trim();
|
|
3292
|
+
throw new Error(errorText || defaultMsg);
|
|
3293
3293
|
}
|
|
3294
3294
|
throw error;
|
|
3295
3295
|
}
|
|
@@ -3817,7 +3817,51 @@ var RemoteCommandsProvider = class {
|
|
|
3817
3817
|
}
|
|
3818
3818
|
};
|
|
3819
3819
|
|
|
3820
|
+
// tools/warp_grep/providers/code_storage_http.ts
|
|
3821
|
+
async function post(url, body, op) {
|
|
3822
|
+
const res = await fetch(url, {
|
|
3823
|
+
method: "POST",
|
|
3824
|
+
headers: { "Content-Type": "application/json" },
|
|
3825
|
+
body: JSON.stringify(body)
|
|
3826
|
+
});
|
|
3827
|
+
if (!res.ok) {
|
|
3828
|
+
const text = await res.text().catch(() => res.statusText);
|
|
3829
|
+
throw new Error(`${op} failed (${res.status}): ${text}`);
|
|
3830
|
+
}
|
|
3831
|
+
const data = await res.json();
|
|
3832
|
+
if (data.error) throw new Error(data.error);
|
|
3833
|
+
return data.stdout;
|
|
3834
|
+
}
|
|
3835
|
+
function createCodeStorageHttpCommands(config) {
|
|
3836
|
+
const { baseUrl, repoId, branch } = config;
|
|
3837
|
+
const encodedRepoId = encodeURIComponent(repoId);
|
|
3838
|
+
return {
|
|
3839
|
+
grep: (pattern, path5, glob) => post(`${baseUrl}/api/code-search/${encodedRepoId}/grep`, { pattern, path: path5, glob, branch }, "grep"),
|
|
3840
|
+
read: (path5, start, end) => post(`${baseUrl}/api/code-search/${encodedRepoId}/read`, { path: path5, start, end, branch }, "read"),
|
|
3841
|
+
listDir: (path5, maxDepth) => post(`${baseUrl}/api/code-search/${encodedRepoId}/list`, { path: path5, maxDepth, branch }, "list")
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
// tools/warp_grep/utils/github.ts
|
|
3846
|
+
function parseGitHubUrl(input) {
|
|
3847
|
+
input = input.trim();
|
|
3848
|
+
const urlPattern = /^(?:https?:\/\/)?github\.com\/([^\/]+)\/([^\/\?\#]+)/;
|
|
3849
|
+
const match = input.match(urlPattern);
|
|
3850
|
+
if (match) {
|
|
3851
|
+
return { owner: match[1], repo: match[2].replace(/\.git$/, "") };
|
|
3852
|
+
}
|
|
3853
|
+
const shortPattern = /^([^\/]+)\/([^\/]+)$/;
|
|
3854
|
+
const shortMatch = input.match(shortPattern);
|
|
3855
|
+
if (shortMatch && !shortMatch[1].includes(".")) {
|
|
3856
|
+
return { owner: shortMatch[1], repo: shortMatch[2].replace(/\.git$/, "") };
|
|
3857
|
+
}
|
|
3858
|
+
throw new Error(
|
|
3859
|
+
`Invalid GitHub URL or shorthand: "${input}". Expected "owner/repo" or "https://github.com/owner/repo"`
|
|
3860
|
+
);
|
|
3861
|
+
}
|
|
3862
|
+
|
|
3820
3863
|
// tools/warp_grep/client.ts
|
|
3864
|
+
var DEFAULT_CODE_SEARCH_URL = "https://morphllm.com";
|
|
3821
3865
|
async function getLocalProvider(repoRoot, excludes) {
|
|
3822
3866
|
const { LocalRipgrepProvider: LocalRipgrepProvider2 } = await Promise.resolve().then(() => (init_local(), local_exports));
|
|
3823
3867
|
return new LocalRipgrepProvider2(repoRoot, excludes);
|
|
@@ -3825,13 +3869,7 @@ async function getLocalProvider(repoRoot, excludes) {
|
|
|
3825
3869
|
var WarpGrepClient = class {
|
|
3826
3870
|
config;
|
|
3827
3871
|
constructor(config = {}) {
|
|
3828
|
-
this.config = {
|
|
3829
|
-
morphApiKey: config.morphApiKey,
|
|
3830
|
-
morphApiUrl: config.morphApiUrl,
|
|
3831
|
-
debug: config.debug,
|
|
3832
|
-
timeout: config.timeout,
|
|
3833
|
-
retryConfig: config.retryConfig
|
|
3834
|
-
};
|
|
3872
|
+
this.config = { ...config };
|
|
3835
3873
|
}
|
|
3836
3874
|
execute(input) {
|
|
3837
3875
|
const toolConfig = {
|
|
@@ -3851,6 +3889,80 @@ var WarpGrepClient = class {
|
|
|
3851
3889
|
}
|
|
3852
3890
|
return executeToolCall({ query: input.query }, toolConfig);
|
|
3853
3891
|
}
|
|
3892
|
+
searchGitHub(input) {
|
|
3893
|
+
if (input.streamSteps) {
|
|
3894
|
+
return this._searchGitHubStreaming(input);
|
|
3895
|
+
}
|
|
3896
|
+
return this._searchGitHubAsync(input);
|
|
3897
|
+
}
|
|
3898
|
+
/**
|
|
3899
|
+
* Read a single file from a public GitHub repository
|
|
3900
|
+
*
|
|
3901
|
+
* @example
|
|
3902
|
+
* ```typescript
|
|
3903
|
+
* const result = await client.readGitHubFile({
|
|
3904
|
+
* github: 'vercel/next.js',
|
|
3905
|
+
* path: 'src/server/app-render/index.tsx',
|
|
3906
|
+
* startLine: 1,
|
|
3907
|
+
* endLine: 50,
|
|
3908
|
+
* });
|
|
3909
|
+
* if (result.success) console.log(result.content);
|
|
3910
|
+
* ```
|
|
3911
|
+
*/
|
|
3912
|
+
async readGitHubFile(input) {
|
|
3913
|
+
return executeGitHubReadFile(input, { timeout: this.config.timeout });
|
|
3914
|
+
}
|
|
3915
|
+
async _resolveGitHubRepo(input) {
|
|
3916
|
+
const { owner, repo } = parseGitHubUrl(input.github);
|
|
3917
|
+
const baseUrl = this.config.codeSearchUrl || DEFAULT_CODE_SEARCH_URL;
|
|
3918
|
+
const importRes = await fetch(`${baseUrl}/api/code-search/get-or-create?url=${encodeURIComponent(`${owner}/${repo}`)}`);
|
|
3919
|
+
if (!importRes.ok) {
|
|
3920
|
+
const text = await importRes.text().catch(() => importRes.statusText);
|
|
3921
|
+
throw new Error(`Failed to import repo ${owner}/${repo}: ${text}`);
|
|
3922
|
+
}
|
|
3923
|
+
const { repoId, defaultBranch } = await importRes.json();
|
|
3924
|
+
return {
|
|
3925
|
+
repo,
|
|
3926
|
+
remoteCommands: createCodeStorageHttpCommands({ baseUrl, repoId, branch: input.branch || defaultBranch })
|
|
3927
|
+
};
|
|
3928
|
+
}
|
|
3929
|
+
async _searchGitHubAsync(input) {
|
|
3930
|
+
try {
|
|
3931
|
+
const { repo, remoteCommands } = await this._resolveGitHubRepo(input);
|
|
3932
|
+
return this.execute({
|
|
3933
|
+
query: input.query,
|
|
3934
|
+
repoRoot: repo,
|
|
3935
|
+
remoteCommands
|
|
3936
|
+
});
|
|
3937
|
+
} catch (error) {
|
|
3938
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
async *_searchGitHubStreaming(input) {
|
|
3942
|
+
let repo;
|
|
3943
|
+
let remoteCommands;
|
|
3944
|
+
try {
|
|
3945
|
+
({ repo, remoteCommands } = await this._resolveGitHubRepo(input));
|
|
3946
|
+
} catch (error) {
|
|
3947
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
3948
|
+
}
|
|
3949
|
+
const generator = this.execute({
|
|
3950
|
+
query: input.query,
|
|
3951
|
+
repoRoot: repo,
|
|
3952
|
+
remoteCommands,
|
|
3953
|
+
streamSteps: true
|
|
3954
|
+
});
|
|
3955
|
+
let result;
|
|
3956
|
+
for (; ; ) {
|
|
3957
|
+
const { value, done } = await generator.next();
|
|
3958
|
+
if (done) {
|
|
3959
|
+
result = value;
|
|
3960
|
+
break;
|
|
3961
|
+
}
|
|
3962
|
+
yield value;
|
|
3963
|
+
}
|
|
3964
|
+
return result;
|
|
3965
|
+
}
|
|
3854
3966
|
};
|
|
3855
3967
|
async function executeToolCall(input, config) {
|
|
3856
3968
|
const parsed = typeof input === "string" ? JSON.parse(input) : input;
|
|
@@ -3920,6 +4032,56 @@ async function* executeToolCallStreaming(input, config) {
|
|
|
3920
4032
|
}
|
|
3921
4033
|
return processAgentResult(agentResult);
|
|
3922
4034
|
}
|
|
4035
|
+
async function fetchRawGitHubFile(owner, repo, filePath, branch, timeout) {
|
|
4036
|
+
const branches = branch ? [branch] : ["HEAD"];
|
|
4037
|
+
const fallbacks = ["main", "master", "develop"];
|
|
4038
|
+
const fetchWithTimeout = (url) => timeout ? fetch(url, { signal: AbortSignal.timeout(timeout) }) : fetch(url);
|
|
4039
|
+
for (const b of branches) {
|
|
4040
|
+
const url = `https://raw.githubusercontent.com/${owner}/${repo}/${b}/${filePath}`;
|
|
4041
|
+
const res = await fetchWithTimeout(url);
|
|
4042
|
+
if (res.ok) return { content: await res.text(), branch: b };
|
|
4043
|
+
}
|
|
4044
|
+
for (const fb of fallbacks) {
|
|
4045
|
+
if (branch && fb === branch) continue;
|
|
4046
|
+
const url = `https://raw.githubusercontent.com/${owner}/${repo}/${fb}/${filePath}`;
|
|
4047
|
+
const res = await fetchWithTimeout(url);
|
|
4048
|
+
if (res.ok) return { content: await res.text(), branch: fb };
|
|
4049
|
+
}
|
|
4050
|
+
throw new Error(`File not found: ${owner}/${repo}/${filePath}`);
|
|
4051
|
+
}
|
|
4052
|
+
async function executeGitHubReadFile(input, config) {
|
|
4053
|
+
try {
|
|
4054
|
+
const { owner, repo } = parseGitHubUrl(input.github);
|
|
4055
|
+
const { content: raw, branch } = await fetchRawGitHubFile(
|
|
4056
|
+
owner,
|
|
4057
|
+
repo,
|
|
4058
|
+
input.path,
|
|
4059
|
+
input.branch,
|
|
4060
|
+
config?.timeout
|
|
4061
|
+
);
|
|
4062
|
+
const allLines = raw.split("\n");
|
|
4063
|
+
const totalLines = allLines.length;
|
|
4064
|
+
const start = Math.max(1, input.startLine ?? 1);
|
|
4065
|
+
const end = Math.min(totalLines, input.endLine ?? totalLines);
|
|
4066
|
+
const selected = allLines.slice(start - 1, end);
|
|
4067
|
+
const padWidth = String(end).length;
|
|
4068
|
+
const numbered = selected.map((line, i) => `${String(start + i).padStart(padWidth)}|${line}`).join("\n");
|
|
4069
|
+
return {
|
|
4070
|
+
success: true,
|
|
4071
|
+
content: numbered,
|
|
4072
|
+
path: input.path,
|
|
4073
|
+
github: `${owner}/${repo}`,
|
|
4074
|
+
branch,
|
|
4075
|
+
lineRange: [start, end],
|
|
4076
|
+
totalLines
|
|
4077
|
+
};
|
|
4078
|
+
} catch (error) {
|
|
4079
|
+
return {
|
|
4080
|
+
success: false,
|
|
4081
|
+
error: error instanceof Error ? error.message : String(error)
|
|
4082
|
+
};
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
3923
4085
|
function formatResult(result) {
|
|
3924
4086
|
if (!result.success) {
|
|
3925
4087
|
return `Search failed: ${result.error}`;
|
|
@@ -5114,6 +5276,20 @@ var RawRouter = class extends BaseRouter {
|
|
|
5114
5276
|
// tools/warp_grep/prompts.ts
|
|
5115
5277
|
var WARP_GREP_TOOL_NAME = "warpgrep_codebase_search";
|
|
5116
5278
|
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.';
|
|
5279
|
+
var GITHUB_WARP_GREP_SEARCH_TOOL_NAME = "warpgrep_github_search";
|
|
5280
|
+
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. When the task requires understanding code in an external repo, invoke warpgrep_github_search with a GitHub URL or owner/repo shorthand (e.g., vercel/next.js) and a natural-language query describing the target functionality, bug, or architectural concern. 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.';
|
|
5281
|
+
var GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA = {
|
|
5282
|
+
type: "object",
|
|
5283
|
+
properties: {
|
|
5284
|
+
query: { type: "string", description: "Natural language search query describing what to find in the repository" },
|
|
5285
|
+
github: { type: "string", description: 'owner/repo shorthand (ex: "vercel/next.js" for "https://github.com/vercel/next.js")' },
|
|
5286
|
+
branch: { type: "string", description: "Branch to search (defaults to the repository default branch)" }
|
|
5287
|
+
},
|
|
5288
|
+
required: ["query", "github"]
|
|
5289
|
+
};
|
|
5290
|
+
var GITHUB_SEARCH_TOOL_NAME = GITHUB_WARP_GREP_SEARCH_TOOL_NAME;
|
|
5291
|
+
var GITHUB_SEARCH_DESCRIPTION = GITHUB_WARP_GREP_SEARCH_DESCRIPTION;
|
|
5292
|
+
var GITHUB_SEARCH_INPUT_SCHEMA = GITHUB_WARP_GREP_SEARCH_INPUT_SCHEMA;
|
|
5117
5293
|
|
|
5118
5294
|
// tools/warp_grep/openai.ts
|
|
5119
5295
|
var TOOL_PARAMETERS = {
|
|
@@ -5144,6 +5320,28 @@ function createWarpGrepTool(config) {
|
|
|
5144
5320
|
}
|
|
5145
5321
|
});
|
|
5146
5322
|
}
|
|
5323
|
+
function createGitHubSearchTool(config) {
|
|
5324
|
+
const client = new WarpGrepClient(config);
|
|
5325
|
+
const tool4 = {
|
|
5326
|
+
type: "function",
|
|
5327
|
+
function: {
|
|
5328
|
+
name: GITHUB_SEARCH_TOOL_NAME,
|
|
5329
|
+
description: GITHUB_SEARCH_DESCRIPTION,
|
|
5330
|
+
parameters: GITHUB_SEARCH_INPUT_SCHEMA
|
|
5331
|
+
}
|
|
5332
|
+
};
|
|
5333
|
+
return Object.assign(tool4, {
|
|
5334
|
+
execute: async (input) => {
|
|
5335
|
+
return client.searchGitHub(input);
|
|
5336
|
+
},
|
|
5337
|
+
formatResult: (result) => {
|
|
5338
|
+
return formatResult(result);
|
|
5339
|
+
},
|
|
5340
|
+
getSystemPrompt: () => {
|
|
5341
|
+
return getSystemPrompt();
|
|
5342
|
+
}
|
|
5343
|
+
});
|
|
5344
|
+
}
|
|
5147
5345
|
|
|
5148
5346
|
// tools/codebase_search/prompts.ts
|
|
5149
5347
|
var CODEBASE_SEARCH_DESCRIPTION = `Semantic search that finds code by meaning, not exact text.
|
|
@@ -5388,6 +5586,18 @@ var OpenAIToolFactory = class {
|
|
|
5388
5586
|
morphApiKey: this.config.apiKey
|
|
5389
5587
|
});
|
|
5390
5588
|
}
|
|
5589
|
+
/**
|
|
5590
|
+
* Create an OpenAI-compatible GitHub search tool
|
|
5591
|
+
*
|
|
5592
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
5593
|
+
* @returns OpenAI ChatCompletionTool with execute and formatResult methods
|
|
5594
|
+
*/
|
|
5595
|
+
createGitHubSearchTool(toolConfig) {
|
|
5596
|
+
return createGitHubSearchTool({
|
|
5597
|
+
...toolConfig,
|
|
5598
|
+
morphApiKey: this.config.apiKey
|
|
5599
|
+
});
|
|
5600
|
+
}
|
|
5391
5601
|
};
|
|
5392
5602
|
|
|
5393
5603
|
// tools/warp_grep/anthropic.ts
|
|
@@ -5416,6 +5626,25 @@ function createWarpGrepTool2(config) {
|
|
|
5416
5626
|
}
|
|
5417
5627
|
});
|
|
5418
5628
|
}
|
|
5629
|
+
function createGitHubSearchTool2(config) {
|
|
5630
|
+
const client = new WarpGrepClient(config);
|
|
5631
|
+
const tool4 = {
|
|
5632
|
+
name: GITHUB_SEARCH_TOOL_NAME,
|
|
5633
|
+
description: GITHUB_SEARCH_DESCRIPTION,
|
|
5634
|
+
input_schema: GITHUB_SEARCH_INPUT_SCHEMA
|
|
5635
|
+
};
|
|
5636
|
+
return Object.assign(tool4, {
|
|
5637
|
+
execute: async (input) => {
|
|
5638
|
+
return client.searchGitHub(input);
|
|
5639
|
+
},
|
|
5640
|
+
formatResult: (result) => {
|
|
5641
|
+
return formatResult(result);
|
|
5642
|
+
},
|
|
5643
|
+
getSystemPrompt: () => {
|
|
5644
|
+
return getSystemPrompt();
|
|
5645
|
+
}
|
|
5646
|
+
});
|
|
5647
|
+
}
|
|
5419
5648
|
|
|
5420
5649
|
// tools/codebase_search/anthropic.ts
|
|
5421
5650
|
function createCodebaseSearchTool2(config) {
|
|
@@ -5577,6 +5806,18 @@ var AnthropicToolFactory = class {
|
|
|
5577
5806
|
morphApiKey: this.config.apiKey
|
|
5578
5807
|
});
|
|
5579
5808
|
}
|
|
5809
|
+
/**
|
|
5810
|
+
* Create an Anthropic-compatible GitHub search tool
|
|
5811
|
+
*
|
|
5812
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
5813
|
+
* @returns Anthropic Tool with execute and formatResult methods
|
|
5814
|
+
*/
|
|
5815
|
+
createGitHubSearchTool(toolConfig) {
|
|
5816
|
+
return createGitHubSearchTool2({
|
|
5817
|
+
...toolConfig,
|
|
5818
|
+
morphApiKey: this.config.apiKey
|
|
5819
|
+
});
|
|
5820
|
+
}
|
|
5580
5821
|
};
|
|
5581
5822
|
|
|
5582
5823
|
// tools/warp_grep/vercel.ts
|
|
@@ -5614,6 +5855,28 @@ function createWarpGrepTool3(config) {
|
|
|
5614
5855
|
}
|
|
5615
5856
|
});
|
|
5616
5857
|
}
|
|
5858
|
+
function createGitHubSearchTool3(config) {
|
|
5859
|
+
const client = new WarpGrepClient(config);
|
|
5860
|
+
return (0, import_ai.tool)({
|
|
5861
|
+
description: GITHUB_SEARCH_DESCRIPTION,
|
|
5862
|
+
inputSchema: import_zod.z.object({
|
|
5863
|
+
query: import_zod.z.string().describe("Natural language search query"),
|
|
5864
|
+
github: import_zod.z.string().describe('GitHub URL or "owner/repo" shorthand'),
|
|
5865
|
+
branch: import_zod.z.string().optional().describe("Branch to search (defaults to repo default branch)")
|
|
5866
|
+
}),
|
|
5867
|
+
execute: async (params) => {
|
|
5868
|
+
const result = await client.searchGitHub(params);
|
|
5869
|
+
if (!result.success) {
|
|
5870
|
+
throw new Error(`GitHub search failed: ${result.error}`);
|
|
5871
|
+
}
|
|
5872
|
+
return {
|
|
5873
|
+
success: true,
|
|
5874
|
+
contexts: result.contexts,
|
|
5875
|
+
summary: result.summary
|
|
5876
|
+
};
|
|
5877
|
+
}
|
|
5878
|
+
});
|
|
5879
|
+
}
|
|
5617
5880
|
|
|
5618
5881
|
// tools/codebase_search/vercel.ts
|
|
5619
5882
|
var import_ai2 = require("ai");
|
|
@@ -5756,6 +6019,18 @@ var VercelToolFactory = class {
|
|
|
5756
6019
|
morphApiKey: this.config.apiKey
|
|
5757
6020
|
});
|
|
5758
6021
|
}
|
|
6022
|
+
/**
|
|
6023
|
+
* Create a Vercel AI SDK-compatible GitHub search tool
|
|
6024
|
+
*
|
|
6025
|
+
* @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
|
|
6026
|
+
* @returns Vercel AI SDK tool
|
|
6027
|
+
*/
|
|
6028
|
+
createGitHubSearchTool(toolConfig) {
|
|
6029
|
+
return createGitHubSearchTool3({
|
|
6030
|
+
...toolConfig,
|
|
6031
|
+
morphApiKey: this.config.apiKey
|
|
6032
|
+
});
|
|
6033
|
+
}
|
|
5759
6034
|
};
|
|
5760
6035
|
|
|
5761
6036
|
// client.ts
|