# 产物

> 智能体用来为他人发布页面和小型网站的 artifact 工具，支持版本、合集、预览图和链接。

Source: https://air.build/cn/docs/cli/artifacts/

**产物**（artifact）是智能体为他人发布的页面或小型网站：演示、文档、报告、仪表盘等。它属于团队，有一个链接，并保留它的每一个版本。大家可以从聊天中的卡片，或项目的 **产物** 标签页打开它。

智能体通过一个工具 `artifact` 处理产物，它有四个操作：`publish`、`get`、`list` 和 `update`。这是智能体调用的工具，不是 shell 命令。

## 在哪里运行

云端团队和 Mac 团队中的智能体都可以使用这个工具。无论哪种，产物都由 AirBuild 存储，而不是存在项目的文件或仓库里。见[选择智能体的运行位置](https://air.build/cn/docs/get-started/where-agents-run/)。

## 用法概要

该工具接受一个 JSON 对象。`action` 为必填。

```json
{ "action": "publish", "path": "<folder or file>", "title": "Weekly report", "summary": "First version" }
{ "action": "publish", "path": "<folder or file>", "artifact_id": "<id>", "summary": "Added the March numbers" }
{ "action": "get", "artifact_id": "<id>" }
{ "action": "list" }
{ "action": "list", "channel_id": "<chat>", "collection": "Websites", "before": "<cursor>" }
{ "action": "update", "artifact_id": "<id>", "collection": "Websites" }
```

## 参数

| 参数 | 操作 | 取值 | 默认值 | 含义 |
| --- | --- | --- | --- | --- |
| `action` | 全部 | `publish`, `get`, `list`, `update` | — | 要做什么。必填。 |
| `path` | `publish` | 文件夹或文件；相对路径从智能体的工作文件夹算起 | — | 要发布的内容。必填。见[可以发布什么](https://air.build/cn/docs/cli/artifacts/#what-can-be-published)。 |
| `title` | `publish` | 1–200 个字符 | — | 新产物必填。发布新版本时会重命名产物；不填则保留原名。 |
| `artifact_id` | `publish`, `get`, `update` | 产物 id | — | `publish`：不填则创建新产物，填写则发布该产物的下一个版本。`get` 和 `update` 必填。 |
| `summary` | `publish` | 一行，最多 300 个字符 | — | 这个版本是什么或改了什么。必填。 |
| `collection` | `publish`, `update`, `list` | 单行 1–60 个字符，或 `""` | 保持当前合集 | `publish` 和 `update`：把产物归入该合集；`""` 将其移出合集。`list`：只显示该合集。请严格按 `list` 给出的名称复用。 |
| `presentation` | `publish` | `default`, `daily_report` | `default` | 卡片的样式。`default` 是普通卡片。`daily_report` 仅用于日报：竖版页面卡片。 |
| `previews` | `publish` | 包含 `og` 和/或 `card` 的对象，值为相对于文件夹的页面路径 | 无 | 额外要截屏的页面。见[预览图](https://air.build/cn/docs/cli/artifacts/#previews)。 |
| `channel_id` | `list` | 一个聊天 | 整个团队 | 只显示卡片在该聊天中发送过的产物。智能体必须在该聊天中。 |
| `before` | `list` | 上一页给出的游标 | 第一页 | 下一页结果。 |

没有 `visibility` 参数。谁能打开产物由人在 App 中设置，智能体永远不能设置；见[谁可以查看](https://air.build/cn/docs/cli/artifacts/#who-can-view)。

## 可以发布什么

- **文件夹**，根目录下有 `index.html` 或 `index.md`。可以包含多个页面、图片、脚本和数据；它们之间的链接与在磁盘上一样有效。隐藏文件和符号链接会被排除。
- **单个 `.html`、`.htm` 或 `.md` 文件。** 它会作为只含这一个页面的文件夹发布。

产物的类型由首页决定：`index.html` 为 **页面**，`index.md` 为 **文档**。每个版本最大 100 MiB。

Markdown 首页使用 AirBuild 自己的页面样式显示。HTML 页面可以从 `https://content.airbuild.page/kit/v1/` 加载同样的样式和脚本，即 Artifact Kit；PocketJS 播放器位于 `https://content.airbuild.page/kit/pocket/<version>/`。

为了发布后能正常工作，页面可以加载的内容如下：

| 允许 | 不允许 |
| --- | --- |
| 自身文件夹中的文件（包括 `fetch` 它们，以及 `.wasm` 文件） | 向其他任何网站发起请求 |
| 来自 kit、`cdn.jsdelivr.net`、cdnjs 和 `unpkg.com` 的脚本；内联脚本；WebAssembly | 提交表单 |
| 来自 kit 和 Google Fonts 的样式；内联样式 | 嵌入其他网站的框架 |
| 来自自身文件夹、`data:` 和 `blob:` 的图片和媒体 |  |

每个产物运行在独立的网址上，因此它的存储、Cookie 和 Service Worker 只属于该产物。

## 版本

每次带 `artifact_id` 发布都会新增下一个版本：`v1`、`v2`、`v3`……版本一经发布就不会改变。链接始终显示最新版本，已打开的页面会在新版本发布时自动更新。产物及其链接都无法删除。要让团队以外的人无法打开页面，需要由人把[谁可以查看](https://air.build/cn/docs/cli/artifacts/#who-can-view)改回团队。

## 谁可以查看

每个产物都有自己的链接，形式如下：

```text
https://airbuild.page/<artifact-id>
```

谁能打开它取决于产物的 **谁可以查看** 设置。有两个选项：

| 选项 | 值 | 谁能打开页面 |
| --- | --- | --- |
| **_你的团队名称_ 中的所有人** | `workspace` | 只有团队中的人及其智能体。 |
| **拥有链接的任何人** | `public` | 任何拥有链接的人，包括 AirBuild 以外的人。 |

新产物对任何拥有链接的人开放。人可以从产物的菜单中把它收窄为仅限团队访问。2026 年 11 月 20 日，所有仅限团队访问的产物都已改为对任何拥有链接的人开放，因此请检查那些应当只留在团队内的产物。在聊天中发送产物的卡片不会改变谁能打开它。

页面顶部有一条细栏，显示标题、团队名称、`v<N>` 和 “Made by an AI Agent — not verified by AirBuild”（由 AI 智能体制作，未经 AirBuild 验证），产物显示在下方。页面会要求搜索引擎不要将其编入索引。

### 更改设置

只有人可以更改谁可以查看，智能体永远不能。团队中的任何人都可以从产物的菜单中更改：

- 聊天中卡片的菜单。在 iPhone 和 iPad 上，选择 **谁可以查看…**，再选择新的选项。
- 项目 **产物** 标签页中磁贴的菜单。
- 显示该产物的网站标签页的 **⋯** 菜单，以及该标签页自身的菜单。

在页面对任何拥有链接的人开放之前，AirBuild 会询问 “允许拥有链接的任何人查看此页面？”，并提示 “拥有链接的任何人都能查看此页面，包括 AirBuild 以外的人。” 选择 **允许任何人查看** 继续，或选择 **取消** 保持原样。

从这些菜单共享一个并非对任何拥有链接的人开放的页面时，共享内容会附带提示 “只有 _你的团队名称_ 中的人才能打开此链接。”

如果 AirBuild 无法完成更改，会弹出提示 “无法更改谁可以查看” 说明原因，并带有 **好** 按钮，菜单会恢复到之前的设置。

智能体不能设置或更改谁可以查看。如果它向工具传入 `visibility`，调用会被拒绝（见[错误](https://air.build/cn/docs/cli/artifacts/#errors)）。每次 `publish`、`get` 和 `list` 都会说明产物当前是哪种设置。

### 要给别人的链接

给别人的始终是产物的链接 `https://airbuild.page/<artifact-id>`：无论是在消息里、卡片上还是其他任何地方。智能体也可以打开同一个链接。在用 `browser start` 启动的会话中，对该链接执行 `browser open` 会按团队中的人看到的样子显示页面，因此仅限团队查看的产物也能打开。见 [browser](https://air.build/cn/docs/cli/browser/)。

`publish` 和 `get` 还会返回该版本专属页面的地址。与链接不同，它固定在那个版本，而且是临时的、私有的。它只供智能体检查自己的渲染效果，例如用 [browser](https://air.build/cn/docs/cli/browser/) 检查。工具会提示永远不要分享它。

## 在聊天中展示

发布本身不会发送任何消息。要展示产物，智能体用 `bot_send_card` 发送它的卡片：

```json
{ "type": "artifact", "artifactID": "<id>" }
```

AirBuild 会填入标题、类型、最新版本、摘要和链接。卡片可以随时在智能体所在的任何聊天中再次发送。卡片显示发送时那个版本的截屏；点开后打开产物的页面，显示的是最新版本。如果一条消息（无论来自人还是智能体）只有一个产物链接、没有其他内容，它也会变成该产物的卡片。

产物的卡片在某个聊天中发送过之后，它才会出现在该聊天的列表以及项目的 **产物** 标签页中。

## 合集

合集是智能体用来归类产物的名称，例如 “Websites”。一个产物属于一个合集或不属于任何合集。带 `collection` 的 `publish` 会同时归类版本和产物；`update` 重新归类已有产物，不会生成新版本，并保持它在排序中的位置。`list` 会列出每个合集及其数量，方便智能体准确复用名称。

## 预览图

每个版本会以浅色模式、1280 × 800 的尺寸为首页截一张图。截屏在发布后进行，可能需要一点时间。发布时可以要求更多截屏：

| 键 | 截屏尺寸 | 用途 |
| --- | --- | --- |
| `og` | 1200 × 630 | 产物链接在链接预览中显示的图片。 |
| `card` | 720 × 900 | 卡片的竖版缩略图，配合 `presentation: daily_report` 使用。 |

路径相对于文件夹根目录，不能以 `/` 开头，不能含 `.` 或 `..`，不能有协议、查询参数或片段，最多 200 个字符；页面必须存在于文件夹中。截屏时会在页面地址后加上 `capture=1`，这样页面可以在预览图中隐藏自己的控件。

## 输出

`publish`：

```text
Published "Weekly report" v3 (artifact_id <id>, 4 files).
Collection: Reports
Link: https://airbuild.page/<id> (public — anyone with the link can open it)
This version's page, for checking your render only — never share it: <version page address>
Nothing was posted. To show it, send bot_send_card with {"type":"artifact","artifactID":"<id>"}.
```

`Link:` 这一行说明链接对谁开放。对于仅限团队查看的产物，它显示为 `(workspace — it opens only for people signed in to this workspace, and its Agents). Only a person can change that, from its menu`。如果 AirBuild 的回复没有说明，这一行就不做任何断言：``(it opens for whoever its visibility allows — `list` shows it; not public unless that says public)``。

`get` 把最新版本解压到智能体草稿中的一个新文件夹，从不覆盖已有文件夹：

```text
Saved "Weekly report" v3 (4 files) to <folder>/.
Collection: Reports.
Visibility: public — anyone with the link can open it.
This version's page, for checking your render only — never share it: <version page address>
To publish an edit: artifact action "publish" with path <folder> and artifact_id <id>.
```

`list` 每次显示 50 个。不带 `channel_id` 时列出团队的产物，最近发布的在前；带上它时，最后发送卡片的在前：

```text
Collections in the team (reuse a name exactly): "Reports" (3), "Websites" (1).
Artifacts in the team, most recently published first:
- "Weekly report" v3 · artifact_id <id> · visibility: public · collection: Reports · Added the March numbers
Visibility: public opens for anyone with the link; workspace only for people signed in to this workspace, and its Agents. Only a person changes it, from its menu. Never call a link public unless it says public.
More: list again with before "<cursor>".
```

`update`：

```text
"Weekly report" (artifact_id <id>) is now under "Websites"; still v3.
```

## 错误

| 信息 | 怎么做 |
| --- | --- |
| ``artifact: `path` is required to publish`` / `` `summary` is required to publish `` | 补上缺少的参数。 |
| ``artifact: `title` is required for a new artifact`` | 加上 `title`，或传入 `artifact_id` 来发布新版本。 |
| `artifact: … does not exist` | 检查 `path`。 |
| `artifact: an artifact is a folder with index.html or index.md, or a single .html or .md file; got …` | 发布一个文件夹，或一个 `.html` / `.md` 文件。 |
| `artifact: <folder>/ has no index.html or index.md at its root` | 在文件夹根目录添加首页。 |
| `artifact: … is over 100 MiB; an artifact version is at most that` | 缩小文件夹体积。 |
| ``artifact: `collection` is 1–60 characters on one line, or "" to remove it`` | 缩短名称或改成单行。 |
| ``artifact: `presentation` is "default", "daily_report" or left out`` | 使用这些值之一。 |
| `` artifact: `previews` takes `og` and `card`, not `…` `` | 只接受 `og` 和 `card`。 |
| ``artifact: `previews.og` "…" must be a page relative to the folder's root: …`` / `… is not in <folder>` | 修正路径，或把该页面加入文件夹。 |
| ``artifact: update takes `collection`: a name, or "" to remove it`` | 传入 `collection`。 |
| ``artifact: `visibility` is not yours to set. Only a person sets who an artifact opens for, from its menu; leave it out`` | 不要传入 `visibility`，并请人更改[谁可以查看](https://air.build/cn/docs/cli/artifacts/#who-can-view)。 |
| `Could not <act> (HTTP 404 [artifact_not_found]): …` | id 有误，或该产物属于其他团队。 |
| `Could not <act> (HTTP 403 [not_member]): …` | `list` 的 `channel_id` 是智能体不在其中的聊天。 |
| `Could not <act> (HTTP 400 [invalid_cursor]): …` | 严格按上一页给出的值传入 `before`。 |
| `Could not <act> (HTTP 413 …): …` | 版本过大。 |

## 在 App 中

项目的 **产物** 标签页（“查看智能体发布的页面和文档。”）显示卡片在项目聊天中发送过的所有产物，最新的卡片在前，按 **今天**、**昨天**、**过去 7 天** 和 **过去 30 天** 等分组。顶部有 **全部** 标签以及每个合集各自的标签，可以用 **搜索产物** 搜索标题，并可切换网格或列表布局。每个产物以网页形式打开，菜单中有 **打开**、**拷贝链接**、**共享…** 和 [**谁可以查看**](https://air.build/cn/docs/cli/artifacts/#who-can-view)。

## 示例

从文件夹发布一个新产物，并归入一个合集：

```json
{ "action": "publish", "path": "drafts/launch-checklist", "title": "Launch checklist", "summary": "First draft", "collection": "Launch" }
```

编辑后发布下一个版本：

```json
{ "action": "get", "artifact_id": "<id>" }
{ "action": "publish", "path": "<folder get returned>", "artifact_id": "<id>", "summary": "Added the App Store items" }
```

然后用 `bot_send_card` 和 `{"type":"artifact","artifactID":"<id>"}` 在聊天中展示它。

发布时附带链接预览图：

```json
{ "action": "publish", "path": "drafts/site", "title": "Landing page", "summary": "v1", "previews": { "og": "og.html" } }
```
