paperclip-github-plugin 0.17.7 → 0.19.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/README.md CHANGED
@@ -39,7 +39,7 @@ The plugin adds a full in-host workflow instead of a one-off import script:
39
39
 
40
40
  ## How it works
41
41
 
42
- 1. Save a GitHub token in the plugin settings.
42
+ 1. Save a GitHub token, or a GitHub App's credentials, in the plugin settings.
43
43
  2. Connect one or more GitHub repositories to Paperclip projects.
44
44
  3. Run a sync manually or let the scheduled job keep things up to date.
45
45
 
@@ -201,6 +201,7 @@ Additional behavior:
201
201
  - If the Paperclip host initially creates that imported maintainer issue in `backlog`, GitHub Sync promotes it to `todo` without replacing the configured default assignee with the executor handoff assignee, so triage ownership stays intact.
202
202
  - When Paperclip board access is connected for a company, the advanced assignee dropdowns list both company agents and `Me` for the connected board user.
203
203
  - Newly imported issues that finish sync in `todo` and are assigned to an agent enqueue an assignee wakeup so the agent can pick them up promptly.
204
+ - GitHub Sync will not repeatedly re-open a deliberately blocked issue. When it moves an issue out of `blocked` it records a hash of the linked pull requests' externally observable state (head SHA, CI state, mergeability, merge state status, review decision, unresolved review threads); while that state is unchanged, a later pass leaves `blocked` alone. This matters when a required check is red for something nobody in the company can clear — the contributor CLA gate is the common case, an upstream baseline failure or an unreleased dependency behave the same. Previously each sync pass moved the issue back to active work, the assignee woke, re-established that it was still externally blocked, and the loop repeated on the next pass. Any real change — a push, a CI result, a review, a resolved conflict — changes the hash and normal routing resumes immediately.
204
205
  - For linked pull requests, GitHub Sync treats merge-conflict, behind-branch, blocked, draft, unstable merge states, and unresolved review threads as executor work, while merge-ready states such as `CLEAN` and `HAS_HOOKS` can move work into `in_review` when CI is green and review threads are resolved. If an issue is already `blocked` and GitHub reports only pending external merge requirements while CI is unfinished, sync preserves the external wait instead of waking an executor. A stale aggregate `CHANGES_REQUESTED` review decision alone does not move that maintainer wait back to active execution. Transient `UNKNOWN` mergeability also does not move an already `in_review` maintainer wait back to active execution when CI is green and review threads are resolved.
205
206
  - Imported issues that are already `blocked` stay `blocked` while any first-class `blockedBy` issue is still non-terminal, even if the linked GitHub pull request is otherwise green and review-ready.
206
207
  - When sync moves work into `in_review`, GitHub Sync first follows the Paperclip issue execution policy's current reviewer or approver when that stage is visible on the issue. If Paperclip exposes an internal review or approval stage but not yet the participant, the plugin falls back to the configured reviewer or approver handoff assignee. If the transition is only a healthy linked-PR wait with no visible internal review or approval stage, GitHub Sync leaves the issue unassigned so it can wait on normal maintainer review without waking an internal owner. An execution state explicitly marked `completed` contains historical stage and decision fields, not active routing: GitHub Sync clears that completed policy/state and the stale internal agent assignee atomically when restoring `done` to `in_review`, keeps any human assignee, and emits no assignment wakeup.
@@ -225,6 +226,54 @@ The plugin is designed to avoid persisting raw credentials in plugin state.
225
226
  - On authenticated Paperclip deployments, sync is blocked until the relevant company has connected Paperclip board access. On local trusted deployments, board access setup remains visible so operators can configure it for host API paths that still require board credentials, but missing board access does not by itself block sync preflight.
226
227
  - KPI API route requests must include `Authorization: Bearer <PAPERCLIP_API_KEY>` from an agent run; the Paperclip host authenticates the token and supplies the agent company before the worker records any metric event.
227
228
 
