GitHubApiTool
public class GitHubApiTool
源码Source
io/agentscope/harness/coding/tools/GitHubApiTool.java:38–172GitHub 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 |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
method | String | 方法(类型 `String`)。The method. |
path | String | 路径(类型 `String`)。The path. |
body | String | 正文(类型 `String`)。The body. |
queryParams | Map<String, String> | 查询参数(类型 `Map`)。The query params. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/coding/tools/GitHubApiTool.java:51–129resolveToken
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 |
|---|---|---|
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The ctx. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/coding/tools/GitHubApiTool.java:144–157