Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ agents that you configure declaratively without writing or deploying any runtime

- **One-command super agent** — `ar super-agent run` creates a hosted agent and drops you into a chat REPL in seconds.
- **Declarative deployment** — Kubernetes-style YAML (`ar sa apply -f superagent.yaml`) for reproducible, version-controlled agents.
- **Runtime declarative deploy** — `ar runtime apply -f runtime.yaml` builds an Agent Runtime from a container image and waits for it to reach `READY`.
- **Runtime declarative deploy** — `ar runtime apply -f runtime.yaml` deploys an Agent Runtime from an image, or invokes a cloud build first when the YAML defines `cloudBuild`.
- **Seven resource groups** — `config`, `model`, `sandbox`, `tool`, `skill`, `super-agent`, `runtime`, all following the same `ar <group> <action>` pattern.
- **Multi-profile config** — store multiple sets of credentials in `~/.agentrun/config.json` and switch with `--profile`.
- **Multiple output formats** — `json` (default), `table`, `yaml`, and `quiet` for shell piping.
Expand Down Expand Up @@ -191,6 +191,29 @@ EOF
ar runtime apply -f runtime.yaml
```

To cloud-build the image before deploy, add `cloudBuild`. The target image is
the same `spec.container.image`; docker-image-builder skips existing tags by
default.

```bash
cat > runtime-build.yaml <<EOF
apiVersion: agentrun/v1
kind: AgentRuntime
metadata: {name: my-agent}
spec:
container:
image: registry.cn-hangzhou.aliyuncs.com/my-ns/my-agent:v1
cloudBuild:
dir: .
setupScript: scripts/setup.sh
baseContainerConfig:
image: serverless-registry.cn-hangzhou.cr.aliyuncs.com/functionai/docker-image-builder-worker:20260514-111141-2d80effe
EOF
ar runtime apply -f runtime-build.yaml
# or build without deploying:
# ar runtime cloud-build -f runtime-build.yaml
```

## Command groups

| Group | Alias | Purpose | Docs |
Expand All @@ -201,7 +224,7 @@ ar runtime apply -f runtime.yaml
| `tool` | | MCP and FunctionCall tools | [en](./docs/en/tool.md) · [zh](./docs/zh/tool.md) |
| `skill` | | Platform skill packages + local execution | [en](./docs/en/skill.md) · [zh](./docs/zh/skill.md) |
| `super-agent` | `sa` | Quickstart / CRUD / declarative / conversation | [en](./docs/en/super-agent.md) · [zh](./docs/zh/super-agent.md) |
| `runtime` | `rt` | Declarative Agent Runtime deploy (container mode) | [en](./docs/en/runtime.md) · [zh](./docs/zh/runtime.md) |
| `runtime` | `rt` | Declarative Agent Runtime deploy and optional cloud image build | [en](./docs/en/runtime.md) · [zh](./docs/zh/runtime.md) |

## Documentation

Expand Down
26 changes: 24 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Agent)**:一种由平台托管、用户只需声明配置、无需编写或

- **一键拉起超级 Agent** — `ar super-agent run` 一条命令创建托管 Agent 并进入 REPL 对话。
- **声明式部署** — Kubernetes 风格 YAML(`ar sa apply -f superagent.yaml`),可版本化、可重复部署。
- **Runtime 声明式部署** — `ar runtime apply -f runtime.yaml` 从容器镜像创建 Agent Runtime 并等待 `READY`
- **Runtime 声明式部署** — `ar runtime apply -f runtime.yaml` 从镜像部署 Agent Runtime;YAML 写了 `cloudBuild` 时,会先调用云上构建
- **七大资源组** — `config`、`model`、`sandbox`、`tool`、`skill`、`super-agent`、`runtime`,统一 `ar <group> <action>` 模式。
- **多 Profile 配置** — `~/.agentrun/config.json` 支持多套凭证,通过 `--profile` 切换。
- **多种输出格式** — 默认 `json`,支持 `table` / `yaml` / `quiet`(适合 shell 管道)。
Expand Down Expand Up @@ -187,6 +187,28 @@ EOF
ar runtime apply -f runtime.yaml
```

