aoconnect
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAOConnect Skill
AOConnect Skill
A command-line interface for interacting with AO processes using the library.
@permaweb/aoconnect一款基于库的命令行界面工具,用于与AO进程进行交互。
@permaweb/aoconnectPhrase Mappings
短语映射
| User Request | Command |
|---|---|
| "use aoconnect to spawn" | |
| "use aoconnect to message" | |
| "use aoconnect to read result" | |
| "use aoconnect to dryrun" | |
| "use aoconnect to monitor" | |
| "use aoconnect to connect" | |
| 用户请求 | 命令 |
|---|---|
| "使用aoconnect生成" | |
| "使用aoconnect发送消息" | |
| "使用aoconnect读取结果" | |
| "使用aoconnect试运行" | |
| "使用aoconnect监控" | |
| "使用aoconnect连接" | |
Installation
安装
Install the aoconnect skill and its dependency:
bash
npx skills add https://github.com/permaweb/skills --skill aoconnect
npm install --save @permaweb/aoconnectOr manually:
bash
cd skills/aoconnect
npm install @permaweb/aoconnect安装aoconnect skill及其依赖:
bash
npx skills add https://github.com/permaweb/skills --skill aoconnect
npm install --save @permaweb/aoconnect或手动安装:
bash
cd skills/aoconnect
npm install @permaweb/aoconnectPrerequisites
前提条件
- Node.js 18+
- @permaweb/aoconnect package installed
- Arweave wallet (JWK format) for signing messages
- Node.js 18+
- 已安装**@permaweb/aoconnect**包
- Arweave钱包(JWK格式),用于签名消息
Available Functions
可用功能
Spawn an AO Process
生成AO进程
sh
node skills/aoconnect/index.mjs spawn \
--wallet ./wallet.json \
--module <module-txid> \
--scheduler <scheduler-address>Options:
- - Path to Arweave wallet JSON
--wallet <path> - - The arweave TxID of the ao Module
--module <txid> - - The Arweave wallet address of a Scheduler Unit
--scheduler <address> - - Optional data to include in spawn message
--data <string>
Example:
sh
node skills/aoconnect/index.mjs spawn \
--wallet ./wallet.json \
--module "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
--scheduler "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"Output:
json
{
"messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
"processId": "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg",
"height": 587540,
"tags": [
{ "name": "App-Process", "value": "l3hbt..." },
{ "name": "App-Name", "value": "arweave-ao" }
]
}sh
node skills/aoconnect/index.mjs spawn \
--wallet ./wallet.json \
--module <module-txid> \
--scheduler <scheduler-address>选项:
- - Arweave钱包JSON文件路径
--wallet <path> - - AO模块的Arweave交易ID
--module <txid> - - 调度单元的Arweave钱包地址
--scheduler <address> - - 生成消息中可包含的可选数据
--data <string>
示例:
sh
node skills/aoconnect/index.mjs spawn \
--wallet ./wallet.json \
--module "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
--scheduler "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"输出:
json
{
"messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
"processId": "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg",
"height": 587540,
"tags": [
{ "name": "App-Process", "value": "l3hbt..." },
{ "name": "App-Name", "value": "arweave-ao" }
]
}Send a Message to an AO Process
向AO进程发送消息
sh
node skills/aoconnect/index.mjs message \
--wallet ./wallet.json \
--process <process-id> \
--data=<message-data> \
--tags Name=Value,Another=TagOptions:
- - Path to Arweave wallet JSON (required)
--wallet <path> - - The ao Process ID (required)
--process <id> - - Message data (optional, random string if not provided)
--data <string> - - Message tags (optional)
--tags <name=value,another=value>
Example:
sh
node skills/aoconnect/index.mjs message \
--wallet ./wallet.json \
--process "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg" \
--data="Hello from AO!" \
--tags "Action=greet", "User=Rakis"Output:
json
{
"messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
"height": 587540,
"tags": [
{ "name": "Action", "value": "greet" },
{ "name": "User", "value": "Rakis" },
{ "name": "Original-Message", "value": "l3hbt..." }
]
}sh
node skills/aoconnect/index.mjs message \
--wallet ./wallet.json \
--process <process-id> \
--data=<message-data> \
--tags Name=Value,Another=Tag选项:
- - Arweave钱包JSON文件路径(必填)
--wallet <path> - - AO进程ID(必填)
--process <id> - - 消息数据(可选,未提供则使用随机字符串)
--data <string> - - 消息标签(可选)
--tags <name=value,another=value>
示例:
sh
node skills/aoconnect/index.mjs message \
--wallet ./wallet.json \
--process "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg" \
--data="Hello from AO!" \
--tags "Action=greet", "User=Rakis"输出:
json
{
"messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
"height": 587540,
"tags": [
{ "name": "Action", "value": "greet" },
{ "name": "User", "value": "Rakis" },
{ "name": "Original-Message", "value": "l3hbt..." }
]
}Read the Result of an AO Message Evaluation
读取AO消息执行结果
sh
node skills/aoconnect/index.mjs result \
--message=<message-id> \
--process=<process-id>Options:
- - The ao message ID to evaluate (required)
--message=<id> - - The ao Process ID (required)
--process=<id>
Example:
sh
node skills/aoconnect/index.mjs result \
--message="l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
--process="5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg"Output:
json
{
"messages": [
{
"messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
"tags": [
{ "name": "Action", "value": "greet" },
{ "name": "User", "value": "Rakis" }
],
"data": "Hello from AO!"
}
],
"spawns": [],
"output": {
"messages": [
{
"from": "address",
"to": "process-id",
"target": "process-id",
"tags": [
{ "name": "Response", "value": "Hello from AO!" }
],
"data": "",
"height": 587541
}
],
"size": 256
},
"error": null
}sh
node skills/aoconnect/index.mjs result \
--message=<message-id> \
--process=<process-id>选项:
- - 要执行的AO消息ID(必填)
--message=<id> - - AO进程ID(必填)
--process=<id>
示例:
sh
node skills/aoconnect/index.mjs result \
--message="l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
--process="5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg"输出:
json
{
"messages": [
{
"messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
"tags": [
{ "name": "Action", "value": "greet" },
{ "name": "User", "value": "Rakis" }
],
"data": "Hello from AO!"
}
],
"spawns": [],
"output": {
"messages": [
{
"from": "address",
"to": "process-id",
"target": "process-id",
"tags": [
{ "name": "Response", "value": "Hello from AO!" }
],
"data": "",
"height": 587541
}
],
"size": 256
},
"error": null
}Dry Run a Message (No Memory Commit)
试运行消息(不提交内存)
sh
node skills/aoconnect/index.mjs dryrun \
--message=<message-id> \
--process=<process-id>Options:
- - The ao message ID to dry run (required)
--message=<id> - - The ao Process ID (required)
--process=<id>
Example:
sh
node skills/aoconnect/index.mjs dryrun \
--message="l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
--process="5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg"Output:
json
{
"messages": [
{
"messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
"tags": [
{ "name": "Action", "value": "greet" }
]
}
],
"spawns": [],
"output": {
"messages": [
{
"from": "address",
"to": "process-id",
"target": "process-id",
"tags": [
{ "name": "Response", "value": "Hello from AO!" }
],
"height": 587541
}
],
"size": 256
},
"error": null
}Note: Dry run evaluates the message but doesn't save it to memory. Perfect for testing without committing to the chain.
sh
node skills/aoconnect/index.mjs dryrun \
--message=<message-id> \
--process=<process-id>选项:
- - 要试运行的AO消息ID(必填)
--message=<id> - - AO进程ID(必填)
--process=<id>
示例:
sh
node skills/aoconnect/index.mjs dryrun \
--message="l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
--process="5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg"输出:
json
{
"messages": [
{
"messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
"tags": [
{ "name": "Action", "value": "greet" }
]
}
],
"spawns": [],
"output": {
"messages": [
{
"from": "address",
"to": "process-id",
"target": "process-id",
"tags": [
{ "name": "Response", "value": "Hello from AO!" }
],
"height": 587541
}
],
"size": 256
},
"error": null
}注意: 试运行会执行消息但不会将其保存到内存,非常适合在不提交到链上的情况下进行测试。
Monitor Messages
监控消息
sh
node skills/aoconnect/index.mjs monitor \
--process <process-id> \
--on-message "<callback>"Options:
- - The ao Process ID to monitor (required)
--process <id> - - JavaScript function to call for each new message (required)
--on-message "<function>"
Example:
sh
node skills/aoconnect/index.mjs monitor \
--process "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg" \
--on-message 'return { tags: msg.tags, data: msg.data }'Note: In chat interface, use this pattern:
bash
node skills/aoconnect/index.mjs monitor --process <id> --on-message "{console.log(msg.tags)}"sh
node skills/aoconnect/index.mjs monitor \
--process <process-id> \
--on-message "<callback>"选项:
- - 要监控的AO进程ID(必填)
--process <id> - - 每条新消息触发的JavaScript函数(必填)
--on-message "<function>"
示例:
sh
node skills/aoconnect/index.mjs monitor \
--process "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg" \
--on-message 'return { tags: msg.tags, data: msg.data }'注意: 在聊天界面中,使用以下格式:
bash
node skills/aoconnect/index.mjs monitor --process <id> --on-message "{console.log(msg.tags)}"Connect to Custom Nodes
连接到自定义节点
sh
node skills/aoconnect/index.mjs connect --mu <url> --cu <url> --gateway <url>Options:
- - Message Unit URL (optional)
--mu <url> - - Compute Unit URL (optional)
--cu <url> - - Arweave gateway URL (optional)
--gateway <url>
Example:
sh
node skills/aoconnect/index.mjs connect \
--mu "https://mu.ao-testnet.xyz" \
--cu "https://cu.ao-testnet.xyz" \
--gateway "https://arweave.net"sh
node skills/aoconnect/index.mjs connect --mu <url> --cu <url> --gateway <url>选项:
- - 消息单元URL(可选)
--mu <url> - - 计算单元URL(可选)
--cu <url> - - Arweave网关URL(可选)
--gateway <url>
示例:
sh
node skills/aoconnect/index.mjs connect \
--mu "https://mu.ao-testnet.xyz" \
--cu "https://cu.ao-testnet.xyz" \
--gateway "https://arweave.net"Usage with AI Tools
与AI工具配合使用
Claude Code / OpenCode will automatically invoke the aoconnect skill when you:
bash
use aoconnect to spawn <process>
use aoconnect to message <process> --data=<string>
use aoconnect to read result --message=<id>
use aoconnect to dryrun --message=<id>The skill will prompt for wallet path if not configured.
当你输入以下命令时,Claude Code / OpenCode会自动调用aoconnect skill:
bash
use aoconnect to spawn <process>
use aoconnect to message <process> --data=<string>
use aoconnect to read result --message=<id>
use aoconnect to dryrun --message=<id>如果未配置钱包路径,该skill会提示你提供。
Common Use Cases
常见使用场景
Send a Transfer Message
发送转账消息
sh
node skills/aoconnect/index.mjs message \
--wallet ./wallet.json \
--process "ao-token-demo-AOe5Hdg4UQhOiE0ZYvRjB_8YDhROi3pA0YCEhPzb_KQ" \
--data=<raw-balance-value> \
--tags "Action=Transfer", "Recipient=<address>"sh
node skills/aoconnect/index.mjs message \
--wallet ./wallet.json \
--process "ao-token-demo-AOe5Hdg4UQhOiE0ZYvRjB_8YDhROi3pA0YCEhPzb_KQ" \
--data=<raw-balance-value> \
--tags "Action=Transfer", "Recipient=<address>"Dry Run Before Committing
提交前先试运行
Always dry run first to verify your message works:
sh
node skills/aoconnect/index.mjs message \
--wallet ./wallet.json \
--process <process-id> \
--data="test"
node skills/aoconnect/index.mjs dryrun \
--message=<message-id> \
--process=<process-id>始终先进行试运行以验证消息是否可用:
sh
node skills/aoconnect/index.mjs message \
--wallet ./wallet.json \
--process <process-id> \
--data="test"
node skills/aoconnect/index.mjs dryrun \
--message=<message-id> \
--process=<process-id>Monitor Active Process
监控活跃进程
sh
node skills/aoconnect/index.mjs monitor \
--process "<active-process-id>" \
--on-message "{console.log('New message:', msg.tags)}"sh
node skills/aoconnect/index.mjs monitor \
--process "<active-process-id>" \
--on-message "{console.log('New message:', msg.tags)}"Error Handling
错误处理
Missing Wallet
缺少钱包
Error: walletPath is required. Please provide a path to your Arweave wallet JSON file.Solution: Provide a wallet path:
sh
--wallet ./wallet.jsonError: walletPath is required. Please provide a path to your Arweave wallet JSON file.解决方案: 提供钱包路径:
sh
--wallet ./wallet.jsonInvalid Process ID
无效进程ID
Error: Failed to send message: Invalid process IDSolution: Verify the process ID is correct and valid.
Error: Failed to send message: Invalid process ID解决方案: 验证进程ID是否正确有效。
Authentication Failures
认证失败
Error: Failed to send message: UnauthorizedSolution: Ensure your wallet has sufficient balance and proper permissions.
Error: Failed to send message: Unauthorized解决方案: 确保你的钱包有足够的余额和适当的权限。
API Reference
API参考
messageAo(processId, options)
messageAo(processId, options)
Send a message to an ao Process.
Parameters:
- (string): The ao Process ID
processId - (Object): Message options
options- (string): Message data
data - (Array): Message tags
tags - (string): Path to wallet JSON
walletPath
Returns: Promise<Object> - Message result
向AO进程发送消息。
参数:
- (string): AO进程ID
processId - (Object): 消息选项
options- (string): 消息数据
data - (Array): 消息标签
tags - (string): 钱包JSON文件路径
walletPath
返回值: Promise<Object> - 消息结果
resultAo(options)
resultAo(options)
Read the result of an ao message evaluation.
Parameters:
- (Object)
options- (string): The message ID
message - (string): The Process ID
process
Returns: Promise<Object> - Result object
读取AO消息执行结果。
参数:
- (Object)
options- (string): 消息ID
message - (string): 进程ID
process
返回值: Promise<Object> - 结果对象
dryrunAo(options)
dryrunAo(options)
Dry run a message without committing to memory.
Parameters:
- (Object)
options- (string): The message ID
message - (string): The Process ID
process
Returns: Promise<Object> - Dry run result
试运行消息,不提交到内存。
参数:
- (Object)
options- (string): 消息ID
message - (string): 进程ID
process
返回值: Promise<Object> - 试运行结果
spawnAo(options)
spawnAo(options)
Spawn an ao Process.
Parameters:
- (Object)
options- (string): Module TxID
module - (string): Scheduler address
scheduler - (string): Path to wallet JSON
walletPath - (Array): Tags for spawn message
tags
Returns: Promise<Object> - Spawn result
生成AO进程。
参数:
- (Object)
options- (string): 模块交易ID
module - (string): 调度器地址
scheduler - (string): 钱包JSON文件路径
walletPath - (Array): 生成消息的标签
tags
返回值: Promise<Object> - 生成结果
monitorAo(options)
monitorAo(options)
Monitor messages from a Process.
Parameters:
- (Object)
options- (string): Process ID
process - (Function): Callback for new messages
onMessage
Returns: string - Monitor ID
监控进程的消息。
参数:
- (Object)
options- (string): 进程ID
process - (Function): 新消息的回调函数
onMessage
返回值: string - 监控ID
unmonitorAo(monitorId)
unmonitorAo(monitorId)
Stop monitoring messages.
Parameters:
- (string): Monitor ID
monitorId
停止监控消息。
参数:
- (string): 监控ID
monitorId
connectAo(config)
connectAo(config)
Connect to ao nodes with custom configuration.
Parameters:
- (Object)
config- (string): Message Unit URL
MU_URL - (string): Compute Unit URL
CU_URL - (string): Arweave gateway URL
GATEWAY_URL
Returns: Object - aoconnect functions
使用自定义配置连接到AO节点。
参数:
- (Object)
config- (string): 消息单元URL
MU_URL - (string): 计算单元URL
CU_URL - (string): Arweave网关URL
GATEWAY_URL
返回值: Object - aoconnect函数集合
getConnection(config)
getConnection(config)
Get connected aoconnect functions.
Parameters:
- (Object): Connection config
config
Returns: Object - aoconnect functions
获取已连接的aoconnect函数。
参数:
- (Object): 连接配置
config
返回值: Object - aoconnect函数集合
Node.js vs Browser
Node.js与浏览器对比
This skill works in both Node.js and browser environments.
该skill可在Node.js和浏览器环境中使用。
Node.js
Node.js
javascript
import { messageAo, createDataItemSigner } from "./index.mjs";
import { readFileSync } from "node:fs";
const wallet = JSON.parse(readFileSync("./wallet.json", "utf-8"));
const result = await messageAo("process-id", {
walletPath: "./wallet.json",
data: "Hello AO!",
tags: [{ name: "Action", value: "greet" }]
});javascript
import { messageAo, createDataItemSigner } from "./index.mjs";
import { readFileSync } from "node:fs";
const wallet = JSON.parse(readFileSync("./wallet.json", "utf-8"));
const result = await messageAo("process-id", {
walletPath: "./wallet.json",
data: "Hello AO!",
tags: [{ name: "Action", value: "greet" }]
});Browser
浏览器
javascript
import { messageAo, createDataItemSigner } from "./index.mjs";
const result = await messageAo("process-id", {
walletPath: "/path/to/wallet.json", // or loaded from localStorage
data: "Hello AO!",
tags: [{ name: "Action", value: "greet" }]
});javascript
import { messageAo, createDataItemSigner } from "./index.mjs";
const result = await messageAo("process-id", {
walletPath: "/path/to/wallet.json", // 或从localStorage加载
data: "Hello AO!",
tags: [{ name: "Action", value: "greet" }]
});