@morphllm/morphsdk 0.2.109 → 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.
Files changed (64) hide show
  1. package/dist/{chunk-UILVPDO3.js → chunk-23R562QJ.js} +23 -19
  2. package/dist/chunk-23R562QJ.js.map +1 -0
  3. package/dist/{chunk-KRDIR7GG.js → chunk-3MLWXJTJ.js} +8 -2
  4. package/dist/chunk-3MLWXJTJ.js.map +1 -0
  5. package/dist/{chunk-3L6QGAMK.js → chunk-ALTKGCG5.js} +2 -2
  6. package/dist/{chunk-QE53XISP.js → chunk-FL4ZBHK2.js} +2 -2
  7. package/dist/{chunk-EREXPWY4.js → chunk-HI35Y6EZ.js} +2 -2
  8. package/dist/{chunk-PRKYN7WR.js → chunk-JYKYQ5DN.js} +115 -22
  9. package/dist/chunk-JYKYQ5DN.js.map +1 -0
  10. package/dist/{chunk-4KMBU6T3.js → chunk-YJZP5ZL5.js} +4 -4
  11. package/dist/{chunk-ZROQPUCQ.js → chunk-YY7NZLAI.js} +2 -2
  12. package/dist/{client-DYnecl6H.d.ts → client-DksVOIsG.d.ts} +200 -6
  13. package/dist/client.cjs +136 -33
  14. package/dist/client.cjs.map +1 -1
  15. package/dist/client.d.ts +2 -2
  16. package/dist/client.js +7 -7
  17. package/dist/index.cjs +136 -33
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +9 -9
  21. package/dist/tools/warp_grep/agent/runner.cjs +7 -1
  22. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  23. package/dist/tools/warp_grep/agent/runner.js +2 -2
  24. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  25. package/dist/tools/warp_grep/agent/types.d.ts +1 -1
  26. package/dist/tools/warp_grep/anthropic.cjs +23 -14
  27. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  28. package/dist/tools/warp_grep/anthropic.d.ts +1 -1
  29. package/dist/tools/warp_grep/anthropic.js +4 -4
  30. package/dist/tools/warp_grep/client.cjs +26 -16
  31. package/dist/tools/warp_grep/client.cjs.map +1 -1
  32. package/dist/tools/warp_grep/client.d.ts +1 -1
  33. package/dist/tools/warp_grep/client.js +3 -3
  34. package/dist/tools/warp_grep/gemini.cjs +23 -14
  35. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  36. package/dist/tools/warp_grep/gemini.d.ts +1 -1
  37. package/dist/tools/warp_grep/gemini.js +3 -3
  38. package/dist/tools/warp_grep/harness.cjs +7 -1
  39. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  40. package/dist/tools/warp_grep/harness.js +3 -3
  41. package/dist/tools/warp_grep/index.cjs +26 -16
  42. package/dist/tools/warp_grep/index.cjs.map +1 -1
  43. package/dist/tools/warp_grep/index.d.ts +1 -1
  44. package/dist/tools/warp_grep/index.js +8 -8
  45. package/dist/tools/warp_grep/openai.cjs +23 -14
  46. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  47. package/dist/tools/warp_grep/openai.d.ts +1 -1
  48. package/dist/tools/warp_grep/openai.js +4 -4
  49. package/dist/tools/warp_grep/providers/local.js +2 -2
  50. package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
  51. package/dist/tools/warp_grep/vercel.cjs +23 -14
  52. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  53. package/dist/tools/warp_grep/vercel.d.ts +1 -1
  54. package/dist/tools/warp_grep/vercel.js +4 -4
  55. package/dist/{types-BMowL9iZ.d.ts → types-D5p8QErL.d.ts} +2 -0
  56. package/package.json +1 -1
  57. package/dist/chunk-KRDIR7GG.js.map +0 -1
  58. package/dist/chunk-PRKYN7WR.js.map +0 -1
  59. package/dist/chunk-UILVPDO3.js.map +0 -1
  60. /package/dist/{chunk-3L6QGAMK.js.map → chunk-ALTKGCG5.js.map} +0 -0
  61. /package/dist/{chunk-QE53XISP.js.map → chunk-FL4ZBHK2.js.map} +0 -0
  62. /package/dist/{chunk-EREXPWY4.js.map → chunk-HI35Y6EZ.js.map} +0 -0
  63. /package/dist/{chunk-4KMBU6T3.js.map → chunk-YJZP5ZL5.js.map} +0 -0
  64. /package/dist/{chunk-ZROQPUCQ.js.map → chunk-YY7NZLAI.js.map} +0 -0
