CALLANYTHING
Caller · 5 min

把外部能力
接进 AGENT

先用已发布的 delexec-ops 包跑一次本地 hotline,看一份 result_package,理解协议怎么帮你省掉「每根 API 单独拼接」的工。源码拆解路径放在后面。

Local Mode无需 Platform走 supervisor HTTP

这页教你做什么

从 0 到「Agent 真的发起了一次跨进程调用」

  • · 启动 Client 本地 supervisor
  • · 用 CLI 注册一个本地 Caller 身份
  • · 把 example hotline 挂上来当作 Responder 模拟
  • · 用 run-example 发起 example call · 拉 result
  • · 解读 result_package:Agent 拿到的协议化结果长什么样
01

官方路径:安装 CLI + 跑通 bootstrap

陌生用户从已发布的 @delexec/ops 开始,不需要 clone 第四仓库,也不需要先理解三仓结构。

bash
任意目录
npm install -g @delexec/ops
delexec-ops bootstrap --email [email protected] --text "Summarize this bootstrap request."
delexec-ops status
delexec-ops run-example --text "Summarize this follow-up request."
提示这四条命令会启动本地 runtime、准备 example hotline,并完成一次本机自调用。看到 SUCCEEDED 就说明 Caller 的最小闭环已经打通。
bash
源码贡献者路径
git clone --recursive https://github.com/hejiajiudeeyu/delegated-execution-dev.git
cd delegated-execution-dev
corepack pnpm install
bash
单独使用 client 子仓也可以
cd repos/client
npm install
提示后面的步骤是源码拆解和 HTTP 调试路径,工作目录都是 repos/client,等价于在第四仓库根用 corepack pnpm --dir repos/client --filter @delexec/ops exec ...
02

源码拆解:启动 supervisor

如果你在贡献代码或排查 HTTP 细节,可以从源码启动 supervisor。普通首次体验只需要上面的 delexec-ops bootstrap。

bash
repos/client
# 可选:把本机状态隔离到一个独立目录,避免污染默认 ~/.delexec
export DELEXEC_HOME="$HOME/.delexec-quickstart"
export OPS_PORT_SUPERVISOR=8179

DELEXEC_HOME="$DELEXEC_HOME" \
OPS_PORT_SUPERVISOR="$OPS_PORT_SUPERVISOR" \
npm run ops -- start
注意这条命令会前台 running,建议另起一个终端做后续步骤。看到 supervisor listening on 127.0.0.1:8179 即 OK。
03

初始化并取一个会话 token

supervisor 第一次跑要做一次 setup,之后用 X-Ops-Session 标识当前管理员会话。

bash
BASE="http://127.0.0.1:${OPS_PORT_SUPERVISOR:-8079}"
# 第一次跑:初始化 + 拿 session
curl -s -X POST "$BASE/setup" -H 'content-type: application/json' -d '{}'
SESSION=$(curl -s -X POST "$BASE/auth/session/setup" \
  -H 'content-type: application/json' \
  -d '{"passphrase":"client-localtest-123"}' | jq -r '.token')
echo "$SESSION"
export OPS_SESSION="$SESSION"
提示想跳过 curl?后面的步骤也都有 CLI 等价命令;详见 repos/client/docs/current/guides/local-mode-onboarding.md
04

注册一个本地 Caller 身份

即使是 Local Mode,protocol 也要求 Caller 有明确身份;这一步会在 DELEXEC_HOME 下生成本地账号。

bash
CLI 写法
npm run ops -- auth register --local --email [email protected]
bash
HTTP 写法
curl -s -X POST "$BASE/auth/register-caller" \
  -H 'content-type: application/json' \
  -H "X-Ops-Session: $OPS_SESSION" \
  -d '{ "contact_email": "[email protected]" }'
05

挂一根「示例 hotline」上来

Local Mode 下,让本机同时扮演 Responder,挂一条用于联调的 workspace-summary 示例 hotline。生产场景里这一步是 Marketplace 上拉到的真实能力。

