@github-tools/sdk 1.19.0 → 1.20.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.
Files changed (63) hide show
  1. package/README.md +60 -26
  2. package/dist/approval-policy--kByBqhT.mjs +17 -0
  3. package/dist/approval-policy--kByBqhT.mjs.map +1 -0
  4. package/dist/connect/eve.d.mts +2 -2
  5. package/dist/connect/eve.d.mts.map +1 -1
  6. package/dist/connect/eve.mjs +1 -1
  7. package/dist/connect.d.mts +15 -24
  8. package/dist/connect.d.mts.map +1 -1
  9. package/dist/connect.mjs +2 -2
  10. package/dist/{cores-BeLZwcde.mjs → cores-FLzAv2tu.mjs} +23 -2
  11. package/dist/cores-FLzAv2tu.mjs.map +1 -0
  12. package/dist/evaluation-BtoHbxuQ.mjs +311 -0
  13. package/dist/evaluation-BtoHbxuQ.mjs.map +1 -0
  14. package/dist/{eve-runtime-YTxfrWP-.mjs → eve-runtime-C-0doyHq.mjs} +13 -7
  15. package/dist/eve-runtime-C-0doyHq.mjs.map +1 -0
  16. package/dist/{eve-runtime-DRh2QJI7.d.mts → eve-runtime-CflZNuXD.d.mts} +6 -6
  17. package/dist/{eve-runtime-DRh2QJI7.d.mts.map → eve-runtime-CflZNuXD.d.mts.map} +1 -1
  18. package/dist/eve-runtime.d.mts +5 -5
  19. package/dist/eve-runtime.mjs +4 -4
  20. package/dist/eve.d.mts +53 -4
  21. package/dist/eve.d.mts.map +1 -1
  22. package/dist/eve.mjs +52 -3
  23. package/dist/eve.mjs.map +1 -1
  24. package/dist/{index-DkZvveZP.d.mts → index-C3wlz660.d.mts} +91 -347
  25. package/dist/index-C3wlz660.d.mts.map +1 -0
  26. package/dist/index.d.mts +3 -3
  27. package/dist/index.mjs +4 -3
  28. package/dist/{interrupts-C_lUXMdd.d.mts → interrupts-BSDPwdJ2.d.mts} +2 -2
  29. package/dist/interrupts-BSDPwdJ2.d.mts.map +1 -0
  30. package/dist/{src-Bx5p1Unc.mjs → src-DyiAVHKl.mjs} +338 -15
  31. package/dist/src-DyiAVHKl.mjs.map +1 -0
  32. package/dist/tanstack/interrupts.d.mts +1 -1
  33. package/dist/tanstack.d.mts +1214 -56
  34. package/dist/tanstack.d.mts.map +1 -1
  35. package/dist/tanstack.mjs +26 -13
  36. package/dist/tanstack.mjs.map +1 -1
  37. package/dist/{token-Bh8nPj66.mjs → token-DIwB-wtp.mjs} +35 -116
  38. package/dist/token-DIwB-wtp.mjs.map +1 -0
  39. package/dist/{tool-types-CrC80SIL.d.mts → tool-types-OFyE3z0C.d.mts} +283 -54
  40. package/dist/tool-types-OFyE3z0C.d.mts.map +1 -0
  41. package/dist/{types-BmwOpI5-.d.mts → types-CJqhvQwi.d.mts} +3 -3
  42. package/dist/{types-BmwOpI5-.d.mts.map → types-CJqhvQwi.d.mts.map} +1 -1
  43. package/dist/{types-CPAsEMzx.d.mts → types-ITYfXMtY.d.mts} +2 -2
  44. package/dist/{types-CPAsEMzx.d.mts.map → types-ITYfXMtY.d.mts.map} +1 -1
  45. package/dist/workflow.d.mts +34 -40
  46. package/dist/workflow.d.mts.map +1 -1
  47. package/dist/workflow.mjs +17 -46
  48. package/dist/workflow.mjs.map +1 -1
  49. package/dist/{write-tools-BaoTUCg7.mjs → write-tools-DnGZw-RD.mjs} +941 -112
  50. package/dist/write-tools-DnGZw-RD.mjs.map +1 -0
  51. package/package.json +4 -6
  52. package/dist/cores-BeLZwcde.mjs.map +0 -1
  53. package/dist/evaluation-f-2QwBid.mjs +0 -210
  54. package/dist/evaluation-f-2QwBid.mjs.map +0 -1
  55. package/dist/eve-runtime-YTxfrWP-.mjs.map +0 -1
  56. package/dist/index-DkZvveZP.d.mts.map +0 -1
  57. package/dist/instructions-BuypoY0x.mjs +0 -148
  58. package/dist/instructions-BuypoY0x.mjs.map +0 -1
  59. package/dist/interrupts-C_lUXMdd.d.mts.map +0 -1
  60. package/dist/src-Bx5p1Unc.mjs.map +0 -1
  61. package/dist/token-Bh8nPj66.mjs.map +0 -1
  62. package/dist/tool-types-CrC80SIL.d.mts.map +0 -1
  63. package/dist/write-tools-BaoTUCg7.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { C as GithubTokenInput, E as GithubToolPreset, M as GithubWriteToolName, a as GithubToolsContext, j as GithubToolName, o as CommitIdentity } from "./tool-types-CrC80SIL.mjs";
1
+ import { B as GithubToolName, F as GithubToolPreset, V as GithubWriteToolName, a as GithubToolsContext, j as GithubTokenInput, o as CommitIdentity } from "./tool-types-OFyE3z0C.mjs";
2
2
  import { z } from "zod";
3
3
  import { ToolModelOutput } from "eve/tools";
4
4
  import { Approval } from "eve/tools/approval";
