@elizaos/plugin-github 2.0.0-beta.1 → 2.0.3-beta.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shaw Walters and elizaOS Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # @elizaos/plugin-github
2
+
3
+ GitHub integration for elizaOS agents. Enables agents to manage pull requests, issues, and notifications using the GitHub REST API via Octokit.
4
+
5
+ ## What it does
6
+
7
+ - **List pull requests** — open/closed/all for a specific repo or across accessible repos, with optional author filter.
8
+ - **Review pull requests** — submit approve, request-changes, or comment reviews (requires confirmation).
9
+ - **Issue management** — create, assign, close, reopen, comment on, or label issues (all write ops require confirmation).
10
+ - **Notification triage** — fetch unread GitHub notifications and return them ranked by priority score (reason, subject type, repo freshness). Read-only, no confirmation needed.
11
+ - **PAT management** — REST endpoints for storing/removing a GitHub Personal Access Token from local disk (`<state-dir>/credentials/github.json`).
12
+
13
+ ## Enabling the plugin
14
+
15
+ Add `"@elizaos/plugin-github"` to the agent's `plugins` array in its character file or runtime configuration. The plugin is opt-in.
16
+
17
+ ## Required configuration
18
+
19
+ At least one GitHub token must be configured. The plugin supports two roles:
20
+
21
+ - **`user`** — acts on behalf of the human (used for reviews and notifications by default).
22
+ - **`agent`** — acts on behalf of the Eliza agent (used for issue and PR ops by default).
23
+
24
+ ### Multi-account (recommended)
25
+
26
+ Set `GITHUB_ACCOUNTS` to a JSON array:
27
+
28
+ ```json
29
+ [
30
+ { "accountId": "user", "role": "user", "token": "ghp_..." },
31
+ { "accountId": "agent", "role": "agent", "token": "ghp_..." }
32
+ ]
33
+ ```
34
+
35
+ ### Legacy single-account
36
+
37
+ | Env var | Role |
38
+ |---|---|
39
+ | `GITHUB_USER_PAT` | user |
40
+ | `GITHUB_AGENT_PAT` | agent |
41
+
42
+ ### OAuth (optional)
43
+
44
+ To enable OAuth-app flows through the connector account manager, also set:
45
+
46
+ - `GITHUB_OAUTH_CLIENT_ID`
47
+ - `GITHUB_OAUTH_CLIENT_SECRET`
48
+ - `GITHUB_OAUTH_REDIRECT_URI`
49
+
50
+ ## Actions
51
+
52
+ The plugin exposes one umbrella action `GITHUB` that dispatches to sub-operations via an `action` parameter:
53
+
54
+ | `action` value | What it does |
55
+ |---|---|
56
+ | `pr_list` | List pull requests |
57
+ | `pr_review` | Submit a PR review (requires `review_action`: approve / request-changes / comment) |
58
+ | `issue_create` | Create a new issue (`title` required) |
59
+ | `issue_assign` | Assign users to an issue |
60
+ | `issue_close` | Close an issue |
61
+ | `issue_reopen` | Reopen a closed issue |
62
+ | `issue_comment` | Add a comment to an issue |
63
+ | `issue_label` | Apply labels to an issue |
64
+ | `notification_triage` | Fetch and rank unread notifications |
65
+
66
+ All write operations require confirmation before they execute.
67
+
68
+ ## HTTP routes
69
+
70
+ The plugin registers three routes on the agent's server for PAT management:
71
+
72
+ | Method | Path | Description |
73
+ |---|---|---|
74
+ | `GET` | `/api/github/token` | Returns connection status (token never exposed) |
75
+ | `POST` | `/api/github/token` | Save a PAT (validated against GitHub `/user` before save) |
76
+ | `DELETE` | `/api/github/token` | Remove the saved PAT |
77
+
78
+ ## Development
79
+
80
+ ```bash
81
+ bun run --cwd plugins/plugin-github build
82
+ bun run --cwd plugins/plugin-github test
83
+ bun run --cwd plugins/plugin-github typecheck
84
+ ```
85
+
86
+ See [CLAUDE.md](CLAUDE.md) for agent-facing layout and extension guide.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-github",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.3-beta.2",
4
4
  "description": "GitHub integration plugin for elizaOS agents — PRs, issues, notifications via the GitHub REST API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -8,8 +8,24 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
