# 列出脚本版本 (/docs/api/native/automation/listScriptVersions)





按语义版本倒序分页列出不可变的 schema 和锁定依赖。默认不带源码；仅 expand=source 带完整源码，其它值返回 400。详情接口保持全文。

`GET /automation/v1/scripts/{ns}/{name}/versions`

## 鉴权 [#鉴权]

`Authorization: Bearer $PRAXIS_API_KEY`

## 请求字段 [#请求字段]

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| path: ns | `string` | 必填；命名空间，存储前转为小写，格式 [a-z0-9][a-z0-9._-]&#123;0,63&#125;；praxis 只读。 |
| path: name | `string` | 必填；名称，存储前转为小写，格式 [a-z0-9][a-z0-9._-]&#123;0,63&#125;。 |
| query: limit | `integer` | 可选；每页条数，整数 1–100，默认 25。 minimum: 1；maximum: 100 |
| query: cursor | `string` | 可选；上一页返回的 next_cursor，不透明字符串；保持原查询条件继续翻页。 |
| query: expand | `"source"` | 可选；仅接受 source；默认不带源码，其它值返回 400。 |

## 示例 [#示例]

[SDK 安装与示例环境](/docs/api/native/automation)

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

| 变量 | 来源 |
| --- | --- |
| SCRIPT_NAME | [创建脚本返回的 name](/docs/api/native/automation/createScript) |

```bash
: "${SCRIPT_NAME:?Set SCRIPT_NAME}"
curl --fail-with-body -X GET "https://api.deepraxis.ai/automation/v1/scripts/docs-samples/${SCRIPT_NAME}/versions" \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
```

```typescript
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.scripts.versions.list({
  "path": {
    "ns": "docs-samples",
    "name": env("SCRIPT_NAME")
  }
});
console.log(result);
```

## 响应 [#响应]

### HTTP 200 [#http-200]

Success