229
+ ### Authenticating as a GitHub App
230
+
231
+ A company can act on GitHub as a GitHub App instead of a person. In **GitHub access**, choose **GitHub App**, enter the App ID and paste the App's private key (`.pem`). The settings page checks the credentials against GitHub, picks the App installation (the only one, or the one on the account that owns the company's mapped repositories), stores the private key as a company secret named `github_sync_app_key_<company id>`, and mirrors it into plugin config as `githubAppPrivateKeyRefs` next to `githubAppsByCompanyId` (App ID, installation ID, slug).
232
+
233
+ The worker then signs a short-lived App JWT with that key and exchanges it for an installation access token, which it caches and renews about five minutes before its one-hour expiry. Sync, every agent tool and branch publication use that token, so comments, labels, reviews and pull requests are attributed to the App's bot account (`<slug>[bot]`). App authentication takes precedence over a saved token for that company; saving a token again switches the company back to token authentication. Other companies on the same instance are unaffected.
234
+
235
+ The App needs the repository permissions for what the company does: at least Metadata (read), Contents (read), Issues and Pull requests (read and write); Checks (read and write) for check runs; Contents (write) only if agents publish branches. `assign_to_current_user` is not available in App mode, because GitHub does not let an App assign issues to itself.
236
+
237
+ ### Waking agents from GitHub App events
238
+
239
+ With GitHub App authentication, GitHub can wake Paperclip agents directly, without syncing issues. GitHub sends the App's webhook deliveries to the plugin. Each delivery that matches one of the company's **event routes** wakes the route's agent through `agents.invoke`. That run has no Paperclip task, so it creates no assignments, blockers or recovery issues. The agent gets a short prompt with the event, repository, pull request or issue, head commit, labels and any comment text, and fetches the rest with the agent tools.
240
+
241
+ To set it up, open **GitHub App events** in GitHub Sync settings:
242
+
243
+ 1. Copy the **Webhook URL** (`<paperclip origin>/api/plugins/paperclip-github-plugin/webhooks/github`) into the App's webhook settings on GitHub and turn the webhook on.
244
+ 2. Click **Generate secret**, paste the secret into the App's webhook secret on GitHub, and save. The secret is stored as a company secret.
245
+ 3. Subscribe the App to the events your routes use: Pull request, Issues, Issue comment, Pull request review, Pull request review comment, and Check suite and Workflow run for `ci_completed`.
246
+ 4. Write the routes as a JSON array and save.
247
+
248
+ ```json
249
+ [
250
+ {
251
+ "id": "first-pass-review",
252
+ "event": "ci_completed",
253
+ "agentId": "<reviewer agent id>",
254
+ "repositories": ["micronaut-projects/*"],
255
+ "excludedLabels": ["risk-tier: t0"],
256
+ "instructions": "Run the AI first pass on this pull request."
257
+ },
258
+ { "id": "triage", "event": "issues", "agentId": "<triage agent id>" },
259
+ { "id": "ask", "event": "issue_comment", "agentId": "<reviewer agent id>" }
260
+ ]
261
+ ```
262
+
263
+ | Field | Meaning |
264
+ | --- | --- |
265
+ | `event` | `pull_request`, `issues`, `issue_comment`, `pull_request_review`, `pull_request_review_comment`, or `ci_completed`. |
266
+ | `actions` | GitHub actions that count. Defaults: `opened`, `reopened`, `ready_for_review`, `synchronize` for pull requests; `opened` for issues; `created` for comments; `submitted` for reviews. |
267
+ | `repositories` | `owner/repo` or `owner/*`. Empty means every repository the App can see. |
268
+ | `includeDrafts`, `includeBotAuthors` | Draft pull requests and bot-authored items are skipped unless set to `true`. |
269
+ | `requiredLabels`, `excludedLabels`, `excludedAuthors` | Case-insensitive filters. |
270
+ | `requireMention` | Comment and review events wake only when the text mentions `@<app slug>`. Defaults to `true`. |
271
+ | `instructions` | Text appended to the prompt, up to 4,000 characters. |
272
+
273
+ `ci_completed` fires when every check run on a pull request's head commit has finished, not counting the App's own checks, so a review can wait for CI. It comes from `check_suite` and `workflow_run` deliveries. Pull requests from forks are found through the commit. The prompt reports the overall result as `success` or `failure`.
274
+
275
+ Every delivery's signature is checked against the company's webhook secret before anything in it is used. Only deliveries from the company's App installation are accepted. The App's own activity never wakes an agent. A redelivery, or several CI suites finishing on one commit, wakes each route once. A delivery with a bad signature is rejected and shows as failed in the App's delivery log.
276
+
228
277
  #### Sharing the token with Paperclip's own GitHub features
