@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.
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.mjs","names":[],"sources":["../src/workflow.ts"],"sourcesContent":["import { DurableAgent } from '@workflow/ai/agent'\nimport type { CompatibleLanguageModel } from '@workflow/ai/agent'\nimport { createGithubTools } from './index'\nimport { resolveInstructions } from './agents'\nimport type { GithubToolPreset, ApprovalConfig } from './index'\n\nexport type CreateDurableGithubAgentOptions = {\n model: string | CompatibleLanguageModel | (() => Promise<CompatibleLanguageModel>)\n /**\n * GitHub personal access token.\n * Falls back to `process.env.GITHUB_TOKEN` when omitted.\n */\n token?: string\n preset?: GithubToolPreset | GithubToolPreset[]\n requireApproval?: ApprovalConfig\n instructions?: string\n additionalInstructions?: string\n /** Maximum number of LLM calls before stopping. Unlimited by default. */\n maxSteps?: number\n temperature?: number\n}\n\n/**\n * Create a pre-configured durable GitHub agent powered by Vercel Workflow SDK's `DurableAgent`.\n *\n * Each tool call runs as a durable step with automatic retries and observability.\n * Must be used inside a `\"use workflow\"` function.\n *\n * **Note:** `requireApproval` is accepted for forward-compatibility but is currently\n * ignored by `DurableAgent` — the Workflow SDK does not yet support interactive tool\n * approval. All tools execute immediately without user confirmation.\n *\n * @example\n * ```ts\n * import { createDurableGithubAgent } from '@github-tools/sdk/workflow'\n * import { getWritable } from 'workflow'\n * import type { ModelMessage, UIMessageChunk } from 'ai'\n *\n * async function chatWorkflow(messages: ModelMessage[], token: string) {\n * \"use workflow\"\n * const agent = createDurableGithubAgent({\n * model: 'anthropic/claude-sonnet-4.6',\n * token,\n * preset: 'code-review',\n * })\n * const writable = getWritable<UIMessageChunk>()\n * await agent.stream({ messages, writable })\n * }\n * ```\n */\nexport function createDurableGithubAgent({\n model,\n token,\n preset,\n requireApproval,\n instructions,\n additionalInstructions,\n ...agentOptions\n}: CreateDurableGithubAgentOptions) {\n const tools = createGithubTools({ token, requireApproval, preset })\n\n const resolvedModel = typeof model === 'string' || typeof model === 'function'\n ? model\n : () => Promise.resolve(model)\n\n return new DurableAgent({\n ...agentOptions,\n model: resolvedModel,\n tools,\n instructions: resolveInstructions({ preset, instructions, additionalInstructions }),\n })\n}\n\nexport { createGithubTools, createGithubAgent } from './index'\nexport type { GithubTools, GithubToolsOptions, GithubToolPreset, GithubWriteToolName, ApprovalConfig } from './index'\nexport type { CreateGithubAgentOptions } from './agents'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,yBAAyB,EACvC,OACA,OACA,QACA,iBACA,cACA,wBACA,GAAG,gBAC+B;CAClC,MAAM,QAAQ,kBAAkB;EAAE;EAAO;EAAiB;EAAQ,CAAC;CAEnE,MAAM,gBAAgB,OAAO,UAAU,YAAY,OAAO,UAAU,aAChE,cACM,QAAQ,QAAQ,MAAM;AAEhC,QAAO,IAAI,aAAa;EACtB,GAAG;EACH,OAAO;EACP;EACA,cAAc,oBAAoB;GAAE;GAAQ;GAAc;GAAwB,CAAC;EACpF,CAAC"}
1
+ {"version":3,"file":"workflow.mjs","names":[],"sources":["../src/workflow.ts"],"sourcesContent":["import { DurableAgent } from '@workflow/ai/agent'\nimport type { CompatibleLanguageModel, DurableAgentOptions, DurableAgentStreamOptions, DurableAgentStreamResult, TelemetrySettings } from '@workflow/ai/agent'\nimport type { ToolSet, StepResult, FinishReason, LanguageModelUsage, LanguageModelResponseMetadata, ModelMessage, StopCondition } from 'ai'\nimport { createGithubTools } from './index'\nimport { resolveInstructions } from './agents'\nimport type { GithubToolPreset, ApprovalConfig } from './index'\nimport type { CommitIdentity } from './types'\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 the Workflow SDK's `DurableAgent` that adds a non-streaming\n * `.generate()` method alongside the existing `.stream()`.\n *\n * - `.stream()` — delegates to `DurableAgent.stream()`, each tool call is\n * an individually retriable workflow step. Works in workflow context.\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: DurableAgent<TTools>\n private _model: DurableAgentOptions<TTools>['model']\n private _instructions?: DurableAgentOptions<TTools>['instructions']\n private _telemetry?: TelemetrySettings\n private _tools: TTools\n\n constructor(options: DurableAgentOptions<TTools>) {\n this.agent = new DurableAgent(options)\n this._model = options.model\n this._instructions = options.instructions\n this._telemetry = options.experimental_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 `DurableAgent.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: DurableAgentStreamOptions<TStreamTools, OUTPUT, PARTIAL_OUTPUT>,\n ): Promise<DurableAgentStreamResult<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 * @example\n * ```ts\n * async function agentTurn(prompt: string) {\n * \"use step\"\n * const agent = createDurableGithubAgent({\n * model: 'anthropic/claude-sonnet-4.6',\n * preset: 'code-review',\n * })\n * const { text } = await agent.generate({ prompt })\n * return text\n * }\n * ```\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 model = typeof this._model === 'function'\n ? await this._model()\n : this._model\n\n const system = typeof this._instructions === 'string'\n ? this._instructions\n : undefined\n\n const result = await generateText({\n model: model as Parameters<typeof generateText>[0]['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 `DurableAgentOptions` (temperature, telemetry, callbacks, etc.)\n * and adds GitHub-specific fields (token, preset, approval config).\n */\nexport type CreateDurableGithubAgentOptions =\n Omit<DurableAgentOptions, 'model' | 'tools' | 'instructions'> & {\n model: string | CompatibleLanguageModel | (() => Promise<CompatibleLanguageModel>)\n /**\n * GitHub personal access token.\n * Falls back to `process.env.GITHUB_TOKEN` when omitted.\n */\n token?: string\n preset?: GithubToolPreset | GithubToolPreset[]\n requireApproval?: ApprovalConfig\n instructions?: string\n additionalInstructions?: string\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 Vercel Workflow SDK's `DurableAgent`.\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 * - `.generate()` — uses `generateText` from the AI SDK; must be called from\n * within a `\"use step\"` function when running inside a workflow.\n *\n * **Note:** `requireApproval` is accepted for forward-compatibility but is currently\n * ignored by `DurableAgent` — the Workflow SDK does not yet support interactive tool\n * approval. All tools execute immediately without user confirmation.\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, UIMessageChunk } from 'ai'\n *\n * async function chatWorkflow(messages: ModelMessage[], token: string) {\n * \"use workflow\"\n * const agent = createDurableGithubAgent({\n * model: 'anthropic/claude-sonnet-4.6',\n * token,\n * preset: 'code-review',\n * })\n * const writable = getWritable<UIMessageChunk>()\n * await agent.stream({ messages, writable })\n * }\n * ```\n *\n * @example Non-streaming (bot / background job — needs \"use step\")\n * ```ts\n * import { createDurableGithubAgent } from '@github-tools/sdk/workflow'\n *\n * async function agentTurn(prompt: string) {\n * \"use step\"\n * const agent = createDurableGithubAgent({\n * model: 'anthropic/claude-sonnet-4.6',\n * preset: 'code-review',\n * })\n * const { text } = await agent.generate({ prompt })\n * return text\n * }\n * ```\n */\nexport function createDurableGithubAgent({\n model,\n token,\n preset,\n requireApproval,\n instructions,\n additionalInstructions,\n author,\n committer,\n coAuthors,\n ...agentOptions\n}: CreateDurableGithubAgentOptions) {\n const tools = createGithubTools({ token, requireApproval, preset, author, committer, coAuthors })\n\n const resolvedModel = typeof model === 'string' || typeof model === 'function'\n ? model\n : () => Promise.resolve(model)\n\n return new DurableGithubAgent({\n ...agentOptions as Omit<typeof agentOptions, 'toolChoice'>,\n model: resolvedModel,\n tools,\n instructions: resolveInstructions({ preset, instructions, additionalInstructions }),\n })\n}\n\nexport { createGithubTools, createGithubAgent } from './index'\nexport type { CommitIdentity, CommitToolOptions, GithubTools, GithubToolsOptions, GithubToolPreset, GithubWriteToolName, ApprovalConfig, ToolOverrides } from './index'\nexport type { CreateGithubAgentOptions } from './agents'\n"],"mappings":";;;;;;;;;;;;;AA6BA,IAAa,qBAAb,MAAkE;CAChE;CACA;CACA;CACA;CACA;CAEA,YAAY,SAAsC;AAChD,OAAK,QAAQ,IAAI,aAAa,QAAQ;AACtC,OAAK,SAAS,QAAQ;AACtB,OAAK,gBAAgB,QAAQ;AAC7B,OAAK,aAAa,QAAQ;AAC1B,OAAK,SAAS,QAAQ,SAAS,EAAE;;;CAInC,IAAI,QAAgB;AAClB,SAAO,KAAK,MAAM;;;;;;CAOpB,OACE,SACyD;AACzD,SAAO,KAAK,MAAM,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;;;;CAuBnC,MAAM,SAAS,EAAE,QAAQ,YAAoJ;EAC3K,MAAM,EAAE,iBAAiB,MAAM,OAAO;EAEtC,MAAM,QAAQ,OAAO,KAAK,WAAW,aACjC,MAAM,KAAK,QAAQ,GACnB,KAAK;EAET,MAAM,SAAS,OAAO,KAAK,kBAAkB,WACzC,KAAK,gBACL,KAAA;EAEJ,MAAM,SAAS,MAAM,aAAa;GACzB;GACP,OAAO,KAAK;GACZ;GACA;GACA;GACA,wBAAwB,KAAK;GAC9B,CAAC;AAEF,SAAO;GACL,MAAM,OAAO;GACb,cAAc,OAAO;GACrB,OAAO,OAAO;GACd,OAAO,OAAO;GACd,UAAU,OAAO;GAClB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFL,SAAgB,yBAAyB,EACvC,OACA,OACA,QACA,iBACA,cACA,wBACA,QACA,WACA,WACA,GAAG,gBAC+B;CAClC,MAAM,QAAQ,kBAAkB;EAAE;EAAO;EAAiB;EAAQ;EAAQ;EAAW;EAAW,CAAC;CAEjG,MAAM,gBAAgB,OAAO,UAAU,YAAY,OAAO,UAAU,aAChE,cACM,QAAQ,QAAQ,MAAM;AAEhC,QAAO,IAAI,mBAAmB;EAC5B,GAAG;EACH,OAAO;EACP;EACA,cAAc,oBAAoB;GAAE;GAAQ;GAAc;GAAwB,CAAC;EACpF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@github-tools/sdk",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "GitHub tools for the Vercel AI SDK, wrap GitHub's API as AI SDK tools ready to plug into any agent",
5
5
  "author": "HugoRCD <hugo.richard@vercel.com",
6
6
  "repository": {
@@ -46,10 +46,10 @@
46
46
  "octokit": "^5.0.5"
47
47
  },
48
48
  "peerDependencies": {
49
+ "@workflow/ai": "^4.1.0-beta.60",
49
50
  "ai": "^6.0.97",
50
- "zod": "^4.3.6",
51
51
  "workflow": "^4.2.0-beta.76",
52
- "@workflow/ai": "^4.1.0-beta.60"
52
+ "zod": "^4.3.6"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "workflow": {
@@ -60,11 +60,11 @@
60
60
  }
61
61
  },
62
62
  "devDependencies": {
63
- "@types/node": "^24.10.13",
64
- "eslint": "^9.19.0",
65
- "tsdown": "^0.20.3",
66
- "typescript": "^5.9.3",
67
- "typescript-eslint": "^8.24.0"
63
+ "@types/node": "^25.6.0",
64
+ "eslint": "^10.3.0",
65
+ "tsdown": "^0.21.10",
66
+ "typescript": "^6.0.3",
67
+ "typescript-eslint": "^8.59.2"
68
68
  },
69
69
  "publishConfig": {
70
70
  "access": "public"