@morphllm/morphsdk 0.2.119 → 0.2.121

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 (182) hide show
  1. package/dist/{chunk-ZRLEAPZV.js → chunk-266SWRHK.js} +2 -2
  2. package/dist/{chunk-4VWJFZVS.js → chunk-3HBZXN6E.js} +6 -1
  3. package/dist/chunk-3HBZXN6E.js.map +1 -0
  4. package/dist/{chunk-3T4BGWCV.js → chunk-7IZUNRPZ.js} +37 -23
  5. package/dist/{chunk-3T4BGWCV.js.map → chunk-7IZUNRPZ.js.map} +1 -1
  6. package/dist/{chunk-FXBT4UDY.js → chunk-7QZFNYOH.js} +7 -2
  7. package/dist/chunk-7QZFNYOH.js.map +1 -0
  8. package/dist/{chunk-M5DR2WOZ.js → chunk-AI3ZCOCT.js} +1 -1
  9. package/dist/{chunk-UNHHRMU7.js → chunk-BDKXYMU2.js} +4 -4
  10. package/dist/{chunk-G7RSAZIK.js → chunk-C3BQUIFE.js} +5 -5
  11. package/dist/{chunk-WM77HRKO.js → chunk-CIFPLFBQ.js} +2 -2
  12. package/dist/{chunk-WVTX3QS6.js → chunk-CXP63PHW.js} +2 -2
  13. package/dist/{chunk-5IVVJMMX.js → chunk-DL3Y3R6A.js} +2 -2
  14. package/dist/{chunk-HMQSMEN2.js → chunk-EF7ZYLA2.js} +4 -4
  15. package/dist/chunk-EJYFE73S.js +230 -0
  16. package/dist/chunk-EJYFE73S.js.map +1 -0
  17. package/dist/{chunk-EAT5W3SH.js → chunk-EZFXR52Q.js} +2 -2
  18. package/dist/{chunk-HMAX2FEE.js → chunk-FV3R3JGV.js} +4 -4
  19. package/dist/{chunk-OUEJ6XEO.js → chunk-GNRMDXJA.js} +2 -2
  20. package/dist/chunk-J267T54M.js +76 -0
  21. package/dist/chunk-J267T54M.js.map +1 -0
  22. package/dist/{chunk-SI2CKRKJ.js → chunk-JBIFS33U.js} +2 -2
  23. package/dist/{chunk-EMMSRY32.js → chunk-L4PK4VC7.js} +2 -2
  24. package/dist/{chunk-PR44LEQQ.js → chunk-MAAULSSQ.js} +2 -2
  25. package/dist/{chunk-QL7MV3GT.js → chunk-QDGB6FLI.js} +12 -8
  26. package/dist/chunk-QDGB6FLI.js.map +1 -0
  27. package/dist/{chunk-K4EO7S2O.js → chunk-U5UDFQXK.js} +2 -2
  28. package/dist/{chunk-O5DA5V5S.js → chunk-W37KJB25.js} +2 -2
  29. package/dist/{chunk-ZYPLV3HP.js → chunk-WEBUKGPK.js} +3 -3
  30. package/dist/{chunk-OOCSNAA5.js → chunk-XERAWJ3H.js} +2 -2
  31. package/dist/{chunk-Y5BB7JFH.js → chunk-YMOTJ6ZP.js} +4 -4
  32. package/dist/{client-D7iO2TbA.d.ts → client-Bp3MRcJc.d.ts} +6 -1
  33. package/dist/client.cjs +329 -2
  34. package/dist/client.cjs.map +1 -1
  35. package/dist/client.d.ts +4 -1
  36. package/dist/client.js +24 -22
  37. package/dist/edge.cjs +305 -1
  38. package/dist/edge.cjs.map +1 -1
  39. package/dist/edge.d.ts +4 -0
  40. package/dist/edge.js +15 -7
  41. package/dist/index.cjs +334 -2
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.ts +5 -1
  44. package/dist/index.js +38 -30
  45. package/dist/modelrouter/core.cjs +227 -0
  46. package/dist/modelrouter/core.cjs.map +1 -1
  47. package/dist/modelrouter/core.js +3 -2
  48. package/dist/modelrouter/index.cjs +227 -0
  49. package/dist/modelrouter/index.cjs.map +1 -1
  50. package/dist/modelrouter/index.js +3 -2
  51. package/dist/tools/browser/anthropic.cjs +227 -0
  52. package/dist/tools/browser/anthropic.cjs.map +1 -1
  53. package/dist/tools/browser/anthropic.js +6 -5
  54. package/dist/tools/browser/core.cjs +227 -0
  55. package/dist/tools/browser/core.cjs.map +1 -1
  56. package/dist/tools/browser/core.js +5 -4
  57. package/dist/tools/browser/index.cjs +227 -0
  58. package/dist/tools/browser/index.cjs.map +1 -1
  59. package/dist/tools/browser/index.js +13 -12
  60. package/dist/tools/browser/index.js.map +1 -1
  61. package/dist/tools/browser/openai.cjs +227 -0
  62. package/dist/tools/browser/openai.cjs.map +1 -1
  63. package/dist/tools/browser/openai.js +6 -5
  64. package/dist/tools/browser/profiles/core.cjs +227 -0
  65. package/dist/tools/browser/profiles/core.cjs.map +1 -1
  66. package/dist/tools/browser/profiles/core.js +3 -2
  67. package/dist/tools/browser/profiles/index.cjs +227 -0
  68. package/dist/tools/browser/profiles/index.cjs.map +1 -1
  69. package/dist/tools/browser/profiles/index.js +3 -2
  70. package/dist/tools/browser/vercel.cjs +227 -0
  71. package/dist/tools/browser/vercel.cjs.map +1 -1
  72. package/dist/tools/browser/vercel.js +6 -5
  73. package/dist/tools/codebase_search/anthropic.cjs +227 -0
  74. package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
  75. package/dist/tools/codebase_search/anthropic.js +4 -3
  76. package/dist/tools/codebase_search/core.cjs +227 -0
  77. package/dist/tools/codebase_search/core.cjs.map +1 -1
  78. package/dist/tools/codebase_search/core.js +3 -2
  79. package/dist/tools/codebase_search/index.cjs +227 -0
  80. package/dist/tools/codebase_search/index.cjs.map +1 -1
  81. package/dist/tools/codebase_search/index.js +8 -7
  82. package/dist/tools/codebase_search/openai.cjs +227 -0
  83. package/dist/tools/codebase_search/openai.cjs.map +1 -1
  84. package/dist/tools/codebase_search/openai.js +4 -3
  85. package/dist/tools/codebase_search/vercel.cjs +227 -0
  86. package/dist/tools/codebase_search/vercel.cjs.map +1 -1
  87. package/dist/tools/codebase_search/vercel.js +4 -3
  88. package/dist/tools/compact/core.cjs +110 -0
  89. package/dist/tools/compact/core.cjs.map +1 -0
  90. package/dist/tools/compact/core.d.ts +37 -0
  91. package/dist/tools/compact/core.js +8 -0
  92. package/dist/tools/compact/core.js.map +1 -0
  93. package/dist/tools/compact/index.cjs +112 -0
  94. package/dist/tools/compact/index.cjs.map +1 -0
  95. package/dist/tools/compact/index.d.ts +4 -0
  96. package/dist/tools/compact/index.js +8 -0
  97. package/dist/tools/compact/index.js.map +1 -0
  98. package/dist/tools/compact/types.cjs +19 -0
  99. package/dist/tools/compact/types.cjs.map +1 -0
  100. package/dist/tools/compact/types.d.ts +60 -0
  101. package/dist/tools/compact/types.js +1 -0
  102. package/dist/tools/compact/types.js.map +1 -0
  103. package/dist/tools/fastapply/anthropic.cjs +241 -1
  104. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  105. package/dist/tools/fastapply/anthropic.js +4 -3
  106. package/dist/tools/fastapply/apply.cjs +230 -1
  107. package/dist/tools/fastapply/apply.cjs.map +1 -1
  108. package/dist/tools/fastapply/apply.js +2 -1
  109. package/dist/tools/fastapply/core.cjs +241 -1
  110. package/dist/tools/fastapply/core.cjs.map +1 -1
  111. package/dist/tools/fastapply/core.js +3 -2
  112. package/dist/tools/fastapply/index.cjs +241 -1
  113. package/dist/tools/fastapply/index.cjs.map +1 -1
  114. package/dist/tools/fastapply/index.d.ts +1 -1
  115. package/dist/tools/fastapply/index.js +9 -8
  116. package/dist/tools/fastapply/openai.cjs +241 -1
  117. package/dist/tools/fastapply/openai.cjs.map +1 -1
  118. package/dist/tools/fastapply/openai.js +4 -3
  119. package/dist/tools/fastapply/vercel.cjs +241 -1
  120. package/dist/tools/fastapply/vercel.cjs.map +1 -1
  121. package/dist/tools/fastapply/vercel.d.ts +1 -1
  122. package/dist/tools/fastapply/vercel.js +4 -3
  123. package/dist/tools/index.cjs +241 -1
  124. package/dist/tools/index.cjs.map +1 -1
  125. package/dist/tools/index.d.ts +1 -1
  126. package/dist/tools/index.js +9 -8
  127. package/dist/tools/utils/resilience.cjs +229 -0
  128. package/dist/tools/utils/resilience.cjs.map +1 -1
  129. package/dist/tools/utils/resilience.js +2 -1
  130. package/dist/tools/warp_grep/agent/runner.cjs +230 -1
  131. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  132. package/dist/tools/warp_grep/agent/runner.js +4 -3
  133. package/dist/tools/warp_grep/anthropic.cjs +230 -1
  134. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  135. package/dist/tools/warp_grep/anthropic.js +6 -5
  136. package/dist/tools/warp_grep/client.cjs +230 -1
  137. package/dist/tools/warp_grep/client.cjs.map +1 -1
  138. package/dist/tools/warp_grep/client.js +5 -4
  139. package/dist/tools/warp_grep/gemini.cjs +230 -1
  140. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  141. package/dist/tools/warp_grep/gemini.js +5 -4
  142. package/dist/tools/warp_grep/gemini.js.map +1 -1
  143. package/dist/tools/warp_grep/harness.js +9 -9
  144. package/dist/tools/warp_grep/index.cjs +230 -1
  145. package/dist/tools/warp_grep/index.cjs.map +1 -1
  146. package/dist/tools/warp_grep/index.js +10 -9
  147. package/dist/tools/warp_grep/openai.cjs +230 -1
  148. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  149. package/dist/tools/warp_grep/openai.js +6 -5
  150. package/dist/tools/warp_grep/providers/local.js +2 -2
  151. package/dist/tools/warp_grep/vercel.cjs +230 -1
  152. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  153. package/dist/tools/warp_grep/vercel.js +6 -5
  154. package/dist/version.cjs +256 -0
  155. package/dist/version.cjs.map +1 -0
  156. package/dist/version.d.ts +3 -0
  157. package/dist/version.js +8 -0
  158. package/dist/version.js.map +1 -0
  159. package/package.json +7 -2
  160. package/dist/chunk-4VWJFZVS.js.map +0 -1
  161. package/dist/chunk-FXBT4UDY.js.map +0 -1
  162. package/dist/chunk-QL7MV3GT.js.map +0 -1
  163. package/dist/{chunk-ZRLEAPZV.js.map → chunk-266SWRHK.js.map} +0 -0
  164. package/dist/{chunk-M5DR2WOZ.js.map → chunk-AI3ZCOCT.js.map} +0 -0
  165. package/dist/{chunk-UNHHRMU7.js.map → chunk-BDKXYMU2.js.map} +0 -0
  166. package/dist/{chunk-G7RSAZIK.js.map → chunk-C3BQUIFE.js.map} +0 -0
  167. package/dist/{chunk-WM77HRKO.js.map → chunk-CIFPLFBQ.js.map} +0 -0
  168. package/dist/{chunk-WVTX3QS6.js.map → chunk-CXP63PHW.js.map} +0 -0
  169. package/dist/{chunk-5IVVJMMX.js.map → chunk-DL3Y3R6A.js.map} +0 -0
  170. package/dist/{chunk-HMQSMEN2.js.map → chunk-EF7ZYLA2.js.map} +0 -0
  171. package/dist/{chunk-EAT5W3SH.js.map → chunk-EZFXR52Q.js.map} +0 -0
  172. package/dist/{chunk-HMAX2FEE.js.map → chunk-FV3R3JGV.js.map} +0 -0
  173. package/dist/{chunk-OUEJ6XEO.js.map → chunk-GNRMDXJA.js.map} +0 -0
  174. package/dist/{chunk-SI2CKRKJ.js.map → chunk-JBIFS33U.js.map} +0 -0
  175. package/dist/{chunk-EMMSRY32.js.map → chunk-L4PK4VC7.js.map} +0 -0
  176. package/dist/{chunk-PR44LEQQ.js.map → chunk-MAAULSSQ.js.map} +0 -0
  177. package/dist/{chunk-K4EO7S2O.js.map → chunk-U5UDFQXK.js.map} +0 -0
  178. package/dist/{chunk-O5DA5V5S.js.map → chunk-W37KJB25.js.map} +0 -0
  179. package/dist/{chunk-ZYPLV3HP.js.map → chunk-WEBUKGPK.js.map} +0 -0
  180. package/dist/{chunk-OOCSNAA5.js.map → chunk-XERAWJ3H.js.map} +0 -0
  181. package/dist/{chunk-Y5BB7JFH.js.map → chunk-YMOTJ6ZP.js.map} +0 -0
  182. package/dist/{vercel-B1GZ_g9N.d.ts → vercel-BTSPdTA-.d.ts} +2 -2
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-YQMPVJ2L.js";
5
5
  import {
6
6
  executeCodebaseSearch
7
- } from "./chunk-WM77HRKO.js";
7
+ } from "./chunk-CIFPLFBQ.js";
8
8
 