229
278
 
230
279
  GitHub Sync stores its token as a company secret named `github_sync_<company id>` and references it from plugin config. Paperclip's host-side GitHub features do not read that reference: `server/src/services/git-credentials.ts` resolves a company secret **by name**, probing `GITHUB_TOKEN`, `GH_TOKEN` and `PAPERCLIP_GITHUB_TOKEN` in that order. Those credentials back managed-checkout git authentication, the merged-PR confirmation sweep, the execution-workspace reaper's `merged_via_pr` detection, and the built-in GitHub external-object provider's liveness snapshots. Without one of those secrets those host features run unauthenticated and degrade on private repositories and GitHub rate limits.
@@ -272,6 +321,8 @@ The plugin exposes GitHub workflow tools to Paperclip agents, including:
272
321
  - issue reads, comment reads, comment writes, metadata updates, native `completed`/`not_planned`/`duplicate` closure and `reopened` transitions, and `assign_to_current_user` assignment to the saved token owner
273
322
  - pull request creation, reads, updates, changed-file inspection, CI-check inspection, and asset upload for PR visual evidence
274
323
  - review-thread reads, replies, resolve and unresolve actions, and `request_pull_request_reviewers` reviewer requests
324
+ - shared company memory: `remember_memory`, `recall_memories`, and `forget_memory`
325
+ - review tools for an AI first-pass reviewer: `submit_pull_request_review`, `create_check_run`, `update_check_run`, `add_pull_request_labels`, and `remove_pull_request_labels`
275
326
  - organization-level GitHub Project search/listing and pull-request-to-project association
276
327
 
277
328
  `create_pull_request` is the single agent-facing delivery call for both branch publication and PR creation. The caller supplies the Paperclip issue id, a plain local branch name, the exact 40-character local branch-tip SHA, the base branch, and the PR metadata. The optional `repository` may select any GitHub repository, including one that is not mapped in Paperclip; if omitted, the issue project must have exactly one mapped repository. By default the tool uses the execution-workspace root as the local Git checkout. For general-purpose workspaces that contain several repositories, `workspaceRelativePath` selects a checkout below that trusted root, with realpath containment enforced. The trusted plugin worker verifies checkout ownership, resolves the issue's execution worktree and GitHub secret, verifies the checked-out branch, worktree HEAD, local branch tip, and base ancestry, publishes only that exact commit with a non-forcing refspec, reads the remote branch SHA back, and only then asks GitHub to create and link the PR. GitHub token permissions determine whether publication and PR creation are allowed. The credential is never returned to or injected into the calling agent.
@@ -280,6 +331,10 @@ Branch publication uses an isolated temporary bare repository backed by the sele
280
331
 
281
332
  Optional `labels`, `userReviewers`, and `teamReviewers` are applied right after the pull request exists (for example the approved `type:` label and the linked issue author as reviewer). Those follow-up calls never undo the pull request: their outcome is reported in the result as `labels`, `requestedReviewers`, `requestedTeams`, or `warnings`. The tool also appends the new pull request to the issue's GitHub link record immediately, so the Paperclip issue card shows the linked pull request without waiting for the next sync. `update_pull_request` accepts a replacement `labels` set, and `get_issue` returns the issue `author`, all `participants` (author and distinct commenters with their repository association), and `reviewerCandidates` (non-bot owners, members, and collaborators among them) so agents can request the reporter and the maintainers who joined the discussion as reviewers.