如需部署前云上构建镜像,可增加 `cloudBuild`。目标镜像就是同一个
`spec.container.image`;docker-image-builder 默认会跳过已存在 tag。

```bash
cat > runtime-build.yaml <<EOF
apiVersion: agentrun/v1
kind: AgentRuntime
metadata: {name: my-agent}
spec:
container:
image: registry.cn-hangzhou.aliyuncs.com/my-ns/my-agent:v1
cloudBuild:
dir: .
setupScript: scripts/setup.sh
baseContainerConfig:
image: serverless-registry.cn-hangzhou.cr.aliyuncs.com/functionai/docker-image-builder-worker:20260514-111141-2d80effe
EOF
ar runtime apply -f runtime-build.yaml
# 或者只构建不部署:
# ar runtime cloud-build -f runtime-build.yaml
```

## 命令组总览

| 命令组 | 别名 | 用途 | 文档 |
Expand All @@ -197,7 +219,7 @@ ar runtime apply -f runtime.yaml
| `tool` | | MCP 与 FunctionCall 工具 | [en](./docs/en/tool.md) · [zh](./docs/zh/tool.md) |
| `skill` | | 平台技能包 + 本地执行 | [en](./docs/en/skill.md) · [zh](./docs/zh/skill.md) |
| `super-agent` | `sa` | 一键拉起 / CRUD / 声明式 / 会话管理 | [en](./docs/en/super-agent.md) · [zh](./docs/zh/super-agent.md) |
| `runtime` | `rt` | 声明式 Agent Runtime 部署(容器模式) | [en](./docs/en/runtime.md) · [zh](./docs/zh/runtime.md) |
| `runtime` | `rt` | 声明式 Agent Runtime 部署,可选云上镜像构建 | [en](./docs/en/runtime.md) · [zh](./docs/zh/runtime.md) |

## 文档

Expand Down
3 changes: 3 additions & 0 deletions agentruntime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ metadata:
spec:
container:
image: registry.cn-hangzhou.aliyuncs.com/my-ns/my-agent:v1
# cloudBuild: # optional; build only if image tag is missing
# dir: . # source directory uploaded to builder
# setupScript: scripts/setup.sh # empty string skips setup
# command: ["python", "app.py"] # optional, overrides image CMD/ENTRYPOINT
# port: 9000 # optional; spec.port below also works