bash
# 启用 responder 角色
curl -s -X POST "$BASE/responder/enable" \
  -H 'content-type: application/json' \
  -H "X-Ops-Session: $OPS_SESSION" \
  -d '{}'

# 挂上 example hotline(本仓内置)
curl -s -X POST "$BASE/responder/hotlines/example" \
  -H 'content-type: application/json' \
  -H "X-Ops-Session: $OPS_SESSION" \
  -d '{}'
06

列出本机能调用的 hotline

这是 Caller 视角里最常用的 API:catalog 决定了 Agent 当前可调用的能力集合。

bash
curl -s "$BASE/catalog/hotlines" \
  -H "X-Ops-Session: $OPS_SESSION" | jq
提示你应当看到一条 local.delegated-execution.workspace-summary.v1, 这是 Agent 接下来要调的 hotline。
07

发起一次真实调用

一切准备好了。下面这条命令模拟 Agent 在 Caller 进程里发起一个 hotline 调用。

bash
HTTP 写法
REQ=$(curl -s -X POST "$BASE/requests/example" \
  -H 'content-type: application/json' \
  -H "X-Ops-Session: $OPS_SESSION" \
  -d '{}')
echo "$REQ"
REQUEST_ID=$(echo "$REQ" | jq -r '.request_id')
bash
CLI 写法
npm run ops -- run-example --text "summarize my workspace"
08

拉结果 · 看 result_package

协议化结果是 CALL ANYTHING 的核心:所有 hotline 返回同一种 result_package 结构,Agent 只学一次。

bash
curl -s "$BASE/requests/$REQUEST_ID/result" \
  -H "X-Ops-Session: $OPS_SESSION" | jq
json
脱敏后的真实形状
{
  "request_id": "req_xxx",
  "status": "SUCCEEDED",
  "result_package": {
    "request_id": "req_xxx",
    "responder_id": "responder_xxx",
    "hotline_id": "local.delegated-execution.workspace-summary.v1",
    "status": "ok",
    "output": {
      "summary": "..."
    },
    "timing": {
      "elapsed_ms": 123
    }
  }
}

5 个字段 Agent 必看:

  • · status:SUCCEEDED / FAILED
  • · result_package.status:ok / error
  • · hotline_id:调用的能力 ID(含版本)
  • · output:具体输出,shape 由该 hotline 的 output_schema 决定
  • · timing.elapsed_ms:耗时,可作为计费 / 评分输入
09

OPC #0 生产演练:充值后用一条 CLI 发起一次付费调用

这不是本地 quick start 的必做步骤;它用于公开生产演练。Caller 先注册公开 Platform 身份,把 tenant_id 交给 operator 充值,然后直接用 delexec-ops call-hotline 完成 billing consent、dispatch、result polling 和结算核对。

bash
注册 Caller · 配置 public relay runtime · 交给 operator 充值
PLATFORM="https://callanything.xyz/platform"
RELAY="https://callanything.xyz/relay"
CALLER_EMAIL="caller-opc0"@"example.com"
export DELEXEC_HOME="$HOME/.delexec-caller-public"
export OPS_PORT_SUPERVISOR=8279
export OPS_PORT_CALLER=8281
export TRANSPORT_TYPE="relay_http"
export TRANSPORT_BASE_URL="$RELAY"

# delexec-ops auth register 会调用 $PLATFORM/v1/users/register 并把 API key 写入本地状态。
CALLER_JSON=$(delexec-ops auth register \
  --platform "$PLATFORM" \
  --email "$CALLER_EMAIL")
echo "$CALLER_JSON" | jq

CALLER_API_KEY=$(echo "$CALLER_JSON" | jq -r '.api_key')
CALLER_TENANT_ID=$(echo "$CALLER_JSON" | jq -r '.user_id')
export CALLER_API_KEY CALLER_TENANT_ID