282
333
 
334
+ The memory tools give every agent in a company one shared notebook. A note has a topic, short content (up to 2,000 characters), optional tags, and either a repository (`owner/repo`) or company-wide scope. Saving the same repository and topic again replaces the note, and `forget_memory` removes it. `recall_memories` returns notes for a repository plus the company-wide ones. It ranks them by how many query words appear in the topic, tags and content, then by recency, and returns at most 25. No model call is involved. Notes are plugin entities scoped to the company, with up to 1,000 per company, and they are never visible to another company. Don't store secrets or personal data in them.
335
+
336
+ `submit_pull_request_review` submits one review with an optional set of up to 50 inline comments on diff lines (`path`, `line`, optional `side`, and `startLine` for a range). The verdict is `COMMENT` (default) or `REQUEST_CHANGES`; `APPROVE` is rejected, so approval always stays with a human reviewer. The review summary carries the AI-authorship footer. `create_check_run` attaches a named check, such as `AI first pass`, to the pull request head commit (or an explicit `headSha`), and `update_check_run` moves it to `in_progress` or completes it with a conclusion and a `title`/`summary` output. Branch rules can require that check, which lets an agent gate a merge without approving it. GitHub only lets GitHub Apps write check runs, so these two tools need [GitHub App authentication](#authenticating-as-a-github-app); with a personal token they fail with an error that says so. `add_pull_request_labels` and `remove_pull_request_labels` change only the named labels, unlike `update_pull_request`, which replaces the whole set; removing a label the pull request does not have is reported in `notPresent` rather than failing.
337
+
283
338
  The call is ordered and retry-safe rather than a cross-system transaction: a published branch may remain if GitHub PR creation or Paperclip link persistence fails. On retry, the tool re-verifies and republishes the exact SHA, then recovers an already-open PR only when repository, head, base, and head SHA all match before repairing the link and metric. It never deletes a branch or closes a PR as automatic compensation.
284
339
 
285
340
  After that durable link is written, pull-request tools can use the same `paperclipIssueId` to read or update the PR immediately, even when the Paperclip issue was created natively and has no linked GitHub issue. If one Paperclip issue has same-number PRs in different repositories, the caller must also supply the repository so the worker can reject ambiguous or unlinked selections.
@@ -297,9 +352,9 @@ Two details decide the recipe:
297
352
  - Plugin tools are dispatched with `providerType: "paperclip_plugin"` and carry **no connection id, no catalog entry id and no application id** (`server/src/services/tool-gateway.ts`). A profile entry with `selectorType: "connection"` or `"catalog_entry"` requires a non-null id at write time, so those selectors can never match a plugin tool.
298
353
  - The selectors that *can* match are `tool_name` (compared against the fully namespaced name, `paperclip-github-plugin:<tool>`) and `risk_level`. A profile with `defaultAction: "allow"` also matches everything.
299
354
 
300
- The recipe below uses explicit `tool_name` include entries for all 21 tools on a profile whose `defaultAction` stays `deny`, bound at **company** scope. That keeps the profile least-privilege and makes the grant auditable per tool.
355
+ The recipe below uses explicit `tool_name` include entries for all 29 tools on a profile whose `defaultAction` stays `deny`, bound at **company** scope. That keeps the profile least-privilege and makes the grant auditable per tool.
301
356
 
302
- #### The 21 tool names
357
+ #### The 29 tool names
303
358
 
304
359
  ```text
305
360
  paperclip-github-plugin:search_repository_items
@@ -318,10 +373,18 @@ paperclip-github-plugin:reply_to_review_thread
318
373
  paperclip-github-plugin:resolve_review_thread
319
374
  paperclip-github-plugin:unresolve_review_thread
320
375
  paperclip-github-plugin:request_pull_request_reviewers
376
+ paperclip-github-plugin:submit_pull_request_review
377
+ paperclip-github-plugin:create_check_run
378
+ paperclip-github-plugin:update_check_run
379
+ paperclip-github-plugin:add_pull_request_labels
380
+ paperclip-github-plugin:remove_pull_request_labels
321
381
  paperclip-github-plugin:list_organization_projects
322
382
  paperclip-github-plugin:add_pull_request_to_project
323
383
  paperclip-github-plugin:upload_pull_request_asset
324
384
  paperclip-github-plugin:link_github_item
385
+ paperclip-github-plugin:remember_memory
386
+ paperclip-github-plugin:recall_memories
387
+ paperclip-github-plugin:forget_memory
325
388
  paperclip-github-plugin:get_issue_interaction_summary
326
389
  ```
327
390
 
package/dist/manifest.js CHANGED
@@ -61,6 +61,47 @@ var pullRequestTargetSchema = {
61
61
  }
62
62
  ]