@@ -68,4 +68,4 @@ type EveGithubToolsOptions = {
68
68
  type EveToolFactoryOptions = Omit<EveGithubToolsOptions, 'preset' | 'include' | 'exclude'>;
69
69
  //#endregion
70
70
  export { EveToolOverrides as a, EveToolFactoryOptions as i, EveApprovalValue as n, EveGithubToolsOptions as r, EveApprovalConfig as t };
71
- //# sourceMappingURL=types-CPAsEMzx.d.mts.map
71
+ //# sourceMappingURL=types-ITYfXMtY.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-CPAsEMzx.d.mts","names":[],"sources":["../src/eve/types.ts"],"mappings":";;;;;;;;;;;;;KAkBY,2DAKR;KAEQ,8BAER,QAAQ,OAAO,qBAAqB;KAE5B,mBAAmB,QAAQ,OAAO;EAC5C;EACA,WAAW;EACX,iBAAiB,oBAAoB,kBAAkB,QAAQ;;EAE/D,eAAe,EAAE;;KAGP;;EAEV,QAAQ;;;;;;EAMR,SAAS,mBAAmB;;;;;;EAM5B,UAAU;;;;;;EAMV,UAAU;;;;;;EAMV,kBAAkB;;;;;;EAMlB,YAAY;;EAEZ,SAAS;;EAET,YAAY;;EAEZ,YAAY;;;;;EAKZ,UAAU;;KAGA,wBAAwB,KAAK"}
1
+ {"version":3,"file":"types-ITYfXMtY.d.mts","names":[],"sources":["../src/eve/types.ts"],"mappings":";;;;;;;;;;;;;KAkBY,2DAKR;KAEQ,8BAER,QAAQ,OAAO,qBAAqB;KAE5B,mBAAmB,QAAQ,OAAO;EAC5C;EACA,WAAW;EACX,iBAAiB,oBAAoB,kBAAkB,QAAQ;;EAE/D,eAAe,EAAE;;KAGP;;EAEV,QAAQ;;;;;;EAMR,SAAS,mBAAmB;;;;;;EAM5B,UAAU;;;;;;EAMV,UAAU;;;;;;EAMV,kBAAkB;;;;;;EAMlB,YAAY;;EAEZ,SAAS;;EAET,YAAY;;EAEZ,YAAY;;;;;EAKZ,UAAU;;KAGA,wBAAwB,KAAK"}
@@ -1,56 +1,45 @@
1
- import { a as createGithubAgent, i as CreateGithubAgentOptions, n as GithubToolsOptions, r as createGithubTools, t as GithubTools } from "./index-DkZvveZP.mjs";
2
- import { C as GithubTokenInput, D as PRESET_TOOLS, E as GithubToolPreset, M as GithubWriteToolName, O as PresetToolName, T as CombinedPresetToolNames, a as GithubToolsContext, d as ToolOverrides, f as ApprovalConfig, i as PickGithubTools, j as GithubToolName, k as GITHUB_TOOL_NAMES, o as CommitIdentity, p as StaticApprovalConfig, r as GithubToolsForPreset, s as CommitToolOptions, t as AllGithubTools, w as resolveGithubToken, y as GITHUB_WRITE_TOOLS } from "./tool-types-CrC80SIL.mjs";
3
- import { FinishReason, LanguageModel, LanguageModelResponseMetadata, LanguageModelUsage, ModelMessage, StepResult, StopCondition, ToolSet } from "ai";
4
- import { WorkflowAgentOptions, WorkflowAgentStreamOptions, WorkflowAgentStreamResult } from "@ai-sdk/workflow";
1
+ import { B as GithubToolName, E as GITHUB_WRITE_TOOLS, F as GithubToolPreset, I as PRESET_TOOLS, L as PresetToolName, M as resolveGithubToken, P as CombinedPresetToolNames, R as GITHUB_TOOL_NAMES, V as GithubWriteToolName, a as GithubToolsContext, d as ToolOverrides, f as ApprovalConfig, i as PickGithubTools, j as GithubTokenInput, n as GithubToolsBaseOptions, o as CommitIdentity, p as StaticApprovalConfig, r as GithubToolsForPreset, s as CommitToolOptions, t as AllGithubTools } from "./tool-types-OFyE3z0C.mjs";
2
+ import { Gt as CreateGithubAgentOptions, Kt as createGithubAgent, n as GithubToolsOptions, r as createGithubTools, t as GithubTools } from "./index-C3wlz660.mjs";
3
+ import { LanguageModel, Output, ToolSet } from "ai";
4
+ import { WorkflowAgent, WorkflowAgentOptions, WorkflowAgentStreamOptions, WorkflowAgentStreamResult } from "@ai-sdk/workflow";
5
5
  import { Context } from "@ai-sdk/provider-utils";
6
6
  //#region src/workflow.d.ts
7
+ type WorkflowGenerate<TTools extends ToolSet> = WorkflowAgent<TTools> extends {
8
+ generate: infer Generate;
9
+ } ? Generate : never;
10
+ /** Options of {@link DurableGithubAgent.generate}: those of `WorkflowAgent.generate()`. */
11
+ export type DurableGithubAgentGenerateOptions<TTools extends ToolSet = ToolSet> = WorkflowGenerate<TTools> extends ((options: infer Options) => unknown) ? Options : never;
7
12
  /**
8
- * Result of {@link DurableGithubAgent.generate}.
13
+ * Result of {@link DurableGithubAgent.generate}: the `WorkflowAgent` generation result. Read the
14
+ * fields you need inside the workflow and return those, since the result itself is not serializable.
9
15
  */
10
- export 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
- }
16
+ export type DurableGithubAgentGenerateResult<TTools extends ToolSet = ToolSet> = WorkflowGenerate<TTools> extends ((options: never) => Promise<infer Result>) ? Result : never;
19
17
  /**
20
- * A wrapper around {@link WorkflowAgent} that adds a non-streaming
21
- * `.generate()` method alongside the existing `.stream()`.
18
+ * A GitHub agent built on {@link WorkflowAgent}. Call both methods from a `"use workflow"`
19
+ * function: each model call and each tool call runs as its own retriable workflow step, and
20
+ * tools with `needsApproval` pause the run until the user answers.
22
21
  *
23
- * - `.stream()` — delegates to `WorkflowAgent.stream()`. Each tool call is
24
- * an individually retriable workflow step. Supports `needsApproval` on tools.
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).
22
+ * - `.stream()` writes the response to a `writable` for chat UIs.
23
+ * - `.generate()` returns the finished result, for bots, webhooks, and background jobs.
28
24
  */
