AS AgentScopeAPI 手册 / API Reference

GitHubApiTool

public class GitHubApiTool
源码Source io/agentscope/harness/coding/tools/GitHubApiTool.java:38–172

GitHub API 工具,封装可被智能体调用的能力。位于 io.agentscope.harness.coding.tools 包。核心成员包括 github_api_request、resolveToken、GitHubApiTool。

GitHub API tool — plan option B (Java-side direct calls).

Replaces the Python-side GH_TOKEN=dummy gh pattern. The GitHub token is resolved from the session context (via RuntimeContext.extra("github_token")) or falls back to GITHUB_TOKEN / GH_TOKEN environment variables. The agent never sees the raw token.

构造器摘要Constructor Summary

构造器Constructor说明Description
public GitHubApiTool()
初始化 `GitHubApiTool` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public String github_api_request(RuntimeContext runtimeContext, String method, String path, String body, Map<String, String> queryParams)
执行 `github_api_request` 方法。
Performs the github api request operation.
public static String resolveToken(RuntimeContext ctx)
static
解析令牌。
Resolves the GitHub token from (in priority order): - AgentStateStore extra `github_token` (injected by the webhook handler or dispatcher) - `GITHUB_TOKEN` environment variable - `GH_TOKEN` environment variable

构造器详情Constructor Detail

GitHubApiTool

public GitHubApiTool()

初始化 GitHubApiTool 实例。

Creates a new instance.

源码Source io/agentscope/harness/coding/tools/GitHubApiTool.java:43–49

方法详情Method Detail

github_api_request

public String github_api_request(RuntimeContext runtimeContext, String method, String path, String body, Map<String, String> queryParams)

执行 github_api_request 方法。

Performs the github api request operation.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
methodString方法(类型 `String`)。The method.
pathString路径(类型 `String`)。The path.
bodyString正文(类型 `String`)。The body.
queryParamsMap<String, String>查询参数(类型 `Map`)。The query params.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/coding/tools/GitHubApiTool.java:51–129

resolveToken

public static String resolveToken(RuntimeContext ctx)
static

解析令牌。

Resolves the GitHub token from (in priority order): - AgentStateStore extra github_token (injected by the webhook handler or dispatcher) - GITHUB_TOKEN environment variable - GH_TOKEN environment variable

参数Parameters
名称Name类型Type说明Description
ctxRuntimeContext运行时上下文(类型 `RuntimeContext`)。The ctx.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/coding/tools/GitHubApiTool.java:144–157
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.