@github-tools/sdk 1.20.0 → 1.21.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 (55) hide show
  1. package/README.md +45 -12
  2. package/dist/{approval-policy--kByBqhT.mjs → approval-policy-CEMMPq92.mjs} +2 -2
  3. package/dist/{approval-policy--kByBqhT.mjs.map → approval-policy-CEMMPq92.mjs.map} +1 -1
  4. package/dist/connect/eve.d.mts +1 -1
  5. package/dist/connect/eve.mjs +1 -1
  6. package/dist/connect.d.mts +5 -5
  7. package/dist/connect.d.mts.map +1 -1
  8. package/dist/connect.mjs +2 -2
  9. package/dist/{cores-FLzAv2tu.mjs → cores-meFAMt2D.mjs} +20 -2
  10. package/dist/cores-meFAMt2D.mjs.map +1 -0
  11. package/dist/{tool-types-OFyE3z0C.d.mts → dry-run-DXckOam2.d.mts} +172 -18
  12. package/dist/dry-run-DXckOam2.d.mts.map +1 -0
  13. package/dist/{evaluation-BtoHbxuQ.mjs → evaluation-DJHINyAu.mjs} +2 -2
  14. package/dist/{evaluation-BtoHbxuQ.mjs.map → evaluation-DJHINyAu.mjs.map} +1 -1
  15. package/dist/{eve-runtime-CflZNuXD.d.mts → eve-runtime-B_CJE9JV.d.mts} +20 -6
  16. package/dist/eve-runtime-B_CJE9JV.d.mts.map +1 -0
  17. package/dist/{eve-runtime-C-0doyHq.mjs → eve-runtime-DPzMPCLt.mjs} +40 -12
  18. package/dist/eve-runtime-DPzMPCLt.mjs.map +1 -0
  19. package/dist/eve-runtime.d.mts +5 -5
  20. package/dist/eve-runtime.mjs +4 -4
  21. package/dist/eve.d.mts +45 -3
  22. package/dist/eve.d.mts.map +1 -1
  23. package/dist/eve.mjs +45 -3
  24. package/dist/eve.mjs.map +1 -1
  25. package/dist/{index-C3wlz660.d.mts → index-CzzrtCVj.d.mts} +32 -5
  26. package/dist/index-CzzrtCVj.d.mts.map +1 -0
  27. package/dist/index.d.mts +3 -3
  28. package/dist/index.mjs +4 -4
  29. package/dist/{src-DyiAVHKl.mjs → src-BlhrSieS.mjs} +166 -21
  30. package/dist/src-BlhrSieS.mjs.map +1 -0
  31. package/dist/tanstack.d.mts +533 -190
  32. package/dist/tanstack.d.mts.map +1 -1
  33. package/dist/tanstack.mjs +32 -11
  34. package/dist/tanstack.mjs.map +1 -1
  35. package/dist/{token-DIwB-wtp.mjs → token-BLps09gm.mjs} +3 -2
  36. package/dist/token-BLps09gm.mjs.map +1 -0
  37. package/dist/{types-CJqhvQwi.d.mts → types-Bln8U42J.d.mts} +3 -3
  38. package/dist/{types-CJqhvQwi.d.mts.map → types-Bln8U42J.d.mts.map} +1 -1
  39. package/dist/{types-ITYfXMtY.d.mts → types-C7O2lwwz.d.mts} +14 -2
  40. package/dist/{types-ITYfXMtY.d.mts.map → types-C7O2lwwz.d.mts.map} +1 -1
  41. package/dist/workflow.d.mts +9 -2
  42. package/dist/workflow.d.mts.map +1 -1
  43. package/dist/workflow.mjs +6 -4
  44. package/dist/workflow.mjs.map +1 -1
  45. package/dist/{write-tools-DnGZw-RD.mjs → write-tools-w-8tjnDQ.mjs} +440 -33
  46. package/dist/write-tools-w-8tjnDQ.mjs.map +1 -0
  47. package/package.json +1 -1
  48. package/dist/cores-FLzAv2tu.mjs.map +0 -1
  49. package/dist/eve-runtime-C-0doyHq.mjs.map +0 -1
  50. package/dist/eve-runtime-CflZNuXD.d.mts.map +0 -1
  51. package/dist/index-C3wlz660.d.mts.map +0 -1
  52. package/dist/src-DyiAVHKl.mjs.map +0 -1
  53. package/dist/token-DIwB-wtp.mjs.map +0 -1
  54. package/dist/tool-types-OFyE3z0C.d.mts.map +0 -1
  55. package/dist/write-tools-DnGZw-RD.mjs.map +0 -1
