arcbounty-agent-sdk 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -0
- package/dist/index.d.mts +220 -11
- package/dist/index.d.ts +220 -11
- package/dist/index.js +362 -141
- package/dist/index.mjs +358 -138
- package/package.json +11 -3
- package/.env.example +0 -13
- package/examples/demo-agent.ts +0 -94
- package/src/ArcBountyAgent.ts +0 -645
- package/src/abi.ts +0 -386
- package/src/constants.ts +0 -20
- package/src/index.ts +0 -21
- package/src/ipfs.ts +0 -80
- package/src/metadata.ts +0 -69
- package/src/types.ts +0 -105
- package/tsconfig.json +0 -13
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arcbounty-agent-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "TypeScript SDK for AI agents to interact with ArcBounty — ERC-8183 + ERC-8004 on Arc Network",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"types": "./dist/index.d.ts",
|
|
@@ -15,7 +18,8 @@
|
|
|
15
18
|
"scripts": {
|
|
16
19
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
17
20
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
18
|
-
"typecheck": "tsc --noEmit"
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"test": "vitest run"
|
|
19
23
|
},
|
|
20
24
|
"keywords": [
|
|
21
25
|
"arc",
|
|
@@ -33,6 +37,10 @@
|
|
|
33
37
|
"@types/node": "^25.6.0",
|
|
34
38
|
"tsup": "^8.0.0",
|
|
35
39
|
"typescript": "^5.0.0",
|
|
36
|
-
"viem": "^2.0.0"
|
|
40
|
+
"viem": "^2.0.0",
|
|
41
|
+
"vitest": "^4.1.9"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@circle-fin/developer-controlled-wallets": "^10.8.0"
|
|
37
45
|
}
|
|
38
46
|
}
|
package/.env.example
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Agent wallet — fund with a tiny amount of ARC for gas + USDC for take/work flow.
|
|
2
|
-
AGENT_PRIVATE_KEY="0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
3
|
-
|
|
4
|
-
# Arc Testnet
|
|
5
|
-
ARC_RPC_URL="https://rpc.testnet.arc.network"
|
|
6
|
-
|
|
7
|
-
# Canonical BountyAdapter — source of truth: contracts/DEPLOYMENTS.md
|
|
8
|
-
BOUNTY_ADAPTER_ADDRESS="0x5E7106382bA80c8805A570dEE4cB4bC321a8Ed83"
|
|
9
|
-
|
|
10
|
-
# IPFS pinning (server-to-server from the agent). Prefer JWT.
|
|
11
|
-
PINATA_JWT=""
|
|
12
|
-
PINATA_API_KEY=""
|
|
13
|
-
PINATA_SECRET=""
|
package/examples/demo-agent.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Demo Agent — ArcBounty
|
|
3
|
-
*
|
|
4
|
-
* Runs the full autonomous cycle:
|
|
5
|
-
* 1. Pin agent metadata to IPFS (real CID, persistent — never data:).
|
|
6
|
-
* 2. Register in ERC-8004 IdentityRegistry (idempotent).
|
|
7
|
-
* 3. Subscribe to BountyCreated, pick the first matching new bounty.
|
|
8
|
-
* 4. Take it, run the task, submit the result.
|
|
9
|
-
*
|
|
10
|
-
* Env:
|
|
11
|
-
* AGENT_PRIVATE_KEY — agent wallet (0x...)
|
|
12
|
-
* BOUNTY_ADAPTER_ADDRESS — current adapter (see contracts/DEPLOYMENTS.md)
|
|
13
|
-
* PINATA_JWT — server-side IPFS pinning
|
|
14
|
-
* ARC_RPC_URL — optional, defaults to Arc Testnet RPC
|
|
15
|
-
*
|
|
16
|
-
* Run:
|
|
17
|
-
* npx tsx examples/demo-agent.ts
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
ArcBountyAgent,
|
|
22
|
-
pinAgentMetadata,
|
|
23
|
-
type AgentMetadata,
|
|
24
|
-
type BountyMeta,
|
|
25
|
-
} from "../src/index.js";
|
|
26
|
-
|
|
27
|
-
const METADATA: AgentMetadata = {
|
|
28
|
-
name: "DemoTranslationAgent v0.1",
|
|
29
|
-
description: "Demo agent that transforms content-category bounty descriptions.",
|
|
30
|
-
agent_type: "translation",
|
|
31
|
-
capabilities: ["en-upper", "summarize"],
|
|
32
|
-
version: "0.1.0",
|
|
33
|
-
arcbounty: {
|
|
34
|
-
min_reputation: 0,
|
|
35
|
-
preferred_categories: ["content", "data"],
|
|
36
|
-
min_reward_usdc: 1,
|
|
37
|
-
max_reward_usdc: 100,
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
async function main() {
|
|
42
|
-
const privateKey = process.env["AGENT_PRIVATE_KEY"];
|
|
43
|
-
if (!privateKey) throw new Error("Set AGENT_PRIVATE_KEY env var");
|
|
44
|
-
|
|
45
|
-
// 1. Pin the manifest. Validates against the schema first.
|
|
46
|
-
console.log("[1/4] Pinning agent metadata to IPFS…");
|
|
47
|
-
const metadataURI = await pinAgentMetadata(METADATA);
|
|
48
|
-
console.log(" manifest =", metadataURI);
|
|
49
|
-
|
|
50
|
-
const agent = new ArcBountyAgent({
|
|
51
|
-
privateKey: privateKey as `0x${string}`,
|
|
52
|
-
metadataURI,
|
|
53
|
-
rpcUrl: process.env["ARC_RPC_URL"] ?? "https://rpc.testnet.arc.network",
|
|
54
|
-
});
|
|
55
|
-
console.log(" agent address =", agent.address);
|
|
56
|
-
|
|
57
|
-
// 2. Register (idempotent — finds existing tokenId if already minted).
|
|
58
|
-
console.log("\n[2/4] Registering in ERC-8004 IdentityRegistry…");
|
|
59
|
-
const agentId = await agent.register();
|
|
60
|
-
console.log(" agent ID =", agentId.toString());
|
|
61
|
-
|
|
62
|
-
// 3. Either take a pre-existing open bounty, or wait for the next match.
|
|
63
|
-
console.log("\n[3/4] Looking for content bounties (max $50)…");
|
|
64
|
-
const existing = await agent.listOpenBounties({ category: "content", maxReward: 50 });
|
|
65
|
-
let target: BountyMeta | undefined = existing[0];
|
|
66
|
-
|
|
67
|
-
if (!target) {
|
|
68
|
-
console.log(" none open — subscribing for the next match (5min)…");
|
|
69
|
-
target = await new Promise<BountyMeta>((resolve, reject) => {
|
|
70
|
-
const timeout = setTimeout(() => { stop(); reject(new Error("no matching bounty in 5 minutes")); }, 5 * 60_000);
|
|
71
|
-
const stop = agent.subscribeToNewBounties(
|
|
72
|
-
{ category: "content", maxReward: 50 },
|
|
73
|
-
meta => { clearTimeout(timeout); stop(); resolve(meta); },
|
|
74
|
-
);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
console.log(` picked #${target.jobId} ($${agent.formatUsdc(target.reward)} USDC)`);
|
|
78
|
-
|
|
79
|
-
// 4. Take → run task off-chain → submit result.
|
|
80
|
-
console.log("\n[4/4] Take + run + submit…");
|
|
81
|
-
await agent.runOnce(
|
|
82
|
-
{ category: "content", maxReward: 50 },
|
|
83
|
-
async (description, meta) => {
|
|
84
|
-
console.log(" desc:", description.slice(0, 120));
|
|
85
|
-
return `## Result from DemoAgent\n\n**Bounty #${meta.jobId}** processed.\n\n${description.toUpperCase()}`;
|
|
86
|
-
},
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const rep = await agent.getReputation();
|
|
90
|
-
console.log(`\nDone. Reputation: ${rep.averageScore}/100 over ${rep.totalJobs} job(s).`);
|
|
91
|
-
console.log("Poster has 14 days to approve/reject. After that anyone can call autoApprove.");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
main().catch(err => { console.error("Fatal:", err); process.exit(1); });
|