Class OpenCodeCallbackParser
java.lang.Object
io.github.easy4j.opencode.api.mapper.OpenCodeCallbackParser
Parses callback JSON from OpenCode AI text responses.
OpenCode does not have a native webhook/callback mechanism. This parser attempts to extract JSON blocks from the AI's text response, following the format conventions defined by cloud-agents prompt templates (e.g., the callback_url output format specified in SKILL.md).
The parser tries three strategies in order:
- Extract JSON from
```json ... ```fenced code blocks - Parse the entire text as JSON directly
- Extract bare JSON objects containing
task_id,taskId, ortitle
- Since:
- 1.0.0
- Author:
- Loong Wan
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparseFromPromptResult(PromptResult result) 从 PromptResult 中提取文本内容并解析为 Map。parseFromText(String text) 从纯文本中尝试提取并解析 JSON。
-
Constructor Details
-
OpenCodeCallbackParser
public OpenCodeCallbackParser()
-
-
Method Details
-
parseFromPromptResult
从 PromptResult 中提取文本内容并解析为 Map。- Parameters:
result- OpenCode Prompt 执行结果- Returns:
- OpenCode Server 返回的键值映射;无数据时为空映射
-
parseFromText
从纯文本中尝试提取并解析 JSON。- Parameters:
text- 发送给模型的文本内容- Returns:
- OpenCode Server 返回的键值映射;无数据时为空映射
-