@morphllm/morphsdk 0.2.103 → 0.2.105

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/client.d.ts CHANGED
@@ -3,9 +3,9 @@ import './tools/fastapply/core.js';
3
3
  import './tools/codebase_search/core.js';
4
4
  import './tools/browser/core.js';
5
5
  import './tools/warp_grep/client.js';
6
+ export { M as MorphClient, a as MorphClientConfig } from './client-DYnecl6H.js';
6
7
  import './git/client.js';
7
8
  import './modelrouter/core.js';
8
- export { M as MorphClient, a as MorphClientConfig } from './client-BVeUudyD.js';
9
9
  import './tools/fastapply/types.js';
10
10
  import './tools/fastapply/apply.js';
11
11
  import './tools/codebase_search/types.js';
@@ -15,12 +15,12 @@ import './tools/browser/profiles/types.js';
15
15
  import './tools/warp_grep/agent/types.js';
16
16
  import './types-BMowL9iZ.js';
17
17
  import './tools/warp_grep/providers/types.js';
18
- import './git/types.js';
19
- import 'isomorphic-git';
20
- import 'isomorphic-git/http/node';
21
- import './modelrouter/types.js';
22
18
  import 'openai/resources/index.mjs';
23
19
  import '@anthropic-ai/sdk/resources/messages.mjs';
24
20
  import 'ai';
25
21
  import './tools/warp_grep/vercel.js';
26
22
  import './tools/warp_grep/agent/prompt.js';
23
+ import './git/types.js';
24
+ import 'isomorphic-git';
25
+ import 'isomorphic-git/http/node';
26
+ import './modelrouter/types.js';
package/dist/client.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MorphClient
3
- } from "./chunk-Y2OTK5WC.js";
3
+ } from "./chunk-DX5HVNUP.js";
4
4
  import "./chunk-QUIGATZE.js";
5
5
  import "./chunk-MY4OU4ON.js";
6
6
  import "./chunk-AFLEE2PO.js";
