# listDocuments()

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/tools/list-documents/
Language: zh

`api.tools.listDocuments() → Promise<Source[]>`

账户上保存的每一文件文件,没有争论,没有信用,也没有快捷的快捷键 api.files.list().

Status: GET /api/files · free · no arguments

和 [api.files.list()](/zh/sdk/ref/files/list), , 现时 `api.tools` 以便“列出我所拥有的东西”可以作为工具交给一个模型。

## 返回值 {#returns}

```javascript
[
  {
    id: "…",                       // the sourceId, to pass to readDocument()
    name: "report.md",
    category: "document",          // document | image | audio | video
    mimeType: "text/markdown",
    size: 9118,
    storageId: "…",                // where it lives, or null
    status: "ready",
    createdAt: "2026-10-05T18:02:11.000Z"
  }
]
```

> **服务器布局没有显示**
>
> 文件由文件的代号识别, 而不是在磁盘上路径识别。 这就是将一个能从任何地方( 您的脚本、 页面、 运行) 找到的代号保存在任何位置, 却不知道字节坐在哪里 。

## 列出什么,没有列出什么 {#scope}

| 名单清单 | 没有列出 |
| --- | --- |
| 文件保存通过 `api.files` | 电脑上的档案文件 [files.list()](/zh/sdk/ref/local-files/list) |
| 为账户存储的附加附件 | 桶中的东西——这些是 `run({ action: "list" })` |
| 生成和保存的媒体 | 手机浏览器里的任何信息 |

## 作为一种工具 {#as-a-tool}

它是少数没有争论的申报单之一,运行比一个光列出的单子更能说明问题:它用账户的文档回答问题 **和** 打电话者计算机的文件, 每个组名, 所以模型知道下一步要使用哪个标识符, 一个代号, 另一个路径。

```javascript
tools: {
  list_documents: api.tools.listDocuments,
  read_document: api.tools.readDocument,
}

// What the model is told, in a run:
// { computer: { storage: "MacBook", files: [{ path, mimeType, size }] },
//   server:   [{ sourceId, name, mimeType }] }
```

## 错误 {#errors}

失败会引发服务器发送的信息。 没有空结果错误: 账户没有文件回答, 且没有空数组 。

- [readDocument()](/zh/sdk/ref/tools/read-document): 读一个回去。
- [api.files](/zh/sdk/ref/files): 完整文件资源 。
- [api.tools](/zh/sdk/ref/tools): 十五个,用它们的两个方法

```python
documents = api.tools.list_documents()
# {
#   "computer": [{"name", "path", "type", "size"}],          # ~/.iagenify/files
#   "account":  [{"id": "…",                                  # the sourceId, for read_document()
#                 "name": "report.md", "category": "document",
#                 "mimeType": "text/markdown", "size": 9118,
#                 "storageId": "…", "status": "ready",
#                 "createdAt": "2026-10-05T18:02:11.000Z"}]
# }
```

```python
tools = {
    "list_documents": api.tools.list_documents,
    "read_document": api.tools.read_document,
}

# What the model is told, in a run:
# {"computer": {"storage": "MacBook", "files": [{"path", "mimeType", "size"}]},
#  "server":   [{"sourceId", "name", "mimeType"}]}
```