63
63
  };
64
+ var checkRunUpdateProperties = {
65
+ status: {
66
+ type: "string",
67
+ enum: ["queued", "in_progress", "completed"],
68
+ description: "Check status. Setting conclusion implies completed."
69
+ },
70
+ conclusion: {
71
+ type: "string",
72
+ enum: ["success", "failure", "neutral", "cancelled", "skipped", "timed_out", "action_required"],
73
+ description: "Required when status is completed."
74
+ },
75
+ title: {
76
+ type: "string",
77
+ description: "Short output title. Requires summary."
78
+ },
79
+ summary: {
80
+ type: "string",
81
+ description: "Markdown output summary, up to 65535 characters. Requires title."
82
+ },
83
+ text: {
84
+ type: "string",
85
+ description: "Optional longer Markdown output details."
86
+ },
87
+ detailsUrl: {
88
+ type: "string",
89
+ description: "Optional link shown as the check details, such as the Paperclip issue."
90
+ },
91
+ externalId: {
92
+ type: "string",
93
+ description: "Optional caller reference stored on the check run."
94
+ }
95
+ };
96
+ var pullRequestLabelsProperty = {
97
+ type: "array",
98
+ minItems: 1,
99
+ items: {
100
+ type: "string",
101
+ minLength: 1
102
+ },
103
+ description: "Label names."
104
+ };
64
105
  var organizationProjectTargetSchema = {
65
106
  anyOf: [
66
107
  {
@@ -536,6 +577,162 @@ var GITHUB_AGENT_TOOLS = [
536
577
  ]
537
578
  }
538
579
  },
580
+ {
581
+ name: "submit_pull_request_review",
582
+ displayName: "Submit Pull Request Review",
583
+ description: "Submit a pull request review as COMMENT or REQUEST_CHANGES, optionally with inline comments on changed lines. Approving is not supported: approval stays with human reviewers. Provide only the human-facing body; the plugin appends the required AI-authorship footer and includes llmModel when supplied.",
584
+ parametersSchema: {
585
+ type: "object",
586
+ additionalProperties: false,
587
+ required: ["body"],
588
+ ...pullRequestTargetSchema,
589
+ properties: {
590
+ repository: repositoryProperty,
591
+ pullRequestNumber: pullRequestNumberProperty,
592
+ paperclipIssueId: paperclipIssueIdProperty,
593
+ event: {
594
+ type: "string",
595
+ enum: ["COMMENT", "REQUEST_CHANGES"],
596
+ description: "Review verdict. Defaults to COMMENT. APPROVE is deliberately not accepted."
597
+ },
598
+ body: {
599
+ type: "string",
600
+ minLength: 1,
601
+ description: "Review summary without the AI footer."
602
+ },
603
+ commitId: {
604
+ type: "string",
605
+ description: "Optional head commit SHA the review applies to. GitHub rejects inline comments when this does not match the reviewed diff; omit to review the current head."
606
+ },
607
+ comments: {
608
+ type: "array",
609
+ maxItems: 50,
610
+ description: "Optional inline comments. Each one targets a line of the pull request diff.",
611
+ items: {
612
+ type: "object",
613
+ additionalProperties: false,
614
+ required: ["path", "line", "body"],
615
+ properties: {
616
+ path: {
617
+ type: "string",
618
+ description: "File path relative to the repository root."
619
+ },
620
+ line: {
621
+ type: "integer",
622
+ minimum: 1,
623
+ description: "Line in the file the comment applies to (the last line for a multi-line comment)."
624
+ },
625
+ side: {
626
+ type: "string",
627
+ enum: ["LEFT", "RIGHT"],
628
+ description: "RIGHT for added or unchanged lines (default), LEFT for deleted lines."
629
+ },
630
+ startLine: {
631
+ type: "integer",
632
+ minimum: 1,
633
+ description: "First line of a multi-line comment."
634
+ },
635
+ startSide: {
636
+ type: "string",
637
+ enum: ["LEFT", "RIGHT"],
638
+ description: "Side of startLine. Defaults to side."
639
+ },
640
+ body: {
641
+ type: "string",
642
+ minLength: 1,
643
+ description: "Inline comment text."
644
+ }
645
+ }
646
+ }
647
+ },
648
+ llmModel: llmModelProperty
649
+ }
650
+ }
651
+ },
652
+ {
653
+ name: "create_check_run",
654
+ displayName: "Create Check Run",
655
+ description: 'Create a GitHub check run on a pull request head commit, for example an "AI first pass" check that branch rules can require. Requires GitHub App authentication: GitHub does not let personal tokens write check runs.',
656
+ parametersSchema: {
657
+ type: "object",
658
+ additionalProperties: false,
659
+ required: ["name"],
660
+ anyOf: [
661
+ { required: ["paperclipIssueId"] },
662
+ { required: ["pullRequestNumber"] },
663
+ { required: ["headSha"] }
664
+ ],
665
+ properties: {
666
+ repository: repositoryProperty,
667
+ pullRequestNumber: pullRequestNumberProperty,
668
+ paperclipIssueId: paperclipIssueIdProperty,
669
+ headSha: {
670
+ type: "string",
671
+ description: "Commit SHA to attach the check to. Defaults to the pull request head commit."
672
+ },
673
+ name: {
674
+ type: "string",
675
+ minLength: 1,
676
+ description: 'Check name shown on the pull request, such as "AI first pass".'
677
+ },
678
+ ...checkRunUpdateProperties
679
+ }
680
+ }
681
+ },
682
+ {
683
+ name: "update_check_run",
684
+ displayName: "Update Check Run",
685
+ description: "Update a check run created by create_check_run: move it to in_progress, or complete it with a conclusion and summary. Requires GitHub App authentication.",
686
+ parametersSchema: {
687
+ type: "object",
688
+ additionalProperties: false,
689
+ required: ["checkRunId"],
690
+ properties: {
691
+ repository: repositoryProperty,
692
+ paperclipIssueId: paperclipIssueIdProperty,
693
+ checkRunId: {
694
+ type: "integer",
695
+ minimum: 1,
696
+ description: "Check run id returned by create_check_run."
697
+ },
698
+ ...checkRunUpdateProperties
699
+ }
700
+ }
701
+ },
702
+ {
703
+ name: "add_pull_request_labels",
704
+ displayName: "Add Pull Request Labels",
705
+ description: "Add labels to a pull request without touching its other labels.",
706
+ parametersSchema: {
707
+ type: "object",
708
+ additionalProperties: false,
709
+ required: ["labels"],
710
+ ...pullRequestTargetSchema,
711
+ properties: {
712
+ repository: repositoryProperty,
713
+ pullRequestNumber: pullRequestNumberProperty,
714
+ paperclipIssueId: paperclipIssueIdProperty,
715
+ labels: pullRequestLabelsProperty
716
+ }
717
+ }
718
+ },
719
+ {
720
+ name: "remove_pull_request_labels",
721
+ displayName: "Remove Pull Request Labels",
722
+ description: "Remove labels from a pull request. Labels the pull request does not have are ignored.",
723
+ parametersSchema: {
724
+ type: "object",
725
+ additionalProperties: false,
726
+ required: ["labels"],
727
+ ...pullRequestTargetSchema,
728
+ properties: {
729
+ repository: repositoryProperty,
730
+ pullRequestNumber: pullRequestNumberProperty,
731
+ paperclipIssueId: paperclipIssueIdProperty,
732
+ labels: pullRequestLabelsProperty
733
+ }
734
+ }
735
+ },
539
736
  {
540
737
  name: "list_organization_projects",
541
738
  displayName: "List Organization Projects",
@@ -683,6 +880,92 @@ var GITHUB_AGENT_TOOLS = [
683
880
  }
684
881
  }
685
882
  },
