@kaibanjs/tools
Version:
A set of tools to work with LLMs and KaibanJS
112 lines (111 loc) • 3.18 kB
TypeScript
/**
* GitHub Issues
*
* This tool integrates with GitHub's API to fetch issues from specified repositories.
* It provides a clean, structured way to retrieve open issues, making it ideal for
* monitoring and analysis purposes.
*
* Key features:
* - Fetches open issues from any public GitHub repository
* - Handles pagination automatically
* - Returns structured data with issue details
* - Includes metadata like issue numbers, titles, labels, and descriptions
*
* Authentication:
* - Works without authentication for public repositories (60 requests/hour limit)
* - Optional GitHub token for higher rate limits (5,000 requests/hour)
*
* Rate Limits:
* - Authenticated: 5,000 requests per hour
* - Unauthenticated: 60 requests per hour
*
* For more information about GitHub's API, visit: https://docs.github.com/en/rest
*/
import { StructuredTool } from '@langchain/core/tools';
import { z } from 'zod';
/**
* Configuration options for the GithubIssues tool
* @interface GithubIssuesFields
* @property {string} [token] - GitHub personal access token for authentication
* @property {number} [limit] - Maximum number of issues to fetch (defaults to 10)
*/
interface GithubIssuesFields {
token?: string;
limit?: number;
}
/**
* Structured response format for GitHub issues
* @interface FormattedResponse
* @example
* {
* repository: {
* name: "langchainjs",
* url: "https://github.com/langchain-ai/langchainjs",
* owner: "langchain-ai"
* },
* metadata: {
* totalIssues: 5,
* lastUpdated: "2024-03-20",
* limit: 10
* },
* issues: [{
* number: 123,
* title: "Add new feature",
* url: "https://github.com/langchain-ai/langchainjs/issues/123",
* labels: ["enhancement"],
* description: "We should add this new feature..."
* }]
* }
*/
interface FormattedResponse {
repository: {
name: string;
url: string;
owner: string;
};
metadata: {
totalIssues: number;
lastUpdated: string;
limit: number;
};
issues: Array<{
number: number;
title: string;
url: string;
labels: string[];
description: string;
}>;
}
/**
* Error message returned when the GitHub API request fails
* @typedef {string} GithubIssuesError
* @example "API request failed: Client Error (404)"
*/
type GithubIssuesError = string;
/**
* Response type that can either be a formatted response or an error message
* @typedef {FormattedResponse | GithubIssuesError} GithubIssuesResponse
*/
type GithubIssuesResponse = FormattedResponse | GithubIssuesError;
export declare class GithubIssues extends StructuredTool {
private token?;
private limit;
private httpClient;
name: string;
description: string;
schema: z.ZodObject<{
repoUrl: z.ZodString;
}, "strip", z.ZodTypeAny, {
repoUrl: string;
}, {
repoUrl: string;
}>;
constructor(fields?: GithubIssuesFields);
_call(input: {
repoUrl: string;
}): Promise<GithubIssuesResponse>;
private _fetchIssues;
private _formatResponse;
private _parseRepoUrl;
}
export {};