事件

CLI-JAW 使用 WebSocket 进行实时更新,使用 NDJSON 进行流式 AI 响应。

WebSocket 连接

ws://localhost:3457/ws

WebSocket 连接实时接收所有服务器事件。

主要事件

事件载荷描述
message{role, content}聊天消息(用户或助手)
tool_use{name, input}AI 工具调用
thinking{content}扩展思考块
status{state}Agent 状态变更
error{message}错误通知
steer_started{prompt}Steer 提示注入
goal_done{goalId}目标已完成
goal_cancel{goalId}目标已取消

NDJSON 流

聊天响应以换行符分隔的 JSON 格式进行流式传输:

POST /api/chat
Content-Type: application/json

{"message": "Hello"}

Response (streaming):
{"type":"thinking","content":"..."}
{"type":"text","content":"Hello! "}
{"type":"text","content":"How can I help?"}
{"type":"done"}

Trace 文件

会话 trace 以 NDJSON 文件格式保存到 ~/.cli-jaw/traces/。每一行是一个带时间戳的事件。