883
+ {
884
+ name: "remember_memory",
885
+ displayName: "Remember",
886
+ description: "Save a short note to the company memory that every agent shares, such as a repository convention, a known flaky test, or a reviewer preference. Saving the same repository and topic again replaces the note. Keep notes factual and specific; never store secrets or personal data.",
887
+ parametersSchema: {
888
+ type: "object",
889
+ additionalProperties: false,
890
+ required: ["topic", "content"],
891
+ properties: {
892
+ repository: {
893
+ type: "string",
894
+ description: "GitHub repository as owner/repo the note applies to. Omit for a company-wide note."
895
+ },
896
+ topic: {
897
+ type: "string",
898
+ minLength: 1,
899
+ maxLength: 120,
900
+ description: 'Short title that identifies the note, such as "flaky test: HttpClientSpec".'
901
+ },
902
+ content: {
903
+ type: "string",
904
+ minLength: 1,
905
+ maxLength: 2e3,
906
+ description: "The note itself."
907
+ },
908
+ tags: {
909
+ type: "array",
910
+ maxItems: 10,
911
+ items: { type: "string" },
912
+ description: 'Optional tags, such as "review", "triage" or "ci".'
913
+ }
914
+ }
915
+ }
916
+ },
917
+ {
918
+ name: "recall_memories",
919
+ displayName: "Recall",
920
+ description: "Look up notes in the shared company memory. Returns notes for the repository plus company-wide notes, best matches first. Call it before starting work on a repository, with a few keywords.",
921
+ parametersSchema: {
922
+ type: "object",
923
+ additionalProperties: false,
924
+ properties: {
925
+ query: {
926
+ type: "string",
927
+ description: "Keywords matched against note topics, tags and content. Omit to get the most recent notes."
928
+ },
929
+ repository: {
930
+ type: "string",
931
+ description: "GitHub repository as owner/repo. Company-wide notes are always included."
932
+ },
933
+ tags: {
934
+ type: "array",
935
+ items: { type: "string" },
936
+ description: "Only return notes with at least one of these tags."
937
+ },
938
+ limit: {
939
+ type: "integer",
940
+ minimum: 1,
941
+ maximum: 25,
942
+ description: "Maximum number of notes. Defaults to 10."
943
+ }
944
+ }
945
+ }
946
+ },
947
+ {
948
+ name: "forget_memory",
949
+ displayName: "Forget",
950
+ description: "Remove a note from the shared company memory when it is wrong or no longer true.",
951
+ parametersSchema: {
952
+ type: "object",
953
+ additionalProperties: false,
954
+ required: ["topic"],
955
+ properties: {
956
+ repository: {
957
+ type: "string",
958
+ description: "Repository of the note as owner/repo. Omit for a company-wide note."
959
+ },
960
+ topic: {
961
+ type: "string",
962
+ minLength: 1,
963
+ maxLength: 120,
964
+ description: "Topic of the note to remove."
965
+ }
966
+ }
967
+ }
968
+ },
686
969
  {
687
970
  name: "get_issue_interaction_summary",
688
971
  displayName: "Get Issue Interaction Summary",
@@ -709,6 +992,9 @@ var GITHUB_AGENT_TOOLS = [
709
992
  }
710
993
  ];