@@ -1,5 +1,5 @@
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";
1
+ import { B as PRESET_TOOLS, G as GithubWriteToolName, H as GITHUB_TOOL_NAMES, N as GithubTokenInput, O as GITHUB_WRITE_TOOLS, P as resolveGithubToken, R as CombinedPresetToolNames, V as PresetToolName, W as GithubToolName, a as GithubToolsForPreset, c as CommitIdentity, h as StaticApprovalConfig, i as GithubToolsBaseOptions, l as CommitToolOptions, m as ApprovalConfig, o as PickGithubTools, p as ToolOverrides, r as AllGithubTools, s as GithubToolsContext, z as GithubToolPreset } from "./dry-run-DXckOam2.mjs";
2
+ import { Qt as createGithubAgent, Zt as CreateGithubAgentOptions, n as GithubToolsOptions, r as createGithubTools, t as GithubTools } from "./index-CzzrtCVj.mjs";
3
3
  import { LanguageModel, Output, ToolSet } from "ai";
4
4
  import { WorkflowAgent, WorkflowAgentOptions, WorkflowAgentStreamOptions, WorkflowAgentStreamResult } from "@ai-sdk/workflow";
5
5
  import { Context } from "@ai-sdk/provider-utils";
@@ -76,6 +76,13 @@ export type CreateDurableGithubAgentOptions = Omit<WorkflowAgentOptions, 'model'
76
76
  * `execute`, `inputSchema`, and `outputSchema` cannot be overridden.
77
77
  */
78
78
  overrides?: GithubToolsBaseOptions['overrides'];
79
+ /**
80
+ * Repositories and branches the tools may act on, checked before each call reaches GitHub,
81
+ * as on `createGithubTools`.
82
+ */
83
+ guardrails?: GithubToolsBaseOptions['guardrails'];
84
+ /** Send no write to GitHub, as on `createGithubTools`. */
85
+ dryRun?: boolean;
79
86
  /**
80
87
  * Fully replace the default system prompt.
81
88
  * When set, `preset` system prompts and `additionalInstructions` are ignored.
@@ -1 +1 @@
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"}
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,aAAa;;EAEb;;;;;EAKA;;;;;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,5 +1,5 @@
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";
1
+ import { S as resolveGithubToken, Za as githubToolsErrors, g as GITHUB_TOOL_NAMES, n as resolveInstructions, t as GITHUB_WRITE_TOOLS, v as PRESET_TOOLS } from "./write-tools-w-8tjnDQ.mjs";
2
+ import { r as createGithubAgent, t as createGithubTools } from "./src-BlhrSieS.mjs";
3
3
  import { WorkflowAgent } from "@ai-sdk/workflow";
4
4
  //#region src/workflow.ts
5
5
  /**
@@ -34,7 +34,7 @@ var DurableGithubAgent = class {
34
34
  return this.agent.generate(options);
35
35
  }
36
36
  };
37
- function createDurableGithubAgent({ model, token, preset, requireApproval, overrides, context, instructions, additionalInstructions, author, committer, coAuthors, ...agentOptions }) {
37
+ function createDurableGithubAgent({ model, token, preset, requireApproval, overrides, context, instructions, additionalInstructions, author, committer, coAuthors, guardrails, dryRun, ...agentOptions }) {
38
38
  const tools = createGithubTools({
39
39
  token,
40
40
  requireApproval,
@@ -43,7 +43,9 @@ function createDurableGithubAgent({ model, token, preset, requireApproval, overr
43
43
  context,
44
44
  author,
45
45
  committer,
46
- coAuthors
46
+ coAuthors,
47
+ guardrails,
48
+ dryRun
47
49
  });
48
50
  return new DurableGithubAgent({
49
51
  ...agentOptions,
@@ -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} 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"}
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 * Repositories and branches the tools may act on, checked before each call reaches GitHub,\n * as on `createGithubTools`.\n */\n guardrails?: GithubToolsBaseOptions['guardrails']\n /** Send no write to GitHub, as on `createGithubTools`. */\n dryRun?: boolean\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 guardrails,\n dryRun,\n ...agentOptions\n}: CreateDurableGithubAgentOptions): DurableGithubAgent<AllGithubTools | Pick<AllGithubTools, GithubToolName>> {\n const tools = createGithubTools({ token, requireApproval, preset, overrides, context, author, committer, coAuthors, guardrails, dryRun })\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;AAmHA,SAAgB,yBAAyB,EACvC,OACA,OACA,QACA,iBACA,WACA,SACA,cACA,wBACA,QACA,WACA,WACA,YACA,QACA,GAAG,gBAC0G;CAC7G,MAAM,QAAQ,kBAAkB;EAAE;EAAO;EAAiB;EAAQ;EAAW;EAAS;EAAQ;EAAW;EAAW;EAAY;CAAO,CAAC;CAExI,OAAO,IAAI,mBAAmB;EAC5B,GAAG;EACH;EACA;EACA,cAAc,oBAAoB;GAAE;GAAQ;GAAc;GAAwB;EAAQ,CAAC;CAC7F,CAAC;AACH"}