@elizaos/plugin-github 1.2.0 → 1.2.9

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/index.d.ts CHANGED
@@ -1,9 +1,563 @@
1
- import type { Plugin } from '@elizaos/core';
2
- import { type Action, type Provider } from '@elizaos/core';
3
- import { GitHubService } from './services/github';
1
+ import { Service, IAgentRuntime, Action, Provider, Plugin } from '@elizaos/core';
2
+ import { z } from 'zod';
3
+
4
+ interface GitHubActivityItem$1 {
5
+ id: string;
6
+ timestamp: string;
7
+ action: string;
8
+ resource_type: "repository" | "issue" | "pr" | "user";
9
+ resource_id: string;
10
+ details: Record<string, any>;
11
+ success: boolean;
12
+ error?: string;
13
+ }
14
+ declare class GitHubService extends Service {
15
+ static serviceType: string;
16
+ capabilityDescription: string;
17
+ private octokit;
18
+ private rateLimitRemaining;
19
+ private rateLimitReset;
20
+ private activityLog;
21
+ private githubConfig;
22
+ constructor(runtime?: IAgentRuntime);
23
+ static start(runtime: IAgentRuntime): Promise<GitHubService>;
24
+ stop(): Promise<void>;
25
+ /**
26
+ * Validate authentication by checking user permissions
27
+ */
28
+ validateAuthentication(): Promise<boolean>;
29
+ /**
30
+ * Rate limiting helper to prevent hitting GitHub API limits
31
+ */
32
+ private checkRateLimit;
33
+ /**
34
+ * Update rate limit info from response headers
35
+ */
36
+ private updateRateLimit;
37
+ /**
38
+ * Sanitize error for logging (remove sensitive data)
39
+ */
40
+ private sanitizeError;
41
+ /**
42
+ * Validate GitHub username/repo name format
43
+ */
44
+ private validateGitHubName;
45
+ /**
46
+ * Get authenticated user information
47
+ */
48
+ getAuthenticatedUser(): Promise<any>;
49
+ /**
50
+ * Get user by username
51
+ */
52
+ getUserByUsername(username: string): Promise<any>;
53
+ /**
54
+ * Get repository information
55
+ */
56
+ getRepository(owner: string, repo: string): Promise<any>;
57
+ /**
58
+ * List repositories for authenticated user
59
+ */
60
+ getRepositories(options?: {
61
+ visibility?: "all" | "public" | "private";
62
+ affiliation?: "owner" | "collaborator" | "organization_member";
63
+ type?: "all" | "owner" | "public" | "private" | "member";
64
+ sort?: "created" | "updated" | "pushed" | "full_name";
65
+ direction?: "asc" | "desc";
66
+ per_page?: number;
67
+ }): Promise<any>;
68
+ /**
69
+ * Get repository issues
70
+ */
71
+ getRepositoryIssues(owner: string, repo: string, options?: {
72
+ milestone?: string | number;
73
+ state?: "open" | "closed" | "all";
74
+ assignee?: string;
75
+ creator?: string;
76
+ mentioned?: string;
77
+ labels?: string;
78
+ sort?: "created" | "updated" | "comments";
79
+ direction?: "asc" | "desc";
80
+ since?: string;
81
+ per_page?: number;
82
+ }): Promise<any>;
83
+ /**
84
+ * Get specific issue
85
+ */
86
+ getIssue(owner: string, repo: string, issue_number: number): Promise<any>;
87
+ /**
88
+ * Create issue comment
89
+ */
90
+ createIssueComment(owner: string, repo: string, issue_number: number, body: string): Promise<any>;
91
+ /**
92
+ * Get issue comments
93
+ */
94
+ getIssueComments(owner: string, repo: string, issue_number: number, options?: {
95
+ since?: string;
96
+ per_page?: number;
97
+ }): Promise<any>;
98
+ /**
99
+ * Get repository pull requests
100
+ */
101
+ getRepositoryPullRequests(owner: string, repo: string, options?: {
102
+ state?: "open" | "closed" | "all";
103
+ head?: string;
104
+ base?: string;
105
+ sort?: "created" | "updated" | "popularity";
106
+ direction?: "asc" | "desc";
107
+ per_page?: number;
108
+ }): Promise<any>;
109
+ /**
110
+ * Get specific pull request
111
+ */
112
+ getPullRequest(owner: string, repo: string, pull_number: number): Promise<any>;
113
+ /**
114
+ * Create pull request
115
+ */
116
+ createPullRequest(owner: string, repo: string, options: {
117
+ title: string;
118
+ head: string;
119
+ base: string;
120
+ body?: string;
121
+ maintainer_can_modify?: boolean;
122
+ draft?: boolean;
123
+ }): Promise<any>;
124
+ /**
125
+ * Create or update file
126
+ */
127
+ createOrUpdateFile(owner: string, repo: string, path: string, content: string, message: string, branch?: string, sha?: string): Promise<any>;
128
+ /**
129
+ * Get file content
130
+ */
131
+ getFileContent(owner: string, repo: string, path: string, ref?: string): Promise<{
132
+ content: string;
133
+ sha: string;
134
+ }>;
135
+ /**
136
+ * Delete file
137
+ */
138
+ deleteFile(owner: string, repo: string, path: string, message: string, sha: string, branch?: string): Promise<any>;
139
+ /**
140
+ * Get repository tree
141
+ */
142
+ getRepositoryTree(owner: string, repo: string, tree_sha?: string): Promise<any[]>;
143
+ /**
144
+ * Get default branch
145
+ */
146
+ getDefaultBranch(owner: string, repo: string): Promise<string>;
147
+ /**
148
+ * Create webhook
149
+ */
150
+ createWebhook(owner: string, repo: string, config: {
151
+ url: string;
152
+ content_type?: "json" | "form";
153
+ secret?: string;
154
+ insecure_ssl?: string;
155
+ }, events?: string[]): Promise<any>;
156
+ /**
157
+ * List webhooks
158
+ */
159
+ listWebhooks(owner: string, repo: string): Promise<any[]>;
160
+ /**
161
+ * Delete webhook
162
+ */
163
+ deleteWebhook(owner: string, repo: string, hook_id: number): Promise<void>;
164
+ /**
165
+ * Ping webhook
166
+ */
167
+ pingWebhook(owner: string, repo: string, hook_id: number): Promise<void>;
168
+ /**
169
+ * Get activity log for debugging and monitoring
170
+ */
171
+ getActivityLog(limit?: number): GitHubActivityItem$1[];
172
+ /**
173
+ * Clear activity log
174
+ */
175
+ clearActivityLog(): void;
176
+ /**
177
+ * Get rate limit status
178
+ */
179
+ getRateLimitStatus(): {
180
+ remaining: number;
181
+ reset: number;
182
+ limit: number;
183
+ used: number;
184
+ resource: string;
185
+ };
186
+ /**
187
+ * Get rate limit (alias for compatibility)
188
+ */
189
+ getRateLimit(): {
190
+ remaining: number;
191
+ reset: number;
192
+ limit: number;
193
+ used: number;
194
+ resource: string;
195
+ };
196
+ /**
197
+ * Get current authenticated user (alias for compatibility)
198
+ */
199
+ getCurrentUser(): Promise<any>;
200
+ /**
201
+ * Get Git reference
202
+ */
203
+ getRef(owner: string, repo: string, ref: string): Promise<any>;
204
+ /**
205
+ * Create a new branch
206
+ */
207
+ createBranch(owner: string, repo: string, branchName: string, sha: string): Promise<any>;
208
+ /**
209
+ * List branches
210
+ */
211
+ listBranches(owner: string, repo: string): Promise<any[]>;
212
+ /**
213
+ * Get branch details
214
+ */
215
+ getBranch(owner: string, repo: string, branch: string): Promise<any>;
216
+ /**
217
+ * Delete a branch
218
+ */
219
+ deleteBranch(owner: string, repo: string, branch: string): Promise<void>;
220
+ /**
221
+ * Compare two branches
222
+ */
223
+ compareBranches(owner: string, repo: string, base: string, head: string): Promise<any>;
224
+ /**
225
+ * Get branch protection settings
226
+ */
227
+ getBranchProtection(owner: string, repo: string, branch: string): Promise<any>;
228
+ /**
229
+ * List issues
230
+ */
231
+ listIssues(owner: string, repo: string, options?: any): Promise<any>;
232
+ /**
233
+ * Create issue
234
+ */
235
+ createIssue(owner: string, repo: string, options: {
236
+ title: string;
237
+ body?: string;
238
+ assignees?: string[];
239
+ milestone?: number;
240
+ labels?: string[];
241
+ }): Promise<any>;
242
+ /**
243
+ * Search issues
244
+ */
245
+ searchIssues(query: string, options?: any): Promise<any>;
246
+ /**
247
+ * Search pull requests
248
+ */
249
+ searchPullRequests(query: string, options?: any): Promise<any>;
250
+ /**
251
+ * List pull requests
252
+ */
253
+ listPullRequests(owner: string, repo: string, options?: any): Promise<any>;
254
+ /**
255
+ * Merge pull request
256
+ */
257
+ mergePullRequest(owner: string, repo: string, pull_number: number, options?: {
258
+ commit_title?: string;
259
+ commit_message?: string;
260
+ merge_method?: "merge" | "squash" | "rebase";
261
+ }): Promise<any>;
262
+ /**
263
+ * List repositories
264
+ */
265
+ listRepositories(options?: any): Promise<any>;
266
+ /**
267
+ * Create repository
268
+ */
269
+ createRepository(options: {
270
+ name: string;
271
+ description?: string;
272
+ private?: boolean;
273
+ auto_init?: boolean;
274
+ gitignore_template?: string;
275
+ license_template?: string;
276
+ }): Promise<any>;
277
+ /**
278
+ * Search repositories
279
+ */
280
+ searchRepositories(query: string, options?: any): Promise<any>;
281
+ /**
282
+ * Get contributors stats
283
+ */
284
+ getContributorsStats(owner: string, repo: string): Promise<any>;
285
+ /**
286
+ * Get commit activity stats
287
+ */
288
+ getCommitActivityStats(owner: string, repo: string): Promise<any>;
289
+ /**
290
+ * Get code frequency stats
291
+ */
292
+ getCodeFrequencyStats(owner: string, repo: string): Promise<any>;
293
+ /**
294
+ * Get repository languages
295
+ */
296
+ getLanguages(owner: string, repo: string): Promise<any>;
297
+ /**
298
+ * Get traffic views
299
+ */
300
+ getTrafficViews(owner: string, repo: string): Promise<any>;
301
+ /**
302
+ * Get traffic clones
303
+ */
304
+ getTrafficClones(owner: string, repo: string): Promise<any>;
305
+ /**
306
+ * Get top paths
307
+ */
308
+ getTopPaths(owner: string, repo: string): Promise<any>;
309
+ /**
310
+ * Get top referrers
311
+ */
312
+ getTopReferrers(owner: string, repo: string): Promise<any>;
313
+ /**
314
+ * Get user information
315
+ */
316
+ getUser(username: string): Promise<any>;
317
+ /**
318
+ * List user repositories
319
+ */
320
+ listUserRepositories(username: string, options?: any): Promise<any>;
321
+ /**
322
+ * List user events
323
+ */
324
+ listUserEvents(username: string, options?: any): Promise<any>;
325
+ private logActivity;
326
+ private handleError;
327
+ }
328
+
329
+ declare const githubConfigSchema: z.ZodObject<{
330
+ GITHUB_TOKEN: z.ZodString;
331
+ GITHUB_OWNER: z.ZodOptional<z.ZodString>;
332
+ GITHUB_WEBHOOK_SECRET: z.ZodOptional<z.ZodString>;
333
+ }, z.core.$strip>;
334
+ declare const githubConfigSchemaFlexible: z.ZodObject<{
335
+ GITHUB_TOKEN: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>>>;
336
+ GITHUB_OWNER: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>>>;
337
+ GITHUB_WEBHOOK_SECRET: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>>>;
338
+ }, z.core.$strip>;
339
+ type GitHubConfig = z.infer<typeof githubConfigSchema>;
340
+ interface GitHubRepository {
341
+ id: number;
342
+ name: string;
343
+ full_name: string;
344
+ description: string | null;
345
+ html_url: string;
346
+ clone_url: string;
347
+ ssh_url: string;
348
+ private: boolean;
349
+ fork: boolean;
350
+ archived: boolean;
351
+ disabled: boolean;
352
+ created_at: string;
353
+ updated_at: string;
354
+ pushed_at: string;
355
+ size: number;
356
+ stargazers_count: number;
357
+ watchers_count: number;
358
+ forks_count: number;
359
+ open_issues_count: number;
360
+ language: string | null;
361
+ topics: string[];
362
+ license: {
363
+ key: string;
364
+ name: string;
365
+ spdx_id: string;
366
+ } | null;
367
+ default_branch: string;
368
+ owner: {
369
+ login: string;
370
+ id: number;
371
+ type: "User" | "Organization";
372
+ avatar_url: string;
373
+ };
374
+ }
375
+ interface GitHubIssue {
376
+ id: number;
377
+ number: number;
378
+ title: string;
379
+ body: string | null;
380
+ state: "open" | "closed";
381
+ labels: Array<{
382
+ id: number;
383
+ name: string;
384
+ color: string;
385
+ description: string | null;
386
+ }>;
387
+ assignees: Array<{
388
+ login: string;
389
+ id: number;
390
+ avatar_url: string;
391
+ }>;
392
+ user: {
393
+ login: string;
394
+ id: number;
395
+ avatar_url: string;
396
+ };
397
+ created_at: string;
398
+ updated_at: string;
399
+ closed_at: string | null;
400
+ html_url: string;
401
+ comments: number;
402
+ milestone: {
403
+ id: number;
404
+ title: string;
405
+ description: string | null;
406
+ state: "open" | "closed";
407
+ due_on: string | null;
408
+ } | null;
409
+ }
410
+ interface GitHubPullRequest {
411
+ id: number;
412
+ number: number;
413
+ title: string;
414
+ body: string | null;
415
+ state: "open" | "closed" | "merged";
416
+ draft: boolean;
417
+ merged: boolean;
418
+ mergeable: boolean | null;
419
+ merged_at: string | null;
420
+ head: {
421
+ ref: string;
422
+ sha: string;
423
+ repo: GitHubRepository | null;
424
+ };
425
+ base: {
426
+ ref: string;
427
+ sha: string;
428
+ repo: GitHubRepository;
429
+ };
430
+ user: {
431
+ login: string;
432
+ id: number;
433
+ avatar_url: string;
434
+ };
435
+ assignees: Array<{
436
+ login: string;
437
+ id: number;
438
+ avatar_url: string;
439
+ }>;
440
+ labels: Array<{
441
+ id: number;
442
+ name: string;
443
+ color: string;
444
+ description: string | null;
445
+ }>;
446
+ created_at: string;
447
+ updated_at: string;
448
+ html_url: string;
449
+ comments: number;
450
+ commits: number;
451
+ additions: number;
452
+ deletions: number;
453
+ changed_files: number;
454
+ }
455
+ interface CreateRepositoryOptions {
456
+ name: string;
457
+ description?: string;
458
+ private?: boolean;
459
+ auto_init?: boolean;
460
+ gitignore_template?: string;
461
+ license_template?: string;
462
+ allow_squash_merge?: boolean;
463
+ allow_merge_commit?: boolean;
464
+ allow_rebase_merge?: boolean;
465
+ delete_branch_on_merge?: boolean;
466
+ has_issues?: boolean;
467
+ has_projects?: boolean;
468
+ has_wiki?: boolean;
469
+ has_downloads?: boolean;
470
+ homepage?: string;
471
+ topics?: string[];
472
+ }
473
+ interface CreateIssueOptions {
474
+ title: string;
475
+ body?: string;
476
+ assignees?: string[];
477
+ milestone?: number;
478
+ labels?: string[];
479
+ }
480
+ interface CreatePullRequestOptions {
481
+ title: string;
482
+ head: string;
483
+ base: string;
484
+ body?: string;
485
+ draft?: boolean;
486
+ maintainer_can_modify?: boolean;
487
+ }
488
+ interface GitHubActivityItem {
489
+ id: string;
490
+ timestamp: string;
491
+ action: string;
492
+ resource_type: "repository" | "issue" | "pull_request";
493
+ resource_id: string;
494
+ details: Record<string, any>;
495
+ success: boolean;
496
+ error?: string;
497
+ }
498
+ interface GitHubSearchResult<T> {
499
+ total_count: number;
500
+ incomplete_results: boolean;
501
+ items: T[];
502
+ }
503
+ interface GitHubWebhookPayload {
504
+ action: string;
505
+ repository?: GitHubRepository;
506
+ issue?: GitHubIssue;
507
+ pull_request?: GitHubPullRequest;
508
+ sender: {
509
+ login: string;
510
+ id: number;
511
+ avatar_url: string;
512
+ };
513
+ }
514
+ interface GitHubRateLimit {
515
+ limit: number;
516
+ remaining: number;
517
+ reset: number;
518
+ used: number;
519
+ resource: string;
520
+ }
521
+ declare class GitHubAPIError extends Error {
522
+ status: number;
523
+ response?: any | undefined;
524
+ constructor(message: string, status: number, response?: any | undefined);
525
+ }
526
+ declare class GitHubAuthenticationError extends GitHubAPIError {
527
+ constructor(message?: string);
528
+ }
529
+ declare class GitHubRateLimitError extends GitHubAPIError {
530
+ resetTime: number;
531
+ constructor(message: string | undefined, resetTime: number);
532
+ }
533
+ declare const createRepositorySchema: z.ZodObject<{
534
+ name: z.ZodString;
535
+ description: z.ZodOptional<z.ZodString>;
536
+ private: z.ZodDefault<z.ZodBoolean>;
537
+ auto_init: z.ZodDefault<z.ZodBoolean>;
538
+ gitignore_template: z.ZodOptional<z.ZodString>;
539
+ license_template: z.ZodOptional<z.ZodString>;
540
+ homepage: z.ZodOptional<z.ZodString>;
541
+ topics: z.ZodOptional<z.ZodArray<z.ZodString>>;
542
+ }, z.core.$strip>;
543
+ declare const createIssueSchema: z.ZodObject<{
544
+ title: z.ZodString;
545
+ body: z.ZodOptional<z.ZodString>;
546
+ assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
547
+ labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
548
+ milestone: z.ZodOptional<z.ZodNumber>;
549
+ }, z.core.$strip>;
550
+ declare const createPullRequestSchema: z.ZodObject<{
551
+ title: z.ZodString;
552
+ head: z.ZodString;
553
+ base: z.ZodString;
554
+ body: z.ZodOptional<z.ZodString>;
555
+ draft: z.ZodDefault<z.ZodBoolean>;
556
+ maintainer_can_modify: z.ZodDefault<z.ZodBoolean>;
557
+ }, z.core.$strip>;
558
+
4
559
  declare const githubActions: Action[];
5
560
  declare const githubProviders: Provider[];
6
- export declare const githubPlugin: Plugin;
7
- export { GitHubService, githubActions, githubProviders };
8
- export * from './types';
9
- export default githubPlugin;
561
+ declare const githubPlugin: Plugin;
562
+
563
+ export { type CreateIssueOptions, type CreatePullRequestOptions, type CreateRepositoryOptions, GitHubAPIError, type GitHubActivityItem, GitHubAuthenticationError, type GitHubConfig, type GitHubIssue, type GitHubPullRequest, type GitHubRateLimit, GitHubRateLimitError, type GitHubRepository, type GitHubSearchResult, GitHubService, type GitHubWebhookPayload, createIssueSchema, createPullRequestSchema, createRepositorySchema, githubPlugin as default, githubActions, githubConfigSchema, githubConfigSchemaFlexible, githubPlugin, githubProviders };