9
9
  // tools/codebase_search/openai.ts
10
10
  var codebaseSearchTool = {
@@ -125,4 +125,4 @@ export {
125
125
  getSystemPrompt,
126
126
  openai_default
127
127
  };
128
- //# sourceMappingURL=chunk-ZRLEAPZV.js.map
128
+ //# sourceMappingURL=chunk-266SWRHK.js.map
@@ -1,3 +1,7 @@
1
+ import {
2
+ SDK_VERSION
3
+ } from "./chunk-EJYFE73S.js";
4
+
1
5
  // tools/utils/resilience.ts
2
6
  var DEFAULT_RETRY_CONFIG = {
3
7
  maxRetries: 3,
@@ -17,6 +21,7 @@ async function fetchWithRetry(url, options, retryConfig = {}) {
17
21
  } = retryConfig;
18
22
  let lastError = null;
19
23
  let delay = initialDelay;
24
+ options = { ...options, headers: { "X-Morph-SDK-Version": SDK_VERSION, ...options.headers } };
20
25
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
21
26
  try {
22
27
  const response = await fetch(url, options);
@@ -86,4 +91,4 @@ export {
86
91
  withTimeout,
87
92
  MorphError
88
93
  };
89
- //# sourceMappingURL=chunk-4VWJFZVS.js.map
94
+ //# sourceMappingURL=chunk-3HBZXN6E.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../tools/utils/resilience.ts"],"sourcesContent":["/**\n * Resilience utilities for retry logic and timeout handling\n */\n\nimport { SDK_VERSION } from '../../version.js';\n\nexport interface RetryConfig {\n maxRetries?: number; // Default: 3\n initialDelay?: number; // Default: 1000ms\n maxDelay?: number; // Default: 30000ms\n backoffMultiplier?: number; // Default: 2\n retryableErrors?: string[]; // Default: ['ECONNREFUSED', 'ETIMEDOUT', 'ENOTFOUND']\n onRetry?: (attempt: number, error: Error) => void;\n}\n\nconst DEFAULT_RETRY_CONFIG: Required<Omit<RetryConfig, 'onRetry'>> = {\n maxRetries: 3,\n initialDelay: 1000,\n maxDelay: 30000,\n backoffMultiplier: 2,\n retryableErrors: ['ECONNREFUSED', 'ETIMEDOUT', 'ENOTFOUND'],\n};\n\n/**\n * Retry a fetch request with exponential backoff\n * \n * @param url - Request URL\n * @param options - Fetch options\n * @param retryConfig - Retry configuration\n * @returns Response from fetch\n * \n * @example\n * ```typescript\n * const response = await fetchWithRetry(\n * 'https://api.example.com/data',\n * { method: 'POST', body: JSON.stringify(data) },\n * { maxRetries: 5, initialDelay: 500 }\n * );\n * ```\n */\nexport async function fetchWithRetry(\n url: string,\n options: RequestInit,\n retryConfig: RetryConfig = {}\n): Promise<Response> {\n const {\n maxRetries = DEFAULT_RETRY_CONFIG.maxRetries,\n initialDelay = DEFAULT_RETRY_CONFIG.initialDelay,\n maxDelay = DEFAULT_RETRY_CONFIG.maxDelay,\n backoffMultiplier = DEFAULT_RETRY_CONFIG.backoffMultiplier,\n retryableErrors = DEFAULT_RETRY_CONFIG.retryableErrors,\n onRetry,\n } = retryConfig;\n\n let lastError: Error | null = null;\n let delay = initialDelay;\n\n // Inject SDK version header (caller-provided headers can override)\n options = { ...options, headers: { 'X-Morph-SDK-Version': SDK_VERSION, ...options.headers } };\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n const response = await fetch(url, options);\n \n // Retry on 429 (rate limit) or 503 (service unavailable)\n if (response.status === 429 || response.status === 503) {\n if (attempt < maxRetries) {\n // Check for Retry-After header\n const retryAfter = response.headers.get('Retry-After');\n const waitTime = retryAfter \n ? parseInt(retryAfter) * 1000 \n : Math.min(delay, maxDelay);\n \n const error = new Error(`HTTP ${response.status}: Retrying after ${waitTime}ms`);\n if (onRetry) {\n onRetry(attempt + 1, error);\n }\n \n await sleep(waitTime);\n delay *= backoffMultiplier;\n continue;\n }\n }\n\n return response;\n } catch (error) {\n lastError = error as Error;\n \n // Check if error is retryable\n const isRetryable = retryableErrors.some(errType => \n lastError?.message?.includes(errType)\n );\n\n if (!isRetryable || attempt === maxRetries) {\n throw lastError;\n }\n\n // Exponential backoff\n const waitTime = Math.min(delay, maxDelay);\n if (onRetry) {\n onRetry(attempt + 1, lastError);\n }\n \n await sleep(waitTime);\n delay *= backoffMultiplier;\n }\n }\n\n throw lastError || new Error('Max retries exceeded');\n}\n\n/**\n * Add timeout to any promise\n * \n * @param promise - Promise to wrap with timeout\n * @param timeoutMs - Timeout in milliseconds\n * @param errorMessage - Optional custom error message\n * @returns Promise that rejects if timeout is reached\n * \n * @example\n * ```typescript\n * const result = await withTimeout(\n * fetchData(),\n * 5000,\n * 'Data fetch timed out'\n * );\n * ```\n */\nexport async function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number,\n errorMessage?: string\n): Promise<T> {\n let timeoutId: NodeJS.Timeout | number;\n \n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => {\n reject(new Error(errorMessage || `Operation timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n });\n\n try {\n const result = await Promise.race([promise, timeoutPromise]);\n clearTimeout(timeoutId!);\n return result;\n } catch (error) {\n clearTimeout(timeoutId!);\n throw error;\n }\n}\n\n/**\n * Sleep for specified milliseconds\n */\nfunction sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/**\n * Unified error type for all tools\n */\nexport class MorphError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode?: number,\n public retryable: boolean = false\n ) {\n super(message);\n this.name = 'MorphError';\n }\n}\n\n\n"],"mappings":";;;;;AAeA,IAAM,uBAA+D;AAAA,EACnE,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,iBAAiB,CAAC,gBAAgB,aAAa,WAAW;AAC5D;AAmBA,eAAsB,eACpB,KACA,SACA,cAA2B,CAAC,GACT;AACnB,QAAM;AAAA,IACJ,aAAa,qBAAqB;AAAA,IAClC,eAAe,qBAAqB;AAAA,IACpC,WAAW,qBAAqB;AAAA,IAChC,oBAAoB,qBAAqB;AAAA,IACzC,kBAAkB,qBAAqB;AAAA,IACvC;AAAA,EACF,IAAI;AAEJ,MAAI,YAA0B;AAC9B,MAAI,QAAQ;AAGZ,YAAU,EAAE,GAAG,SAAS,SAAS,EAAE,uBAAuB,aAAa,GAAG,QAAQ,QAAQ,EAAE;AAE5F,WAAS,UAAU,GAAG,WAAW,YAAY,WAAW;AACtD,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,KAAK,OAAO;AAGzC,UAAI,SAAS,WAAW,OAAO,SA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CAAC;AACvD;AAKO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACpC,YACE,SACO,MACA,YACA,YAAqB,OAC5B;AACA,UAAM,OAAO;AAJN;AACA;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
@@ -1,51 +1,54 @@
1
+ import {
2
+ createWarpGrepTool as createWarpGrepTool2
3
+ } from "./chunk-XERAWJ3H.js";
1
4
  import {
2
5
  createWarpGrepTool
3
- } from "./chunk-WVTX3QS6.js";
6
+ } from "./chunk-CXP63PHW.js";
4
7
  import {
5
8
  createWarpGrepTool as createWarpGrepTool3
6
- } from "./chunk-K4EO7S2O.js";
7
- import {
8
- createWarpGrepTool as createWarpGrepTool2
9
- } from "./chunk-OOCSNAA5.js";
9
+ } from "./chunk-U5UDFQXK.js";
10
10
  import {
11
11
  WarpGrepClient
12
- } from "./chunk-G7RSAZIK.js";
12
+ } from "./chunk-C3BQUIFE.js";
13
+ import {
14
+ createCodebaseSearchTool
15
+ } from "./chunk-266SWRHK.js";
13
16
  import {
14
17
  createCodebaseSearchTool as createCodebaseSearchTool3
15
- } from "./chunk-O5DA5V5S.js";
18
+ } from "./chunk-W37KJB25.js";
16
19
  import {
17
20
  createCodebaseSearchTool as createCodebaseSearchTool2
18
- } from "./chunk-OUEJ6XEO.js";
19
- import {
20
- createCodebaseSearchTool
21
- } from "./chunk-ZRLEAPZV.js";
21
+ } from "./chunk-GNRMDXJA.js";
22
22
  import {
23
23
  CodebaseSearchClient
24
- } from "./chunk-WM77HRKO.js";
24
+ } from "./chunk-CIFPLFBQ.js";
25
+ import {
26
+ createEditFileTool
27
+ } from "./chunk-BDKXYMU2.js";
25
28
  import {
26
29
  createEditFileTool as createEditFileTool3
27
- } from "./chunk-HMAX2FEE.js";
30
+ } from "./chunk-FV3R3JGV.js";
28
31
  import {
29
32
  createEditFileTool as createEditFileTool2
30
- } from "./chunk-Y5BB7JFH.js";
31
- import {
32
- createEditFileTool
33
- } from "./chunk-UNHHRMU7.js";
33
+ } from "./chunk-YMOTJ6ZP.js";
34
34
  import {
35
35
  FastApplyClient
36
- } from "./chunk-M5DR2WOZ.js";
36
+ } from "./chunk-AI3ZCOCT.js";
37
37
  import {
38
38
  BrowserClient
39
- } from "./chunk-ZYPLV3HP.js";
39
+ } from "./chunk-WEBUKGPK.js";
40
40
  import {
41
- MorphGit
42
- } from "./chunk-LE66XCOI.js";
41
+ CompactClient
42
+ } from "./chunk-J267T54M.js";
43
43
  import {
44
44
  AnthropicRouter,
45
45
  GeminiRouter,
46
46
  OpenAIRouter,
47
47
  RawRouter
48
- } from "./chunk-EMMSRY32.js";
48
+ } from "./chunk-L4PK4VC7.js";
49
+ import {
50
+ MorphGit
51
+ } from "./chunk-LE66XCOI.js";
49
52
 
50
53
  // tools/github/types.ts