29
25
  export declare class DurableGithubAgent<TTools extends ToolSet = ToolSet> {
30
26
  private agent;
31
- private _model;
32
- private _instructions?;
33
- private _telemetry?;
34
- private _tools;
35
27
  constructor(options: WorkflowAgentOptions<TTools>);
36
28
  /** The tool set configured for this agent. */
37
29
  get tools(): TTools;
38
- /**
39
- * Stream the agent's response. Delegates directly to `WorkflowAgent.stream()`.
40
- * Works in workflow context — each tool call is a durable step.
41
- */
30
+ /** Stream the agent's response. Delegates to `WorkflowAgent.stream()`. */
42
31
  stream<TStreamTools extends TTools = TTools, OUTPUT = never, PARTIAL_OUTPUT = never>(options: WorkflowAgentStreamOptions<TStreamTools, Context, OUTPUT, PARTIAL_OUTPUT>): Promise<WorkflowAgentStreamResult<TStreamTools, OUTPUT>>;
43
32
  /**
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.
33
+ * Generate the full response without streaming. Delegates to `WorkflowAgent.generate()`, which
34
+ * needs `@ai-sdk/workflow` 2.0.59 or later. Stops after 20 steps unless `stopWhen` says otherwise.
35
+ * A write that needs approval ends the call with a `tool-approval-request` in
36
+ * `responseMessages`; append the user's `tool-approval-response` and call `generate()` again.
49
37
  */
50
- generate({ prompt, stopWhen }: {
51
- prompt: string;
52
- stopWhen?: StopCondition<TTools> | Array<StopCondition<TTools>>;
53
- }): Promise<DurableGithubAgentGenerateResult<TTools>>;
38
+ generate<OUTPUT = string>(options: DurableGithubAgentGenerateOptions<TTools> & {
39
+ output?: Output.Output<OUTPUT>;
40
+ }): Promise<Omit<DurableGithubAgentGenerateResult<TTools>, 'output'> & {
41
+ readonly output: OUTPUT;
42
+ }>;
54
43
  }
55
44
  /**
56
45
  * Options for creating a durable GitHub agent via {@link createDurableGithubAgent}.
@@ -68,8 +57,8 @@ export type CreateDurableGithubAgentOptions = Omit<WorkflowAgentOptions, 'model'
68
57
  /**
69
58
  * Restrict tools and system prompt to a predefined preset.
70
59
  *
71
- * Selects a subset of tools and, when a single preset is passed,
72
- * sets a matching system prompt. Combine presets with an array to merge tool sets.
60
+ * Selects a subset of tools and sets the preset's system prompt. Combine presets with an array
61
+ * to merge their tool sets and system prompts.
73
62
  *
74
63
  * @see {@link GithubToolPreset} for available presets and included tools.
75
64
  */
@@ -82,6 +71,11 @@ export type CreateDurableGithubAgentOptions = Omit<WorkflowAgentOptions, 'model'
82
71
  * @see {@link StaticApprovalConfig} for global and per-tool options.
83
72
  */
84
73
  requireApproval?: StaticApprovalConfig;
