@morphllm/morphsdk 0.2.16 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-UIEIJZA3.js → chunk-GPFHYUKV.js} +2 -1
- package/dist/chunk-GPFHYUKV.js.map +1 -0
- package/dist/{chunk-CDFM7C52.js → chunk-UFIIEUGW.js} +9 -9
- package/dist/{chunk-HGIFACNP.js → chunk-VONZKK4S.js} +2 -3
- package/dist/chunk-VONZKK4S.js.map +1 -0
- package/dist/{chunk-KP75GOQS.js → chunk-Y5RCNDLV.js} +3 -5
- package/dist/chunk-Y5RCNDLV.js.map +1 -0
- package/dist/client.cjs +1 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +5 -5
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -11
- package/dist/tools/browser/anthropic.cjs +1 -0
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +1 -1
- package/dist/tools/browser/core.cjs +1 -0
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +1 -1
- package/dist/tools/browser/index.cjs +1 -0
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +1 -1
- package/dist/tools/browser/openai.cjs +1 -0
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +1 -1
- package/dist/tools/browser/types.cjs.map +1 -1
- package/dist/tools/browser/vercel.cjs +1 -0
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +1 -1
- package/dist/tools/codebase_search/index.cjs +1 -2
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +4 -4
- package/dist/tools/codebase_search/vercel.cjs +1 -2
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +1 -1
- package/dist/tools/fastapply/index.cjs +2 -4
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +4 -4
- package/dist/tools/fastapply/vercel.cjs +2 -4
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +1 -1
- package/dist/tools/index.cjs +2 -4
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +4 -4
- package/package.json +2 -2
- package/dist/anthropic-CknfcMoO.d.ts +0 -64
- package/dist/chunk-HGIFACNP.js.map +0 -1
- package/dist/chunk-KP75GOQS.js.map +0 -1
- package/dist/chunk-UIEIJZA3.js.map +0 -1
- package/dist/client.d.ts +0 -114
- package/dist/git/client.d.ts +0 -230
- package/dist/git/config.d.ts +0 -11
- package/dist/git/index.d.ts +0 -5
- package/dist/git/types.d.ts +0 -91
- package/dist/index.d.ts +0 -14
- package/dist/modelrouter/core.d.ts +0 -56
- package/dist/modelrouter/index.d.ts +0 -2
- package/dist/modelrouter/types.d.ts +0 -35
- package/dist/openai-BkKsS30n.d.ts +0 -111
- package/dist/tools/browser/anthropic.d.ts +0 -51
- package/dist/tools/browser/core.d.ts +0 -196
- package/dist/tools/browser/index.d.ts +0 -72
- package/dist/tools/browser/openai.d.ts +0 -69
- package/dist/tools/browser/prompts.d.ts +0 -7
- package/dist/tools/browser/types.d.ts +0 -225
- package/dist/tools/browser/vercel.d.ts +0 -128
- package/dist/tools/codebase_search/anthropic.d.ts +0 -40
- package/dist/tools/codebase_search/core.d.ts +0 -40
- package/dist/tools/codebase_search/index.d.ts +0 -11
- package/dist/tools/codebase_search/openai.d.ts +0 -87
- package/dist/tools/codebase_search/prompts.d.ts +0 -7
- package/dist/tools/codebase_search/types.d.ts +0 -46
- package/dist/tools/codebase_search/vercel.d.ts +0 -100
- package/dist/tools/fastapply/anthropic.d.ts +0 -4
- package/dist/tools/fastapply/core.d.ts +0 -41
- package/dist/tools/fastapply/index.d.ts +0 -11
- package/dist/tools/fastapply/openai.d.ts +0 -4
- package/dist/tools/fastapply/prompts.d.ts +0 -7
- package/dist/tools/fastapply/types.d.ts +0 -77
- package/dist/tools/fastapply/vercel.d.ts +0 -5
- package/dist/tools/index.d.ts +0 -11
- package/dist/tools/utils/resilience.d.ts +0 -58
- package/dist/vercel-Cd1wjuoK.d.ts +0 -108
- /package/dist/{chunk-CDFM7C52.js.map → chunk-UFIIEUGW.js.map} +0 -0
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { EditFileInput, EditFileConfig, EditFileResult, EditChanges } from './types.js';
|
|
2
|
-
import '../utils/resilience.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Core implementation of Morph Fast Apply
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* FastApply client for programmatic file editing
|
|
10
|
-
*/
|
|
11
|
-
declare class FastApplyClient {
|
|
12
|
-
private config;
|
|
13
|
-
constructor(config?: {
|
|
14
|
-
apiKey?: string;
|
|
15
|
-
debug?: boolean;
|
|
16
|
-
timeout?: number;
|
|
17
|
-
retryConfig?: any;
|
|
18
|
-
});
|
|
19
|
-
/**
|
|
20
|
-
* Execute a file edit operation
|
|
21
|
-
*
|
|
22
|
-
* @param input - Edit parameters including filepath, instructions, and code_edit
|
|
23
|
-
* @param overrides - Optional config overrides for this operation
|
|
24
|
-
* @returns Edit result with success status and changes
|
|
25
|
-
*/
|
|
26
|
-
execute(input: EditFileInput, overrides?: Partial<EditFileConfig>): Promise<EditFileResult>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Generate a unified diff between two strings
|
|
30
|
-
*/
|
|
31
|
-
declare function generateUdiff(original: string, modified: string, filepath: string): string;
|
|
32
|
-
/**
|
|
33
|
-
* Count changes from a unified diff
|
|
34
|
-
*/
|
|
35
|
-
declare function countChanges(original: string, modified: string): EditChanges;
|
|
36
|
-
/**
|
|
37
|
-
* Execute a file edit using Morph Fast Apply
|
|
38
|
-
*/
|
|
39
|
-
declare function executeEditFile(input: EditFileInput, config?: EditFileConfig): Promise<EditFileResult>;
|
|
40
|
-
|
|
41
|
-
export { FastApplyClient, countChanges, executeEditFile, generateUdiff };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { countChanges, executeEditFile, generateUdiff } from './core.js';
|
|
2
|
-
export { EditChanges, EditFileConfig, EditFileInput, EditFileResult } from './types.js';
|
|
3
|
-
export { EDIT_FILE_SYSTEM_PROMPT, EDIT_FILE_TOOL_DESCRIPTION } from './prompts.js';
|
|
4
|
-
export { a as anthropic } from '../../anthropic-CknfcMoO.js';
|
|
5
|
-
export { o as openai } from '../../openai-BkKsS30n.js';
|
|
6
|
-
export { v as vercel } from '../../vercel-Cd1wjuoK.js';
|
|
7
|
-
import '../utils/resilience.js';
|
|
8
|
-
import '@anthropic-ai/sdk/resources/messages';
|
|
9
|
-
import 'openai/resources/chat/completions';
|
|
10
|
-
import 'ai';
|
|
11
|
-
import 'zod';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* System prompts for edit_file tool
|
|
3
|
-
*/
|
|
4
|
-
declare const EDIT_FILE_TOOL_DESCRIPTION = "Use this tool to make an edit to an existing file.\n\nThis will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.\n\nWhen writing the edit, you should specify each edit in sequence, with the special comment // ... existing code ... to represent unchanged code in between edited lines.\n\nFor example:\n\n// ... existing code ...\nFIRST_EDIT\n// ... existing code ...\nSECOND_EDIT\n// ... existing code ...\nTHIRD_EDIT\n// ... existing code ...\n\nYou should still bias towards repeating as few lines of the original file as possible to convey the change.\nBut, each edit should contain minimally sufficient context of unchanged lines around the code you're editing to resolve ambiguity.\n\nDO NOT omit spans of pre-existing code (or comments) without using the // ... existing code ... comment to indicate its absence. If you omit the existing code comment, the model may inadvertently delete these lines.\n\nIf you plan on deleting a section, you must provide context before and after to delete it.\n\nMake sure it is clear what the edit should be, and where it should be applied.\nMake edits to a file in a single edit_file call instead of multiple edit_file calls to the same file. The apply model can handle many distinct edits at once.";
|
|
5
|
-
declare const EDIT_FILE_SYSTEM_PROMPT = "When the user is asking for edits to their code, use the edit_file tool to highlight the changes necessary and add comments to indicate where unchanged code has been skipped. For example:\n\n// ... existing code ...\n{{ edit_1 }}\n// ... existing code ...\n{{ edit_2 }}\n// ... existing code ...\n\nOften this will mean that the start/end of the file will be skipped, but that's okay! Rewrite the entire file ONLY if specifically requested. Always provide a brief explanation of the updates, unless the user specifically requests only the code.\n\nThese edit codeblocks are also read by a less intelligent language model, colloquially called the apply model, to update the file. To help specify the edit to the apply model, you will be very careful when generating the codeblock to not introduce ambiguity. You will specify all unchanged regions (code and comments) of the file with \"// ... existing code ...\" comment markers. This will ensure the apply model will not delete existing unchanged code or comments when editing the file.";
|
|
6
|
-
|
|
7
|
-
export { EDIT_FILE_SYSTEM_PROMPT, EDIT_FILE_TOOL_DESCRIPTION };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { RetryConfig } from '../utils/resilience.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Core types for Morph Fast Apply SDK
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Input parameters for the edit_file tool
|
|
9
|
-
*/
|
|
10
|
-
interface EditFileInput {
|
|
11
|
-
/** Path to the file to edit (relative to baseDir) */
|
|
12
|
-
target_filepath: string;
|
|
13
|
-
/** First-person description of what you're changing */
|
|
14
|
-
instructions: string;
|
|
15
|
-
/** Lazy edit with // ... existing code ... markers */
|
|
16
|
-
code_edit: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Statistics about the changes made
|
|
20
|
-
*/
|
|
21
|
-
interface EditChanges {
|
|
22
|
-
linesAdded: number;
|
|
23
|
-
linesRemoved: number;
|
|
24
|
-
linesModified: number;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Result returned after executing an edit
|
|
28
|
-
*/
|
|
29
|
-
interface EditFileResult {
|
|
30
|
-
/** Whether the edit was successful */
|
|
31
|
-
success: boolean;
|
|
32
|
-
/** Path to the edited file */
|
|
33
|
-
filepath: string;
|
|
34
|
-
/** Universal diff format showing changes */
|
|
35
|
-
udiff?: string;
|
|
36
|
-
/** Statistics about the changes */
|
|
37
|
-
changes: EditChanges;
|
|
38
|
-
/** Error message if unsuccessful */
|
|
39
|
-
error?: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Configuration options for the edit_file tool
|
|
43
|
-
*/
|
|
44
|
-
interface EditFileConfig {
|
|
45
|
-
/** Morph API key (defaults to MORPH_API_KEY env var) */
|
|
46
|
-
morphApiKey?: string;
|
|
47
|
-
/** Morph API base URL */
|
|
48
|
-
morphApiUrl?: string;
|
|
49
|
-
/** Base directory for file operations (defaults to cwd) */
|
|
50
|
-
baseDir?: string;
|
|
51
|
-
/** Whether to generate udiff (default: true) */
|
|
52
|
-
generateUdiff?: boolean;
|
|
53
|
-
/** Whether to automatically write to file (default: true) */
|
|
54
|
-
autoWrite?: boolean;
|
|
55
|
-
/** Custom system prompt (null to disable) */
|
|
56
|
-
systemPrompt?: string | null;
|
|
57
|
-
/** Custom tool description (defaults to EDIT_FILE_TOOL_DESCRIPTION) */
|
|
58
|
-
description?: string;
|
|
59
|
-
/** Timeout for API calls in ms (default: 30000) */
|
|
60
|
-
timeout?: number;
|
|
61
|
-
/** Retry configuration for API calls */
|
|
62
|
-
retryConfig?: RetryConfig;
|
|
63
|
-
/** Enable debug logging (default: false) */
|
|
64
|
-
debug?: boolean;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Response from Morph Apply API
|
|
68
|
-
*/
|
|
69
|
-
interface MorphApplyResponse {
|
|
70
|
-
choices: Array<{
|
|
71
|
-
message: {
|
|
72
|
-
content: string;
|
|
73
|
-
};
|
|
74
|
-
}>;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export type { EditChanges, EditFileConfig, EditFileInput, EditFileResult, MorphApplyResponse };
|
package/dist/tools/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { countChanges, executeEditFile, generateUdiff } from './fastapply/core.js';
|
|
2
|
-
export { EditChanges, EditFileConfig, EditFileInput, EditFileResult } from './fastapply/types.js';
|
|
3
|
-
export { EDIT_FILE_SYSTEM_PROMPT, EDIT_FILE_TOOL_DESCRIPTION } from './fastapply/prompts.js';
|
|
4
|
-
export { a as anthropic } from '../anthropic-CknfcMoO.js';
|
|
5
|
-
export { o as openai } from '../openai-BkKsS30n.js';
|
|
6
|
-
export { v as vercel } from '../vercel-Cd1wjuoK.js';
|
|
7
|
-
import './utils/resilience.js';
|
|
8
|
-
import '@anthropic-ai/sdk/resources/messages';
|
|
9
|
-
import 'openai/resources/chat/completions';
|
|
10
|
-
import 'ai';
|
|
11
|
-
import 'zod';
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resilience utilities for retry logic and timeout handling
|
|
3
|
-
*/
|
|
4
|
-
interface RetryConfig {
|
|
5
|
-
maxRetries?: number;
|
|
6
|
-
initialDelay?: number;
|
|
7
|
-
maxDelay?: number;
|
|
8
|
-
backoffMultiplier?: number;
|
|
9
|
-
retryableErrors?: string[];
|
|
10
|
-
onRetry?: (attempt: number, error: Error) => void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Retry a fetch request with exponential backoff
|
|
14
|
-
*
|
|
15
|
-
* @param url - Request URL
|
|
16
|
-
* @param options - Fetch options
|
|
17
|
-
* @param retryConfig - Retry configuration
|
|
18
|
-
* @returns Response from fetch
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* const response = await fetchWithRetry(
|
|
23
|
-
* 'https://api.example.com/data',
|
|
24
|
-
* { method: 'POST', body: JSON.stringify(data) },
|
|
25
|
-
* { maxRetries: 5, initialDelay: 500 }
|
|
26
|
-
* );
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
declare function fetchWithRetry(url: string, options: RequestInit, retryConfig?: RetryConfig): Promise<Response>;
|
|
30
|
-
/**
|
|
31
|
-
* Add timeout to any promise
|
|
32
|
-
*
|
|
33
|
-
* @param promise - Promise to wrap with timeout
|
|
34
|
-
* @param timeoutMs - Timeout in milliseconds
|
|
35
|
-
* @param errorMessage - Optional custom error message
|
|
36
|
-
* @returns Promise that rejects if timeout is reached
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const result = await withTimeout(
|
|
41
|
-
* fetchData(),
|
|
42
|
-
* 5000,
|
|
43
|
-
* 'Data fetch timed out'
|
|
44
|
-
* );
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, errorMessage?: string): Promise<T>;
|
|
48
|
-
/**
|
|
49
|
-
* Unified error type for all tools
|
|
50
|
-
*/
|
|
51
|
-
declare class MorphError extends Error {
|
|
52
|
-
code: string;
|
|
53
|
-
statusCode?: number | undefined;
|
|
54
|
-
retryable: boolean;
|
|
55
|
-
constructor(message: string, code: string, statusCode?: number | undefined, retryable?: boolean);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export { MorphError, type RetryConfig, fetchWithRetry, withTimeout };
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import * as ai from 'ai';
|
|
2
|
-
import { EditChanges, EditFileConfig } from './tools/fastapply/types.js';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
declare const editFileTool: ai.Tool<z.ZodObject<{
|
|
6
|
-
target_filepath: z.ZodString;
|
|
7
|
-
instructions: z.ZodString;
|
|
8
|
-
code_edit: z.ZodString;
|
|
9
|
-
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
target_filepath: string;
|
|
11
|
-
instructions: string;
|
|
12
|
-
code_edit: string;
|
|
13
|
-
}, {
|
|
14
|
-
target_filepath: string;
|
|
15
|
-
instructions: string;
|
|
16
|
-
code_edit: string;
|
|
17
|
-
}>, {
|
|
18
|
-
success: boolean;
|
|
19
|
-
filepath: string;
|
|
20
|
-
changes: EditChanges;
|
|
21
|
-
udiff: string | undefined;
|
|
22
|
-
}> & {
|
|
23
|
-
execute: (args: {
|
|
24
|
-
target_filepath: string;
|
|
25
|
-
instructions: string;
|
|
26
|
-
code_edit: string;
|
|
27
|
-
}, options: ai.ToolExecutionOptions) => PromiseLike<{
|
|
28
|
-
success: boolean;
|
|
29
|
-
filepath: string;
|
|
30
|
-
changes: EditChanges;
|
|
31
|
-
udiff: string | undefined;
|
|
32
|
-
}>;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Get the system prompt for edit_file usage
|
|
36
|
-
*
|
|
37
|
-
* Add this to your system message to guide the model on using edit_file properly.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* const result = await generateText({
|
|
42
|
-
* model: anthropic('claude-sonnet-4-5-20250929'),
|
|
43
|
-
* system: getSystemPrompt(),
|
|
44
|
-
* tools: { editFile: editFileTool },
|
|
45
|
-
* prompt: "Fix bugs"
|
|
46
|
-
* });
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
declare function getSystemPrompt(): string;
|
|
50
|
-
/**
|
|
51
|
-
* Create a custom edit_file tool with configuration
|
|
52
|
-
*
|
|
53
|
-
* @param config - Configuration options
|
|
54
|
-
* @returns Vercel AI SDK tool with custom config
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* const customEditTool = createEditFileTool({
|
|
59
|
-
* baseDir: './src',
|
|
60
|
-
* generateUdiff: true,
|
|
61
|
-
* description: 'Custom tool description for your use case'
|
|
62
|
-
* });
|
|
63
|
-
*
|
|
64
|
-
* const result = await generateText({
|
|
65
|
-
* model: anthropic('claude-sonnet-4-5-20250929'),
|
|
66
|
-
* tools: { editFile: customEditTool },
|
|
67
|
-
* prompt: "Fix bugs"
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
declare function createEditFileTool(config?: EditFileConfig): ai.Tool<z.ZodObject<{
|
|
72
|
-
target_filepath: z.ZodString;
|
|
73
|
-
instructions: z.ZodString;
|
|
74
|
-
code_edit: z.ZodString;
|
|
75
|
-
}, "strip", z.ZodTypeAny, {
|
|
76
|
-
target_filepath: string;
|
|
77
|
-
instructions: string;
|
|
78
|
-
code_edit: string;
|
|
79
|
-
}, {
|
|
80
|
-
target_filepath: string;
|
|
81
|
-
instructions: string;
|
|
82
|
-
code_edit: string;
|
|
83
|
-
}>, {
|
|
84
|
-
success: boolean;
|
|
85
|
-
filepath: string;
|
|
86
|
-
changes: EditChanges;
|
|
87
|
-
udiff: string | undefined;
|
|
88
|
-
}> & {
|
|
89
|
-
execute: (args: {
|
|
90
|
-
target_filepath: string;
|
|
91
|
-
instructions: string;
|
|
92
|
-
code_edit: string;
|
|
93
|
-
}, options: ai.ToolExecutionOptions) => PromiseLike<{
|
|
94
|
-
success: boolean;
|
|
95
|
-
filepath: string;
|
|
96
|
-
changes: EditChanges;
|
|
97
|
-
udiff: string | undefined;
|
|
98
|
-
}>;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
declare const vercel_createEditFileTool: typeof createEditFileTool;
|
|
102
|
-
declare const vercel_editFileTool: typeof editFileTool;
|
|
103
|
-
declare const vercel_getSystemPrompt: typeof getSystemPrompt;
|
|
104
|
-
declare namespace vercel {
|
|
105
|
-
export { vercel_createEditFileTool as createEditFileTool, editFileTool as default, vercel_editFileTool as editFileTool, vercel_getSystemPrompt as getSystemPrompt };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export { createEditFileTool as c, editFileTool as e, getSystemPrompt as g, vercel as v };
|
|
File without changes
|