自动化

读取运行源码

读取运行实际使用的源码及摘要。

读取运行实际使用的源码及摘要。结果包括语言与 SHA-256 摘要,适用于临时运行及已发布定义的运行。

GET /automation/v1/runs/{id}/source

鉴权

Authorization: Bearer $PRAXIS_API_KEY

请求字段

参数类型说明
path: idstring必填;运行 ID(run_)。

示例

先设置以下环境变量,使用你自己的资源:

: "${RUN_ID:?Set RUN_ID}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/runs/${RUN_ID}/source" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
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,
});
const result = await automation.runs.retrieveSource({
  "path": {
    "id": env("RUN_ID")
  }
});
console.log(result);

响应

HTTP 200

Success

application/json

字段类型说明
language"ts" / "yaml"必填 / 必有;源码语言。ts 表示 TypeScript 脚本;yaml 表示工作流 YAML。
sourcestring必填 / 必有;运行时使用的完整源码(ts 或 yaml)。
sha256string必填 / 必有;源码的 SHA-256 摘要,可作为发布时的 expected_source_sha256。

实测响应

HTTP 200

{
  "language": "ts",
  "source": "export default async (input: { n: number }) => ({ answer: input.n + 1 });",
  "sha256": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d"
}

错误码

HTTP错误码与说明
400INVALID_PARAMS:请求参数、路径、游标或请求体格式无效。
404RUN_NOT_FOUND:运行不存在或当前租户不可见。
defaultRFC 9457 automation problem. 429 includes Retry-After.

鉴权错误与通用错误 · 排查时保留响应头 X-Request-Id。

导出

本页内容