@github-tools/sdk 1.4.0 → 1.6.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 +50 -2
- package/dist/index-ikP-LT-3.d.mts +1634 -0
- package/dist/index-ikP-LT-3.d.mts.map +1 -0
- package/dist/index.d.mts +2 -777
- package/dist/index.mjs +1 -219
- package/dist/{agents-D9aKsd_7.mjs → src--pAdGYqY.mjs} +335 -23
- package/dist/src--pAdGYqY.mjs.map +1 -0
- package/dist/workflow.d.mts +159 -55
- package/dist/workflow.d.mts.map +1 -1
- package/dist/workflow.mjs +105 -11
- package/dist/workflow.mjs.map +1 -1
- package/package.json +8 -8
- package/dist/agents-C6nqZiYp.d.mts +0 -781
- package/dist/agents-C6nqZiYp.d.mts.map +0 -1
- package/dist/agents-D9aKsd_7.mjs.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/workflow.d.mts
CHANGED
|
@@ -1,10 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { CompatibleLanguageModel,
|
|
1
|
+
import { $ as CommitToolOptions, Q as CommitIdentity, a as GithubWriteToolName, c as createGithubAgent, i as GithubToolsOptions, n as GithubToolPreset, nt as ToolOverrides, o as createGithubTools, r as GithubTools, s as CreateGithubAgentOptions, t as ApprovalConfig } from "./index-ikP-LT-3.mjs";
|
|
2
|
+
import * as _$ai from "ai";
|
|
3
|
+
import { FinishReason, LanguageModelResponseMetadata, LanguageModelUsage, ModelMessage, StepResult, StopCondition, ToolSet } from "ai";
|
|
4
|
+
import { CompatibleLanguageModel, DurableAgentOptions, DurableAgentStreamOptions, DurableAgentStreamResult } from "@workflow/ai/agent";
|
|
5
5
|
|
|
6
6
|
//#region src/workflow.d.ts
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Result of {@link DurableGithubAgent.generate}.
|
|
9
|
+
*/
|
|
10
|
+
interface DurableGithubAgentGenerateResult<TTools extends ToolSet = ToolSet> {
|
|
11
|
+
text: string;
|
|
12
|
+
finishReason: FinishReason;
|
|
13
|
+
usage: LanguageModelUsage;
|
|
14
|
+
steps: StepResult<TTools>[];
|
|
15
|
+
response: LanguageModelResponseMetadata & {
|
|
16
|
+
messages: ModelMessage[];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A wrapper around the Workflow SDK's `DurableAgent` that adds a non-streaming
|
|
21
|
+
* `.generate()` method alongside the existing `.stream()`.
|
|
22
|
+
*
|
|
23
|
+
* - `.stream()` — delegates to `DurableAgent.stream()`, each tool call is
|
|
24
|
+
* an individually retriable workflow step. Works in workflow context.
|
|
25
|
+
* - `.generate()` — uses `generateText` from the AI SDK for non-streaming
|
|
26
|
+
* execution. Must be called from within a `"use step"` function in
|
|
27
|
+
* workflow context (the Workflow runtime blocks raw I/O in workflow scope).
|
|
28
|
+
*/
|
|
29
|
+
declare class DurableGithubAgent<TTools extends ToolSet = ToolSet> {
|
|
30
|
+
private agent;
|
|
31
|
+
private _model;
|
|
32
|
+
private _instructions?;
|
|
33
|
+
private _telemetry?;
|
|
34
|
+
private _tools;
|
|
35
|
+
constructor(options: DurableAgentOptions<TTools>);
|
|
36
|
+
/** The tool set configured for this agent. */
|
|
37
|
+
get tools(): TTools;
|
|
38
|
+
/**
|
|
39
|
+
* Stream the agent's response. Delegates directly to `DurableAgent.stream()`.
|
|
40
|
+
* Works in workflow context — each tool call is a durable step.
|
|
41
|
+
*/
|
|
42
|
+
stream<TStreamTools extends TTools = TTools, OUTPUT = never, PARTIAL_OUTPUT = never>(options: DurableAgentStreamOptions<TStreamTools, OUTPUT, PARTIAL_OUTPUT>): Promise<DurableAgentStreamResult<TStreamTools, OUTPUT>>;
|
|
43
|
+
/**
|
|
44
|
+
* Generate a non-streaming response using `generateText` from the AI SDK.
|
|
45
|
+
*
|
|
46
|
+
* In workflow context this **must** be called from within a `"use step"`
|
|
47
|
+
* function, because the Workflow runtime blocks direct I/O (HTTP calls)
|
|
48
|
+
* at the workflow scope level.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* async function agentTurn(prompt: string) {
|
|
53
|
+
* "use step"
|
|
54
|
+
* const agent = createDurableGithubAgent({
|
|
55
|
+
* model: 'anthropic/claude-sonnet-4.6',
|
|
56
|
+
* preset: 'code-review',
|
|
57
|
+
* })
|
|
58
|
+
* const { text } = await agent.generate({ prompt })
|
|
59
|
+
* return text
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
generate({
|
|
64
|
+
prompt,
|
|
65
|
+
stopWhen
|
|
66
|
+
}: {
|
|
67
|
+
prompt: string;
|
|
68
|
+
stopWhen?: StopCondition<TTools> | Array<StopCondition<TTools>>;
|
|
69
|
+
}): Promise<DurableGithubAgentGenerateResult<TTools>>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Options for creating a durable GitHub agent via {@link createDurableGithubAgent}.
|
|
73
|
+
*
|
|
74
|
+
* Extends all `DurableAgentOptions` (temperature, telemetry, callbacks, etc.)
|
|
75
|
+
* and adds GitHub-specific fields (token, preset, approval config).
|
|
76
|
+
*/
|
|
77
|
+
type CreateDurableGithubAgentOptions = Omit<DurableAgentOptions, 'model' | 'tools' | 'instructions'> & {
|
|
8
78
|
model: string | CompatibleLanguageModel | (() => Promise<CompatibleLanguageModel>);
|
|
9
79
|
/**
|
|
10
80
|
* GitHub personal access token.
|
|
@@ -14,21 +84,37 @@ type CreateDurableGithubAgentOptions = {
|
|
|
14
84
|
preset?: GithubToolPreset | GithubToolPreset[];
|
|
15
85
|
requireApproval?: ApprovalConfig;
|
|
16
86
|
instructions?: string;
|
|
17
|
-
additionalInstructions?: string;
|
|
18
|
-
|
|
19
|
-
|
|
87
|
+
additionalInstructions?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Default author for commit-creating tools.
|
|
90
|
+
* Falls back to the authenticated user when omitted.
|
|
91
|
+
*/
|
|
92
|
+
author?: CommitIdentity;
|
|
93
|
+
/**
|
|
94
|
+
* Default committer for commit-creating tools.
|
|
95
|
+
* Falls back to the authenticated user when omitted.
|
|
96
|
+
*/
|
|
97
|
+
committer?: CommitIdentity;
|
|
98
|
+
/**
|
|
99
|
+
* Co-authors to attribute on all commits.
|
|
100
|
+
* Added as "Co-authored-by" trailers to commit messages.
|
|
101
|
+
*/
|
|
102
|
+
coAuthors?: CommitIdentity[];
|
|
20
103
|
};
|
|
21
104
|
/**
|
|
22
105
|
* Create a pre-configured durable GitHub agent powered by Vercel Workflow SDK's `DurableAgent`.
|
|
23
106
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
107
|
+
* Returns a {@link DurableGithubAgent} with two interaction modes:
|
|
108
|
+
*
|
|
109
|
+
* - `.stream()` — works directly in workflow scope; each tool call is a durable step.
|
|
110
|
+
* - `.generate()` — uses `generateText` from the AI SDK; must be called from
|
|
111
|
+
* within a `"use step"` function when running inside a workflow.
|
|
26
112
|
*
|
|
27
113
|
* **Note:** `requireApproval` is accepted for forward-compatibility but is currently
|
|
28
114
|
* ignored by `DurableAgent` — the Workflow SDK does not yet support interactive tool
|
|
29
115
|
* approval. All tools execute immediately without user confirmation.
|
|
30
116
|
*
|
|
31
|
-
* @example
|
|
117
|
+
* @example Streaming (chat UI — works in workflow scope)
|
|
32
118
|
* ```ts
|
|
33
119
|
* import { createDurableGithubAgent } from '@github-tools/sdk/workflow'
|
|
34
120
|
* import { getWritable } from 'workflow'
|
|
@@ -45,6 +131,21 @@ type CreateDurableGithubAgentOptions = {
|
|
|
45
131
|
* await agent.stream({ messages, writable })
|
|
46
132
|
* }
|
|
47
133
|
* ```
|
|
134
|
+
*
|
|
135
|
+
* @example Non-streaming (bot / background job — needs "use step")
|
|
136
|
+
* ```ts
|
|
137
|
+
* import { createDurableGithubAgent } from '@github-tools/sdk/workflow'
|
|
138
|
+
*
|
|
139
|
+
* async function agentTurn(prompt: string) {
|
|
140
|
+
* "use step"
|
|
141
|
+
* const agent = createDurableGithubAgent({
|
|
142
|
+
* model: 'anthropic/claude-sonnet-4.6',
|
|
143
|
+
* preset: 'code-review',
|
|
144
|
+
* })
|
|
145
|
+
* const { text } = await agent.generate({ prompt })
|
|
146
|
+
* return text
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
48
149
|
*/
|
|
49
150
|
declare function createDurableGithubAgent({
|
|
50
151
|
model,
|
|
@@ -53,9 +154,12 @@ declare function createDurableGithubAgent({
|
|
|
53
154
|
requireApproval,
|
|
54
155
|
instructions,
|
|
55
156
|
additionalInstructions,
|
|
157
|
+
author,
|
|
158
|
+
committer,
|
|
159
|
+
coAuthors,
|
|
56
160
|
...agentOptions
|
|
57
|
-
}: CreateDurableGithubAgentOptions):
|
|
58
|
-
getRepository: ai.Tool<{
|
|
161
|
+
}: CreateDurableGithubAgentOptions): DurableGithubAgent<Partial<{
|
|
162
|
+
getRepository: _$ai.Tool<{
|
|
59
163
|
owner: string;
|
|
60
164
|
repo: string;
|
|
61
165
|
}, {
|
|
@@ -72,7 +176,7 @@ declare function createDurableGithubAgent({
|
|
|
72
176
|
createdAt: string;
|
|
73
177
|
updatedAt: string;
|
|
74
178
|
}>;
|
|
75
|
-
listBranches: ai.Tool<{
|
|
179
|
+
listBranches: _$ai.Tool<{
|
|
76
180
|
owner: string;
|
|
77
181
|
repo: string;
|
|
78
182
|
perPage: number;
|
|
@@ -81,7 +185,7 @@ declare function createDurableGithubAgent({
|
|
|
81
185
|
sha: string;
|
|
82
186
|
protected: boolean;
|
|
83
187
|
}[]>;
|
|
84
|
-
getFileContent: ai.Tool<{
|
|
188
|
+
getFileContent: _$ai.Tool<{
|
|
85
189
|
owner: string;
|
|
86
190
|
repo: string;
|
|
87
191
|
path: string;
|
|
@@ -112,7 +216,7 @@ declare function createDurableGithubAgent({
|
|
|
112
216
|
content: string;
|
|
113
217
|
entries?: undefined;
|
|
114
218
|
}>;
|
|
115
|
-
listPullRequests: ai.Tool<{
|
|
219
|
+
listPullRequests: _$ai.Tool<{
|
|
116
220
|
owner: string;
|
|
117
221
|
repo: string;
|
|
118
222
|
state: "open" | "closed" | "all";
|
|
@@ -129,7 +233,7 @@ declare function createDurableGithubAgent({
|
|
|
129
233
|
createdAt: string;
|
|
130
234
|
updatedAt: string;
|
|
131
235
|
}[]>;
|
|
132
|
-
getPullRequest: ai.Tool<{
|
|
236
|
+
getPullRequest: _$ai.Tool<{
|
|
133
237
|
owner: string;
|
|
134
238
|
repo: string;
|
|
135
239
|
pullNumber: number;
|
|
@@ -152,7 +256,7 @@ declare function createDurableGithubAgent({
|
|
|
152
256
|
updatedAt: string;
|
|
153
257
|
mergedAt: string | null;
|
|
154
258
|
}>;
|
|
155
|
-
listIssues: ai.Tool<{
|
|
259
|
+
listIssues: _$ai.Tool<{
|
|
156
260
|
owner: string;
|
|
157
261
|
repo: string;
|
|
158
262
|
state: "open" | "closed" | "all";
|
|
@@ -168,7 +272,7 @@ declare function createDurableGithubAgent({
|
|
|
168
272
|
createdAt: string;
|
|
169
273
|
updatedAt: string;
|
|
170
274
|
}[]>;
|
|
171
|
-
getIssue: ai.Tool<{
|
|
275
|
+
getIssue: _$ai.Tool<{
|
|
172
276
|
owner: string;
|
|
173
277
|
repo: string;
|
|
174
278
|
issueNumber: number;
|
|
@@ -186,7 +290,7 @@ declare function createDurableGithubAgent({
|
|
|
186
290
|
updatedAt: string;
|
|
187
291
|
closedAt: string | null;
|
|
188
292
|
}>;
|
|
189
|
-
searchCode: ai.Tool<{
|
|
293
|
+
searchCode: _$ai.Tool<{
|
|
190
294
|
query: string;
|
|
191
295
|
perPage: number;
|
|
192
296
|
}, {
|
|
@@ -199,7 +303,7 @@ declare function createDurableGithubAgent({
|
|
|
199
303
|
sha: string;
|
|
200
304
|
}[];
|
|
201
305
|
}>;
|
|
202
|
-
searchRepositories: ai.Tool<{
|
|
306
|
+
searchRepositories: _$ai.Tool<{
|
|
203
307
|
query: string;
|
|
204
308
|
perPage: number;
|
|
205
309
|
order: "asc" | "desc";
|
|
@@ -217,7 +321,7 @@ declare function createDurableGithubAgent({
|
|
|
217
321
|
topics: string[] | undefined;
|
|
218
322
|
}[];
|
|
219
323
|
}>;
|
|
220
|
-
listCommits: ai.Tool<{
|
|
324
|
+
listCommits: _$ai.Tool<{
|
|
221
325
|
owner: string;
|
|
222
326
|
repo: string;
|
|
223
327
|
perPage: number;
|
|
@@ -234,7 +338,7 @@ declare function createDurableGithubAgent({
|
|
|
234
338
|
date: string | undefined;
|
|
235
339
|
url: string;
|
|
236
340
|
}[]>;
|
|
237
|
-
getCommit: ai.Tool<{
|
|
341
|
+
getCommit: _$ai.Tool<{
|
|
238
342
|
owner: string;
|
|
239
343
|
repo: string;
|
|
240
344
|
ref: string;
|
|
@@ -258,7 +362,7 @@ declare function createDurableGithubAgent({
|
|
|
258
362
|
patch: string | undefined;
|
|
259
363
|
}[] | undefined;
|
|
260
364
|
}>;
|
|
261
|
-
getBlame: ai.Tool<{
|
|
365
|
+
getBlame: _$ai.Tool<{
|
|
262
366
|
owner: string;
|
|
263
367
|
repo: string;
|
|
264
368
|
path: string;
|
|
@@ -295,7 +399,7 @@ declare function createDurableGithubAgent({
|
|
|
295
399
|
}[];
|
|
296
400
|
error?: undefined;
|
|
297
401
|
}>;
|
|
298
|
-
createBranch: ai.Tool<{
|
|
402
|
+
createBranch: _$ai.Tool<{
|
|
299
403
|
owner: string;
|
|
300
404
|
repo: string;
|
|
301
405
|
branch: string;
|
|
@@ -305,7 +409,7 @@ declare function createDurableGithubAgent({
|
|
|
305
409
|
sha: string;
|
|
306
410
|
url: string;
|
|
307
411
|
}>;
|
|
308
|
-
forkRepository: ai.Tool<{
|
|
412
|
+
forkRepository: _$ai.Tool<{
|
|
309
413
|
owner: string;
|
|
310
414
|
repo: string;
|
|
311
415
|
organization?: string | undefined;
|
|
@@ -323,7 +427,7 @@ declare function createDurableGithubAgent({
|
|
|
323
427
|
url: string;
|
|
324
428
|
} | null;
|
|
325
429
|
}>;
|
|
326
|
-
createRepository: ai.Tool<{
|
|
430
|
+
createRepository: _$ai.Tool<{
|
|
327
431
|
name: string;
|
|
328
432
|
isPrivate: boolean;
|
|
329
433
|
autoInit: boolean;
|
|
@@ -342,7 +446,7 @@ declare function createDurableGithubAgent({
|
|
|
342
446
|
private: boolean;
|
|
343
447
|
createdAt: string;
|
|
344
448
|
}>;
|
|
345
|
-
createOrUpdateFile: ai.Tool<{
|
|
449
|
+
createOrUpdateFile: _$ai.Tool<{
|
|
346
450
|
owner: string;
|
|
347
451
|
repo: string;
|
|
348
452
|
path: string;
|
|
@@ -356,7 +460,7 @@ declare function createDurableGithubAgent({
|
|
|
356
460
|
commitSha: string | undefined;
|
|
357
461
|
commitUrl: string | undefined;
|
|
358
462
|
}>;
|
|
359
|
-
createPullRequest: ai.Tool<{
|
|
463
|
+
createPullRequest: _$ai.Tool<{
|
|
360
464
|
owner: string;
|
|
361
465
|
repo: string;
|
|
362
466
|
title: string;
|
|
@@ -373,7 +477,7 @@ declare function createDurableGithubAgent({
|
|
|
373
477
|
branch: string;
|
|
374
478
|
base: string;
|
|
375
479
|
}>;
|
|
376
|
-
mergePullRequest: ai.Tool<{
|
|
480
|
+
mergePullRequest: _$ai.Tool<{
|
|
377
481
|
owner: string;
|
|
378
482
|
repo: string;
|
|
379
483
|
pullNumber: number;
|
|
@@ -385,7 +489,7 @@ declare function createDurableGithubAgent({
|
|
|
385
489
|
message: string;
|
|
386
490
|
sha: string;
|
|
387
491
|
}>;
|
|
388
|
-
addPullRequestComment: ai.Tool<{
|
|
492
|
+
addPullRequestComment: _$ai.Tool<{
|
|
389
493
|
owner: string;
|
|
390
494
|
repo: string;
|
|
391
495
|
pullNumber: number;
|
|
@@ -397,7 +501,7 @@ declare function createDurableGithubAgent({
|
|
|
397
501
|
author: string | undefined;
|
|
398
502
|
createdAt: string;
|
|
399
503
|
}>;
|
|
400
|
-
listPullRequestFiles: ai.Tool<{
|
|
504
|
+
listPullRequestFiles: _$ai.Tool<{
|
|
401
505
|
owner: string;
|
|
402
506
|
repo: string;
|
|
403
507
|
pullNumber: number;
|
|
@@ -411,7 +515,7 @@ declare function createDurableGithubAgent({
|
|
|
411
515
|
changes: number;
|
|
412
516
|
patch: string | undefined;
|
|
413
517
|
}[]>;
|
|
414
|
-
listPullRequestReviews: ai.Tool<{
|
|
518
|
+
listPullRequestReviews: _$ai.Tool<{
|
|
415
519
|
owner: string;
|
|
416
520
|
repo: string;
|
|
417
521
|
pullNumber: number;
|
|
@@ -425,7 +529,7 @@ declare function createDurableGithubAgent({
|
|
|
425
529
|
url: string;
|
|
426
530
|
submittedAt: string | undefined;
|
|
427
531
|
}[]>;
|
|
428
|
-
createPullRequestReview: ai.Tool<{
|
|
532
|
+
createPullRequestReview: _$ai.Tool<{
|
|
429
533
|
owner: string;
|
|
430
534
|
repo: string;
|
|
431
535
|
pullNumber: number;
|
|
@@ -445,7 +549,7 @@ declare function createDurableGithubAgent({
|
|
|
445
549
|
author: string | undefined;
|
|
446
550
|
submittedAt: string | undefined;
|
|
447
551
|
}>;
|
|
448
|
-
createIssue: ai.Tool<{
|
|
552
|
+
createIssue: _$ai.Tool<{
|
|
449
553
|
owner: string;
|
|
450
554
|
repo: string;
|
|
451
555
|
title: string;
|
|
@@ -459,7 +563,7 @@ declare function createDurableGithubAgent({
|
|
|
459
563
|
state: string;
|
|
460
564
|
labels: (string | undefined)[];
|
|
461
565
|
}>;
|
|
462
|
-
addIssueComment: ai.Tool<{
|
|
566
|
+
addIssueComment: _$ai.Tool<{
|
|
463
567
|
owner: string;
|
|
464
568
|
repo: string;
|
|
465
569
|
issueNumber: number;
|
|
@@ -471,7 +575,7 @@ declare function createDurableGithubAgent({
|
|
|
471
575
|
author: string | undefined;
|
|
472
576
|
createdAt: string;
|
|
473
577
|
}>;
|
|
474
|
-
closeIssue: ai.Tool<{
|
|
578
|
+
closeIssue: _$ai.Tool<{
|
|
475
579
|
owner: string;
|
|
476
580
|
repo: string;
|
|
477
581
|
issueNumber: number;
|
|
@@ -483,7 +587,7 @@ declare function createDurableGithubAgent({
|
|
|
483
587
|
url: string;
|
|
484
588
|
closedAt: string | null;
|
|
485
589
|
}>;
|
|
486
|
-
listLabels: ai.Tool<{
|
|
590
|
+
listLabels: _$ai.Tool<{
|
|
487
591
|
owner: string;
|
|
488
592
|
repo: string;
|
|
489
593
|
perPage: number;
|
|
@@ -493,7 +597,7 @@ declare function createDurableGithubAgent({
|
|
|
493
597
|
color: string;
|
|
494
598
|
description: string | null;
|
|
495
599
|
}[]>;
|
|
496
|
-
addLabels: ai.Tool<{
|
|
600
|
+
addLabels: _$ai.Tool<{
|
|
497
601
|
owner: string;
|
|
498
602
|
repo: string;
|
|
499
603
|
issueNumber: number;
|
|
@@ -503,7 +607,7 @@ declare function createDurableGithubAgent({
|
|
|
503
607
|
color: string;
|
|
504
608
|
description: string | null;
|
|
505
609
|
}[]>;
|
|
506
|
-
removeLabel: ai.Tool<{
|
|
610
|
+
removeLabel: _$ai.Tool<{
|
|
507
611
|
owner: string;
|
|
508
612
|
repo: string;
|
|
509
613
|
issueNumber: number;
|
|
@@ -513,7 +617,7 @@ declare function createDurableGithubAgent({
|
|
|
513
617
|
label: string;
|
|
514
618
|
issueNumber: number;
|
|
515
619
|
}>;
|
|
516
|
-
listGists: ai.Tool<{
|
|
620
|
+
listGists: _$ai.Tool<{
|
|
517
621
|
perPage: number;
|
|
518
622
|
page: number;
|
|
519
623
|
username?: string | undefined;
|
|
@@ -528,7 +632,7 @@ declare function createDurableGithubAgent({
|
|
|
528
632
|
createdAt: string;
|
|
529
633
|
updatedAt: string;
|
|
530
634
|
}[]>;
|
|
531
|
-
getGist: ai.Tool<{
|
|
635
|
+
getGist: _$ai.Tool<{
|
|
532
636
|
gistId: string;
|
|
533
637
|
}, {
|
|
534
638
|
id: string | undefined;
|
|
@@ -546,7 +650,7 @@ declare function createDurableGithubAgent({
|
|
|
546
650
|
createdAt: string | undefined;
|
|
547
651
|
updatedAt: string | undefined;
|
|
548
652
|
}>;
|
|
549
|
-
listGistComments: ai.Tool<{
|
|
653
|
+
listGistComments: _$ai.Tool<{
|
|
550
654
|
gistId: string;
|
|
551
655
|
perPage: number;
|
|
552
656
|
page: number;
|
|
@@ -558,7 +662,7 @@ declare function createDurableGithubAgent({
|
|
|
558
662
|
createdAt: string;
|
|
559
663
|
updatedAt: string;
|
|
560
664
|
}[]>;
|
|
561
|
-
createGist: ai.Tool<{
|
|
665
|
+
createGist: _$ai.Tool<{
|
|
562
666
|
files: Record<string, {
|
|
563
667
|
content: string;
|
|
564
668
|
}>;
|
|
@@ -572,7 +676,7 @@ declare function createDurableGithubAgent({
|
|
|
572
676
|
files: string[];
|
|
573
677
|
owner: string | undefined;
|
|
574
678
|
}>;
|
|
575
|
-
updateGist: ai.Tool<{
|
|
679
|
+
updateGist: _$ai.Tool<{
|
|
576
680
|
gistId: string;
|
|
577
681
|
description?: string | undefined;
|
|
578
682
|
files?: Record<string, {
|
|
@@ -585,13 +689,13 @@ declare function createDurableGithubAgent({
|
|
|
585
689
|
url: string | undefined;
|
|
586
690
|
files: string[];
|
|
587
691
|
}>;
|
|
588
|
-
deleteGist: ai.Tool<{
|
|
692
|
+
deleteGist: _$ai.Tool<{
|
|
589
693
|
gistId: string;
|
|
590
694
|
}, {
|
|
591
695
|
deleted: boolean;
|
|
592
696
|
gistId: string;
|
|
593
697
|
}>;
|
|
594
|
-
createGistComment: ai.Tool<{
|
|
698
|
+
createGistComment: _$ai.Tool<{
|
|
595
699
|
gistId: string;
|
|
596
700
|
body: string;
|
|
597
701
|
}, {
|
|
@@ -601,7 +705,7 @@ declare function createDurableGithubAgent({
|
|
|
601
705
|
author: string | undefined;
|
|
602
706
|
createdAt: string;
|
|
603
707
|
}>;
|
|
604
|
-
listWorkflows: ai.Tool<{
|
|
708
|
+
listWorkflows: _$ai.Tool<{
|
|
605
709
|
owner: string;
|
|
606
710
|
repo: string;
|
|
607
711
|
perPage: number;
|
|
@@ -618,7 +722,7 @@ declare function createDurableGithubAgent({
|
|
|
618
722
|
updatedAt: string;
|
|
619
723
|
}[];
|
|
620
724
|
}>;
|
|
621
|
-
listWorkflowRuns: ai.Tool<{
|
|
725
|
+
listWorkflowRuns: _$ai.Tool<{
|
|
622
726
|
owner: string;
|
|
623
727
|
repo: string;
|
|
624
728
|
perPage: number;
|
|
@@ -644,7 +748,7 @@ declare function createDurableGithubAgent({
|
|
|
644
748
|
runAttempt: number | undefined;
|
|
645
749
|
}[];
|
|
646
750
|
}>;
|
|
647
|
-
getWorkflowRun: ai.Tool<{
|
|
751
|
+
getWorkflowRun: _$ai.Tool<{
|
|
648
752
|
owner: string;
|
|
649
753
|
repo: string;
|
|
650
754
|
runId: number;
|
|
@@ -664,7 +768,7 @@ declare function createDurableGithubAgent({
|
|
|
664
768
|
updatedAt: string;
|
|
665
769
|
runStartedAt: string | undefined;
|
|
666
770
|
}>;
|
|
667
|
-
listWorkflowJobs: ai.Tool<{
|
|
771
|
+
listWorkflowJobs: _$ai.Tool<{
|
|
668
772
|
owner: string;
|
|
669
773
|
repo: string;
|
|
670
774
|
runId: number;
|
|
@@ -692,7 +796,7 @@ declare function createDurableGithubAgent({
|
|
|
692
796
|
}[] | undefined;
|
|
693
797
|
}[];
|
|
694
798
|
}>;
|
|
695
|
-
triggerWorkflow: ai.Tool<{
|
|
799
|
+
triggerWorkflow: _$ai.Tool<{
|
|
696
800
|
owner: string;
|
|
697
801
|
repo: string;
|
|
698
802
|
workflowId: string | number;
|
|
@@ -703,7 +807,7 @@ declare function createDurableGithubAgent({
|
|
|
703
807
|
workflowId: string | number;
|
|
704
808
|
ref: string;
|
|
705
809
|
}>;
|
|
706
|
-
cancelWorkflowRun: ai.Tool<{
|
|
810
|
+
cancelWorkflowRun: _$ai.Tool<{
|
|
707
811
|
owner: string;
|
|
708
812
|
repo: string;
|
|
709
813
|
runId: number;
|
|
@@ -711,7 +815,7 @@ declare function createDurableGithubAgent({
|
|
|
711
815
|
cancelled: boolean;
|
|
712
816
|
runId: number;
|
|
713
817
|
}>;
|
|
714
|
-
rerunWorkflowRun: ai.Tool<{
|
|
818
|
+
rerunWorkflowRun: _$ai.Tool<{
|
|
715
819
|
owner: string;
|
|
716
820
|
repo: string;
|
|
717
821
|
runId: number;
|
|
@@ -723,5 +827,5 @@ declare function createDurableGithubAgent({
|
|
|
723
827
|
}>;
|
|
724
828
|
}>>;
|
|
725
829
|
//#endregion
|
|
726
|
-
export { type ApprovalConfig, CreateDurableGithubAgentOptions, type CreateGithubAgentOptions, type GithubToolPreset, type GithubTools, type GithubToolsOptions, type GithubWriteToolName, createDurableGithubAgent, createGithubAgent, createGithubTools };
|
|
830
|
+
export { type ApprovalConfig, type CommitIdentity, type CommitToolOptions, CreateDurableGithubAgentOptions, type CreateGithubAgentOptions, DurableGithubAgent, DurableGithubAgentGenerateResult, type GithubToolPreset, type GithubTools, type GithubToolsOptions, type GithubWriteToolName, type ToolOverrides, createDurableGithubAgent, createGithubAgent, createGithubTools };
|
|
727
831
|
//# sourceMappingURL=workflow.d.mts.map
|
package/dist/workflow.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/workflow.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/workflow.ts"],"mappings":";;;;;;;;AAWA;UAAiB,gCAAA,gBAAgD,OAAA,GAAU,OAAA;EACzE,IAAA;EACA,YAAA,EAAc,YAAA;EACd,KAAA,EAAO,kBAAA;EACP,KAAA,EAAO,UAAA,CAAW,MAAA;EAClB,QAAA,EAAU,6BAAA;IAAkC,QAAA,EAAU,YAAA;EAAA;AAAA;;;;;;;;;;;cAa3C,kBAAA,gBAAkC,OAAA,GAAU,OAAA;EAAA,QAC/C,KAAA;EAAA,QACA,MAAA;EAAA,QACA,aAAA;EAAA,QACA,UAAA;EAAA,QACA,MAAA;cAEI,OAAA,EAAS,mBAAA,CAAoB,MAAA;EApBa;EAAA,IA6BlD,KAAA,CAAA,GAAS,MAAA;EA7BqD;AAapE;;;EAwBE,MAAA,sBAA4B,MAAA,GAAS,MAAA,yCAAA,CACnC,OAAA,EAAS,yBAAA,CAA0B,YAAA,EAAc,MAAA,EAAQ,cAAA,IACxD,OAAA,CAAQ,wBAAA,CAAyB,YAAA,EAAc,MAAA;EA1BK;;;;;;;;;;;;;;;;;;;;EAkDjD,QAAA,CAAA;IAAW,MAAA;IAAQ;EAAA;IAAc,MAAA;IAAgB,QAAA,GAAW,aAAA,CAAc,MAAA,IAAU,KAAA,CAAM,aAAA,CAAc,MAAA;EAAA,IAAa,OAAA,CAAQ,gCAAA,CAAiC,MAAA;AAAA;;;;;;;KAoC1J,+BAAA,GACV,IAAA,CAAK,mBAAA;EACH,KAAA,WAAgB,uBAAA,UAAiC,OAAA,CAAQ,uBAAA;EAnFnD;;;;EAwFN,KAAA;EACA,MAAA,GAAS,gBAAA,GAAmB,gBAAA;EAC5B,eAAA,GAAkB,cAAA;EAClB,YAAA;EACA,sBAAA;EAzE0B;;;;EA8E1B,MAAA,GAAS,cAAA;EA7E0B;;;;EAkFnC,SAAA,GAAY,cAAA;EAjFH;;;;EAsFT,SAAA,GAAY,cAAA;AAAA;;;;;;;;;;;;;;;AA1BhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2EgB,wBAAA,CAAA;EACd,KAAA;EACA,KAAA;EACA,MAAA;EACA,eAAA;EACA,YAAA;EACA,sBAAA;EACA,MAAA;EACA,SAAA;EACA,SAAA;EAAA,GACG;AAAA,GACF,+BAAA,GAA+B,kBAAA,CAAA,OAAA;iBAAA,IAAA,CAAA,IAAA"}
|
package/dist/workflow.mjs
CHANGED
|
@@ -1,19 +1,95 @@
|
|
|
1
|
-
import { n as resolveInstructions, t as
|
|
2
|
-
import { createGithubTools } from "./index.mjs";
|
|
1
|
+
import { n as createGithubAgent, r as resolveInstructions, t as createGithubTools } from "./src--pAdGYqY.mjs";
|
|
3
2
|
import { DurableAgent } from "@workflow/ai/agent";
|
|
4
|
-
|
|
5
3
|
//#region src/workflow.ts
|
|
6
4
|
/**
|
|
5
|
+
* A wrapper around the Workflow SDK's `DurableAgent` that adds a non-streaming
|
|
6
|
+
* `.generate()` method alongside the existing `.stream()`.
|
|
7
|
+
*
|
|
8
|
+
* - `.stream()` — delegates to `DurableAgent.stream()`, each tool call is
|
|
9
|
+
* an individually retriable workflow step. Works in workflow context.
|
|
10
|
+
* - `.generate()` — uses `generateText` from the AI SDK for non-streaming
|
|
11
|
+
* execution. Must be called from within a `"use step"` function in
|
|
12
|
+
* workflow context (the Workflow runtime blocks raw I/O in workflow scope).
|
|
13
|
+
*/
|
|
14
|
+
var DurableGithubAgent = class {
|
|
15
|
+
agent;
|
|
16
|
+
_model;
|
|
17
|
+
_instructions;
|
|
18
|
+
_telemetry;
|
|
19
|
+
_tools;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.agent = new DurableAgent(options);
|
|
22
|
+
this._model = options.model;
|
|
23
|
+
this._instructions = options.instructions;
|
|
24
|
+
this._telemetry = options.experimental_telemetry;
|
|
25
|
+
this._tools = options.tools ?? {};
|
|
26
|
+
}
|
|
27
|
+
/** The tool set configured for this agent. */
|
|
28
|
+
get tools() {
|
|
29
|
+
return this.agent.tools;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Stream the agent's response. Delegates directly to `DurableAgent.stream()`.
|
|
33
|
+
* Works in workflow context — each tool call is a durable step.
|
|
34
|
+
*/
|
|
35
|
+
stream(options) {
|
|
36
|
+
return this.agent.stream(options);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generate a non-streaming response using `generateText` from the AI SDK.
|
|
40
|
+
*
|
|
41
|
+
* In workflow context this **must** be called from within a `"use step"`
|
|
42
|
+
* function, because the Workflow runtime blocks direct I/O (HTTP calls)
|
|
43
|
+
* at the workflow scope level.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* async function agentTurn(prompt: string) {
|
|
48
|
+
* "use step"
|
|
49
|
+
* const agent = createDurableGithubAgent({
|
|
50
|
+
* model: 'anthropic/claude-sonnet-4.6',
|
|
51
|
+
* preset: 'code-review',
|
|
52
|
+
* })
|
|
53
|
+
* const { text } = await agent.generate({ prompt })
|
|
54
|
+
* return text
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
async generate({ prompt, stopWhen }) {
|
|
59
|
+
const { generateText } = await import("ai");
|
|
60
|
+
const model = typeof this._model === "function" ? await this._model() : this._model;
|
|
61
|
+
const system = typeof this._instructions === "string" ? this._instructions : void 0;
|
|
62
|
+
const result = await generateText({
|
|
63
|
+
model,
|
|
64
|
+
tools: this._tools,
|
|
65
|
+
system,
|
|
66
|
+
prompt,
|
|
67
|
+
stopWhen,
|
|
68
|
+
experimental_telemetry: this._telemetry
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
text: result.text,
|
|
72
|
+
finishReason: result.finishReason,
|
|
73
|
+
usage: result.usage,
|
|
74
|
+
steps: result.steps,
|
|
75
|
+
response: result.response
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
7
80
|
* Create a pre-configured durable GitHub agent powered by Vercel Workflow SDK's `DurableAgent`.
|
|
8
81
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
82
|
+
* Returns a {@link DurableGithubAgent} with two interaction modes:
|
|
83
|
+
*
|
|
84
|
+
* - `.stream()` — works directly in workflow scope; each tool call is a durable step.
|
|
85
|
+
* - `.generate()` — uses `generateText` from the AI SDK; must be called from
|
|
86
|
+
* within a `"use step"` function when running inside a workflow.
|
|
11
87
|
*
|
|
12
88
|
* **Note:** `requireApproval` is accepted for forward-compatibility but is currently
|
|
13
89
|
* ignored by `DurableAgent` — the Workflow SDK does not yet support interactive tool
|
|
14
90
|
* approval. All tools execute immediately without user confirmation.
|
|
15
91
|
*
|
|
16
|
-
* @example
|
|
92
|
+
* @example Streaming (chat UI — works in workflow scope)
|
|
17
93
|
* ```ts
|
|
18
94
|
* import { createDurableGithubAgent } from '@github-tools/sdk/workflow'
|
|
19
95
|
* import { getWritable } from 'workflow'
|
|
@@ -30,15 +106,33 @@ import { DurableAgent } from "@workflow/ai/agent";
|
|
|
30
106
|
* await agent.stream({ messages, writable })
|
|
31
107
|
* }
|
|
32
108
|
* ```
|
|
109
|
+
*
|
|
110
|
+
* @example Non-streaming (bot / background job — needs "use step")
|
|
111
|
+
* ```ts
|
|
112
|
+
* import { createDurableGithubAgent } from '@github-tools/sdk/workflow'
|
|
113
|
+
*
|
|
114
|
+
* async function agentTurn(prompt: string) {
|
|
115
|
+
* "use step"
|
|
116
|
+
* const agent = createDurableGithubAgent({
|
|
117
|
+
* model: 'anthropic/claude-sonnet-4.6',
|
|
118
|
+
* preset: 'code-review',
|
|
119
|
+
* })
|
|
120
|
+
* const { text } = await agent.generate({ prompt })
|
|
121
|
+
* return text
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
33
124
|
*/
|
|
34
|
-
function createDurableGithubAgent({ model, token, preset, requireApproval, instructions, additionalInstructions, ...agentOptions }) {
|
|
125
|
+
function createDurableGithubAgent({ model, token, preset, requireApproval, instructions, additionalInstructions, author, committer, coAuthors, ...agentOptions }) {
|
|
35
126
|
const tools = createGithubTools({
|
|
36
127
|
token,
|
|
37
128
|
requireApproval,
|
|
38
|
-
preset
|
|
129
|
+
preset,
|
|
130
|
+
author,
|
|
131
|
+
committer,
|
|
132
|
+
coAuthors
|
|
39
133
|
});
|
|
40
134
|
const resolvedModel = typeof model === "string" || typeof model === "function" ? model : () => Promise.resolve(model);
|
|
41
|
-
return new
|
|
135
|
+
return new DurableGithubAgent({
|
|
42
136
|
...agentOptions,
|
|
43
137
|
model: resolvedModel,
|
|
44
138
|
tools,
|
|
@@ -49,7 +143,7 @@ function createDurableGithubAgent({ model, token, preset, requireApproval, instr
|
|
|
49
143
|
})
|
|
50
144
|
});
|
|
51
145
|
}
|
|
52
|
-
|
|
53
146
|
//#endregion
|
|
54
|
-
export { createDurableGithubAgent, createGithubAgent, createGithubTools };
|
|
147
|
+
export { DurableGithubAgent, createDurableGithubAgent, createGithubAgent, createGithubTools };
|
|
148
|
+
|
|
55
149
|
//# sourceMappingURL=workflow.mjs.map
|