paperclip-github-plugin 0.10.1 → 0.11.0

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/worker.js CHANGED
@@ -687,12 +687,6 @@ var GITHUB_SYNC_PLUGIN_ID = "paperclip-github-plugin";
687
687
  var COMPANY_METRIC_API_ROUTE_KEY = "record-company-metric-event";
688
688
  var COMPANY_METRIC_API_ROUTE_PATH = "/company-metrics/events";
689
689
  var COMPANY_METRIC_API_ROUTE_URL_PATH = `/api/plugins/${GITHUB_SYNC_PLUGIN_ID}/api${COMPANY_METRIC_API_ROUTE_PATH}`;
690
- var ISSUE_LINK_API_ROUTE_KEY = "link-github-item";
691
- var ISSUE_LINK_API_ROUTE_PATH = "/issue-link";
692
- var ISSUE_LINK_API_ROUTE_URL_PATH = `/api/plugins/${GITHUB_SYNC_PLUGIN_ID}/api${ISSUE_LINK_API_ROUTE_PATH}`;
693
- var PULL_REQUEST_ASSET_API_ROUTE_KEY = "upload-pull-request-asset";
694
- var PULL_REQUEST_ASSET_API_ROUTE_PATH = "/pull-request-assets";
695
- var PULL_REQUEST_ASSET_API_ROUTE_URL_PATH = `/api/plugins/${GITHUB_SYNC_PLUGIN_ID}/api${PULL_REQUEST_ASSET_API_ROUTE_PATH}`;
696
690
 
697
691
  // src/paperclip-health.ts
698
692
  function normalizeOptionalString(value) {
@@ -10793,127 +10787,6 @@ async function handleCompanyMetricApiRoute(ctx, input) {
10793
10787
  }
10794
10788
  };
10795
10789
  }
