@morphllm/morphsdk 0.2.198 → 0.2.199

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.
Files changed (243) hide show
  1. package/README.md +1 -147
  2. package/dist/{chunk-CAFREMIT.js → chunk-5KQ2WRBU.js} +2 -2
  3. package/dist/{chunk-FUYX2MNM.js → chunk-7UU4NF4G.js} +4 -10
  4. package/dist/chunk-7UU4NF4G.js.map +1 -0
  5. package/dist/{chunk-XTFRHVCW.js → chunk-BLCCGRKT.js} +2 -2
  6. package/dist/{chunk-6XFL2NER.js → chunk-BTMMUG3E.js} +2 -2
  7. package/dist/{chunk-4JUIEYAH.js → chunk-CEXBKXWU.js} +3 -3
  8. package/dist/{chunk-FESO6TDQ.js → chunk-DP2PT36G.js} +2 -2
  9. package/dist/chunk-GKRPR5PZ.js +322 -0
  10. package/dist/chunk-GKRPR5PZ.js.map +1 -0
  11. package/dist/{chunk-ZQNTXHBQ.js → chunk-GTV27THY.js} +2 -2
  12. package/dist/{chunk-ZU5YYGBJ.js → chunk-JOC3ZI56.js} +3 -29
  13. package/dist/chunk-JOC3ZI56.js.map +1 -0
  14. package/dist/{chunk-WLMPQFER.js → chunk-K2JR2NFQ.js} +4 -4
  15. package/dist/{chunk-YQ2G5YLI.js → chunk-KXEPBLVD.js} +10 -10
  16. package/dist/{chunk-T6TXYTKH.js → chunk-MEZTHMB2.js} +4 -4
  17. package/dist/{chunk-ZGERT23F.js → chunk-O7LJEVZO.js} +2 -2
  18. package/dist/{chunk-LN7GNFET.js → chunk-OPNTDMHH.js} +4 -4
  19. package/dist/{chunk-QKNGVBE2.js → chunk-PKJ7ODTG.js} +3 -3
  20. package/dist/{chunk-4DNEBVGV.js → chunk-PW6K6OJL.js} +2 -2
  21. package/dist/{chunk-PV6EF6NG.js → chunk-Q3NH3NPD.js} +2 -2
  22. package/dist/{chunk-O5264GI4.js → chunk-RL3ZTXT3.js} +4 -4
  23. package/dist/{chunk-D2RFP6R2.js → chunk-ULHHMZRL.js} +3 -3
  24. package/dist/{chunk-PEFXG5M6.js → chunk-UT3NQLCF.js} +2 -2
  25. package/dist/{chunk-VBZ7BG47.js → chunk-VS5F2ORN.js} +3 -3
  26. package/dist/{chunk-YUH3MTP3.js → chunk-W37OFBSG.js} +2 -2
  27. package/dist/{chunk-SKN2L5CE.js → chunk-WDBYAXZ5.js} +2 -2
  28. package/dist/{chunk-XK3PQZW6.js → chunk-YSFEKIYQ.js} +2 -2
  29. package/dist/{chunk-3XS5P5XH.js → chunk-ZHB57ORD.js} +6 -6
  30. package/dist/client-CGW0Cevz.d.ts +402 -0
  31. package/dist/client.cjs +12 -1644
  32. package/dist/client.cjs.map +1 -1
  33. package/dist/client.d.ts +3 -7
  34. package/dist/client.js +27 -32
  35. package/dist/core/client.cjs +2 -34
  36. package/dist/core/client.cjs.map +1 -1
  37. package/dist/core/client.d.ts +0 -8
  38. package/dist/core/client.js +4 -4
  39. package/dist/core/error.cjs +2 -28
  40. package/dist/core/error.cjs.map +1 -1
  41. package/dist/core/error.js +3 -3
  42. package/dist/core/index.cjs +2 -34
  43. package/dist/core/index.cjs.map +1 -1
  44. package/dist/core/index.js +4 -4
  45. package/dist/edge.cjs +2 -34
  46. package/dist/edge.cjs.map +1 -1
  47. package/dist/edge.js +7 -7
  48. package/dist/index.cjs +12 -1656
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.ts +1 -5
  51. package/dist/index.js +31 -49
  52. package/dist/modelrouter/core.cjs +2 -34
  53. package/dist/modelrouter/core.cjs.map +1 -1
  54. package/dist/modelrouter/core.js +5 -5
  55. package/dist/modelrouter/index.cjs +2 -34
  56. package/dist/modelrouter/index.cjs.map +1 -1
  57. package/dist/modelrouter/index.js +5 -5
  58. package/dist/subagents/anthropic.cjs +2 -34
  59. package/dist/subagents/anthropic.cjs.map +1 -1
  60. package/dist/subagents/anthropic.js +11 -11
  61. package/dist/subagents/vercel.cjs +2 -34
  62. package/dist/subagents/vercel.cjs.map +1 -1
  63. package/dist/subagents/vercel.js +11 -11
  64. package/dist/tools/codebase_search/anthropic.cjs +2 -34
  65. package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
  66. package/dist/tools/codebase_search/anthropic.js +6 -6
  67. package/dist/tools/codebase_search/core.cjs +2 -34
  68. package/dist/tools/codebase_search/core.cjs.map +1 -1
  69. package/dist/tools/codebase_search/core.js +5 -5
  70. package/dist/tools/codebase_search/index.cjs +2 -34
  71. package/dist/tools/codebase_search/index.cjs.map +1 -1
  72. package/dist/tools/codebase_search/index.js +10 -10
  73. package/dist/tools/codebase_search/openai.cjs +2 -34
  74. package/dist/tools/codebase_search/openai.cjs.map +1 -1
  75. package/dist/tools/codebase_search/openai.js +6 -6
  76. package/dist/tools/codebase_search/vercel.cjs +2 -34
  77. package/dist/tools/codebase_search/vercel.cjs.map +1 -1
  78. package/dist/tools/codebase_search/vercel.js +6 -6
  79. package/dist/tools/compact/core.cjs +2 -34
  80. package/dist/tools/compact/core.cjs.map +1 -1
  81. package/dist/tools/compact/core.js +5 -5
  82. package/dist/tools/compact/index.cjs +2 -34
  83. package/dist/tools/compact/index.cjs.map +1 -1
  84. package/dist/tools/compact/index.js +6 -6
  85. package/dist/tools/fastapply/anthropic.cjs +2 -28
  86. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  87. package/dist/tools/fastapply/anthropic.js +7 -7
  88. package/dist/tools/fastapply/apply.cjs +2 -28
  89. package/dist/tools/fastapply/apply.cjs.map +1 -1
  90. package/dist/tools/fastapply/apply.js +2 -2
  91. package/dist/tools/fastapply/core.cjs +2 -34
  92. package/dist/tools/fastapply/core.cjs.map +1 -1
  93. package/dist/tools/fastapply/core.js +6 -6
  94. package/dist/tools/fastapply/index.cjs +2 -28
  95. package/dist/tools/fastapply/index.cjs.map +1 -1
  96. package/dist/tools/fastapply/index.js +11 -11
  97. package/dist/tools/fastapply/openai.cjs +2 -28
  98. package/dist/tools/fastapply/openai.cjs.map +1 -1
  99. package/dist/tools/fastapply/openai.js +7 -7
  100. package/dist/tools/fastapply/vercel.cjs +2 -28
  101. package/dist/tools/fastapply/vercel.cjs.map +1 -1
  102. package/dist/tools/fastapply/vercel.js +7 -7
  103. package/dist/tools/index.cjs +2 -28
  104. package/dist/tools/index.cjs.map +1 -1
  105. package/dist/tools/index.js +11 -11
  106. package/dist/tools/utils/resilience.cjs +2 -28
  107. package/dist/tools/utils/resilience.cjs.map +1 -1
  108. package/dist/tools/utils/resilience.js +2 -2
  109. package/dist/tools/warp_grep/agent/runner.cjs +2 -28
  110. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  111. package/dist/tools/warp_grep/agent/runner.js +3 -3
  112. package/dist/tools/warp_grep/anthropic.cjs +2 -34
  113. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  114. package/dist/tools/warp_grep/anthropic.js +11 -11
  115. package/dist/tools/warp_grep/client.cjs +2 -34
  116. package/dist/tools/warp_grep/client.cjs.map +1 -1
  117. package/dist/tools/warp_grep/client.js +10 -10
  118. package/dist/tools/warp_grep/gemini.cjs +2 -34
  119. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  120. package/dist/tools/warp_grep/gemini.js +10 -10
  121. package/dist/tools/warp_grep/harness.js +9 -9
  122. package/dist/tools/warp_grep/index.cjs +2 -34
  123. package/dist/tools/warp_grep/index.cjs.map +1 -1
  124. package/dist/tools/warp_grep/index.js +16 -16
  125. package/dist/tools/warp_grep/openai.cjs +2 -34
  126. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  127. package/dist/tools/warp_grep/openai.js +11 -11
  128. package/dist/tools/warp_grep/providers/local.js +2 -2
  129. package/dist/tools/warp_grep/vercel.cjs +2 -34
  130. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  131. package/dist/tools/warp_grep/vercel.js +11 -11
  132. package/dist/version.cjs +2 -28
  133. package/dist/version.cjs.map +1 -1
  134. package/dist/version.js +1 -1
  135. package/package.json +2 -28
  136. package/dist/anthropic-B6my2oBx.d.ts +0 -56
  137. package/dist/chunk-2AMEQAO2.js +0 -46
  138. package/dist/chunk-2AMEQAO2.js.map +0 -1
  139. package/dist/chunk-2HMEZZKK.js +0 -44
  140. package/dist/chunk-2HMEZZKK.js.map +0 -1
  141. package/dist/chunk-2VERUKO2.js +0 -177
  142. package/dist/chunk-2VERUKO2.js.map +0 -1
  143. package/dist/chunk-FUYX2MNM.js.map +0 -1
  144. package/dist/chunk-GJ42MYUU.js +0 -57
  145. package/dist/chunk-GJ42MYUU.js.map +0 -1
  146. package/dist/chunk-KQKLQHJF.js +0 -96
  147. package/dist/chunk-KQKLQHJF.js.map +0 -1
  148. package/dist/chunk-PIIXU2H3.js +0 -389
  149. package/dist/chunk-PIIXU2H3.js.map +0 -1
  150. package/dist/chunk-XH6KJJDI.js +0 -80
  151. package/dist/chunk-XH6KJJDI.js.map +0 -1
  152. package/dist/chunk-YD6TNDR4.js +0 -622
  153. package/dist/chunk-YD6TNDR4.js.map +0 -1
  154. package/dist/chunk-YHZJYCOU.js +0 -680
  155. package/dist/chunk-YHZJYCOU.js.map +0 -1
  156. package/dist/chunk-YTYCHRQ2.js +0 -106
  157. package/dist/chunk-YTYCHRQ2.js.map +0 -1
  158. package/dist/chunk-ZU5YYGBJ.js.map +0 -1
  159. package/dist/client-DCeydotn.d.ts +0 -1015
  160. package/dist/openai-BQMeDFef.d.ts +0 -81
  161. package/dist/tools/browser/anthropic.cjs +0 -645
  162. package/dist/tools/browser/anthropic.cjs.map +0 -1
  163. package/dist/tools/browser/anthropic.d.ts +0 -4
  164. package/dist/tools/browser/anthropic.js +0 -22
  165. package/dist/tools/browser/anthropic.js.map +0 -1
  166. package/dist/tools/browser/core.cjs +0 -1821
  167. package/dist/tools/browser/core.cjs.map +0 -1
  168. package/dist/tools/browser/core.d.ts +0 -245
  169. package/dist/tools/browser/core.js +0 -32
  170. package/dist/tools/browser/core.js.map +0 -1
  171. package/dist/tools/browser/errors.cjs +0 -208
  172. package/dist/tools/browser/errors.cjs.map +0 -1
  173. package/dist/tools/browser/errors.d.ts +0 -158
  174. package/dist/tools/browser/errors.js +0 -22
  175. package/dist/tools/browser/errors.js.map +0 -1
  176. package/dist/tools/browser/index.cjs +0 -2159
  177. package/dist/tools/browser/index.cjs.map +0 -1
  178. package/dist/tools/browser/index.d.ts +0 -134
  179. package/dist/tools/browser/index.js +0 -163
  180. package/dist/tools/browser/index.js.map +0 -1
  181. package/dist/tools/browser/live.cjs +0 -134
  182. package/dist/tools/browser/live.cjs.map +0 -1
  183. package/dist/tools/browser/live.d.ts +0 -75
  184. package/dist/tools/browser/live.js +0 -16
  185. package/dist/tools/browser/live.js.map +0 -1
  186. package/dist/tools/browser/openai.cjs +0 -661
  187. package/dist/tools/browser/openai.cjs.map +0 -1
  188. package/dist/tools/browser/openai.d.ts +0 -4
  189. package/dist/tools/browser/openai.js +0 -28
  190. package/dist/tools/browser/openai.js.map +0 -1
  191. package/dist/tools/browser/profiles/core.cjs +0 -932
  192. package/dist/tools/browser/profiles/core.cjs.map +0 -1
  193. package/dist/tools/browser/profiles/core.d.ts +0 -187
  194. package/dist/tools/browser/profiles/core.js +0 -30
  195. package/dist/tools/browser/profiles/core.js.map +0 -1
  196. package/dist/tools/browser/profiles/index.cjs +0 -932
  197. package/dist/tools/browser/profiles/index.cjs.map +0 -1
  198. package/dist/tools/browser/profiles/index.d.ts +0 -4
  199. package/dist/tools/browser/profiles/index.js +0 -30
  200. package/dist/tools/browser/profiles/index.js.map +0 -1
  201. package/dist/tools/browser/profiles/types.cjs +0 -74
  202. package/dist/tools/browser/profiles/types.cjs.map +0 -1
  203. package/dist/tools/browser/profiles/types.d.ts +0 -195
  204. package/dist/tools/browser/profiles/types.js +0 -16
  205. package/dist/tools/browser/profiles/types.js.map +0 -1
  206. package/dist/tools/browser/prompts.cjs +0 -69
  207. package/dist/tools/browser/prompts.cjs.map +0 -1
  208. package/dist/tools/browser/prompts.d.ts +0 -7
  209. package/dist/tools/browser/prompts.js +0 -10
  210. package/dist/tools/browser/prompts.js.map +0 -1
  211. package/dist/tools/browser/types.cjs +0 -19
  212. package/dist/tools/browser/types.cjs.map +0 -1
  213. package/dist/tools/browser/types.d.ts +0 -338
  214. package/dist/tools/browser/types.js +0 -1
  215. package/dist/tools/browser/types.js.map +0 -1
  216. package/dist/tools/browser/vercel.cjs +0 -622
  217. package/dist/tools/browser/vercel.cjs.map +0 -1
  218. package/dist/tools/browser/vercel.d.ts +0 -4
  219. package/dist/tools/browser/vercel.js +0 -22
  220. package/dist/tools/browser/vercel.js.map +0 -1
  221. package/dist/vercel-CVF27qFK.d.ts +0 -74
  222. /package/dist/{chunk-CAFREMIT.js.map → chunk-5KQ2WRBU.js.map} +0 -0
  223. /package/dist/{chunk-XTFRHVCW.js.map → chunk-BLCCGRKT.js.map} +0 -0
  224. /package/dist/{chunk-6XFL2NER.js.map → chunk-BTMMUG3E.js.map} +0 -0
  225. /package/dist/{chunk-4JUIEYAH.js.map → chunk-CEXBKXWU.js.map} +0 -0
  226. /package/dist/{chunk-FESO6TDQ.js.map → chunk-DP2PT36G.js.map} +0 -0
  227. /package/dist/{chunk-ZQNTXHBQ.js.map → chunk-GTV27THY.js.map} +0 -0
  228. /package/dist/{chunk-WLMPQFER.js.map → chunk-K2JR2NFQ.js.map} +0 -0
  229. /package/dist/{chunk-YQ2G5YLI.js.map → chunk-KXEPBLVD.js.map} +0 -0
  230. /package/dist/{chunk-T6TXYTKH.js.map → chunk-MEZTHMB2.js.map} +0 -0
  231. /package/dist/{chunk-ZGERT23F.js.map → chunk-O7LJEVZO.js.map} +0 -0
  232. /package/dist/{chunk-LN7GNFET.js.map → chunk-OPNTDMHH.js.map} +0 -0
  233. /package/dist/{chunk-QKNGVBE2.js.map → chunk-PKJ7ODTG.js.map} +0 -0
  234. /package/dist/{chunk-4DNEBVGV.js.map → chunk-PW6K6OJL.js.map} +0 -0
  235. /package/dist/{chunk-PV6EF6NG.js.map → chunk-Q3NH3NPD.js.map} +0 -0
  236. /package/dist/{chunk-O5264GI4.js.map → chunk-RL3ZTXT3.js.map} +0 -0
  237. /package/dist/{chunk-D2RFP6R2.js.map → chunk-ULHHMZRL.js.map} +0 -0
  238. /package/dist/{chunk-PEFXG5M6.js.map → chunk-UT3NQLCF.js.map} +0 -0
  239. /package/dist/{chunk-VBZ7BG47.js.map → chunk-VS5F2ORN.js.map} +0 -0
  240. /package/dist/{chunk-YUH3MTP3.js.map → chunk-W37OFBSG.js.map} +0 -0
  241. /package/dist/{chunk-SKN2L5CE.js.map → chunk-WDBYAXZ5.js.map} +0 -0
  242. /package/dist/{chunk-XK3PQZW6.js.map → chunk-YSFEKIYQ.js.map} +0 -0
  243. /package/dist/{chunk-3XS5P5XH.js.map → chunk-ZHB57ORD.js.map} +0 -0
