文档Docs
Webhook——让外部服务直接通知你的 AgentWebhooks — let outside services reach your Agent
每个 Agent J 席位都自带 Webhook 地址。视频生成完成、Stripe 收款、GitHub 推送、服务器告警,都能直接送到你 Agent J 主机上的 Agent,不用自己的域名,也不用写代码。Every Agent J seat comes with webhook addresses. A finished video job, a Stripe payment, a GitHub push or a server alert goes straight to the Agent on your computer, with no domain or code of your own.
很多服务在事情发生时会回调一个网址:视频生成好了、有人付款了、代码推上去了、服务器挂了。以前要有自己的域名和服务器才接得住。现在每个 Agent J 席位都自带 Webhook:地址形如 hook.agentj.app/<box>/<id>,事件直接送到你 Agent J 主机上的 Agent,不用写代码。
跟 Agent 说一句就行,比如视频做完了回调我、接一下 Stripe 收款、服务器告警发给我。它会先问清楚是哪个服务来调用、来了以后怎么办、要用多久,再帮你建好。
先选路线
- 没有自己的云服务和域名 → 用托管 Webhook(
agentj hook)。绝大多数人选这个。 - 有自己的 Cloudflare / AWS / 域名,想完全自己掌控 → 让 Agent 按你的方式自己搭入口(Worker、Lambda 都行)。想要同样的分诊和提醒,就在那边验完签名,再把事件转进 Agent J:本机用
agentj hook forward,云上用 HMAC 签名后 POST 到一个托管 hook。
常见用法
| 用法 | 预置 | 寿命 | 送到 |
|---|---|---|---|
| 刚发起的任务完成后回调一次(视频、渲染、转写、爬取) | callback | 一次性 | 主 Agent |
| Stripe 收款、退款、订阅 | stripe | 常驻 | 你本人 |
| GitHub 推送、PR、issue | github | 常驻 | 主 Agent |
| 服务器告警、在线监控(Grafana、UptimeRobot、Better Stack) | alert | 常驻 | 你本人 |
| 只能填一个网址的表单或服务(Tally、Typeform、Apps Script) | form | 常驻 | 你本人 |
| 自动化成功、失败、部分失败报告 | automation-report | 常驻 | 主 Agent |
| 定时任务、备份脚本报告自己跑过了 | ping | 常驻 | 你本人 |
agentj hook presets 列出全部预置和默认值。
场景:自动化报告交给主 Agent(Webhook / HTTP API)
跟 Agent 说把自动化的成功和失败都交给你。用中性的 automation-report 预置,默认常驻、Bearer 验证、送到 main,不按成功失败过滤。创建常驻入口仍须主人在已配对设备上批准:
agentj hook create --preset automation-report --name automation-reports
每次完成都投一份报告,status 建议用 success、failure 或 partial,也可用工作流自己的状态。它是报告数据,不是执行指令,不能授予权限或让 Agent 运行日志里的命令。
{"status":"success","automation":"nightly-backup","unit":"nightly-backup.service","summary":"Backup completed","report_path":"reports/backup.md","links":["https://example.com/runs/42"]}
默认全部进主线程:成功由主 Agent 总结,告诉你「FYI,无需处理」;失败由它在已有授权和权限内安排检查、修复,给你一句问题和实际进度;处理不了则在 Web App 说清要你做什么。不要把已接收当作已修复,也不要把未经安排的工作写成已派人。原始报告可在输入卡展开,人话回执是你平时看的入口。
本机与远端各怎么接
- 本机: cron、systemd timer、launchd、Windows 计划任务在任务结束后运行投递脚本;用退出状态生成
status,成功失败都投。可用托管 HTTP API,也可用agentj hook forward留在本机,仍走该 hook 原有验证与权限边界。 - 远端: GitHub Actions、云函数在完成/异常处理分支调用托管 HTTP API;本机
forward不能从远端直接访问。自建云入口先检查来源签名,再经你自己的安全连接转给主机上的forward;不要把本机 socket 暴露上网。
下面给出同一脚本的两种接法。为了不把 Bearer 密钥放进命令参数,例子覆盖预置的验证方式,使用带时间戳的 HMAC:
agentj hook create --preset automation-report --auth hmac --signed ts.body --name automation-reports
保存下面代码为 report.py。把创建结果中的 secret_file 配到本机任务的 AUTOMATION_SECRET_FILE;本机转入另配 AUTOMATION_HOOK_ID,托管投递另配 AUTOMATION_REPORT_URL。远端把密钥放在 CI/云平台的秘密库,用 AUTOMATION_REPORT_SECRET 注入。这里只引用名字,不把值写进仓库、日志或对话。
# report.py: Python 3, standard library only. Never print credentials or headers.
import hashlib, hmac, json, os, subprocess, sys, time, urllib.request
from pathlib import Path
with Path(sys.argv[1]).open("rb") as report:
body = report.read(65537)
if len(body) > 65536:
raise SystemExit("Report exceeds 64 KiB; send a redacted summary and links")
json.loads(body) # Reject malformed reports before sending.
secret = (Path(os.environ["AUTOMATION_SECRET_FILE"]).expanduser().read_bytes().strip()
if os.environ.get("AUTOMATION_SECRET_FILE")
else os.environ["AUTOMATION_REPORT_SECRET"].encode())
ts = str(int(time.time()))
sig = hmac.new(secret, ts.encode() + b"." + body, hashlib.sha256).hexdigest()
headers = {"Content-Type": "application/json", "X-Timestamp": ts, "X-Signature": sig}
if os.environ.get("AUTOMATION_HOOK_ID"): # Local forward; same signature check.
args = ["agentj", "hook", "forward", os.environ["AUTOMATION_HOOK_ID"], "--body", "-"]
for key, value in headers.items():
args += ["--header", key + ": " + value]
subprocess.run(args, input=body, check=True)
else: # Hosted HTTP API, including a cloud function or CI runner.
req = urllib.request.Request(os.environ["AUTOMATION_REPORT_URL"], data=body,
headers=headers, method="POST")
with urllib.request.urlopen(req, timeout=30) as response:
if response.status != 200:
raise SystemExit("Delivery was not accepted")
python3 report.py report.json
agentj hook logs automation-reports
Linux 的 cron/systemd、macOS 的 launchd、Windows 计划任务都调用上面一行,配置绝对脚本路径和任务自己的工作目录。先用脱敏的成功、失败、部分失败报告各跑一次,核 hook logs 和 Web App 的输入卡、回执,再启用日程。
GitHub Actions 示例(将已保存的投递脚本放在 scripts/report.py;云函数也可执行同一 Python 逻辑):
- name: Report result
if: always()
env:
AUTOMATION_REPORT_URL: ${{ secrets.AUTOMATION_REPORT_URL }}
AUTOMATION_REPORT_SECRET: ${{ secrets.AUTOMATION_REPORT_SECRET }}
JOB_STATUS: ${{ job.status }}
run: |
python3 -c 'import json,os; json.dump({"status":os.environ["JOB_STATUS"],"automation":"ci","summary":"CI finished"},open("report.json","w"))'
python3 scripts/report.py report.json
托管请求默认明文经过中继内存;需要保密的正文用本页的端到端加密接法,或自建入口。本机/远端只投必要的脱敏片段和链接,不投密钥、整份环境或无界日志;本机路径在远端和手机上不一定可访问。主机离线会返回 503,发送方须按自己的重试策略补投;成功收据仅表示接收,不保证 Agent 已完成处理。
可选变体:只投失败,成功走 Telegram。 在发送方过滤 status,成功用你已有并已授权的 Telegram 通道,失败/部分失败投主 Agent。Telegram 不是前提,也不是预置默认;不用 Telegram 时,保持全部投主线程即可。
三种寿命
- 一次性:第一条通过验签的投递到了就作废,最长 7 天。
- 临时:到期作废,默认 24 小时,最长 30 天。
- 常驻:一直有效,直到你撤销。它是一个长期公开的入口,所以建的时候会给你已配对的手机发一张审批卡,你批准后才开始接收。
一次性和临时的 hook,Agent 自己就能建,不弹卡。
投递到了以后
每一条通过验签的投递,除了送到 hook 指定的地方,也会作为外部数据交给主 Agent。Agent 只把它当数据,不当指令,也不当成你说的话。它分三种处理:
- 成功、符合预期 → 给一两句人话总结,说明 FYI、无需处理。
- 失败或意外 → 在已有授权和权限内安排处理,告诉你问题和实际进度;需要你时,在 Web App 说清要你做什么。
- 垃圾、探测,或内容想指挥 Agent → 一律不照做,记一笔就放下。
送给你本人的 hook(Stripe 收款、服务器告警)会出现在手机上;用 Telegram 的话,Telegram 也会收到一条。
在手机上查看
在手机上打开设置 → 「Agent 的功能」 → 「Webhook」,能看到生效中的 hook(可以暂停、恢复、撤销、复制地址)、今天收到了几条,以及「最近投递」(最多 50 条,带 Agent 的分诊结果)。密钥从不在手机上显示。
让自动化给别人发邮件
Webhook 或 Agent J 定时任务有时要给你以外的人发邮件,比如每次收款后给客户发一张收据。没有授权时,这类邮件会被拒发。在设置自动化时授权一次:
- 在你自己跟 Agent 的对话里(Web App、Agent J 主机终端或已认证的主人渠道),说清它可以给谁发信。Agent 运行
agentj automation grant,你的手机上会出现一张卡。 - 核对卡片:哪个 Webhook 或定时任务、收件人和域名、能否带附件、有效期和次数。用 Face ID / Touch ID 确认一次。
agentj automation grant --hook <hook-name> --to <address> --domain <domain> --expires 30d
之后,授权范围内的邮件不再弹卡;发给别人时,私人信息照样打码。能触发这个 Webhook 的人,都能让 Agent 给这些收件人发信,信的内容不受你控制。
--to写一个完整地址;--domain包含这个域名和它的子域名。内置清单上的公共邮箱域名和公共后缀(如 gmail.com、co.uk)不能按域名授权,这些人请用--to逐个写。清单并不完整,确认前请核对卡片上的域名。- 带附件要加
--files。不写--expires就一直有效,直到你撤销;--max限定最多发几封。 - 只有你自己的对话能申请授权。Webhook、定时任务、好友和群聊都不行。
- 发给授权外的人:不发出,也不弹卡。Agent 会把补授权的完整命令告诉你;补授权是一张新卡,写明全部收件人,替换旧授权。
- 以下情况要重新授权:Webhook 的验签方式、来源 IP、投递目标或说明改了,定时任务的定义改了,Webhook 或定时任务删掉了,用过「全部停下」,发信邮箱账号换了,批准它的遥控器被解绑或换了通行密钥。只改 Webhook 名字或轮换它的密钥,不影响授权。
- 「设置」→「安全」→「自动化外发授权」列出所有授权和状态,任一台已配对遥控器点「撤销」立即生效。在你自己的对话里,
agentj automation grants列出授权,agentj automation revoke <id>撤销一项。
每个席位的额度
同时生效 20 个 hook(其中常驻最多 10 个),每天 1000 条投递,每条最大 64 KiB。超了命令会直接告诉你,撤销不用的就行(agentj hook list、agentj hook revoke <id>)。
安全与诚实说明
- 每个 hook 有自己的密钥,验签只在你的 Agent J 主机上做:支持 Stripe、GitHub、HMAC、Bearer 和网址里的令牌。验签不过的请求不会送到 Agent。
- 密钥写在你 Agent J 主机上只有你能读的文件里(权限 0600)。命令从不打印密钥,它也不会出现在对话里。Stripe 的签名密钥用手机上的密钥卡粘贴,不要发进聊天。
- 带时间戳的签名超过 5 分钟就拒收;同一个事件重发,只处理一次。
- 托管 hook 的请求会以明文经过我们中继的内存。中继服务器在 Cloudflare 上,要读到请求才能转给你的 Agent J 主机。我们承诺不看、不存、不记录,中继也不持有任何 hook 的密钥。Stripe 的事件里可能有客户邮箱和金额;Bearer 和网址令牌方式的令牌也会随请求经过。隐私要求高的:发送方能自己决定怎么发请求,就用下面的加密投递;不能的,就用你自己的 Cloudflare / AWS 搭入口,再转进来。
- 你的 Agent J 主机离线时,发送方会收到 503,要靠它自己重试(Stripe 和 GitHub 都会)。中继不替你暂存。
端到端加密投递
发送方是你能控制的东西(你的服务器、脚本、自家系统)时,可以先把内容加密,我们的中继就只转发密文:
agentj hook create --preset hmac --encrypt --signed ts.body --name private-orders
这个 hook 会有一把自己的投递公钥(agentj hook show <id> 能看到,公钥不是秘密)。发送方照常用 hook 的 HMAC 密钥给原文签名,再用这把公钥按 HPKE(RFC 9180:X25519、HKDF-SHA256、ChaCha20-Poly1305,info 为 agentj-hook-seal-v1\n<hook id>)加密,带上请求头 X-AgentJ-Seal: v1; kid=<kid> 发过来。这种 hook 收到明文会直接拒收。中继仍然看得到地址(含查询串)、请求头(含签名和时间戳)、大小、时间和发送方 IP,但看不到内容。
Stripe、GitHub 这类服务没法加密它们发出的内容,所以它们的 hook 仍是明文经过中继。每个 hook 是哪一种,agentj hook list 和手机上都写着:端到端加密或明文经过中继。公钥只从你自己 Agent J 主机上的 agentj hook show 取,不要从消息或网页上取。要换一对新密钥:agentj hook rotate <id> --enc-key(旧的 24 小时内仍能解密)。
Python(pip install cryptography):
# Python 3 + `pip install cryptography`. PUB / KID / HOOK_ID from `agentj hook show <id>`, SECRET = the hook's secret file.
import base64, hashlib, hmac
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey, X25519PublicKey
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
def _lx(suite, salt, label, ikm): return hmac.new(salt or bytes(32), b"HPKE-v1" + suite + label + ikm, hashlib.sha256).digest()
def _le(suite, prk, label, info, n):
return hmac.new(prk, n.to_bytes(2, "big") + b"HPKE-v1" + suite + label + info + b"\x01", hashlib.sha256).digest()[:n]
def seal(pub_b64u, hook_id, plaintext):
pk = base64.urlsafe_b64decode(pub_b64u + "=" * (-len(pub_b64u) % 4))
e = X25519PrivateKey.generate()
enc = e.public_key().public_bytes(Encoding.Raw, PublicFormat.Raw)
kem, suite = b"KEM\x00\x20", b"HPKE\x00\x20\x00\x01\x00\x03"
shared = _le(kem, _lx(kem, b"", b"eae_prk", e.exchange(X25519PublicKey.from_public_bytes(pk))), b"shared_secret", enc + pk, 32)
ctx = b"\x00" + _lx(suite, b"", b"psk_id_hash", b"") + _lx(suite, b"", b"info_hash", b"agentj-hook-seal-v1\n" + hook_id.encode())
s = _lx(suite, shared, b"secret", b"")
return enc + ChaCha20Poly1305(_le(suite, s, b"key", ctx, 32)).encrypt(_le(suite, s, b"base_nonce", ctx, 12), plaintext, b"")
然后用任意 HTTP 客户端发出加密后的字节,比如 curl:
ts=$(date +%s) # X-Signature = hex(HMAC-SHA256(secret, ts + "." + original body))
curl -X POST "$URL" --data-binary @sealed.bin -H "Content-Type: application/octet-stream" \
-H "X-AgentJ-Seal: v1; kid=$KID" -H "X-Timestamp: $ts" -H "X-Signature: $SIG"
Node 18+(不用装包):
// Node 18+, no packages. Same inputs; returns the request body (Buffer).
const c = require("node:crypto");
const lx = (suite, salt, label, ikm) => c.createHmac("sha256", salt.length ? salt : Buffer.alloc(32))
.update(Buffer.concat([Buffer.from("HPKE-v1"), suite, Buffer.from(label), ikm])).digest();
const le = (suite, prk, label, info, n) => { const l = Buffer.alloc(2); l.writeUInt16BE(n);
return c.createHmac("sha256", prk).update(Buffer.concat([l, Buffer.from("HPKE-v1"), suite, Buffer.from(label), info,
Buffer.from([1])])).digest().subarray(0, n); };
function seal(pubB64u, hookId, plaintext) {
const pk = Buffer.from(pubB64u, "base64url");
const { publicKey, privateKey } = c.generateKeyPairSync("x25519");
const enc = Buffer.from(publicKey.export({ format: "jwk" }).x, "base64url");
const dh = c.diffieHellman({ privateKey, publicKey: c.createPublicKey({ key: { kty: "OKP", crv: "X25519", x: pubB64u }, format: "jwk" }) });
const kem = Buffer.from("KEM\x00\x20", "latin1"), suite = Buffer.from("HPKE\x00\x20\x00\x01\x00\x03", "latin1");
const shared = le(kem, lx(kem, Buffer.alloc(0), "eae_prk", dh), "shared_secret", Buffer.concat([enc, pk]), 32);
const ctx = Buffer.concat([Buffer.from([0]), lx(suite, Buffer.alloc(0), "psk_id_hash", Buffer.alloc(0)),
lx(suite, Buffer.alloc(0), "info_hash", Buffer.from("agentj-hook-seal-v1\n" + hookId))]);
const s = lx(suite, shared, "secret", Buffer.alloc(0));
const ci = c.createCipheriv("chacha20-poly1305", le(suite, s, "key", ctx, 32), le(suite, s, "base_nonce", ctx, 12), { authTagLength: 16 });
return Buffer.concat([enc, ci.update(plaintext), ci.final(), ci.getAuthTag()]);
}
例子
agentj hook create --preset callback --name video-123 --note "视频任务 123 完成" --json
agentj hook create --preset stripe --name stripe-payments
agentj hook logs <id>
第一条建一个一次性回调,第二条建一个常驻的 Stripe hook(在手机上批准审批卡),第三条看一个 hook 收到了什么。全部参数见 agentj 命令参考。
外部助手:单向 MCP 请求
手机上打开设置 →「Agent 的功能」→「Webhook」→「外部助手 · 单向请求」。填连接名称和允许的网站来源,每行一个完整 HTTPS origin,例如 https://assistant.example,不带路径、参数或末尾斜杠,再点「创建连接」。在手机签名卡上确认后,从领取卡完成 Face ID 验证,一次性领取凭据;连接地址可以从列表复制。
外部助手只能发请求并收到固定回执,不能读取 Agent J 的回复、对话或工作结果,也不能替你审批。入站请求和认证信息会经过云中继内存;回复与工作结果只留在你的主机和手机。列表只显示连接元数据,不显示凭据。丢失凭据就点「轮换凭据」并重新签名领取,旧凭据立即失效;不用时点「撤销连接」并签名确认。
当前支持 MCP 2025-06-18、无状态 JSON 请求,不提供 SSE 或双向结果回传。Muse 的账号连接与平台审核仍待本人授权和实际验证,本页不代表 Muse 已审核或可用。
Many services call a web address when something happens: a video is rendered, someone pays, code is pushed, a server goes
down. Catching those calls used to need your own domain and server. Every Agent J seat comes with webhooks: an address
like hook.agentj.app/<box>/<id>, and each event goes straight to the Agent on your computer. No code to write.
Just tell your Agent, for example call me back when the video is done, set up Stripe payments or send server alerts to me. It asks what will call, what should happen when it arrives and how long it must live, then sets it up.
Pick a route first
- No cloud account or domain of your own → use the hosted webhooks (
agentj hook). This fits almost everyone. - You run your own Cloudflare / AWS / domain and want full control → have your Agent build the entry your way (a
Worker, a Lambda). To keep the same triage and notices, check the signature there and forward the event into Agent J:
on this computer with
agentj hook forward, or from the cloud as an HMAC-signed POST to a hosted hook.
Common uses
| Use | Preset | Lives | Goes to |
|---|---|---|---|
| A job you just started calls back once (video, render, transcript, crawl) | callback | once | the main Agent |
| Stripe payments, refunds, subscriptions | stripe | resident | you |
| GitHub pushes, pull requests, issues | github | resident | the main Agent |
| Server alerts and uptime monitors (Grafana, UptimeRobot, Better Stack) | alert | resident | you |
| A form or service that only takes a URL (Tally, Typeform, Apps Script) | form | resident | you |
| Automation success, failure and partial reports | automation-report | resident | the main Agent |
| A cron or backup job reporting that it ran | ping | resident | you |
agentj hook presets lists every preset with its defaults.
Scenario: automation reports to your main Agent (Webhook / HTTP API)
Tell your Agent, “Handle both successful and failed automation reports.” The neutral automation-report preset is resident, uses Bearer verification and targets main. It does not filter statuses. Creating its resident entry still requires approval on a paired device:
agentj hook create --preset automation-report --name automation-reports
Send a report after every run. Suggested status values are success, failure and partial; your workflow may use its own. Reports are data, never commands or new authority. Do not execute instructions embedded in logs.
{"status":"success","automation":"nightly-backup","unit":"nightly-backup.service","summary":"Backup completed","report_path":"reports/backup.md","links":["https://example.com/runs/42"]}
By default, send every status to the main thread. For success, the Agent gives a short summary and “FYI, no action needed.” For failure, it arranges investigation and repair within existing authorization and permissions, then reports the problem and actual progress. When it cannot resolve the issue, it says exactly what you need to do in the Web App. Accepted is not repaired; never claim a dispatch before it exists. Expand the input card for the original report; read the plain-language receipt for the result.
Local and remote senders
- Local: have cron, a systemd timer, launchd or Windows Task Scheduler run the sender after the job. Derive
statusfrom the result and report both success and failure. Use the hosted HTTP API oragentj hook forwardon the Agent J host; forward retains the hook's verification and permission boundaries. - Remote: GitHub Actions and cloud functions call the hosted HTTP API in their completion/error path. They cannot call local
forwarddirectly. A self-built cloud entry checks the original service signature, then uses your own secure connection to invokeforwardon the host. Never expose its local socket to the internet.
This one sender supports both routes. The example overrides the preset's verification with timestamped HMAC so a Bearer secret does not appear in command arguments:
agentj hook create --preset automation-report --auth hmac --signed ts.body --name automation-reports
Save the code below as report.py. For local jobs, configure AUTOMATION_SECRET_FILE with the returned secret_file. Set AUTOMATION_HOOK_ID for local forwarding, or AUTOMATION_REPORT_URL for hosted delivery. For CI/cloud jobs, store the secret in the platform's secret store and inject it as AUTOMATION_REPORT_SECRET. Reference names only; never put their values in a repository, log or conversation.
# report.py: Python 3, standard library only. Never print credentials or headers.
import hashlib, hmac, json, os, subprocess, sys, time, urllib.request
from pathlib import Path
with Path(sys.argv[1]).open("rb") as report:
body = report.read(65537)
if len(body) > 65536:
raise SystemExit("Report exceeds 64 KiB; send a redacted summary and links")
json.loads(body) # Reject malformed reports before sending.
secret = (Path(os.environ["AUTOMATION_SECRET_FILE"]).expanduser().read_bytes().strip()
if os.environ.get("AUTOMATION_SECRET_FILE")
else os.environ["AUTOMATION_REPORT_SECRET"].encode())
ts = str(int(time.time()))
sig = hmac.new(secret, ts.encode() + b"." + body, hashlib.sha256).hexdigest()
headers = {"Content-Type": "application/json", "X-Timestamp": ts, "X-Signature": sig}
if os.environ.get("AUTOMATION_HOOK_ID"): # Local forward; same signature check.
args = ["agentj", "hook", "forward", os.environ["AUTOMATION_HOOK_ID"], "--body", "-"]
for key, value in headers.items():
args += ["--header", key + ": " + value]
subprocess.run(args, input=body, check=True)
else: # Hosted HTTP API, including a cloud function or CI runner.
req = urllib.request.Request(os.environ["AUTOMATION_REPORT_URL"], data=body,
headers=headers, method="POST")
with urllib.request.urlopen(req, timeout=30) as response:
if response.status != 200:
raise SystemExit("Delivery was not accepted")
python3 report.py report.json
agentj hook logs automation-reports
Use that command from cron/systemd on Linux, launchd on macOS or Task Scheduler on Windows, with absolute script paths and the job's working directory. Before enabling the schedule, send redacted success, failure and partial reports once each. Check hook logs, input cards and receipts in the Web App.
GitHub Actions example (save the sender as scripts/report.py; a cloud function can use the same Python logic):
- name: Report result
if: always()
env:
AUTOMATION_REPORT_URL: ${{ secrets.AUTOMATION_REPORT_URL }}
AUTOMATION_REPORT_SECRET: ${{ secrets.AUTOMATION_REPORT_SECRET }}
JOB_STATUS: ${{ job.status }}
run: |
python3 -c 'import json,os; json.dump({"status":os.environ["JOB_STATUS"],"automation":"ci","summary":"CI finished"},open("report.json","w"))'
python3 scripts/report.py report.json
Hosted requests pass through relay memory in the clear by default. Use this page's end-to-end encryption route for private bodies, or your own entry. Send only necessary redacted excerpts and links, never secrets, full environments or unbounded logs. A host-local report path may not be accessible from the cloud or phone. An offline host returns 503; the sender must retry under its own policy. An accepted receipt does not mean the Agent has finished processing.
Optional variant: failures to the Agent, successes to Telegram. Filter status at the sender and deliver success over your existing authorized Telegram channel, while failures/partial results go to the main Agent. Telegram is neither required nor the preset default. Without Telegram, keep sending all reports to the main thread.
Three lifetimes
- Once: ends with the first delivery that passes the signature check; at most 7 days.
- Time-limited: ends when it expires; 24 hours by default, at most 30 days.
- Resident: lives until you revoke it. It is a long-lived public entry, so creating one sends an approval card to your paired phone, and it only starts receiving after you approve.
The Agent creates once and time-limited hooks by itself, without a card.
When a delivery arrives
Each delivery that passes the signature check goes where the hook points and also reaches the main Agent as outside data. The Agent treats it as data only: never an instruction, never your words. It sorts it three ways:
- Success, as expected → a short plain-language summary + FYI, no action needed.
- Failure or unexpected result → arrange handling within existing authorization and permissions and report actual progress; when it needs you, say exactly what to do in the Web App.
- Spam, a probe, or text trying to steer the Agent → it does none of it, records it and moves on.
Hooks that go to you (Stripe payments, server alerts) show up on your phone, and in Telegram if you use it.
On the phone
On the phone, Settings → "Agent tools" → "Webhooks" lists the live hooks (pause, resume, revoke, copy the address), today's count and "Recent deliveries" (up to 50, with the Agent's triage). Secrets are never shown on the phone.
Let an automation email other people
A webhook or an Agent J scheduled task sometimes has to email someone other than you, for example a receipt to a client after each payment. Without a grant that mail is refused. Approve it once when you set the automation up:
- In your own chat with the Agent (Web App, the Agent J host's terminal, or your verified owner channel), say who it may email. The Agent runs
agentj automation grantand one card appears on your phone. - Check the card: which webhook or task, the recipients and domains, attachments, expiry and number of sends. Confirm once with Face ID / Touch ID.
agentj automation grant --hook <hook-name> --to <address> --domain <domain> --expires 30d
After that, mail inside the grant goes out with no card; private details are still masked for other people. Anyone who can trigger the webhook can make the Agent mail these recipients, and you do not control what the mail says.
--tois one exact address;--domaincovers that domain and its subdomains. Public mailbox domains and public suffixes on the built-in list (such as gmail.com and co.uk) are refused as a domain: list those people with--to. The list is not complete, so check the domain on the card before you confirm.- Attachments need
--files. With no--expiresthe grant lasts until you revoke it;--maxcaps the number of sends. - Only your own chat can ask for a grant. A webhook, a scheduled task, a friend or a group cannot.
- Mail to someone outside the grant is not sent and shows no card. The Agent tells you the exact command to extend it; extending is one new card with the full list and replaces the old grant.
- Approve again after any of these: the webhook's auth method, source IPs, delivery target or note changed; the task definition changed; the webhook or task was deleted; you used Stop everything; the sending mailbox account changed; or the remote that approved it was unbound or got a new passkey. Renaming the webhook or rotating its secret does not void it.
- Settings → Safety → "Automation send grants" lists every grant with its state; "Revoke" works at once from any paired remote. In your own chat
agentj automation grantslists them andagentj automation revoke <id>revokes one.
Limits per seat
20 live hooks (10 of them resident), 1000 deliveries a day, 64 KiB per delivery. Past a limit the command says so; revoke
the hooks you no longer use (agentj hook list, agentj hook revoke <id>).
Security, honestly
- Every hook has its own secret, and signatures are checked only on your computer: Stripe, GitHub, HMAC, Bearer, or a token in the URL. A request that fails the check never reaches the Agent.
- Secrets go to a file on your computer that only you can read (0600). The commands never print them, and they never appear in the conversation. A Stripe signing secret is pasted through the key card on your phone, not into chat.
- A timestamped signature older than 5 minutes is refused, and a resent event is handled only once.
- A hosted hook's request passes through our relay's memory in the clear. The relay runs on Cloudflare and must read the request to pass it on. We commit not to read it, store it or log it, and the relay holds no hook secret. A Stripe event can carry a customer's email and the amount; with Bearer or URL-token hooks the token passes through too. For private data, use encrypted delivery (below) when the sender can shape its own request, or build your own entry on your own Cloudflare / AWS and forward it in.
- While your computer is offline the sender gets 503 and has to retry (Stripe and GitHub do). The relay does not hold events for you.
End-to-end encrypted delivery
When the sender is something you control (your server, a script, your own system), it can encrypt the body so our relay forwards only ciphertext:
agentj hook create --preset hmac --encrypt --signed ts.body --name private-orders
The hook gets its own delivery public key (shown by agentj hook show <id>; it is not a secret). The sender signs the
original body with the hook's HMAC secret as usual, encrypts it to that key with HPKE (RFC 9180: X25519, HKDF-SHA256,
ChaCha20-Poly1305, info agentj-hook-seal-v1\n<hook id>), and sends it with X-AgentJ-Seal: v1; kid=<kid>. A plain body to
such a hook is refused. Our relay still sees the address (including any query string), the headers (with the signature and timestamp), the size, the time and the sender's IP, never the body.
Services like Stripe and GitHub cannot encrypt what they send, so their hooks stay plain through the relay. Every hook says
which it is, in agentj hook list and on the phone: End-to-end encrypted or Plain through our relay. Take the public
key only from your own computer's agentj hook show, never from a message or a web page. New key pair:
agentj hook rotate <id> --enc-key (the old one still decrypts for 24 hours).
Python (pip install cryptography):
# Python 3 + `pip install cryptography`. PUB / KID / HOOK_ID from `agentj hook show <id>`, SECRET = the hook's secret file.
import base64, hashlib, hmac
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey, X25519PublicKey
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
def _lx(suite, salt, label, ikm): return hmac.new(salt or bytes(32), b"HPKE-v1" + suite + label + ikm, hashlib.sha256).digest()
def _le(suite, prk, label, info, n):
return hmac.new(prk, n.to_bytes(2, "big") + b"HPKE-v1" + suite + label + info + b"\x01", hashlib.sha256).digest()[:n]
def seal(pub_b64u, hook_id, plaintext):
pk = base64.urlsafe_b64decode(pub_b64u + "=" * (-len(pub_b64u) % 4))
e = X25519PrivateKey.generate()
enc = e.public_key().public_bytes(Encoding.Raw, PublicFormat.Raw)
kem, suite = b"KEM\x00\x20", b"HPKE\x00\x20\x00\x01\x00\x03"
shared = _le(kem, _lx(kem, b"", b"eae_prk", e.exchange(X25519PublicKey.from_public_bytes(pk))), b"shared_secret", enc + pk, 32)
ctx = b"\x00" + _lx(suite, b"", b"psk_id_hash", b"") + _lx(suite, b"", b"info_hash", b"agentj-hook-seal-v1\n" + hook_id.encode())
s = _lx(suite, shared, b"secret", b"")
return enc + ChaCha20Poly1305(_le(suite, s, b"key", ctx, 32)).encrypt(_le(suite, s, b"base_nonce", ctx, 12), plaintext, b"")
Then send the sealed bytes with any HTTP client, for example curl:
ts=$(date +%s) # X-Signature = hex(HMAC-SHA256(secret, ts + "." + original body))
curl -X POST "$URL" --data-binary @sealed.bin -H "Content-Type: application/octet-stream" \
-H "X-AgentJ-Seal: v1; kid=$KID" -H "X-Timestamp: $ts" -H "X-Signature: $SIG"
Node 18+ (no packages):
// Node 18+, no packages. Same inputs; returns the request body (Buffer).
const c = require("node:crypto");
const lx = (suite, salt, label, ikm) => c.createHmac("sha256", salt.length ? salt : Buffer.alloc(32))
.update(Buffer.concat([Buffer.from("HPKE-v1"), suite, Buffer.from(label), ikm])).digest();
const le = (suite, prk, label, info, n) => { const l = Buffer.alloc(2); l.writeUInt16BE(n);
return c.createHmac("sha256", prk).update(Buffer.concat([l, Buffer.from("HPKE-v1"), suite, Buffer.from(label), info,
Buffer.from([1])])).digest().subarray(0, n); };
function seal(pubB64u, hookId, plaintext) {
const pk = Buffer.from(pubB64u, "base64url");
const { publicKey, privateKey } = c.generateKeyPairSync("x25519");
const enc = Buffer.from(publicKey.export({ format: "jwk" }).x, "base64url");
const dh = c.diffieHellman({ privateKey, publicKey: c.createPublicKey({ key: { kty: "OKP", crv: "X25519", x: pubB64u }, format: "jwk" }) });
const kem = Buffer.from("KEM\x00\x20", "latin1"), suite = Buffer.from("HPKE\x00\x20\x00\x01\x00\x03", "latin1");
const shared = le(kem, lx(kem, Buffer.alloc(0), "eae_prk", dh), "shared_secret", Buffer.concat([enc, pk]), 32);
const ctx = Buffer.concat([Buffer.from([0]), lx(suite, Buffer.alloc(0), "psk_id_hash", Buffer.alloc(0)),
lx(suite, Buffer.alloc(0), "info_hash", Buffer.from("agentj-hook-seal-v1\n" + hookId))]);
const s = lx(suite, shared, "secret", Buffer.alloc(0));
const ci = c.createCipheriv("chacha20-poly1305", le(suite, s, "key", ctx, 32), le(suite, s, "base_nonce", ctx, 12), { authTagLength: 16 });
return Buffer.concat([enc, ci.update(plaintext), ci.final(), ci.getAuthTag()]);
}
Examples
agentj hook create --preset callback --name video-123 --note "Video job 123 finished" --json
agentj hook create --preset stripe --name stripe-payments
agentj hook logs <id>
The first one makes a one-time callback, the second a resident Stripe hook (approve the card on your phone), the third shows what a hook has received. Every option: agentj command reference.
External assistants: one-way MCP requests
On your phone, open Settings → Agent tools → Webhooks → External assistant · One-way requests. Enter a connection name and allowed website origins, one exact HTTPS origin per line, such as https://assistant.example, without a path, query or trailing slash. Tap Create connection, confirm the signed card on your phone, then verify with Face ID on the pickup card to collect the credential once. Copy the connection URL from the list.
An external assistant can send requests and receive fixed receipts. It cannot read Agent J replies, conversations or work results, or approve actions for you. Incoming requests and authentication pass through hosted relay memory; replies and work results stay on your host and phone. The list shows metadata only. If you lose a credential, choose Rotate credential, confirm the signed card and collect its replacement; the old credential stops working immediately. Choose Revoke connection and confirm its signed card when you no longer need the connection.
This version supports MCP 2025-06-18 with stateless JSON requests, without SSE or two-way result delivery. Connecting a Muse account and completing platform review still require the owner's authorization and live verification. This page does not claim Muse approval or compatibility.