`application/json`

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| data | `object[]` | 必填 / 必有；本页的脚本版本（默认不含源码，expand=source 才带），按 semver 降序排列。 |
| data[].id | `string` | 必填 / 必有；版本 ID，脚本前缀 scv_，工作流前缀 wfv_。 |
| data[].kind | `"script"` / `"workflow"` | 必填 / 必有；编排类型。script 为 TypeScript 脚本，一次执行；workflow 为 YAML 工作流，由步骤组成，可等待事件、定时器或子运行并可暂停。 |
| data[].version | `string` | 必填 / 必有；版本号（semver，已去掉 +build 元数据）。 |
| data[].digest | `string` | 必填 / 必有；源码与契约的内容摘要。 |
| data[].source | `string` | 可选；该版本的完整源码。版本列表默认不返回，需要时加 expand=source。 |
| data[].input_schema | `object` | 必填 / 必有；任意 JSON 对象（键为字符串，值为任意 JSON 值）。 |
| data[].input_schema.*（分支5) | `object` | 递归 JSON 值。 |
| data[].input_schema.*（分支6)[] | `null` / `string` / `number` / `boolean` / `object` / `JSON[]` | 递归 JSON 值。 |
| data[].output_schema | `object` | 必填 / 必有；脚本从返回类型推导，支持 Promise 解包、Record、交叉类型和 Date（date-time）；推不出时为空 schema，并在 /validate 的 warnings 给出 warning。 |
| data[].output_schema.*（分支5) | `object` | 递归 JSON 值。 |
| data[].output_schema.*（分支6)[] | `null` / `string` / `number` / `boolean` / `object` / `JSON[]` | 递归 JSON 值。 |
| data[].references | `object[]` | 必填 / 必有；该版本依赖的动作、平台 API、脚本与工作流。脚本和工作流依赖在发布时锁定到精确版本。 |
| data[].references[].kind | `"action"` / `"script"` / `"workflow"` / `"platform_api"` / `"run"` | 必填 / 必有；依赖类型。action 为动作；platform_api 为平台 API 操作；script 为脚本；workflow 为工作流；run 为脚本中 invoke("ns/name") 调用的子运行目标（脚本或工作流，发布时解析）。 |
| data[].references[].name | `string` | 必填 / 必有；被依赖对象：动作为 ns/name，平台 API 为操作名，脚本与工作流为 ns/name。 |
| data[].references[].range | `string` | 可选；引用时写的版本范围或标签（npm 规则）；未写时为空。 |
| data[].references[].locked_version | `string` | 可选；发布时锁定的精确版本；仅脚本与工作流依赖有，动作与平台 API 不锁定。 |
| data[].outline | `null` / `object[]` | 必填 / 必有；工作流的步骤大纲（OutlineNode 数组），由解析器静态生成；脚本为 null。 |
| data[].outline（分支2)[].name | `string` | 必填 / 必有；步骤名，即工作流 YAML 中该步骤的键。 |
| data[].outline（分支2)[].reference | `string` | 必填 / 必有；该步骤在工作流文档中的 JSON Pointer，例如 /do/0/start；与运行时 Task.reference 一致。 |
| data[].outline（分支2)[].kind | `"run"` / `"call"` / `"wait"` / `"set"` / `"for"` / `"fork"` / `"try"` / `"switch"` / `"emit"` / `"raise"` / `"listen"` / `"do"` | 必填 / 必有；工作流步骤类型。call 调用动作；run 运行子脚本或子工作流；wait 等待时长；set 设置变量；for 循环；fork 并行分支；try 带捕获的块；switch 条件分支；emit 发出事件；raise 抛出错误；listen 等待事件；do 顺序执行的步骤块。 |
| data[].outline（分支2)[].target | `string` | 可选；步骤调用的目标：call 步骤为动作 ns/name，run 步骤为 ns/name@范围；其它类型没有。 |
| data[].outline（分支2)[].wait | `object` | 可选；等待步骤的摘要：时长（seconds 或 duration）或等待的事件类型（event）。 不接受额外字段。 |
| data[].outline（分支2)[].wait.until | `string` | 可选；等待结束的绝对时刻，仅在可静态确定时给出；目前大纲不填充该字段。 |
| data[].outline（分支2)[].wait.seconds | `number` | 可选；可静态换算的等待秒数；时长对象与可换算的 ISO 时长均投影到此字段。 |
| data[].outline（分支2)[].wait.event | `string` | 可选；listen 步骤等待的事件类型。 |
| data[].outline（分支2)[].wait.duration | `string` | 可选；无法静态换算成秒的原始时长或运行时表达式；不与 seconds 强行换算。 |
| data[].outline（分支2)[].loop | `object` | 可选；for 步骤的循环信息 &#123;each, in&#125;。 不接受额外字段。 |
| data[].outline（分支2)[].loop.each | `string` | 必填 / 必有；循环变量名；未指定时为 item。 |
| data[].outline（分支2)[].loop.in | `string` | 必填 / 必有；被遍历的集合表达式原文。 |
| data[].outline（分支2)[].children | `object[]` | 可选；嵌套的子步骤（do、fork 分支、try 与 catch 内的步骤）。 |
| data[].outline（分支2)[].children[] | `object` | 递归 JSON 值。 |
| data[].sdk_version | `null` / `string` | 必填 / 必有；发布脚本所用的 SDK 版本；工作流为 null。 |
| data[].published_at | `string` | 必填 / 必有；发布时间（RFC 3339 UTC）。 |
| data[].published_by | `object` | 必填 / 必有；网关注入的主体 &#123;type, id&#125;，表示谁发起或操作；本服务不解析名字，名字由控制台批量解析。 不接受额外字段。 |
| data[].published_by.type | `"user"` / `"api_key"` / `"agent"` / `"run"` / `"trigger"` | 必填 / 必有；主体类型。user 为登录用户；api_key 为平台 API Key；agent 为智能体；run 为由运行本身（例如父运行）执行的操作；trigger 为触发器。 |
| data[].published_by.id | `string` | 必填 / 必有；主体标识，含义随 type 而定：用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID；按不透明字符串处理。 |
| data[].deprecated | `null` / `string` | 必填 / 必有；弃用说明；未弃用为 null。弃用的版本仍可运行，但按范围或标签解析时优先选用未弃用的版本。 |
| data[].deprecated_at | `null` / `string` | 必填 / 必有；弃用时间（RFC 3339 UTC）；未弃用为 null。 |
| data[].deprecated_by | `null` / `object` | 必填 / 必有；执行弃用的主体；未弃用为 null。 |
| data[].deprecated_by（分支2).type | `"user"` / `"api_key"` / `"agent"` / `"run"` / `"trigger"` | 必填 / 必有；主体类型。user 为登录用户；api_key 为平台 API Key；agent 为智能体；run 为由运行本身（例如父运行）执行的操作；trigger 为触发器。 |
| data[].deprecated_by（分支2).id | `string` | 必填 / 必有；主体标识，含义随 type 而定：用户 ID、API Key ID、智能体 ID、运行 ID 或触发器 ID；按不透明字符串处理。 |
| next_cursor | `null` / `string` | 必填 / 必有；下一页游标，原样传给 cursor 参数并保持原查询条件；没有更多页为 null。接口不返回总数。 |

### 实测响应 [#实测响应]

HTTP 200

```json
{
  "data": [
    {
      "id": "scv_00mv67lza679fc5498438040079f0c5684208c4915",
      "kind": "script",
      "version": "1.0.0",
      "digest": "7ae6678882a4ef2ea96e401c105d5c6ef512917cd72a9235289d2a3bf1f1b49d",
      "input_schema": {
        "type": "object",
        "properties": {
          "n": {
            "type": "number"
          }
        },
        "required": [
          "n"
        ]
      },
      "output_schema": {
        "type": "object",
        "properties": {
          "answer": {
            "type": "number"
          }
        },
        "required": [
          "answer"
        ]
      },
      "references": [],
      "outline": null,
      "sdk_version": "0.1.0",
      "published_at": "2026-10-13T04:57:22.398Z",
      "published_by": {
        "type": "api_key",
        "id": "key_3e00b8984967"
      },
      "deprecated": null,
      "deprecated_at": null,
      "deprecated_by": null
    }
  ],
  "next_cursor": null
}
```

## 错误码 [#错误码]

| HTTP | 错误码与说明 |
| --- | --- |
| 400 | INVALID_PARAMS：请求参数、路径、游标或请求体格式无效。 |
| 404 | TARGET_NOT_FOUND：编排目标不存在或类型不匹配。 |
| default | RFC 9457 automation problem. 429 includes Retry-After. |

[鉴权错误与通用错误](/docs/api/errors) · 排查时保留响应头 `X-Request-Id`。
