# 能力 能力 框架

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/iagenify/env/
Language: zh

`api.env · api.capabilities · api.framework`

搞什么 SDK 确定它运行的地点。 三个属性, 建筑时读过一次, 它们是引擎分支的 。

Status: read at construction · no I/O · 自动检测

您无法设置这些 。 它们被检测到, 它们很重要, 因为他们决定了会话在哪里缓存, 代理器是否可以运行命令, 以及服务器对调用器的了解 。

## 千 千 {#env}

| 值 | 检测自 |
| --- | --- |
| 节点 | process.versions.node 字符串 |
| 工人工人 | 时间 时间 确定自己是 云花工人 |
| 浏览器 | window.document 存在已存在 |
| 未知 | 以上各款中,无一与上述一款对齐。 |

顺序事项: Node 首先测试,然后测试工人,然后测试浏览器。所以一个捆绑机,它会打 `process` 页面中该页面的页面 `node` - 之后 `env` 确定会话仓库, 这是在捆绑的应用程序中缓存行为异常时首读的 。

```javascript
console.log(api.env, api.framework, api.capabilities);
// "node" "next.js" { runtime: "node", shell: true, … }   ← server
// "browser" "next.js" { runtime: "browser", shell: false, … } ← page
```

## 能力能力 {#capabilities}

```javascript
{
  runtime: "node",
  shell: true,              // commands can be run here
  filesystem: true,         // files can be read and written here
  persistentStorage: true,  // a session survives a restart
  http: true                // always true
}
```

| 能力 | 节点 | 浏览器 | 工人工人 |
| --- | --- | --- | --- |
| 贝壳 | 否 是 | 无 无 | 无 无 |
| 文件系统 | 否 是 | 无 无 | 无 无 |
| 持久性压力 | 否 是 | 否 是 | 无 无 |
| http http 上 | 否 是 | 否 是 | 否 是 |

这些描述时间描述的是一个运行时间, 不是允许。 授权是一个单独的决定, 由您自己回调的呼叫决定 。 运行时间 *能够* 运行命令仍然在它之前询问。请参见 [权限权限](/zh/sdk/agent/permissions).

## 每一变化的 {#consequences}

| 能力 | 假的 手段 |
| --- | --- |
| 贝壳 | 不准打球工具 除非你提供空壳桥 |
| 文件系统 | 此运行时无工作空间; 文件工具需要一个文件桥 。 |
| 持久性压力 | 届会只要能持续到这一过程,然后又会再次交换。 |

桥就是没有功能的运行时间如何得到行为:工具电话被转发到可以运行它的地方,答案又回来了。这正是手机——没有贝壳,没有文件系统——仍然读取文件并运行命令的方式。 [桥桥](/zh/sdk/agent/bridges).

```javascript
const tools = api.capabilities.shell
  ? api.tools.all
  : api.tools.all.filter((name) => name !== "bash" && name !== "terminal");

const agent = api.agents.create({ runtime: "local", machine: pc, tools });
```

## 框架框架框架框架 {#framework}

| 值 | 检测自 |
| --- | --- |
| next.js | 页面上带有下自有的全局 |
| 冈斯比 | 上面有盖茨比的全局 |
| 维 | 模块 URL 名 名 名 维 照 |
| 浏览器 | a页,以上无一 |
| 节点 | 根本没有窗口 |

> **服务器运行时在此读取节点**
>
> 框架检测查看页面。 没有窗口- Node, 以及一个工人——它回答节点。当您想要运行时间时读取 env;阅读框架只是为了学习周围是哪个页面框架。

## 服务器上有什么能连上服务器 {#sent}

运行时间和框架随关键交换器进行旅行,还有一台机器代号,它来自东道方自己的名称、平台、架构和运行时间版本,每个后期请求都包含该代号以及可以检测到的任何资源。

| 发送发送 | 设计目的 |
| --- | --- |
| 运行时间和框架 | 因此,可以在同一原因上将会议与会议分开。 |
| 机器id | 所以在重开点之间 识别一台机器 而不是两次注册 |
| 检测到的资源 | 机器存储器可以报告自己的磁盘 CPU 和 GPU. |

资源探测是最努力和最静默的资源探测:它无法读的东西根本就不存在,没有问题。 完整页眉列表, 以及如何打印您所发送的 进程 , 正在打开 [请求标题](/zh/sdk/concepts/request-headers).

## 分行在 {#recipes}

```javascript
if (!api.capabilities.persistentStorage) {
  // Nothing is cached between runs: each one exchanges the key once.
  // Supply a storage you control if you want the session to outlive the process.
}

if (api.env === "browser") {
  // A real key must not be here. Call your own server instead.
}

if (api.env === "unknown") {
  // An unrecognised runtime. HTTP works; assume nothing else does.
}
```

- [运行环境](/zh/sdk/runtimes): 每一个运行时间支持什么 和它要求你什么
- [请求标头](/zh/sdk/concepts/request-headers): 请求随处可见 如何看待
- [桥接](/zh/sdk/agent/bridges): 给一个运行时间 一种它不具备的能力。

```python
print(api.env, api.framework, api.capabilities)
# "python" "python" {"runtime": "python", "shell": True, ...}
```

```python
{
    "runtime": "python",
    "shell": True,               # commands can be run here
    "filesystem": True,          # files can be read and written here
    "persistentStorage": True,   # a session survives a restart
    "http": True,                # always True
}
```

```python
tools = (
    list(api.tools.all)
    if api.capabilities["shell"]
    else [name for name in api.tools.all if name not in ("bash", "terminal")]
)

agent = api.agents.create(runtime="local", machine=pc, model=model, tools=tools)
```

```python
if not api.capabilities["persistentStorage"]:
    # Nothing is cached between runs: each one exchanges the key once.
    # Supply a storage you control if you want the session to outlive the process.
    pass

# A Python process is always a server or a script: a real key belongs here,
# never in the browser pages it serves.
```
