@github-tools/sdk 1.2.0 → 1.4.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.
@@ -0,0 +1,727 @@
1
+ import { n as createGithubAgent, t as CreateGithubAgentOptions } from "./agents-C6nqZiYp.mjs";
2
+ import { ApprovalConfig, GithubToolPreset, GithubTools, GithubToolsOptions, GithubWriteToolName, createGithubTools } from "./index.mjs";
3
+ import * as ai from "ai";
4
+ import { CompatibleLanguageModel, DurableAgent } from "@workflow/ai/agent";
5
+
6
+ //#region src/workflow.d.ts
7
+ type CreateDurableGithubAgentOptions = {
8
+ model: string | CompatibleLanguageModel | (() => Promise<CompatibleLanguageModel>);
9
+ /**
10
+ * GitHub personal access token.
11
+ * Falls back to `process.env.GITHUB_TOKEN` when omitted.
12
+ */
13
+ token?: string;
14
+ preset?: GithubToolPreset | GithubToolPreset[];
15
+ requireApproval?: ApprovalConfig;
16
+ instructions?: string;
17
+ additionalInstructions?: string; /** Maximum number of LLM calls before stopping. Unlimited by default. */
18
+ maxSteps?: number;
19
+ temperature?: number;
20
+ };
21
+ /**
22
+ * Create a pre-configured durable GitHub agent powered by Vercel Workflow SDK's `DurableAgent`.
23
+ *
24
+ * Each tool call runs as a durable step with automatic retries and observability.
25
+ * Must be used inside a `"use workflow"` function.
26
+ *
27
+ * **Note:** `requireApproval` is accepted for forward-compatibility but is currently
28
+ * ignored by `DurableAgent` — the Workflow SDK does not yet support interactive tool
29
+ * approval. All tools execute immediately without user confirmation.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { createDurableGithubAgent } from '@github-tools/sdk/workflow'
34
+ * import { getWritable } from 'workflow'
35
+ * import type { ModelMessage, UIMessageChunk } from 'ai'
36
+ *
37
+ * async function chatWorkflow(messages: ModelMessage[], token: string) {
38
+ * "use workflow"
39
+ * const agent = createDurableGithubAgent({
40
+ * model: 'anthropic/claude-sonnet-4.6',
41
+ * token,
42
+ * preset: 'code-review',
43
+ * })
44
+ * const writable = getWritable<UIMessageChunk>()
45
+ * await agent.stream({ messages, writable })
46
+ * }
47
+ * ```
48
+ */
49
+ declare function createDurableGithubAgent({
50
+ model,
51
+ token,
52
+ preset,
53
+ requireApproval,
54
+ instructions,
55
+ additionalInstructions,
56
+ ...agentOptions
57
+ }: CreateDurableGithubAgentOptions): DurableAgent<Partial<{
58
+ getRepository: ai.Tool<{
59
+ owner: string;
60
+ repo: string;
61
+ }, {
62
+ name: string;
63
+ fullName: string;
64
+ description: string | null;
65
+ url: string;
66
+ defaultBranch: string;
67
+ stars: number;
68
+ forks: number;
69
+ openIssues: number;
70
+ language: string | null;
71
+ private: boolean;
72
+ createdAt: string;
73
+ updatedAt: string;
74
+ }>;
75
+ listBranches: ai.Tool<{
76
+ owner: string;
77
+ repo: string;
78
+ perPage: number;
79
+ }, {
80
+ name: string;
81
+ sha: string;
82
+ protected: boolean;
83
+ }[]>;
84
+ getFileContent: ai.Tool<{
85
+ owner: string;
86
+ repo: string;
87
+ path: string;
88
+ ref?: string | undefined;
89
+ }, {
90
+ type: string;
91
+ entries: {
92
+ name: string;
93
+ type: "file" | "dir" | "submodule" | "symlink";
94
+ path: string;
95
+ }[];
96
+ path?: undefined;
97
+ sha?: undefined;
98
+ size?: undefined;
99
+ content?: undefined;
100
+ } | {
101
+ type: "submodule" | "symlink";
102
+ path: string;
103
+ entries?: undefined;
104
+ sha?: undefined;
105
+ size?: undefined;
106
+ content?: undefined;
107
+ } | {
108
+ type: string;
109
+ path: string;
110
+ sha: string;
111
+ size: number;
112
+ content: string;
113
+ entries?: undefined;
114
+ }>;
115
+ listPullRequests: ai.Tool<{
116
+ owner: string;
117
+ repo: string;
118
+ state: "open" | "closed" | "all";
119
+ perPage: number;
120
+ }, {
121
+ number: number;
122
+ title: string;
123
+ state: string;
124
+ url: string;
125
+ author: string | undefined;
126
+ branch: string;
127
+ base: string;
128
+ draft: boolean | undefined;
129
+ createdAt: string;
130
+ updatedAt: string;
131
+ }[]>;
132
+ getPullRequest: ai.Tool<{
133
+ owner: string;
134
+ repo: string;
135
+ pullNumber: number;
136
+ }, {
137
+ number: number;
138
+ title: string;
139
+ body: string | null;
140
+ state: "open" | "closed";
141
+ url: string;
142
+ author: string;
143
+ branch: string;
144
+ base: string;
145
+ draft: boolean | undefined;
146
+ merged: boolean;
147
+ mergeable: boolean | null;
148
+ additions: number;
149
+ deletions: number;
150
+ changedFiles: number;
151
+ createdAt: string;
152
+ updatedAt: string;
153
+ mergedAt: string | null;
154
+ }>;
155
+ listIssues: ai.Tool<{
156
+ owner: string;
157
+ repo: string;
158
+ state: "open" | "closed" | "all";
159
+ perPage: number;
160
+ labels?: string | undefined;
161
+ }, {
162
+ number: number;
163
+ title: string;
164
+ state: string;
165
+ url: string;
166
+ author: string | undefined;
167
+ labels: (string | undefined)[];
168
+ createdAt: string;
169
+ updatedAt: string;
170
+ }[]>;
171
+ getIssue: ai.Tool<{
172
+ owner: string;
173
+ repo: string;
174
+ issueNumber: number;
175
+ }, {
176
+ number: number;
177
+ title: string;
178
+ body: string | null | undefined;
179
+ state: string;
180
+ url: string;
181
+ author: string | undefined;
182
+ assignees: string[] | undefined;
183
+ labels: (string | undefined)[];
184
+ comments: number;
185
+ createdAt: string;
186
+ updatedAt: string;
187
+ closedAt: string | null;
188
+ }>;
189
+ searchCode: ai.Tool<{
190
+ query: string;
191
+ perPage: number;
192
+ }, {
193
+ totalCount: number;
194
+ items: {
195
+ name: string;
196
+ path: string;
197
+ url: string;
198
+ repository: string;
199
+ sha: string;
200
+ }[];
201
+ }>;
202
+ searchRepositories: ai.Tool<{
203
+ query: string;
204
+ perPage: number;
205
+ order: "asc" | "desc";
206
+ sort?: "stars" | "forks" | "help-wanted-issues" | "updated" | undefined;
207
+ }, {
208
+ totalCount: number;
209
+ items: {
210
+ name: string;
211
+ fullName: string;
212
+ description: string | null;
213
+ url: string;
214
+ stars: number;
215
+ forks: number;
216
+ language: string | null;
217
+ topics: string[] | undefined;
218
+ }[];
219
+ }>;
220
+ listCommits: ai.Tool<{
221
+ owner: string;
222
+ repo: string;
223
+ perPage: number;
224
+ path?: string | undefined;
225
+ sha?: string | undefined;
226
+ author?: string | undefined;
227
+ since?: string | undefined;
228
+ until?: string | undefined;
229
+ }, {
230
+ sha: string;
231
+ message: string;
232
+ author: string | undefined;
233
+ authorLogin: string | undefined;
234
+ date: string | undefined;
235
+ url: string;
236
+ }[]>;
237
+ getCommit: ai.Tool<{
238
+ owner: string;
239
+ repo: string;
240
+ ref: string;
241
+ }, {
242
+ sha: string;
243
+ message: string;
244
+ author: string | undefined;
245
+ authorLogin: string | undefined;
246
+ date: string | undefined;
247
+ url: string;
248
+ stats: {
249
+ additions: number | undefined;
250
+ deletions: number | undefined;
251
+ total: number | undefined;
252
+ } | null;
253
+ files: {
254
+ filename: string;
255
+ status: "added" | "removed" | "modified" | "renamed" | "copied" | "changed" | "unchanged";
256
+ additions: number;
257
+ deletions: number;
258
+ patch: string | undefined;
259
+ }[] | undefined;
260
+ }>;
261
+ getBlame: ai.Tool<{
262
+ owner: string;
263
+ repo: string;
264
+ path: string;
265
+ ref?: string | undefined;
266
+ line?: number | undefined;
267
+ lineStart?: number | undefined;
268
+ lineEnd?: number | undefined;
269
+ }, {
270
+ error: string;
271
+ ref?: undefined;
272
+ tipSha?: undefined;
273
+ path?: undefined;
274
+ rangeCount?: undefined;
275
+ ranges?: undefined;
276
+ } | {
277
+ ref: string;
278
+ tipSha: string;
279
+ path: string;
280
+ rangeCount: number;
281
+ ranges: {
282
+ startingLine: number;
283
+ endingLine: number;
284
+ age: number;
285
+ commit: {
286
+ sha: string;
287
+ abbreviatedSha: string;
288
+ messageHeadline: string;
289
+ authoredDate: string;
290
+ url: string;
291
+ authorName: string | null;
292
+ authorEmail: string | null;
293
+ authorLogin: string | null;
294
+ };
295
+ }[];
296
+ error?: undefined;
297
+ }>;
298
+ createBranch: ai.Tool<{
299
+ owner: string;
300
+ repo: string;
301
+ branch: string;
302
+ from?: string | undefined;
303
+ }, {
304
+ ref: string;
305
+ sha: string;
306
+ url: string;
307
+ }>;
308
+ forkRepository: ai.Tool<{
309
+ owner: string;
310
+ repo: string;
311
+ organization?: string | undefined;
312
+ name?: string | undefined;
313
+ }, {
314
+ name: string;
315
+ fullName: string;
316
+ url: string;
317
+ cloneUrl: string;
318
+ sshUrl: string;
319
+ defaultBranch: string;
320
+ private: boolean;
321
+ parent: {
322
+ fullName: string;
323
+ url: string;
324
+ } | null;
325
+ }>;
326
+ createRepository: ai.Tool<{
327
+ name: string;
328
+ isPrivate: boolean;
329
+ autoInit: boolean;
330
+ description?: string | undefined;
331
+ gitignoreTemplate?: string | undefined;
332
+ licenseTemplate?: string | undefined;
333
+ org?: string | undefined;
334
+ }, {
335
+ name: string;
336
+ fullName: string;
337
+ description: string | null;
338
+ url: string;
339
+ cloneUrl: string;
340
+ sshUrl: string;
341
+ defaultBranch: string;
342
+ private: boolean;
343
+ createdAt: string;
344
+ }>;
345
+ createOrUpdateFile: ai.Tool<{
346
+ owner: string;
347
+ repo: string;
348
+ path: string;
349
+ message: string;
350
+ content: string;
351
+ branch?: string | undefined;
352
+ sha?: string | undefined;
353
+ }, {
354
+ path: string | undefined;
355
+ sha: string | undefined;
356
+ commitSha: string | undefined;
357
+ commitUrl: string | undefined;
358
+ }>;
359
+ createPullRequest: ai.Tool<{
360
+ owner: string;
361
+ repo: string;
362
+ title: string;
363
+ head: string;
364
+ base: string;
365
+ draft: boolean;
366
+ body?: string | undefined;
367
+ }, {
368
+ number: number;
369
+ title: string;
370
+ url: string;
371
+ state: "open" | "closed";
372
+ draft: boolean | undefined;
373
+ branch: string;
374
+ base: string;
375
+ }>;
376
+ mergePullRequest: ai.Tool<{
377
+ owner: string;
378
+ repo: string;
379
+ pullNumber: number;
380
+ mergeMethod: "merge" | "squash" | "rebase";
381
+ commitTitle?: string | undefined;
382
+ commitMessage?: string | undefined;
383
+ }, {
384
+ merged: boolean;
385
+ message: string;
386
+ sha: string;
387
+ }>;
388
+ addPullRequestComment: ai.Tool<{
389
+ owner: string;
390
+ repo: string;
391
+ pullNumber: number;
392
+ body: string;
393
+ }, {
394
+ id: number;
395
+ url: string;
396
+ body: string | undefined;
397
+ author: string | undefined;
398
+ createdAt: string;
399
+ }>;
400
+ listPullRequestFiles: ai.Tool<{
401
+ owner: string;
402
+ repo: string;
403
+ pullNumber: number;
404
+ perPage: number;
405
+ page: number;
406
+ }, {
407
+ filename: string;
408
+ status: "added" | "removed" | "modified" | "renamed" | "copied" | "changed" | "unchanged";
409
+ additions: number;
410
+ deletions: number;
411
+ changes: number;
412
+ patch: string | undefined;
413
+ }[]>;
414
+ listPullRequestReviews: ai.Tool<{
415
+ owner: string;
416
+ repo: string;
417
+ pullNumber: number;
418
+ perPage: number;
419
+ page: number;
420
+ }, {
421
+ id: number;
422
+ state: string;
423
+ body: string;
424
+ author: string | undefined;
425
+ url: string;
426
+ submittedAt: string | undefined;
427
+ }[]>;
428
+ createPullRequestReview: ai.Tool<{
429
+ owner: string;
430
+ repo: string;
431
+ pullNumber: number;
432
+ event: "APPROVE" | "REQUEST_CHANGES" | "COMMENT";
433
+ body?: string | undefined;
434
+ comments?: {
435
+ path: string;
436
+ body: string;
437
+ line?: number | undefined;
438
+ side?: "LEFT" | "RIGHT" | undefined;
439
+ }[] | undefined;
440
+ }, {
441
+ id: number;
442
+ state: string;
443
+ body: string;
444
+ url: string;
445
+ author: string | undefined;
446
+ submittedAt: string | undefined;
447
+ }>;
448
+ createIssue: ai.Tool<{
449
+ owner: string;
450
+ repo: string;
451
+ title: string;
452
+ body?: string | undefined;
453
+ labels?: string[] | undefined;
454
+ assignees?: string[] | undefined;
455
+ }, {
456
+ number: number;
457
+ title: string;
458
+ url: string;
459
+ state: string;
460
+ labels: (string | undefined)[];
461
+ }>;
462
+ addIssueComment: ai.Tool<{
463
+ owner: string;
464
+ repo: string;
465
+ issueNumber: number;
466
+ body: string;
467
+ }, {
468
+ id: number;
469
+ url: string;
470
+ body: string | undefined;
471
+ author: string | undefined;
472
+ createdAt: string;
473
+ }>;
474
+ closeIssue: ai.Tool<{
475
+ owner: string;
476
+ repo: string;
477
+ issueNumber: number;
478
+ stateReason: "completed" | "not_planned";
479
+ }, {
480
+ number: number;
481
+ title: string;
482
+ state: string;
483
+ url: string;
484
+ closedAt: string | null;
485
+ }>;
486
+ listLabels: ai.Tool<{
487
+ owner: string;
488
+ repo: string;
489
+ perPage: number;
490
+ page: number;
491
+ }, {
492
+ name: string;
493
+ color: string;
494
+ description: string | null;
495
+ }[]>;
496
+ addLabels: ai.Tool<{
497
+ owner: string;
498
+ repo: string;
499
+ issueNumber: number;
500
+ labels: string[];
501
+ }, {
502
+ name: string;
503
+ color: string;
504
+ description: string | null;
505
+ }[]>;
506
+ removeLabel: ai.Tool<{
507
+ owner: string;
508
+ repo: string;
509
+ issueNumber: number;
510
+ label: string;
511
+ }, {
512
+ removed: boolean;
513
+ label: string;
514
+ issueNumber: number;
515
+ }>;
516
+ listGists: ai.Tool<{
517
+ perPage: number;
518
+ page: number;
519
+ username?: string | undefined;
520
+ }, {
521
+ id: string;
522
+ description: string | null;
523
+ public: boolean;
524
+ url: string;
525
+ files: string[];
526
+ owner: string | undefined;
527
+ comments: number;
528
+ createdAt: string;
529
+ updatedAt: string;
530
+ }[]>;
531
+ getGist: ai.Tool<{
532
+ gistId: string;
533
+ }, {
534
+ id: string | undefined;
535
+ description: string | null | undefined;
536
+ public: boolean | undefined;
537
+ url: string | undefined;
538
+ owner: string | undefined;
539
+ files: {
540
+ filename: string | undefined;
541
+ language: string | undefined;
542
+ size: number | undefined;
543
+ content: string | undefined;
544
+ }[];
545
+ comments: number | undefined;
546
+ createdAt: string | undefined;
547
+ updatedAt: string | undefined;
548
+ }>;
549
+ listGistComments: ai.Tool<{
550
+ gistId: string;
551
+ perPage: number;
552
+ page: number;
553
+ }, {
554
+ id: number;
555
+ body: string;
556
+ author: string | undefined;
557
+ url: string;
558
+ createdAt: string;
559
+ updatedAt: string;
560
+ }[]>;
561
+ createGist: ai.Tool<{
562
+ files: Record<string, {
563
+ content: string;
564
+ }>;
565
+ isPublic: boolean;
566
+ description?: string | undefined;
567
+ }, {
568
+ id: string | undefined;
569
+ description: string | null | undefined;
570
+ public: boolean | undefined;
571
+ url: string | undefined;
572
+ files: string[];
573
+ owner: string | undefined;
574
+ }>;
575
+ updateGist: ai.Tool<{
576
+ gistId: string;
577
+ description?: string | undefined;
578
+ files?: Record<string, {
579
+ content: string;
580
+ }> | undefined;
581
+ filesToDelete?: string[] | undefined;
582
+ }, {
583
+ id: string | undefined;
584
+ description: string | null | undefined;
585
+ url: string | undefined;
586
+ files: string[];
587
+ }>;
588
+ deleteGist: ai.Tool<{
589
+ gistId: string;
590
+ }, {
591
+ deleted: boolean;
592
+ gistId: string;
593
+ }>;
594
+ createGistComment: ai.Tool<{
595
+ gistId: string;
596
+ body: string;
597
+ }, {
598
+ id: number;
599
+ url: string;
600
+ body: string;
601
+ author: string | undefined;
602
+ createdAt: string;
603
+ }>;
604
+ listWorkflows: ai.Tool<{
605
+ owner: string;
606
+ repo: string;
607
+ perPage: number;
608
+ page: number;
609
+ }, {
610
+ totalCount: number;
611
+ workflows: {
612
+ id: number;
613
+ name: string;
614
+ path: string;
615
+ state: "active" | "deleted" | "disabled_fork" | "disabled_inactivity" | "disabled_manually";
616
+ url: string;
617
+ createdAt: string;
618
+ updatedAt: string;
619
+ }[];
620
+ }>;
621
+ listWorkflowRuns: ai.Tool<{
622
+ owner: string;
623
+ repo: string;
624
+ perPage: number;
625
+ page: number;
626
+ workflowId?: string | number | undefined;
627
+ branch?: string | undefined;
628
+ event?: string | undefined;
629
+ status?: "success" | "completed" | "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "timed_out" | "in_progress" | "queued" | "requested" | "waiting" | "pending" | undefined;
630
+ }, {
631
+ totalCount: number;
632
+ runs: {
633
+ id: number;
634
+ name: string | null | undefined;
635
+ status: string | null;
636
+ conclusion: string | null;
637
+ branch: string | null;
638
+ event: string;
639
+ url: string;
640
+ actor: string | undefined;
641
+ createdAt: string;
642
+ updatedAt: string;
643
+ runNumber: number;
644
+ runAttempt: number | undefined;
645
+ }[];
646
+ }>;
647
+ getWorkflowRun: ai.Tool<{
648
+ owner: string;
649
+ repo: string;
650
+ runId: number;
651
+ }, {
652
+ id: number;
653
+ name: string | null | undefined;
654
+ status: string | null;
655
+ conclusion: string | null;
656
+ branch: string | null;
657
+ sha: string;
658
+ event: string;
659
+ url: string;
660
+ actor: string | undefined;
661
+ runNumber: number;
662
+ runAttempt: number | undefined;
663
+ createdAt: string;
664
+ updatedAt: string;
665
+ runStartedAt: string | undefined;
666
+ }>;
667
+ listWorkflowJobs: ai.Tool<{
668
+ owner: string;
669
+ repo: string;
670
+ runId: number;
671
+ filter: "all" | "latest";
672
+ perPage: number;
673
+ page: number;
674
+ }, {
675
+ totalCount: number;
676
+ jobs: {
677
+ id: number;
678
+ name: string;
679
+ status: "completed" | "in_progress" | "queued" | "requested" | "waiting" | "pending";
680
+ conclusion: "success" | "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "timed_out" | null;
681
+ url: string | null;
682
+ startedAt: string;
683
+ completedAt: string | null;
684
+ runnerName: string | null;
685
+ steps: {
686
+ name: string;
687
+ status: "completed" | "in_progress" | "queued";
688
+ conclusion: string | null;
689
+ number: number;
690
+ startedAt: string | null | undefined;
691
+ completedAt: string | null | undefined;
692
+ }[] | undefined;
693
+ }[];
694
+ }>;
695
+ triggerWorkflow: ai.Tool<{
696
+ owner: string;
697
+ repo: string;
698
+ workflowId: string | number;
699
+ ref: string;
700
+ inputs?: Record<string, string> | undefined;
701
+ }, {
702
+ triggered: boolean;
703
+ workflowId: string | number;
704
+ ref: string;
705
+ }>;
706
+ cancelWorkflowRun: ai.Tool<{
707
+ owner: string;
708
+ repo: string;
709
+ runId: number;
710
+ }, {
711
+ cancelled: boolean;
712
+ runId: number;
713
+ }>;
714
+ rerunWorkflowRun: ai.Tool<{
715
+ owner: string;
716
+ repo: string;
717
+ runId: number;
718
+ onlyFailedJobs: boolean;
719
+ }, {
720
+ rerun: boolean;
721
+ runId: number;
722
+ onlyFailedJobs: boolean;
723
+ }>;
724
+ }>>;
725
+ //#endregion
726
+ export { type ApprovalConfig, CreateDurableGithubAgentOptions, type CreateGithubAgentOptions, type GithubToolPreset, type GithubTools, type GithubToolsOptions, type GithubWriteToolName, createDurableGithubAgent, createGithubAgent, createGithubTools };
727
+ //# sourceMappingURL=workflow.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/workflow.ts"],"mappings":";;;;;;KAMY,+BAAA;EACV,KAAA,WAAgB,uBAAA,UAAiC,OAAA,CAAQ,uBAAA;;AAD3D;;;EAME,KAAA;EACA,MAAA,GAAS,gBAAA,GAAmB,gBAAA;EAC5B,eAAA,GAAkB,cAAA;EAClB,YAAA;EACA,sBAAA,WAFkB;EAIlB,QAAA;EACA,WAAA;AAAA;;;;;;;;;;;;;;;;AA+BF;;;;;;;;;;;;;iBAAgB,wBAAA,CAAA;EACd,KAAA;EACA,KAAA;EACA,MAAA;EACA,eAAA;EACA,YAAA;EACA,sBAAA;EAAA,GACG;AAAA,GACF,+BAAA,GAA+B,YAAA,CAAA,OAAA;iBAAA,EAAA,CAAA,IAAA"}