@morphllm/morphsdk 0.2.93 → 0.2.95
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-2AMEQAO2.js +46 -0
- package/dist/chunk-2AMEQAO2.js.map +1 -0
- package/dist/{chunk-EI4UKP24.js → chunk-2HMEZZKK.js} +2 -2
- package/dist/{chunk-EI4UKP24.js.map → chunk-2HMEZZKK.js.map} +1 -1
- package/dist/chunk-2VERUKO2.js +177 -0
- package/dist/chunk-2VERUKO2.js.map +1 -0
- package/dist/{chunk-VHOWYK66.js → chunk-43LQLGP6.js} +23 -33
- package/dist/chunk-43LQLGP6.js.map +1 -0
- package/dist/{chunk-LMUZ3NGC.js → chunk-73RV6EXR.js} +2 -2
- package/dist/{chunk-PBLPZ6AU.js → chunk-7D6TXC7X.js} +2 -2
- package/dist/{chunk-GU6DACME.js → chunk-O7LDZA52.js} +2 -2
- package/dist/{chunk-5QIWYEHJ.js → chunk-PE4KGDA6.js} +1 -8
- package/dist/chunk-PE4KGDA6.js.map +1 -0
- package/dist/{chunk-SQN4DUQS.js → chunk-Q6Y4R236.js} +26 -2
- package/dist/chunk-Q6Y4R236.js.map +1 -0
- package/dist/{chunk-PUGIOVSP.js → chunk-QAT5UVPX.js} +2 -2
- package/dist/{chunk-MIIJWDOQ.js → chunk-QJP62BXH.js} +166 -71
- package/dist/chunk-QJP62BXH.js.map +1 -0
- package/dist/{chunk-EYGBUH2R.js → chunk-R7IQWNSA.js} +8 -8
- package/dist/chunk-R7IQWNSA.js.map +1 -0
- package/dist/chunk-SI2CKRKJ.js +389 -0
- package/dist/chunk-SI2CKRKJ.js.map +1 -0
- package/dist/{chunk-4WLGDYWQ.js → chunk-TSENDJQI.js} +6 -6
- package/dist/chunk-TSENDJQI.js.map +1 -0
- package/dist/{chunk-IUG2FHNN.js → chunk-XH7P7HVT.js} +1 -8
- package/dist/chunk-XH7P7HVT.js.map +1 -0
- package/dist/{chunk-FNLNDMIX.js → chunk-YZ5NCWO2.js} +6 -6
- package/dist/chunk-YZ5NCWO2.js.map +1 -0
- package/dist/{chunk-IJ54DTJ3.js → chunk-ZYTAKEBW.js} +13 -13
- package/dist/client.cjs +770 -110
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.js +16 -13
- package/dist/index.cjs +770 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -13
- package/dist/tools/browser/anthropic.cjs +58 -23
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +7 -4
- package/dist/tools/browser/core.cjs +750 -70
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.d.ts +30 -24
- package/dist/tools/browser/core.js +5 -2
- package/dist/tools/browser/errors.cjs +208 -0
- package/dist/tools/browser/errors.cjs.map +1 -0
- package/dist/tools/browser/errors.d.ts +158 -0
- package/dist/tools/browser/errors.js +22 -0
- package/dist/tools/browser/errors.js.map +1 -0
- package/dist/tools/browser/index.cjs +783 -85
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.d.ts +5 -2
- package/dist/tools/browser/index.js +32 -9
- package/dist/tools/browser/index.js.map +1 -1
- package/dist/tools/browser/live.cjs +25 -1
- package/dist/tools/browser/live.cjs.map +1 -1
- package/dist/tools/browser/live.js +1 -1
- package/dist/tools/browser/openai.cjs +58 -23
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +7 -4
- package/dist/tools/browser/profiles/core.cjs +670 -0
- package/dist/tools/browser/profiles/core.cjs.map +1 -0
- package/dist/tools/browser/profiles/core.d.ts +187 -0
- package/dist/tools/browser/profiles/core.js +29 -0
- package/dist/tools/browser/profiles/core.js.map +1 -0
- package/dist/tools/browser/profiles/index.cjs +670 -0
- package/dist/tools/browser/profiles/index.cjs.map +1 -0
- package/dist/tools/browser/profiles/index.d.ts +4 -0
- package/dist/tools/browser/profiles/index.js +29 -0
- package/dist/tools/browser/profiles/index.js.map +1 -0
- package/dist/tools/browser/profiles/types.cjs +74 -0
- package/dist/tools/browser/profiles/types.cjs.map +1 -0
- package/dist/tools/browser/profiles/types.d.ts +195 -0
- package/dist/tools/browser/profiles/types.js +16 -0
- package/dist/tools/browser/profiles/types.js.map +1 -0
- package/dist/tools/browser/prompts.cjs +1 -1
- package/dist/tools/browser/prompts.cjs.map +1 -1
- package/dist/tools/browser/prompts.d.ts +1 -1
- package/dist/tools/browser/prompts.js +1 -1
- package/dist/tools/browser/types.cjs.map +1 -1
- package/dist/tools/browser/types.d.ts +55 -51
- package/dist/tools/browser/vercel.cjs +60 -25
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.d.ts +1 -1
- package/dist/tools/browser/vercel.js +7 -4
- package/dist/tools/fastapply/anthropic.cjs +0 -7
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +1 -1
- package/dist/tools/fastapply/index.cjs +0 -14
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +5 -5
- package/dist/tools/fastapply/openai.cjs +0 -7
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +1 -1
- package/dist/tools/index.cjs +0 -14
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +5 -5
- package/dist/tools/warp_grep/agent/runner.cjs +18 -98
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +2 -3
- package/dist/tools/warp_grep/anthropic.cjs +18 -98
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +8 -9
- package/dist/tools/warp_grep/client.cjs +18 -98
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +5 -6
- package/dist/tools/warp_grep/gemini.cjs +18 -98
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +7 -8
- package/dist/tools/warp_grep/gemini.js.map +1 -1
- package/dist/tools/warp_grep/harness.js +10 -10
- package/dist/tools/warp_grep/index.cjs +18 -98
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +8 -9
- package/dist/tools/warp_grep/openai.cjs +18 -98
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +8 -9
- package/dist/tools/warp_grep/vercel.cjs +18 -98
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +8 -9
- package/dist/{vercel-CsnNSdze.d.ts → vercel-CVF27qFK.d.ts} +10 -10
- package/package.json +7 -2
- package/dist/chunk-4WLGDYWQ.js.map +0 -1
- package/dist/chunk-5QIWYEHJ.js.map +0 -1
- package/dist/chunk-EYGBUH2R.js.map +0 -1
- package/dist/chunk-FNLNDMIX.js.map +0 -1
- package/dist/chunk-IUG2FHNN.js.map +0 -1
- package/dist/chunk-MIIJWDOQ.js.map +0 -1
- package/dist/chunk-SQN4DUQS.js.map +0 -1
- package/dist/chunk-VHOWYK66.js.map +0 -1
- /package/dist/{chunk-LMUZ3NGC.js.map → chunk-73RV6EXR.js.map} +0 -0
- /package/dist/{chunk-PBLPZ6AU.js.map → chunk-7D6TXC7X.js.map} +0 -0
- /package/dist/{chunk-GU6DACME.js.map → chunk-O7LDZA52.js.map} +0 -0
- /package/dist/{chunk-PUGIOVSP.js.map → chunk-QAT5UVPX.js.map} +0 -0
- /package/dist/{chunk-IJ54DTJ3.js.map → chunk-ZYTAKEBW.js.map} +0 -0
|
@@ -2,25 +2,24 @@ import {
|
|
|
2
2
|
createWarpGrepTool,
|
|
3
3
|
execute,
|
|
4
4
|
warpGrepTool
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-7D6TXC7X.js";
|
|
6
6
|
import "../../chunk-KW7OEGZK.js";
|
|
7
7
|
import {
|
|
8
8
|
formatResult
|
|
9
|
-
} from "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
9
|
+
} from "../../chunk-QAT5UVPX.js";
|
|
10
|
+
import "../../chunk-43LQLGP6.js";
|
|
11
11
|
import "../../chunk-PUGSTXLO.js";
|
|
12
12
|
import "../../chunk-KRDIR7GG.js";
|
|
13
|
-
import "../../chunk-APP75CBN.js";
|
|
14
|
-
import "../../chunk-SNGGSPYJ.js";
|
|
15
|
-
import {
|
|
16
|
-
getSystemPrompt
|
|
17
|
-
} from "../../chunk-FMLHRJDF.js";
|
|
18
13
|
import "../../chunk-4KMBU6T3.js";
|
|
19
14
|
import "../../chunk-G2RSY56Q.js";
|
|
20
15
|
import "../../chunk-YPKNMYD4.js";
|
|
21
16
|
import "../../chunk-TPP2UGQP.js";
|
|
22
17
|
import "../../chunk-5PNMAWLC.js";
|
|
23
|
-
import "../../chunk-
|
|
18
|
+
import "../../chunk-APP75CBN.js";
|
|
19
|
+
import "../../chunk-SNGGSPYJ.js";
|
|
20
|
+
import {
|
|
21
|
+
getSystemPrompt
|
|
22
|
+
} from "../../chunk-FMLHRJDF.js";
|
|
24
23
|
import "../../chunk-PZ5AY32C.js";
|
|
25
24
|
export {
|
|
26
25
|
createWarpGrepTool,
|
|
@@ -728,80 +728,6 @@ function mergeRanges(ranges) {
|
|
|
728
728
|
return merged;
|
|
729
729
|
}
|
|
730
730
|
|
|
731
|
-
// tools/utils/resilience.ts
|
|
732
|
-
var DEFAULT_RETRY_CONFIG = {
|
|
733
|
-
maxRetries: 3,
|
|
734
|
-
initialDelay: 1e3,
|
|
735
|
-
maxDelay: 3e4,
|
|
736
|
-
backoffMultiplier: 2,
|
|
737
|
-
retryableErrors: ["ECONNREFUSED", "ETIMEDOUT", "ENOTFOUND"]
|
|
738
|
-
};
|
|
739
|
-
async function fetchWithRetry(url, options, retryConfig = {}) {
|
|
740
|
-
const {
|
|
741
|
-
maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,
|
|
742
|
-
initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,
|
|
743
|
-
maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,
|
|
744
|
-
backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,
|
|
745
|
-
retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,
|
|
746
|
-
onRetry
|
|
747
|
-
} = retryConfig;
|
|
748
|
-
let lastError = null;
|
|
749
|
-
let delay = initialDelay;
|
|
750
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
751
|
-
try {
|
|
752
|
-
const response = await fetch(url, options);
|
|
753
|
-
if (response.status === 429 || response.status === 503) {
|
|
754
|
-
if (attempt < maxRetries) {
|
|
755
|
-
const retryAfter = response.headers.get("Retry-After");
|
|
756
|
-
const waitTime = retryAfter ? parseInt(retryAfter) * 1e3 : Math.min(delay, maxDelay);
|
|
757
|
-
const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);
|
|
758
|
-
if (onRetry) {
|
|
759
|
-
onRetry(attempt + 1, error);
|
|
760
|
-
}
|
|
761
|
-
await sleep(waitTime);
|
|
762
|
-
delay *= backoffMultiplier;
|
|
763
|
-
continue;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
return response;
|
|
767
|
-
} catch (error) {
|
|
768
|
-
lastError = error;
|
|
769
|
-
const isRetryable = retryableErrors.some(
|
|
770
|
-
(errType) => lastError?.message?.includes(errType)
|
|
771
|
-
);
|
|
772
|
-
if (!isRetryable || attempt === maxRetries) {
|
|
773
|
-
throw lastError;
|
|
774
|
-
}
|
|
775
|
-
const waitTime = Math.min(delay, maxDelay);
|
|
776
|
-
if (onRetry) {
|
|
777
|
-
onRetry(attempt + 1, lastError);
|
|
778
|
-
}
|
|
779
|
-
await sleep(waitTime);
|
|
780
|
-
delay *= backoffMultiplier;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
throw lastError || new Error("Max retries exceeded");
|
|
784
|
-
}
|
|
785
|
-
async function withTimeout(promise, timeoutMs, errorMessage) {
|
|
786
|
-
let timeoutId;
|
|
787
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
788
|
-
timeoutId = setTimeout(() => {
|
|
789
|
-
reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));
|
|
790
|
-
}, timeoutMs);
|
|
791
|
-
});
|
|
792
|
-
try {
|
|
793
|
-
const result = await Promise.race([promise, timeoutPromise]);
|
|
794
|
-
clearTimeout(timeoutId);
|
|
795
|
-
return result;
|
|
796
|
-
} catch (error) {
|
|
797
|
-
clearTimeout(timeoutId);
|
|
798
|
-
throw error;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
function sleep(ms) {
|
|
802
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
803
|
-
}
|
|
804
|
-
|
|
805
731
|
// tools/warp_grep/agent/formatter.ts
|
|
806
732
|
var ToolOutputFormatter = class {
|
|
807
733
|
format(toolName, args, output, options = {}) {
|
|
@@ -976,42 +902,36 @@ function enforceContextLimit(messages, maxChars = AGENT_CONFIG.MAX_CONTEXT_CHARS
|
|
|
976
902
|
}
|
|
977
903
|
|
|
978
904
|
// tools/warp_grep/agent/runner.ts
|
|
905
|
+
var import_openai = __toESM(require("openai"), 1);
|
|
979
906
|
var import_path2 = __toESM(require("path"), 1);
|
|
980
907
|
var parser = new LLMResponseParser();
|
|
981
908
|
var DEFAULT_API_URL = "https://api.morphllm.com";
|
|
982
909
|
async function callModel(messages, model, options = {}) {
|
|
983
910
|
const baseUrl = options.morphApiUrl || DEFAULT_API_URL;
|
|
984
911
|
const apiKey = options.morphApiKey || process.env.MORPH_API_KEY || "";
|
|
985
|
-
const fetchPromise = fetchWithRetry(
|
|
986
|
-
`${baseUrl}/v1/chat/completions`,
|
|
987
|
-
{
|
|
988
|
-
method: "POST",
|
|
989
|
-
headers: {
|
|
990
|
-
"Content-Type": "application/json",
|
|
991
|
-
Authorization: `Bearer ${apiKey}`
|
|
992
|
-
},
|
|
993
|
-
body: JSON.stringify({
|
|
994
|
-
model,
|
|
995
|
-
temperature: 0,
|
|
996
|
-
max_tokens: 1024,
|
|
997
|
-
repetition_penalty: 1.05,
|
|
998
|
-
messages
|
|
999
|
-
})
|
|
1000
|
-
},
|
|
1001
|
-
options.retryConfig
|
|
1002
|
-
);
|
|
1003
912
|
const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1006
|
-
|
|
913
|
+
const client = new import_openai.default({
|
|
914
|
+
apiKey,
|
|
915
|
+
baseURL: baseUrl,
|
|
916
|
+
maxRetries: options.retryConfig?.maxRetries,
|
|
917
|
+
timeout: timeoutMs
|
|
918
|
+
});
|
|
919
|
+
let data;
|
|
920
|
+
try {
|
|
921
|
+
data = await client.chat.completions.create({
|
|
922
|
+
model,
|
|
923
|
+
temperature: 0,
|
|
924
|
+
max_tokens: 1024,
|
|
925
|
+
messages
|
|
926
|
+
});
|
|
927
|
+
} catch (error) {
|
|
928
|
+
if (error instanceof import_openai.default.APIError && error.status === 404) {
|
|
1007
929
|
throw new Error(
|
|
1008
930
|
"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"
|
|
1009
931
|
);
|
|
1010
932
|
}
|
|
1011
|
-
|
|
1012
|
-
throw new Error(`morph-warp-grep error ${resp.status}: ${t}`);
|
|
933
|
+
throw error;
|
|
1013
934
|
}
|
|
1014
|
-
const data = await resp.json();
|
|
1015
935
|
const content = data?.choices?.[0]?.message?.content;
|
|
1016
936
|
if (!content || typeof content !== "string") {
|
|
1017
937
|
throw new Error("Invalid response from model");
|