# 產物

> Agent 用來為使用者發佈頁面與小型網站的 artifact 工具，支援版本、集合、預覽與連結。

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

**產物**（artifact）是 Agent 為使用者發佈的頁面或小型網站，例如示範、文件、報告或儀表板。它屬於團隊，具有一個連結，並保留所有歷史版本。使用者可以從聊天中的卡片，或從專案的**產物**分頁開啟它。

Agent 透過單一工具 `artifact` 處理產物，共有四個動作：`publish`、`get`、`list` 與 `update`。這是 Agent 呼叫的工具，而不是 shell 指令。

## 執行位置

雲端團隊與 Mac 團隊上的 Agent 都能使用這個工具。無論哪一種，產物都由 AirBuild 儲存，而不是存放在專案的檔案或儲存庫中。請參閱[選擇 Agent 的執行位置](https://air.build/tw/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` | 資料夾或檔案；相對路徑從 Agent 的工作資料夾起算 | — | 要發佈的內容。必填。請參閱[可以發佈的內容](https://air.build/tw/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/tw/docs/cli/artifacts/#previews)。 |
| `channel_id` | `list` | 一個聊天 | 整個團隊 | 只顯示卡片曾傳送到此聊天的產物。Agent 必須在該聊天中。 |
| `before` | `list` | 上一頁提供的游標 | 第一頁 | 下一頁結果。 |

沒有 `visibility` 參數。誰能開啟產物由使用者在 App 中設定，Agent 永遠不能設定；請見[誰可以檢視](https://air.build/tw/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/tw/docs/cli/artifacts/#who-can-view)改回團隊。

## 誰可以檢視

每個產物都有自己的連結，格式如下：

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

誰能開啟它，取決於產物的**誰可以檢視**設定。共有兩個選項：

| 選項 | 值 | 誰能開啟頁面 |
| --- | --- | --- |
| **_你的團隊名稱_ 中的所有人** | `workspace` | 只有團隊中的人及其 Agent。 |
| **擁有連結的任何人** | `public` | 任何擁有連結的人，包括 AirBuild 以外的人。 |

新產物對任何擁有連結的人開放。使用者可以從產物的選單將它縮限為僅限團隊開啟。2026 年 11 月 20 日，所有僅限團隊開啟的產物都已改為對任何擁有連結的人開放，因此請檢查哪些產物應該只留在團隊內。在聊天中傳送產物的卡片，並不會改變誰能開啟它。

頁面上方會有一條細列，顯示標題、團隊名稱、`v<N>` 以及 "Made by an AI Agent — not verified by AirBuild"（由 AI Agent 製作，未經 AirBuild 驗證），下方則是產物內容。頁面會要求搜尋引擎不要建立索引。

### 變更設定

只有使用者能變更誰可以檢視，Agent 永遠不能。團隊中的任何人都可以從產物的選單中變更：

- 聊天中卡片的選單。在 iPhone 與 iPad 上，選擇**誰可以檢視…**，再選擇新的選項。
- 專案**產物**分頁中圖塊的選單。
- 顯示該產物的網站分頁的 **⋯** 選單，以及該分頁本身的選單。

在頁面對任何擁有連結的人開放之前，AirBuild 會詢問「允許擁有連結的任何人檢視此頁面？」，並附上訊息「擁有連結的任何人都能檢視此頁面，包括 AirBuild 以外的人。」選擇**允許任何人檢視**繼續，或選擇**取消**維持原狀。

從這些選單分享一個並未對任何擁有連結的人開放的頁面時，分享內容會附上提示「只有 _你的團隊名稱_ 中的人才能打開此連結。」

若 AirBuild 無法完成變更，會跳出提示「無法更改誰可以檢視」說明原因，並附有**好**按鈕，選單也會回到先前的設定。

Agent 無法設定或變更誰可以檢視。若它向工具傳入 `visibility`，呼叫會被拒絕（請見[錯誤](https://air.build/tw/docs/cli/artifacts/#errors)）。每次 `publish`、`get` 與 `list` 都會說明產物目前是哪一種設定。

### 要給別人的連結

給別人的一律是產物的連結 `https://airbuild.page/<artifact-id>`：不論是在訊息中、卡片上或其他任何地方。Agent 也可以開啟同一個連結。在以 `browser start` 啟動的工作階段中，對該連結執行 `browser open` 會依團隊中的人所看到的樣子顯示頁面，因此僅限團隊檢視的產物也能開啟。請見 [browser](https://air.build/tw/docs/cli/browser/)。

`publish` 與 `get` 也會回傳該版本專屬頁面的網址。與連結不同，它會固定在該版本上，而且是暫時的、私人的。它只供 Agent 檢查自己的呈現結果，例如用 [browser](https://air.build/tw/docs/cli/browser/) 檢查。工具會提醒永遠不要分享它。

## 在聊天中顯示

發佈本身不會張貼任何內容。若要顯示產物，Agent 需以 `bot_send_card` 傳送其卡片：

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

AirBuild 會自動填入標題、類型、最新版本、摘要與連結。卡片可隨時在 Agent 所在的任何聊天中再次傳送。卡片顯示的是傳送當時該版本的截圖；點開後會開啟產物的頁面，顯示最新版本。若某則訊息（無論來自使用者或 Agent）只有一個產物連結而沒有其他內容，也會變成該產物的卡片。

產物的卡片傳送到某個聊天後，就會出現在該聊天的清單，以及專案的**產物**分頁中。

## 集合

集合是 Agent 用來歸類產物的名稱，例如 "Websites"。一個產物只屬於一個集合，或不屬於任何集合。帶 `collection` 的 `publish` 會同時歸類該版本與產物；`update` 會重新歸類現有產物，但不建立新版本，且保留其排序位置。`list` 會列出每個集合及其數量，讓 Agent 能完全一致地重複使用名稱。

## 預覽

每個版本都會以淺色模式、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` 會將最新版本解開到 Agent 草稿中的一個新資料夾；絕不會覆寫現有資料夾：

```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/tw/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` 是 Agent 不在其中的聊天。 |
| `Could not <act> (HTTP 400 [invalid_cursor]): …` | 請完全依照上一頁提供的值傳入 `before`。 |
| `Could not <act> (HTTP 413 …): …` | 版本太大。 |

## 在 App 中

專案的**產物**分頁（「查看代理發佈的頁面和文件。」）會顯示卡片曾傳送到專案聊天中的所有產物，最新的卡片排在最前，並分為**今天**、**昨天**、**過去 7 天**與**過去 30 天**等區段。分頁上有**全部**與各集合的標籤，可用**搜尋產物**搜尋標題，並可切換格狀或清單版面。每個產物都會以網頁開啟，其選單中有**打開**、**拷貝連結**、**分享…** 與 [**誰可以檢視**](https://air.build/tw/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" } }
```
