> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 快速入门

> 创建一个 outpost，并通过单台机器提供会话服务

<Accordion title="前提条件">
  * 一个已启用 Outposts 的组织
  * 一个具有相应 Outposts 作用域的 [v3 API 令牌](/zh/api-reference/v3/overview)：
    * `account.outposts.orchestrator`，用于管理 outpost 的协调器 (包含 machine 作用域)
    * `account.outposts.machine`，供工作器读取队列并认领/释放会话
  * 一台机器 (VM 或容器) ，并满足：
    * 已安装 Devin CLI
    * 具备[机器依赖项](/zh/cloud/outposts/overview#machine-dependencies)
    * 已克隆你的代码仓库，并已配置远程仓库
    * 可访问你的会话所需的构建工具、软件包仓库、secrets 和内部服务
</Accordion>

<Tabs>
  <Tab title="你的主机">
    <Note>
      会话会直接在拥有你用户权限的机器上执行。我们建议在你愿意让 Agent
      自由操作的专用目录下运行工作器——更好的是，在一台专门用于长期运行以 Agent 为核心任务的机器上运行，例如你桌上的 Mac Mini。
    </Note>

    <Steps>
      <Step title="安装 Devin CLI">
        下载并安装 [Devin CLI](/zh/cli)：

        ```bash theme={null}
        curl -fsSL https://cli.devin.ai/install.sh | bash
        ```
      </Step>

      <Step title="创建一个 outpost">
        在 [Devin Cloud](https://app.devin.ai) 中，前往 Settings → Environment → Outposts，然后点击 "Create Outpost" 按钮。

        <video autoPlay muted loop playsInline className="w-full aspect-video" src="https://mintcdn.com/cognitionai/xlfcZs3jVVOLjL3w/images/onboard-devin/outposts/outposts-settings.mp4?fit=max&auto=format&n=xlfcZs3jVVOLjL3w&q=85&s=4a08b9c473c66d33aa6e148edd7ec675" data-path="images/onboard-devin/outposts/outposts-settings.mp4" />

        为你的 Outpost 命名，并选择它将提供服务的机器类型 (例如 Linux、Windows 或 Mac) 。然后点击 "Create" 按钮。

        <Frame>
          <img src="https://mintcdn.com/cognitionai/xlfcZs3jVVOLjL3w/images/onboard-devin/outposts/create-outpost.png?fit=max&auto=format&n=xlfcZs3jVVOLjL3w&q=85&s=452beb7a9d7a38d185f3c04331e2f7bf" alt="创建 outpost 对话框" style={{ width: "400px", height: "auto" }} width="996" height="908" data-path="images/onboard-devin/outposts/create-outpost.png" />
        </Frame>

        创建 Outpost 后，你会获得一个 Outpost 令牌，分配给它的工作器将使用该令牌向 Devin 进行身份验证。

        复制该令牌并将其保存在安全的地方，以便后续使用。**该令牌只会在你创建 Outpost 时显示一次**。
      </Step>

      <Step title="运行你的 Outpost 工作器">
        进入你希望工作器运行的目录：

        ```bash theme={null}
        cd /path/to/worker/directory
        ```

        然后使用你之前复制的 Outpost 名称和令牌运行 `devin worker start` 命令：

        ```bash theme={null}
        devin worker start --outpost=<your-outpost-name> --token=<your-outpost-token>
        ```
      </Step>

      <Step title="启动一个新的 Outpost 会话">
        在 [Devin Cloud](https://app.devin.ai) 中，启动一个新会话并将其配置为在你的 Outpost 上运行。在 "Configuration" → "Virtual environment" 下，你会看到新创建的 Outpost 已列出。选择它即可让会话在其上运行。

        <video autoPlay muted loop playsInline className="w-full aspect-video" src="https://mintcdn.com/cognitionai/xlfcZs3jVVOLjL3w/images/onboard-devin/outposts/select-outpost.mp4?fit=max&auto=format&n=xlfcZs3jVVOLjL3w&q=85&s=0f8d6595eac8eac7227c25a389cc027b" data-path="images/onboard-devin/outposts/select-outpost.mp4" />

        现在你可以让 Devin 开始在你的机器上进行构建了！试试这样一个简单的请求：

        ```
        Create a "hello world" python script for me
        ```

        然后你就会看到脚本出现在工作器的目录中！
      </Step>
    </Steps>

    ### 后续步骤

    在你的代码所在目录中启动工作器，然后让 Devin 在其基础上进行构建。会话可以看到工作器工作目录下已检出的代码仓库。要同时处理更多会话，请在更多机器上运行指向同一 outpost 的工作器：N 个工作器可处理 N 个并发会话，其余会在队列中等待。

    <CardGroup cols={2}>
      <Card title="编排" icon="diagram-project" href="/zh/cloud/outposts/orchestration">
        在会话进入队列时自动预配机器，而不是始终保留长期运行的工作器。
      </Card>

      <Card title="集成" icon="plug" href="/zh/cloud/outposts/overview#integrations">
        在你已经使用的平台上运行你的 outpost——Namespace、Modal、E2B 等。
      </Card>
    </CardGroup>
  </Tab>

  <Tab title="Docker">
    <Steps>
      <Step title="创建 outpost">
        在 [Devin Cloud](https://app.devin.ai) 中，前往 Settings → Environment → Outposts，然后点击 "Create Outpost" 按钮。

        <video autoPlay muted loop playsInline className="w-full aspect-video" src="https://mintcdn.com/cognitionai/xlfcZs3jVVOLjL3w/images/onboard-devin/outposts/outposts-settings.mp4?fit=max&auto=format&n=xlfcZs3jVVOLjL3w&q=85&s=4a08b9c473c66d33aa6e148edd7ec675" data-path="images/onboard-devin/outposts/outposts-settings.mp4" />

        为你的 Outpost 命名，并选择 Linux 作为平台 (你的容器运行在 Linux 上) 。然后点击 "Create" 按钮。

        <Frame>
          <img src="https://mintcdn.com/cognitionai/xlfcZs3jVVOLjL3w/images/onboard-devin/outposts/create-docker-outpost.png?fit=max&auto=format&n=xlfcZs3jVVOLjL3w&q=85&s=33e17e70904be599623231fcd2a05861" alt="创建 Outpost 对话框" style={{ width: "400px", height: "auto" }} width="996" height="908" data-path="images/onboard-devin/outposts/create-docker-outpost.png" />
        </Frame>

        创建 Outpost 后，你会获得一个 Outpost 令牌；你想分配给它的工作器将使用该令牌向 Devin 进行身份验证。

        复制该令牌并将其保存在安全的位置，以便后续使用。**该令牌只会在创建 Outpost 时显示一次**。
      </Step>

      <Step title="构建工作器镜像">
        基于官方 Devin CLI 镜像 (`public.ecr.aws/e0h8a4b6/devin-cli`) 构建，并添加[机器依赖项](/zh/cloud/outposts/overview#machine-dependencies)以及会话所需的任何代码仓库或工具：

        ```dockerfile Dockerfile theme={null}
        # Devin CLI 已预装，是该镜像的 entrypoint。
        # 使用 :stable，或固定到特定的 CLI 版本标签。
        FROM public.ecr.aws/e0h8a4b6/devin-cli:stable

        # git 为必需项；ffmpeg 可启用屏幕录制功能
        RUN apt-get update && apt-get install -y --no-install-recommends \
            ca-certificates git ffmpeg \
            && rm -rf /var/lib/apt/lists/*

        # 工作器运行所在的目录
        WORKDIR /repos

        # 可选：克隆你的 session 所需的代码仓库：
        # RUN git clone https://github.com/your-org/app.git \
        #     && git clone https://github.com/your-org/infra.git

        CMD ["worker", "start"]
        ```

        或者让 Devin 帮你创建一个 Dockerfile：

        ```
        Write a Dockerfile for a Devin Outposts worker image. Base it on
        public.ecr.aws/e0h8a4b6/devin-cli:stable, which has the Devin CLI preinstalled
        as the image's entrypoint. Install git and ffmpeg. Clone these repositories
        into the working directory the worker runs in: <your repos>. The default
        command should be ["worker", "start"].
        ```

        <Note>
          Browser 功能需要在镜像中安装 Chrome 或 Chromium，并将
          `DEVIN_CHROME_PATH` 指向该二进制程序。基础镜像是 Ubuntu，而
          Ubuntu 的 `chromium` apt 软件包只是一个 snap 占位包，在
          容器中无法工作——对于 amd64 镜像，请改为安装 Google Chrome：

          ```dockerfile theme={null}
          RUN apt-get update && apt-get install -y --no-install-recommends curl \
              && curl -fsSL https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /tmp/chrome.deb \
              && apt-get install -y --no-install-recommends /tmp/chrome.deb \
              && rm /tmp/chrome.deb && rm -rf /var/lib/apt/lists/*
          ENV DEVIN_CHROME_PATH=/usr/bin/google-chrome
          ```
        </Note>

        对于私有代码仓库，请通过你偏好的方式 (例如 [build secrets](https://docs.docker.com/build/building/secrets/)) 将凭据内置到镜像中，以便在运行时能够正常执行克隆和远程仓库操作。

        当你对 Dockerfile 满意后，构建该镜像：

        ```bash theme={null}
        docker build -t devin-worker .
        ```
      </Step>

      <Step title="启动你的 Outpost 工作器">
        使用 `worker start` 命令，基于你的镜像运行一个容器，并传入你的 Outpost 名称以及你之前复制的令牌 (该镜像的 entrypoint 是 Devin CLI，因此参数会直接传递给 `devin`) ：

        ```bash theme={null}
        docker run devin-worker \
          worker start --outpost=<your-outpost-name> --token=<your-outpost-token>
        ```
      </Step>

      <Step title="启动新的 Outpost 会话">
        在 [Devin Cloud](https://app.devin.ai) 上，新建一个会话，并将其配置为在你的 Outpost 上运行。在 "配置" → "虚拟环境" 下，你会看到新建的 Outpost 已显示在列表中。选择它，即可让会话在该 Outpost 上运行。

        <video autoPlay muted loop playsInline className="w-full aspect-video" src="https://mintcdn.com/cognitionai/xlfcZs3jVVOLjL3w/images/onboard-devin/outposts/configure-docker-outpost.mp4?fit=max&auto=format&n=xlfcZs3jVVOLjL3w&q=85&s=6d5715a0a967c042ddde5671836e0581" data-path="images/onboard-devin/outposts/configure-docker-outpost.mp4" />

        现在你可以让 Devin 在你的容器中开始构建了！先试试一些简单的任务，比如

        ```
        Create a "hello world" python script for me
        ```

        然后，你会看到脚本出现在容器的工作目录中！
      </Step>
    </Steps>

    ### 后续步骤

    将你希望 Devin 使用的代码仓库预置到 image 中，让 Devin 在此基础上进行构建——session 将在工作器的工作目录下看到已检出的代码仓库。如需同时处理更多 session，可运行更多指向同一 outpost 的 container：N 个工作器可并发服务 N 个 session，其余 session 在队列中等待。

    <CardGroup cols={2}>
      <Card title="编排" icon="diagram-project" href="/zh/cloud/outposts/orchestration">
        在会话进入队列时自动预配容器，无需一直保留长期运行的工作器。
      </Card>

      <Card title="集成" icon="plug" href="/zh/cloud/outposts/overview#integrations">
        在你已经使用的平台上运行 outpost——如 Namespace、Modal、E2B 等。
      </Card>
    </CardGroup>
  </Tab>
</Tabs>