74
+ /**
75
+ * Per-tool overrides (`description`, `title`, `needsApproval`, …), as on `createGithubTools`.
76
+ * `execute`, `inputSchema`, and `outputSchema` cannot be overridden.
77
+ */
78
+ overrides?: GithubToolsBaseOptions['overrides'];
85
79
  /**
86
80
  * Fully replace the default system prompt.
87
81
  * When set, `preset` system prompts and `additionalInstructions` are ignored.
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/workflow.ts"],"mappings":";;;;;;;;;iBA+BiB,iCAAiC,eAAe,UAAU;EACzE;EACA,cAAc;EACd,OAAO;EACP,OAAO,WAAW;EAClB,UAAU;IAAkC,UAAU;;;;;;;;;;;;;qBAa3C,mBAAmB,eAAe,UAAU;UAC/C;UACA;UACA;UACA;UACA;EAEI,YAAA,SAAS,qBAAqB;;MAStC,SAAS;;;;;EAQb,OAAO,qBAAqB,SAAS,QAAQ,gBAAgB,wBAC3D,SAAS,2BAA2B,cAAc,SAAS,QAAQ,kBAClE,QAAQ,0BAA0B,cAAc;;;;;;;;EAW7C,WAAW,QAAQ;IAAc;IAAgB,WAAW,cAAc,UAAU,MAAM,cAAc;MAAa,QAAQ,iCAAiC;;;;;;;;YA8B1J,kCACV,KAAK;EACH,gBAAgB;;;;;EAKhB,QAAQ;;;;;;;;;EASR,SAAS,mBAAmB;;;;;;;;EAQ5B,kBAAkB;;;;;EAKlB;;;;;EAKA;;;;EAIA,UAAU;;;;;EAKV,SAAS;;;;;EAKT,YAAY;;;;;EAKZ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiCA,yBACd,SAAS;EAAoC;IAC5C,mBAAmB;wBACN,yBAAyB,UAAU,kBACjD,SAAS;EAAoC,QAAQ;IACpD,mBAAmB,KAAK,gBAAgB,eAAe;wBAC1C,yBAAyB,mBAAmB,oBAC1D,SAAS;EAAoC,QAAQ;IACpD,mBAAmB,KAAK,gBAAgB,wBAAwB"}
1
+ {"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/workflow.ts"],"mappings":";;;;;;KAuBK,iBAAiB,eAAe,WAAW,cAAc;EAAkB,gBAAgB;IAAa;;YAGjG,kCAAkC,eAAe,UAAU,WAAW,iBAAiB,kBAAiB,eAAe,uBAAsB;;;;;YAM7I,iCAAiC,eAAe,UAAU,WAAW,iBAAiB,kBAAiB,mBAAmB,cAAc,WAAU;;;;;;;;;qBAUjJ,mBAAmB,eAAe,UAAU;UAC/C;EAEI,YAAA,SAAS,qBAAqB;;MAKtC,SAAS;;EAKb,OAAO,qBAAqB,SAAS,QAAQ,gBAAgB,wBAC3D,SAAS,2BAA2B,cAAc,SAAS,QAAQ,kBAClE,QAAQ,0BAA0B,cAAc;;;;;;;EAUnD,SAAS,iBACP,SAAS,kCAAkC;IAAY,SAAS,OAAO,OAAO;MAC7E,QAAQ,KAAK,iCAAiC;aAAgC,QAAQ;;;;;;;;;YAY/E,kCACV,KAAK;EACH,gBAAgB;;;;;EAKhB,QAAQ;;;;;;;;;EASR,SAAS,mBAAmB;;;;;;;;EAQ5B,kBAAkB;;;;;EAKlB,YAAY;;;;;EAKZ;;;;;EAKA;;;;EAIA,UAAU;;;;;EAKV,SAAS;;;;;EAKT,YAAY;;;;;EAKZ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiCA,yBACd,SAAS;EAAoC;IAC5C,mBAAmB;wBACN,yBAAyB,UAAU,kBACjD,SAAS;EAAoC,QAAQ;IACpD,mBAAmB,KAAK,gBAAgB,eAAe;wBAC1C,yBAAyB,mBAAmB,oBAC1D,SAAS;EAAoC,QAAQ;IACpD,mBAAmB,KAAK,gBAAgB,wBAAwB"}
package/dist/workflow.mjs CHANGED
@@ -1,74 +1,45 @@
1
- import { m as PRESET_TOOLS, n as GITHUB_TOOL_NAMES, t as GITHUB_WRITE_TOOLS, v as resolveGithubToken } from "./write-tools-BaoTUCg7.mjs";
2
- import { n as createGithubAgent, t as createGithubTools } from "./src-Bx5p1Unc.mjs";
3
- import { t as resolveInstructions } from "./instructions-BuypoY0x.mjs";
1
+ import { Aa as githubToolsErrors, _ as PRESET_TOOLS, h as GITHUB_TOOL_NAMES, n as resolveInstructions, t as GITHUB_WRITE_TOOLS, x as resolveGithubToken } from "./write-tools-DnGZw-RD.mjs";
2
+ import { r as createGithubAgent, t as createGithubTools } from "./src-DyiAVHKl.mjs";
4
3
  import { WorkflowAgent } from "@ai-sdk/workflow";
5
4
  //#region src/workflow.ts
6
5
  /**
7
- * A wrapper around {@link WorkflowAgent} that adds a non-streaming
8
- * `.generate()` method alongside the existing `.stream()`.
6
+ * A GitHub agent built on {@link WorkflowAgent}. Call both methods from a `"use workflow"`
7
+ * function: each model call and each tool call runs as its own retriable workflow step, and
8
+ * tools with `needsApproval` pause the run until the user answers.
9
9
  *
10
- * - `.stream()` — delegates to `WorkflowAgent.stream()`. Each tool call is
11
- * an individually retriable workflow step. Supports `needsApproval` on tools.
12
- * - `.generate()` — uses `generateText` from the AI SDK for non-streaming
13
- * execution. Must be called from within a `"use step"` function in
14
- * workflow context (the Workflow runtime blocks raw I/O in workflow scope).
10
+ * - `.stream()` writes the response to a `writable` for chat UIs.
11
+ * - `.generate()` returns the finished result, for bots, webhooks, and background jobs.
15
12
  */
