@morphllm/morphsdk 0.2.104 → 0.2.106

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.
@@ -0,0 +1,733 @@
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 { WarpGrepClient } from './tools/warp_grep/client.js';
6
+ import { MorphGit } from './git/client.js';
7
+ import { OpenAIRouter, AnthropicRouter, GeminiRouter, RawRouter } from './modelrouter/core.js';
8
+ import { EditFileConfig, EditFileInput, EditFileResult, EditChanges } from './tools/fastapply/types.js';
9
+ import { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './tools/codebase_search/types.js';
10
+ import { d as WarpGrepToolConfig, b as WarpGrepResult, c as WarpGrepContext } from './types-BMowL9iZ.js';
11
+ import * as openai_resources_index_mjs from 'openai/resources/index.mjs';
12
+ import * as _anthropic_ai_sdk_resources_messages_mjs from '@anthropic-ai/sdk/resources/messages.mjs';
13
+ import * as ai from 'ai';
14
+ import { WarpGrepInput } from './tools/warp_grep/vercel.js';
15
+
16
+ /**
17
+ * GitHub SDK Types
18
+ *
19
+ * Type definitions for the Morph GitHub integration.
20
+ * Users connect GitHub in the Morph dashboard, then use these
21
+ * types to interact with their GitHub repos through the SDK.
22
+ */
23
+ /**
24
+ * Configuration for the GitHub client
25
+ */
26
+ interface GitHubClientConfig {
27
+ /** Morph API key (defaults to MORPH_API_KEY env var) */
28
+ apiKey?: string;
29
+ /** Default installation ID to use (optional, can be specified per-request) */
30
+ installationId?: string;
31
+ /** Base URL for the Morph API (defaults to https://api.morphllm.com) */
32
+ baseUrl?: string;
33
+ /** Request timeout in milliseconds */
34
+ timeout?: number;
35
+ /** Enable debug logging */
36
+ debug?: boolean;
37
+ }
38
+ /**
39
+ * A GitHub App installation (connected GitHub account)
40
+ */
41
+ interface Installation {
42
+ /** Installation ID (use this for subsequent requests) */
43
+ id: string;
44
+ /** GitHub account login (username or org name) */
45
+ accountLogin: string;
46
+ /** Account type */
47
+ accountType: "User" | "Organization";
48
+ /** Custom display name (set in Morph dashboard) */
49
+ displayName?: string;
50
+ }
51
+ /**
52
+ * A GitHub repository
53
+ */
54
+ interface Repo {
55
+ /** GitHub's numeric repo ID */
56
+ id: number;
57
+ /** Repository name (e.g., "app") */
58
+ name: string;
59
+ /** Full name including owner (e.g., "acme/app") */
60
+ fullName: string;
61
+ /** Whether the repo is private */
62
+ private: boolean;
63
+ /** Default branch name */
64
+ defaultBranch?: string;
65
+ }
66
+ /**
67
+ * A pull request (basic info)
68
+ */
69
+ interface PullRequest {
70
+ /** PR number */
71
+ number: number;
72
+ /** PR title */
73
+ title: string;
74
+ /** PR description/body */
75
+ body: string | null;
76
+ /** PR state */
77
+ state: "open" | "closed";
78
+ /** Author's GitHub username */
79
+ author: string;
80
+ /** HEAD commit SHA */
81
+ headSha: string;
82
+ /** Base branch name */
83
+ baseBranch: string;
84
+ /** HEAD branch name */
85
+ headBranch: string;
86
+ /** Creation timestamp (ISO 8601) */
87
+ createdAt: string;
88
+ /** Last update timestamp (ISO 8601) */
89
+ updatedAt: string;
90
+ }
91
+ /**
92
+ * A pull request with full context (diff and files)
93
+ */
94
+ interface PullRequestWithContext extends PullRequest {
95
+ /** Full unified diff */
96
+ diff: string;
97
+ /** List of changed files with patches */
98
+ files: FileChange[];
99
+ }
100
+ /**
101
+ * A file changed in a pull request
102
+ */
103
+ interface FileChange {
104
+ /** File path */
105
+ filename: string;
106
+ /** Change status */
107
+ status: "added" | "removed" | "modified" | "renamed";
108
+ /** Number of lines added */
109
+ additions: number;
110
+ /** Number of lines deleted */
111
+ deletions: number;
112
+ /** Unified diff patch for this file */
113
+ patch?: string;
114
+ }
115
+ /**
116
+ * A deployment (e.g., Vercel preview)
117
+ */
118
+ interface Deployment {
119
+ /** Deployment ID */
120
+ id: number;
121
+ /** Commit SHA this deployment is for */
122
+ sha: string;
123
+ /** Environment name (e.g., "preview", "production") */
124
+ environment: string;
125
+ /** Deployment state */
126
+ state: "pending" | "success" | "failure" | "error" | "inactive" | "in_progress" | "queued";
127
+ /** Preview/deployment URL (if available) */
128
+ url: string | null;
129
+ /** Creation timestamp (ISO 8601) */
130
+ createdAt: string;
131
+ }
132
+ /**
133
+ * A comment on a PR/issue
134
+ */
135
+ interface Comment {
136
+ /** Comment ID */
137
+ id: number;
138
+ /** Comment body/content */
139
+ body: string;
140
+ /** Author's GitHub username */
141
+ author: string;
142
+ /** Creation timestamp (ISO 8601) */
143
+ createdAt: string;
144
+ /** Last update timestamp (ISO 8601) */
145
+ updatedAt: string;
146
+ }
147
+ /**
148
+ * A GitHub check run (CI status)
149
+ */
150
+ interface CheckRun {
151
+ /** Check run ID */
152
+ id: number;
153
+ /** Check run name */
154
+ name: string;
155
+ /** Current status */
156
+ status: "queued" | "in_progress" | "completed";
157
+ /** Conclusion (only set when status is "completed") */
158
+ conclusion?: "success" | "failure" | "neutral" | "cancelled" | "skipped" | "timed_out" | "action_required";
159
+ /** Start timestamp (ISO 8601) */
160
+ startedAt?: string;
161
+ /** Completion timestamp (ISO 8601) */
162
+ completedAt?: string;
163
+ }
164
+ /**
165
+ * Input for listing repositories
166
+ */
167
+ interface ListReposInput {
168
+ /** Installation ID to list repos for */
169
+ installationId: string;
170
+ }
171
+ /**
172
+ * Input for listing pull requests
173
+ */
174
+ interface ListPullRequestsInput {
175
+ /** Repository owner */
176
+ owner: string;
177
+ /** Repository name */
178
+ repo: string;
179
+ /** Filter by PR state (default: "open") */
180
+ state?: "open" | "closed" | "all";
181
+ /** Installation ID (uses default if not specified) */
182
+ installationId?: string;
183
+ }
184
+ /**
185
+ * Input for getting a single pull request
186
+ */
187
+ interface GetPullRequestInput {
188
+ /** Repository owner */
189
+ owner: string;
190
+ /** Repository name */
191
+ repo: string;
192
+ /** PR number */
193
+ number: number;
194
+ /** Installation ID (uses default if not specified) */
195
+ installationId?: string;
196
+ }
197
+ /**
198
+ * Input for listing deployments
199
+ */
200
+ interface ListDeploymentsInput {
201
+ /** Repository owner */
202
+ owner: string;
203
+ /** Repository name */
204
+ repo: string;
205
+ /** Filter by commit SHA */
206
+ sha?: string;
207
+ /** Filter by environment name */
208
+ environment?: string;
209
+ /** Installation ID (uses default if not specified) */
210
+ installationId?: string;
211
+ }
212
+ /**
213
+ * Input for listing comments on a PR
214
+ */
215
+ interface ListCommentsInput {
216
+ /** Repository owner */
217
+ owner: string;
218
+ /** Repository name */
219
+ repo: string;
220
+ /** PR number */
221
+ pr: number;
222
+ /** Installation ID (uses default if not specified) */
223
+ installationId?: string;
224
+ }
225
+ /**
226
+ * Input for creating a comment
227
+ */
228
+ interface CreateCommentInput {
229
+ /** Repository owner */
230
+ owner: string;
231
+ /** Repository name */
232
+ repo: string;
233
+ /** PR number */
234
+ pr: number;
235
+ /** Comment body (Markdown supported) */
236
+ body: string;
237
+ /** Installation ID (uses default if not specified) */
238
+ installationId?: string;
239
+ }
240
+ /**
241
+ * Input for updating a comment
242
+ */
243
+ interface UpdateCommentInput {
244
+ /** Repository owner */
245
+ owner: string;
246
+ /** Repository name */
247
+ repo: string;
248
+ /** Comment ID to update */
249
+ commentId: number;
250
+ /** New comment body */
251
+ body: string;
252
+ /** Installation ID (uses default if not specified) */
253
+ installationId?: string;
254
+ }
255
+ /**
256
+ * Input for deleting a comment
257
+ */
258
+ interface DeleteCommentInput {
259
+ /** Repository owner */
260
+ owner: string;
261
+ /** Repository name */
262
+ repo: string;
263
+ /** Comment ID to delete */
264
+ commentId: number;
265
+ /** Installation ID (uses default if not specified) */
266
+ installationId?: string;
267
+ }
268
+ /**
269
+ * Input for creating a check run
270
+ */
271
+ interface CreateCheckRunInput {
272
+ /** Repository owner */
273
+ owner: string;
274
+ /** Repository name */
275
+ repo: string;
276
+ /** Commit SHA to create check run for */
277
+ sha: string;
278
+ /** Check run name (e.g., "Preview Test") */
279
+ name: string;
280
+ /** Initial status */
281
+ status: "queued" | "in_progress";
282
+ /** Output title */
283
+ title?: string;
284
+ /** Output summary (Markdown supported) */
285
+ summary?: string;
286
+ /** Installation ID (uses default if not specified) */
287
+ installationId?: string;
288
+ }
289
+ /**
290
+ * Input for updating a check run
291
+ */
292
+ interface UpdateCheckRunInput {
293
+ /** Repository owner */
294
+ owner: string;
295
+ /** Repository name */
296
+ repo: string;
297
+ /** Check run ID to update */
298
+ checkRunId: number;
299
+ /** New status */
300
+ status?: "queued" | "in_progress" | "completed";
301
+ /** Conclusion (required if status is "completed") */
302
+ conclusion?: CheckRun["conclusion"];
303
+ /** Output title */
304
+ title?: string;
305
+ /** Output summary (Markdown supported) */
306
+ summary?: string;
307
+ /** Output text (detailed info, Markdown supported) */
308
+ text?: string;
309
+ /** Installation ID (uses default if not specified) */
310
+ installationId?: string;
311
+ }
312
+ /**
313
+ * Error thrown by GitHub operations
314
+ */
315
+ declare class GitHubError extends Error {
316
+ /** HTTP status code */
317
+ status: number;
318
+ /** Error code from API */
319
+ code?: string;
320
+ constructor(message: string, status: number, code?: string);
321
+ }
322
+ /**
323
+ * Error thrown when no installation is found or specified
324
+ */
325
+ declare class NoInstallationError extends GitHubError {
326
+ constructor(message?: string);
327
+ }
328
+ /**
329
+ * Error thrown when resource is not found
330
+ */
331
+ declare class NotFoundError extends GitHubError {
332
+ constructor(resource: string);
333
+ }
334
+ /**
335
+ * Error thrown when user lacks permission
336
+ */
337
+ declare class PermissionError extends GitHubError {
338
+ constructor(message?: string);
339
+ }
340
+
341
+ /**
342
+ * GitHub SDK Client
343
+ *
344
+ * Provides access to GitHub repositories, pull requests, deployments,
345
+ * comments, and check runs through the user's connected GitHub account.
346
+ *
347
+ * All operations are proxied through the Morph API - installation tokens
348
+ * are never exposed to the client.
349
+ */
350
+
351
+ /**
352
+ * GitHub SDK Client
353
+ *
354
+ * @example
355
+ * ```typescript
356
+ * import { MorphClient } from '@morphllm/morphsdk';
357
+ *
358
+ * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
359
+ *
360
+ * // List installations
361
+ * const installations = await morph.github.installations.list();
362
+ *
363
+ * // Get PR with context
364
+ * const pr = await morph.github.pullRequests.get({
365
+ * owner: "acme",
366
+ * repo: "app",
367
+ * number: 42
368
+ * });
369
+ * ```
370
+ */
371
+ declare class GitHubClient {
372
+ private apiKey;
373
+ private baseUrl;
374
+ private timeout;
375
+ private debug;
376
+ private defaultInstallationId?;
377
+ /** Installation operations */
378
+ installations: {
379
+ list: () => Promise<Installation[]>;
380
+ get: (installationId: string) => Promise<Installation>;
381
+ };
382
+ /** Repository operations */
383
+ repos: {
384
+ list: (input: ListReposInput) => Promise<Repo[]>;
385
+ };
386
+ /** Pull request operations */
387
+ pullRequests: {
388
+ list: (input: ListPullRequestsInput) => Promise<PullRequest[]>;
389
+ get: (input: GetPullRequestInput) => Promise<PullRequestWithContext>;
390
+ };
391
+ /** Deployment operations */
392
+ deployments: {
393
+ list: (input: ListDeploymentsInput) => Promise<Deployment[]>;
394
+ };
395
+ /** Comment operations */
396
+ comments: {
397
+ list: (input: ListCommentsInput) => Promise<Comment[]>;
398
+ create: (input: CreateCommentInput) => Promise<Comment>;
399
+ update: (input: UpdateCommentInput) => Promise<Comment>;
400
+ delete: (input: DeleteCommentInput) => Promise<void>;
401
+ };
402
+ /** Check run operations */
403
+ checkRuns: {
404
+ create: (input: CreateCheckRunInput) => Promise<CheckRun>;
405
+ update: (input: UpdateCheckRunInput) => Promise<CheckRun>;
406
+ };
407
+ constructor(config?: GitHubClientConfig);
408
+ /**
409
+ * Make an API request to the Morph GitHub proxy
410
+ */
411
+ private request;
412
+ /**
413
+ * Get the installation ID to use for a request
414
+ */
415
+ private getInstallationId;
416
+ private listInstallations;
417
+ private getInstallation;
418
+ private listRepos;
419
+ private listPullRequests;
420
+ private getPullRequest;
421
+ private listDeployments;
422
+ private listComments;
423
+ private createComment;
424
+ private updateComment;
425
+ private deleteComment;
426
+ private createCheckRun;
427
+ private updateCheckRun;
428
+ }
429
+
430
+ /**
431
+ * Factory for creating OpenAI-compatible tools with inherited API key
432
+ *
433
+ * @example
434
+ * ```typescript
435
+ * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
436
+ *
437
+ * const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });
438
+ * const searchTool = morph.openai.createCodebaseSearchTool({ repoId: 'my-project' });
439
+ * const editTool = morph.openai.createEditFileTool({ baseDir: './src' });
440
+ *
441
+ * // Use with OpenAI client
442
+ * const response = await openai.chat.completions.create({
443
+ * model: 'gpt-4o',
444
+ * tools: [grepTool, searchTool, editTool],
445
+ * messages: [{ role: 'user', content: 'Find and fix the bug' }]
446
+ * });
447
+ * ```
448
+ */
449
+ declare class OpenAIToolFactory {
450
+ private config;
451
+ constructor(config: MorphClientConfig);
452
+ /**
453
+ * Create an OpenAI-compatible warp grep tool
454
+ *
455
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
456
+ * @returns OpenAI ChatCompletionTool with execute and formatResult methods
457
+ */
458
+ createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
459
+ execute: (input: unknown) => Promise<WarpGrepResult>;
460
+ formatResult: (result: WarpGrepResult) => string;
461
+ getSystemPrompt: () => string;
462
+ };
463
+ /**
464
+ * Create an OpenAI-compatible codebase search tool
465
+ *
466
+ * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
467
+ * @returns OpenAI ChatCompletionTool with execute and formatResult methods
468
+ */
469
+ createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
470
+ execute: (input: CodebaseSearchInput | string) => Promise<CodebaseSearchResult>;
471
+ formatResult: (result: CodebaseSearchResult) => string;
472
+ getSystemPrompt: () => string;
473
+ };
474
+ /**
475
+ * Create an OpenAI-compatible edit file tool
476
+ *
477
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
478
+ * @returns OpenAI ChatCompletionTool with execute and formatResult methods
479
+ */
480
+ createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): openai_resources_index_mjs.ChatCompletionTool & {
481
+ execute: (input: EditFileInput | string) => Promise<EditFileResult>;
482
+ formatResult: (result: EditFileResult) => string;
483
+ getSystemPrompt: () => string;
484
+ };
485
+ }
486
+
487
+ /**
488
+ * Factory for creating Anthropic-compatible tools with inherited API key
489
+ *
490
+ * @example
491
+ * ```typescript
492
+ * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
493
+ *
494
+ * const grepTool = morph.anthropic.createWarpGrepTool({ repoRoot: '.' });
495
+ * const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'my-project' });
496
+ * const editTool = morph.anthropic.createEditFileTool({ baseDir: './src' });
497
+ *
498
+ * // Use with Anthropic client
499
+ * const response = await anthropic.messages.create({
500
+ * model: 'claude-sonnet-4-5-20250929',
501
+ * tools: [grepTool, searchTool, editTool],
502
+ * messages: [{ role: 'user', content: 'Find and fix the bug' }]
503
+ * });
504
+ * ```
505
+ */
506
+ declare class AnthropicToolFactory {
507
+ private config;
508
+ constructor(config: MorphClientConfig);
509
+ /**
510
+ * Create an Anthropic-compatible warp grep tool
511
+ *
512
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
513
+ * @returns Anthropic Tool with execute and formatResult methods
514
+ */
515
+ createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
516
+ execute: (input: unknown) => Promise<WarpGrepResult>;
517
+ formatResult: (result: WarpGrepResult) => string;
518
+ getSystemPrompt: () => string;
519
+ };
520
+ /**
521
+ * Create an Anthropic-compatible codebase search tool
522
+ *
523
+ * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
524
+ * @returns Anthropic Tool with execute and formatResult methods
525
+ */
526
+ createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
527
+ execute: (input: CodebaseSearchInput) => Promise<CodebaseSearchResult>;
528
+ formatResult: (result: CodebaseSearchResult) => string;
529
+ getSystemPrompt: () => string;
530
+ };
531
+ /**
532
+ * Create an Anthropic-compatible edit file tool
533
+ *
534
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
535
+ * @returns Anthropic Tool with execute and formatResult methods
536
+ */
537
+ createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): _anthropic_ai_sdk_resources_messages_mjs.Tool & {
538
+ execute: (input: EditFileInput) => Promise<EditFileResult>;
539
+ formatResult: (result: EditFileResult) => string;
540
+ getSystemPrompt: () => string;
541
+ };
542
+ }
543
+
544
+ /**
545
+ * Factory for creating Vercel AI SDK-compatible tools with inherited API key
546
+ *
547
+ * @example
548
+ * ```typescript
549
+ * const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
550
+ *
551
+ * const grepTool = morph.vercel.createWarpGrepTool({ repoRoot: '.' });
552
+ * const searchTool = morph.vercel.createCodebaseSearchTool({ repoId: 'my-project' });
553
+ * const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });
554
+ *
555
+ * // Use with Vercel AI SDK
556
+ * const result = await generateText({
557
+ * model: anthropic('claude-sonnet-4-5-20250929'),
558
+ * tools: { grep: grepTool, search: searchTool, edit: editTool },
559
+ * prompt: 'Find and fix the bug'
560
+ * });
561
+ * ```
562
+ */
563
+ declare class VercelToolFactory {
564
+ private config;
565
+ constructor(config: MorphClientConfig);
566
+ /**
567
+ * Create a Vercel AI SDK-compatible warp grep tool
568
+ *
569
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
570
+ * @returns Vercel AI SDK tool
571
+ */
572
+ createWarpGrepTool(toolConfig: Omit<WarpGrepToolConfig, 'morphApiKey'>): ai.Tool<WarpGrepInput, {
573
+ success: boolean;
574
+ contexts: WarpGrepContext[] | undefined;
575
+ summary: string | undefined;
576
+ }>;
577
+ /**
578
+ * Create a Vercel AI SDK-compatible codebase search tool
579
+ *
580
+ * @param toolConfig - Tool configuration with repoId (apiKey inherited from MorphClient)
581
+ * @returns Vercel AI SDK tool
582
+ */
583
+ createCodebaseSearchTool(toolConfig: Omit<CodebaseSearchConfig, 'apiKey'>): ai.Tool<{
584
+ query: string;
585
+ target_directories: string[];
586
+ explanation: string;
587
+ limit?: number | undefined;
588
+ }, {
589
+ error: string | undefined;
590
+ results: never[];
591
+ found?: undefined;
592
+ searchTime?: undefined;
593
+ } | {
594
+ found: number;
595
+ searchTime: string;
596
+ results: {
597
+ file: string;
598
+ symbol: string;
599
+ lines: string;
600
+ language: string;
601
+ relevance: string;
602
+ code: string;
603
+ }[];
604
+ error?: undefined;
605
+ }>;
606
+ /**
607
+ * Create a Vercel AI SDK-compatible edit file tool
608
+ *
609
+ * @param toolConfig - Tool configuration (morphApiKey inherited from MorphClient)
610
+ * @returns Vercel AI SDK tool
611
+ */
612
+ createEditFileTool(toolConfig?: Omit<EditFileConfig, 'morphApiKey'>): ai.Tool<{
613
+ target_filepath: string;
614
+ instructions: string;
615
+ code_edit: string;
616
+ }, {
617
+ success: boolean;
618
+ filepath: string;
619
+ changes: EditChanges;
620
+ udiff: string | undefined;
621
+ }>;
622
+ }
623
+
624
+ /**
625
+ * Unified Morph SDK Client
626
+ *
627
+ * Provides access to all Morph tools through a single interface
628
+ *
629
+ * @example
630
+ * ```typescript
631
+ * import { MorphClient } from '@morphllm/morphsdk';
632
+ *
633
+ * const morph = new MorphClient({
634
+ * apiKey: process.env.MORPH_API_KEY,
635
+ * debug: true,
636
+ * timeout: 60000
637
+ * });
638
+ *
639
+ * // Direct execution
640
+ * await morph.fastApply.execute({ target_filepath: 'src/index.ts', ... });
641
+ * await morph.warpGrep.execute({ query: 'Find auth', repoRoot: '.' });
642
+ * await morph.codebaseSearch.search({ query: 'auth logic', repoId: 'x' });
643
+ *
644
+ * // Tool creation for AI agents (API key inherited)
645
+ * const grepTool = morph.openai.createWarpGrepTool({ repoRoot: '.' });
646
+ * const searchTool = morph.anthropic.createCodebaseSearchTool({ repoId: 'x' });
647
+ * const editTool = morph.vercel.createEditFileTool({ baseDir: './src' });
648
+ *
649
+ * // Use tools with OpenAI
650
+ * const response = await openai.chat.completions.create({
651
+ * model: 'gpt-4o',
652
+ * tools: [grepTool],
653
+ * messages: [{ role: 'user', content: 'Find the bug' }]
654
+ * });
655
+ * ```
656
+ */
657
+
658
+ /**
659
+ * Configuration for the MorphClient
660
+ */
661
+ interface MorphClientConfig {
662
+ /** Morph API key for authentication (defaults to MORPH_API_KEY env var) */
663
+ apiKey?: string;
664
+ /** Enable debug logging across all tools */
665
+ debug?: boolean;
666
+ /** Default timeout in milliseconds for API requests */
667
+ timeout?: number;
668
+ /** Retry configuration for failed requests */
669
+ retryConfig?: RetryConfig;
670
+ /** GitHub-specific configuration */
671
+ github?: {
672
+ /** Default installation ID for GitHub operations */
673
+ installationId?: string;
674
+ };
675
+ }
676
+ /**
677
+ * Unified Morph SDK Client
678
+ *
679
+ * Provides access to all Morph tools through a single interface:
680
+ * - fastApply: AI-powered file editing with intelligent merging
681
+ * - codebaseSearch: Semantic code search
682
+ * - warpGrep: Fast code search with ripgrep
683
+ * - browser: AI-powered browser automation
684
+ * - git: Version control operations
685
+ * - routers: Intelligent model selection (OpenAI, Anthropic, Gemini)
686
+ * - openai/anthropic/vercel: Tool factories for agent frameworks
687
+ */
688
+ declare class MorphClient {
689
+ /** Client configuration */
690
+ config: MorphClientConfig;
691
+ /** FastApply tool for editing files with AI-powered merge */
692
+ fastApply: FastApplyClient;
693
+ /** CodebaseSearch tool for semantic code search */
694
+ codebaseSearch: CodebaseSearchClient;
695
+ /** WarpGrep tool for fast code search using ripgrep */
696
+ warpGrep: WarpGrepClient;
697
+ /** Browser tool for AI-powered browser automation */
698
+ browser: BrowserClient;
699
+ /** GitHub tool for PR context, comments, and check runs */
700
+ github: GitHubClient;
701
+ /** Git tool for version control operations */
702
+ git: MorphGit;
703
+ /** Model routers for intelligent model selection */
704
+ routers: {
705
+ openai: OpenAIRouter;
706
+ anthropic: AnthropicRouter;
707
+ gemini: GeminiRouter;
708
+ raw: RawRouter;
709
+ };
710
+ /** OpenAI-compatible tool factories */
711
+ openai: OpenAIToolFactory;
712
+ /** Anthropic-compatible tool factories */
713
+ anthropic: AnthropicToolFactory;
714
+ /** Vercel AI SDK tool factories */
715
+ vercel: VercelToolFactory;
716
+ /**
717
+ * Create a new Morph SDK client
718
+ *
719
+ * @param config - Client configuration (apiKey, debug, timeout, retryConfig)
720
+ *
721
+ * @example
722
+ * ```typescript
723
+ * const morph = new MorphClient({
724
+ * apiKey: process.env.MORPH_API_KEY,
725
+ * debug: true,
726
+ * timeout: 60000
727
+ * });
728
+ * ```
729
+ */
730
+ constructor(config?: MorphClientConfig);
731
+ }
732
+
733
+ export { AnthropicToolFactory as A, type Comment as C, type Deployment as D, type FileChange as F, GitHubClient as G, type Installation as I, type ListReposInput as L, MorphClient as M, NoInstallationError as N, OpenAIToolFactory as O, type PullRequest as P, type Repo as R, type UpdateCommentInput as U, VercelToolFactory as V, type MorphClientConfig as a, type GitHubClientConfig as b, type PullRequestWithContext as c, type CheckRun as d, type ListPullRequestsInput as e, type GetPullRequestInput as f, type ListDeploymentsInput as g, type ListCommentsInput as h, type CreateCommentInput as i, type DeleteCommentInput as j, type CreateCheckRunInput as k, type UpdateCheckRunInput as l, GitHubError as m, NotFoundError as n, PermissionError as o };