Expand Down
67 changes: 66 additions & 1 deletion docs/en/runtime-yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rejected (see [Validation rules](#validation-rules)).
- [CLI auto-injection](#cli-auto-injection)
- [`metadata`](#metadata)
- [`spec.container`](#speccontainer)
- [`spec.container.cloudBuild`](#speccontainercloudbuild)
- [`spec` resource & runtime knobs](#spec-resource--runtime-knobs)
- [`spec.protocol`](#specprotocol)
- [`spec.network`](#specnetwork)
Expand Down Expand Up @@ -77,7 +78,8 @@ Required block. Defines the container image and registry credentials.

| Key | Type | Required | Notes |
|---|---|---|---|
| `image` | string | ✓ | OCI image reference. |
| `image` | string | ✓ | OCI image reference. When `cloudBuild` is set, this is also the target image passed to the builder. |
| `cloudBuild` | mapping | | Build the image in the cloud. docker-image-builder skips existing target tags by default. |
| `command` | list&lt;string&gt; | | Overrides image `ENTRYPOINT`/`CMD`. |
| `port` | int | | Container listen port. If set, wins over `spec.port`. |
| `imageRegistryType` | enum | | One of `ACR`, `ACREE`, `CUSTOM`. |
Expand All @@ -103,6 +105,45 @@ registryConfig:
All three sub-blocks (`auth`, `cert`, `network`) are individually optional, but
`registryConfig` itself is mandatory under `CUSTOM`.


## `spec.container.cloudBuild`

Optional block. It asks `ar runtime apply` or `ar runtime cloud-build` to build
`spec.container.image` with docker-image-builder. The target image is always
`spec.container.image`; existing-tag checks are delegated to docker-image-builder.

| Key | Type | Default | Notes |
|---|---|---|---|
| `dir` | string | `.` | Local source directory to upload. Relative paths are resolved from the current working directory. |
| `setupScript` | string | `scripts/setup.sh` | Script executed in the builder before packaging. Empty string skips setup. |
| `timeoutMinutes` | string/number | `20` | Setup script timeout in minutes. Worker creation, upload and push are not counted. |
| `cpu` | string/number | `4` | Builder worker CPU, for example `4` or `4c`. |
| `memory` | string/number | `8192` | Builder worker memory in MB. |
| `region` | string | AgentRun region / `cn-hangzhou` | FC region for the builder worker. |
| `registry` | mapping | env vars | Optional target registry auth; see below. |
| `baseContainerConfig.image` | string | docker-image-builder default | Build environment image used by the cloud worker. |

Only standard OCI registry mode is supported. Do not write `registryMode`,
`baseImage`, `baseAcrInstanceId`, or `baseRegistry` in this block.

```yaml
cloudBuild:
dir: .
setupScript: scripts/setup.sh
timeoutMinutes: 20
cpu: 4
memory: 8192
baseContainerConfig:
image: serverless-registry.cn-hangzhou.cr.aliyuncs.com/functionai/docker-image-builder-worker:20260514-111141-2d80effe
```

`registry.username` and `registry.password` are optional. If omitted, the CLI
reads `DOCKER_IMAGE_BUILDER_USERNAME` and `DOCKER_IMAGE_BUILDER_PASSWORD` from
the environment or `.env`. Aliyun UID/AK/SK are resolved from the active
AgentRun profile and passed to docker-image-builder through environment
variables. The CLI does not interpolate `${...}` in YAML values; use environment
variables by omitting `registry`, or put literal values in YAML.

## `spec` resource & runtime knobs

| Key | Type | Default | Notes |
Expand Down Expand Up @@ -274,6 +315,7 @@ for the parser (`src/agentrun_cli/_utils/agentruntime_yaml.py`).
| `metadata.name` missing or fails `[a-z0-9-]{1,63}` | |
| `spec.container` missing or not a mapping | |
| `spec.container.image` missing or empty | |
| `spec.container.cloudBuild` has unsupported fields | Only OCI mode is supported; ACREE/base-registry builder fields are rejected. |
| `spec.container.imageRegistryType` not in `ACR|ACREE|CUSTOM` | |
| `imageRegistryType=CUSTOM` but `registryConfig` missing | |
| `metadata.tags` present | SDK 0.0.200 removed the field. |
Expand Down Expand Up @@ -320,6 +362,28 @@ spec:
# system_tags=["x-agentrun-cli"], artifact_type=Container
```


### Cloud build before deploy

```yaml
apiVersion: agentrun/v1
kind: AgentRuntime
metadata:
name: my-agent
spec:
container:
image: registry.cn-hangzhou.aliyuncs.com/my-ns/my-agent:v1
cloudBuild:
dir: .
setupScript: scripts/setup.sh
env:
LOG_LEVEL: info
```

`ar runtime apply -f runtime.yaml` invokes docker-image-builder and then deploys
the same `image` value. docker-image-builder skips existing target tags by
default.

### Production — ACREE + private network + NAS + canary endpoint

```yaml
Expand Down Expand Up @@ -406,6 +470,7 @@ For users who need to cross-reference the SDK
| `spec.container.imageRegistryType` | `container_configuration.image_registry_type` |
| `spec.container.acrInstanceId` | `container_configuration.acr_instance_id` |
| `spec.container.registryConfig.*` | `container_configuration.registry_config.*` |
| `spec.container.cloudBuild.*` | CLI-only build plan; not sent to AgentRun SDK. |
| `spec.cpu / memory / port / diskSize` | `cpu / memory / port / disk_size` |
| `spec.enableSessionIsolation` | `enable_session_isolation` |
| `spec.protocol.type` | `protocol_configuration.type` |
Expand Down
77 changes: 69 additions & 8 deletions docs/en/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

# ar runtime

Manage **Agent Runtimes** declaratively from a YAML file. The CLI only supports
container-mode runtimes (you supply an OCI image; building the image is out of
scope for this command group). Endpoints are embedded in the same YAML; the
default behaviour is to inject one named `default` (`targetVersion=LATEST`).
Manage **Agent Runtimes** declaratively from a YAML file. The CLI supports
container-mode runtimes from an existing OCI image, and can optionally invoke a
cloud image build before deployment through `spec.container.cloudBuild`.
Endpoints are embedded in the same YAML; the default behaviour is to inject one
named `default` (`targetVersion=LATEST`).

Also available as the alias `ar rt`.

Expand All @@ -15,7 +16,8 @@ Also available as the alias `ar rt`.

## Commands

- [apply](#apply) — create-or-update from YAML, with status polling.
- [apply](#apply) — cloud-build when configured, then create-or-update from YAML.
- [cloud-build](#cloud-build) — build images from YAML without deploying.
- [render](#render) — dry-run validate + render to SDK input.
- [get](#get) — fetch one runtime by name.
- [list](#list) — list runtimes; filter by `--created-by-cli` or `--workspace`.
Expand Down Expand Up @@ -49,7 +51,10 @@ ar runtime apply -f FILE [--wait/--no-wait] [--timeout DURATION]

The CLI injects sensible defaults for `cpu` (2 cores), `memory` (4096 MB) and
`port` (9000) when the YAML omits them — the backend rejects null values for
these three fields with HTTP 400.
these three fields with HTTP 400. If `spec.container.cloudBuild` is present,
`apply` invokes docker-image-builder before submitting the runtime, then deploys
the same image reference. docker-image-builder skips existing target tags by
default.

### Examples

Expand All @@ -65,6 +70,22 @@ spec:
EOF
ar runtime apply -f runtime.yaml

# Build in the cloud, then deploy.
cat > runtime-build.yaml <<EOF
apiVersion: agentrun/v1
kind: AgentRuntime
metadata: {name: my-agent}
spec:
container:
image: registry.cn-hangzhou.aliyuncs.com/my-ns/my-agent:v1
cloudBuild:
dir: .
setupScript: scripts/setup.sh
baseContainerConfig:
image: serverless-registry.cn-hangzhou.cr.aliyuncs.com/functionai/docker-image-builder-worker:20260514-111141-2d80effe
EOF
ar runtime apply -f runtime-build.yaml

# Non-blocking submit (CI-friendly):
ar runtime apply -f runtime.yaml --no-wait

Expand All @@ -75,6 +96,44 @@ ar runtime apply -f runtime.yaml --timeout 20m
ar runtime apply -f runtime.yaml --no-prune-endpoints
```


---

## cloud-build

```
ar runtime cloud-build -f FILE
```

### Options

| Flag | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `-f`, `--file` | path | yes | | YAML file path (supports multi-document). |

Runs only the `spec.container.cloudBuild` step and does not create or update the
runtime. For each document, the command invokes docker-image-builder and reports
`completed` when the builder exits successfully. The builder skips existing
target tags by default. For multi-document YAML (`---` separated), every
document must define `spec.container.cloudBuild`; otherwise the command fails
before invoking any builder process.

`cloud-build` uses the same credentials as `apply`: AgentRun profile values for
Aliyun UID/AK/SK, and `DOCKER_IMAGE_BUILDER_USERNAME` /
`DOCKER_IMAGE_BUILDER_PASSWORD` for registry auth unless the YAML overrides them
under `cloudBuild.registry`.

When the CLI downloads docker-image-builder automatically, it verifies the
sibling `.sha256` file before caching or running the binary. Set
`DOCKER_IMAGE_BUILDER_BINPATH` to use an explicit local builder binary.

### Examples

```bash
# Build only; do not deploy the runtime.
ar runtime cloud-build -f runtime-build.yaml
```

---

## render
Expand All @@ -91,8 +150,10 @@ ar runtime render -f FILE

Validates the YAML, applies CLI auto-injection (`system_tags=["x-agentrun-cli"]`,
`artifact_type=Container`, default endpoint when `spec.endpoints` is omitted),
and prints the SDK create-input as JSON without calling the server. Use this to
preview changes before `apply`.
and prints the SDK create-input as JSON without calling the server. When the
YAML includes `cloudBuild`, `render` also prints a `cloudBuildPlan` preview but
does not check the registry or build anything. Use this to preview changes
before `apply`.

---

Expand Down
Loading
Loading