@morphllm/morphsdk 0.2.110 → 0.2.111
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-I72WZNZF.js → chunk-JYKYQ5DN.js} +111 -18
- package/dist/chunk-JYKYQ5DN.js.map +1 -0
- package/dist/{client-BH1R-YHX.d.ts → client-DksVOIsG.d.ts} +199 -5
- package/dist/client.cjs +110 -17
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/index.cjs +110 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-I72WZNZF.js.map +0 -1
package/dist/client.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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-
|
|
6
|
+
export { M as MorphClient, a as MorphClientConfig } from './client-DksVOIsG.js';
|
|
7
7
|
import './git/client.js';
|
|
8
8
|
import './modelrouter/core.js';
|
|
9
9
|
import './tools/fastapply/types.js';
|
package/dist/client.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -3707,11 +3707,13 @@ var PermissionError = class extends GitHubError {
|
|
|
3707
3707
|
};
|
|
3708
3708
|
|
|
3709
3709
|
// tools/github/core.ts
|
|
3710
|
-
var
|
|
3710
|
+
var LANDING_BASE_URL = "https://api.morphllm.com";
|
|
3711
|
+
var BACKEND_BASE_URL = "https://browser.morphllm.com";
|
|
3711
3712
|
var DEFAULT_TIMEOUT2 = 3e4;
|
|
3712
3713
|
var GitHubClient = class {
|
|
3713
3714
|
apiKey;
|
|
3714
|
-
|
|
3715
|
+
landingUrl;
|
|
3716
|
+
backendUrl;
|
|
3715
3717
|
timeout;
|
|
3716
3718
|
debug;
|
|
3717
3719
|
defaultInstallationId;
|
|
@@ -3719,6 +3721,8 @@ var GitHubClient = class {
|
|
|
3719
3721
|
installations;
|
|
3720
3722
|
/** Repository operations */
|
|
3721
3723
|
repos;
|
|
3724
|
+
/** Project operations (monorepo sub-projects) */
|
|
3725
|
+
projects;
|
|
3722
3726
|
/** Pull request operations */
|
|
3723
3727
|
pullRequests;
|
|
3724
3728
|
/** Deployment operations */
|
|
@@ -3727,9 +3731,17 @@ var GitHubClient = class {
|
|
|
3727
3731
|
comments;
|
|
3728
3732
|
/** Check run operations */
|
|
3729
3733
|
checkRuns;
|
|
3734
|
+
/**
|
|
3735
|
+
* Get the GitHub App installation URL.
|
|
3736
|
+
* Users visit this URL once to install the Morph GitHub App on their account/org.
|
|
3737
|
+
*/
|
|
3738
|
+
getInstallUrl() {
|
|
3739
|
+
return "https://github.com/apps/morph-subagents/installations/new";
|
|
3740
|
+
}
|
|
3730
3741
|
constructor(config = {}) {
|
|
3731
3742
|
this.apiKey = config.apiKey || process.env.MORPH_API_KEY || "";
|
|
3732
|
-
this.
|
|
3743
|
+
this.landingUrl = config.baseUrl || LANDING_BASE_URL;
|
|
3744
|
+
this.backendUrl = config.backendUrl || BACKEND_BASE_URL;
|
|
3733
3745
|
this.timeout = config.timeout || DEFAULT_TIMEOUT2;
|
|
3734
3746
|
this.debug = config.debug || false;
|
|
3735
3747
|
this.defaultInstallationId = config.installationId;
|
|
@@ -3738,10 +3750,22 @@ var GitHubClient = class {
|
|
|
3738
3750
|
}
|
|
3739
3751
|
this.installations = {
|
|
3740
3752
|
list: this.listInstallations.bind(this),
|
|
3741
|
-
get: this.getInstallation.bind(this)
|
|
3753
|
+
get: this.getInstallation.bind(this),
|
|
3754
|
+
update: this.updateInstallation.bind(this),
|
|
3755
|
+
disconnect: this.disconnectInstallation.bind(this)
|
|
3742
3756
|
};
|
|
3743
3757
|
this.repos = {
|
|
3744
|
-
list: this.listRepos.bind(this)
|
|
3758
|
+
list: this.listRepos.bind(this),
|
|
3759
|
+
get: this.getRepo.bind(this),
|
|
3760
|
+
update: this.updateRepo.bind(this),
|
|
3761
|
+
remove: this.removeRepo.bind(this),
|
|
3762
|
+
sync: this.syncRepos.bind(this)
|
|
3763
|
+
};
|
|
3764
|
+
this.projects = {
|
|
3765
|
+
list: this.listProjects.bind(this),
|
|
3766
|
+
create: this.createProject.bind(this),
|
|
3767
|
+
update: this.updateProject.bind(this),
|
|
3768
|
+
delete: this.deleteProject.bind(this)
|
|
3745
3769
|
};
|
|
3746
3770
|
this.pullRequests = {
|
|
3747
3771
|
list: this.listPullRequests.bind(this),
|
|
@@ -3762,10 +3786,24 @@ var GitHubClient = class {
|
|
|
3762
3786
|
};
|
|
3763
3787
|
}
|
|
3764
3788
|
/**
|
|
3765
|
-
* Make an API request to the
|
|
3789
|
+
* Make an API request to the browser backend (CRUD endpoints)
|
|
3766
3790
|
*/
|
|
3767
3791
|
async request(method, path5, body) {
|
|
3768
|
-
|
|
3792
|
+
return this._fetch(this.backendUrl, method, path5, body);
|
|
3793
|
+
}
|
|
3794
|
+
// TODO: These endpoints use Octokit and currently live in landing.
|
|
3795
|
+
// Move them to the backend so all GitHub SDK traffic goes through a single URL.
|
|
3796
|
+
/**
|
|
3797
|
+
* Make an API request to the landing app (Octokit-based endpoints)
|
|
3798
|
+
*/
|
|
3799
|
+
async landingRequest(method, path5, body) {
|
|
3800
|
+
return this._fetch(this.landingUrl, method, path5, body);
|
|
3801
|
+
}
|
|
3802
|
+
/**
|
|
3803
|
+
* Shared fetch logic for both backend and landing requests
|
|
3804
|
+
*/
|
|
3805
|
+
async _fetch(baseUrl, method, path5, body) {
|
|
3806
|
+
const url = `${baseUrl}${path5}`;
|
|
3769
3807
|
if (this.debug) {
|
|
3770
3808
|
console.log(`[GitHub SDK] ${method} ${path5}`, body || "");
|
|
3771
3809
|
}
|
|
@@ -3784,7 +3822,7 @@ var GitHubClient = class {
|
|
|
3784
3822
|
clearTimeout(timeoutId);
|
|
3785
3823
|
if (!response.ok) {
|
|
3786
3824
|
const errorData = await response.json().catch(() => ({}));
|
|
3787
|
-
const message = errorData.error || errorData.message || response.statusText;
|
|
3825
|
+
const message = errorData.error || errorData.detail || errorData.message || response.statusText;
|
|
3788
3826
|
if (this.debug) {
|
|
3789
3827
|
console.error(`[GitHub SDK] Error ${response.status}:`, message);
|
|
3790
3828
|
}
|
|
@@ -3834,6 +3872,15 @@ var GitHubClient = class {
|
|
|
3834
3872
|
async getInstallation(installationId) {
|
|
3835
3873
|
return this.request("GET", `/api/v1/github/installations/${installationId}`);
|
|
3836
3874
|
}
|
|
3875
|
+
async updateInstallation(input) {
|
|
3876
|
+
if (this.debug) console.log("[GitHub SDK] updateInstallation", input.installationId);
|
|
3877
|
+
const { installationId, ...body } = input;
|
|
3878
|
+
return this.request("PATCH", `/api/v1/github/installations/${installationId}`, body);
|
|
3879
|
+
}
|
|
3880
|
+
async disconnectInstallation(installationId) {
|
|
3881
|
+
if (this.debug) console.log("[GitHub SDK] disconnectInstallation", installationId);
|
|
3882
|
+
return this.request("DELETE", `/api/v1/github/installations/${installationId}`);
|
|
3883
|
+
}
|
|
3837
3884
|
// ==========================================================================
|
|
3838
3885
|
// Repositories
|
|
3839
3886
|
// ==========================================================================
|
|
@@ -3844,8 +3891,51 @@ var GitHubClient = class {
|
|
|
3844
3891
|
}
|
|
3845
3892
|
return this.request("GET", `/api/v1/github/installations/${installationId}/repos`);
|
|
3846
3893
|
}
|
|
3894
|
+
async getRepo(repoId) {
|
|
3895
|
+
if (this.debug) console.log("[GitHub SDK] getRepo", repoId);
|
|
3896
|
+
return this.request("GET", `/api/v1/github/repos/${repoId}`);
|
|
3897
|
+
}
|
|
3898
|
+
async updateRepo(input) {
|
|
3899
|
+
if (this.debug) console.log("[GitHub SDK] updateRepo", input.repoId);
|
|
3900
|
+
const { repoId, ...body } = input;
|
|
3901
|
+
return this.request("PATCH", `/api/v1/github/repos/${repoId}`, body);
|
|
3902
|
+
}
|
|
3903
|
+
async removeRepo(repoId) {
|
|
3904
|
+
if (this.debug) console.log("[GitHub SDK] removeRepo", repoId);
|
|
3905
|
+
return this.request("DELETE", `/api/v1/github/repos/${repoId}`);
|
|
3906
|
+
}
|
|
3907
|
+
async syncRepos(input) {
|
|
3908
|
+
const installationId = input.installationId || this.defaultInstallationId;
|
|
3909
|
+
if (!installationId) {
|
|
3910
|
+
throw new NoInstallationError("installationId required. Call installations.list() first.");
|
|
3911
|
+
}
|
|
3912
|
+
if (this.debug) console.log("[GitHub SDK] syncRepos", installationId);
|
|
3913
|
+
return this.request("POST", `/api/v1/github/installations/${installationId}/repos/sync`);
|
|
3914
|
+
}
|
|
3915
|
+
// ==========================================================================
|
|
3916
|
+
// Projects (monorepo sub-projects)
|
|
3917
|
+
// ==========================================================================
|
|
3918
|
+
async listProjects(input) {
|
|
3919
|
+
if (this.debug) console.log("[GitHub SDK] listProjects", input.repoId);
|
|
3920
|
+
return this.request("GET", `/api/v1/github/repos/${input.repoId}/projects`);
|
|
3921
|
+
}
|
|
3922
|
+
async createProject(input) {
|
|
3923
|
+
if (this.debug) console.log("[GitHub SDK] createProject", input.repoId, input.name);
|
|
3924
|
+
const { repoId, ...body } = input;
|
|
3925
|
+
return this.request("POST", `/api/v1/github/repos/${repoId}/projects`, body);
|
|
3926
|
+
}
|
|
3927
|
+
async updateProject(input) {
|
|
3928
|
+
if (this.debug) console.log("[GitHub SDK] updateProject", input.projectId);
|
|
3929
|
+
const { projectId, ...body } = input;
|
|
3930
|
+
return this.request("PATCH", `/api/v1/github/projects/${projectId}`, body);
|
|
3931
|
+
}
|
|
3932
|
+
async deleteProject(projectId) {
|
|
3933
|
+
if (this.debug) console.log("[GitHub SDK] deleteProject", projectId);
|
|
3934
|
+
return this.request("DELETE", `/api/v1/github/projects/${projectId}`);
|
|
3935
|
+
}
|
|
3847
3936
|
// ==========================================================================
|
|
3848
3937
|
// Pull Requests
|
|
3938
|
+
// TODO: Move to backend — currently uses Octokit in landing
|
|
3849
3939
|
// ==========================================================================
|
|
3850
3940
|
async listPullRequests(input) {
|
|
3851
3941
|
const installationId = this.getInstallationId(input);
|
|
@@ -3855,7 +3945,7 @@ var GitHubClient = class {
|
|
|
3855
3945
|
...input.state && { state: input.state },
|
|
3856
3946
|
...installationId && { installationId }
|
|
3857
3947
|
});
|
|
3858
|
-
return this.
|
|
3948
|
+
return this.landingRequest("GET", `/api/v1/github/pulls?${params}`);
|
|
3859
3949
|
}
|
|
3860
3950
|
async getPullRequest(input) {
|
|
3861
3951
|
const installationId = this.getInstallationId(input);
|
|
@@ -3864,13 +3954,14 @@ var GitHubClient = class {
|
|
|
3864
3954
|
repo: input.repo,
|
|
3865
3955
|
...installationId && { installationId }
|
|
3866
3956
|
});
|
|
3867
|
-
return this.
|
|
3957
|
+
return this.landingRequest(
|
|
3868
3958
|
"GET",
|
|
3869
3959
|
`/api/v1/github/pulls/${input.number}?${params}`
|
|
3870
3960
|
);
|
|
3871
3961
|
}
|
|
3872
3962
|
// ==========================================================================
|
|
3873
3963
|
// Deployments
|
|
3964
|
+
// TODO: Move to backend — currently uses Octokit in landing
|
|
3874
3965
|
// ==========================================================================
|
|
3875
3966
|
async listDeployments(input) {
|
|
3876
3967
|
const installationId = this.getInstallationId(input);
|
|
@@ -3881,10 +3972,11 @@ var GitHubClient = class {
|
|
|
3881
3972
|
...input.environment && { environment: input.environment },
|
|
3882
3973
|
...installationId && { installationId }
|
|
3883
3974
|
});
|
|
3884
|
-
return this.
|
|
3975
|
+
return this.landingRequest("GET", `/api/v1/github/deployments?${params}`);
|
|
3885
3976
|
}
|
|
3886
3977
|
// ==========================================================================
|
|
3887
3978
|
// Comments
|
|
3979
|
+
// TODO: Move to backend — currently uses Octokit in landing
|
|
3888
3980
|
// ==========================================================================
|
|
3889
3981
|
async listComments(input) {
|
|
3890
3982
|
const installationId = this.getInstallationId(input);
|
|
@@ -3894,11 +3986,11 @@ var GitHubClient = class {
|
|
|
3894
3986
|
pr: String(input.pr),
|
|
3895
3987
|
...installationId && { installationId }
|
|
3896
3988
|
});
|
|
3897
|
-
return this.
|
|
3989
|
+
return this.landingRequest("GET", `/api/v1/github/comments?${params}`);
|
|
3898
3990
|
}
|
|
3899
3991
|
async createComment(input) {
|
|
3900
3992
|
const installationId = this.getInstallationId(input);
|
|
3901
|
-
return this.
|
|
3993
|
+
return this.landingRequest("POST", "/api/v1/github/comments", {
|
|
3902
3994
|
owner: input.owner,
|
|
3903
3995
|
repo: input.repo,
|
|
3904
3996
|
pr: input.pr,
|
|
@@ -3908,7 +4000,7 @@ var GitHubClient = class {
|
|
|
3908
4000
|
}
|
|
3909
4001
|
async updateComment(input) {
|
|
3910
4002
|
const installationId = this.getInstallationId(input);
|
|
3911
|
-
return this.
|
|
4003
|
+
return this.landingRequest("PATCH", `/api/v1/github/comments/${input.commentId}`, {
|
|
3912
4004
|
owner: input.owner,
|
|
3913
4005
|
repo: input.repo,
|
|
3914
4006
|
body: input.body,
|
|
@@ -3922,14 +4014,15 @@ var GitHubClient = class {
|
|
|
3922
4014
|
repo: input.repo,
|
|
3923
4015
|
...installationId && { installationId }
|
|
3924
4016
|
});
|
|
3925
|
-
await this.
|
|
4017
|
+
await this.landingRequest("DELETE", `/api/v1/github/comments/${input.commentId}?${params}`);
|
|
3926
4018
|
}
|
|
3927
4019
|
// ==========================================================================
|
|
3928
4020
|
// Check Runs
|
|
4021
|
+
// TODO: Move to backend — currently uses Octokit in landing
|
|
3929
4022
|
// ==========================================================================
|
|
3930
4023
|
async createCheckRun(input) {
|
|
3931
4024
|
const installationId = this.getInstallationId(input);
|
|
3932
|
-
return this.
|
|
4025
|
+
return this.landingRequest("POST", "/api/v1/github/check-runs", {
|
|
3933
4026
|
owner: input.owner,
|
|
3934
4027
|
repo: input.repo,
|
|
3935
4028
|
sha: input.sha,
|
|
@@ -3942,7 +4035,7 @@ var GitHubClient = class {
|
|
|
3942
4035
|
}
|
|
3943
4036
|
async updateCheckRun(input) {
|
|
3944
4037
|
const installationId = this.getInstallationId(input);
|
|
3945
|
-
return this.
|
|
4038
|
+
return this.landingRequest("PATCH", `/api/v1/github/check-runs/${input.checkRunId}`, {
|
|
3946
4039
|
owner: input.owner,
|
|
3947
4040
|
repo: input.repo,
|
|
3948
4041
|
...input.status && { status: input.status },
|