@morphllm/morphsdk 0.2.199 → 0.2.200
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-GTV27THY.js → chunk-3CCWSLQW.js} +2 -2
- package/dist/{chunk-DP2PT36G.js → chunk-7I2A7GGJ.js} +2 -2
- package/dist/{chunk-CEXBKXWU.js → chunk-AKSXZBPT.js} +3 -3
- package/dist/{chunk-GKRPR5PZ.js → chunk-B4X5RWLR.js} +18 -69
- package/dist/chunk-B4X5RWLR.js.map +1 -0
- package/dist/{chunk-PKJ7ODTG.js → chunk-L6YOMTFU.js} +3 -3
- package/dist/{chunk-OPNTDMHH.js → chunk-LN7GNFET.js} +4 -4
- package/dist/{chunk-KXEPBLVD.js → chunk-MLROWLS6.js} +10 -10
- package/dist/{chunk-PW6K6OJL.js → chunk-MPL6BDR6.js} +2 -2
- package/dist/{chunk-ZHB57ORD.js → chunk-PD3EDFQD.js} +6 -6
- package/dist/{chunk-5KQ2WRBU.js → chunk-PJNL35DC.js} +2 -2
- package/dist/{chunk-UT3NQLCF.js → chunk-Q65LL6UM.js} +2 -2
- package/dist/{chunk-W37OFBSG.js → chunk-QTBFL4DG.js} +2 -2
- package/dist/{chunk-BLCCGRKT.js → chunk-SNYHVDE4.js} +4 -4
- package/dist/{chunk-O7LJEVZO.js → chunk-TIMDDHYB.js} +4 -4
- package/dist/{chunk-Q3NH3NPD.js → chunk-UHIANNKC.js} +4 -4
- package/dist/{chunk-7UU4NF4G.js → chunk-UKAAT6KT.js} +4 -4
- package/dist/{chunk-JOC3ZI56.js → chunk-UZ42MHTR.js} +3 -37
- package/dist/chunk-UZ42MHTR.js.map +1 -0
- package/dist/{chunk-YSFEKIYQ.js → chunk-WTENYKJP.js} +2 -2
- package/dist/{chunk-BTMMUG3E.js → chunk-XTLPA7ZP.js} +2 -2
- package/dist/{chunk-ULHHMZRL.js → chunk-Z57GJLCG.js} +3 -3
- package/dist/{chunk-WDBYAXZ5.js → chunk-ZE64EWUV.js} +2 -2
- package/dist/{client-CGW0Cevz.d.ts → client-BWhi-vSj.d.ts} +4 -65
- package/dist/client.cjs +45 -411
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +2 -4
- package/dist/client.js +22 -27
- package/dist/core/client.cjs +2 -36
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.js +4 -4
- package/dist/core/error.cjs +2 -36
- package/dist/core/error.cjs.map +1 -1
- package/dist/core/error.js +3 -3
- package/dist/core/index.cjs +2 -36
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +4 -4
- package/dist/edge.cjs +2 -36
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +7 -7
- package/dist/index.cjs +48 -416
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +26 -34
- package/dist/modelrouter/core.cjs +2 -36
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +5 -5
- package/dist/modelrouter/index.cjs +2 -36
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +5 -5
- package/dist/subagents/anthropic.cjs +2 -36
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.d.ts +1 -1
- package/dist/subagents/anthropic.js +11 -11
- package/dist/subagents/index.d.ts +1 -1
- package/dist/subagents/prompts.d.ts +1 -1
- package/dist/subagents/types.d.ts +1 -1
- package/dist/subagents/vercel.cjs +2 -36
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.d.ts +1 -1
- package/dist/subagents/vercel.js +11 -11
- package/dist/tools/compact/core.cjs +2 -36
- package/dist/tools/compact/core.cjs.map +1 -1
- package/dist/tools/compact/core.js +5 -5
- package/dist/tools/compact/index.cjs +2 -36
- package/dist/tools/compact/index.cjs.map +1 -1
- package/dist/tools/compact/index.js +6 -6
- package/dist/tools/fastapply/anthropic.cjs +2 -36
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +7 -7
- package/dist/tools/fastapply/apply.cjs +2 -36
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +2 -36
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +6 -6
- package/dist/tools/fastapply/index.cjs +2 -36
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +12 -12
- package/dist/tools/fastapply/openai.cjs +2 -36
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +7 -7
- package/dist/tools/fastapply/vercel.cjs +2 -36
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +7 -7
- package/dist/tools/index.cjs +2 -36
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +12 -12
- package/dist/tools/utils/resilience.cjs +2 -36
- 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 +2 -36
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +3 -3
- package/dist/tools/warp_grep/anthropic.cjs +2 -36
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +1 -1
- package/dist/tools/warp_grep/anthropic.js +11 -11
- package/dist/tools/warp_grep/client.cjs +2 -36
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +1 -1
- package/dist/tools/warp_grep/client.js +10 -10
- package/dist/tools/warp_grep/gemini.cjs +2 -36
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.d.ts +1 -1
- package/dist/tools/warp_grep/gemini.js +10 -10
- package/dist/tools/warp_grep/harness.js +9 -9
- package/dist/tools/warp_grep/index.cjs +2 -36
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +1 -1
- package/dist/tools/warp_grep/index.js +16 -16
- package/dist/tools/warp_grep/openai.cjs +2 -36
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +1 -1
- package/dist/tools/warp_grep/openai.js +11 -11
- package/dist/tools/warp_grep/providers/code_storage_http.d.ts +1 -1
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
- package/dist/tools/warp_grep/vercel.cjs +2 -36
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +1 -1
- package/dist/tools/warp_grep/vercel.js +11 -11
- package/dist/{types-qwD753FR.d.ts → types-DxZLPogx.d.ts} +1 -1
- package/dist/version.cjs +2 -36
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -36
- package/dist/chunk-EMURAU6J.js +0 -148
- package/dist/chunk-EMURAU6J.js.map +0 -1
- package/dist/chunk-GKRPR5PZ.js.map +0 -1
- package/dist/chunk-IDMKQWQG.js +0 -214
- package/dist/chunk-IDMKQWQG.js.map +0 -1
- package/dist/chunk-JOC3ZI56.js.map +0 -1
- package/dist/chunk-K2JR2NFQ.js +0 -128
- package/dist/chunk-K2JR2NFQ.js.map +0 -1
- package/dist/chunk-MEZTHMB2.js +0 -83
- package/dist/chunk-MEZTHMB2.js.map +0 -1
- package/dist/chunk-RL3ZTXT3.js +0 -58
- package/dist/chunk-RL3ZTXT3.js.map +0 -1
- package/dist/chunk-TLXVGE4R.js +0 -42
- package/dist/chunk-TLXVGE4R.js.map +0 -1
- package/dist/chunk-VS5F2ORN.js +0 -97
- package/dist/chunk-VS5F2ORN.js.map +0 -1
- package/dist/chunk-YQMPVJ2L.js +0 -32
- package/dist/chunk-YQMPVJ2L.js.map +0 -1
- package/dist/otel-CG0uqXjp.d.ts +0 -42
- package/dist/tools/codebase_search/anthropic.cjs +0 -664
- package/dist/tools/codebase_search/anthropic.cjs.map +0 -1
- package/dist/tools/codebase_search/anthropic.d.ts +0 -40
- package/dist/tools/codebase_search/anthropic.js +0 -16
- package/dist/tools/codebase_search/anthropic.js.map +0 -1
- package/dist/tools/codebase_search/core.cjs +0 -606
- package/dist/tools/codebase_search/core.cjs.map +0 -1
- package/dist/tools/codebase_search/core.d.ts +0 -51
- package/dist/tools/codebase_search/core.js +0 -16
- package/dist/tools/codebase_search/core.js.map +0 -1
- package/dist/tools/codebase_search/index.cjs +0 -789
- package/dist/tools/codebase_search/index.cjs.map +0 -1
- package/dist/tools/codebase_search/index.d.ts +0 -12
- package/dist/tools/codebase_search/index.js +0 -32
- package/dist/tools/codebase_search/index.js.map +0 -1
- package/dist/tools/codebase_search/openai.cjs +0 -713
- package/dist/tools/codebase_search/openai.cjs.map +0 -1
- package/dist/tools/codebase_search/openai.d.ts +0 -87
- package/dist/tools/codebase_search/openai.js +0 -26
- package/dist/tools/codebase_search/openai.js.map +0 -1
- package/dist/tools/codebase_search/prompts.cjs +0 -57
- package/dist/tools/codebase_search/prompts.cjs.map +0 -1
- package/dist/tools/codebase_search/prompts.d.ts +0 -7
- package/dist/tools/codebase_search/prompts.js +0 -10
- package/dist/tools/codebase_search/prompts.js.map +0 -1
- package/dist/tools/codebase_search/types.cjs +0 -19
- package/dist/tools/codebase_search/types.cjs.map +0 -1
- package/dist/tools/codebase_search/types.d.ts +0 -50
- package/dist/tools/codebase_search/types.js +0 -1
- package/dist/tools/codebase_search/types.js.map +0 -1
- package/dist/tools/codebase_search/vercel.cjs +0 -626
- package/dist/tools/codebase_search/vercel.cjs.map +0 -1
- package/dist/tools/codebase_search/vercel.d.ts +0 -65
- package/dist/tools/codebase_search/vercel.js +0 -20
- package/dist/tools/codebase_search/vercel.js.map +0 -1
- package/dist/tracing/core.cjs +0 -410
- package/dist/tracing/core.cjs.map +0 -1
- package/dist/tracing/core.d.ts +0 -58
- package/dist/tracing/core.js +0 -12
- package/dist/tracing/core.js.map +0 -1
- package/dist/tracing/index.cjs +0 -422
- package/dist/tracing/index.cjs.map +0 -1
- package/dist/tracing/index.d.ts +0 -5
- package/dist/tracing/index.js +0 -17
- package/dist/tracing/index.js.map +0 -1
- package/dist/tracing/interaction.cjs +0 -273
- package/dist/tracing/interaction.cjs.map +0 -1
- package/dist/tracing/interaction.d.ts +0 -41
- package/dist/tracing/interaction.js +0 -11
- package/dist/tracing/interaction.js.map +0 -1
- package/dist/tracing/otel.cjs +0 -56
- package/dist/tracing/otel.cjs.map +0 -1
- package/dist/tracing/otel.d.ts +0 -2
- package/dist/tracing/otel.js +0 -10
- package/dist/tracing/otel.js.map +0 -1
- package/dist/tracing/types.cjs +0 -19
- package/dist/tracing/types.cjs.map +0 -1
- package/dist/tracing/types.d.ts +0 -124
- package/dist/tracing/types.js +0 -1
- package/dist/tracing/types.js.map +0 -1
- /package/dist/{chunk-GTV27THY.js.map → chunk-3CCWSLQW.js.map} +0 -0
- /package/dist/{chunk-DP2PT36G.js.map → chunk-7I2A7GGJ.js.map} +0 -0
- /package/dist/{chunk-CEXBKXWU.js.map → chunk-AKSXZBPT.js.map} +0 -0
- /package/dist/{chunk-PKJ7ODTG.js.map → chunk-L6YOMTFU.js.map} +0 -0
- /package/dist/{chunk-OPNTDMHH.js.map → chunk-LN7GNFET.js.map} +0 -0
- /package/dist/{chunk-KXEPBLVD.js.map → chunk-MLROWLS6.js.map} +0 -0
- /package/dist/{chunk-PW6K6OJL.js.map → chunk-MPL6BDR6.js.map} +0 -0
- /package/dist/{chunk-ZHB57ORD.js.map → chunk-PD3EDFQD.js.map} +0 -0
- /package/dist/{chunk-5KQ2WRBU.js.map → chunk-PJNL35DC.js.map} +0 -0
- /package/dist/{chunk-UT3NQLCF.js.map → chunk-Q65LL6UM.js.map} +0 -0
- /package/dist/{chunk-W37OFBSG.js.map → chunk-QTBFL4DG.js.map} +0 -0
- /package/dist/{chunk-BLCCGRKT.js.map → chunk-SNYHVDE4.js.map} +0 -0
- /package/dist/{chunk-O7LJEVZO.js.map → chunk-TIMDDHYB.js.map} +0 -0
- /package/dist/{chunk-Q3NH3NPD.js.map → chunk-UHIANNKC.js.map} +0 -0
- /package/dist/{chunk-7UU4NF4G.js.map → chunk-UKAAT6KT.js.map} +0 -0
- /package/dist/{chunk-YSFEKIYQ.js.map → chunk-WTENYKJP.js.map} +0 -0
- /package/dist/{chunk-BTMMUG3E.js.map → chunk-XTLPA7ZP.js.map} +0 -0
- /package/dist/{chunk-ULHHMZRL.js.map → chunk-Z57GJLCG.js.map} +0 -0
- /package/dist/{chunk-WDBYAXZ5.js.map → chunk-ZE64EWUV.js.map} +0 -0
|
@@ -1,664 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// tools/codebase_search/anthropic.ts
|
|
31
|
-
var anthropic_exports = {};
|
|
32
|
-
__export(anthropic_exports, {
|
|
33
|
-
createCodebaseSearchTool: () => createCodebaseSearchTool
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(anthropic_exports);
|
|
36
|
-
|
|
37
|
-
// package.json
|
|
38
|
-
var package_default = {
|
|
39
|
-
name: "@morphllm/morphsdk",
|
|
40
|
-
version: "0.2.199",
|
|
41
|
-
description: "TypeScript SDK and CLI for Morph Fast Apply integration",
|
|
42
|
-
type: "module",
|
|
43
|
-
main: "./dist/index.cjs",
|
|
44
|
-
module: "./dist/index.js",
|
|
45
|
-
types: "./dist/index.d.ts",
|
|
46
|
-
exports: {
|
|
47
|
-
".": {
|
|
48
|
-
types: "./dist/index.d.ts",
|
|
49
|
-
import: "./dist/index.js",
|
|
50
|
-
require: "./dist/index.cjs"
|
|
51
|
-
},
|
|
52
|
-
"./logger": {
|
|
53
|
-
types: "./dist/logger.d.ts",
|
|
54
|
-
import: "./dist/logger.js",
|
|
55
|
-
require: "./dist/logger.cjs"
|
|
56
|
-
},
|
|
57
|
-
"./edge": {
|
|
58
|
-
types: "./dist/edge.d.ts",
|
|
59
|
-
import: "./dist/edge.js",
|
|
60
|
-
require: "./dist/edge.cjs"
|
|
61
|
-
},
|
|
62
|
-
"./tools/warp-grep": {
|
|
63
|
-
types: "./dist/tools/warp_grep/index.d.ts",
|
|
64
|
-
import: "./dist/tools/warp_grep/index.js",
|
|
65
|
-
require: "./dist/tools/warp_grep/index.cjs"
|
|
66
|
-
},
|
|
67
|
-
"./tools/warp-grep/openai": {
|
|
68
|
-
types: "./dist/tools/warp_grep/openai.d.ts",
|
|
69
|
-
import: "./dist/tools/warp_grep/openai.js",
|
|
70
|
-
require: "./dist/tools/warp_grep/openai.cjs"
|
|
71
|
-
},
|
|
72
|
-
"./tools/warp-grep/anthropic": {
|
|
73
|
-
types: "./dist/tools/warp_grep/anthropic.d.ts",
|
|
74
|
-
import: "./dist/tools/warp_grep/anthropic.js",
|
|
75
|
-
require: "./dist/tools/warp_grep/anthropic.cjs"
|
|
76
|
-
},
|
|
77
|
-
"./tools/warp-grep/vercel": {
|
|
78
|
-
types: "./dist/tools/warp_grep/vercel.d.ts",
|
|
79
|
-
import: "./dist/tools/warp_grep/vercel.js",
|
|
80
|
-
require: "./dist/tools/warp_grep/vercel.cjs"
|
|
81
|
-
},
|
|
82
|
-
"./tools/warp-grep/client": {
|
|
83
|
-
types: "./dist/tools/warp_grep/client.d.ts",
|
|
84
|
-
import: "./dist/tools/warp_grep/client.js",
|
|
85
|
-
require: "./dist/tools/warp_grep/client.cjs"
|
|
86
|
-
},
|
|
87
|
-
"./tools/warp-grep/gemini": {
|
|
88
|
-
types: "./dist/tools/warp_grep/gemini.d.ts",
|
|
89
|
-
import: "./dist/tools/warp_grep/gemini.js",
|
|
90
|
-
require: "./dist/tools/warp_grep/gemini.cjs"
|
|
91
|
-
},
|
|
92
|
-
"./tools/warp-grep/harness": {
|
|
93
|
-
types: "./dist/tools/warp_grep/harness.d.ts",
|
|
94
|
-
import: "./dist/tools/warp_grep/harness.js",
|
|
95
|
-
require: "./dist/tools/warp_grep/harness.cjs"
|
|
96
|
-
},
|
|
97
|
-
"./tracing": {
|
|
98
|
-
types: "./dist/tracing/index.d.ts",
|
|
99
|
-
import: "./dist/tracing/index.js",
|
|
100
|
-
require: "./dist/tracing/index.cjs"
|
|
101
|
-
},
|
|
102
|
-
"./tracing/otel": {
|
|
103
|
-
types: "./dist/tracing/otel.d.ts",
|
|
104
|
-
import: "./dist/tracing/otel.js",
|
|
105
|
-
require: "./dist/tracing/otel.cjs"
|
|
106
|
-
},
|
|
107
|
-
"./tools/fastapply": {
|
|
108
|
-
types: "./dist/tools/fastapply/index.d.ts",
|
|
109
|
-
import: "./dist/tools/fastapply/index.js",
|
|
110
|
-
require: "./dist/tools/fastapply/index.cjs"
|
|
111
|
-
},
|
|
112
|
-
"./tools/fastapply/anthropic": {
|
|
113
|
-
types: "./dist/tools/fastapply/anthropic.d.ts",
|
|
114
|
-
import: "./dist/tools/fastapply/anthropic.js",
|
|
115
|
-
require: "./dist/tools/fastapply/anthropic.cjs"
|
|
116
|
-
},
|
|
117
|
-
"./tools/fastapply/openai": {
|
|
118
|
-
types: "./dist/tools/fastapply/openai.d.ts",
|
|
119
|
-
import: "./dist/tools/fastapply/openai.js",
|
|
120
|
-
require: "./dist/tools/fastapply/openai.cjs"
|
|
121
|
-
},
|
|
122
|
-
"./tools/fastapply/vercel": {
|
|
123
|
-
types: "./dist/tools/fastapply/vercel.d.ts",
|
|
124
|
-
import: "./dist/tools/fastapply/vercel.js",
|
|
125
|
-
require: "./dist/tools/fastapply/vercel.cjs"
|
|
126
|
-
},
|
|
127
|
-
"./tools/codebase-search": {
|
|
128
|
-
types: "./dist/tools/codebase_search/index.d.ts",
|
|
129
|
-
import: "./dist/tools/codebase_search/index.js",
|
|
130
|
-
require: "./dist/tools/codebase_search/index.cjs"
|
|
131
|
-
},
|
|
132
|
-
"./tools/codebase-search/anthropic": {
|
|
133
|
-
types: "./dist/tools/codebase_search/anthropic.d.ts",
|
|
134
|
-
import: "./dist/tools/codebase_search/anthropic.js",
|
|
135
|
-
require: "./dist/tools/codebase_search/anthropic.cjs"
|
|
136
|
-
},
|
|
137
|
-
"./tools/codebase-search/openai": {
|
|
138
|
-
types: "./dist/tools/codebase_search/openai.d.ts",
|
|
139
|
-
import: "./dist/tools/codebase_search/openai.js",
|
|
140
|
-
require: "./dist/tools/codebase_search/openai.cjs"
|
|
141
|
-
},
|
|
142
|
-
"./tools/codebase-search/vercel": {
|
|
143
|
-
types: "./dist/tools/codebase_search/vercel.d.ts",
|
|
144
|
-
import: "./dist/tools/codebase_search/vercel.js",
|
|
145
|
-
require: "./dist/tools/codebase_search/vercel.cjs"
|
|
146
|
-
},
|
|
147
|
-
"./modelrouter": {
|
|
148
|
-
types: "./dist/modelrouter/index.d.ts",
|
|
149
|
-
import: "./dist/modelrouter/index.js",
|
|
150
|
-
require: "./dist/modelrouter/index.cjs"
|
|
151
|
-
},
|
|
152
|
-
"./tools/compact": {
|
|
153
|
-
types: "./dist/tools/compact/index.d.ts",
|
|
154
|
-
import: "./dist/tools/compact/index.js",
|
|
155
|
-
require: "./dist/tools/compact/index.cjs"
|
|
156
|
-
},
|
|
157
|
-
"./subagents": {
|
|
158
|
-
types: "./dist/subagents/index.d.ts",
|
|
159
|
-
import: "./dist/subagents/index.js",
|
|
160
|
-
require: "./dist/subagents/index.cjs"
|
|
161
|
-
},
|
|
162
|
-
"./subagents/vercel": {
|
|
163
|
-
types: "./dist/subagents/vercel.d.ts",
|
|
164
|
-
import: "./dist/subagents/vercel.js",
|
|
165
|
-
require: "./dist/subagents/vercel.cjs"
|
|
166
|
-
},
|
|
167
|
-
"./subagents/anthropic": {
|
|
168
|
-
types: "./dist/subagents/anthropic.d.ts",
|
|
169
|
-
import: "./dist/subagents/anthropic.js",
|
|
170
|
-
require: "./dist/subagents/anthropic.cjs"
|
|
171
|
-
},
|
|
172
|
-
"./ai-sdk": {
|
|
173
|
-
types: "./dist/ai-sdk/index.d.ts",
|
|
174
|
-
import: "./dist/ai-sdk/index.js",
|
|
175
|
-
require: "./dist/ai-sdk/index.cjs"
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
files: [
|
|
179
|
-
"dist/**/*.js",
|
|
180
|
-
"dist/**/*.cjs",
|
|
181
|
-
"dist/**/*.d.ts",
|
|
182
|
-
"dist/**/*.map",
|
|
183
|
-
"!dist/**/__tests__/**",
|
|
184
|
-
"!dist/**/*.test.*"
|
|
185
|
-
],
|
|
186
|
-
scripts: {
|
|
187
|
-
build: "tsup version.ts index.ts edge.ts client.ts core/index.ts core/client.ts core/resource.ts core/error.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/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 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 subagents/index.ts subagents/types.ts subagents/prompts.ts subagents/vercel.ts subagents/anthropic.ts tracing/index.ts tracing/core.ts tracing/interaction.ts tracing/otel.ts tracing/types.ts --format esm,cjs --sourcemap --clean --dts --dts-resolve && tsup ai-sdk/index.ts --format esm,cjs --sourcemap --dts --no-clean --out-dir dist/ai-sdk",
|
|
188
|
-
prepare: "npm run build",
|
|
189
|
-
typecheck: "tsc --noEmit && tsc --noEmit -p ai-sdk/tsconfig.json",
|
|
190
|
-
lint: "eslint .",
|
|
191
|
-
test: "vitest run",
|
|
192
|
-
"test:watch": "vitest watch",
|
|
193
|
-
"test:anthropic": "vitest run anthropic",
|
|
194
|
-
"test:openai": "vitest run openai",
|
|
195
|
-
"test:vercel": "vitest run vercel",
|
|
196
|
-
"test:git": "vitest run git",
|
|
197
|
-
"test:agent": "npx tsx tests/fullAgentTest.ts",
|
|
198
|
-
"test:integration": "npx tsx tests/fullIntegrationTest.ts",
|
|
199
|
-
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
200
|
-
"release:patch": "npm version patch && npm publish",
|
|
201
|
-
"release:minor": "npm version minor && npm publish",
|
|
202
|
-
"release:major": "npm version major && npm publish"
|
|
203
|
-
},
|
|
204
|
-
keywords: [
|
|
205
|
-
"morph",
|
|
206
|
-
"fast-apply",
|
|
207
|
-
"cli",
|
|
208
|
-
"sdk",
|
|
209
|
-
"edit-file"
|
|
210
|
-
],
|
|
211
|
-
engines: {
|
|
212
|
-
node: ">=18"
|
|
213
|
-
},
|
|
214
|
-
license: "MIT",
|
|
215
|
-
dependencies: {
|
|
216
|
-
"@opentelemetry/api": "^1.9.0",
|
|
217
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
|
|
218
|
-
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
219
|
-
"@traceloop/node-server-sdk": "^0.27.0",
|
|
220
|
-
"@vscode/ripgrep": "^1.17.0",
|
|
221
|
-
ai: ">=5.0.0",
|
|
222
|
-
diff: "^7.0.0",
|
|
223
|
-
openai: "^4.52.7",
|
|
224
|
-
zod: ">=3.23.0"
|
|
225
|
-
},
|
|
226
|
-
devDependencies: {
|
|
227
|
-
"@ai-sdk/anthropic": "^2.0.70",
|
|
228
|
-
"@ai-sdk/openai": "^2.0.35",
|
|
229
|
-
"@anthropic-ai/sdk": "^0.30.1",
|
|
230
|
-
"@google/generative-ai": "^0.24.1",
|
|
231
|
-
"@types/diff": "^7.0.2",
|
|
232
|
-
"@types/node": "^20.14.10",
|
|
233
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
234
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
235
|
-
dotenv: "^16.4.5",
|
|
236
|
-
eslint: "^8.57.0",
|
|
237
|
-
shx: "^0.3.4",
|
|
238
|
-
tsup: "^8.5.0",
|
|
239
|
-
tsx: "^4.16.2",
|
|
240
|
-
typescript: "^5.5.4",
|
|
241
|
-
vitest: "^2.1.6"
|
|
242
|
-
},
|
|
243
|
-
peerDependencies: {
|
|
244
|
-
"@ai-sdk/openai-compatible": ">=2.0.74 <4",
|
|
245
|
-
"@anthropic-ai/sdk": ">=0.25.0",
|
|
246
|
-
"@google/generative-ai": ">=0.21.0",
|
|
247
|
-
ai: ">=5.0.0",
|
|
248
|
-
zod: ">=3.23.0"
|
|
249
|
-
},
|
|
250
|
-
peerDependenciesMeta: {
|
|
251
|
-
"@anthropic-ai/sdk": {
|
|
252
|
-
optional: true
|
|
253
|
-
},
|
|
254
|
-
"@google/generative-ai": {
|
|
255
|
-
optional: true
|
|
256
|
-
},
|
|
257
|
-
ai: {
|
|
258
|
-
optional: true
|
|
259
|
-
},
|
|
260
|
-
zod: {
|
|
261
|
-
optional: true
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
publishConfig: {
|
|
265
|
-
access: "public"
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
// version.ts
|
|
270
|
-
var SDK_VERSION = package_default.version;
|
|
271
|
-
|
|
272
|
-
// tools/utils/resilience.ts
|
|
273
|
-
var DEFAULT_RETRY_CONFIG = {
|
|
274
|
-
maxRetries: 3,
|
|
275
|
-
initialDelay: 1e3,
|
|
276
|
-
maxDelay: 3e4,
|
|
277
|
-
backoffMultiplier: 2,
|
|
278
|
-
retryableErrors: ["ECONNREFUSED", "ETIMEDOUT", "ENOTFOUND"]
|
|
279
|
-
};
|
|
280
|
-
async function fetchWithRetry(url, options, retryConfig = {}) {
|
|
281
|
-
const {
|
|
282
|
-
maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,
|
|
283
|
-
initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,
|
|
284
|
-
maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,
|
|
285
|
-
backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,
|
|
286
|
-
retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,
|
|
287
|
-
onRetry
|
|
288
|
-
} = retryConfig;
|
|
289
|
-
let lastError = null;
|
|
290
|
-
let delay = initialDelay;
|
|
291
|
-
options = { ...options, headers: { "X-Morph-SDK-Version": SDK_VERSION, ...options.headers } };
|
|
292
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
293
|
-
try {
|
|
294
|
-
const response = await fetch(url, options);
|
|
295
|
-
if (response.status === 429 || response.status === 503) {
|
|
296
|
-
if (attempt < maxRetries) {
|
|
297
|
-
const retryAfter = response.headers.get("Retry-After");
|
|
298
|
-
const waitTime = retryAfter ? parseInt(retryAfter) * 1e3 : Math.min(delay, maxDelay);
|
|
299
|
-
const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);
|
|
300
|
-
if (onRetry) {
|
|
301
|
-
onRetry(attempt + 1, error);
|
|
302
|
-
}
|
|
303
|
-
await sleep(waitTime);
|
|
304
|
-
delay *= backoffMultiplier;
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return response;
|
|
309
|
-
} catch (error) {
|
|
310
|
-
lastError = error;
|
|
311
|
-
const isRetryable = retryableErrors.some(
|
|
312
|
-
(errType) => lastError?.message?.includes(errType)
|
|
313
|
-
);
|
|
314
|
-
if (!isRetryable || attempt === maxRetries) {
|
|
315
|
-
throw lastError;
|
|
316
|
-
}
|
|
317
|
-
const waitTime = Math.min(delay, maxDelay);
|
|
318
|
-
if (onRetry) {
|
|
319
|
-
onRetry(attempt + 1, lastError);
|
|
320
|
-
}
|
|
321
|
-
await sleep(waitTime);
|
|
322
|
-
delay *= backoffMultiplier;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
throw lastError || new Error("Max retries exceeded");
|
|
326
|
-
}
|
|
327
|
-
async function withTimeout(promise, timeoutMs, errorMessage) {
|
|
328
|
-
let timeoutId;
|
|
329
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
330
|
-
timeoutId = setTimeout(() => {
|
|
331
|
-
reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));
|
|
332
|
-
}, timeoutMs);
|
|
333
|
-
});
|
|
334
|
-
try {
|
|
335
|
-
const result = await Promise.race([promise, timeoutPromise]);
|
|
336
|
-
clearTimeout(timeoutId);
|
|
337
|
-
return result;
|
|
338
|
-
} catch (error) {
|
|
339
|
-
clearTimeout(timeoutId);
|
|
340
|
-
throw error;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
function sleep(ms) {
|
|
344
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
345
|
-
}
|
|
346
|
-
var MorphError = class extends Error {
|
|
347
|
-
constructor(message, code, statusCode, retryable = false) {
|
|
348
|
-
super(message);
|
|
349
|
-
this.code = code;
|
|
350
|
-
this.statusCode = statusCode;
|
|
351
|
-
this.retryable = retryable;
|
|
352
|
-
this.name = "MorphError";
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
// logger.ts
|
|
357
|
-
var MorphLogger = class {
|
|
358
|
-
enabled;
|
|
359
|
-
fileStream;
|
|
360
|
-
/** Resolves once the file stream is initialized (or immediately if no file logging). */
|
|
361
|
-
ready;
|
|
362
|
-
constructor() {
|
|
363
|
-
this.enabled = typeof process !== "undefined" && (process.env.MORPH_DEBUG === "1" || !!process.env.MORPH_LOG_FILE);
|
|
364
|
-
this.fileStream = null;
|
|
365
|
-
const f = typeof process !== "undefined" ? process.env.MORPH_LOG_FILE : void 0;
|
|
366
|
-
if (f) {
|
|
367
|
-
this.ready = import("fs").then((fs) => {
|
|
368
|
-
this.fileStream = fs.createWriteStream(f, { flags: "a" });
|
|
369
|
-
}).catch(() => {
|
|
370
|
-
});
|
|
371
|
-
} else {
|
|
372
|
-
this.ready = Promise.resolve();
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
debug(component, msg, data) {
|
|
376
|
-
this._log("debug", component, msg, data);
|
|
377
|
-
}
|
|
378
|
-
info(component, msg, data) {
|
|
379
|
-
this._log("info", component, msg, data);
|
|
380
|
-
}
|
|
381
|
-
warn(component, msg, data) {
|
|
382
|
-
this._log("warn", component, msg, data);
|
|
383
|
-
}
|
|
384
|
-
error(component, msg, data) {
|
|
385
|
-
this._log("error", component, msg, data);
|
|
386
|
-
}
|
|
387
|
-
enable() {
|
|
388
|
-
this.enabled = true;
|
|
389
|
-
}
|
|
390
|
-
get isEnabled() {
|
|
391
|
-
return this.enabled;
|
|
392
|
-
}
|
|
393
|
-
_log(level, component, msg, data) {
|
|
394
|
-
if (level !== "error" && !this.enabled) return;
|
|
395
|
-
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
396
|
-
const prefix = `[${ts}] [${level.toUpperCase()}] [${component}]`;
|
|
397
|
-
console.error(data ? `${prefix} ${msg} ${JSON.stringify(data)}` : `${prefix} ${msg}`);
|
|
398
|
-
this.fileStream?.write(JSON.stringify({ ts, level, component, msg, ...data && { data } }) + "\n");
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
var logger = new MorphLogger();
|
|
402
|
-
|
|
403
|
-
// core/error.ts
|
|
404
|
-
async function toMorphError(response) {
|
|
405
|
-
let message = `Morph API request failed (${response.status})`;
|
|
406
|
-
let code = "api_error";
|
|
407
|
-
try {
|
|
408
|
-
const body = await response.json();
|
|
409
|
-
message = body.error?.message ?? body.message ?? message;
|
|
410
|
-
code = body.error?.code ?? body.error?.type ?? code;
|
|
411
|
-
} catch {
|
|
412
|
-
}
|
|
413
|
-
if (response.status === 401) code = "authentication_error";
|
|
414
|
-
if (response.status === 429) code = "rate_limit_exceeded";
|
|
415
|
-
const retryable = response.status === 429 || response.status === 503;
|
|
416
|
-
return new MorphError(message, code, response.status, retryable);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// core/client.ts
|
|
420
|
-
var DEFAULT_BASE_URL = "https://api.morphllm.com";
|
|
421
|
-
var DEFAULT_REPOS_URL = "https://repos.morphllm.com";
|
|
422
|
-
var DEFAULT_TIMEOUT = 6e4;
|
|
423
|
-
var env = (name) => typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
424
|
-
var stripTrailingSlash = (url) => url.replace(/\/+$/, "");
|
|
425
|
-
var MorphAPIClient = class {
|
|
426
|
-
/** Explicit key as provided; resolved against env at request time. */
|
|
427
|
-
apiKey;
|
|
428
|
-
baseURL;
|
|
429
|
-
reposURL;
|
|
430
|
-
/** Explicit default timeout (ms), if set. The request default is applied lazily so
|
|
431
|
-
* resources can read an undefined value and supply their own fallback. */
|
|
432
|
-
timeout;
|
|
433
|
-
retryConfig;
|
|
434
|
-
debug;
|
|
435
|
-
constructor(options = {}) {
|
|
436
|
-
this.apiKey = options.apiKey;
|
|
437
|
-
this.baseURL = stripTrailingSlash(options.baseURL ?? DEFAULT_BASE_URL);
|
|
438
|
-
this.reposURL = stripTrailingSlash(options.reposURL ?? env("MORPH_SEARCH_URL") ?? DEFAULT_REPOS_URL);
|
|
439
|
-
this.timeout = options.timeout;
|
|
440
|
-
this.retryConfig = options.retryConfig;
|
|
441
|
-
this.debug = options.debug ?? false;
|
|
442
|
-
if (this.debug) logger.enable();
|
|
443
|
-
}
|
|
444
|
-
/** The key actually used for requests: explicit, else `MORPH_API_KEY`. */
|
|
445
|
-
resolveApiKey() {
|
|
446
|
-
return this.apiKey ?? env("MORPH_API_KEY");
|
|
447
|
-
}
|
|
448
|
-
/** Headers shared with tools that bring their own HTTP client (FastApply/WarpGrep via the `openai` package). */
|
|
449
|
-
defaultHeaders() {
|
|
450
|
-
return { "X-Morph-SDK-Version": SDK_VERSION };
|
|
451
|
-
}
|
|
452
|
-
buildURL(path, baseURL) {
|
|
453
|
-
if (/^https?:\/\//i.test(path)) return path;
|
|
454
|
-
const base = stripTrailingSlash(baseURL ?? this.baseURL);
|
|
455
|
-
return `${base}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
456
|
-
}
|
|
457
|
-
buildHeaders(apiKey, extra) {
|
|
458
|
-
return {
|
|
459
|
-
"Content-Type": "application/json",
|
|
460
|
-
"X-Morph-SDK-Version": SDK_VERSION,
|
|
461
|
-
Authorization: `Bearer ${apiKey}`,
|
|
462
|
-
...extra
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
applyQuery(url, query) {
|
|
466
|
-
if (!query) return url;
|
|
467
|
-
const params = new URLSearchParams();
|
|
468
|
-
for (const [key, value] of Object.entries(query)) {
|
|
469
|
-
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
470
|
-
}
|
|
471
|
-
const qs = params.toString();
|
|
472
|
-
return qs ? `${url}${url.includes("?") ? "&" : "?"}${qs}` : url;
|
|
473
|
-
}
|
|
474
|
-
async request(method, path, opts = {}) {
|
|
475
|
-
const apiKey = this.resolveApiKey();
|
|
476
|
-
if (!apiKey) {
|
|
477
|
-
throw new MorphError(
|
|
478
|
-
"Morph API key not found. Set the MORPH_API_KEY environment variable or pass apiKey in config.",
|
|
479
|
-
"missing_api_key",
|
|
480
|
-
401
|
|
481
|
-
);
|
|
482
|
-
}
|
|
483
|
-
const url = this.applyQuery(this.buildURL(path, opts.baseURL), opts.query);
|
|
484
|
-
const timeout = opts.timeout ?? this.timeout ?? DEFAULT_TIMEOUT;
|
|
485
|
-
const init = {
|
|
486
|
-
method,
|
|
487
|
-
headers: this.buildHeaders(apiKey, opts.headers),
|
|
488
|
-
...opts.body !== void 0 ? { body: JSON.stringify(opts.body) } : {},
|
|
489
|
-
...opts.signal ? { signal: opts.signal } : {}
|
|
490
|
-
};
|
|
491
|
-
logger.debug("MorphAPIClient", "request", { method, url });
|
|
492
|
-
const response = await withTimeout(
|
|
493
|
-
fetchWithRetry(url, init, this.retryConfig ?? {}),
|
|
494
|
-
timeout,
|
|
495
|
-
`Morph request to ${url} timed out after ${timeout}ms`
|
|
496
|
-
);
|
|
497
|
-
if (!response.ok) throw await toMorphError(response);
|
|
498
|
-
if (opts.stream) return response;
|
|
499
|
-
if (response.status === 204) return void 0;
|
|
500
|
-
const text = await response.text();
|
|
501
|
-
return text ? JSON.parse(text) : void 0;
|
|
502
|
-
}
|
|
503
|
-
get(path, opts) {
|
|
504
|
-
return this.request("GET", path, opts);
|
|
505
|
-
}
|
|
506
|
-
post(path, opts) {
|
|
507
|
-
return this.request("POST", path, opts);
|
|
508
|
-
}
|
|
509
|
-
delete(path, opts) {
|
|
510
|
-
return this.request("DELETE", path, opts);
|
|
511
|
-
}
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
// tools/codebase_search/core.ts
|
|
515
|
-
var DEFAULT_TIMEOUT2 = 3e4;
|
|
516
|
-
var emptyStats = { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: 0 };
|
|
517
|
-
async function runSearch(client, input, repoId, timeout, baseURL) {
|
|
518
|
-
const startTime = Date.now();
|
|
519
|
-
logger.debug("CodebaseSearch", "request", { query: input.query.slice(0, 100), repo_id: repoId });
|
|
520
|
-
try {
|
|
521
|
-
const data = await client.post(
|
|
522
|
-
"/v1/codebase_search",
|
|
523
|
-
{
|
|
524
|
-
baseURL: baseURL ?? client.reposURL,
|
|
525
|
-
timeout,
|
|
526
|
-
body: {
|
|
527
|
-
query: input.query,
|
|
528
|
-
repoId,
|
|
529
|
-
targetDirectories: input.target_directories || [],
|
|
530
|
-
limit: input.limit || 10,
|
|
531
|
-
candidateLimit: 50
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
);
|
|
535
|
-
const elapsed = Date.now() - startTime;
|
|
536
|
-
logger.debug("CodebaseSearch", "response", { results_count: data.results?.length || 0, latency_ms: elapsed });
|
|
537
|
-
return {
|
|
538
|
-
success: true,
|
|
539
|
-
results: data.results || [],
|
|
540
|
-
stats: data.stats || { totalResults: 0, candidatesRetrieved: 0, searchTimeMs: elapsed }
|
|
541
|
-
};
|
|
542
|
-
} catch (error) {
|
|
543
|
-
const message = error instanceof MorphError && error.statusCode ? `Search failed (${error.statusCode}): ${error.message}` : error instanceof Error ? error.message : "Unknown error";
|
|
544
|
-
logger.error("CodebaseSearch", "error", { error: message, latency_ms: Date.now() - startTime });
|
|
545
|
-
return { success: false, results: [], stats: { ...emptyStats }, error: message };
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
async function executeCodebaseSearch(input, config) {
|
|
549
|
-
const apiKey = config.apiKey || process.env.MORPH_API_KEY;
|
|
550
|
-
if (!apiKey) {
|
|
551
|
-
throw new Error("MORPH_API_KEY not found. Set environment variable or pass in config");
|
|
552
|
-
}
|
|
553
|
-
const client = new MorphAPIClient({
|
|
554
|
-
apiKey,
|
|
555
|
-
reposURL: config.searchUrl,
|
|
556
|
-
timeout: config.timeout ?? DEFAULT_TIMEOUT2,
|
|
557
|
-
retryConfig: config.retryConfig,
|
|
558
|
-
debug: config.debug
|
|
559
|
-
});
|
|
560
|
-
return runSearch(client, input, config.repoId, config.timeout ?? DEFAULT_TIMEOUT2, config.searchUrl);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// tools/codebase_search/prompts.ts
|
|
564
|
-
var CODEBASE_SEARCH_DESCRIPTION = `Semantic search that finds code by meaning, not exact text.
|
|
565
|
-
|
|
566
|
-
Use this to explore unfamiliar codebases or ask "how/where/what" questions:
|
|
567
|
-
- "How does X work?" - Find implementation details
|
|
568
|
-
- "Where is Y handled?" - Locate specific functionality
|
|
569
|
-
- "What happens when Z?" - Understand flow
|
|
570
|
-
|
|
571
|
-
The tool uses two-stage retrieval (embedding similarity + reranking) to find the most semantically relevant code chunks.
|
|
572
|
-
|
|
573
|
-
Returns code chunks with file paths, line ranges, and full content ranked by relevance.`;
|
|
574
|
-
var CODEBASE_SEARCH_SYSTEM_PROMPT = `You have access to the codebase_search tool that performs semantic code search.
|
|
575
|
-
|
|
576
|
-
When searching:
|
|
577
|
-
- Use natural language queries describing what you're looking for
|
|
578
|
-
- Be specific about functionality, not variable names
|
|
579
|
-
- Use target_directories to narrow search if you know the area
|
|
580
|
-
- Results are ranked by relevance (rerank score is most important)
|
|
581
|
-
|
|
582
|
-
The tool returns:
|
|
583
|
-
- File paths with symbol names (e.g. "src/auth.ts::AuthService@L1-L17")
|
|
584
|
-
- Line ranges for precise navigation
|
|
585
|
-
- Full code content for each match
|
|
586
|
-
- Dual relevance scores: embedding similarity + rerank score
|
|
587
|
-
|
|
588
|
-
Use results to understand code or answer questions. The content is provided in full - avoid re-reading unless you need more context.`;
|
|
589
|
-
|
|
590
|
-
// tools/codebase_search/anthropic.ts
|
|
591
|
-
function createCodebaseSearchTool(config) {
|
|
592
|
-
const toolDefinition = {
|
|
593
|
-
name: "codebase_search",
|
|
594
|
-
description: CODEBASE_SEARCH_DESCRIPTION,
|
|
595
|
-
input_schema: {
|
|
596
|
-
type: "object",
|
|
597
|
-
properties: {
|
|
598
|
-
explanation: {
|
|
599
|
-
type: "string",
|
|
600
|
-
description: "One sentence explanation as to why this tool is being used, and how it contributes to the goal."
|
|
601
|
-
},
|
|
602
|
-
query: {
|
|
603
|
-
type: "string",
|
|
604
|
-
description: 'A complete question about what you want to understand. Ask as if talking to a colleague: "How does X work?", "What happens when Y?", "Where is Z handled?"'
|
|
605
|
-
},
|
|
606
|
-
target_directories: {
|
|
607
|
-
type: "array",
|
|
608
|
-
items: { type: "string" },
|
|
609
|
-
description: "Prefix directory paths to limit search scope (single directory only, no glob patterns). Use [] to search entire repo."
|
|
610
|
-
},
|
|
611
|
-
limit: {
|
|
612
|
-
type: "number",
|
|
613
|
-
description: "Maximum results to return (default: 10)"
|
|
614
|
-
}
|
|
615
|
-
},
|
|
616
|
-
required: ["query", "target_directories", "explanation"]
|
|
617
|
-
},
|
|
618
|
-
cache_control: { type: "ephemeral" }
|
|
619
|
-
};
|
|
620
|
-
return Object.assign(toolDefinition, {
|
|
621
|
-
execute: async (input) => {
|
|
622
|
-
return executeCodebaseSearch(input, config);
|
|
623
|
-
},
|
|
624
|
-
formatResult: (result) => {
|
|
625
|
-
return formatResult(result);
|
|
626
|
-
},
|
|
627
|
-
getSystemPrompt: () => {
|
|
628
|
-
return CODEBASE_SEARCH_SYSTEM_PROMPT;
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
function formatResult(result) {
|
|
633
|
-
if (!result.success) {
|
|
634
|
-
return `Search failed: ${result.error}`;
|
|
635
|
-
}
|
|
636
|
-
if (result.results.length === 0) {
|
|
637
|
-
return "No matching code found. Try rephrasing your query or broadening the search scope.";
|
|
638
|
-
}
|
|
639
|
-
const lines = [];
|
|
640
|
-
lines.push(`Found ${result.results.length} relevant code sections (searched ${result.stats.candidatesRetrieved} candidates in ${result.stats.searchTimeMs}ms):
|
|
641
|
-
`);
|
|
642
|
-
result.results.forEach((r, i) => {
|
|
643
|
-
const relevance = (r.rerankScore * 100).toFixed(1);
|
|
644
|
-
lines.push(`${i + 1}. ${r.filepath} (${relevance}% relevant)`);
|
|
645
|
-
lines.push(` Symbol: ${r.symbolPath}`);
|
|
646
|
-
lines.push(` Language: ${r.language}`);
|
|
647
|
-
lines.push(` Lines: ${r.startLine}-${r.endLine}`);
|
|
648
|
-
lines.push(` Code:`);
|
|
649
|
-
const codeLines = r.content.split("\n");
|
|
650
|
-
codeLines.slice(0, Math.min(codeLines.length, 20)).forEach((line) => {
|
|
651
|
-
lines.push(` ${line}`);
|
|
652
|
-
});
|
|
653
|
-
if (codeLines.length > 20) {
|
|
654
|
-
lines.push(` ... (${codeLines.length - 20} more lines)`);
|
|
655
|
-
}
|
|
656
|
-
lines.push("");
|
|
657
|
-
});
|
|
658
|
-
return lines.join("\n");
|
|
659
|
-
}
|
|
660
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
661
|
-
0 && (module.exports = {
|
|
662
|
-
createCodebaseSearchTool
|
|
663
|
-
});
|
|
664
|
-
//# sourceMappingURL=anthropic.cjs.map
|