51
54
  var GitHubError = class extends Error {
@@ -550,6 +553,8 @@ var MorphClient = class {
550
553
  anthropic;
551
554
  /** Vercel AI SDK tool factories */
552
555
  vercel;
556
+ /** Responses API with compact tool */
557
+ responses;
553
558
  /**
554
559
  * Create a new Morph SDK client
555
560
  *
@@ -626,6 +631,15 @@ var MorphClient = class {
626
631
  retryConfig: config.retryConfig
627
632
  })
628
633
  };
634
+ const compactClient = new CompactClient({
635
+ morphApiKey: config.apiKey,
636
+ timeout: config.timeout,
637
+ retryConfig: config.retryConfig,
638
+ debug: config.debug
639
+ });
640
+ this.responses = {
641
+ compact: compactClient.compact.bind(compactClient)
642
+ };
629
643
  this.openai = new OpenAIToolFactory(config);
630
644
  this.anthropic = new AnthropicToolFactory(config);
631
645
  this.vercel = new VercelToolFactory(config);
@@ -643,4 +657,4 @@ export {
643
657
  VercelToolFactory,
644
658
  MorphClient
645
659
  };
646
- //# sourceMappingURL=chunk-3T4BGWCV.js.map
660
+ //# sourceMappingURL=chunk-7IZUNRPZ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../tools/github/types.ts","../tools/github/core.ts","../factories/openai.ts","../factories/anthropic.ts","../factories/vercel.ts","../client.ts"],"sourcesContent":["/**\n * GitHub SDK Types\n *\n * Type definitions for the Morph GitHub integration.\n * Users connect GitHub in the Morph dashboard, then use these\n * types to interact with their GitHub repos through the SDK.\n */\n\n// =============================================================================\n// Configuration\n// =============================================================================\n\n/**\n * Configuration for the GitHub client\n */\nexport interface GitHubClientConfig {\n /** Morph API key (defaults to MORPH_API_KEY env var) */\n apiKey?: string;\n /** Default installation ID to use (optional, can be specified per-request) */\n installationId?: string;\n /** Base URL for the Morph API (defaults to https://api.morphllm.com) */\n baseUrl?: string;\n /** Request timeout in milliseconds */\n timeout?: number;\n /** Enable debug logging */\n debug?: boolean;\n}\n\n// =============================================================================\n// Core Types\n// =============================================================================\n\n/**\n * A GitHub App installation (connected GitHub account)\n */\nexport interface Installation {\n /** Installation ID (use this for subsequent requests) */\n id: string;\n /** GitHub account login (username or org name) */\n accountLogin: string;\n /** Account type */\n accountType: \"User\" | \"Organization\";\n /** Custom display name (set in Morph dashboard) */\n displayName?: string;\n /** Whether check runs are disabled (only PR comments posted) */\n disableCheckRun: boolean;\n /** Whether to keep all previous PR comments (vs. replacing with latest) */\n keepCommentHistory: boolean;\n /** Browser automation model used for preview tests */\n model: string;\n}\n\n/**\n * Input for updating installation settings\n */\nexport interface UpdateInstallationInput {\n /** Installation ID to update */\n installationId: string;\n /** Custom display name */\n displayName?: string;\n /** Whether to disable check runs */\n disableCheckRun?: boolean;\n /** Whether to keep comment history */\n keepCommentHistory?: boolean;\n /** Browser automation model */\n model?: string;\n}\n\n/**\n * Site authentication credentials for a repo or project\n */\nexport interface SiteAuth {\n /** Login username or email */\n username: string | null;\n /** Login password */\n password: string | null;\n}\n\n/**\n * A repository with its Morph configuration\n */\nexport interface RepoConfig {\n /** Database UUID — use this for update/remove operations */\n id: string;\n /** GitHub's numeric repo ID */\n githubId: number;\n /** Full name including owner (e.g., \"acme/app\") */\n fullName: string;\n /** Repository name (e.g., \"app\") */\n name: string;\n /** Whether Morph tests are enabled */\n enabled: boolean;\n /** Whether to also test on mobile viewport */\n testMobile: boolean;\n /** Path filter — only trigger tests when files match this prefix */\n pathFilter: string | null;\n /** Custom instructions for the AI agent */\n customInstructions: string | null;\n /** Site authentication credentials */\n auth: SiteAuth | null;\n}\n\n/**\n * Input for updating a repo's configuration\n */\nexport interface UpdateRepoInput {\n /** Repo DB ID (from RepoConfig.id) */\n repoId: string;\n /** Whether Morph tests are enabled */\n enabled?: boolean;\n /** Whether to also test on mobile viewport */\n testMobile?: boolean;\n /** Path filter for conditional triggers */\n pathFilter?: string | null;\n /** Custom instructions for the AI agent */\n customInstructions?: string | null;\n /** Site auth credentials (null to clear) */\n auth?: { username?: string; password?: string; cookies?: unknown } | null;\n}\n\n/**\n * Input for syncing repos from GitHub\n */\nexport interface SyncReposInput {\n /** Installation ID to sync repos for */\n installationId: string;\n}\n\n/**\n * A monorepo sub-project scoped under a repo\n */\nexport interface Project {\n /** Project DB UUID */\n id: string;\n /** Parent repo DB UUID */\n repoId: string;\n /** Project name */\n name: string;\n /** Path filter within the repo */\n pathFilter: string | null;\n /** Whether tests are enabled */\n enabled: boolean;\n /** Whether to test on mobile viewport */\n testMobile: boolean;\n /** Custom instructions for the AI agent */\n customInstructions: string | null;\n /** Site authentication credentials */\n auth: SiteAuth | null;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n}\n\n/**\n * Input for creating a project\n */\nexport interface CreateProjectInput {\n /** Parent repo DB ID */\n repoId: string;\n /** Project name (must be unique within the repo) */\n name: string;\n /** Path filter within the repo (e.g., \"packages/web/\") */\n pathFilter: string;\n /** Custom instructions for the AI agent */\n customInstructions?: string;\n}\n\n/**\n * Input for updating a project\n */\nexport interface UpdateProjectInput {\n /** Project DB ID */\n projectId: string;\n /** Whether tests are enabled */\n enabled?: boolean;\n /** Whether to test on mobile viewport */\n testMobile?: boolean;\n /** Path filter within the repo */\n pathFilter?: string | null;\n /** Custom instructions for the AI agent */\n customInstructions?: string | null;\n /** Site auth credentials (null to clear) */\n auth?: { username?: string; password?: string; cookies?: unknown } | null;\n}\n\n/**\n * Input for listing projects\n */\nexport interface ListProjectsInput {\n /** Parent repo DB ID */\n repoId: string;\n}\n\n/**\n * A GitHub repository\n */\nexport interface Repo {\n /** GitHub's numeric repo ID */\n id: number;\n /** Repository name (e.g., \"app\") */\n name: string;\n /** Full name including owner (e.g., \"acme/app\") */\n fullName: string;\n /** Whether the repo is private */\n private: boolean;\n /** Default branch name */\n defaultBranch?: string;\n}\n\n/**\n * A pull request (basic info)\n */\nexport interface PullRequest {\n /** PR number */\n number: number;\n /** PR title */\n title: string;\n /** PR description/body */\n body: string | null;\n /** PR state */\n state: \"open\" | \"closed\";\n /** Author's GitHub username */\n author: string;\n /** HEAD commit SHA */\n headSha: string;\n /** Base branch name */\n baseBranch: string;\n /** HEAD branch name */\n headBranch: string;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n /** Last update timestamp (ISO 8601) */\n updatedAt: string;\n}\n\n/**\n * A pull request with full context (diff and files)\n */\nexport interface PullRequestWithContext extends PullRequest {\n /** Full unified diff */\n diff: string;\n /** List of changed files with patches */\n files: FileChange[];\n}\n\n/**\n * A file changed in a pull request\n */\nexport interface FileChange {\n /** File path */\n filename: string;\n /** Change status */\n status: \"added\" | \"removed\" | \"modified\" | \"renamed\";\n /** Number of lines added */\n additions: number;\n /** Number of lines deleted */\n deletions: number;\n /** Unified diff patch for this file */\n patch?: string;\n}\n\n/**\n * A deployment (e.g., Vercel preview)\n */\nexport interface Deployment {\n /** Deployment ID */\n id: number;\n /** Commit SHA this deployment is for */\n sha: string;\n /** Environment name (e.g., \"preview\", \"production\") */\n environment: string;\n /** Deployment state */\n state: \"pending\" | \"success\" | \"failure\" | \"error\" | \"inactive\" | \"in_progress\" | \"queued\";\n /** Preview/deployment URL (if available) */\n url: string | null;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n}\n\n/**\n * A comment on a PR/issue\n */\nexport interface Comment {\n /** Comment ID */\n id: number;\n /** Comment body/content */\n body: string;\n /** Author's GitHub username */\n author: string;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n /** Last update timestamp (ISO 8601) */\n updatedAt: string;\n}\n\n/**\n * A GitHub check run (CI status)\n */\nexport interface CheckRun {\n /** Check run ID */\n id: number;\n /** Check run name */\n name: string;\n /** Current status */\n status: \"queued\" | \"in_progress\" | \"completed\";\n /** Conclusion (only set when status is \"completed\") */\n conclusion?:\n | \"success\"\n | \"failure\"\n | \"neutral\"\n | \"cancelled\"\n | \"skipped\"\n | \"timed_out\"\n | \"action_required\";\n /** Start timestamp (ISO 8601) */\n startedAt?: string;\n /** Completion timestamp (ISO 8601) */\n completedAt?: string;\n}\n\n// =============================================================================\n// Input Types\n// =============================================================================\n\n/**\n * Input for listing repositories\n */\nexport interface ListReposInput {\n /** Installation ID to list repos for */\n installationId: string;\n}\n\n/**\n * Input for listing pull requests\n */\nexport interface ListPullRequestsInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Filter by PR state (default: \"open\") */\n state?: \"open\" | \"closed\" | \"all\";\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for getting a single pull request\n */\nexport interface GetPullRequestInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** PR number */\n number: number;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for listing deployments\n */\nexport interface ListDeploymentsInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Filter by commit SHA */\n sha?: string;\n /** Filter by environment name */\n environment?: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for listing comments on a PR\n */\nexport interface ListCommentsInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** PR number */\n pr: number;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for creating a comment\n */\nexport interface CreateCommentInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** PR number */\n pr: number;\n /** Comment body (Markdown supported) */\n body: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for updating a comment\n */\nexport interface UpdateCommentInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Comment ID to update */\n commentId: number;\n /** New comment body */\n body: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for deleting a comment\n */\nexport interface DeleteCommentInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Comment ID to delete */\n commentId: number;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for creating a check run\n */\nexport interface CreateCheckRunInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Commit SHA to create check run for */\n sha: string;\n /** Check run name (e.g., \"Preview Test\") */\n name: string;\n /** Initial status */\n status: \"queued\" | \"in_progress\";\n /** Output title */\n title?: string;\n /** Output summary (Markdown supported) */\n summary?: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for updating a check run\n */\nexport interface UpdateCheckRunInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Check run ID to update */\n checkRunId: number;\n /** New status */\n status?: \"queued\" | \"in_progress\" | \"completed\";\n /** Conclusion (required if status is \"completed\") */\n conclusion?: CheckRun[\"conclusion\"];\n /** Output title */\n title?: string;\n /** Output summary (Markdown supported) */\n summary?: string;\n /** Output text (detailed info, Markdown supported) */\n text?: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n// =============================================================================\n// Error Types\n// =============================================================================\n\n/**\n * Error thrown by GitHub operations\n */\nexport class GitHubError extends Error {\n /** HTTP status code */\n status: number;\n /** Error code from API */\n code?: string;\n\n constructor(message: string, status: number, code?: string) {\n super(message);\n this.name = \"GitHubError\";\n this.status = status;\n this.code = code;\n }\n}\n\n/**\n * Error thrown when no installation is found or specified\n */\nexport class NoInstallationError extends GitHubError {\n constructor(message = \"No GitHub installation found. Connect GitHub at morphllm.com/dashboard/integrations/github\") {\n super(message, 404, \"NO_INSTALLATION\");\n }\n}\n\n/**\n * Error thrown when resource is not found\n */\nexport class NotFoundError extends GitHubError {\n constructor(resource: string) {\n super(`${resource} not found`, 404, \"NOT_FOUND\");\n }\n}\n\n/**\n * Error thrown when user lacks permission\n */\nexport class PermissionError extends GitHubError {\n constructor(message = \"Insufficient permissions for this operation\") {\n super(message, 403, \"PERMISSION_DENIED\");\n }\n}\n","/**\n * GitHub SDK Client\n *\n * Provides access to GitHub repositories, pull requests, deployments,\n * comments, and check runs through the user's connected GitHub account.\n *\n * All operations are proxied through the Morph API - installation tokens\n * are never exposed to the client.\n */\n\nimport type {\n GitHubClientConfig,\n Installation,\n Repo,\n RepoConfig,\n PullRequest,\n PullRequestWithContext,\n Deployment,\n Comment,\n CheckRun,\n Project,\n ListReposInput,\n ListPullRequestsInput,\n GetPullRequestInput,\n ListDeploymentsInput,\n ListCommentsInput,\n CreateCommentInput,\n UpdateCommentInput,\n DeleteCommentInput,\n CreateCheckRunInput,\n UpdateCheckRunInput,\n UpdateInstallationInput,\n UpdateRepoInput,\n SyncReposInput,\n CreateProjectInput,\n UpdateProjectInput,\n ListProjectsInput,\n} from \"./types.js\";\n\nimport { GitHubError, NoInstallationError, NotFoundError, PermissionError } from \"./types.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.morphllm.com\";\nconst DEFAULT_TIMEOUT = 30000;\n\n/**\n * GitHub SDK Client\n *\n * @example\n * ```typescript\n * import { MorphClient } from '@morphllm/morphsdk';\n *\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n *\n * // List installations\n * const installations = await morph.github.installations.list();\n *\n * // Get PR with context\n * const pr = await morph.github.pullRequests.get({\n * owner: \"acme\",\n * repo: \"app\",\n * number: 42\n * });\n * ```\n */\nexport class GitHubClient {\n private apiKey: string;\n private baseUrl: string;\n private timeout: number;\n private debug: boolean;\n private defaultInstallationId?: string;\n\n /** Installation operations */\n public installations: {\n list: () => Promise<Installation[]>;\n get: (installationId: string) => Promise<Installation>;\n update: (input: UpdateInstallationInput) => Promise<Installation>;\n disconnect: (installationId: string) => Promise<{ success: boolean; alreadyDeleted: boolean }>;\n };\n\n /** Repository operations */\n public repos: {\n list: (input: ListReposInput) => Promise<RepoConfig[]>;\n get: (repoId: string) => Promise<RepoConfig>;\n update: (input: UpdateRepoInput) => Promise<RepoConfig>;\n remove: (repoId: string) => Promise<{ success: boolean; alreadyRemoved: boolean }>;\n sync: (input: SyncReposInput) => Promise<{ count: number }>;\n };\n\n /** Project operations (monorepo sub-projects) */\n public projects: {\n list: (input: ListProjectsInput) => Promise<Project[]>;\n create: (input: CreateProjectInput) => Promise<Project>;\n update: (input: UpdateProjectInput) => Promise<Project>;\n delete: (projectId: string) => Promise<{ success: boolean }>;\n };\n\n /** Pull request operations */\n public pullRequests: {\n list: (input: ListPullRequestsInput) => Promise<PullRequest[]>;\n get: (input: GetPullRequestInput) => Promise<PullRequestWithContext>;\n };\n\n /** Deployment operations */\n public deployments: {\n list: (input: ListDeploymentsInput) => Promise<Deployment[]>;\n };\n\n /** Comment operations */\n public comments: {\n list: (input: ListCommentsInput) => Promise<Comment[]>;\n create: (input: CreateCommentInput) => Promise<Comment>;\n update: (input: UpdateCommentInput) => Promise<Comment>;\n delete: (input: DeleteCommentInput) => Promise<void>;\n };\n\n /** Check run operations */\n public checkRuns: {\n create: (input: CreateCheckRunInput) => Promise<CheckRun>;\n update: (input: UpdateCheckRunInput) => Promise<CheckRun>;\n };\n\n /**\n * Get the GitHub App installation URL.\n * Users visit this URL once to install the Morph GitHub App on their account/org.\n */\n public getInstallUrl(): string {\n return \"https://github.com/apps/morph-subagents/installations/new\";\n }\n\n constructor(config: GitHubClientConfig = {}) {\n this.apiKey = config.apiKey || process.env.MORPH_API_KEY || \"\";\n this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;\n this.timeout = config.timeout || DEFAULT_TIMEOUT;\n this.debug = config.debug || false;\n this.defaultInstallationId = config.installationId;\n\n if (!this.apiKey) {\n throw new Error(\"API key required. Set MORPH_API_KEY or pass apiKey in config.\");\n }\n\n // Bind all methods\n this.installations = {\n list: this.listInstallations.bind(this),\n get: this.getInstallation.bind(this),\n update: this.updateInstallation.bind(this),\n disconnect: this.disconnectInstallation.bind(this),\n };\n\n this.repos = {\n list: this.listRepos.bind(this),\n get: this.getRepo.bind(this),\n update: this.updateRepo.bind(this),\n remove: this.removeRepo.bind(this),\n sync: this.syncRepos.bind(this),\n };\n\n this.projects = {\n list: this.listProjects.bind(this),\n create: this.createProject.bind(this),\n update: this.updateProject.bind(this),\n delete: this.deleteProject.bind(this),\n };\n\n this.pullRequests = {\n list: this.listPullRequests.bind(this),\n get: this.getPullRequest.bind(this),\n };\n\n this.deployments = {\n list: this.listDeployments.bind(this),\n };\n\n this.comments = {\n list: this.listComments.bind(this),\n create: this.createComment.bind(this),\n update: this.updateComment.bind(this),\n delete: this.deleteComment.bind(this),\n };\n\n this.checkRuns = {\n create: this.createCheckRun.bind(this),\n update: this.updateCheckRun.bind(this),\n };\n }\n\n /**\n * Make an authenticated API request\n */\n private async request<T>(\n method: string,\n path: string,\n body?: Record<string, unknown>\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n\n if (this.debug) {\n console.log(`[GitHub SDK] ${method} ${path}`, body || \"\");\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const response = await fetch(url, {\n method,\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${this.apiKey}`,\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.error || errorData.detail || errorData.message || response.statusText;\n\n if (this.debug) {\n console.error(`[GitHub SDK] Error ${response.status}:`, message);\n }\n\n // Map to specific error types\n if (response.status === 404) {\n if (message.includes(\"installation\")) {\n throw new NoInstallationError(message);\n }\n throw new NotFoundError(message);\n }\n if (response.status === 403) {\n throw new PermissionError(message);\n }\n throw new GitHubError(message, response.status, errorData.code);\n }\n\n const data = await response.json();\n\n if (this.debug) {\n console.log(`[GitHub SDK] Response:`, JSON.stringify(data).slice(0, 200));\n }\n\n return data as T;\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof GitHubError) {\n throw error;\n }\n\n if (error instanceof Error && error.name === \"AbortError\") {\n throw new GitHubError(\"Request timeout\", 408, \"TIMEOUT\");\n }\n\n throw new GitHubError(\n error instanceof Error ? error.message : \"Unknown error\",\n 500,\n \"UNKNOWN\"\n );\n }\n }\n\n /**\n * Get the installation ID to use for a request\n */\n private getInstallationId(input?: { installationId?: string }): string | undefined {\n return input?.installationId || this.defaultInstallationId;\n }\n\n // ==========================================================================\n // Installations\n // ==========================================================================\n\n private async listInstallations(): Promise<Installation[]> {\n return this.request<Installation[]>(\"GET\", \"/api/v1/github/installations\");\n }\n\n private async getInstallation(installationId: string): Promise<Installation> {\n return this.request<Installation>(\"GET\", `/api/v1/github/installations/${installationId}`);\n }\n\n private async updateInstallation(input: UpdateInstallationInput): Promise<Installation> {\n if (this.debug) console.log(\"[GitHub SDK] updateInstallation\", input.installationId);\n const { installationId, ...body } = input;\n return this.request<Installation>(\"PATCH\", `/api/v1/github/installations/${installationId}`, body);\n }\n\n private async disconnectInstallation(installationId: string): Promise<{ success: boolean; alreadyDeleted: boolean }> {\n if (this.debug) console.log(\"[GitHub SDK] disconnectInstallation\", installationId);\n return this.request<{ success: boolean; alreadyDeleted: boolean }>(\"DELETE\", `/api/v1/github/installations/${installationId}`);\n }\n\n // ==========================================================================\n // Repositories\n // ==========================================================================\n\n private async listRepos(input: ListReposInput): Promise<RepoConfig[]> {\n const installationId = input.installationId || this.defaultInstallationId;\n if (!installationId) {\n throw new NoInstallationError(\"installationId required. Call installations.list() first.\");\n }\n return this.request<RepoConfig[]>(\"GET\", `/api/v1/github/installations/${installationId}/repos`);\n }\n\n private async getRepo(repoId: string): Promise<RepoConfig> {\n if (this.debug) console.log(\"[GitHub SDK] getRepo\", repoId);\n return this.request<RepoConfig>(\"GET\", `/api/v1/github/repos/${repoId}`);\n }\n\n private async updateRepo(input: UpdateRepoInput): Promise<RepoConfig> {\n if (this.debug) console.log(\"[GitHub SDK] updateRepo\", input.repoId);\n const { repoId, ...body } = input;\n return this.request<RepoConfig>(\"PATCH\", `/api/v1/github/repos/${repoId}`, body);\n }\n\n private async removeRepo(repoId: string): Promise<{ success: boolean; alreadyRemoved: boolean }> {\n if (this.debug) console.log(\"[GitHub SDK] removeRepo\", repoId);\n return this.request<{ success: boolean; alreadyRemoved: boolean }>(\"DELETE\", `/api/v1/github/repos/${repoId}`);\n }\n\n private async syncRepos(input: SyncReposInput): Promise<{ count: number }> {\n const installationId = input.installationId || this.defaultInstallationId;\n if (!installationId) {\n throw new NoInstallationError(\"installationId required. Call installations.list() first.\");\n }\n if (this.debug) console.log(\"[GitHub SDK] syncRepos\", installationId);\n return this.request<{ count: number }>(\"POST\", `/api/v1/github/installations/${installationId}/repos/sync`);\n }\n\n // ==========================================================================\n // Projects (monorepo sub-projects)\n // ==========================================================================\n\n private async listProjects(input: ListProjectsInput): Promise<Project[]> {\n if (this.debug) console.log(\"[GitHub SDK] listProjects\", input.repoId);\n return this.request<Project[]>(\"GET\", `/api/v1/github/repos/${input.repoId}/projects`);\n }\n\n private async createProject(input: CreateProjectInput): Promise<Project> {\n if (this.debug) console.log(\"[GitHub SDK] createProject\", input.repoId, input.name);\n const { repoId, ...body } = input;\n return this.request<Project>(\"POST\", `/api/v1/github/repos/${repoId}/projects`, body);\n }\n\n private async updateProject(input: UpdateProjectInput): Promise<Project> {\n if (this.debug) console.log(\"[GitHub SDK] updateProject\", input.projectId);\n const { projectId, ...body } = input;\n return this.request<Project>(\"PATCH\", `/api/v1/github/projects/${projectId}`, body);\n }\n\n private async deleteProject(projectId: string): Promise<{ success: boolean }> {\n if (this.debug) console.log(\"[GitHub SDK] deleteProject\", projectId);\n return this.request<{ success: boolean }>(\"DELETE\", `/api/v1/github/projects/${projectId}`);\n }\n\n // ==========================================================================\n // Pull Requests\n // ==========================================================================\n\n private async listPullRequests(input: ListPullRequestsInput): Promise<PullRequest[]> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(input.state && { state: input.state }),\n ...(installationId && { installationId }),\n });\n return this.request<PullRequest[]>(\"GET\", `/api/v1/github/pulls?${params}`);\n }\n\n private async getPullRequest(input: GetPullRequestInput): Promise<PullRequestWithContext> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(installationId && { installationId }),\n });\n return this.request<PullRequestWithContext>(\n \"GET\",\n `/api/v1/github/pulls/${input.number}?${params}`\n );\n }\n\n // ==========================================================================\n // Deployments\n // ==========================================================================\n\n private async listDeployments(input: ListDeploymentsInput): Promise<Deployment[]> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(input.sha && { sha: input.sha }),\n ...(input.environment && { environment: input.environment }),\n ...(installationId && { installationId }),\n });\n return this.request<Deployment[]>(\"GET\", `/api/v1/github/deployments?${params}`);\n }\n\n // ==========================================================================\n // Comments\n // ==========================================================================\n\n private async listComments(input: ListCommentsInput): Promise<Comment[]> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n pr: String(input.pr),\n ...(installationId && { installationId }),\n });\n return this.request<Comment[]>(\"GET\", `/api/v1/github/comments?${params}`);\n }\n\n private async createComment(input: CreateCommentInput): Promise<Comment> {\n const installationId = this.getInstallationId(input);\n return this.request<Comment>(\"POST\", \"/api/v1/github/comments\", {\n owner: input.owner,\n repo: input.repo,\n pr: input.pr,\n body: input.body,\n ...(installationId && { installationId }),\n });\n }\n\n private async updateComment(input: UpdateCommentInput): Promise<Comment> {\n const installationId = this.getInstallationId(input);\n return this.request<Comment>(\"PATCH\", `/api/v1/github/comments/${input.commentId}`, {\n owner: input.owner,\n repo: input.repo,\n body: input.body,\n ...(installationId && { installationId }),\n });\n }\n\n private async deleteComment(input: DeleteCommentInput): Promise<void> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(installationId && { installationId }),\n });\n await this.request<void>(\"DELETE\", `/api/v1/github/comments/${input.commentId}?${params}`);\n }\n\n // ==========================================================================\n // Check Runs\n // ==========================================================================\n\n private async createCheckRun(input: CreateCheckRunInput): Promise<CheckRun> {\n const installationId = this.getInstallationId(input);\n return this.request<CheckRun>(\"POST\", \"/api/v1/github/check-runs\", {\n owner: input.owner,\n repo: input.repo,\n sha: input.sha,\n name: input.name,\n status: input.status,\n ...(input.title && { title: input.title }),\n ...(input.summary && { summary: input.summary }),\n ...(installationId && { installationId }),\n });\n }\n\n private async updateCheckRun(input: UpdateCheckRunInput): Promise<CheckRun> {\n const installationId = this.getInstallationId(input);\n return this.request<CheckRun>(\"PATCH\", `/api/v1/github/check-runs/${input.checkRunId}`, {\n owner: input.owner,\n repo: input.repo,\n ...(input.status && { status: input.status }),\n ...(input.conclusion && { conclusion: input.conclusion }),\n ...(input.title && { title: input.title }),\n ...(input.summary && { summary: input.summary }),\n ...(input.text && { text: input.text }),\n ...(installationId && { installationId }),\n });\n }\n}\n","/**\n * OpenAI Tool Factory for MorphClient\n * \n * Creates OpenAI-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool } from '../tools/warp_grep/openai.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/openai.js';\nimport { createEditFileTool } from '../tools/fastapply/openai.js';\nimport type { WarpGrepToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\n\n/**\n * Factory for creating OpenAI-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.openai.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.openai.createEditFileTool({ baseDir: './src' });\n * \n * // Use with OpenAI client\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [grepTool, searchTool, editTool],\n * messages: [{ role: 'user', content: 'Find and fix the bug' }]\n * });\n * ```\n */\nexport class OpenAIToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create an OpenAI-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an OpenAI-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an OpenAI-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Anthropic Tool Factory for MorphClient\n * \n * Creates Anthropic-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool } from '../tools/warp_grep/anthropic.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/anthropic.js';\nimport { createEditFileTool } from '../tools/fastapply/anthropic.js';\nimport type { WarpGrepToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\n\n/**\n * Factory for creating Anthropic-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.anthropic.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.anthropic.createEditFileTool({ baseDir: './src' });\n * \n * // Use with Anthropic client\n * const response = await anthropic.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [grepTool, searchTool, editTool],\n * messages: [{ role: 'user', content: 'Find and fix the bug' }]\n * });\n * ```\n */\nexport class AnthropicToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create an Anthropic-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n\n }\n\n /**\n * Create an Anthropic-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an Anthropic-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Vercel AI SDK Tool Factory for MorphClient\n * \n * Creates Vercel AI SDK-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool } from '../tools/warp_grep/vercel.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/vercel.js';\nimport { createEditFileTool } from '../tools/fastapply/vercel.js';\nimport type { WarpGrepToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\n\n/**\n * Factory for creating Vercel AI SDK-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.vercel.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.vercel.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });\n * \n * // Use with Vercel AI SDK\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { grep: grepTool, search: searchTool, edit: editTool },\n * prompt: 'Find and fix the bug'\n * });\n * ```\n */\nexport class VercelToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create a Vercel AI SDK-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create a Vercel AI SDK-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create a Vercel AI SDK-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Unified Morph SDK Client\n * \n * Provides access to all Morph tools through a single interface\n * \n * @example\n * ```typescript\n * import { MorphClient } from '@morphllm/morphsdk';\n * \n * const morph = new MorphClient({ \n * apiKey: process.env.MORPH_API_KEY,\n * debug: true,\n * timeout: 60000\n * });\n * \n * // Direct execution\n * await morph.fastApply.execute({ target_filepath: 'src/index.ts', ... });\n * await morph.warpGrep.execute({ query: 'Find auth', repoRoot: '.' });\n * await morph.codebaseSearch.search({ query: 'auth logic', repoId: 'x' });\n * \n * // Tool creation for AI agents (API key inherited)\n * const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'x' });\n * const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });\n * \n * // Use tools with OpenAI\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [grepTool],\n * messages: [{ role: 'user', content: 'Find the bug' }]\n * });\n * ```\n */\n\nimport type { RetryConfig } from './tools/utils/resilience.js';\nimport { FastApplyClient } from './tools/fastapply/core.js';\nimport { CodebaseSearchClient } from './tools/codebase_search/core.js';\nimport { BrowserClient } from './tools/browser/core.js';\nimport { WarpGrepClient } from './tools/warp_grep/client.js';\nimport { GitHubClient } from './tools/github/core.js';\nimport { MorphGit } from './git/index.js';\nimport { OpenAIRouter, AnthropicRouter, GeminiRouter, RawRouter } from './modelrouter/core.js';\nimport { OpenAIToolFactory, AnthropicToolFactory, VercelToolFactory } from './factories/index.js';\n\n/**\n * Configuration for the MorphClient\n */\nexport interface MorphClientConfig {\n /** Morph API key for authentication (defaults to MORPH_API_KEY env var) */\n apiKey?: string;\n /** Enable debug logging across all tools */\n debug?: boolean;\n /** Default timeout in milliseconds for API requests */\n timeout?: number;\n /** Retry configuration for failed requests */\n retryConfig?: RetryConfig;\n /** GitHub-specific configuration */\n github?: {\n /** Default installation ID for GitHub operations */\n installationId?: string;\n };\n}\n\n/**\n * Unified Morph SDK Client\n * \n * Provides access to all Morph tools through a single interface:\n * - fastApply: AI-powered file editing with intelligent merging\n * - codebaseSearch: Semantic code search\n * - warpGrep: Fast code search with ripgrep\n * - browser: AI-powered browser automation\n * - git: Version control operations\n * - routers: Intelligent model selection (OpenAI, Anthropic, Gemini)\n * - openai/anthropic/vercel: Tool factories for agent frameworks\n */\nexport class MorphClient {\n /** Client configuration */\n public config: MorphClientConfig;\n\n /** FastApply tool for editing files with AI-powered merge */\n public fastApply: FastApplyClient;\n\n /** CodebaseSearch tool for semantic code search */\n public codebaseSearch: CodebaseSearchClient;\n\n /** WarpGrep tool for fast code search using ripgrep */\n public warpGrep: WarpGrepClient;\n\n /** Browser tool for AI-powered browser automation */\n public browser: BrowserClient;\n\n /** GitHub tool for PR context, comments, and check runs */\n public github: GitHubClient;\n\n /** Git tool for version control operations */\n public git: MorphGit;\n\n /** Model routers for intelligent model selection */\n public routers: {\n openai: OpenAIRouter;\n anthropic: AnthropicRouter;\n gemini: GeminiRouter;\n raw: RawRouter;\n };\n\n /** OpenAI-compatible tool factories */\n public openai: OpenAIToolFactory;\n\n /** Anthropic-compatible tool factories */\n public anthropic: AnthropicToolFactory;\n\n /** Vercel AI SDK tool factories */\n public vercel: VercelToolFactory;\n\n /**\n * Create a new Morph SDK client\n * \n * @param config - Client configuration (apiKey, debug, timeout, retryConfig)\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ \n * apiKey: process.env.MORPH_API_KEY,\n * debug: true,\n * timeout: 60000\n * });\n * ```\n */\n constructor(config: MorphClientConfig = {}) {\n this.config = config;\n\n // Initialize all sub-clients with shared config\n this.fastApply = new FastApplyClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.codebaseSearch = new CodebaseSearchClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.warpGrep = new WarpGrepClient({\n morphApiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.browser = new BrowserClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.github = new GitHubClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n installationId: config.github?.installationId,\n });\n\n this.git = new MorphGit({\n apiKey: config.apiKey,\n retryConfig: config.retryConfig,\n });\n\n this.routers = {\n openai: new OpenAIRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n anthropic: new AnthropicRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n gemini: new GeminiRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n raw: new RawRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n };\n\n // Initialize tool factories\n this.openai = new OpenAIToolFactory(config);\n this.anthropic = new AnthropicToolFactory(config);\n this.vercel = new VercelToolFactory(config);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAweO,IAAM,cAAN,cAA0B,MAAM;AAAA;AAAA,EAErC;AAAA;AAAA,EAEA;AAAA,EAEA,YAAY,SAAiB,QAAgB,MAAe;AAC1D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,YAAY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,IAAI,gBAAgB;AAAA,QAC7B,QAAQ,OAAO;AAAA,QACf,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,aAAa,OAAO;AAAA,MACtB,CAAC;AAAA,MACD,QAAQ,IAAI,aAAa;AAAA,QACvB,QAAQ,OAAO;AAAA,QACf,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,aAAa,OAAO;AAAA,MACtB,CAAC;AAAA,MACD,KAAK,IAAI,UAAU;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,aAAa,OAAO;AAAA,MACtB,CAAC;AAAA,IACH;AAGA,SAAK,SAAS,IAAI,kBAAkB,MAAM;AAC1C,SAAK,YAAY,IAAI,qBAAqB,MAAM;AAChD,SAAK,SAAS,IAAI,kBAAkB,MAAM;AAAA,EAC5C;AACF;","names":["createWarpGrepTool","createCodebaseSearchTool","createEditFileTool","createWarpGrepTool","createCodebaseSearchTool","createEditFileTool"]}
1
+ {"version":3,"sources":["../tools/github/types.ts","../tools/github/core.ts","../factories/openai.ts","../factories/anthropic.ts","../factories/vercel.ts","../client.ts"],"sourcesContent":["/**\n * GitHub SDK Types\n *\n * Type definitions for the Morph GitHub integration.\n * Users connect GitHub in the Morph dashboard, then use these\n * types to interact with their GitHub repos through the SDK.\n */\n\n// =============================================================================\n// Configuration\n// =============================================================================\n\n/**\n * Configuration for the GitHub client\n */\nexport interface GitHubClientConfig {\n /** Morph API key (defaults to MORPH_API_KEY env var) */\n apiKey?: string;\n /** Default installation ID to use (optional, can be specified per-request) */\n installationId?: string;\n /** Base URL for the Morph API (defaults to https://api.morphllm.com) */\n baseUrl?: string;\n /** Request timeout in milliseconds */\n timeout?: number;\n /** Enable debug logging */\n debug?: boolean;\n}\n\n// =============================================================================\n// Core Types\n// =============================================================================\n\n/**\n * A GitHub App installation (connected GitHub account)\n */\nexport interface Installation {\n /** Installation ID (use this for subsequent requests) */\n id: string;\n /** GitHub account login (username or org name) */\n accountLogin: string;\n /** Account type */\n accountType: \"User\" | \"Organization\";\n /** Custom display name (set in Morph dashboard) */\n displayName?: string;\n /** Whether check runs are disabled (only PR comments posted) */\n disableCheckRun: boolean;\n /** Whether to keep all previous PR comments (vs. replacing with latest) */\n keepCommentHistory: boolean;\n /** Browser automation model used for preview tests */\n model: string;\n}\n\n/**\n * Input for updating installation settings\n */\nexport interface UpdateInstallationInput {\n /** Installation ID to update */\n installationId: string;\n /** Custom display name */\n displayName?: string;\n /** Whether to disable check runs */\n disableCheckRun?: boolean;\n /** Whether to keep comment history */\n keepCommentHistory?: boolean;\n /** Browser automation model */\n model?: string;\n}\n\n/**\n * Site authentication credentials for a repo or project\n */\nexport interface SiteAuth {\n /** Login username or email */\n username: string | null;\n /** Login password */\n password: string | null;\n}\n\n/**\n * A repository with its Morph configuration\n */\nexport interface RepoConfig {\n /** Database UUID — use this for update/remove operations */\n id: string;\n /** GitHub's numeric repo ID */\n githubId: number;\n /** Full name including owner (e.g., \"acme/app\") */\n fullName: string;\n /** Repository name (e.g., \"app\") */\n name: string;\n /** Whether Morph tests are enabled */\n enabled: boolean;\n /** Whether to also test on mobile viewport */\n testMobile: boolean;\n /** Path filter — only trigger tests when files match this prefix */\n pathFilter: string | null;\n /** Custom instructions for the AI agent */\n customInstructions: string | null;\n /** Site authentication credentials */\n auth: SiteAuth | null;\n}\n\n/**\n * Input for updating a repo's configuration\n */\nexport interface UpdateRepoInput {\n /** Repo DB ID (from RepoConfig.id) */\n repoId: string;\n /** Whether Morph tests are enabled */\n enabled?: boolean;\n /** Whether to also test on mobile viewport */\n testMobile?: boolean;\n /** Path filter for conditional triggers */\n pathFilter?: string | null;\n /** Custom instructions for the AI agent */\n customInstructions?: string | null;\n /** Site auth credentials (null to clear) */\n auth?: { username?: string; password?: string; cookies?: unknown } | null;\n}\n\n/**\n * Input for syncing repos from GitHub\n */\nexport interface SyncReposInput {\n /** Installation ID to sync repos for */\n installationId: string;\n}\n\n/**\n * A monorepo sub-project scoped under a repo\n */\nexport interface Project {\n /** Project DB UUID */\n id: string;\n /** Parent repo DB UUID */\n repoId: string;\n /** Project name */\n name: string;\n /** Path filter within the repo */\n pathFilter: string | null;\n /** Whether tests are enabled */\n enabled: boolean;\n /** Whether to test on mobile viewport */\n testMobile: boolean;\n /** Custom instructions for the AI agent */\n customInstructions: string | null;\n /** Site authentication credentials */\n auth: SiteAuth | null;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n}\n\n/**\n * Input for creating a project\n */\nexport interface CreateProjectInput {\n /** Parent repo DB ID */\n repoId: string;\n /** Project name (must be unique within the repo) */\n name: string;\n /** Path filter within the repo (e.g., \"packages/web/\") */\n pathFilter: string;\n /** Custom instructions for the AI agent */\n customInstructions?: string;\n}\n\n/**\n * Input for updating a project\n */\nexport interface UpdateProjectInput {\n /** Project DB ID */\n projectId: string;\n /** Whether tests are enabled */\n enabled?: boolean;\n /** Whether to test on mobile viewport */\n testMobile?: boolean;\n /** Path filter within the repo */\n pathFilter?: string | null;\n /** Custom instructions for the AI agent */\n customInstructions?: string | null;\n /** Site auth credentials (null to clear) */\n auth?: { username?: string; password?: string; cookies?: unknown } | null;\n}\n\n/**\n * Input for listing projects\n */\nexport interface ListProjectsInput {\n /** Parent repo DB ID */\n repoId: string;\n}\n\n/**\n * A GitHub repository\n */\nexport interface Repo {\n /** GitHub's numeric repo ID */\n id: number;\n /** Repository name (e.g., \"app\") */\n name: string;\n /** Full name including owner (e.g., \"acme/app\") */\n fullName: string;\n /** Whether the repo is private */\n private: boolean;\n /** Default branch name */\n defaultBranch?: string;\n}\n\n/**\n * A pull request (basic info)\n */\nexport interface PullRequest {\n /** PR number */\n number: number;\n /** PR title */\n title: string;\n /** PR description/body */\n body: string | null;\n /** PR state */\n state: \"open\" | \"closed\";\n /** Author's GitHub username */\n author: string;\n /** HEAD commit SHA */\n headSha: string;\n /** Base branch name */\n baseBranch: string;\n /** HEAD branch name */\n headBranch: string;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n /** Last update timestamp (ISO 8601) */\n updatedAt: string;\n}\n\n/**\n * A pull request with full context (diff and files)\n */\nexport interface PullRequestWithContext extends PullRequest {\n /** Full unified diff */\n diff: string;\n /** List of changed files with patches */\n files: FileChange[];\n}\n\n/**\n * A file changed in a pull request\n */\nexport interface FileChange {\n /** File path */\n filename: string;\n /** Change status */\n status: \"added\" | \"removed\" | \"modified\" | \"renamed\";\n /** Number of lines added */\n additions: number;\n /** Number of lines deleted */\n deletions: number;\n /** Unified diff patch for this file */\n patch?: string;\n}\n\n/**\n * A deployment (e.g., Vercel preview)\n */\nexport interface Deployment {\n /** Deployment ID */\n id: number;\n /** Commit SHA this deployment is for */\n sha: string;\n /** Environment name (e.g., \"preview\", \"production\") */\n environment: string;\n /** Deployment state */\n state: \"pending\" | \"success\" | \"failure\" | \"error\" | \"inactive\" | \"in_progress\" | \"queued\";\n /** Preview/deployment URL (if available) */\n url: string | null;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n}\n\n/**\n * A comment on a PR/issue\n */\nexport interface Comment {\n /** Comment ID */\n id: number;\n /** Comment body/content */\n body: string;\n /** Author's GitHub username */\n author: string;\n /** Creation timestamp (ISO 8601) */\n createdAt: string;\n /** Last update timestamp (ISO 8601) */\n updatedAt: string;\n}\n\n/**\n * A GitHub check run (CI status)\n */\nexport interface CheckRun {\n /** Check run ID */\n id: number;\n /** Check run name */\n name: string;\n /** Current status */\n status: \"queued\" | \"in_progress\" | \"completed\";\n /** Conclusion (only set when status is \"completed\") */\n conclusion?:\n | \"success\"\n | \"failure\"\n | \"neutral\"\n | \"cancelled\"\n | \"skipped\"\n | \"timed_out\"\n | \"action_required\";\n /** Start timestamp (ISO 8601) */\n startedAt?: string;\n /** Completion timestamp (ISO 8601) */\n completedAt?: string;\n}\n\n// =============================================================================\n// Input Types\n// =============================================================================\n\n/**\n * Input for listing repositories\n */\nexport interface ListReposInput {\n /** Installation ID to list repos for */\n installationId: string;\n}\n\n/**\n * Input for listing pull requests\n */\nexport interface ListPullRequestsInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Filter by PR state (default: \"open\") */\n state?: \"open\" | \"closed\" | \"all\";\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for getting a single pull request\n */\nexport interface GetPullRequestInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** PR number */\n number: number;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for listing deployments\n */\nexport interface ListDeploymentsInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Filter by commit SHA */\n sha?: string;\n /** Filter by environment name */\n environment?: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for listing comments on a PR\n */\nexport interface ListCommentsInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** PR number */\n pr: number;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for creating a comment\n */\nexport interface CreateCommentInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** PR number */\n pr: number;\n /** Comment body (Markdown supported) */\n body: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for updating a comment\n */\nexport interface UpdateCommentInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Comment ID to update */\n commentId: number;\n /** New comment body */\n body: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for deleting a comment\n */\nexport interface DeleteCommentInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Comment ID to delete */\n commentId: number;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for creating a check run\n */\nexport interface CreateCheckRunInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Commit SHA to create check run for */\n sha: string;\n /** Check run name (e.g., \"Preview Test\") */\n name: string;\n /** Initial status */\n status: \"queued\" | \"in_progress\";\n /** Output title */\n title?: string;\n /** Output summary (Markdown supported) */\n summary?: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n/**\n * Input for updating a check run\n */\nexport interface UpdateCheckRunInput {\n /** Repository owner */\n owner: string;\n /** Repository name */\n repo: string;\n /** Check run ID to update */\n checkRunId: number;\n /** New status */\n status?: \"queued\" | \"in_progress\" | \"completed\";\n /** Conclusion (required if status is \"completed\") */\n conclusion?: CheckRun[\"conclusion\"];\n /** Output title */\n title?: string;\n /** Output summary (Markdown supported) */\n summary?: string;\n /** Output text (detailed info, Markdown supported) */\n text?: string;\n /** Installation ID (uses default if not specified) */\n installationId?: string;\n}\n\n// =============================================================================\n// Error Types\n// =============================================================================\n\n/**\n * Error thrown by GitHub operations\n */\nexport class GitHubError extends Error {\n /** HTTP status code */\n status: number;\n /** Error code from API */\n code?: string;\n\n constructor(message: string, status: number, code?: string) {\n super(message);\n this.name = \"GitHubError\";\n this.status = status;\n this.code = code;\n }\n}\n\n/**\n * Error thrown when no installation is found or specified\n */\nexport class NoInstallationError extends GitHubError {\n constructor(message = \"No GitHub installation found. Connect GitHub at morphllm.com/dashboard/integrations/github\") {\n super(message, 404, \"NO_INSTALLATION\");\n }\n}\n\n/**\n * Error thrown when resource is not found\n */\nexport class NotFoundError extends GitHubError {\n constructor(resource: string) {\n super(`${resource} not found`, 404, \"NOT_FOUND\");\n }\n}\n\n/**\n * Error thrown when user lacks permission\n */\nexport class PermissionError extends GitHubError {\n constructor(message = \"Insufficient permissions for this operation\") {\n super(message, 403, \"PERMISSION_DENIED\");\n }\n}\n","/**\n * GitHub SDK Client\n *\n * Provides access to GitHub repositories, pull requests, deployments,\n * comments, and check runs through the user's connected GitHub account.\n *\n * All operations are proxied through the Morph API - installation tokens\n * are never exposed to the client.\n */\n\nimport type {\n GitHubClientConfig,\n Installation,\n Repo,\n RepoConfig,\n PullRequest,\n PullRequestWithContext,\n Deployment,\n Comment,\n CheckRun,\n Project,\n ListReposInput,\n ListPullRequestsInput,\n GetPullRequestInput,\n ListDeploymentsInput,\n ListCommentsInput,\n CreateCommentInput,\n UpdateCommentInput,\n DeleteCommentInput,\n CreateCheckRunInput,\n UpdateCheckRunInput,\n UpdateInstallationInput,\n UpdateRepoInput,\n SyncReposInput,\n CreateProjectInput,\n UpdateProjectInput,\n ListProjectsInput,\n} from \"./types.js\";\n\nimport { GitHubError, NoInstallationError, NotFoundError, PermissionError } from \"./types.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.morphllm.com\";\nconst DEFAULT_TIMEOUT = 30000;\n\n/**\n * GitHub SDK Client\n *\n * @example\n * ```typescript\n * import { MorphClient } from '@morphllm/morphsdk';\n *\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n *\n * // List installations\n * const installations = await morph.github.installations.list();\n *\n * // Get PR with context\n * const pr = await morph.github.pullRequests.get({\n * owner: \"acme\",\n * repo: \"app\",\n * number: 42\n * });\n * ```\n */\nexport class GitHubClient {\n private apiKey: string;\n private baseUrl: string;\n private timeout: number;\n private debug: boolean;\n private defaultInstallationId?: string;\n\n /** Installation operations */\n public installations: {\n list: () => Promise<Installation[]>;\n get: (installationId: string) => Promise<Installation>;\n update: (input: UpdateInstallationInput) => Promise<Installation>;\n disconnect: (installationId: string) => Promise<{ success: boolean; alreadyDeleted: boolean }>;\n };\n\n /** Repository operations */\n public repos: {\n list: (input: ListReposInput) => Promise<RepoConfig[]>;\n get: (repoId: string) => Promise<RepoConfig>;\n update: (input: UpdateRepoInput) => Promise<RepoConfig>;\n remove: (repoId: string) => Promise<{ success: boolean; alreadyRemoved: boolean }>;\n sync: (input: SyncReposInput) => Promise<{ count: number }>;\n };\n\n /** Project operations (monorepo sub-projects) */\n public projects: {\n list: (input: ListProjectsInput) => Promise<Project[]>;\n create: (input: CreateProjectInput) => Promise<Project>;\n update: (input: UpdateProjectInput) => Promise<Project>;\n delete: (projectId: string) => Promise<{ success: boolean }>;\n };\n\n /** Pull request operations */\n public pullRequests: {\n list: (input: ListPullRequestsInput) => Promise<PullRequest[]>;\n get: (input: GetPullRequestInput) => Promise<PullRequestWithContext>;\n };\n\n /** Deployment operations */\n public deployments: {\n list: (input: ListDeploymentsInput) => Promise<Deployment[]>;\n };\n\n /** Comment operations */\n public comments: {\n list: (input: ListCommentsInput) => Promise<Comment[]>;\n create: (input: CreateCommentInput) => Promise<Comment>;\n update: (input: UpdateCommentInput) => Promise<Comment>;\n delete: (input: DeleteCommentInput) => Promise<void>;\n };\n\n /** Check run operations */\n public checkRuns: {\n create: (input: CreateCheckRunInput) => Promise<CheckRun>;\n update: (input: UpdateCheckRunInput) => Promise<CheckRun>;\n };\n\n /**\n * Get the GitHub App installation URL.\n * Users visit this URL once to install the Morph GitHub App on their account/org.\n */\n public getInstallUrl(): string {\n return \"https://github.com/apps/morph-subagents/installations/new\";\n }\n\n constructor(config: GitHubClientConfig = {}) {\n this.apiKey = config.apiKey || process.env.MORPH_API_KEY || \"\";\n this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;\n this.timeout = config.timeout || DEFAULT_TIMEOUT;\n this.debug = config.debug || false;\n this.defaultInstallationId = config.installationId;\n\n if (!this.apiKey) {\n throw new Error(\"API key required. Set MORPH_API_KEY or pass apiKey in config.\");\n }\n\n // Bind all methods\n this.installations = {\n list: this.listInstallations.bind(this),\n get: this.getInstallation.bind(this),\n update: this.updateInstallation.bind(this),\n disconnect: this.disconnectInstallation.bind(this),\n };\n\n this.repos = {\n list: this.listRepos.bind(this),\n get: this.getRepo.bind(this),\n update: this.updateRepo.bind(this),\n remove: this.removeRepo.bind(this),\n sync: this.syncRepos.bind(this),\n };\n\n this.projects = {\n list: this.listProjects.bind(this),\n create: this.createProject.bind(this),\n update: this.updateProject.bind(this),\n delete: this.deleteProject.bind(this),\n };\n\n this.pullRequests = {\n list: this.listPullRequests.bind(this),\n get: this.getPullRequest.bind(this),\n };\n\n this.deployments = {\n list: this.listDeployments.bind(this),\n };\n\n this.comments = {\n list: this.listComments.bind(this),\n create: this.createComment.bind(this),\n update: this.updateComment.bind(this),\n delete: this.deleteComment.bind(this),\n };\n\n this.checkRuns = {\n create: this.createCheckRun.bind(this),\n update: this.updateCheckRun.bind(this),\n };\n }\n\n /**\n * Make an authenticated API request\n */\n private async request<T>(\n method: string,\n path: string,\n body?: Record<string, unknown>\n ): Promise<T> {\n const url = `${this.baseUrl}${path}`;\n\n if (this.debug) {\n console.log(`[GitHub SDK] ${method} ${path}`, body || \"\");\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const response = await fetch(url, {\n method,\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${this.apiKey}`,\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n const message = errorData.error || errorData.detail || errorData.message || response.statusText;\n\n if (this.debug) {\n console.error(`[GitHub SDK] Error ${response.status}:`, message);\n }\n\n // Map to specific error types\n if (response.status === 404) {\n if (message.includes(\"installation\")) {\n throw new NoInstallationError(message);\n }\n throw new NotFoundError(message);\n }\n if (response.status === 403) {\n throw new PermissionError(message);\n }\n throw new GitHubError(message, response.status, errorData.code);\n }\n\n const data = await response.json();\n\n if (this.debug) {\n console.log(`[GitHub SDK] Response:`, JSON.stringify(data).slice(0, 200));\n }\n\n return data as T;\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof GitHubError) {\n throw error;\n }\n\n if (error instanceof Error && error.name === \"AbortError\") {\n throw new GitHubError(\"Request timeout\", 408, \"TIMEOUT\");\n }\n\n throw new GitHubError(\n error instanceof Error ? error.message : \"Unknown error\",\n 500,\n \"UNKNOWN\"\n );\n }\n }\n\n /**\n * Get the installation ID to use for a request\n */\n private getInstallationId(input?: { installationId?: string }): string | undefined {\n return input?.installationId || this.defaultInstallationId;\n }\n\n // ==========================================================================\n // Installations\n // ==========================================================================\n\n private async listInstallations(): Promise<Installation[]> {\n return this.request<Installation[]>(\"GET\", \"/api/v1/github/installations\");\n }\n\n private async getInstallation(installationId: string): Promise<Installation> {\n return this.request<Installation>(\"GET\", `/api/v1/github/installations/${installationId}`);\n }\n\n private async updateInstallation(input: UpdateInstallationInput): Promise<Installation> {\n if (this.debug) console.log(\"[GitHub SDK] updateInstallation\", input.installationId);\n const { installationId, ...body } = input;\n return this.request<Installation>(\"PATCH\", `/api/v1/github/installations/${installationId}`, body);\n }\n\n private async disconnectInstallation(installationId: string): Promise<{ success: boolean; alreadyDeleted: boolean }> {\n if (this.debug) console.log(\"[GitHub SDK] disconnectInstallation\", installationId);\n return this.request<{ success: boolean; alreadyDeleted: boolean }>(\"DELETE\", `/api/v1/github/installations/${installationId}`);\n }\n\n // ==========================================================================\n // Repositories\n // ==========================================================================\n\n private async listRepos(input: ListReposInput): Promise<RepoConfig[]> {\n const installationId = input.installationId || this.defaultInstallationId;\n if (!installationId) {\n throw new NoInstallationError(\"installationId required. Call installations.list() first.\");\n }\n return this.request<RepoConfig[]>(\"GET\", `/api/v1/github/installations/${installationId}/repos`);\n }\n\n private async getRepo(repoId: string): Promise<RepoConfig> {\n if (this.debug) console.log(\"[GitHub SDK] getRepo\", repoId);\n return this.request<RepoConfig>(\"GET\", `/api/v1/github/repos/${repoId}`);\n }\n\n private async updateRepo(input: UpdateRepoInput): Promise<RepoConfig> {\n if (this.debug) console.log(\"[GitHub SDK] updateRepo\", input.repoId);\n const { repoId, ...body } = input;\n return this.request<RepoConfig>(\"PATCH\", `/api/v1/github/repos/${repoId}`, body);\n }\n\n private async removeRepo(repoId: string): Promise<{ success: boolean; alreadyRemoved: boolean }> {\n if (this.debug) console.log(\"[GitHub SDK] removeRepo\", repoId);\n return this.request<{ success: boolean; alreadyRemoved: boolean }>(\"DELETE\", `/api/v1/github/repos/${repoId}`);\n }\n\n private async syncRepos(input: SyncReposInput): Promise<{ count: number }> {\n const installationId = input.installationId || this.defaultInstallationId;\n if (!installationId) {\n throw new NoInstallationError(\"installationId required. Call installations.list() first.\");\n }\n if (this.debug) console.log(\"[GitHub SDK] syncRepos\", installationId);\n return this.request<{ count: number }>(\"POST\", `/api/v1/github/installations/${installationId}/repos/sync`);\n }\n\n // ==========================================================================\n // Projects (monorepo sub-projects)\n // ==========================================================================\n\n private async listProjects(input: ListProjectsInput): Promise<Project[]> {\n if (this.debug) console.log(\"[GitHub SDK] listProjects\", input.repoId);\n return this.request<Project[]>(\"GET\", `/api/v1/github/repos/${input.repoId}/projects`);\n }\n\n private async createProject(input: CreateProjectInput): Promise<Project> {\n if (this.debug) console.log(\"[GitHub SDK] createProject\", input.repoId, input.name);\n const { repoId, ...body } = input;\n return this.request<Project>(\"POST\", `/api/v1/github/repos/${repoId}/projects`, body);\n }\n\n private async updateProject(input: UpdateProjectInput): Promise<Project> {\n if (this.debug) console.log(\"[GitHub SDK] updateProject\", input.projectId);\n const { projectId, ...body } = input;\n return this.request<Project>(\"PATCH\", `/api/v1/github/projects/${projectId}`, body);\n }\n\n private async deleteProject(projectId: string): Promise<{ success: boolean }> {\n if (this.debug) console.log(\"[GitHub SDK] deleteProject\", projectId);\n return this.request<{ success: boolean }>(\"DELETE\", `/api/v1/github/projects/${projectId}`);\n }\n\n // ==========================================================================\n // Pull Requests\n // ==========================================================================\n\n private async listPullRequests(input: ListPullRequestsInput): Promise<PullRequest[]> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(input.state && { state: input.state }),\n ...(installationId && { installationId }),\n });\n return this.request<PullRequest[]>(\"GET\", `/api/v1/github/pulls?${params}`);\n }\n\n private async getPullRequest(input: GetPullRequestInput): Promise<PullRequestWithContext> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(installationId && { installationId }),\n });\n return this.request<PullRequestWithContext>(\n \"GET\",\n `/api/v1/github/pulls/${input.number}?${params}`\n );\n }\n\n // ==========================================================================\n // Deployments\n // ==========================================================================\n\n private async listDeployments(input: ListDeploymentsInput): Promise<Deployment[]> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(input.sha && { sha: input.sha }),\n ...(input.environment && { environment: input.environment }),\n ...(installationId && { installationId }),\n });\n return this.request<Deployment[]>(\"GET\", `/api/v1/github/deployments?${params}`);\n }\n\n // ==========================================================================\n // Comments\n // ==========================================================================\n\n private async listComments(input: ListCommentsInput): Promise<Comment[]> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n pr: String(input.pr),\n ...(installationId && { installationId }),\n });\n return this.request<Comment[]>(\"GET\", `/api/v1/github/comments?${params}`);\n }\n\n private async createComment(input: CreateCommentInput): Promise<Comment> {\n const installationId = this.getInstallationId(input);\n return this.request<Comment>(\"POST\", \"/api/v1/github/comments\", {\n owner: input.owner,\n repo: input.repo,\n pr: input.pr,\n body: input.body,\n ...(installationId && { installationId }),\n });\n }\n\n private async updateComment(input: UpdateCommentInput): Promise<Comment> {\n const installationId = this.getInstallationId(input);\n return this.request<Comment>(\"PATCH\", `/api/v1/github/comments/${input.commentId}`, {\n owner: input.owner,\n repo: input.repo,\n body: input.body,\n ...(installationId && { installationId }),\n });\n }\n\n private async deleteComment(input: DeleteCommentInput): Promise<void> {\n const installationId = this.getInstallationId(input);\n const params = new URLSearchParams({\n owner: input.owner,\n repo: input.repo,\n ...(installationId && { installationId }),\n });\n await this.request<void>(\"DELETE\", `/api/v1/github/comments/${input.commentId}?${params}`);\n }\n\n // ==========================================================================\n // Check Runs\n // ==========================================================================\n\n private async createCheckRun(input: CreateCheckRunInput): Promise<CheckRun> {\n const installationId = this.getInstallationId(input);\n return this.request<CheckRun>(\"POST\", \"/api/v1/github/check-runs\", {\n owner: input.owner,\n repo: input.repo,\n sha: input.sha,\n name: input.name,\n status: input.status,\n ...(input.title && { title: input.title }),\n ...(input.summary && { summary: input.summary }),\n ...(installationId && { installationId }),\n });\n }\n\n private async updateCheckRun(input: UpdateCheckRunInput): Promise<CheckRun> {\n const installationId = this.getInstallationId(input);\n return this.request<CheckRun>(\"PATCH\", `/api/v1/github/check-runs/${input.checkRunId}`, {\n owner: input.owner,\n repo: input.repo,\n ...(input.status && { status: input.status }),\n ...(input.conclusion && { conclusion: input.conclusion }),\n ...(input.title && { title: input.title }),\n ...(input.summary && { summary: input.summary }),\n ...(input.text && { text: input.text }),\n ...(installationId && { installationId }),\n });\n }\n}\n","/**\n * OpenAI Tool Factory for MorphClient\n * \n * Creates OpenAI-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool } from '../tools/warp_grep/openai.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/openai.js';\nimport { createEditFileTool } from '../tools/fastapply/openai.js';\nimport type { WarpGrepToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\n\n/**\n * Factory for creating OpenAI-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.openai.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.openai.createEditFileTool({ baseDir: './src' });\n * \n * // Use with OpenAI client\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [grepTool, searchTool, editTool],\n * messages: [{ role: 'user', content: 'Find and fix the bug' }]\n * });\n * ```\n */\nexport class OpenAIToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create an OpenAI-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an OpenAI-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an OpenAI-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns OpenAI ChatCompletionTool with execute and formatResult methods\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Anthropic Tool Factory for MorphClient\n * \n * Creates Anthropic-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool } from '../tools/warp_grep/anthropic.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/anthropic.js';\nimport { createEditFileTool } from '../tools/fastapply/anthropic.js';\nimport type { WarpGrepToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\n\n/**\n * Factory for creating Anthropic-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.anthropic.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.anthropic.createEditFileTool({ baseDir: './src' });\n * \n * // Use with Anthropic client\n * const response = await anthropic.messages.create({\n * model: 'claude-sonnet-4-5-20250929',\n * tools: [grepTool, searchTool, editTool],\n * messages: [{ role: 'user', content: 'Find and fix the bug' }]\n * });\n * ```\n */\nexport class AnthropicToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create an Anthropic-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n\n }\n\n /**\n * Create an Anthropic-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create an Anthropic-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Anthropic Tool with execute and formatResult methods\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Vercel AI SDK Tool Factory for MorphClient\n * \n * Creates Vercel AI SDK-compatible tools that inherit the API key from MorphClient.\n */\n\nimport type { MorphClientConfig } from '../client.js';\nimport { createWarpGrepTool } from '../tools/warp_grep/vercel.js';\nimport { createCodebaseSearchTool } from '../tools/codebase_search/vercel.js';\nimport { createEditFileTool } from '../tools/fastapply/vercel.js';\nimport type { WarpGrepToolConfig } from '../tools/warp_grep/types.js';\nimport type { CodebaseSearchConfig } from '../tools/codebase_search/types.js';\nimport type { EditFileConfig } from '../tools/fastapply/types.js';\n\n/**\n * Factory for creating Vercel AI SDK-compatible tools with inherited API key\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });\n * \n * const grepTool = morph.vercel.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.vercel.createCodebaseSearchTool({ repoId: 'my-project' });\n * const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });\n * \n * // Use with Vercel AI SDK\n * const result = await generateText({\n * model: anthropic('claude-sonnet-4-5-20250929'),\n * tools: { grep: grepTool, search: searchTool, edit: editTool },\n * prompt: 'Find and fix the bug'\n * });\n * ```\n */\nexport class VercelToolFactory {\n constructor(private config: MorphClientConfig) {}\n\n /**\n * Create a Vercel AI SDK-compatible warp grep tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>) {\n return createWarpGrepTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create a Vercel AI SDK-compatible codebase search tool\n * \n * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>) {\n return createCodebaseSearchTool({ \n ...toolConfig, \n apiKey: this.config.apiKey,\n });\n }\n\n /**\n * Create a Vercel AI SDK-compatible edit file tool\n * \n * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)\n * @returns Vercel AI SDK tool\n */\n createEditFileTool(toolConfig: Omit<EditFileConfig, 'morphApiKey'> = {}) {\n return createEditFileTool({ \n ...toolConfig, \n morphApiKey: this.config.apiKey,\n });\n }\n}\n\n","/**\n * Unified Morph SDK Client\n * \n * Provides access to all Morph tools through a single interface\n * \n * @example\n * ```typescript\n * import { MorphClient } from '@morphllm/morphsdk';\n * \n * const morph = new MorphClient({ \n * apiKey: process.env.MORPH_API_KEY,\n * debug: true,\n * timeout: 60000\n * });\n * \n * // Direct execution\n * await morph.fastApply.execute({ target_filepath: 'src/index.ts', ... });\n * await morph.warpGrep.execute({ query: 'Find auth', repoRoot: '.' });\n * await morph.codebaseSearch.search({ query: 'auth logic', repoId: 'x' });\n * \n * // Tool creation for AI agents (API key inherited)\n * const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });\n * const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'x' });\n * const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });\n * \n * // Use tools with OpenAI\n * const response = await openai.chat.completions.create({\n * model: 'gpt-4o',\n * tools: [grepTool],\n * messages: [{ role: 'user', content: 'Find the bug' }]\n * });\n * ```\n */\n\nimport type { RetryConfig } from './tools/utils/resilience.js';\nimport { FastApplyClient } from './tools/fastapply/core.js';\nimport { CodebaseSearchClient } from './tools/codebase_search/core.js';\nimport { BrowserClient } from './tools/browser/core.js';\nimport { WarpGrepClient } from './tools/warp_grep/client.js';\nimport { GitHubClient } from './tools/github/core.js';\nimport { MorphGit } from './git/index.js';\nimport { CompactClient } from './tools/compact/core.js';\nimport { OpenAIRouter, AnthropicRouter, GeminiRouter, RawRouter } from './modelrouter/core.js';\nimport { OpenAIToolFactory, AnthropicToolFactory, VercelToolFactory } from './factories/index.js';\n\n/**\n * Configuration for the MorphClient\n */\nexport interface MorphClientConfig {\n /** Morph API key for authentication (defaults to MORPH_API_KEY env var) */\n apiKey?: string;\n /** Enable debug logging across all tools */\n debug?: boolean;\n /** Default timeout in milliseconds for API requests */\n timeout?: number;\n /** Retry configuration for failed requests */\n retryConfig?: RetryConfig;\n /** GitHub-specific configuration */\n github?: {\n /** Default installation ID for GitHub operations */\n installationId?: string;\n };\n}\n\n/**\n * Unified Morph SDK Client\n * \n * Provides access to all Morph tools through a single interface:\n * - fastApply: AI-powered file editing with intelligent merging\n * - codebaseSearch: Semantic code search\n * - warpGrep: Fast code search with ripgrep\n * - browser: AI-powered browser automation\n * - git: Version control operations\n * - routers: Intelligent model selection (OpenAI, Anthropic, Gemini)\n * - openai/anthropic/vercel: Tool factories for agent frameworks\n */\nexport class MorphClient {\n /** Client configuration */\n public config: MorphClientConfig;\n\n /** FastApply tool for editing files with AI-powered merge */\n public fastApply: FastApplyClient;\n\n /** CodebaseSearch tool for semantic code search */\n public codebaseSearch: CodebaseSearchClient;\n\n /** WarpGrep tool for fast code search using ripgrep */\n public warpGrep: WarpGrepClient;\n\n /** Browser tool for AI-powered browser automation */\n public browser: BrowserClient;\n\n /** GitHub tool for PR context, comments, and check runs */\n public github: GitHubClient;\n\n /** Git tool for version control operations */\n public git: MorphGit;\n\n /** Model routers for intelligent model selection */\n public routers: {\n openai: OpenAIRouter;\n anthropic: AnthropicRouter;\n gemini: GeminiRouter;\n raw: RawRouter;\n };\n\n /** OpenAI-compatible tool factories */\n public openai: OpenAIToolFactory;\n\n /** Anthropic-compatible tool factories */\n public anthropic: AnthropicToolFactory;\n\n /** Vercel AI SDK tool factories */\n public vercel: VercelToolFactory;\n\n /** Responses API with compact tool */\n public responses: {\n compact: CompactClient['compact'];\n };\n\n /**\n * Create a new Morph SDK client\n * \n * @param config - Client configuration (apiKey, debug, timeout, retryConfig)\n * \n * @example\n * ```typescript\n * const morph = new MorphClient({ \n * apiKey: process.env.MORPH_API_KEY,\n * debug: true,\n * timeout: 60000\n * });\n * ```\n */\n constructor(config: MorphClientConfig = {}) {\n this.config = config;\n\n // Initialize all sub-clients with shared config\n this.fastApply = new FastApplyClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.codebaseSearch = new CodebaseSearchClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.warpGrep = new WarpGrepClient({\n morphApiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.browser = new BrowserClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n });\n\n this.github = new GitHubClient({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n installationId: config.github?.installationId,\n });\n\n this.git = new MorphGit({\n apiKey: config.apiKey,\n retryConfig: config.retryConfig,\n });\n\n this.routers = {\n openai: new OpenAIRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n anthropic: new AnthropicRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n gemini: new GeminiRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n raw: new RawRouter({\n apiKey: config.apiKey,\n debug: config.debug,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n }),\n };\n\n const compactClient = new CompactClient({\n morphApiKey: config.apiKey,\n timeout: config.timeout,\n retryConfig: config.retryConfig,\n debug: config.debug,\n });\n this.responses = {\n compact: compactClient.compact.bind(compactClient),\n };\n\n // Initialize tool factories\n this.openai = new OpenAIToolFactory(config);\n this.anthropic = new AnthropicToolFactory(config);\n this.vercel = new VercelToolFactory(config);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAweO,IAAM,cAAN,cAA0B,MAAM;AAAA;AAAA,EAErC;AAAA;AAAA,EAEA;AAAA,EAEA,YAAY,SAAiB,QAAgB,MAAe;AAC1D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,YAAY,UAAU,8FAA8F;AAClH,UAAM,SAAS,KAAK,iBAAiB;AAAA,EACvC;AACF;AAKO,IAAM,gBAAN,cAA4B,YAAY;AAAA,EAC7C,YAAY,UAAkB;AAC5B,UAAM,GAAG,QAAQ,cAAc,KAAK,WAAW;AAAA,EACjD;AACF;AAKO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YAAY,UAAU,+CAA+C;AACnE,UAAM,SAAS,KAAK,mBAAmB;A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CAAC;AAAA,MACD,KAAK,IAAI,UAAU;AAAA,QACjB,QAAQ,OAAO;AAAA,QACf,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,aAAa,OAAO;AAAA,MACtB,CAAC;AAAA,IACH;AAEA,UAAM,gBAAgB,IAAI,cAAc;AAAA,MACtC,aAAa,OAAO;AAAA,MACpB,SAAS,OAAO;AAAA,MAChB,aAAa,OAAO;AAAA,MACpB,OAAO,OAAO;AAAA,IAChB,CAAC;AACD,SAAK,YAAY;AAAA,MACf,SAAS,cAAc,QAAQ,KAAK,aAAa;AAAA,IACnD;AAGA,SAAK,SAAS,IAAI,kBAAkB,MAAM;AAC1C,SAAK,YAAY,IAAI,qBAAqB,MAAM;AAChD,SAAK,SAAS,IAAI,kBAAkB,MAAM;AAAA,EAC5C;AACF;","names":["createWarpGrepTool","createCodebaseSearchTool","createEditFileTool","createWarpGrepTool","createCodebaseSearchTool","createEditFileTool"]}
@@ -1,3 +1,7 @@
1
+ import {
2
+ SDK_VERSION
3
+ } from "./chunk-EJYFE73S.js";
4
+
1
5
  // tools/fastapply/apply.ts
2
6
  import { createTwoFilesPatch } from "diff";
3
7
  import OpenAI from "openai";
@@ -55,7 +59,8 @@ async function callMorphAPI(originalCode, codeEdit, instructions, filepath, conf
55
59
  apiKey,
56
60
  baseURL: `${apiUrl}/v1`,
57
61
  timeout,
58
- maxRetries: config.retryConfig?.maxRetries ?? 3
62
+ maxRetries: config.retryConfig?.maxRetries ?? 3,
63
+ defaultHeaders: { "X-Morph-SDK-Version": SDK_VERSION }
59
64
  });
60
65
  const completion = await client.chat.completions.create({
61
66
  model: "morph-v3-fast",
@@ -111,4 +116,4 @@ export {
111
116
  callMorphAPI,
112
117
  applyEdit
113
118
  };
114
- //# sourceMappingURL=chunk-FXBT4UDY.js.map
119
+ //# sourceMappingURL=chunk-7QZFNYOH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../tools/fastapply/apply.ts"],"sourcesContent":["/**\n * Edge-compatible code application API\n *\n * This module works on:\n * - Node.js\n * - Cloudflare Workers\n * - Vercel Edge Functions\n * - Deno Deploy\n * - Browser environments\n *\n * For file-based operations, use executeEditFile from core.ts\n */\n\nimport { createTwoFilesPatch } from 'diff';\nimport OpenAI from 'openai';\nimport { SDK_VERSION } from '../../version.js';\nimport type {\n EditChanges,\n ApplyEditInput,\n ApplyEditResult,\n ApplyEditConfig,\n} from './types.js';\n\nconst DEFAULT_API_URL = 'https://api.morphllm.com';\nconst DEFAULT_TIMEOUT = 30000;\n\n/**\n * Generate a unified diff between two strings\n */\nexport function generateUdiff(\n original: string,\n modified: string,\n filepath: string\n): string {\n return createTwoFilesPatch(\n filepath,\n filepath,\n original,\n modified,\n 'Original',\n 'Modified'\n );\n}\n\n/**\n * Count changes from a unified diff\n */\nexport function countChanges(original: string, modified: string): EditChanges {\n const diff = generateUdiff(original, modified, 'file');\n const lines = diff.split('\\n');\n\n let linesAdded = 0;\n let linesRemoved = 0;\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n linesAdded++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n linesRemoved++;\n }\n }\n\n const linesModified = Math.min(linesAdded, linesRemoved);\n\n return {\n linesAdded: linesAdded - linesModified,\n linesRemoved: linesRemoved - linesModified,\n linesModified,\n };\n}\n\n/**\n * Call Morph Apply API to merge code edits\n * Uses OpenAI SDK for reliable connection handling, retries, and timeouts\n */\nexport async function callMorphAPI(\n originalCode: string,\n codeEdit: string,\n instructions: string,\n filepath: string,\n config: ApplyEditConfig\n): Promise<{ content: string; completionId?: string }> {\n const apiKey = config.morphApiKey || (typeof process !== 'undefined' ? process.env?.MORPH_API_KEY : undefined);\n const apiUrl = config.morphApiUrl || DEFAULT_API_URL;\n const timeout = config.timeout || DEFAULT_TIMEOUT;\n const debug = config.debug || false;\n\n if (!apiKey) {\n throw new Error(\n 'Morph API key not found. Set MORPH_API_KEY environment variable or pass morphApiKey in config.'\n );\n }\n\n // Format message with XML tags as per Morph Fast Apply spec\n const message = `<instruction>${instructions}</instruction>\\n<code>${originalCode}</code>\\n<update>${codeEdit}</update>`;\n\n if (debug) {\n console.log(`[FastApply] Calling ${apiUrl}/v1/chat/completions`);\n console.log(`[FastApply] File: ${filepath}, Instructions: ${instructions.slice(0, 60)}...`);\n console.log(`[FastApply] Original: ${originalCode.length} chars, Edit: ${codeEdit.length} chars`);\n }\n\n const startTime = Date.now();\n\n const client = new OpenAI({\n apiKey,\n baseURL: `${apiUrl}/v1`,\n timeout,\n maxRetries: config.retryConfig?.maxRetries ?? 3,\n defaultHeaders: { 'X-Morph-SDK-Version': SDK_VERSION },\n });\n\n const completion = await client.chat.completions.create({\n model: 'morph-v3-fast',\n messages: [{ role: 'user', content: message }],\n });\n\n const content = completion.choices[0]?.message?.content;\n if (!content) {\n throw new Error('Morph API returned empty response');\n }\n\n const elapsed = Date.now() - startTime;\n\n if (debug) {\n console.log(`[FastApply] Success in ${elapsed}ms, merged: ${content.length} chars`);\n }\n\n return { content, completionId: completion.id };\n}\n\n/**\n * Apply an edit to code directly without file I/O\n *\n * This is the edge-compatible code-in/code-out API that accepts code content directly\n * and returns the merged result without reading or writing any files.\n *\n * Works on Cloudflare Workers, Vercel Edge Functions, Deno, and browsers.\n *\n * @param input - Code and edit parameters\n * @param config - Optional configuration\n * @returns Result with merged code\n *\n * @example\n * ```typescript\n * import { applyEdit } from '@morphllm/morphsdk';\n *\n * const result = await applyEdit({\n * originalCode: fs.readFileSync('file.ts', 'utf-8'),\n * codeEdit: '// ... existing code ...\\nconst newVar = 42;\\n// ... existing code ...',\n * instructions: 'Add a new variable',\n * filepath: 'file.ts' // optional, for udiff context\n * });\n *\n * if (result.success) {\n * fs.writeFileSync('file.ts', result.mergedCode);\n * }\n * ```\n */\nexport async function applyEdit(\n input: ApplyEditInput,\n config: ApplyEditConfig = {}\n): Promise<ApplyEditResult> {\n const debug = config.debug || false;\n const filepath = input.filepath || 'file';\n\n try {\n if (debug) {\n console.log(`[FastApply] Applying edit to code (${input.originalCode.length} chars)`);\n }\n\n const { content: mergedCode, completionId } = await callMorphAPI(\n input.originalCode,\n input.codeEdit,\n input.instructions,\n filepath,\n config\n );\n\n const udiff = config.generateUdiff !== false\n ? generateUdiff(input.originalCode, mergedCode, filepath)\n : undefined;\n\n const changes = countChanges(input.originalCode, mergedCode);\n\n return {\n success: true,\n mergedCode,\n udiff,\n changes,\n completionId,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';\n if (debug) console.error(`[FastApply] Error: ${errorMessage}`);\n\n return {\n success: false,\n changes: { linesAdded: 0, linesRemoved: 0, linesModified: 0 },\n error: errorMessage,\n };\n }\n}\n"],"mappings":";;;;;AAaA,SAAS,2BAA2B;AACpC,OAAO,YAAY;AASnB,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AAKjB,SAAS,cACd,UACA,UACA,UACQ;AACR,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAKO,SAAS,aAAa,UAAkB,UAA+B;AAC5E,QAAM,OAAO,cAAc,UAAU,UAAU,MAAM;AACrD,QAAM,QAAQ,KAAK,MAAM,IAAI;AAE7B,MAAI,aAAa;AACjB,MAAI,eAAe;AAEnB,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,WAAW,GAAG,KAAK,CAAC,KAAK,WAAW,KAAK,GAAG;AACnD;AAAA,IACF,WAAW,KAAK,WAAW,GAAG,KAAK,CAAC,KAAK,WAAW,KAAK,GAAG;AAC1D;AAAA,IACF;AAAA,EACF;AAEA,QAAM,gBAAgB,KAAK,IAAI,YAAY,YAAY;AAEvD,SAAO;AAAA,IACL,YAAY,aAAa;AAAA,IACzB,cAAc,eAAe;AAAA,IAC7B;AAAA,EACF;AACF;AAMA,eAAsB,aACpB,cACA,UACA,cACA,UACA,QACqD;AACrD,QAAM,SAAS,OAAO,gBAAgB,OAAO,YAAY,cAA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YAAY;AAEnC,MAAI;AACF,QAAI,OAAO;AACT,cAAQ,IAAI,sCAAsC,MAAM,aAAa,MAAM,SAAS;AAAA,IACtF;AAEA,UAAM,EAAE,SAAS,YAAY,aAAa,IAAI,MAAM;AAAA,MAClD,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACF;AAEA,UAAM,QAAQ,OAAO,kBAAkB,QACnC,cAAc,MAAM,cAAc,YAAY,QAAQ,IACtD;AAEJ,UAAM,UAAU,aAAa,MAAM,cAAc,UAAU;AAE3D,WAAO;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,UAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,QAAI,MAAO,SAAQ,MAAM,sBAAsB,YAAY,EAAE;AAE7D,WAAO;AAAA,MACL,SAAS;AAAA,MACT,SAAS,EAAE,YAAY,GAAG,cAAc,GAAG,eAAe,EAAE;AAAA,MAC5D,OAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
@@ -112,4 +112,4 @@ export {
112
112
  FastApplyClient,
113
113
  executeEditFile
114
114
  };
115
- //# sourceMappingURL=chunk-M5DR2WOZ.js.map
115
+ //# sourceMappingURL=chunk-AI3ZCOCT.js.map
@@ -1,10 +1,10 @@
1
+ import {
2
+ executeEditFile
3
+ } from "./chunk-AI3ZCOCT.js";
1
4
  import {
2
5
  EDIT_FILE_SYSTEM_PROMPT,
3
6
  EDIT_FILE_TOOL_DESCRIPTION
4
7
  } from "./chunk-63WE2C5R.js";
5
- import {
6
- executeEditFile
7
- } from "./chunk-M5DR2WOZ.js";
8
8
  import {
9
9
  __export
10
10
  } from "./chunk-PZ5AY32C.js";
@@ -91,4 +91,4 @@ export {
91
91
  openai_default,
92
92
  openai_exports
93
93
  };
94
- //# sourceMappingURL=chunk-UNHHRMU7.js.map
94
+ //# sourceMappingURL=chunk-BDKXYMU2.js.map
@@ -1,10 +1,10 @@
1
- import {
2
- runWarpGrep,
3
- runWarpGrepStreaming
4
- } from "./chunk-QL7MV3GT.js";
5
1
  import {
6
2
  RemoteCommandsProvider
7
3
  } from "./chunk-PUGSTXLO.js";
4
+ import {
5
+ runWarpGrep,
6
+ runWarpGrepStreaming
7
+ } from "./chunk-QDGB6FLI.js";
8
8
 
9
9
  // tools/warp_grep/client.ts
10
10
  async function getLocalProvider(repoRoot, excludes) {
@@ -148,4 +148,4 @@ export {
148
148
  executeToolCallStreaming,
149
149
  formatResult
150
150
  };
151
- //# sourceMappingURL=chunk-G7RSAZIK.js.map
151
+ //# sourceMappingURL=chunk-C3BQUIFE.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  fetchWithRetry,
3
3
  withTimeout
4
- } from "./chunk-4VWJFZVS.js";
4
+ } from "./chunk-3HBZXN6E.js";
5
5
 
6
6
  // tools/codebase_search/core.ts
7
7
  var CodebaseSearchClient = class {
@@ -102,4 +102,4 @@ export {
102
102
  CodebaseSearchClient,
103
103
  executeCodebaseSearch
104
104
  };
105
- //# sourceMappingURL=chunk-WM77HRKO.js.map
105
+ //# sourceMappingURL=chunk-CIFPLFBQ.js.map
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  executeToolCall,
7
7
  formatResult
8
- } from "./chunk-G7RSAZIK.js";
8
+ } from "./chunk-C3BQUIFE.js";
9
9
  import {
10
10
  getSystemPrompt
11
11
  } from "./chunk-FMLHRJDF.js";
@@ -58,4 +58,4 @@ export {
58
58
  createWarpGrepTool,
59
59
  openai_default
60
60
  };
61
- //# sourceMappingURL=chunk-WVTX3QS6.js.map
61
+ //# sourceMappingURL=chunk-CXP63PHW.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-2HMEZZKK.js";
5
5
  import {
6
6
  executeBrowserTask
7
- } from "./chunk-ZYPLV3HP.js";
7
+ } from "./chunk-WEBUKGPK.js";
8
8
  import {
9
9
  __export
10
10
  } from "./chunk-PZ5AY32C.js";
@@ -93,4 +93,4 @@ export {
93
93
  createBrowserTool,
94
94
  openai_exports
95
95
  };
96
- //# sourceMappingURL=chunk-5IVVJMMX.js.map
96
+ //# sourceMappingURL=chunk-DL3Y3R6A.js.map
@@ -1,3 +1,6 @@
1
+ import {
2
+ readAllLines
3
+ } from "./chunk-G2RSY56Q.js";
1
4
  import {
2
5
  fixPathRepetition,
3
6
  isSymlink,
@@ -8,9 +11,6 @@ import {
8
11
  import {
9
12
  runRipgrep
10
13
  } from "./chunk-TPP2UGQP.js";
11
- import {
12
- readAllLines
13
- } from "./chunk-G2RSY56Q.js";
14
14
  import {
15
15
  AGENT_CONFIG,
16
16
  DEFAULT_EXCLUDES
@@ -294,4 +294,4 @@ Details: ${res.stderr}` : ""}`
294
294
  export {
295
295
  LocalRipgrepProvider
296
296
  };
297
- //# sourceMappingURL=chunk-HMQSMEN2.js.map
297
+ //# sourceMappingURL=chunk-EF7ZYLA2.js.map