# 另起终端前台运行,或用 nohup 长运行;Caller controller 会消费 result 并上报结算事件。
nohup env \
  DELEXEC_HOME="$DELEXEC_HOME" \
  OPS_PORT_SUPERVISOR="$OPS_PORT_SUPERVISOR" \
  OPS_PORT_CALLER="$OPS_PORT_CALLER" \
  TRANSPORT_TYPE="relay_http" \
  TRANSPORT_BASE_URL="$RELAY" \
  delexec-ops start \
  > "$DELEXEC_HOME/caller-public-relay.log" 2>&1 &

CALLER_BASE="http://127.0.0.1:$OPS_PORT_CALLER"

# 把 CALLER_TENANT_ID 发给 operator。operator 完成 tenant 创建和人工充值后再继续。
curl -s "$PLATFORM/v1/tenants/me/balance" \
  -H "Authorization: Bearer $CALLER_API_KEY" | jq
bash
选择已审核 hotline · 一条 CLI 完成付费调用
HOTLINE_ID="your.namespace.tool-name.v1"
RESPONDER_ID="responder_xxx"
REQUEST_ID="req_opc0_$(date +%s)"
MAX_CHARGE_CENTS=500

curl -s "$PLATFORM/v1/catalog/hotlines/$HOTLINE_ID" | jq

CALL_RESULT=$(delexec-ops call-hotline \
  --platform "$PLATFORM" \
  --caller-base-url "$CALLER_BASE" \
  --request-id "$REQUEST_ID" \
  --responder-id "$RESPONDER_ID" \
  --hotline-id "$HOTLINE_ID" \
  --text "Summarize this paid public relay request." \
  --max-charge-cents "$MAX_CHARGE_CENTS" \
  --poll-interval-ms 2000 \
  --timeout-ms 60000)

echo "$CALL_RESULT" | tee /tmp/delexec-call-hotline.json | jq
echo "$CALL_RESULT" | jq '{request_id, task_token_present, task_token_claims, delivery_meta, dispatch, inbox, result, events, balance, ledger}'
bash
诊断时再看底层形状
# 上面的 call-hotline 已经封装了这些步骤:
# /v1/tokens/task
# /v1/requests/$REQUEST_ID/delivery-meta
# /controller/requests
# /controller/requests/$REQUEST_ID/dispatch
# $RELAY/v1/messages/send
# /controller/inbox/pull
# /controller/requests/$REQUEST_ID/result
# /v1/tenants/me/balance
# /v1/tenants/me/ledger
# /v1/requests/$REQUEST_ID/events
echo "$CALL_RESULT" | jq '{task_token_claims, delivery_meta, dispatch, inbox, result, events, balance, ledger}'
注意付费调用的验收看三件事:call-hotline 返回 0 且带出task_token_claimsdelivery_metadispatchresulteventsbalanceledger/v1/tenants/me/balance/v1/tenants/me/ledger 的金额变化与max_charge_cents、实际 usage 一致。底层 API 仍保留给排障时核对。

下一步

你刚刚跑通的就是 Caller 的最小闭环。从这里可以分两条路深入:

扩展 Agent 能力

打开 Console,从 Marketplace 浏览 / 收藏更多 hotline,按风险标签配置审批策略。

自己也想发能力?

同一台 supervisor 可以同时做 Caller 和 Responder。换条路看 Responder 怎么 5 分钟发布一根 hotline。

Caller FAQ

Caller Quick Start 常见问题

这部分直接回答第一次做 Caller 接入时最容易卡住的几个问题,也对应页面里的 HowTo schema。

Caller Quick Start 适合谁?

它适合希望把外部能力接进 Agent、但还不想先部署完整 Platform 的团队。页面使用 Local Mode 演示最小调用闭环,方便先验证协议体验。

这页为什么先用 example hotline?

因为它能把 Caller、supervisor 和 Responder 三段链路先稳定跑通,先验证协议流程,再决定接入真实业务 Hotline,能显著减少排查范围。

完成后下一步做什么?

通常有两条路:继续浏览 Marketplace 选择更多 Hotline,或者进入 Console 原型理解审批、路由和运行时状态。若你也想提供能力,则直接进入 Responder Quick Start。