@morphllm/morphsdk 0.2.28 → 0.2.32

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 (90) hide show
  1. package/README.md +3 -3
  2. package/dist/anthropic-DpEAqqZF.d.ts +88 -0
  3. package/dist/{chunk-LN4CTQZG.js → chunk-4OBDFXR4.js} +4 -4
  4. package/dist/{chunk-S3HTYGYF.js → chunk-B4H7N4GZ.js} +14 -2
  5. package/dist/chunk-B4H7N4GZ.js.map +1 -0
  6. package/dist/{chunk-YSBSDU75.js → chunk-BGDEQTRF.js} +4 -4
  7. package/dist/{chunk-EAA7D24N.js → chunk-JJ5ONKDN.js} +7 -7
  8. package/dist/{chunk-CMKITT6X.js → chunk-U6ZHZ5LY.js} +10 -10
  9. package/dist/{chunk-W5CHJ6OX.js → chunk-VD7US3AJ.js} +4 -4
  10. package/dist/client.d.ts +114 -0
  11. package/dist/client.js +4 -4
  12. package/dist/git/client.d.ts +261 -0
  13. package/dist/git/config.d.ts +11 -0
  14. package/dist/git/index.d.ts +5 -0
  15. package/dist/git/types.d.ts +102 -0
  16. package/dist/index.d.ts +14 -0
  17. package/dist/index.js +10 -10
  18. package/dist/modelrouter/core.d.ts +56 -0
  19. package/dist/modelrouter/index.d.ts +2 -0
  20. package/dist/modelrouter/types.d.ts +35 -0
  21. package/dist/openai-BkKsS30n.d.ts +111 -0
  22. package/dist/tools/browser/anthropic.d.ts +51 -0
  23. package/dist/tools/browser/core.d.ts +203 -0
  24. package/dist/tools/browser/index.d.ts +72 -0
  25. package/dist/tools/browser/openai.d.ts +73 -0
  26. package/dist/tools/browser/prompts.d.ts +7 -0
  27. package/dist/tools/browser/types.d.ts +255 -0
  28. package/dist/tools/browser/vercel.d.ts +69 -0
  29. package/dist/tools/codebase_search/anthropic.d.ts +40 -0
  30. package/dist/tools/codebase_search/core.d.ts +40 -0
  31. package/dist/tools/codebase_search/index.d.ts +10 -0
  32. package/dist/tools/codebase_search/index.js +3 -3
  33. package/dist/tools/codebase_search/openai.d.ts +87 -0
  34. package/dist/tools/codebase_search/prompts.d.ts +7 -0
  35. package/dist/tools/codebase_search/types.d.ts +50 -0
  36. package/dist/tools/codebase_search/vercel.d.ts +65 -0
  37. package/dist/tools/fastapply/anthropic.cjs +14 -2
  38. package/dist/tools/fastapply/anthropic.cjs.map +1 -1
  39. package/dist/tools/fastapply/anthropic.d.ts +4 -0
  40. package/dist/tools/fastapply/anthropic.js +9 -3
  41. package/dist/tools/fastapply/core.d.ts +41 -0
  42. package/dist/tools/fastapply/index.cjs +18 -9
  43. package/dist/tools/fastapply/index.cjs.map +1 -1
  44. package/dist/tools/fastapply/index.d.ts +10 -0
  45. package/dist/tools/fastapply/index.js +4 -4
  46. package/dist/tools/fastapply/openai.d.ts +4 -0
  47. package/dist/tools/fastapply/prompts.d.ts +7 -0
  48. package/dist/tools/fastapply/types.d.ts +77 -0
  49. package/dist/tools/fastapply/vercel.d.ts +4 -0
  50. package/dist/tools/index.cjs +18 -9
  51. package/dist/tools/index.cjs.map +1 -1
  52. package/dist/tools/index.d.ts +10 -0
  53. package/dist/tools/index.js +4 -4
  54. package/dist/tools/utils/resilience.d.ts +58 -0
  55. package/dist/tools/warp_grep/agent/config.d.ts +8 -0
  56. package/dist/tools/warp_grep/agent/formatter.d.ts +14 -0
  57. package/dist/tools/warp_grep/agent/grep_helpers.d.ts +16 -0
  58. package/dist/tools/warp_grep/agent/parser.d.ts +16 -0
  59. package/dist/tools/warp_grep/agent/prompt.d.ts +4 -0
  60. package/dist/tools/warp_grep/agent/runner.d.ts +10 -0
  61. package/dist/tools/warp_grep/agent/runner.js +3 -3
  62. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  63. package/dist/tools/warp_grep/agent/types.d.ts +44 -0
  64. package/dist/tools/warp_grep/anthropic.d.ts +14 -0
  65. package/dist/tools/warp_grep/anthropic.js +5 -5
  66. package/dist/tools/warp_grep/index.d.ts +11 -0
  67. package/dist/tools/warp_grep/index.js +9 -9
  68. package/dist/tools/warp_grep/openai.d.ts +33 -0
  69. package/dist/tools/warp_grep/openai.js +5 -5
  70. package/dist/tools/warp_grep/providers/command.d.ts +48 -0
  71. package/dist/tools/warp_grep/providers/local.d.ts +30 -0
  72. package/dist/tools/warp_grep/providers/types.d.ts +49 -0
  73. package/dist/tools/warp_grep/tools/analyse.d.ts +10 -0
  74. package/dist/tools/warp_grep/tools/finish.d.ts +10 -0
  75. package/dist/tools/warp_grep/tools/grep.d.ts +8 -0
  76. package/dist/tools/warp_grep/tools/read.d.ts +9 -0
  77. package/dist/tools/warp_grep/utils/files.d.ts +3 -0
  78. package/dist/tools/warp_grep/utils/format.d.ts +4 -0
  79. package/dist/tools/warp_grep/utils/paths.d.ts +7 -0
  80. package/dist/tools/warp_grep/utils/ripgrep.d.ts +11 -0
  81. package/dist/tools/warp_grep/vercel.d.ts +33 -0
  82. package/dist/tools/warp_grep/vercel.js +5 -5
  83. package/dist/vercel-B1GZ_g9N.d.ts +69 -0
  84. package/package.json +1 -1
  85. package/dist/chunk-S3HTYGYF.js.map +0 -1
  86. /package/dist/{chunk-LN4CTQZG.js.map → chunk-4OBDFXR4.js.map} +0 -0
  87. /package/dist/{chunk-YSBSDU75.js.map → chunk-BGDEQTRF.js.map} +0 -0
  88. /package/dist/{chunk-EAA7D24N.js.map → chunk-JJ5ONKDN.js.map} +0 -0
  89. /package/dist/{chunk-CMKITT6X.js.map → chunk-U6ZHZ5LY.js.map} +0 -0
  90. /package/dist/{chunk-W5CHJ6OX.js.map → chunk-VD7US3AJ.js.map} +0 -0