@@ -1,680 +0,0 @@
1
- import {
2
- createGitHubSearchTool as createGitHubSearchTool3,
3
- createWarpGrepTool as createWarpGrepTool3
4
- } from "./chunk-PEFXG5M6.js";
5
- import {
6
- createGitHubSearchTool as createGitHubSearchTool2,
7
- createWarpGrepTool as createWarpGrepTool2
8
- } from "./chunk-XK3PQZW6.js";
9
- import {
10
- createGitHubSearchTool,
11
- createWarpGrepTool
12
- } from "./chunk-YUH3MTP3.js";
13
- import {
14
- createCodebaseSearchTool
15
- } from "./chunk-WLMPQFER.js";
16
- import {
17
- createCodebaseSearchTool as createCodebaseSearchTool3
18
- } from "./chunk-O5264GI4.js";
19
- import {
20
- createCodebaseSearchTool as createCodebaseSearchTool2
21
- } from "./chunk-T6TXYTKH.js";
22
- import {
23
- CodebaseSearchClient
24
- } from "./chunk-VBZ7BG47.js";
25
- import {
26
- createEditFileTool as createEditFileTool3
27
- } from "./chunk-PV6EF6NG.js";
28
- import {
29
- createEditFileTool as createEditFileTool2
30
- } from "./chunk-ZGERT23F.js";
31
- import {
32
- createEditFileTool
33
- } from "./chunk-XTFRHVCW.js";
34
- import {
35
- FastApplyClient
36
- } from "./chunk-D2RFP6R2.js";
37
- import {
38
- BrowserClient
39
- } from "./chunk-YD6TNDR4.js";
40
- import {
41
- createExploreSubagent
42
- } from "./chunk-CAFREMIT.js";
43
- import {
44
- createExploreSubagent as createExploreSubagent2
45
- } from "./chunk-SKN2L5CE.js";
46
- import {
47
- WarpGrepClient
48
- } from "./chunk-YQ2G5YLI.js";
49
- import {
50
- AnthropicRouter,
51
- GeminiRouter,
52
- OpenAIRouter,
53
- RawRouter,
54
- RouterClassifier
55
- } from "./chunk-QKNGVBE2.js";
56
- import {
57
- CompactClient
58
- } from "./chunk-4JUIEYAH.js";
59
- import {
60
- MorphAPIClient
61
- } from "./chunk-FUYX2MNM.js";
62
- import {
63
- logger
64
- } from "./chunk-F3NCFNUX.js";
65
- import {
66
- APIResource
67
- } from "./chunk-5TOJD2C5.js";
68
-
69
- // tools/github/types.ts
70
- var GitHubError = class extends Error {
71
- /** HTTP status code */
72
- status;
73
- /** Error code from API */
74
- code;
75
- constructor(message, status, code) {
76
- super(message);
77
- this.name = "GitHubError";
78
- this.status = status;
79
- this.code = code;
80
- }
81
- };
82
- var NoInstallationError = class extends GitHubError {
83
- constructor(message = "No GitHub installation found. Connect GitHub at morphllm.com/dashboard/integrations/github") {
84
- super(message, 404, "NO_INSTALLATION");
85
- }
86
- };
87
- var NotFoundError = class extends GitHubError {
88
- constructor(resource) {
89
- super(`${resource} not found`, 404, "NOT_FOUND");
90
- }
91
- };
92
- var PermissionError = class extends GitHubError {
93
- constructor(message = "Insufficient permissions for this operation") {
94
- super(message, 403, "PERMISSION_DENIED");
95
- }
96
- };
97
-
98
- // tools/github/core.ts
99
- var DEFAULT_BASE_URL = "https://api.morphllm.com";
100
- var DEFAULT_TIMEOUT = 3e4;
101
- var GitHubClient = class extends APIResource {
102
- timeout;
103
- debug;
104
- defaultInstallationId;
105
- /** Installation operations */
106
- installations;
107
- /** Repository operations */
108
- repos;
109
- /** Project operations (monorepo sub-projects) */
110
- projects;
111
- /** Pull request operations */
112
- pullRequests;
113
- /** Deployment operations */
114
- deployments;
115
- /** Comment operations */
116
- comments;
117
- /** Check run operations */
118
- checkRuns;
119
- /**
120
- * Get the GitHub App installation URL.
121
- * Users visit this URL once to install the Morph GitHub App on their account/org.
122
- */
123
- getInstallUrl() {
124
- return "https://github.com/apps/morph-subagents/installations/new";
125
- }
126
- constructor(clientOrConfig = {}, options = {}) {
127
- const isClient = clientOrConfig instanceof MorphAPIClient;
128
- const config = isClient ? {} : clientOrConfig;
129
- super(
130
- isClient ? clientOrConfig : new MorphAPIClient({
131
- apiKey: config.apiKey,
132
- baseURL: config.baseUrl ?? DEFAULT_BASE_URL,
133
- timeout: config.timeout ?? DEFAULT_TIMEOUT,
134
- debug: config.debug
135
- })
136
- );
137
- this.timeout = config.timeout || DEFAULT_TIMEOUT;
138
- this.debug = config.debug || false;
139
- this.defaultInstallationId = isClient ? options.installationId : config.installationId;
140
- if (!this._client.resolveApiKey()) {
141
- throw new Error("API key required. Set MORPH_API_KEY or pass apiKey in config.");
142
- }
143
- this.installations = {
144
- list: this.listInstallations.bind(this),
145
- get: this.getInstallation.bind(this),
146
- update: this.updateInstallation.bind(this),
147
- disconnect: this.disconnectInstallation.bind(this)
148
- };
149
- this.repos = {
150
- list: this.listRepos.bind(this),
151
- get: this.getRepo.bind(this),
152
- update: this.updateRepo.bind(this),
153
- remove: this.removeRepo.bind(this),
154
- sync: this.syncRepos.bind(this)
155
- };
156
- this.projects = {
157
- list: this.listProjects.bind(this),
158
- create: this.createProject.bind(this),
159
- update: this.updateProject.bind(this),
160
- delete: this.deleteProject.bind(this)
161
- };
162
- this.pullRequests = {
163
- list: this.listPullRequests.bind(this),
164
- get: this.getPullRequest.bind(this)
165
- };
166
- this.deployments = {
167
- list: this.listDeployments.bind(this)
168
- };
169
- this.comments = {
170
- list: this.listComments.bind(this),
171
- create: this.createComment.bind(this),
172
- update: this.updateComment.bind(this),
173
- delete: this.deleteComment.bind(this)
174
- };
175
- this.checkRuns = {
176
- create: this.createCheckRun.bind(this),
177
- update: this.updateCheckRun.bind(this)
178
- };
179
- }
180
- /**
181
- * Make an authenticated API request
182
- */
183
- async request(method, path, body) {
184
- if (this.debug) {
185
- console.log(`[GitHub SDK] ${method} ${path}`, body || "");
186
- }
187
- let response;
188
- try {
189
- response = await this._client.request(method, path, {
190
- body,
191
- timeout: this.timeout,
192
- raw: true
193
- });
194
- } catch (error) {
195
- if (error instanceof Error && /timed out/i.test(error.message)) {
196
- throw new GitHubError("Request timeout", 408, "TIMEOUT");
197
- }
198
- throw new GitHubError(error instanceof Error ? error.message : "Unknown error", 500, "UNKNOWN");
199
- }
200
- if (!response.ok) {
201
- const errorData = await response.json().catch(() => ({}));
202
- const message = errorData.error || errorData.detail || errorData.message || response.statusText;
203
- if (this.debug) {
204
- console.error(`[GitHub SDK] Error ${response.status}:`, message);
205
- }
206
- if (response.status === 404) {
207
- if (message.includes("installation")) {
208
- throw new NoInstallationError(message);
209
- }
210
- throw new NotFoundError(message);
211
- }
212
- if (response.status === 403) {
213
- throw new PermissionError(message);
214
- }
215
- throw new GitHubError(message, response.status, errorData.code);
216
- }
217
- const data = await response.json();
218
- if (this.debug) {
219
- console.log(`[GitHub SDK] Response:`, JSON.stringify(data).slice(0, 200));
220
- }
221
- return data;
222
- }
223
- /**
224
- * Get the installation ID to use for a request
225
- */
226
- getInstallationId(input) {
227
- return input?.installationId || this.defaultInstallationId;
228
- }
229
- // ==========================================================================
230
- // Installations
231
- // ==========================================================================
232
- async listInstallations() {
233
- return this.request("GET", "/api/v1/github/installations");
234
- }
235
- async getInstallation(installationId) {
236
- return this.request("GET", `/api/v1/github/installations/${installationId}`);
237
- }
238
- async updateInstallation(input) {
239
- if (this.debug) console.log("[GitHub SDK] updateInstallation", input.installationId);
240
- const { installationId, ...body } = input;
241
- return this.request("PATCH", `/api/v1/github/installations/${installationId}`, body);
242
- }
243
- async disconnectInstallation(installationId) {
244
- if (this.debug) console.log("[GitHub SDK] disconnectInstallation", installationId);
245
- return this.request("DELETE", `/api/v1/github/installations/${installationId}`);
246
- }
247
- // ==========================================================================
248
- // Repositories
249
- // ==========================================================================
250
- async listRepos(input) {
251
- const installationId = input.installationId || this.defaultInstallationId;
252
- if (!installationId) {
253
- throw new NoInstallationError("installationId required. Call installations.list() first.");
254
- }
255
- return this.request("GET", `/api/v1/github/installations/${installationId}/repos`);
256
- }
257
- async getRepo(repoId) {
258
- if (this.debug) console.log("[GitHub SDK] getRepo", repoId);
259
- return this.request("GET", `/api/v1/github/repos/${repoId}`);
260
- }
261
- async updateRepo(input) {
262
- if (this.debug) console.log("[GitHub SDK] updateRepo", input.repoId);
263
- const { repoId, ...body } = input;
264
- return this.request("PATCH", `/api/v1/github/repos/${repoId}`, body);
265
- }
266
- async removeRepo(repoId) {
267
- if (this.debug) console.log("[GitHub SDK] removeRepo", repoId);
268
- return this.request("DELETE", `/api/v1/github/repos/${repoId}`);
269
- }
270
- async syncRepos(input) {
271
- const installationId = input.installationId || this.defaultInstallationId;
272
- if (!installationId) {
273
- throw new NoInstallationError("installationId required. Call installations.list() first.");
274
- }
275
- if (this.debug) console.log("[GitHub SDK] syncRepos", installationId);
276
- return this.request("POST", `/api/v1/github/installations/${installationId}/repos/sync`);
277
- }
278
- // ==========================================================================
279
- // Projects (monorepo sub-projects)
280
- // ==========================================================================
281
- async listProjects(input) {
282
- if (this.debug) console.log("[GitHub SDK] listProjects", input.repoId);
283
- return this.request("GET", `/api/v1/github/repos/${input.repoId}/projects`);
284
- }
285
- async createProject(input) {
286
- if (this.debug) console.log("[GitHub SDK] createProject", input.repoId, input.name);
287
- const { repoId, ...body } = input;
288
- return this.request("POST", `/api/v1/github/repos/${repoId}/projects`, body);
289
- }
290
- async updateProject(input) {
291
- if (this.debug) console.log("[GitHub SDK] updateProject", input.projectId);
292
- const { projectId, ...body } = input;
293
- return this.request("PATCH", `/api/v1/github/projects/${projectId}`, body);
294
- }
295
- async deleteProject(projectId) {
296
- if (this.debug) console.log("[GitHub SDK] deleteProject", projectId);
297
- return this.request("DELETE", `/api/v1/github/projects/${projectId}`);
298
- }
299
- // ==========================================================================
300
- // Pull Requests
301
- // ==========================================================================
302
- async listPullRequests(input) {
303
- const installationId = this.getInstallationId(input);
304
- const params = new URLSearchParams({
305
- owner: input.owner,
306
- repo: input.repo,
307
- ...input.state && { state: input.state },
308
- ...installationId && { installationId }
309
- });
310
- return this.request("GET", `/api/v1/github/pulls?${params}`);
311
- }
312
- async getPullRequest(input) {
313
- const installationId = this.getInstallationId(input);
314
- const params = new URLSearchParams({
315
- owner: input.owner,
316
- repo: input.repo,
317
- ...installationId && { installationId }
318
- });
319
- return this.request(
320
- "GET",
321
- `/api/v1/github/pulls/${input.number}?${params}`
322
- );
323
- }
324
- // ==========================================================================
325
- // Deployments
326
- // ==========================================================================
327
- async listDeployments(input) {
328
- const installationId = this.getInstallationId(input);
329
- const params = new URLSearchParams({
330
- owner: input.owner,
331
- repo: input.repo,
332
- ...input.sha && { sha: input.sha },
333
- ...input.environment && { environment: input.environment },
334
- ...installationId && { installationId }
335
- });
336
- return this.request("GET", `/api/v1/github/deployments?${params}`);
337
- }
338
- // ==========================================================================
339
- // Comments
340
- // ==========================================================================
341
- async listComments(input) {
342
- const installationId = this.getInstallationId(input);
343
- const params = new URLSearchParams({
344
- owner: input.owner,
345
- repo: input.repo,
346
- pr: String(input.pr),
347
- ...installationId && { installationId }
348
- });
349
- return this.request("GET", `/api/v1/github/comments?${params}`);
350
- }
351
- async createComment(input) {
352
- const installationId = this.getInstallationId(input);
353
- return this.request("POST", "/api/v1/github/comments", {
354
- owner: input.owner,
355
- repo: input.repo,
356
- pr: input.pr,
357
- body: input.body,
358
- ...installationId && { installationId }
359
- });
360
- }
361
- async updateComment(input) {
362
- const installationId = this.getInstallationId(input);
363
- return this.request("PATCH", `/api/v1/github/comments/${input.commentId}`, {
364
- owner: input.owner,
365
- repo: input.repo,
366
- body: input.body,
367
- ...installationId && { installationId }
368
- });
369
- }
370
- async deleteComment(input) {
371
- const installationId = this.getInstallationId(input);
372
- const params = new URLSearchParams({
373
- owner: input.owner,
374
- repo: input.repo,
375
- ...installationId && { installationId }
376
- });
377
- await this.request("DELETE", `/api/v1/github/comments/${input.commentId}?${params}`);
378
- }
379
- // ==========================================================================
380
- // Check Runs
381
- // ==========================================================================
382
- async createCheckRun(input) {
383
- const installationId = this.getInstallationId(input);
384
- return this.request("POST", "/api/v1/github/check-runs", {
385
- owner: input.owner,
386
- repo: input.repo,
387
- sha: input.sha,
388
- name: input.name,
389
- status: input.status,
390
- ...input.title && { title: input.title },
391
- ...input.summary && { summary: input.summary },
392
- ...installationId && { installationId }
393
- });
394
- }
395
- async updateCheckRun(input) {
396
- const installationId = this.getInstallationId(input);
397
- return this.request("PATCH", `/api/v1/github/check-runs/${input.checkRunId}`, {
398
- owner: input.owner,
399
- repo: input.repo,
400
- ...input.status && { status: input.status },
401
- ...input.conclusion && { conclusion: input.conclusion },
402
- ...input.title && { title: input.title },
403
- ...input.summary && { summary: input.summary },
404
- ...input.text && { text: input.text },
405
- ...installationId && { installationId }
406
- });
407
- }
408
- };
409
-
410
- // factories/openai.ts
411
- var OpenAIToolFactory = class {
412
- constructor(config) {
413
- this.config = config;
414
- }
415
- /**
416
- * Create an OpenAI-compatible warp grep tool
417
- *
418
- * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
419
- * @returns OpenAI ChatCompletionTool with execute and formatResult methods
420
- */
421
- createWarpGrepTool(toolConfig) {
422
- return createWarpGrepTool({
423
- ...toolConfig,
424
- morphApiKey: this.config.apiKey
425
- });
426
- }
427
- /**
428
- * Create an OpenAI-compatible codebase search tool
429
- *
430
- * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
431
- * @returns OpenAI ChatCompletionTool with execute and formatResult methods
432
- */
433
- createCodebaseSearchTool(toolConfig) {
434
- return createCodebaseSearchTool({
435
- ...toolConfig,
436
- apiKey: this.config.apiKey
437
- });
438
- }
439
- /**
440
- * Create an OpenAI-compatible edit file tool
441
- *
442
- * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
443
- * @returns OpenAI ChatCompletionTool with execute and formatResult methods
444
- */
445
- createEditFileTool(toolConfig = {}) {
446
- return createEditFileTool({
447
- ...toolConfig,
448
- morphApiKey: this.config.apiKey
449
- });
450
- }
451
- /**
452
- * Create an OpenAI-compatible GitHub search tool
453
- *
454
- * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
455
- * @returns OpenAI ChatCompletionTool with execute and formatResult methods
456
- */
457
- createGitHubSearchTool(toolConfig) {
458
- return createGitHubSearchTool({
459
- ...toolConfig,
460
- morphApiKey: this.config.apiKey
461
- });
462
- }
463
- };
464
-
465
- // factories/anthropic.ts
466
- var AnthropicToolFactory = class {
467
- constructor(config) {
468
- this.config = config;
469
- }
470
- /**
471
- * Create an Anthropic-compatible warp grep tool
472
- *
473
- * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
474
- * @returns Anthropic Tool with execute and formatResult methods
475
- */
476
- createWarpGrepTool(toolConfig) {
477
- return createWarpGrepTool2({
478
- ...toolConfig,
479
- morphApiKey: this.config.apiKey
480
- });
481
- }
482
- /**
483
- * Create an Anthropic-compatible codebase search tool
484
- *
485
- * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
486
- * @returns Anthropic Tool with execute and formatResult methods
487
- */
488
- createCodebaseSearchTool(toolConfig) {
489
- return createCodebaseSearchTool2({
490
- ...toolConfig,
491
- apiKey: this.config.apiKey
492
- });
493
- }
494
- /**
495
- * Create an Anthropic-compatible edit file tool
496
- *
497
- * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
498
- * @returns Anthropic Tool with execute and formatResult methods
499
- */
500
- createEditFileTool(toolConfig = {}) {
501
- return createEditFileTool2({
502
- ...toolConfig,
503
- morphApiKey: this.config.apiKey
504
- });
505
- }
506
- /**
507
- * Create an Anthropic-compatible GitHub search tool
508
- *
509
- * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
510
- * @returns Anthropic Tool with execute and formatResult methods
511
- */
512
- createGitHubSearchTool(toolConfig) {
513
- return createGitHubSearchTool2({
514
- ...toolConfig,
515
- morphApiKey: this.config.apiKey
516
- });
517
- }
518
- /**
519
- * Create an Explore subagent that searches the codebase and returns summaries
520
- *
521
- * @param config - Subagent configuration including client and model (morphApiKey inherited from MorphClient)
522
- * @returns Explore subagent with .tool, .run(), and .stream() methods
523
- */
524
- createExploreSubagent(config) {
525
- return createExploreSubagent({
526
- ...config,
527
- morphApiKey: this.config.apiKey
528
- });
529
- }
530
- };
531
-
532
- // factories/vercel.ts
533
- var VercelToolFactory = class {
534
- constructor(config) {
535
- this.config = config;
536
- }
537
- /**
538
- * Create a Vercel AI SDK-compatible warp grep tool
539
- *
540
- * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
541
- * @returns Vercel AI SDK tool
542
- */
543
- createWarpGrepTool(toolConfig) {
544
- return createWarpGrepTool3({
545
- ...toolConfig,
546
- morphApiKey: this.config.apiKey
547
- });
548
- }
549
- /**
550
- * Create a Vercel AI SDK-compatible codebase search tool
551
- *
552
- * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
553
- * @returns Vercel AI SDK tool
554
- */
555
- createCodebaseSearchTool(toolConfig) {
556
- return createCodebaseSearchTool3({
557
- ...toolConfig,
558
- apiKey: this.config.apiKey
559
- });
560
- }
561
- /**
562
- * Create a Vercel AI SDK-compatible edit file tool
563
- *
564
- * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
565
- * @returns Vercel AI SDK tool
566
- */
567
- createEditFileTool(toolConfig = {}) {
568
- return createEditFileTool3({
569
- ...toolConfig,
570
- morphApiKey: this.config.apiKey
571
- });
572
- }
573
- /**
574
- * Create a Vercel AI SDK-compatible GitHub search tool
575
- *
576
- * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
577
- * @returns Vercel AI SDK tool
578
- */
579
- createGitHubSearchTool(toolConfig) {
580
- return createGitHubSearchTool3({
581
- ...toolConfig,
582
- morphApiKey: this.config.apiKey
583
- });
584
- }
585
- /**
586
- * Create an Explore subagent that searches the codebase and returns summaries
587
- *
588
- * @param config - Subagent configuration including model (morphApiKey inherited from MorphClient)
589
- * @returns Explore subagent with .tool, .run(), and .stream() methods
590
- */
591
- createExploreSubagent(config) {
592
- return createExploreSubagent2({
593
- ...config,
594
- morphApiKey: this.config.apiKey
595
- });
596
- }
597
- };
598
-
599
- // client.ts
600
- var MorphClient = class extends MorphAPIClient {
601
- /** Client configuration */
602
- config;
603
- /** FastApply tool for editing files with AI-powered merge */
604
- fastApply;
605
- /** CodebaseSearch tool for semantic code search */
606
- codebaseSearch;
607
- /** WarpGrep tool for fast code search using ripgrep */
608
- warpGrep;
609
- /** Browser tool for AI-powered browser automation */
610
- browser;
611
- /** GitHub tool for PR context, comments, and check runs */
612
- github;
613
- /** Model routers for intelligent model selection */
614
- routers;
615
- /** OpenAI-compatible tool factories */
616
- openai;
617
- /** Anthropic-compatible tool factories */
618
- anthropic;
619
- /** Vercel AI SDK tool factories */
620
- vercel;
621
- /** Compact context with line ranges */
622
- compact;
623
- /**
624
- * Create a new Morph SDK client
625
- *
626
- * @param config - Client configuration (apiKey, debug, timeout, retryConfig)
627
- *
628
- * @example
629
- * ```typescript
630
- * const morph = new MorphClient({
631
- * apiKey: process.env.MORPH_API_KEY,
632
- * debug: true,
633
- * timeout: 60000
634
- * });
635
- * ```
636
- */
637
- constructor(config = {}) {
638
- super({
639
- apiKey: config.apiKey,
640
- timeout: config.timeout,
641
- retryConfig: config.retryConfig,
642
- debug: config.debug
643
- });
644
- if (!config.apiKey) {
645
- throw new Error("Morph API key is required. Pass it as { apiKey } when constructing MorphClient.");
646
- }
647
- this.config = config;
648
- logger.debug("MorphClient", "initialized", { debug: !!config.debug, timeout: config.timeout });
649
- this.fastApply = new FastApplyClient(this);
650
- this.codebaseSearch = new CodebaseSearchClient(this);
651
- this.warpGrep = new WarpGrepClient(this);
652
- this.browser = new BrowserClient(this);
653
- this.github = new GitHubClient(this, { installationId: config.github?.installationId });
654
- this.routers = {
655
- openai: new OpenAIRouter(this),
656
- anthropic: new AnthropicRouter(this),
657
- gemini: new GeminiRouter(this),
658
- raw: new RawRouter(this),
659
- classify: new RouterClassifier(this)
660
- };
661
- const compactClient = new CompactClient(this);
662
- this.compact = compactClient.compact.bind(compactClient);
663
- this.openai = new OpenAIToolFactory(config);
664
- this.anthropic = new AnthropicToolFactory(config);
665
- this.vercel = new VercelToolFactory(config);
666
- }
667
- };
668
-
669
- export {
670
- GitHubError,
671
- NoInstallationError,
672
- NotFoundError,
673
- PermissionError,
674
- GitHubClient,
675
- OpenAIToolFactory,
676
- AnthropicToolFactory,
677
- VercelToolFactory,
678
- MorphClient
679
- };
680
- //# sourceMappingURL=chunk-YHZJYCOU.js.map