+ "eliza-source": {
12
+ "types": "./src/index.ts",
13
+ "import": "./src/index.ts",
14
+ "default": "./src/index.ts"
15
+ },
11
16
  "import": "./dist/index.js",
12
17
  "default": "./dist/index.js"
18
+ },
19
+ "./*.css": "./dist/*.css",
20
+ "./*": {
21
+ "types": "./dist/*.d.ts",
22
+ "eliza-source": {
23
+ "types": "./src/*.ts",
24
+ "import": "./src/*.ts",
25
+ "default": "./src/*.ts"
26
+ },
27
+ "import": "./dist/*.js",
28
+ "default": "./dist/*.js"
13
29
  }
14
30
  },
15
31
  "files": [
@@ -18,23 +34,24 @@
18
34
  "scripts": {
19
35
  "build": "tsup src/index.ts src/register-routes.ts --format esm --dts --clean",
20
36
  "test": "vitest run",
21
- "typecheck": "tsc --noEmit",
37
+ "typecheck": "tsgo --noEmit",
22
38
  "clean": "rm -rf dist .turbo"
23
39
  },
24
40
  "dependencies": {
25
- "@elizaos/core": "2.0.0-beta.1",
41
+ "@elizaos/core": "2.0.3-beta.2",
26
42
  "@octokit/rest": "^22.0.0"
27
43
  },
28
44
  "peerDependencies": {
29
- "@elizaos/core": "2.0.0-beta.1"
45
+ "@elizaos/core": "2.0.3-beta.2"
30
46
  },
31
47
  "devDependencies": {
32
48
  "@types/node": "24.12.2",
33
49
  "tsup": "8.5.1",
34
50
  "typescript": "^6.0.3",
35
- "vitest": "4.1.5"
51
+ "vitest": "4.1.9"
36
52
  },
37
53
  "publishConfig": {
38
54
  "access": "public"
39
- }
55
+ },
56
+ "gitHead": "82fe0f44215954c2417328203f5bd6510985c1fc"
40
57
  }