package/README.md CHANGED
@@ -18,9 +18,9 @@ export MORPH_API_KEY="sk-your-key-here"
18
18
 
19
19
  ## Features
20
20
 
21
- - **🔍 Semantic Search** - Search code with natural language (morph-v4-embedding + morph-v4-rerank)
22
- - **📦 Repo Storage** - Git with automatic code indexing, agent metadata, and chat history
23
- - **⚡ Fast Apply** - AI-powered code editing at 10,500 tokens/s
21
+ - **🔍 Semantic Search** - State of the Art Code Search (AST aware chunking, morph-v4-embedding + morph-v4-rerank)
22
+ - **📦 Repo Storage** - Agent native git with automatic code indexing, agent metadata, and chat history
23
+ - **⚡ Fast Apply** - 98% 1st pass accuracy, AI-powered code editing at 10,500 tokens/s
24
24
  - **🤖 Agent Tools** - Ready-to-use tools for Anthropic, OpenAI, and Vercel AI SDK
25
25
 
26
26
  ## Quick Start
@@ -0,0 +1,88 @@
1
+ import { Tool } from '@anthropic-ai/sdk/resources/messages';
2
+ import { EditFileResult, EditFileConfig, EditFileInput } from './tools/fastapply/types.js';
3
+
4
+ /**
5
+ * Anthropic SDK adapter for edit_file tool
6
+ */
7
+
8
+ /**
9
+ * Anthropic-native tool definition for edit_file
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import Anthropic from '@anthropic-ai/sdk';
14
+ * import { editFileTool } from 'morphsdk/tools/anthropic';
15
+ *
16
+ * const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
17
+ *
18
+ * const response = await client.messages.create({
19
+ * model: "claude-sonnet-4-5-20250929",
20
+ * tools: [editFileTool],
21
+ * messages: [{ role: "user", content: "Fix the bug in app.ts" }]
22
+ * });
23
+ * ```
24
+ */
25
+ declare const editFileTool: Tool;
26
+ /**
27
+ * Format the result for passing back to Claude
28
+ *
29
+ * @param result - The edit result
30
+ * @returns Formatted string for tool_result
31
+ */
32
+ declare function formatResult(result: EditFileResult): string;
33
+ /**
34
+ * Create a custom edit_file tool with configuration
35
+ *
36
+ * @param config - Configuration options
37
+ * @returns Tool definition with execute and formatResult methods
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const tool = createEditFileTool({
42
+ * baseDir: './src',
43
+ * generateUdiff: true,
44
+ * morphApiKey: 'sk-...',
45
+ * description: 'Custom tool description for your use case'
46
+ * });
47
+ *
48
+ * // Use as Anthropic tool
49
+ * const response = await client.messages.create({
50
+ * tools: [tool], // tool itself is the Tool definition
51
+ * ...
52
+ * });
53
+ *
54
+ * // Execute and format
55
+ * const result = await tool.execute(toolUseBlock.input);
56
+ * const formatted = tool.formatResult(result);
57
+ * ```
58
+ */
59
+ declare function createEditFileTool(config?: EditFileConfig): Tool & {
60
+ execute: (input: EditFileInput) => Promise<EditFileResult>;
61
+ formatResult: (result: EditFileResult) => string;
62
+ getSystemPrompt: () => string;
63
+ };
64
+ /**
65
+ * Execute the edit_file tool with raw input
66
+ *
67
+ * @param input - Tool input from Claude's tool_use
68
+ * @param config - Configuration for Fast Apply
69
+ * @returns Tool result to send back to Claude
70
+ */
71
+ declare function execute(input: EditFileInput, config?: EditFileConfig): Promise<EditFileResult>;
72
+ /**
73
+ * Get the system prompt for the edit_file tool
74
+ *
75
+ * @returns System prompt string
76
+ */
77
+ declare function getSystemPrompt(): string;
78
+
79
+ declare const anthropic_createEditFileTool: typeof createEditFileTool;
80
+ declare const anthropic_editFileTool: typeof editFileTool;
81
+ declare const anthropic_execute: typeof execute;
82
+ declare const anthropic_formatResult: typeof formatResult;
83
+ declare const anthropic_getSystemPrompt: typeof getSystemPrompt;
84
+ declare namespace anthropic {
85
+ export { anthropic_createEditFileTool as createEditFileTool, anthropic_editFileTool as editFileTool, anthropic_execute as execute, anthropic_formatResult as formatResult, anthropic_getSystemPrompt as getSystemPrompt };
86
+ }
87
+
88
+ export { anthropic as a, execute as b, createEditFileTool as c, editFileTool as e, formatResult as f, getSystemPrompt as g };
@@ -1,9 +1,9 @@
1
- import {
2
- runWarpGrep
3
- } from "./chunk-EAA7D24N.js";
4
1
  import {
5
2
  LocalRipgrepProvider
6
3
  } from "./chunk-UYBIKZPM.js";