package/dist/index.cjs CHANGED
@@ -784,11 +784,16 @@ __export(index_exports, {
784
784
  CodebaseSearchClient: () => CodebaseSearchClient,
785
785
  FastApplyClient: () => FastApplyClient,
786
786
  GeminiRouter: () => GeminiRouter,
787
+ GitHubClient: () => GitHubClient,
788
+ GitHubError: () => GitHubError,
787
789
  LocalRipgrepProvider: () => LocalRipgrepProvider,
788
790
  MorphClient: () => MorphClient,
789
791
  MorphGit: () => MorphGit,
792
+ NoInstallationError: () => NoInstallationError,
793
+ NotFoundError: () => NotFoundError,
790
794
  OpenAIRouter: () => OpenAIRouter,
791
795
  OpenAIToolFactory: () => OpenAIToolFactory,
796
+ PermissionError: () => PermissionError,
792
797
  RawRouter: () => RawRouter,
793
798
  VercelToolFactory: () => VercelToolFactory,
794
799
  WarpGrepClient: () => WarpGrepClient,
@@ -3662,6 +3667,284 @@ function formatResult(result) {
3662
3667
  return lines.join("\n");
3663
3668
  }
3664
3669
 
3670
+ // tools/github/types.ts
3671
+ var GitHubError = class extends Error {
3672
+ /** HTTP status code */
3673
+ status;
3674
+ /** Error code from API */
3675
+ code;
3676
+ constructor(message, status, code) {
3677
+ super(message);
3678
+ this.name = "GitHubError";
3679
+ this.status = status;
3680
+ this.code = code;
3681
+ }
3682
+ };
3683
+ var NoInstallationError = class extends GitHubError {
3684
+ constructor(message = "No GitHub installation found. Connect GitHub at morphllm.com/dashboard/integrations/github") {
3685
+ super(message, 404, "NO_INSTALLATION");
3686
+ }
3687
+ };
3688
+ var NotFoundError = class extends GitHubError {
3689
+ constructor(resource) {
3690
+ super(`${resource} not found`, 404, "NOT_FOUND");
3691
+ }
3692
+ };
3693
+ var PermissionError = class extends GitHubError {
3694
+ constructor(message = "Insufficient permissions for this operation") {
3695
+ super(message, 403, "PERMISSION_DENIED");
3696
+ }
3697
+ };
3698
+
3699
+ // tools/github/core.ts
3700
+ var DEFAULT_BASE_URL = "https://api.morphllm.com";
3701
+ var DEFAULT_TIMEOUT2 = 3e4;
3702
+ var GitHubClient = class {
3703
+ apiKey;
3704
+ baseUrl;
3705
+ timeout;
3706
+ debug;
3707
+ defaultInstallationId;
3708
+ /** Installation operations */
3709
+ installations;
3710
+ /** Repository operations */
3711
+ repos;
3712
+ /** Pull request operations */
3713
+ pullRequests;
3714
+ /** Deployment operations */
3715
+ deployments;
3716
+ /** Comment operations */
3717
+ comments;
3718
+ /** Check run operations */
3719
+ checkRuns;
3720
+ constructor(config = {}) {
3721
+ this.apiKey = config.apiKey || process.env.MORPH_API_KEY || "";
3722
+ this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
3723
+ this.timeout = config.timeout || DEFAULT_TIMEOUT2;
3724
+ this.debug = config.debug || false;
3725
+ this.defaultInstallationId = config.installationId;
3726
+ if (!this.apiKey) {
3727
+ throw new Error("API key required. Set MORPH_API_KEY or pass apiKey in config.");
3728
+ }
3729
+ this.installations = {
3730
+ list: this.listInstallations.bind(this),
3731
+ get: this.getInstallation.bind(this)
3732
+ };
3733
+ this.repos = {
3734
+ list: this.listRepos.bind(this)
3735
+ };
3736
+ this.pullRequests = {
3737
+ list: this.listPullRequests.bind(this),
3738
+ get: this.getPullRequest.bind(this)
3739
+ };
3740
+ this.deployments = {
3741
+ list: this.listDeployments.bind(this)
3742
+ };
3743
+ this.comments = {
3744
+ list: this.listComments.bind(this),
3745
+ create: this.createComment.bind(this),
3746
+ update: this.updateComment.bind(this),
3747
+ delete: this.deleteComment.bind(this)
3748
+ };
3749
+ this.checkRuns = {
3750
+ create: this.createCheckRun.bind(this),
3751
+ update: this.updateCheckRun.bind(this)
3752
+ };
3753
+ }
3754
+ /**
3755
+ * Make an API request to the Morph GitHub proxy
3756
+ */
3757
+ async request(method, path5, body) {
3758
+ const url = `${this.baseUrl}${path5}`;
3759
+ if (this.debug) {
3760
+ console.log(`[GitHub SDK] ${method} ${path5}`, body || "");
3761
+ }
3762
+ const controller = new AbortController();
3763
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
3764
+ try {
3765
+ const response = await fetch(url, {
3766
+ method,
3767
+ headers: {
3768
+ "Content-Type": "application/json",
3769
+ Authorization: `Bearer ${this.apiKey}`
3770
+ },
3771
+ body: body ? JSON.stringify(body) : void 0,
3772
+ signal: controller.signal
3773
+ });
3774
+ clearTimeout(timeoutId);
3775
+ if (!response.ok) {
3776
+ const errorData = await response.json().catch(() => ({}));
3777
+ const message = errorData.error || errorData.message || response.statusText;
3778
+ if (this.debug) {
3779
+ console.error(`[GitHub SDK] Error ${response.status}:`, message);
3780
+ }
3781
+ if (response.status === 404) {
3782
+ if (message.includes("installation")) {
3783
+ throw new NoInstallationError(message);
3784
+ }
3785
+ throw new NotFoundError(message);
3786
+ }
3787
+ if (response.status === 403) {
3788
+ throw new PermissionError(message);
3789
+ }
3790
+ throw new GitHubError(message, response.status, errorData.code);
3791
+ }
3792
+ const data = await response.json();
3793
+ if (this.debug) {
3794
+ console.log(`[GitHub SDK] Response:`, JSON.stringify(data).slice(0, 200));
3795
+ }
3796
+ return data;
3797
+ } catch (error) {
3798
+ clearTimeout(timeoutId);
3799
+ if (error instanceof GitHubError) {
3800
+ throw error;
3801
+ }
3802
+ if (error instanceof Error && error.name === "AbortError") {
3803
+ throw new GitHubError("Request timeout", 408, "TIMEOUT");
3804
+ }
3805
+ throw new GitHubError(
3806
+ error instanceof Error ? error.message : "Unknown error",
3807
+ 500,
3808
+ "UNKNOWN"
3809
+ );
3810
+ }
3811
+ }
3812
+ /**
3813
+ * Get the installation ID to use for a request
3814
+ */
3815
+ getInstallationId(input) {
3816
+ return input?.installationId || this.defaultInstallationId;
3817
+ }
3818
+ // ==========================================================================
3819
+ // Installations
3820
+ // ==========================================================================
3821
+ async listInstallations() {
3822
+ return this.request("GET", "/v1/github/installations");
3823
+ }
3824
+ async getInstallation(installationId) {
3825
+ return this.request("GET", `/v1/github/installations/${installationId}`);
3826
+ }
3827
+ // ==========================================================================
3828
+ // Repositories
3829
+ // ==========================================================================
3830
+ async listRepos(input) {
3831
+ const installationId = input.installationId || this.defaultInstallationId;
3832
+ if (!installationId) {
3833
+ throw new NoInstallationError("installationId required. Call installations.list() first.");
3834
+ }
3835
+ return this.request("GET", `/v1/github/installations/${installationId}/repos`);
3836
+ }
3837
+ // ==========================================================================
3838
+ // Pull Requests
3839
+ // ==========================================================================
3840
+ async listPullRequests(input) {
3841
+ const installationId = this.getInstallationId(input);
3842
+ const params = new URLSearchParams({
3843
+ owner: input.owner,
3844
+ repo: input.repo,
3845
+ ...input.state && { state: input.state },
3846
+ ...installationId && { installationId }
3847
+ });
3848
+ return this.request("GET", `/v1/github/pulls?${params}`);
3849
+ }
3850
+ async getPullRequest(input) {
3851
+ const installationId = this.getInstallationId(input);
3852
+ const params = new URLSearchParams({
3853
+ owner: input.owner,
3854
+ repo: input.repo,
3855
+ ...installationId && { installationId }
3856
+ });
3857
+ return this.request(
3858
+ "GET",
3859
+ `/v1/github/pulls/${input.number}?${params}`
3860
+ );
3861
+ }
3862
+ // ==========================================================================
3863
+ // Deployments
3864
+ // ==========================================================================
3865
+ async listDeployments(input) {
3866
+ const installationId = this.getInstallationId(input);
3867
+ const params = new URLSearchParams({
3868
+ owner: input.owner,
3869
+ repo: input.repo,
3870
+ ...input.sha && { sha: input.sha },
3871
+ ...input.environment && { environment: input.environment },
3872
+ ...installationId && { installationId }
3873
+ });
3874
+ return this.request("GET", `/v1/github/deployments?${params}`);
3875
+ }
3876
+ // ==========================================================================
3877
+ // Comments
3878
+ // ==========================================================================
3879
+ async listComments(input) {
3880
+ const installationId = this.getInstallationId(input);
3881
+ const params = new URLSearchParams({
3882
+ owner: input.owner,
3883
+ repo: input.repo,
3884
+ pr: String(input.pr),
3885
+ ...installationId && { installationId }
3886
+ });
3887
+ return this.request("GET", `/v1/github/comments?${params}`);
3888
+ }
3889
+ async createComment(input) {
3890
+ const installationId = this.getInstallationId(input);
3891
+ return this.request("POST", "/v1/github/comments", {
3892
+ owner: input.owner,
3893
+ repo: input.repo,
3894
+ pr: input.pr,
3895
+ body: input.body,
3896
+ ...installationId && { installationId }
3897
+ });
3898
+ }
3899
+ async updateComment(input) {
3900
+ const installationId = this.getInstallationId(input);
3901
+ return this.request("PATCH", `/v1/github/comments/${input.commentId}`, {
3902
+ owner: input.owner,
3903
+ repo: input.repo,
3904
+ body: input.body,
3905
+ ...installationId && { installationId }
3906
+ });
3907
+ }
3908
+ async deleteComment(input) {
3909
+ const installationId = this.getInstallationId(input);
3910
+ const params = new URLSearchParams({
3911
+ owner: input.owner,
3912
+ repo: input.repo,
3913
+ ...installationId && { installationId }
3914
+ });
3915
+ await this.request("DELETE", `/v1/github/comments/${input.commentId}?${params}`);
3916
+ }
3917
+ // ==========================================================================
3918
+ // Check Runs
3919
+ // ==========================================================================
3920
+ async createCheckRun(input) {
3921
+ const installationId = this.getInstallationId(input);
3922
+ return this.request("POST", "/v1/github/check-runs", {
3923
+ owner: input.owner,
3924
+ repo: input.repo,
3925
+ sha: input.sha,
3926
+ name: input.name,
3927
+ status: input.status,
3928
+ ...input.title && { title: input.title },
3929
+ ...input.summary && { summary: input.summary },
3930
+ ...installationId && { installationId }
3931
+ });
3932
+ }
3933
+ async updateCheckRun(input) {
3934
+ const installationId = this.getInstallationId(input);
3935
+ return this.request("PATCH", `/v1/github/check-runs/${input.checkRunId}`, {
3936
+ owner: input.owner,
3937
+ repo: input.repo,
3938
+ ...input.status && { status: input.status },
3939
+ ...input.conclusion && { conclusion: input.conclusion },
3940
+ ...input.title && { title: input.title },
3941
+ ...input.summary && { summary: input.summary },
3942
+ ...input.text && { text: input.text },
3943
+ ...installationId && { installationId }
3944
+ });
3945
+ }
3946
+ };
3947
+
3665
3948
  // git/client.ts
3666
3949
  var import_isomorphic_git = __toESM(require("isomorphic-git"), 1);
3667
3950
  var import_node = __toESM(require("isomorphic-git/http/node"), 1);
@@ -5054,6 +5337,8 @@ var MorphClient = class {
5054
5337
  warpGrep;
5055
5338
  /** Browser tool for AI-powered browser automation */
5056
5339
  browser;
5340
+ /** GitHub tool for PR context, comments, and check runs */
5341
+ github;
5057
5342
  /** Git tool for version control operations */
5058
5343
  git;
5059
5344
  /** Model routers for intelligent model selection */
@@ -5104,6 +5389,12 @@ var MorphClient = class {
5104
5389
  timeout: config.timeout,
5105
5390
  retryConfig: config.retryConfig
5106
5391
  });
5392
+ this.github = new GitHubClient({
5393
+ apiKey: config.apiKey,
5394
+ debug: config.debug,
5395
+ timeout: config.timeout,
5396
+ installationId: config.github?.installationId
5397
+ });
5107
5398
  this.git = new MorphGit({
5108
5399
  apiKey: config.apiKey,
5109
5400
  retryConfig: config.retryConfig
@@ -5164,11 +5455,16 @@ var warpGrepInputSchema = import_zod4.z.object({
5164
5455
  CodebaseSearchClient,
5165
5456
  FastApplyClient,
5166
5457
  GeminiRouter,
5458
+ GitHubClient,
5459
+ GitHubError,
5167
5460
  LocalRipgrepProvider,
5168
5461
  MorphClient,
5169
5462
  MorphGit,
5463
+ NoInstallationError,
5464
+ NotFoundError,
5170
5465
  OpenAIRouter,
5171
5466
  OpenAIToolFactory,
5467
+ PermissionError,
5172
5468
  RawRouter,
5173
5469
  VercelToolFactory,
5174
5470
  WarpGrepClient,