@@ -1,6 +0,0 @@
1
- // src/register-routes.ts
2
- import { registerAppRoutePluginLoader } from "@elizaos/core";
3
- registerAppRoutePluginLoader("@elizaos/plugin-github", async () => {
4
- const { githubPlugin } = await import("./index.js");
5
- return githubPlugin;
6
- });
package/dist/index.d.ts DELETED
@@ -1,294 +0,0 @@
1
- import { Action, IAgentRuntime, ConnectorAccountProvider, Service, Plugin } from '@elizaos/core';
2
- import { Octokit } from '@octokit/rest';
3
-
4
- /**
5
- * @module issue-op
6
- * @description Single router action covering GitHub issue lifecycle ops:
7
- * create, assign, close, reopen, comment, label. Replaces the old
8
- * CREATE_ISSUE / ASSIGN_ISSUE actions and absorbs the issue-management ops
9
- * previously implemented in plugin-agent-orchestrator's MANAGE_ISSUES.
10
- *
11
- * All ops are write ops gated on `confirmed: true`.
12
- */
13
-
14
- declare const issueOpAction: Action;
15
-
16
- declare const githubAction: Action;
17
-
18
- /**
19
- * @module notification-triage
20
- * @description Fetches unread GitHub notifications and returns them sorted
21
- * by a composite priority score derived from `reason`, subject type, and
22
- * the notifying repo's `pushed_at` freshness.
23
- *
24
- * Read-only — no confirmation gate.
25
- */
26
-
27
- interface TriagedNotification {
28
- id: string;
29
- reason: string;
30
- repo: string;
31
- title: string;
32
- subjectType: string;
33
- url: string | null;
34
- updatedAt: string;
35
- score: number;
36
- }
37
- declare function scoreNotification(params: {
38
- reason: string;
39
- subjectType: string;
40
- repoPushedAtMs: number | null;
41
- nowMs: number;
42
- }): number;
43
-
44
- declare const notificationTriageAction: Action;
45
-
46
- /**
47
- * @module pr-op
48
- * @description Single router action covering GitHub pull request ops:
49
- * list and review.
50
- */
51
-
52
- declare const prOpAction: Action;
53
-
54
- /**
55
- * @module types
56
- * @description Shared types for the GitHub plugin
57
- */
58
-
59
- type OctokitEndpoint<T, Data> = T extends (...args: infer Args) => unknown ? (...args: Args) => Promise<{
60
- data: Data;
61
- }> : never;
62
- /**
63
- * Identifies which configured token (user-acting or agent-acting) an action
64
- * should execute under. The plugin loads two independent PATs so the user
65
- * and agent personas can act separately on the same repo.
66
- */
67
- type GitHubIdentity = "user" | "agent";
68
- type GitHubUserSummary = {
69
- login?: string | null;
70
- };
71
- type GitHubPullRequestSummary = {
72
- number: number;
73
- title: string;
74
- state: string;
75
- html_url: string;
76
- user?: GitHubUserSummary | null;
77
- };
78
- type GitHubSearchIssueSummary = {
79
- repository_url: string;
80
- number: number;
81
- title: string;
82
- state: string;
83
- html_url: string;
84
- user?: GitHubUserSummary | null;
85
- };
86
- type GitHubReviewResult = {
87
- id: number;
88
- };
89
- type GitHubIssueResult = {
90
- number: number;
91
- html_url: string;
92
- };
93
- type GitHubAssigneesResult = {
94
- assignees?: Array<GitHubUserSummary | null> | null;
95
- };
96
- type GitHubLabelSummary = string | {
97
- name?: string | null;
98
- };
99
- type GitHubIssueDetail = {
100
- number: number;
101
- title: string;
102
- state: string;
103
- html_url: string;
104
- body?: string | null;
105
- labels?: Array<GitHubLabelSummary | null> | null;
106
- user?: GitHubUserSummary | null;
107
- };
108
- type GitHubIssueCommentResult = {
109
- id: number;
110
- html_url: string;
111
- };
112
- type GitHubAddLabelsResult = Array<GitHubLabelSummary | null>;
113
- type GitHubNotificationSummary = {
114
- id: string;
115
- reason?: string | null;
116
- repository?: {
117
- full_name?: string | null;
118
- pushed_at?: string | null;
119
- };
120
- subject?: {
121
- title?: string | null;
122
- type?: string | null;
123
- url?: string | null;
124
- };
125
- updated_at: string;
126
- };
127
- /**
128
- * Narrow Octokit surface used by this plugin's actions. Keeping the service
129
- * contract structural makes tests and local API mocks straightforward without
130
- * depending on the full Octokit class shape.
131
- */
132
- interface GitHubOctokitClient {
133
- activity: {
134
- listNotificationsForAuthenticatedUser: OctokitEndpoint<Octokit["activity"]["listNotificationsForAuthenticatedUser"], GitHubNotificationSummary[]>;
135
- };
136
- issues: {
137
- addAssignees: OctokitEndpoint<Octokit["issues"]["addAssignees"], GitHubAssigneesResult>;
138
- addLabels: OctokitEndpoint<Octokit["issues"]["addLabels"], GitHubAddLabelsResult>;
139
- create: OctokitEndpoint<Octokit["issues"]["create"], GitHubIssueResult>;
140
- createComment: OctokitEndpoint<Octokit["issues"]["createComment"], GitHubIssueCommentResult>;
141
- get: OctokitEndpoint<Octokit["issues"]["get"], GitHubIssueDetail>;
142
- listForRepo: OctokitEndpoint<Octokit["issues"]["listForRepo"], GitHubIssueDetail[]>;
143
- update: OctokitEndpoint<Octokit["issues"]["update"], GitHubIssueDetail>;
144
- };
145
- pulls: {
146
- createReview: OctokitEndpoint<Octokit["pulls"]["createReview"], GitHubReviewResult>;
147
- list: OctokitEndpoint<Octokit["pulls"]["list"], GitHubPullRequestSummary[]>;
148
- };
149
- search: {
150
- issuesAndPullRequests: OctokitEndpoint<Octokit["search"]["issuesAndPullRequests"], {
151
- items: GitHubSearchIssueSummary[];
152
- }>;
153
- };
154
- }
155
- /**
156
- * Service contract exposed to actions. Actions resolve their Octokit client
157
- * via this interface and never read environment variables directly.
158
- */
159
- interface IGitHubService {
160
- getOctokit(selector: GitHubIdentity | {
161
- as?: GitHubIdentity;
162
- role?: GitHubIdentity;
163
- accountId?: string;
164
- }): GitHubOctokitClient | null;
165
- }
166
- declare const GITHUB_SERVICE_TYPE = "github";
167
- declare const GitHubActions: {
168
- readonly GITHUB_ISSUE_OP: "GITHUB_ISSUE";
169
- readonly GITHUB_PR_OP: "GITHUB_PR";
170
- readonly GITHUB_NOTIFICATION_TRIAGE: "GITHUB_NOTIFICATION_TRIAGE";
171
- };
172
- /** Issue ops accepted by GITHUB_ISSUE_OP. */
173
- type GitHubIssueOp = "create" | "assign" | "close" | "reopen" | "comment" | "label";
174
- /** PR ops accepted by GITHUB_PR_OP. */
175
- type GitHubPrOp = "list" | "review";
176
- /**
177
- * Structured result returned by action handlers. Actions never throw —
178
- * recoverable problems are surfaced as `{ success: false }` with a reason,
179
- * and destructive actions surface a confirmation request distinctly.
180
- */
181
- type GitHubActionResult<T = unknown> = {
182
- success: true;
183
- data: T;
184
- } | {
185
- success: false;
186
- error: string;
187
- } | {
188
- success: false;
189
- requiresConfirmation: true;
190
- preview: string;
191
- };
192
- interface RateLimitError {
193
- kind: "rate-limit";
194
- resetAtMs: number | null;
195
- message: string;
196
- }
197
- /** Parameters shared by every action invocation. */
198
- interface BaseActionOptions {
199
- as?: GitHubIdentity;
200
- accountId?: string;
201
- confirmed?: boolean;
202
- }
203
-
204
- declare const DEFAULT_GITHUB_USER_ACCOUNT_ID = "user";
205
- declare const DEFAULT_GITHUB_AGENT_ACCOUNT_ID = "agent";
206
- interface GitHubAccountConfig {
207
- accountId: string;
208
- role: GitHubIdentity;
209
- token: string;
210
- label?: string;
211
- }
212
- interface GitHubAccountSelection {
213
- accountId?: string;
214
- role: GitHubIdentity;
215
- }
216
- declare function defaultGitHubAccountIdForRole(role: GitHubIdentity): string;
217
- declare function normalizeGitHubAccountId(value: unknown): string | undefined;
218
- declare function resolveGitHubAccountSelection(options: Record<string, unknown> | undefined, defaultRole: GitHubIdentity): GitHubAccountSelection;
219
- declare function readGitHubAccounts(runtime: IAgentRuntime): GitHubAccountConfig[];
220
- declare function readGitHubAccountsWithConnectorCredentials(runtime: IAgentRuntime): Promise<GitHubAccountConfig[]>;
221
- declare function resolveGitHubAccount(accounts: readonly GitHubAccountConfig[], selection: GitHubAccountSelection): GitHubAccountConfig | null;
222
-
223
- /**
224
- * GitHub ConnectorAccountManager provider.
225
- *
226
- * Bridges plugin-github to the @elizaos/core ConnectorAccountManager so the
227
- * generic HTTP CRUD + OAuth surface can list, create, patch, delete, and run
228
- * the OAuth flow for GitHub accounts. PATs remain supported as a legacy code
229
- * path; OAuth-app installations are exposed via startOAuth/completeOAuth.
230
- *
231
- * Account model:
232
- * - role "OWNER" — the user persona acting on their own behalf (legacy GITHUB_USER_PAT)
233
- * - role "AGENT" — the agent persona acting on its own behalf (legacy GITHUB_AGENT_PAT)
234
- * accountKey = GitHub username (login).
235
- */
236
-
237
- /**
238
- * Build the GitHub ConnectorAccountManager provider.
239
- */
240
- declare function createGitHubConnectorAccountProvider(runtime: IAgentRuntime): ConnectorAccountProvider;
241
-
242
- /**
243
- * @module github-service
244
- * @description Service that owns GitHub REST clients for the plugin.
245
- *
246
- * Role-tagged account records are supported, with the legacy user/agent PAT
247
- * split preserved as the default account set. Actions request an Octokit
248
- * client by role and optionally by accountId; the service returns `null` when
249
- * the requested account has no token configured.
250
- */
251
-
252
- declare class GitHubService extends Service implements IGitHubService {
253
- private readonly createClient;
254
- static serviceType: string;
255
- capabilityDescription: string;
256
- private clients;
257
- constructor(runtime?: IAgentRuntime, createClient?: (auth: string) => GitHubOctokitClient);
258
- static start(runtime: IAgentRuntime, createClient?: (auth: string) => GitHubOctokitClient): Promise<Service>;
259
- private initialize;
260
- getOctokit(selector: GitHubIdentity | {
261
- as?: GitHubIdentity;
262
- role?: GitHubIdentity;
263
- accountId?: string;
264
- }): GitHubOctokitClient | null;
265
- /**
266
- * Allows tests to inject an Octokit-shaped mock without going through
267
- * environment variables. Not part of the public runtime contract.
268
- */
269
- setClientForTesting(as: GitHubIdentity, client: GitHubOctokitClient | null, accountId?: string): void;
270
- stop(): Promise<void>;
271
- }
272
-
273
- /**
274
- * @module plugin-github
275
- * @description elizaOS plugin for GitHub integration.
276
- *
277
- * Actions:
278
- * - GITHUB (PR, issue, and notification operations)
279
- *
280
- * Auth: role-tagged account records with legacy PAT fallback.
281
- * - GITHUB_ACCOUNTS — JSON account records ({accountId, role, token})
282
- * - GITHUB_USER_PAT — legacy user acting on their own behalf
283
- * - GITHUB_AGENT_PAT — legacy agent acting on its own behalf
284
- * E2E fallbacks: ELIZA_E2E_GITHUB_USER_PAT / ELIZA_E2E_GITHUB_AGENT_PAT.
285
- *
286
- * Each action takes an `as: "user" | "agent"` option and may take accountId
287
- * to select a specific account. GITHUB_PR_OP review and
288
- * GITHUB_NOTIFICATION_TRIAGE default to `"user"`; the other ops default to
289
- * `"agent"`.
290
- */
291
-
292
- declare const githubPlugin: Plugin;
293
-
294
- export { type BaseActionOptions, DEFAULT_GITHUB_AGENT_ACCOUNT_ID, DEFAULT_GITHUB_USER_ACCOUNT_ID, GITHUB_SERVICE_TYPE, type GitHubAccountConfig, type GitHubAccountSelection, type GitHubActionResult, GitHubActions, type GitHubIdentity, type GitHubIssueOp, type GitHubOctokitClient, type GitHubPrOp, GitHubService, type IGitHubService, type RateLimitError, type TriagedNotification, createGitHubConnectorAccountProvider, githubPlugin as default, defaultGitHubAccountIdForRole, githubAction, githubPlugin, issueOpAction, normalizeGitHubAccountId, notificationTriageAction, prOpAction, readGitHubAccounts, readGitHubAccountsWithConnectorCredentials, resolveGitHubAccount, resolveGitHubAccountSelection, scoreNotification };