4
+ import {
5
+ runWarpGrep
6
+ } from "./chunk-JJ5ONKDN.js";
7
7
 
8
8
  // tools/warp_grep/openai.ts
9
9
  import { z } from "zod";
@@ -53,4 +53,4 @@ function createMorphWarpGrepTool(config) {
53
53
  export {
54
54
  createMorphWarpGrepTool
55
55
  };
56
- //# sourceMappingURL=chunk-LN4CTQZG.js.map
56
+ //# sourceMappingURL=chunk-4OBDFXR4.js.map
@@ -13,7 +13,10 @@ import {
13
13
  var anthropic_exports = {};
14
14
  __export(anthropic_exports, {
15
15
  createEditFileTool: () => createEditFileTool,
16
- editFileTool: () => editFileTool
16
+ editFileTool: () => editFileTool,
17
+ execute: () => execute,
18
+ formatResult: () => formatResult,
19
+ getSystemPrompt: () => getSystemPrompt
17
20
  });
18
21
  var editFileTool = {
19
22
  name: "edit_file",
@@ -73,10 +76,19 @@ function createEditFileTool(config = {}) {
73
76
  }
74
77
  });
75
78
  }
79
+ async function execute(input, config) {
80
+ return executeEditFile(input, config);
81
+ }
82
+ function getSystemPrompt() {
83
+ return EDIT_FILE_SYSTEM_PROMPT;
84
+ }
76
85
 
77
86
  export {
78
87
  editFileTool,
88
+ formatResult,
79
89
  createEditFileTool,
90
+ execute,
91
+ getSystemPrompt,
80
92
  anthropic_exports
81
93
  };