711
994
 
995
+ // src/github-webhooks.ts
996
+ var GITHUB_WEBHOOK_ENDPOINT_KEY = "github";
997
+
712
998
  // src/kpi-contract.ts
713
999
  var GITHUB_SYNC_PLUGIN_ID = "paperclip-github-plugin";
714
1000
  var COMPANY_METRIC_API_ROUTE_KEY = "record-company-metric-event";
@@ -719,7 +1005,7 @@ var COMPANY_METRIC_API_ROUTE_URL_PATH = `/api/plugins/${GITHUB_SYNC_PLUGIN_ID}/a
719
1005
  var require2 = createRequire(import.meta.url);
720
1006
  var packageJson = require2("../package.json");
721
1007
  var SCHEDULE_TICK_CRON = "* * * * *";
722
- var MANIFEST_VERSION = "0.17.7"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
1008
+ var MANIFEST_VERSION = "0.19.0"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
723
1009
  var COMPANY_SECRET_REF_VALUE_SCHEMA = {
724
1010
  anyOf: [
725
1011
  { type: "string" },
@@ -762,11 +1048,13 @@ var manifest = {
762
1048
  "issue.comments.read",
763
1049
  "issue.comments.create",
764
1050
  "agents.read",
1051
+ "agents.invoke",
765
1052
  "jobs.schedule",
766
1053
  "api.routes.register",
767
1054
  "http.outbound",
768
1055
  "secrets.read-ref",
769
- "agent.tools.register"
1056
+ "agent.tools.register",
1057
+ "webhooks.receive"
770
1058
  ],
771
1059
  instanceConfigSchema: {
772
1060
  type: "object",
@@ -783,6 +1071,41 @@ var manifest = {
783
1071
  description: "Company id to Paperclip secret reference for the board access token.",
784
1072
  additionalProperties: COMPANY_SECRET_REF_VALUE_SCHEMA
785
1073
  },
1074
+ githubAppsByCompanyId: {
1075
+ type: "object",
1076
+ title: "GitHub App Authentication",
1077
+ description: "Company id to the GitHub App and installation the company authenticates as. Takes precedence over the GitHub token.",
1078
+ additionalProperties: {
1079
+ type: "object",
1080
+ properties: {
1081
+ appId: { type: "string" },
1082
+ installationId: { type: "integer" },
1083
+ slug: { type: "string" }
1084
+ },
1085
+ required: ["appId", "installationId"]
1086
+ }
1087
+ },
1088
+ githubAppPrivateKeyRefs: {
1089
+ type: "object",
1090
+ title: "GitHub App Private Key Secrets",
1091
+ description: "Company id to Paperclip secret reference for the GitHub App private key.",
1092
+ additionalProperties: COMPANY_SECRET_REF_VALUE_SCHEMA
1093
+ },
1094
+ githubWebhookSecretRefs: {
1095
+ type: "object",
1096
+ title: "GitHub App Webhook Secrets",
1097
+ description: "Company id to Paperclip secret reference for the GitHub App webhook secret.",
1098
+ additionalProperties: COMPANY_SECRET_REF_VALUE_SCHEMA
1099
+ },
1100
+ githubEventRoutesByCompanyId: {
1101
+ type: "object",
1102
+ title: "GitHub Event Routes",
1103
+ description: "Company id to the list of GitHub events that wake a Paperclip agent.",
1104
+ additionalProperties: {
1105
+ type: "array",
1106
+ items: { type: "object" }
1107
+ }
1108
+ },
786
1109
  paperclipApiBaseUrl: {
787
1110
  type: "string",
788
1111
  title: "Trusted Paperclip API Origin"
@@ -806,6 +1129,13 @@ var manifest = {
806
1129
  capability: "api.routes.register"
807
1130
  }
808
1131
  ],
1132
+ webhooks: [
1133
+ {
1134
+ endpointKey: GITHUB_WEBHOOK_ENDPOINT_KEY,
1135
+ displayName: "GitHub App events",
1136
+ description: "Signed GitHub App webhook deliveries. Matching events wake the Paperclip agent named by an event route."
1137
+ }
1138
+ ],
809
1139
  tools: GITHUB_AGENT_TOOLS,
810
1140
  entrypoints: {
811
1141
  worker: "./dist/worker.js",