16
13
  var DurableGithubAgent = class {
17
14
  agent;
18
- _model;
19
- _instructions;
20
- _telemetry;
21
- _tools;
22
15
  constructor(options) {
23
16
  this.agent = new WorkflowAgent(options);
24
- this._model = options.model;
25
- this._instructions = typeof options.instructions === "string" ? options.instructions : void 0;
26
- this._telemetry = options.telemetry;
27
- this._tools = options.tools ?? {};
28
17
  }
29
18
  /** The tool set configured for this agent. */
30
19
  get tools() {
31
20
  return this.agent.tools;
32
21
  }
33
- /**
34
- * Stream the agent's response. Delegates directly to `WorkflowAgent.stream()`.
35
- * Works in workflow context — each tool call is a durable step.
36
- */
22
+ /** Stream the agent's response. Delegates to `WorkflowAgent.stream()`. */
37
23
  stream(options) {
38
24
  return this.agent.stream(options);
39
25
  }
40
26
  /**
41
- * Generate a non-streaming response using `generateText` from the AI SDK.
42
- *
43
- * In workflow context this **must** be called from within a `"use step"`
44
- * function, because the Workflow runtime blocks direct I/O (HTTP calls)
45
- * at the workflow scope level.
27
+ * Generate the full response without streaming. Delegates to `WorkflowAgent.generate()`, which
28
+ * needs `@ai-sdk/workflow` 2.0.59 or later. Stops after 20 steps unless `stopWhen` says otherwise.
29
+ * A write that needs approval ends the call with a `tool-approval-request` in
30
+ * `responseMessages`; append the user's `tool-approval-response` and call `generate()` again.
46
31
  */
47
- async generate({ prompt, stopWhen }) {
48
- const { generateText } = await import("ai");
49
- const system = this._instructions;
50
- const result = await generateText({
51
- model: this._model,
52
- tools: this._tools,
53
- system,
54
- prompt,
55
- stopWhen,
56
- experimental_telemetry: this._telemetry
57
- });
58
- return {
59
- text: result.text,
60
- finishReason: result.finishReason,
61
- usage: result.usage,
62
- steps: result.steps,
63
- response: result.response
64
- };
32
+ generate(options) {
33
+ if (typeof this.agent.generate !== "function") throw githubToolsErrors.DURABLE_GENERATE_UNAVAILABLE();
34
+ return this.agent.generate(options);
65
35
  }
66
36
  };
67
- function createDurableGithubAgent({ model, token, preset, requireApproval, context, instructions, additionalInstructions, author, committer, coAuthors, ...agentOptions }) {
37
+ function createDurableGithubAgent({ model, token, preset, requireApproval, overrides, context, instructions, additionalInstructions, author, committer, coAuthors, ...agentOptions }) {
68
38
  const tools = createGithubTools({
69
39
  token,
70
40
  requireApproval,
71
41
  preset,
42
+ overrides,
72
43
  context,
73
44
  author,
74
45
  committer,
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.mjs","names":[],"sources":["../src/workflow.ts"],"sourcesContent":["import { WorkflowAgent } from '@ai-sdk/workflow'\nimport type {\n WorkflowAgentOptions,\n WorkflowAgentStreamOptions,\n WorkflowAgentStreamResult,\n TelemetryOptions,\n} from '@ai-sdk/workflow'\nimport type {\n LanguageModel,\n ToolSet,\n StepResult,\n FinishReason,\n LanguageModelUsage,\n LanguageModelResponseMetadata,\n ModelMessage,\n StopCondition,\n} from 'ai'\nimport { createGithubTools } from './index'\nimport { resolveInstructions } from './agents'\nimport type { AllGithubTools } from './core/tool-types'\nimport type { CombinedPresetToolNames, GithubToolPreset, PresetToolName } from './core/presets'\nimport type { GithubToolName } from './core/tool-names'\nimport type { StaticApprovalConfig } from './index'\nimport type { CommitIdentity } from './types'\nimport type { GithubTokenInput } from './core/token'\nimport type { GithubToolsContext } from './core/context'\nimport type { Context } from '@ai-sdk/provider-utils'\n\n/**\n * Result of {@link DurableGithubAgent.generate}.\n */\nexport interface DurableGithubAgentGenerateResult<TTools extends ToolSet = ToolSet> {\n text: string\n finishReason: FinishReason\n usage: LanguageModelUsage\n steps: StepResult<TTools>[]\n response: LanguageModelResponseMetadata & { messages: ModelMessage[] }\n}\n\n/**\n * A wrapper around {@link WorkflowAgent} that adds a non-streaming\n * `.generate()` method alongside the existing `.stream()`.\n *\n * - `.stream()` — delegates to `WorkflowAgent.stream()`. Each tool call is\n * an individually retriable workflow step. Supports `needsApproval` on tools.\n * - `.generate()` — uses `generateText` from the AI SDK for non-streaming\n * execution. Must be called from within a `\"use step\"` function in\n * workflow context (the Workflow runtime blocks raw I/O in workflow scope).\n */\nexport class DurableGithubAgent<TTools extends ToolSet = ToolSet> {\n private agent: WorkflowAgent<TTools>\n private _model: LanguageModel\n private _instructions?: string\n private _telemetry?: TelemetryOptions\n private _tools: TTools\n\n constructor(options: WorkflowAgentOptions<TTools>) {\n this.agent = new WorkflowAgent(options)\n this._model = options.model\n this._instructions = typeof options.instructions === 'string' ? options.instructions : undefined\n this._telemetry = options.telemetry\n this._tools = options.tools ?? {} as TTools\n }\n\n /** The tool set configured for this agent. */\n get tools(): TTools {\n return this.agent.tools\n }\n\n /**\n * Stream the agent's response. Delegates directly to `WorkflowAgent.stream()`.\n * Works in workflow context — each tool call is a durable step.\n */\n stream<TStreamTools extends TTools = TTools, OUTPUT = never, PARTIAL_OUTPUT = never>(\n options: WorkflowAgentStreamOptions<TStreamTools, Context, OUTPUT, PARTIAL_OUTPUT>,\n ): Promise<WorkflowAgentStreamResult<TStreamTools, OUTPUT>> {\n return this.agent.stream(options)\n }\n\n /**\n * Generate a non-streaming response using `generateText` from the AI SDK.\n *\n * In workflow context this **must** be called from within a `\"use step\"`\n * function, because the Workflow runtime blocks direct I/O (HTTP calls)\n * at the workflow scope level.\n */\n async generate({ prompt, stopWhen }: { prompt: string, stopWhen?: StopCondition<TTools> | Array<StopCondition<TTools>> }): Promise<DurableGithubAgentGenerateResult<TTools>> {\n const { generateText } = await import('ai')\n\n const system = this._instructions\n\n const result = await generateText({\n model: this._model,\n tools: this._tools,\n system,\n prompt,\n stopWhen,\n experimental_telemetry: this._telemetry as Parameters<typeof generateText>[0]['experimental_telemetry'],\n })\n\n return {\n text: result.text,\n finishReason: result.finishReason,\n usage: result.usage,\n steps: result.steps as StepResult<TTools>[],\n response: result.response,\n }\n }\n}\n\n/**\n * Options for creating a durable GitHub agent via {@link createDurableGithubAgent}.\n *\n * Extends all `WorkflowAgentOptions` (temperature, telemetry, callbacks, etc.)\n * and adds GitHub-specific fields (token, preset, approval config).\n */\nexport type CreateDurableGithubAgentOptions =\n Omit<WorkflowAgentOptions, 'model' | 'tools' | 'instructions'> & {\n model: string | LanguageModel\n /**\n * GitHub personal access token or async token provider.\n * Falls back to `process.env.GITHUB_TOKEN` when omitted.\n */\n token?: GithubTokenInput\n /**\n * Restrict tools and system prompt to a predefined preset.\n *\n * Selects a subset of tools and, when a single preset is passed,\n * sets a matching system prompt. Combine presets with an array to merge tool sets.\n *\n * @see {@link GithubToolPreset} for available presets and included tools.\n */\n preset?: GithubToolPreset | GithubToolPreset[]\n /**\n * Control whether write operations require user approval before execution.\n *\n * `'auto'` is not supported: the evaluation call cannot run inside a workflow function.\n *\n * @see {@link StaticApprovalConfig} for global and per-tool options.\n */\n requireApproval?: StaticApprovalConfig\n /**\n * Fully replace the default system prompt.\n * When set, `preset` system prompts and `additionalInstructions` are ignored.\n */\n instructions?: string\n /**\n * Append text to the preset-specific (or default) system prompt.\n * Ignored when `instructions` is set.\n */\n additionalInstructions?: string\n /**\n * Default owner / repo / PR / issue / ref values for tools and the system prompt.\n */\n context?: GithubToolsContext\n /**\n * Default author for commit-creating tools.\n * Falls back to the authenticated user when omitted.\n */\n author?: CommitIdentity\n /**\n * Default committer for commit-creating tools.\n * Falls back to the authenticated user when omitted.\n */\n committer?: CommitIdentity\n /**\n * Co-authors to attribute on all commits.\n * Added as \"Co-authored-by\" trailers to commit messages.\n */\n coAuthors?: CommitIdentity[]\n }\n\n/**\n * Create a pre-configured durable GitHub agent powered by `WorkflowAgent`\n * from `@ai-sdk/workflow`.\n *\n * Returns a {@link DurableGithubAgent} with two interaction modes:\n *\n * - `.stream()` — works directly in workflow scope; each tool call is a durable step.\n * Write tools honor `requireApproval` via `needsApproval` and pause the workflow\n * until the user approves or denies.\n * - `.generate()` — uses `generateText` from the AI SDK; must be called from\n * within a `\"use step\"` function when running inside a workflow.\n *\n * @example Streaming (chat UI — works in workflow scope)\n * ```ts\n * import { createDurableGithubAgent } from '@github-tools/sdk/workflow'\n * import { getWritable } from 'workflow'\n * import type { ModelMessage, ModelCallStreamPart } from 'ai'\n *\n * async function chatWorkflow(messages: ModelMessage[], token: string) {\n * \"use workflow\"\n * const agent = createDurableGithubAgent({\n * model: 'anthropic/claude-opus-5.5',\n * token,\n * preset: 'code-review',\n * })\n * const writable = getWritable<ModelCallStreamPart>()\n * await agent.stream({ messages, writable })\n * }\n * ```\n */\nexport function createDurableGithubAgent(\n options: CreateDurableGithubAgentOptions & { preset?: undefined },\n): DurableGithubAgent<AllGithubTools>\nexport function createDurableGithubAgent<P extends GithubToolPreset>(\n options: CreateDurableGithubAgentOptions & { preset: P },\n): DurableGithubAgent<Pick<AllGithubTools, PresetToolName<P>>>\nexport function createDurableGithubAgent<P extends readonly GithubToolPreset[]>(\n options: CreateDurableGithubAgentOptions & { preset: P },\n): DurableGithubAgent<Pick<AllGithubTools, CombinedPresetToolNames<P>>>\nexport function createDurableGithubAgent({\n model,\n token,\n preset,\n requireApproval,\n context,\n instructions,\n additionalInstructions,\n author,\n committer,\n coAuthors,\n ...agentOptions\n}: CreateDurableGithubAgentOptions): DurableGithubAgent<AllGithubTools | Pick<AllGithubTools, GithubToolName>> {\n const tools = createGithubTools({ token, requireApproval, preset, context, author, committer, coAuthors })\n\n return new DurableGithubAgent({\n ...agentOptions,\n model,\n tools,\n instructions: resolveInstructions({ preset, instructions, additionalInstructions, context }),\n }) as DurableGithubAgent<typeof tools>\n}\n\nexport { createGithubTools, createGithubAgent } from './index'\nexport type { CommitIdentity, CommitToolOptions, GithubTools, GithubToolsOptions, GithubToolPreset, GithubToolName, GithubWriteToolName, ApprovalConfig, ToolOverrides, AllGithubTools, PresetToolName, CombinedPresetToolNames, GithubToolsForPreset, PickGithubTools, GithubTokenInput, GithubToolsContext } from './index'\nexport { PRESET_TOOLS, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, resolveGithubToken } from './index'\nexport type { CreateGithubAgentOptions } from './agents'\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,IAAa,qBAAb,MAAkE;CAChE;CACA;CACA;CACA;CACA;CAEA,YAAY,SAAuC;EACjD,KAAK,QAAQ,IAAI,cAAc,OAAO;EACtC,KAAK,SAAS,QAAQ;EACtB,KAAK,gBAAgB,OAAO,QAAQ,iBAAiB,WAAW,QAAQ,eAAe,KAAA;EACvF,KAAK,aAAa,QAAQ;EAC1B,KAAK,SAAS,QAAQ,SAAS,CAAC;CAClC;;CAGA,IAAI,QAAgB;EAClB,OAAO,KAAK,MAAM;CACpB;;;;;CAMA,OACE,SAC0D;EAC1D,OAAO,KAAK,MAAM,OAAO,OAAO;CAClC;;;;;;;;CASA,MAAM,SAAS,EAAE,QAAQ,YAAoJ;EAC3K,MAAM,EAAE,iBAAiB,MAAM,OAAO;EAEtC,MAAM,SAAS,KAAK;EAEpB,MAAM,SAAS,MAAM,aAAa;GAChC,OAAO,KAAK;GACZ,OAAO,KAAK;GACZ;GACA;GACA;GACA,wBAAwB,KAAK;EAC/B,CAAC;EAED,OAAO;GACL,MAAM,OAAO;GACb,cAAc,OAAO;GACrB,OAAO,OAAO;GACd,OAAO,OAAO;GACd,UAAU,OAAO;EACnB;CACF;AACF;AAuGA,SAAgB,yBAAyB,EACvC,OACA,OACA,QACA,iBACA,SACA,cACA,wBACA,QACA,WACA,WACA,GAAG,gBAC0G;CAC7G,MAAM,QAAQ,kBAAkB;EAAE;EAAO;EAAiB;EAAQ;EAAS;EAAQ;EAAW;CAAU,CAAC;CAEzG,OAAO,IAAI,mBAAmB;EAC5B,GAAG;EACH;EACA;EACA,cAAc,oBAAoB;GAAE;GAAQ;GAAc;GAAwB;EAAQ,CAAC;CAC7F,CAAC;AACH"}
1
+ {"version":3,"file":"workflow.mjs","names":[],"sources":["../src/workflow.ts"],"sourcesContent":["import { WorkflowAgent } from '@ai-sdk/workflow'\nimport type {\n WorkflowAgentOptions,\n WorkflowAgentStreamOptions,\n WorkflowAgentStreamResult,\n} from '@ai-sdk/workflow'\nimport type { LanguageModel, Output, ToolSet } from 'ai'\nimport { createGithubTools } from './index'\nimport { resolveInstructions } from './agents'\nimport { githubToolsErrors } from './core/errors'\nimport type { AllGithubTools } from './core/tool-types'\nimport type { CombinedPresetToolNames, GithubToolPreset, PresetToolName } from './core/presets'\nimport type { GithubToolName } from './core/tool-names'\nimport type { GithubToolsBaseOptions } from './core/tool-types'\nimport type { StaticApprovalConfig } from './index'\nimport type { CommitIdentity } from './types'\nimport type { GithubTokenInput } from './core/token'\nimport type { GithubToolsContext } from './core/context'\nimport type { Context } from '@ai-sdk/provider-utils'\n\n// Read from `WorkflowAgent` instead of importing `WorkflowAgentGenerateOptions` and\n// `WorkflowAgentGenerateResult`, which `@ai-sdk/workflow` only exports from 2.0.59: importing them\n// would break type checking for `.stream()` users on older supported versions.\ntype WorkflowGenerate<TTools extends ToolSet> = WorkflowAgent<TTools> extends { generate: infer Generate } ? Generate : never\n\n/** Options of {@link DurableGithubAgent.generate}: those of `WorkflowAgent.generate()`. */\nexport type DurableGithubAgentGenerateOptions<TTools extends ToolSet = ToolSet> = WorkflowGenerate<TTools> extends (options: infer Options) => unknown ? Options : never\n\n/**\n * Result of {@link DurableGithubAgent.generate}: the `WorkflowAgent` generation result. Read the\n * fields you need inside the workflow and return those, since the result itself is not serializable.\n */\nexport type DurableGithubAgentGenerateResult<TTools extends ToolSet = ToolSet> = WorkflowGenerate<TTools> extends (options: never) => Promise<infer Result> ? Result : never\n\n/**\n * A GitHub agent built on {@link WorkflowAgent}. Call both methods from a `\"use workflow\"`\n * function: each model call and each tool call runs as its own retriable workflow step, and\n * tools with `needsApproval` pause the run until the user answers.\n *\n * - `.stream()` writes the response to a `writable` for chat UIs.\n * - `.generate()` returns the finished result, for bots, webhooks, and background jobs.\n */\nexport class DurableGithubAgent<TTools extends ToolSet = ToolSet> {\n private agent: WorkflowAgent<TTools>\n\n constructor(options: WorkflowAgentOptions<TTools>) {\n this.agent = new WorkflowAgent(options)\n }\n\n /** The tool set configured for this agent. */\n get tools(): TTools {\n return this.agent.tools\n }\n\n /** Stream the agent's response. Delegates to `WorkflowAgent.stream()`. */\n stream<TStreamTools extends TTools = TTools, OUTPUT = never, PARTIAL_OUTPUT = never>(\n options: WorkflowAgentStreamOptions<TStreamTools, Context, OUTPUT, PARTIAL_OUTPUT>,\n ): Promise<WorkflowAgentStreamResult<TStreamTools, OUTPUT>> {\n return this.agent.stream(options)\n }\n\n /**\n * Generate the full response without streaming. Delegates to `WorkflowAgent.generate()`, which\n * needs `@ai-sdk/workflow` 2.0.59 or later. Stops after 20 steps unless `stopWhen` says otherwise.\n * A write that needs approval ends the call with a `tool-approval-request` in\n * `responseMessages`; append the user's `tool-approval-response` and call `generate()` again.\n */\n generate<OUTPUT = string>(\n options: DurableGithubAgentGenerateOptions<TTools> & { output?: Output.Output<OUTPUT> },\n ): Promise<Omit<DurableGithubAgentGenerateResult<TTools>, 'output'> & { readonly output: OUTPUT }> {\n if (typeof this.agent.generate !== 'function') throw githubToolsErrors.DURABLE_GENERATE_UNAVAILABLE()\n return this.agent.generate(options)\n }\n}\n\n/**\n * Options for creating a durable GitHub agent via {@link createDurableGithubAgent}.\n *\n * Extends all `WorkflowAgentOptions` (temperature, telemetry, callbacks, etc.)\n * and adds GitHub-specific fields (token, preset, approval config).\n */\nexport type CreateDurableGithubAgentOptions =\n Omit<WorkflowAgentOptions, 'model' | 'tools' | 'instructions'> & {\n model: string | LanguageModel\n /**\n * GitHub personal access token or async token provider.\n * Falls back to `process.env.GITHUB_TOKEN` when omitted.\n */\n token?: GithubTokenInput\n /**\n * Restrict tools and system prompt to a predefined preset.\n *\n * Selects a subset of tools and sets the preset's system prompt. Combine presets with an array\n * to merge their tool sets and system prompts.\n *\n * @see {@link GithubToolPreset} for available presets and included tools.\n */\n preset?: GithubToolPreset | GithubToolPreset[]\n /**\n * Control whether write operations require user approval before execution.\n *\n * `'auto'` is not supported: the evaluation call cannot run inside a workflow function.\n *\n * @see {@link StaticApprovalConfig} for global and per-tool options.\n */\n requireApproval?: StaticApprovalConfig\n /**\n * Per-tool overrides (`description`, `title`, `needsApproval`, …), as on `createGithubTools`.\n * `execute`, `inputSchema`, and `outputSchema` cannot be overridden.\n */\n overrides?: GithubToolsBaseOptions['overrides']\n /**\n * Fully replace the default system prompt.\n * When set, `preset` system prompts and `additionalInstructions` are ignored.\n */\n instructions?: string\n /**\n * Append text to the preset-specific (or default) system prompt.\n * Ignored when `instructions` is set.\n */\n additionalInstructions?: string\n /**\n * Default owner / repo / PR / issue / ref values for tools and the system prompt.\n */\n context?: GithubToolsContext\n /**\n * Default author for commit-creating tools.\n * Falls back to the authenticated user when omitted.\n */\n author?: CommitIdentity\n /**\n * Default committer for commit-creating tools.\n * Falls back to the authenticated user when omitted.\n */\n committer?: CommitIdentity\n /**\n * Co-authors to attribute on all commits.\n * Added as \"Co-authored-by\" trailers to commit messages.\n */\n coAuthors?: CommitIdentity[]\n }\n\n/**\n * Create a pre-configured durable GitHub agent powered by `WorkflowAgent`\n * from `@ai-sdk/workflow`.\n *\n * Returns a {@link DurableGithubAgent} with two interaction modes:\n *\n * - `.stream()` — works directly in workflow scope; each tool call is a durable step.\n * Write tools honor `requireApproval` via `needsApproval` and pause the workflow\n * until the user approves or denies.\n * - `.generate()` — uses `generateText` from the AI SDK; must be called from\n * within a `\"use step\"` function when running inside a workflow.\n *\n * @example Streaming (chat UI — works in workflow scope)\n * ```ts\n * import { createDurableGithubAgent } from '@github-tools/sdk/workflow'\n * import { getWritable } from 'workflow'\n * import type { ModelMessage, ModelCallStreamPart } from 'ai'\n *\n * async function chatWorkflow(messages: ModelMessage[], token: string) {\n * \"use workflow\"\n * const agent = createDurableGithubAgent({\n * model: 'anthropic/claude-opus-5.5',\n * token,\n * preset: 'code-review',\n * })\n * const writable = getWritable<ModelCallStreamPart>()\n * await agent.stream({ messages, writable })\n * }\n * ```\n */\nexport function createDurableGithubAgent(\n options: CreateDurableGithubAgentOptions & { preset?: undefined },\n): DurableGithubAgent<AllGithubTools>\nexport function createDurableGithubAgent<P extends GithubToolPreset>(\n options: CreateDurableGithubAgentOptions & { preset: P },\n): DurableGithubAgent<Pick<AllGithubTools, PresetToolName<P>>>\nexport function createDurableGithubAgent<P extends readonly GithubToolPreset[]>(\n options: CreateDurableGithubAgentOptions & { preset: P },\n): DurableGithubAgent<Pick<AllGithubTools, CombinedPresetToolNames<P>>>\nexport function createDurableGithubAgent({\n model,\n token,\n preset,\n requireApproval,\n overrides,\n context,\n instructions,\n additionalInstructions,\n author,\n committer,\n coAuthors,\n ...agentOptions\n}: CreateDurableGithubAgentOptions): DurableGithubAgent<AllGithubTools | Pick<AllGithubTools, GithubToolName>> {\n const tools = createGithubTools({ token, requireApproval, preset, overrides, context, author, committer, coAuthors })\n\n return new DurableGithubAgent({\n ...agentOptions,\n model,\n tools,\n instructions: resolveInstructions({ preset, instructions, additionalInstructions, context }),\n }) as DurableGithubAgent<typeof tools>\n}\n\nexport { createGithubTools, createGithubAgent } from './index'\nexport type { CommitIdentity, CommitToolOptions, GithubTools, GithubToolsOptions, GithubToolPreset, GithubToolName, GithubWriteToolName, ApprovalConfig, ToolOverrides, AllGithubTools, PresetToolName, CombinedPresetToolNames, GithubToolsForPreset, PickGithubTools, GithubTokenInput, GithubToolsContext } from './index'\nexport { PRESET_TOOLS, GITHUB_TOOL_NAMES, GITHUB_WRITE_TOOLS, resolveGithubToken } from './index'\nexport type { CreateGithubAgentOptions } from './agents'\n"],"mappings":";;;;;;;;;;;;AA0CA,IAAa,qBAAb,MAAkE;CAChE;CAEA,YAAY,SAAuC;EACjD,KAAK,QAAQ,IAAI,cAAc,OAAO;CACxC;;CAGA,IAAI,QAAgB;EAClB,OAAO,KAAK,MAAM;CACpB;;CAGA,OACE,SAC0D;EAC1D,OAAO,KAAK,MAAM,OAAO,OAAO;CAClC;;;;;;;CAQA,SACE,SACiG;EACjG,IAAI,OAAO,KAAK,MAAM,aAAa,YAAY,MAAM,kBAAkB,6BAA6B;EACpG,OAAO,KAAK,MAAM,SAAS,OAAO;CACpC;AACF;AA4GA,SAAgB,yBAAyB,EACvC,OACA,OACA,QACA,iBACA,WACA,SACA,cACA,wBACA,QACA,WACA,WACA,GAAG,gBAC0G;CAC7G,MAAM,QAAQ,kBAAkB;EAAE;EAAO;EAAiB;EAAQ;EAAW;EAAS;EAAQ;EAAW;CAAU,CAAC;CAEpH,OAAO,IAAI,mBAAmB;EAC5B,GAAG;EACH;EACA;EACA,cAAc,oBAAoB;GAAE;GAAQ;GAAc;GAAwB;EAAQ,CAAC;CAC7F,CAAC;AACH"}