快速开始#

装好 App、创建密钥,让 Agent 向你提一个问题,大约 60 秒。

1. 安装 App#

在 iPhone、iPad 或 Mac 上从 App Store 下载 Frame 并打开一次。它会在设备上自动创建账号(不需要邮箱),并请求通知权限,请选允许:审批就是这样出现在锁屏上的。

2. 创建 API 密钥#

在 App 里:设置 → 项目 → Default → 密钥 → 新建密钥。起个名字(例如 my-laptop),范围选 write,复制密钥。它以 afk_w_ 开头,只显示一次。

不要把密钥提交进 git,放在环境变量或 CI 的密钥库里。

3. 用命令行登录#

bash
npx agentsframe login --key afk_w_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

它会校验密钥,并保存到 ~/.config/agentsframe/config.json(权限 600)。不想落文件就导出环境变量 AGENTSFRAME_KEY。随时可以检查连接:

bash
npx agentsframe whoami
npx agentsframe doctor

4. 发出第一个审批#

bash
npx agentsframe approve "Deploy?" --wait

手机会收到 Deploy? 和两个按钮。命令会一直等到你点击,打印结果,并用退出码告诉脚本:0 已批准,10 被拒绝。

output (JSON when piped, or with --json)
{"approved":true,"outcome":"answered","action":"approve","state":"answered","card_id":"crd_8f2k1x"}

在脚本里用:

bash
if frame approve "在生产库上跑数据迁移?" --wait --timeout 600 --on-expire deny; then
  ./migrate.sh
else
  echo "未获批准,跳过。" >&2
fi

用 curl 做同样的事#

不需要 CLI:创建卡片,再长轮询等答案。

bash
export AGENTSFRAME_KEY=afk_w_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

# 1. 创建卡片
CARD=$(curl -s https://api.agentsframe.com/v1/cards \
  -H "Authorization: Bearer $AGENTSFRAME_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type":"approval","title":"Deploy?"}')
ID=$(echo "$CARD" | jq -r .id)

# 2. 等答案(已回答返回 200,仍未回答返回 202)
until [ "$(curl -s -o /tmp/card.json -w '%{http_code}' \
  -H "Authorization: Bearer $AGENTSFRAME_KEY" \
  "https://api.agentsframe.com/v1/cards/$ID/wait?timeout=50")" = 200 ]; do :; done

jq -r '.response.action' /tmp/card.json   # approve | deny

不写 actions 的审批默认带 Approve 和 Deny。wait 是长轮询:卡片 state 一离开 open 就返回 200 和卡片;过了 timeout 秒(1 到 55)返回 202,你再循环即可。

在代码里用#

TypeScript
import { Frame } from "agentsframe";

const frame = new Frame({ key: process.env.AGENTSFRAME_KEY! });
const { approved } = await frame.approve("Deploy?", { wait: true });
if (approved) await deploy();
Python
from agentsframe import Frame

frame = Frame()  # 读取 AGENTSFRAME_KEY
if frame.approve("Deploy?", wait=True).approved:
    deploy()

下一步#

  • 提一个带选项的问题:frame ask "Which thumbnail?" --option a:A --option b:B
  • 展示一个成果:frame show ./render.mp4 --title "Episode 12" --review
  • 汇报进度:frame progress start "Nightly import" --value 0.6
  • 把数字放上面板:frame metric set youtube.subscribers 48210
  • 让 Claude Code 或 Codex 能联系到你:MCP 配置(英文)
  • 了解模型:核心概念(英文)