package/dist/client.cjs CHANGED
@@ -2814,7 +2814,13 @@ async function readFinishFiles(repoRoot, files, reader) {
2814
2814
  } else {
2815
2815
  const ranges = mergeRanges(validRanges);
2816
2816
  const chunks = [];
2817
- for (const [s, e] of ranges) {
2817
+ for (let i = 0; i < ranges.length; i++) {
2818
+ const [s, e] = ranges[i];
2819
+ if (i === 0 && s > 1) {
2820
+ chunks.push(`// ... existing code, block starting at line ${s} ...`);
2821
+ } else if (i > 0) {
2822
+ chunks.push(`// ... existing code, block starting at line ${s} ...`);
2823
+ }
2818
2824
  const lines = await reader(f.path, s, e);
2819
2825
  chunks.push(lines.join("\n"));
2820
2826
  }
@@ -3584,7 +3590,8 @@ async function executeToolCall(input, config) {
3584
3590
  }
3585
3591
  const contexts = (finish.resolved ?? []).map((r) => ({
3586
3592
  file: r.path,
3587
- content: r.content
3593
+ content: r.content,
3594
+ lines: r.ranges
3588
3595
  }));
3589
3596
  return { success: true, contexts, summary: finish.payload };
3590
3597
  }
@@ -3595,7 +3602,8 @@ function processAgentResult(result) {
3595
3602
  }
3596
3603
  const contexts = (finish.resolved ?? []).map((r) => ({
3597
3604
  file: r.path,
3598
- content: r.content
3605
+ content: r.content,
3606
+ lines: r.ranges
3599
3607
  }));
3600
3608
  return { success: true, contexts, summary: finish.payload };
3601
3609
  }
@@ -3632,20 +3640,22 @@ function formatResult(result) {
3632
3640
  if (!result.contexts || result.contexts.length === 0) {
3633
3641
  return "No relevant code found. Try rephrasing your query.";
3634
3642
  }
3635
- const lines = [];
3636
- lines.push(`Found ${result.contexts.length} relevant code sections:
3643
+ const parts = [];
3644
+ parts.push(`Morph Fast Context subagent performed search on repository:
3637
3645
  `);
3638
- result.contexts.forEach((ctx, i) => {
3639
- lines.push(`${i + 1}. ${ctx.file}`);
3640
- lines.push("```");
3641
- lines.push(ctx.content);
3642
- lines.push("```");
3643
- lines.push("");
3644
- });
3645
- if (result.summary) {
3646
- lines.push(`Summary: ${result.summary}`);
3647
- }
3648
- return lines.join("\n");
3646
+ parts.push("Relevant context found:");
3647
+ for (const ctx of result.contexts) {
3648
+ const rangeStr = !ctx.lines || ctx.lines === "*" ? "*" : ctx.lines.map(([s, e]) => `${s}-${e}`).join(",");
3649
+ parts.push(`- ${ctx.file}:${rangeStr}`);
3650
+ }
3651
+ parts.push("\nHere is the content of files:\n");
3652
+ for (const ctx of result.contexts) {
3653
+ const rangeStr = !ctx.lines || ctx.lines === "*" ? "" : ` lines="${ctx.lines.map(([s, e]) => `${s}-${e}`).join(",")}"`;
3654
+ parts.push(`<file path="${ctx.file}"${rangeStr}>`);
3655
+ parts.push(ctx.content);
3656
+ parts.push("</file>\n");
3657
+ }
3658
+ return parts.join("\n");
3649
3659
  }
3650
3660
 
3651
3661
  // tools/github/types.ts
@@ -3678,11 +3688,13 @@ var PermissionError = class extends GitHubError {
3678
3688
  };
3679
3689
 
3680
3690
  // tools/github/core.ts
3681
- var DEFAULT_BASE_URL = "https://api.morphllm.com";
3691
+ var LANDING_BASE_URL = "https://api.morphllm.com";
3692
+ var BACKEND_BASE_URL = "https://browser.morphllm.com";
3682
3693
  var DEFAULT_TIMEOUT2 = 3e4;
