自动化
读取运行日志
默认返回保留期内的日志页,保留期为 30 天。
默认返回保留期内的日志页,保留期为 30 天;Accept: text/event-stream 开启实时流,日志帧为 event: log。id 为续传游标,Last-Event-ID 优先于 cursor;每 20 秒发送 : ping,运行终态后以 event: end 收尾。
GET /automation/v1/runs/{id}/logs
鉴权
Authorization: Bearer $PRAXIS_API_KEY
请求字段
| 参数 | 类型 | 说明 |
|---|---|---|
| path: id | string | 必填;运行 ID(run_)。 |
| query: limit | integer | 可选;运行台账每页条数,整数 1–200,默认 50;其它集合上限为 100。 minimum: 1;maximum: 200 |
| query: cursor | string | 可选;上一页返回的 next_cursor,不透明字符串;保持原查询条件继续翻页。 |
| header: Accept | "application/json" / "text/event-stream" | 可选;application/json(默认)读取账本页;text/event-stream 订阅实时流。 |
| header: Last-Event-ID | string | 可选;SSE 续传游标,读取该事件之后的记录;优先于 cursor,仅用于实时流。 |
示例
先设置以下环境变量,使用你自己的资源:
| 变量 | 来源 |
|---|---|
| RUN_ID | 运行 id;暂停和恢复仅工作流;取消需非终态运行 |
: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/logs" \
-H "Authorization: Bearer $PRAXIS_API_KEY" \
-H "Accept: text/event-stream"import { createAutomationClient } from '@deepractice-ai/praxis-sdk/automation';
function env(name: string): string {
const value = process.env[name];
if (!value) throw new Error(`Set ${name}`);
return value;
}
const automation = createAutomationClient({
apiKey: env('PRAXIS_API_KEY'),
baseUrl: 'https://api.deepraxis.ai',
maxRetries: 0,
timeoutMs: 90_000,
});
for await (const event of automation.runs.logs({
"path": {
"id": env("RUN_ID")
}
})) {
console.log(event);
}响应
HTTP 200
Success
application/json
| 字段 | 类型 | 说明 |
|---|---|---|
| data | object[] | 必填 / 必有;本页的日志行(LogLine),按时间顺序排列。 |
| data[].cursor | string | 必填 / 必有;该行的游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。 |
| data[].ts | string | 必填 / 必有;日志产生的时间(RFC 3339 UTC)。 |
| data[].level | "debug" / "info" / "warn" / "error" | 必填 / 必有;日志级别。debug 调试信息;info 一般信息;warn 警告;error 错误。 |
| data[].message | string | 必填 / 必有;日志文本。 |
| next_cursor | null / string | 必填 / 必有;下一页游标,原样传给 cursor 参数并保持原查询条件;没有更多页为 null。接口不返回总数。 |
text/event-stream
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 可选;Resume cursor of this entry; send it back as Last-Event-ID, or as cursor on the JSON form, to continue after it. Absent on the end event. |
| event | "log" / "end" | 必填 / 必有;SSE event name: log carries one log line in data; end is sent once when the run has reached a terminal status and closes the stream. |
| data | object / object | 必填 / 必有;Decoded JSON of one log line; for the end event, an empty object. |
| data(分支1).cursor | string | 必填 / 必有;该行的游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。 |
| data(分支1).ts | string | 必填 / 必有;日志产生的时间(RFC 3339 UTC)。 |
| data(分支1).level | "debug" / "info" / "warn" / "error" | 必填 / 必有;日志级别。debug 调试信息;info 一般信息;warn 警告;error 错误。 |
| data(分支1).message | string | 必填 / 必有;日志文本。 |
| (分支1).event | "log" | 可选;SSE event name: log, one log line is carried in data. |
| (分支1).data | object | 可选;运行产生的一行日志,保留 30 天。 不接受额外字段。 |
| (分支1).data.cursor | string | 必填 / 必有;该行的游标;用作 cursor 翻页,或在 SSE 中作为 Last-Event-ID 续传。 |
| (分支1).data.ts | string | 必填 / 必有;日志产生的时间(RFC 3339 UTC)。 |
| (分支1).data.level | "debug" / "info" / "warn" / "error" | 必填 / 必有;日志级别。debug 调试信息;info 一般信息;warn 警告;error 错误。 |
| (分支1).data.message | string | 必填 / 必有;日志文本。 |
| (分支2).event | "end" | 可选;SSE event name end: sent once when the run has reached a terminal status, and the stream then closes. |
| (分支2).data | object | 可选;Always an empty object for the end event. |
实测响应
HTTP 200
event: end
data: {}
错误码
| HTTP | 错误码与说明 |
|---|---|
| 400 | INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。 |
| 404 | RUN_NOT_FOUND:运行不存在或当前租户不可见。 |
| default | RFC 9457 automation problem. 429 includes Retry-After. |
鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。