82
- //# sourceMappingURL=chunk-S3HTYGYF.js.map
94
+ //# sourceMappingURL=chunk-B4H7N4GZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../tools/fastapply/anthropic.ts"],"sourcesContent":["/**\n * Anthropic SDK adapter for edit_file tool\n */\n\nimport type { Tool } from '@anthropic-ai/sdk/resources/messages';\nimport { executeEditFile } from './core.js';\nimport { EDIT_FILE_TOOL_DESCRIPTION, EDIT_FILE_SYSTEM_PROMPT } from './prompts.js';\nimport type { EditFileInput, EditFileResult, EditFileConfig } from './types.js';\n\n/**\n * Anthropic-native tool definition for edit_file\n * \n * @example\n * ```ts\n * import Anthropic from '@anthropic-ai/sdk';\n * import { editFileTool } from 'morphsdk/tools/anthropic';\n * \n * const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });\n * \n * const response = await client.messages.create({\n * model: \"claude-sonnet-4-5-20250929\",\n * tools: [editFileTool],\n * messages: [{ role: \"user\", content: \"Fix the bug in app.ts\" }]\n * });\n * ```\n */\nexport const editFileTool: Tool = {\n name: 'edit_file',\n description: EDIT_FILE_TOOL_DESCRIPTION,\n input_schema: {\n type: 'object',\n properties: {\n target_filepath: {\n type: 'string',\n description: 'The path of the target file to modify',\n },\n instructions: {\n type: 'string',\n description: 'A single sentence describing what you are changing (first person)',\n },\n code_edit: {\n type: 'string',\n description: 'The lazy edit with // ... existing code ... markers',\n },\n },\n required: ['target_filepath', 'instructions', 'code_edit'],\n },\n};\n\n/**\n * Format the result for passing back to Claude\n * \n * @param result - The edit result\n * @returns Formatted string for tool_result\n */\nexport function formatResult(result: EditFileResult): string {\n if (!result.success) {\n return `Error editing file: ${result.error}`;\n }\n \n const { changes } = result;\n const summary = [\n changes.linesAdded && `+${changes.linesAdded} lines`,\n changes.linesRemoved && `-${changes.linesRemoved} lines`,\n changes.linesModified && `~${changes.linesModified} lines modified`,\n ]\n .filter(Boolean)\n .join(', ');\n \n if (result.udiff) {\n return `Successfully applied changes to ${result.filepath}:\\n\\n${result.udiff}\\n\\nSummary: ${summary}`;\n }\n \n return `Successfully applied changes to ${result.filepath}. ${summary}`;\n}\n\n/**\n * Create a custom edit_file tool with configuration\n * \n * @param config - Configuration options\n * @returns Tool definition with execute and formatResult methods\n * \n * @example\n * ```ts\n * const tool = createEditFileTool({\n * baseDir: './src',\n * generateUdiff: true,\n * morphApiKey: 'sk-...',\n * description: 'Custom tool description for your use case'\n * });\n * \n * // Use as Anthropic tool\n * const response = await client.messages.create({\n * tools: [tool], // tool itself is the Tool definition\n * ...\n * });\n * \n * // Execute and format\n * const result = await tool.execute(toolUseBlock.input);\n * const formatted = tool.formatResult(result);\n * ```\n */\nexport function createEditFileTool(config: EditFileConfig = {}) {\n const toolDef: Tool = {\n ...editFileTool,\n ...(config.description && { description: config.description }),\n };\n \n return Object.assign({}, toolDef, {\n execute: async (input: EditFileInput): Promise<EditFileResult> => {\n return executeEditFile(input, config);\n },\n formatResult: (result: EditFileResult): string => {\n return formatResult(result);\n },\n getSystemPrompt: (): string => {\n return EDIT_FILE_SYSTEM_PROMPT;\n },\n });\n}\n\n/**\n * Execute the edit_file tool with raw input\n * \n * @param input - Tool input from Claude's tool_use\n * @param config - Configuration for Fast Apply\n * @returns Tool result to send back to Claude\n */\nexport async function execute(\n input: EditFileInput,\n config?: EditFileConfig\n): Promise<EditFileResult> {\n return executeEditFile(input, config);\n}\n\n/**\n * Get the system prompt for the edit_file tool\n * \n * @returns System prompt string\n */\nexport function getSystemPrompt(): string {\n return EDIT_FILE_SYSTEM_PROMPT;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BO,IAAM,eAAqB;AAAA,EAChC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,YAAY;AAAA,MACV,iBAAiB;AAAA,QACf,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA,cAAc;AAAA,QACZ,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA,WAAW;AAAA,QACT,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,UAAU,CAAC,mBAAmB,gBAAgB,WAAW;AAAA,EAC3D;AACF;AAQO,SAAS,aAAa,QAAgC;AAC3D,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,uBAAuB,OAAO,KAAK;AAAA,EAC5C;AAEA,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,UAAU;AAAA,IACd,QAAQ,cAAc,IAAI,QAAQ,UAAU;AAAA,IAC5C,QAAQ,gBAAgB,IAAI,QAAQ,YAAY;AAAA,IAChD,QAAQ,iBAAiB,IAAI,QAAQ,aAAa;AAAA,EACpD,EACG,OAAO,OAAO,EACd,KAAK,IAAI;AAEZ,MAAI,OAAO,OAAO;AAChB,WAAO,mCAAmC,OAAO,QAAQ;AAAA;AAAA,EAAQ,OAAO,KAAK;AAAA;AAAA,WAAgB,OAAO;AAAA,EACtG;AAEA,SAAO,mCAAmC,OAAO,QAAQ,KAAK,OAAO;AACvE;AA4BO,SAAS,mBAAmB,SAAyB,CAAC,GAAG;AAC9D,QAAM,UAAgB;AAAA,IACpB,GAAG;AAAA,IACH,GAAI,OAAO,eAAe,EAAE,aAAa,OAAO,YAAY;AAAA,EAC9D;AAEA,SAAO,OAAO,OAAO,CAAC,GAAG,SAAS;AAAA,IAChC,SAAS,OAAO,UAAkD;AAChE,aAAO,gBAAgB,OAAO,MAAM;AAAA,IACtC;AAAA,IACA,cAAc,CAAC,WAAmC;AAChD,aAAO,aAAa,MAAM;AAAA,IAC5B;AAAA,IACA,iBAAiB,MAAc;AAC7B,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AASA,eAAsB,QACpB,OACA,QACyB;AACzB,SAAO,gBAAgB,OAAO,MAAM;AACtC;AAOO,SAAS,kBAA0B;AACxC,SAAO;AACT;","names":[]}
@@ -1,9 +1,9 @@
1
- import {
2
- runWarpGrep
3
- } from "./chunk-EAA7D24N.js";
4
1
  import {
5
2
  LocalRipgrepProvider
6
3
  } from "./chunk-UYBIKZPM.js";