3683
3694
  var GitHubClient = class {
3684
3695
  apiKey;
3685
- baseUrl;
3696
+ landingUrl;
3697
+ backendUrl;
3686
3698
  timeout;
3687
3699
  debug;
3688
3700
  defaultInstallationId;
@@ -3690,6 +3702,8 @@ var GitHubClient = class {
3690
3702
  installations;
3691
3703
  /** Repository operations */
3692
3704
  repos;
3705
+ /** Project operations (monorepo sub-projects) */
3706
+ projects;
3693
3707
  /** Pull request operations */
3694
3708
  pullRequests;
3695
3709
  /** Deployment operations */
@@ -3698,9 +3712,17 @@ var GitHubClient = class {
3698
3712
  comments;
3699
3713
  /** Check run operations */
3700
3714
  checkRuns;
3715
+ /**
3716
+ * Get the GitHub App installation URL.
3717
+ * Users visit this URL once to install the Morph GitHub App on their account/org.
3718
+ */
3719
+ getInstallUrl() {
3720
+ return "https://github.com/apps/morph-subagents/installations/new";
3721
+ }
3701
3722
  constructor(config = {}) {
3702
3723
  this.apiKey = config.apiKey || process.env.MORPH_API_KEY || "";
3703
- this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
3724
+ this.landingUrl = config.baseUrl || LANDING_BASE_URL;
3725
+ this.backendUrl = config.backendUrl || BACKEND_BASE_URL;
3704
3726
  this.timeout = config.timeout || DEFAULT_TIMEOUT2;
3705
3727
  this.debug = config.debug || false;
3706
3728
  this.defaultInstallationId = config.installationId;
@@ -3709,10 +3731,22 @@ var GitHubClient = class {
3709
3731
  }
3710
3732
  this.installations = {
3711
3733
  list: this.listInstallations.bind(this),
3712
- get: this.getInstallation.bind(this)
3734
+ get: this.getInstallation.bind(this),
3735
+ update: this.updateInstallation.bind(this),
3736
+ disconnect: this.disconnectInstallation.bind(this)
3713
3737
  };
3714
3738
  this.repos = {
3715
- list: this.listRepos.bind(this)
3739
+ list: this.listRepos.bind(this),
3740
+ get: this.getRepo.bind(this),
3741
+ update: this.updateRepo.bind(this),
3742
+ remove: this.removeRepo.bind(this),
3743
+ sync: this.syncRepos.bind(this)
3744
+ };
3745
+ this.projects = {
3746
+ list: this.listProjects.bind(this),
3747
+ create: this.createProject.bind(this),
3748
+ update: this.updateProject.bind(this),
3749
+ delete: this.deleteProject.bind(this)
3716
3750
  };
3717
3751
  this.pullRequests = {
3718
3752
  list: this.listPullRequests.bind(this),
@@ -3733,10 +3767,24 @@ var GitHubClient = class {
3733
3767
  };
3734
3768
  }
3735
3769
  /**
3736
- * Make an API request to the Morph GitHub proxy
3770
+ * Make an API request to the browser backend (CRUD endpoints)
3737
3771
  */
3738
3772
  async request(method, path5, body) {
3739
- const url = `${this.baseUrl}${path5}`;
3773
+ return this._fetch(this.backendUrl, method, path5, body);
3774
+ }
3775
+ // TODO: These endpoints use Octokit and currently live in landing.
3776
+ // Move them to the backend so all GitHub SDK traffic goes through a single URL.
3777
+ /**
3778
+ * Make an API request to the landing app (Octokit-based endpoints)
3779
+ */
3780
+ async landingRequest(method, path5, body) {
3781
+ return this._fetch(this.landingUrl, method, path5, body);
3782
+ }
3783
+ /**
3784
+ * Shared fetch logic for both backend and landing requests
3785
+ */
3786
+ async _fetch(baseUrl, method, path5, body) {
3787
+ const url = `${baseUrl}${path5}`;
3740
3788
  if (this.debug) {
3741
3789
  console.log(`[GitHub SDK] ${method} ${path5}`, body || "");
3742
3790
  }
@@ -3755,7 +3803,7 @@ var GitHubClient = class {
3755
3803
  clearTimeout(timeoutId);
3756
3804
  if (!response.ok) {
3757
3805
  const errorData = await response.json().catch(() => ({}));
3758
- const message = errorData.error || errorData.message || response.statusText;
3806
+ const message = errorData.error || errorData.detail || errorData.message || response.statusText;
3759
3807
  if (this.debug) {
3760
3808
  console.error(`[GitHub SDK] Error ${response.status}:`, message);
3761
3809
  }
@@ -3805,6 +3853,15 @@ var GitHubClient = class {
3805
3853
  async getInstallation(installationId) {
3806
3854
  return this.request("GET", `/api/v1/github/installations/${installationId}`);
3807
3855
  }
3856
+ async updateInstallation(input) {
3857
+ if (this.debug) console.log("[GitHub SDK] updateInstallation", input.installationId);
3858
+ const { installationId, ...body } = input;
3859
+ return this.request("PATCH", `/api/v1/github/installations/${installationId}`, body);
3860
+ }
3861
+ async disconnectInstallation(installationId) {
3862
+ if (this.debug) console.log("[GitHub SDK] disconnectInstallation", installationId);
3863
+ return this.request("DELETE", `/api/v1/github/installations/${installationId}`);
3864
+ }
3808
3865
  // ==========================================================================
3809
3866
  // Repositories
3810
3867
  // ==========================================================================
@@ -3815,8 +3872,51 @@ var GitHubClient = class {
3815
3872
  }
3816
3873
  return this.request("GET", `/api/v1/github/installations/${installationId}/repos`);
3817
3874
  }
3875
+ async getRepo(repoId) {
3876
+ if (this.debug) console.log("[GitHub SDK] getRepo", repoId);
3877
+ return this.request("GET", `/api/v1/github/repos/${repoId}`);
3878
+ }
3879
+ async updateRepo(input) {
3880
+ if (this.debug) console.log("[GitHub SDK] updateRepo", input.repoId);
3881
+ const { repoId, ...body } = input;
3882
+ return this.request("PATCH", `/api/v1/github/repos/${repoId}`, body);
3883
+ }
3884
+ async removeRepo(repoId) {
3885
+ if (this.debug) console.log("[GitHub SDK] removeRepo", repoId);
3886
+ return this.request("DELETE", `/api/v1/github/repos/${repoId}`);
3887
+ }
3888
+ async syncRepos(input) {
3889
+ const installationId = input.installationId || this.defaultInstallationId;
3890
+ if (!installationId) {
3891
+ throw new NoInstallationError("installationId required. Call installations.list() first.");
3892
+ }
3893
+ if (this.debug) console.log("[GitHub SDK] syncRepos", installationId);
3894
+ return this.request("POST", `/api/v1/github/installations/${installationId}/repos/sync`);
3895
+ }
3896
+ // ==========================================================================
3897
+ // Projects (monorepo sub-projects)
3898
+ // ==========================================================================
3899
+ async listProjects(input) {
3900
+ if (this.debug) console.log("[GitHub SDK] listProjects", input.repoId);
3901
+ return this.request("GET", `/api/v1/github/repos/${input.repoId}/projects`);
3902
+ }
3903
+ async createProject(input) {
3904
+ if (this.debug) console.log("[GitHub SDK] createProject", input.repoId, input.name);
3905
+ const { repoId, ...body } = input;
3906
+ return this.request("POST", `/api/v1/github/repos/${repoId}/projects`, body);
3907
+ }
3908
+ async updateProject(input) {
3909
+ if (this.debug) console.log("[GitHub SDK] updateProject", input.projectId);
3910
+ const { projectId, ...body } = input;
3911
+ return this.request("PATCH", `/api/v1/github/projects/${projectId}`, body);
3912
+ }
3913
+ async deleteProject(projectId) {
3914
+ if (this.debug) console.log("[GitHub SDK] deleteProject", projectId);
3915
+ return this.request("DELETE", `/api/v1/github/projects/${projectId}`);
3916
+ }
3818
3917
  // ==========================================================================
3819
3918
  // Pull Requests
3919
+ // TODO: Move to backend — currently uses Octokit in landing
3820
3920
  // ==========================================================================
3821
3921
  async listPullRequests(input) {
3822
3922
  const installationId = this.getInstallationId(input);
@@ -3826,7 +3926,7 @@ var GitHubClient = class {
3826
3926
  ...input.state && { state: input.state },
3827
3927
  ...installationId && { installationId }
3828
3928
  });
3829
- return this.request("GET", `/api/v1/github/pulls?${params}`);
3929
+ return this.landingRequest("GET", `/api/v1/github/pulls?${params}`);
3830
3930
  }
3831
3931
  async getPullRequest(input) {
3832
3932
  const installationId = this.getInstallationId(input);
@@ -3835,13 +3935,14 @@ var GitHubClient = class {
3835
3935
  repo: input.repo,
3836
3936
  ...installationId && { installationId }
3837
3937
  });
3838
- return this.request(
3938
+ return this.landingRequest(
3839
3939
  "GET",
3840
3940
  `/api/v1/github/pulls/${input.number}?${params}`
3841
3941
  );
3842
3942
  }
3843
3943
  // ==========================================================================
3844
3944
  // Deployments
3945
+ // TODO: Move to backend — currently uses Octokit in landing
3845
3946
  // ==========================================================================
3846
3947
  async listDeployments(input) {
3847
3948
  const installationId = this.getInstallationId(input);
@@ -3852,10 +3953,11 @@ var GitHubClient = class {
3852
3953
  ...input.environment && { environment: input.environment },
3853
3954
  ...installationId && { installationId }
3854
3955
  });
3855
- return this.request("GET", `/api/v1/github/deployments?${params}`);
3956
+ return this.landingRequest("GET", `/api/v1/github/deployments?${params}`);
3856
3957
  }
3857
3958
  // ==========================================================================
3858
3959
  // Comments
3960
+ // TODO: Move to backend — currently uses Octokit in landing
3859
3961
  // ==========================================================================
3860
3962
  async listComments(input) {
3861
3963
  const installationId = this.getInstallationId(input);
@@ -3865,11 +3967,11 @@ var GitHubClient = class {
3865
3967
  pr: String(input.pr),
3866
3968
  ...installationId && { installationId }
3867
3969
  });
3868
- return this.request("GET", `/api/v1/github/comments?${params}`);
3970
+ return this.landingRequest("GET", `/api/v1/github/comments?${params}`);
3869
3971
  }
3870
3972
  async createComment(input) {
3871
3973
  const installationId = this.getInstallationId(input);
3872
- return this.request("POST", "/api/v1/github/comments", {
3974
+ return this.landingRequest("POST", "/api/v1/github/comments", {
3873
3975
  owner: input.owner,
3874
3976
  repo: input.repo,
3875
3977
  pr: input.pr,
@@ -3879,7 +3981,7 @@ var GitHubClient = class {
3879
3981
  }
3880
3982
  async updateComment(input) {
3881
3983
  const installationId = this.getInstallationId(input);
3882
- return this.request("PATCH", `/api/v1/github/comments/${input.commentId}`, {
3984
+ return this.landingRequest("PATCH", `/api/v1/github/comments/${input.commentId}`, {
3883
3985
  owner: input.owner,
3884
3986
  repo: input.repo,
3885
3987
  body: input.body,
@@ -3893,14 +3995,15 @@ var GitHubClient = class {
3893
3995
  repo: input.repo,
3894
3996
  ...installationId && { installationId }
3895
3997
  });
3896
- await this.request("DELETE", `/api/v1/github/comments/${input.commentId}?${params}`);
3998
+ await this.landingRequest("DELETE", `/api/v1/github/comments/${input.commentId}?${params}`);
3897
3999
  }
3898
4000
  // ==========================================================================
3899
4001
  // Check Runs
4002
+ // TODO: Move to backend — currently uses Octokit in landing
3900
4003
  // ==========================================================================
3901
4004
  async createCheckRun(input) {
3902
4005
  const installationId = this.getInstallationId(input);
3903
- return this.request("POST", "/api/v1/github/check-runs", {
4006
+ return this.landingRequest("POST", "/api/v1/github/check-runs", {
3904
4007
  owner: input.owner,
3905
4008
  repo: input.repo,
3906
4009
  sha: input.sha,
@@ -3913,7 +4016,7 @@ var GitHubClient = class {
3913
4016
  }
3914
4017
  async updateCheckRun(input) {
3915
4018
  const installationId = this.getInstallationId(input);
3916
- return this.request("PATCH", `/api/v1/github/check-runs/${input.checkRunId}`, {
4019
+ return this.landingRequest("PATCH", `/api/v1/github/check-runs/${input.checkRunId}`, {
3917
4020
  owner: input.owner,
3918
4021
  repo: input.repo,
3919
4022
  ...input.status && { status: input.status },