10796
- function parsePluginApiRouteJsonObjectBody(input, routeLabel) {
10797
- if (!input.body || typeof input.body !== "object" || Array.isArray(input.body)) {
10798
- throw new Error(`${routeLabel} body must be a JSON object.`);
10799
- }
10800
- return input.body;
10801
- }
10802
- function parseIssueLinkApiRouteBody(input) {
10803
- return parsePluginApiRouteJsonObjectBody(input, "Issue link route");
10804
- }
10805
- function normalizeIssueLinkApiRouteKind(payload) {
10806
- const explicitKind = normalizeIssueGitHubLinkKind(payload.kind);
10807
- if (explicitKind) {
10808
- return explicitKind;
10809
- }
10810
- const reference = normalizeOptionalString2(payload.reference);
10811
- if (normalizeGitHubPullRequestHtmlUrl(normalizeOptionalString2(payload.pullRequestUrl)) || normalizeToolPositiveInteger(payload.pullRequestNumber) || reference && parseGitHubPullRequestHtmlUrl(reference)) {
10812
- return "pull_request";
10813
- }
10814
- if (normalizeToolPositiveInteger(payload.issueNumber) || reference && parseGitHubIssueHtmlUrl(reference)) {
10815
- return "issue";
10816
- }
10817
- return null;
10818
- }
10819
- async function handlePullRequestAssetApiRoute(ctx, input) {
10820
- if (input.actor.actorType !== "agent") {
10821
- throw new Error("Pull request assets must be uploaded by an authenticated Paperclip agent.");
10822
- }
10823
- const payload = parsePluginApiRouteJsonObjectBody(input, "Pull request asset route");
10824
- const rawPullRequestUrl = normalizeOptionalString2(payload.pullRequestUrl);
10825
- const pullRequestUrl = normalizeGitHubPullRequestHtmlUrl(rawPullRequestUrl);
10826
- if (rawPullRequestUrl && !pullRequestUrl) {
10827
- throw new Error("pullRequestUrl must be a valid GitHub pull request URL.");
10828
- }
10829
- const parsedPullRequestUrl = pullRequestUrl ? parseGitHubPullRequestHtmlUrl(pullRequestUrl) : void 0;
10830
- const repositoryInput = normalizeOptionalString2(payload.repository) ?? parsedPullRequestUrl?.repositoryUrl;
10831
- if (!repositoryInput) {
10832
- throw new Error("repository is required unless pullRequestUrl is provided.");
10833
- }
10834
- const repository = requireRepositoryReference(repositoryInput);
10835
- const pullRequestNumber = normalizeToolPositiveInteger(payload.pullRequestNumber) ?? parsedPullRequestUrl?.pullRequestNumber;
10836
- if (!pullRequestNumber) {
10837
- throw new Error("pullRequestNumber is required unless pullRequestUrl is provided.");
10838
- }
10839
- if (parsedPullRequestUrl && !areRepositoriesEqual(repository, requireRepositoryReference(parsedPullRequestUrl.repositoryUrl))) {
10840
- throw new Error("repository must match pullRequestUrl.");
10841
- }
10842
- const octokit = await createGitHubToolOctokit(ctx, input.companyId, {
10843
- toolName: PULL_REQUEST_ASSET_API_ROUTE_KEY,
10844
- repositoryUrl: repository.url
10845
- });
10846
- const asset = await uploadPullRequestAssetArtifact({
10847
- octokit,
10848
- repository,
10849
- pullRequestNumber,
10850
- payload
10851
- });
10852
- return {
10853
- status: 201,
10854
- body: {
10855
- status: "uploaded",
10856
- asset
10857
- }
10858
- };
10859
- }
10860
- async function handleIssueLinkApiRoute(ctx, input) {
10861
- if (input.actor.actorType !== "agent") {
10862
- throw new Error("GitHub issue links must be recorded by an authenticated Paperclip agent.");
10863
- }
10864
- const companyId = normalizeCompanyId(input.companyId);
10865
- if (!companyId) {
10866
- throw new Error("GitHub issue links require the host to provide the authenticated agent company.");
10867
- }
10868
- const payload = parseIssueLinkApiRouteBody(input);
10869
- const requestedCompanyId = normalizeCompanyId(payload.companyId);
10870
- if (requestedCompanyId && requestedCompanyId !== companyId) {
10871
- throw new Error("companyId must match the authenticated Paperclip agent company.");
10872
- }
10873
- const kind = normalizeIssueLinkApiRouteKind(payload);
10874
- if (!kind) {
10875
- throw new Error('kind must be "issue" or "pull_request", or the payload must include a full GitHub URL.');
10876
- }
10877
- const paperclipIssueId = normalizeOptionalString2(payload.paperclipIssueId) ?? normalizeOptionalString2(payload.issueId);
10878
- if (!paperclipIssueId) {
10879
- throw new Error("paperclipIssueId is required.");
10880
- }
10881
- const linkResult = kind === "issue" ? await linkPaperclipIssueToGitHubIssue(ctx, {
10882
- companyId,
10883
- issueId: paperclipIssueId,
10884
- reference: payload.reference,
10885
- repositoryUrl: normalizeOptionalString2(payload.repository),
10886
- issueNumber: payload.issueNumber,
10887
- allowUnmapped: true
10888
- }) : await linkPaperclipIssueToGitHubPullRequest(ctx, {
10889
- companyId,
10890
- issueId: paperclipIssueId,
10891
- reference: payload.reference,
10892
- repositoryUrl: normalizeOptionalString2(payload.repository),
10893
- pullRequestNumber: payload.pullRequestNumber,
10894
- pullRequestUrl: payload.pullRequestUrl,
10895
- allowUnmapped: true
10896
- });
10897
- ctx.logger.info("GitHub Sync recorded a GitHub issue link API route event.", {
10898
- routeKey: input.routeKey,
10899
- companyId,
10900
- kind,
10901
- paperclipIssueId,
10902
- repositoryUrl: normalizeOptionalString2(linkResult.repositoryUrl),
10903
- githubIssueNumber: normalizeToolPositiveInteger(linkResult.githubIssueNumber),
10904
- githubPullRequestNumber: normalizeToolPositiveInteger(linkResult.githubPullRequestNumber),
10905
- agentId: input.actor.agentId ?? null,
10906
- runId: input.actor.runId ?? null
10907
- });
10908
- return {
10909
- status: 201,
10910
- body: {
10911
- status: "linked",
10912
- companyId,
10913
- ...linkResult
10914
- }
10915
- };
10916
- }
10917
10790
  async function createGitHubToolOctokit(ctx, companyId, context = {}) {
10918
10791
  const token = (await resolveGithubToken(ctx, { companyId })).trim();
10919
10792
  if (!token) {
@@ -16220,7 +16093,7 @@ var plugin = definePlugin({
16220
16093
  });
16221
16094
  ctx.actions.register("sync.runNow", async (input, actionContext) => {
16222
16095
  const record = normalizeActionRecord(input, actionContext);
16223
- const waitForCompletion = "waitForCompletion" in record ? Boolean(record.waitForCompletion) : false;
16096
+ const waitForCompletion = "waitForCompletion" in record ? Boolean(record.waitForCompletion) : true;
16224
16097
  const paperclipApiBaseUrl = "paperclipApiBaseUrl" in record ? record.paperclipApiBaseUrl : void 0;
16225
16098
  const companyId = "companyId" in record && typeof record.companyId === "string" ? record.companyId : void 0;
16226
16099
  const projectId = "projectId" in record && typeof record.projectId === "string" ? record.projectId : void 0;
@@ -16301,12 +16174,6 @@ var plugin = definePlugin({
16301
16174
  if (input.routeKey === COMPANY_METRIC_API_ROUTE_KEY) {
16302
16175
  return handleCompanyMetricApiRoute(pluginRuntimeContext, input);
16303
16176
  }
16304
- if (input.routeKey === ISSUE_LINK_API_ROUTE_KEY) {
16305
- return handleIssueLinkApiRoute(pluginRuntimeContext, input);
16306
- }
16307
- if (input.routeKey === PULL_REQUEST_ASSET_API_ROUTE_KEY) {
16308
- return handlePullRequestAssetApiRoute(pluginRuntimeContext, input);
16309
- }
16310
16177
  return {
16311
16178
  status: 404,
16312
16179
  body: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-github-plugin",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "Paperclip plugin for synchronizing GitHub issues into Paperclip projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@octokit/rest": "^22.0.1",
44
- "@paperclipai/plugin-sdk": "^2026.529.0",
44
+ "@paperclipai/plugin-sdk": "^2026.609.0",
45
45
  "react": "^19.2.7",
46
46
  "react-markdown": "^10.1.0",
47
47
  "rehype-raw": "^7.0.0",