@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.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-DYnecl6H.js';
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';
@@ -13,7 +13,7 @@ import './tools/browser/types.js';
13
13
  import './tools/browser/profiles/core.js';
14
14
  import './tools/browser/profiles/types.js';
15
15
  import './tools/warp_grep/agent/types.js';
16
- import './types-BMowL9iZ.js';
16
+ import './types-D5p8QErL.js';
17
17
  import './tools/warp_grep/providers/types.js';
18
18
  import 'openai/resources/index.mjs';
19
19
  import '@anthropic-ai/sdk/resources/messages.mjs';
package/dist/client.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  MorphClient
3
- } from "./chunk-PRKYN7WR.js";
4
- import "./chunk-QE53XISP.js";
5
- import "./chunk-EREXPWY4.js";
6
- import "./chunk-3L6QGAMK.js";
3
+ } from "./chunk-JYKYQ5DN.js";
4
+ import "./chunk-FL4ZBHK2.js";
5
+ import "./chunk-HI35Y6EZ.js";
6
+ import "./chunk-ALTKGCG5.js";
7
7
  import "./chunk-KW7OEGZK.js";
8
- import "./chunk-UILVPDO3.js";
8
+ import "./chunk-23R562QJ.js";
9
+ import "./chunk-YY7NZLAI.js";
9
10
  import "./chunk-PUGSTXLO.js";
10
- import "./chunk-ZROQPUCQ.js";
11
- import "./chunk-KRDIR7GG.js";
11
+ import "./chunk-3MLWXJTJ.js";
12
12
  import "./chunk-SNGGSPYJ.js";
13
13
  import "./chunk-FMLHRJDF.js";
14
14
  import "./chunk-5PNMAWLC.js";
package/dist/index.cjs CHANGED
@@ -2833,7 +2833,13 @@ async function readFinishFiles(repoRoot, files, reader) {
2833
2833
  } else {
2834
2834
  const ranges = mergeRanges(validRanges);
2835
2835
  const chunks = [];
2836
- for (const [s, e] of ranges) {
2836
+ for (let i = 0; i < ranges.length; i++) {
2837
+ const [s, e] = ranges[i];
2838
+ if (i === 0 && s > 1) {
2839
+ chunks.push(`// ... existing code, block starting at line ${s} ...`);
2840
+ } else if (i > 0) {
2841
+ chunks.push(`// ... existing code, block starting at line ${s} ...`);
2842
+ }
2837
2843
  const lines = await reader(f.path, s, e);
2838
2844
  chunks.push(lines.join("\n"));
2839
2845
  }
@@ -3603,7 +3609,8 @@ async function executeToolCall(input, config) {
3603
3609
  }
3604
3610
  const contexts = (finish.resolved ?? []).map((r) => ({
3605
3611
  file: r.path,
3606
- content: r.content
3612
+ content: r.content,
3613
+ lines: r.ranges
3607
3614
  }));
3608
3615
  return { success: true, contexts, summary: finish.payload };
3609
3616
  }
@@ -3614,7 +3621,8 @@ function processAgentResult(result) {
3614
3621
  }
3615
3622
  const contexts = (finish.resolved ?? []).map((r) => ({
3616
3623
  file: r.path,
3617
- content: r.content
3624
+ content: r.content,
3625
+ lines: r.ranges
3618
3626
  }));
3619
3627
  return { success: true, contexts, summary: finish.payload };
3620
3628
  }
@@ -3651,20 +3659,22 @@ function formatResult(result) {
3651
3659
  if (!result.contexts || result.contexts.length === 0) {
3652
3660
  return "No relevant code found. Try rephrasing your query.";
3653
3661
  }
3654
- const lines = [];
3655
- lines.push(`Found ${result.contexts.length} relevant code sections:
3662
+ const parts = [];
3663
+ parts.push(`Morph Fast Context subagent performed search on repository:
3656
3664
  `);
3657
- result.contexts.forEach((ctx, i) => {
3658
- lines.push(`${i + 1}. ${ctx.file}`);
3659
- lines.push("```");
3660
- lines.push(ctx.content);
3661
- lines.push("```");
3662
- lines.push("");
3663
- });
3664
- if (result.summary) {
3665
- lines.push(`Summary: ${result.summary}`);
3666
- }
3667
- return lines.join("\n");
3665
+ parts.push("Relevant context found:");
3666
+ for (const ctx of result.contexts) {
3667
+ const rangeStr = !ctx.lines || ctx.lines === "*" ? "*" : ctx.lines.map(([s, e]) => `${s}-${e}`).join(",");
3668
+ parts.push(`- ${ctx.file}:${rangeStr}`);
3669
+ }
3670
+ parts.push("\nHere is the content of files:\n");
3671
+ for (const ctx of result.contexts) {
3672
+ const rangeStr = !ctx.lines || ctx.lines === "*" ? "" : ` lines="${ctx.lines.map(([s, e]) => `${s}-${e}`).join(",")}"`;
3673
+ parts.push(`<file path="${ctx.file}"${rangeStr}>`);
3674
+ parts.push(ctx.content);
3675
+ parts.push("</file>\n");
3676
+ }
3677
+ return parts.join("\n");
3668
3678
  }