4
+ import {
5
+ runWarpGrep
6
+ } from "./chunk-JJ5ONKDN.js";
7
7
 
8
8
  // tools/warp_grep/vercel.ts
9
9
  import { tool } from "ai";
@@ -41,4 +41,4 @@ function createMorphWarpGrepTool(config) {
41
41
  export {
42
42
  createMorphWarpGrepTool
43
43
  };
44
- //# sourceMappingURL=chunk-YSBSDU75.js.map
44
+ //# sourceMappingURL=chunk-BGDEQTRF.js.map
@@ -1,15 +1,15 @@
1
- import {
2
- toolRead
3
- } from "./chunk-Z2FBMSNE.js";
4
- import {
5
- getSystemPrompt
6
- } from "./chunk-HKZB23U7.js";
7
1
  import {
8
2
  toolAnalyse
9
3
  } from "./chunk-73RQWOQC.js";
10
4
  import {
11
5
  readFinishFiles
12
6
  } from "./chunk-EK7OQPWD.js";
7
+ import {
8
+ toolRead
9
+ } from "./chunk-Z2FBMSNE.js";
10
+ import {
11
+ getSystemPrompt
12
+ } from "./chunk-HKZB23U7.js";
13
13
  import {
14
14
  AGENT_CONFIG,
15
15
  DEFAULT_MODEL
@@ -198,4 +198,4 @@ async function runWarpGrep(config) {
198
198
  export {
199
199
  runWarpGrep
200
200
  };
201
- //# sourceMappingURL=chunk-EAA7D24N.js.map
201
+ //# sourceMappingURL=chunk-JJ5ONKDN.js.map
@@ -1,20 +1,20 @@
1
1
  import {
2
- BrowserClient
3
- } from "./chunk-NCVWIW7L.js";
2
+ AnthropicRouter,
3
+ GeminiRouter,
4
+ OpenAIRouter
5
+ } from "./chunk-AKVAAKRB.js";
4
6
  import {
5
7
  CodebaseSearchClient
6
8
  } from "./chunk-AG3ICTC5.js";
7
- import {
8
- FastApplyClient
9
- } from "./chunk-Q7USYY6R.js";
10
9
  import {
11
10
  MorphGit
12
11
  } from "./chunk-TBVDBQZ2.js";
13
12
  import {
14
- AnthropicRouter,
15
- GeminiRouter,
16
- OpenAIRouter
17
- } from "./chunk-AKVAAKRB.js";
13
+ FastApplyClient
14
+ } from "./chunk-Q7USYY6R.js";
15
+ import {
16
+ BrowserClient
17
+ } from "./chunk-NCVWIW7L.js";
18
18
 
19
19
  // client.ts
20
20
  var MorphClient = class {
@@ -94,4 +94,4 @@ var MorphClient = class {
94
94
  export {
95
95
  MorphClient
96
96
  };
97
- //# sourceMappingURL=chunk-CMKITT6X.js.map
97
+ //# sourceMappingURL=chunk-U6ZHZ5LY.js.map
@@ -1,9 +1,9 @@
1
- import {
2
- runWarpGrep
3
- } from "./chunk-EAA7D24N.js";
4
1
  import {
5
2
  LocalRipgrepProvider
6
3
  } from "./chunk-UYBIKZPM.js";
4
+ import {
5
+ runWarpGrep
6
+ } from "./chunk-JJ5ONKDN.js";
7
7
 
8
8
  // tools/warp_grep/anthropic.ts
9
9
  import { z } from "zod";
@@ -50,4 +50,4 @@ function createMorphWarpGrepTool(config) {
50
50
  export {
51
51
  createMorphWarpGrepTool
52
52
  };
53
- //# sourceMappingURL=chunk-W5CHJ6OX.js.map
53
+ //# sourceMappingURL=chunk-VD7US3AJ.js.map
@@ -0,0 +1,114 @@
1
+ import { RetryConfig } from './tools/utils/resilience.js';
2
+ import { FastApplyClient } from './tools/fastapply/core.js';
3
+ import { CodebaseSearchClient } from './tools/codebase_search/core.js';
4
+ import { BrowserClient } from './tools/browser/core.js';
5
+ import { MorphGit } from './git/client.js';
6
+ import { OpenAIRouter, AnthropicRouter, GeminiRouter } from './modelrouter/core.js';
7
+ import './git/types.js';
8
+ import './tools/fastapply/types.js';
9
+ import './tools/codebase_search/types.js';
10
+ import './tools/browser/types.js';
11
+ import './modelrouter/types.js';
12
+ import 'isomorphic-git';
13
+ import 'isomorphic-git/http/node';
14
+
15
+ /**
16
+ * Unified Morph SDK Client
17
+ *
18
+ * Provides access to all Morph tools through a single interface
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { MorphClient } from '@cuda_oom/morphsdk';
23
+ *
24
+ * const morph = new MorphClient({
25
+ * apiKey: process.env.MORPH_API_KEY,
26
+ * debug: true,
27
+ * timeout: 60000
28
+ * });
29
+ *
30
+ * // Use FastApply
31
+ * const editResult = await morph.fastApply.execute({
32
+ * target_filepath: 'src/index.ts',
33
+ * instructions: 'Add error handling',
34
+ * code_edit: 'try { ... } catch (e) { ... }'
35
+ * });
36
+ *
37
+ * // Use CodebaseSearch
38
+ * const searchResult = await morph.codebaseSearch.search({
39
+ * query: 'authentication logic',
40
+ * repoId: 'my-project'
41
+ * });
42
+ *
43
+ * // Use Browser automation
44
+ * const browserResult = await morph.browser.execute({
45
+ * task: 'Test the checkout flow',
46
+ * url: 'https://example.com'
47
+ * });
48
+ *
49
+ * // Use Model Router
50
+ * const { model } = await morph.routers.openai.selectModel({
51
+ * input: 'Complex refactoring task',
52
+ * mode: 'balanced'
53
+ * });
54
+ * ```
55
+ */
56
+
57
+ /**
58
+ * Configuration for the MorphClient
59
+ */
60
+ interface MorphClientConfig {
61
+ /** Morph API key for authentication (defaults to MORPH_API_KEY env var) */
62
+ apiKey?: string;
63
+ /** Enable debug logging across all tools */
64
+ debug?: boolean;
65
+ /** Default timeout in milliseconds for API requests */
66
+ timeout?: number;
67
+ /** Retry configuration for failed requests */
68
+ retryConfig?: RetryConfig;
69
+ }
70
+ /**
71
+ * Unified Morph SDK Client
72
+ *
73
+ * Provides access to all Morph tools through a single interface:
74
+ * - fastApply: AI-powered file editing with intelligent merging
75
+ * - codebaseSearch: Semantic code search
76
+ * - browser: AI-powered browser automation
77
+ * - git: Version control operations
78
+ * - routers: Intelligent model selection (OpenAI, Anthropic, Gemini)
79
+ */
80
+ declare class MorphClient {
81
+ /** Client configuration */
82
+ config: MorphClientConfig;
83
+ /** FastApply tool for editing files with AI-powered merge */
84
+ fastApply: FastApplyClient;
85
+ /** CodebaseSearch tool for semantic code search */
86
+ codebaseSearch: CodebaseSearchClient;
87
+ /** Browser tool for AI-powered browser automation */
88
+ browser: BrowserClient;
89
+ /** Git tool for version control operations */
90
+ git: MorphGit;
91
+ /** Model routers for intelligent model selection */
92
+ routers: {
93
+ openai: OpenAIRouter;
94
+ anthropic: AnthropicRouter;
95
+ gemini: GeminiRouter;
96
+ };
97
+ /**
98
+ * Create a new Morph SDK client
99
+ *
100
+ * @param config - Client configuration (apiKey, debug, timeout, retryConfig)
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const morph = new MorphClient({
105
+ * apiKey: process.env.MORPH_API_KEY,
106
+ * debug: true,
107
+ * timeout: 60000
108
+ * });
109
+ * ```
110
+ */
111
+ constructor(config?: MorphClientConfig);
112
+ }
113
+
114
+ export { MorphClient, type MorphClientConfig };
package/dist/client.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  MorphClient
3
- } from "./chunk-CMKITT6X.js";
4
- import "./chunk-NCVWIW7L.js";
3
+ } from "./chunk-U6ZHZ5LY.js";
4
+ import "./chunk-AKVAAKRB.js";
5
5
  import "./chunk-AG3ICTC5.js";
6
- import "./chunk-Q7USYY6R.js";
7
6
  import "./chunk-Q7PDN7TS.js";
8
7
  import "./chunk-TBVDBQZ2.js";
9
- import "./chunk-AKVAAKRB.js";
8
+ import "./chunk-Q7USYY6R.js";
9
+ import "./chunk-NCVWIW7L.js";
10
10
  import "./chunk-4VWJFZVS.js";
11
11
  import "./chunk-PZ5AY32C.js";
12
12
  export {
@@ -0,0 +1,261 @@
1
+ import { MorphGitConfig, CloneOptions, PushOptions, PullOptions, AddOptions, CommitOptions, StatusOptions, LogOptions, CommitObject, CheckoutOptions, BranchOptions, StatusResult, CommitMetadata } from './types.js';
2
+ import 'isomorphic-git';
3
+ import 'isomorphic-git/http/node';
4
+ import '../tools/utils/resilience.js';
5
+
6
+ /**
7
+ * Morph Git Client - Simple, high-level Git operations
8
+ * Built on isomorphic-git with explicit configuration
9
+ */
10
+
11
+ /**
12
+ * MorphGit - Git operations for AI agents with Morph backend
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { MorphGit } from 'morphsdk/git';
17
+ *
18
+ * const morphGit = new MorphGit({
19
+ * apiKey: process.env.MORPH_API_KEY!,
20
+ * proxyUrl: 'https://repos.morphllm.com' // Optional
21
+ * });
22
+ *
23
+ * await morphGit.init({ repoId: 'my-project', dir: './my-project' });
24
+ * await morphGit.push({ dir: './my-project' });
25
+ * ```
26
+ */
27
+ declare class MorphGit {
28
+ private readonly apiKey;
29
+ private readonly proxyUrl;
30
+ constructor(config: MorphGitConfig);
31
+ /**
32
+ * Get auth callback for isomorphic-git operations
33
+ * @private
34
+ */
35
+ private getAuthCallback;
36
+ /**
37
+ * Initialize a new repository
38
+ * Creates the repo in the database and in the git provider
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * await morphGit.init({
43
+ * repoId: 'my-project',
44
+ * dir: './my-project',
45
+ * defaultBranch: 'main'
46
+ * });
47
+ * ```
48
+ */
49
+ init(options: {
50
+ repoId: string;
51
+ dir: string;
52
+ defaultBranch?: string;
53
+ }): Promise<void>;
54
+ /**
55
+ * Clone a repository from Morph repos
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * await morphGit.clone({
60
+ * repoId: 'my-project',
61
+ * dir: './my-project'
62
+ * });
63
+ * ```
64
+ */
65
+ clone(options: CloneOptions): Promise<void>;
66
+ /**
67
+ * Push changes to remote repository
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * await morphGit.push({
72
+ * dir: './my-project',
73
+ * branch: 'main' // Required: explicit branch name
74
+ * });
75
+ * ```
76
+ */
77
+ push(options: PushOptions): Promise<void>;
78
+ /**
79
+ * Pull changes from remote repository
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * await morphGit.pull({
84
+ * dir: './my-project',
85
+ * branch: 'main' // Required: explicit branch name
86
+ * });
87
+ * ```
88
+ */
89
+ pull(options: PullOptions): Promise<void>;
90
+ /**
91
+ * Stage a file for commit
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * await morphGit.add({
96
+ * dir: './my-project',
97
+ * filepath: 'src/app.ts'
98
+ * });
99
+ * ```
100
+ */
101
+ add(options: AddOptions): Promise<void>;
102
+ /**
103
+ * Remove a file from staging
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * await morphGit.remove({
108
+ * dir: './my-project',
109
+ * filepath: 'src/old-file.ts'
110
+ * });
111
+ * ```
112
+ */
113
+ remove(options: AddOptions): Promise<void>;
114
+ /**
115
+ * Commit staged changes
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * await morphGit.commit({
120
+ * dir: './my-project',
121
+ * message: 'Add new feature',
122
+ * author: {
123
+ * name: 'AI Agent',
124
+ * email: 'ai@example.com'
125
+ * },
126
+ * chatHistory: [
127
+ * { role: 'user', content: 'Please add a new feature' },
128
+ * { role: 'assistant', content: 'I will add that feature' }
129
+ * ],
130
+ * recordingId: 'rec_123'
131
+ * });
132
+ * ```
133
+ */
134
+ commit(options: CommitOptions): Promise<string>;
135
+ /**
136
+ * Get status of a file
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * const status = await morphGit.status({
141
+ * dir: './my-project',
142
+ * filepath: 'src/app.ts'
143
+ * });
144
+ * console.log(status); // 'modified', '*added', etc.
145
+ * ```
146
+ */
147
+ status(options: StatusOptions): Promise<string>;
148
+ /**
149
+ * Get commit history
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * const commits = await morphGit.log({
154
+ * dir: './my-project',
155
+ * depth: 10
156
+ * });
157
+ * ```
158
+ */
159
+ log(options: LogOptions): Promise<CommitObject[]>;
160
+ /**
161
+ * Checkout a branch or commit
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * await morphGit.checkout({
166
+ * dir: './my-project',
167
+ * ref: 'feature-branch'
168
+ * });
169
+ * ```
170
+ */
171
+ checkout(options: CheckoutOptions): Promise<void>;
172
+ /**
173
+ * Create a new branch
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * await morphGit.branch({
178
+ * dir: './my-project',
179
+ * name: 'feature-branch',
180
+ * checkout: true
181
+ * });
182
+ * ```
183
+ */
184
+ branch(options: BranchOptions): Promise<void>;
185
+ /**
186
+ * List all branches
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * const branches = await morphGit.listBranches({
191
+ * dir: './my-project'
192
+ * });
193
+ * ```
194
+ */
195
+ listBranches(options: {
196
+ dir: string;
197
+ }): Promise<string[]>;
198
+ /**
199
+ * Get the current branch name
200
+ *
201
+ * @example
202
+ * ```ts
203
+ * const branch = await morphGit.currentBranch({
204
+ * dir: './my-project'
205
+ * });
206
+ * ```
207
+ */
208
+ currentBranch(options: {
209
+ dir: string;
210
+ }): Promise<string | undefined>;
211
+ /**
212
+ * Get list of changed files (similar to git diff --name-only)
213
+ *
214
+ * @example
215
+ * ```ts
216
+ * const changes = await morphGit.statusMatrix({
217
+ * dir: './my-project'
218
+ * });
219
+ * ```
220
+ */
221
+ statusMatrix(options: {
222
+ dir: string;
223
+ }): Promise<StatusResult[]>;
224
+ /**
225
+ * Get the current commit hash
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * const hash = await morphGit.resolveRef({
230
+ * dir: './my-project',
231
+ * ref: 'HEAD'
232
+ * });
233
+ * ```
234
+ */
235
+ resolveRef(options: {
236
+ dir: string;
237
+ ref: string;
238
+ }): Promise<string>;
239
+ /**
240
+ * Get metadata (chat history, recording ID) attached to a commit
241
+ *
242
+ * @example
243
+ * ```ts
244
+ * const metadata = await morphGit.getCommitMetadata({
245
+ * dir: './my-project',
246
+ * commitSha: 'abc123...'
247
+ * });
248
+ *
249
+ * if (metadata) {
250
+ * console.log('Chat history:', metadata.chatHistory);
251
+ * console.log('Recording ID:', metadata.recordingId);
252
+ * }
253
+ * ```
254
+ */
255
+ getCommitMetadata(options: {
256
+ dir: string;
257
+ commitSha: string;
258
+ }): Promise<CommitMetadata | null>;
259
+ }
260
+
261
+ export { MorphGit };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Configuration constants for Morph Git SDK
3
+ */
4
+ /** Default proxy URL for Morph git operations */
5
+ declare const DEFAULT_PROXY_URL = "https://repos.morphllm.com";
6
+ /**
7
+ * Validate API key format
8
+ */
9
+ declare function validateApiKey(apiKey: string): void;
10
+
11
+ export { DEFAULT_PROXY_URL, validateApiKey };
@@ -0,0 +1,5 @@
1
+ export { MorphGit } from './client.js';
2
+ export { AddOptions, BranchOptions, ChatMessage, CheckoutOptions, CloneOptions, CommitMetadata, CommitObject, CommitOptions, DiffOptions, LogOptions, MorphGitConfig, PullOptions, PushOptions, StatusOptions, StatusResult } from './types.js';
3
+ export { default as git } from 'isomorphic-git';
4
+ export { default as http } from 'isomorphic-git/http/node';
5
+ import '../tools/utils/resilience.js';