3669
3679
 
3670
3680
  // tools/github/types.ts
@@ -3697,11 +3707,13 @@ var PermissionError = class extends GitHubError {
3697
3707
  };
3698
3708
 
3699
3709
  // tools/github/core.ts
3700
- var DEFAULT_BASE_URL = "https://api.morphllm.com";
3710
+ var LANDING_BASE_URL = "https://api.morphllm.com";
3711
+ var BACKEND_BASE_URL = "https://browser.morphllm.com";
3701
3712
  var DEFAULT_TIMEOUT2 = 3e4;
3702
3713
  var GitHubClient = class {
3703
3714
  apiKey;
3704
- baseUrl;
3715
+ landingUrl;
3716
+ backendUrl;
3705
3717
  timeout;
3706
3718
  debug;
3707
3719
  defaultInstallationId;
@@ -3709,6 +3721,8 @@ var GitHubClient = class {
3709
3721
  installations;
3710
3722
  /** Repository operations */
3711
3723
  repos;
3724
+ /** Project operations (monorepo sub-projects) */
3725
+ projects;
3712
3726
  /** Pull request operations */
3713
3727
  pullRequests;
3714
3728
  /** Deployment operations */
@@ -3717,9 +3731,17 @@ var GitHubClient = class {
3717
3731
  comments;
3718
3732
  /** Check run operations */
3719
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
+ }
3720
3741
  constructor(config = {}) {
3721
3742
  this.apiKey = config.apiKey || process.env.MORPH_API_KEY || "";
3722
- this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
3743
+ this.landingUrl = config.baseUrl || LANDING_BASE_URL;
3744
+ this.backendUrl = config.backendUrl || BACKEND_BASE_URL;
3723
3745
  this.timeout = config.timeout || DEFAULT_TIMEOUT2;
3724
3746
  this.debug = config.debug || false;
3725
3747
  this.defaultInstallationId = config.installationId;
@@ -3728,10 +3750,22 @@ var GitHubClient = class {
3728
3750
  }
3729
3751
  this.installations = {
3730
3752
  list: this.listInstallations.bind(this),
3731
- get: this.getInstallation.bind(this)
3753
+ get: this.getInstallation.bind(this),
3754
+ update: this.updateInstallation.bind(this),
3755
+ disconnect: this.disconnectInstallation.bind(this)
3732
3756
  };
3733
3757
  this.repos = {
3734
- 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)
3735
3769
  };
3736
3770
  this.pullRequests = {
3737
3771
  list: this.listPullRequests.bind(this),
@@ -3752,10 +3786,24 @@ var GitHubClient = class {
3752
3786
  };
3753
3787
  }
3754
3788
  /**
3755
- * Make an API request to the Morph GitHub proxy
3789
+ * Make an API request to the browser backend (CRUD endpoints)
3756
3790
  */
3757
3791
  async request(method, path5, body) {
3758
- const url = `${this.baseUrl}${path5}`;
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}`;
3759
3807
  if (this.debug) {
3760
3808
  console.log(`[GitHub SDK] ${method} ${path5}`, body || "");
3761
3809
  }
@@ -3774,7 +3822,7 @@ var GitHubClient = class {
3774
3822
  clearTimeout(timeoutId);
3775
3823
  if (!response.ok) {
3776
3824
  const errorData = await response.json().catch(() => ({}));
3777
- const message = errorData.error || errorData.message || response.statusText;
3825
+ const message = errorData.error || errorData.detail || errorData.message || response.statusText;
3778
3826
  if (this.debug) {
3779
3827
  console.error(`[GitHub SDK] Error ${response.status}:`, message);
3780
3828
  }
@@ -3824,6 +3872,15 @@ var GitHubClient = class {
3824
3872
  async getInstallation(installationId) {
3825
3873
  return this.request("GET", `/api/v1/github/installations/${installationId}`);
3826
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
+ }
3827
3884
  // ==========================================================================
3828
3885
  // Repositories
3829
3886
  // ==========================================================================
@@ -3834,8 +3891,51 @@ var GitHubClient = class {
3834
3891
  }
3835
3892
  return this.request("GET", `/api/v1/github/installations/${installationId}/repos`);
3836
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
+ }
3837
3936
  // ==========================================================================
3838
3937
  // Pull Requests
3938
+ // TODO: Move to backend — currently uses Octokit in landing
3839
3939
  // ==========================================================================
3840
3940
  async listPullRequests(input) {
3841
3941
  const installationId = this.getInstallationId(input);
@@ -3845,7 +3945,7 @@ var GitHubClient = class {
3845
3945
  ...input.state && { state: input.state },
3846
3946
  ...installationId && { installationId }
3847
3947
  });
3848
- return this.request("GET", `/api/v1/github/pulls?${params}`);
3948
+ return this.landingRequest("GET", `/api/v1/github/pulls?${params}`);
3849
3949
  }
3850
3950
  async getPullRequest(input) {
3851
3951
  const installationId = this.getInstallationId(input);
@@ -3854,13 +3954,14 @@ var GitHubClient = class {
3854
3954
  repo: input.repo,
3855
3955
  ...installationId && { installationId }
3856
3956
  });
3857
- return this.request(
3957
+ return this.landingRequest(
3858
3958
  "GET",
3859
3959
  `/api/v1/github/pulls/${input.number}?${params}`
3860
3960
  );
3861
3961
  }
3862
3962
  // ==========================================================================
3863
3963
  // Deployments
3964
+ // TODO: Move to backend — currently uses Octokit in landing
3864
3965
  // ==========================================================================
3865
3966
  async listDeployments(input) {
3866
3967
  const installationId = this.getInstallationId(input);
@@ -3871,10 +3972,11 @@ var GitHubClient = class {
3871
3972
  ...input.environment && { environment: input.environment },
3872
3973
  ...installationId && { installationId }
3873
3974
  });
3874
- return this.request("GET", `/api/v1/github/deployments?${params}`);
3975
+ return this.landingRequest("GET", `/api/v1/github/deployments?${params}`);
3875
3976
  }
3876
3977
  // ==========================================================================
3877
3978
  // Comments
3979
+ // TODO: Move to backend — currently uses Octokit in landing
3878
3980
  // ==========================================================================
3879
3981
  async listComments(input) {
3880
3982
  const installationId = this.getInstallationId(input);
@@ -3884,11 +3986,11 @@ var GitHubClient = class {
3884
3986
  pr: String(input.pr),
3885
3987
  ...installationId && { installationId }
3886
3988
  });
3887
- return this.request("GET", `/api/v1/github/comments?${params}`);
3989
+ return this.landingRequest("GET", `/api/v1/github/comments?${params}`);
3888
3990
  }
3889
3991
  async createComment(input) {
3890
3992
  const installationId = this.getInstallationId(input);
3891
- return this.request("POST", "/api/v1/github/comments", {
3993
+ return this.landingRequest("POST", "/api/v1/github/comments", {
3892
3994
  owner: input.owner,
3893
3995
  repo: input.repo,
3894
3996
  pr: input.pr,
@@ -3898,7 +4000,7 @@ var GitHubClient = class {
3898
4000
  }
3899
4001
  async updateComment(input) {
3900
4002
  const installationId = this.getInstallationId(input);
3901
- return this.request("PATCH", `/api/v1/github/comments/${input.commentId}`, {
4003
+ return this.landingRequest("PATCH", `/api/v1/github/comments/${input.commentId}`, {
3902
4004
  owner: input.owner,
3903
4005
  repo: input.repo,
3904
4006
  body: input.body,
@@ -3912,14 +4014,15 @@ var GitHubClient = class {
3912
4014
  repo: input.repo,
3913
4015
  ...installationId && { installationId }
3914
4016
  });
3915
- await this.request("DELETE", `/api/v1/github/comments/${input.commentId}?${params}`);
4017
+ await this.landingRequest("DELETE", `/api/v1/github/comments/${input.commentId}?${params}`);
3916
4018
  }
3917
4019
  // ==========================================================================
3918
4020
  // Check Runs
4021
+ // TODO: Move to backend — currently uses Octokit in landing
3919
4022
  // ==========================================================================
3920
4023
  async createCheckRun(input) {
3921
4024
  const installationId = this.getInstallationId(input);
3922
- return this.request("POST", "/api/v1/github/check-runs", {
4025
+ return this.landingRequest("POST", "/api/v1/github/check-runs", {
3923
4026
  owner: input.owner,
3924
4027
  repo: input.repo,
3925
4028
  sha: input.sha,
@@ -3932,7 +4035,7 @@ var GitHubClient = class {
3932
4035
  }
3933
4036
  async updateCheckRun(input) {
3934
4037
  const installationId = this.getInstallationId(input);
3935
- return this.request("PATCH", `/api/v1/github/check-runs/${input.checkRunId}`, {
4038
+ return this.landingRequest("PATCH", `/api/v1/github/check-runs/${input.checkRunId}`, {
3936
4039
  owner: input.owner,
3937
4040
  repo: input.repo,
3938
4041
  ...input.status && { status: input.status },