dappily-agent-kit 0.1.0 → 0.4.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.
Files changed (42) hide show
  1. package/README.md +126 -121
  2. package/dist/actions/_sandbox_hbar_transfer.d.ts +4 -0
  3. package/dist/actions/_sandbox_hbar_transfer.d.ts.map +1 -0
  4. package/dist/actions/_sandbox_hbar_transfer.js +64 -0
  5. package/dist/actions/_sandbox_hbar_transfer.js.map +1 -0
  6. package/dist/actions/create_topic.d.ts +4 -0
  7. package/dist/actions/create_topic.d.ts.map +1 -0
  8. package/dist/actions/create_topic.js +136 -0
  9. package/dist/actions/create_topic.js.map +1 -0
  10. package/dist/actions/delete_topic.d.ts +4 -0
  11. package/dist/actions/delete_topic.d.ts.map +1 -0
  12. package/dist/actions/delete_topic.js +102 -0
  13. package/dist/actions/delete_topic.js.map +1 -0
  14. package/dist/actions/get_topic_info.d.ts +4 -0
  15. package/dist/actions/get_topic_info.d.ts.map +1 -0
  16. package/dist/actions/get_topic_info.js +79 -0
  17. package/dist/actions/get_topic_info.js.map +1 -0
  18. package/dist/actions/index.d.ts +5 -1
  19. package/dist/actions/index.d.ts.map +1 -1
  20. package/dist/actions/index.js +15 -1
  21. package/dist/actions/index.js.map +1 -1
  22. package/dist/actions/submit_message.d.ts +4 -0
  23. package/dist/actions/submit_message.d.ts.map +1 -0
  24. package/dist/actions/submit_message.js +129 -0
  25. package/dist/actions/submit_message.js.map +1 -0
  26. package/dist/forge/actionSpec.d.ts +389 -0
  27. package/dist/forge/actionSpec.d.ts.map +1 -0
  28. package/dist/forge/actionSpec.js +127 -0
  29. package/dist/forge/actionSpec.js.map +1 -0
  30. package/dist/forge/generator.d.ts +9 -0
  31. package/dist/forge/generator.d.ts.map +1 -0
  32. package/dist/forge/generator.js +322 -0
  33. package/dist/forge/generator.js.map +1 -0
  34. package/dist/forge/index.d.ts +4 -0
  35. package/dist/forge/index.d.ts.map +1 -0
  36. package/dist/forge/index.js +12 -0
  37. package/dist/forge/index.js.map +1 -0
  38. package/dist/index.d.ts +3 -1
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +11 -1
  41. package/dist/index.js.map +1 -1
  42. package/package.json +12 -4
package/README.md CHANGED
@@ -1,24 +1,51 @@
1
1
  # 🦞 Dappily Agent Kit
2
2
 
3
- **Solana Agent Kit-style actions for Hedera — HTS tokens, NFTs, transfers, and more.**
3
+ **AI agent toolkit for Hedera — 15 actions + self-forging action generator.**
4
4
 
5
- Give any AI agent the ability to interact with the Hedera network. Inspired by [solana-agent-kit](https://github.com/sendaifun/solana-agent-kit).
5
+ Give any AI agent the ability to interact with the Hedera network. Define actions as JSON specs, generate working TypeScript automatically.
6
6
 
7
- ## Proven on Testnet
7
+ ## What's New in 0.3.0: The Forge
8
8
 
9
- Every action has been tested with real transactions on Hedera testnet not just schema validation, but actual on-chain execution with verified receipts:
9
+ The kit now includes a **deterministic action generator**. Write a JSON spec get a working, type-safe Hedera action with zero manual code.
10
10
 
11
- | Action | Testnet Proof |
12
- |--------|---------------|
13
- | GET_BALANCE | 999 ℏ queried |
14
- | HBAR_TRANSFER | ✅ Receipt: SUCCESS |
15
- | CREATE_TOKEN | ✅ Token `0.0.7932264` created |
16
- | MINT_TOKEN | Supply 10000 → 15000 |
17
- | BURN_TOKEN | ✅ Supply 15000 → 14000 |
18
- | TRANSFER_TOKEN | 100 tokens moved |
19
- | CREATE_NFT_COLLECTION | ✅ Collection `0.0.7932266` created |
20
- | MINT_NFT | Serials [1, 2, 3] returned |
21
- | BURN_NFT | ✅ Serial #3 destroyed |
11
+ ```typescript
12
+ import { validateSpec, generateAction } from "dappily-agent-kit";
13
+ import * as fs from "fs";
14
+
15
+ // Load a spec
16
+ const spec = JSON.parse(fs.readFileSync("my_action.spec.json", "utf-8"));
17
+
18
+ // Validate against the schema
19
+ const result = validateSpec(spec);
20
+ if (!result.ok) throw new Error(result.errors.join("\n"));
21
+
22
+ // Generate TypeScript code
23
+ const code = generateAction(result.spec);
24
+ fs.writeFileSync("src/actions/my_action.ts", code);
25
+ // → Compiles. Runs on testnet. Zero edits needed.
26
+ ```
27
+
28
+ **Proven on testnet:** The generator produces actions that compile with `tsc --strict` and execute real transactions on Hedera testnet — token creation, HBAR transfers, consensus queries — all without a single manual fix.
29
+
30
+ ## Testnet-Verified Actions
31
+
32
+ | # | Action | Domain | Testnet Proof |
33
+ |---|--------|--------|---------------|
34
+ | 1 | `GET_BALANCE` | Core | ✅ Live query |
35
+ | 2 | `HBAR_TRANSFER` | Core | ✅ Receipt: SUCCESS |
36
+ | 3 | `CREATE_TOKEN` | HTS Fungible | ✅ Token created |
37
+ | 4 | `ASSOCIATE_TOKEN` | HTS Fungible | ✅ |
38
+ | 5 | `TRANSFER_TOKEN` | HTS Fungible | ✅ |
39
+ | 6 | `MINT_TOKEN` | HTS Fungible | ✅ Supply verified |
40
+ | 7 | `BURN_TOKEN` | HTS Fungible | ✅ Supply verified |
41
+ | 8 | `CREATE_NFT_COLLECTION` | HTS NFT | ✅ Collection created |
42
+ | 9 | `MINT_NFT` | HTS NFT | ✅ Serials [1,2,3] |
43
+ | 10 | `TRANSFER_NFT` | HTS NFT | ✅ |
44
+ | 11 | `BURN_NFT` | HTS NFT | ✅ Serial destroyed |
45
+ | 12 | `CREATE_TOPIC` | HCS | ✅ Topic created |
46
+ | 13 | `SUBMIT_MESSAGE` | HCS | ✅ 3 messages, seq verified |
47
+ | 14 | `GET_TOPIC_INFO` | HCS | ✅ Memo + seq + keys |
48
+ | 15 | `DELETE_TOPIC` | HCS | ✅ Deleted + verified |
22
49
 
23
50
  ## Quickstart
24
51
 
@@ -29,159 +56,137 @@ npm install dappily-agent-kit @hashgraph/sdk
29
56
  ```typescript
30
57
  import { HederaAgentKit, getBalanceAction, createTokenAction } from "dappily-agent-kit";
31
58
 
32
- // Initialize with your Hedera credentials
33
- const agent = new HederaAgentKit(
34
- "0.0.YOUR_ACCOUNT",
35
- "YOUR_PRIVATE_KEY",
36
- "testnet" // or "mainnet"
37
- );
59
+ const agent = new HederaAgentKit("0.0.YOUR_ACCOUNT", "YOUR_KEY", "testnet");
38
60
 
39
61
  // Check balance
40
- const balance = await getBalanceAction.handler(agent, {});
41
- if (balance.ok) {
42
- console.log(balance.data.hbarBalance); // "150.5 ℏ"
43
- }
62
+ const bal = await getBalanceAction.handler(agent, {});
63
+ if (bal.ok) console.log(bal.data.hbarBalance);
44
64
 
45
65
  // Create a token
46
66
  const token = await createTokenAction.handler(agent, {
47
- name: "My Token",
48
- symbol: "MTK",
49
- initialSupply: 1000000,
50
- decimals: 2,
67
+ name: "My Token", symbol: "MTK", initialSupply: 1000000, decimals: 2,
51
68
  });
52
- if (token.ok) {
53
- console.log(token.data.tokenId); // "0.0.XXXXX"
54
- }
69
+ if (token.ok) console.log(token.data.tokenId);
55
70
  ```
56
71
 
57
- ## Actions
72
+ ## Standardized Output
58
73
 
59
- ### Core
74
+ Every action returns:
60
75
 
61
- | Action | Input | Description |
62
- |--------|-------|-------------|
63
- | `GET_BALANCE` | `{ accountId?: string }` | Get HBAR + token balances. Defaults to agent's account. |
64
- | `HBAR_TRANSFER` | `{ to, amount, memo? }` | Send HBAR to another account. |
76
+ ```typescript
77
+ // Success
78
+ { ok: true, summary: "...", txId: "...", receipt: { status: "SUCCESS" }, data: { ... } }
65
79
 
66
- ### Fungible Tokens (HTS)
80
+ // Failure
81
+ { ok: false, error: "INSUFFICIENT_PAYER_BALANCE", details: "..." }
82
+ ```
67
83
 
68
- | Action | Input | Description |
69
- |--------|-------|-------------|
70
- | `CREATE_TOKEN` | `{ name, symbol, initialSupply, decimals?, memo? }` | Create a new fungible token. |
71
- | `ASSOCIATE_TOKEN` | `{ tokenId, accountId?, accountPrivateKey? }` | Associate a token with an account. |
72
- | `TRANSFER_TOKEN` | `{ tokenId, to, amount, memo? }` | Transfer fungible tokens. Pre-flight association check. |
73
- | `MINT_TOKEN` | `{ tokenId, amount, supplyPrivateKey? }` | Mint additional supply. |
74
- | `BURN_TOKEN` | `{ tokenId, amount, supplyPrivateKey? }` | Burn supply (irreversible). |
84
+ ## The Forge: Self-Forging Actions
75
85
 
76
- ### NFTs (HTS)
86
+ The Forge is a deterministic code generator that turns JSON specs into working Hedera actions.
77
87
 
78
- | Action | Input | Description |
79
- |--------|-------|-------------|
80
- | `CREATE_NFT_COLLECTION` | `{ name, symbol, maxSupply?, memo? }` | Create an NFT collection. |
81
- | `MINT_NFT` | `{ tokenId, metadata: string[], supplyPrivateKey? }` | Mint NFTs with base64 metadata. Returns serial numbers. |
82
- | `TRANSFER_NFT` | `{ tokenId, serial, to, senderPrivateKey? }` | Transfer an NFT. Pre-flight association check. |
83
- | `BURN_NFT` | `{ tokenId, serial, supplyPrivateKey? }` | Burn an NFT (irreversible). |
88
+ ### How It Works
84
89
 
85
- ## Standardized Output
90
+ 1. **Spec** — A JSON file describing the action: inputs, SDK methods, transforms, error maps
91
+ 2. **Validate** — Zod schema ensures the spec is machine-correct
92
+ 3. **Generate** — Deterministic template fill produces TypeScript code
93
+ 4. **Compile** — `tsc --strict` verifies type safety
94
+ 5. **Test** — Run against Hedera testnet to verify real execution
86
95
 
87
- Every action returns the same shape:
96
+ ### Spec Format (v4)
88
97
 
89
- ```typescript
90
- // Success
98
+ ```json
91
99
  {
92
- ok: true,
93
- summary: "Sent 10 HBAR to 0.0.12345",
94
- txId: "0.0.98765@1700000000.000000000",
95
- receipt: { status: "SUCCESS" },
96
- data: { /* action-specific */ }
100
+ "specVersion": 4,
101
+ "name": "MY_ACTION",
102
+ "category": "fungible",
103
+ "risk": "write",
104
+ "costTier": "medium",
105
+ "hedera": {
106
+ "sdkClass": "TokenCreateTransaction",
107
+ "sdkImports": ["TokenCreateTransaction", "Status"],
108
+ "networkCallType": "transaction"
109
+ },
110
+ "sdkMethods": [
111
+ { "method": "setTokenName", "args": [{ "from": "input.name" }] }
112
+ ],
113
+ "inputs": [
114
+ { "name": "name", "type": "string", "required": true, "describe": "Token name" }
115
+ ],
116
+ "successData": [...],
117
+ "errorMap": [...]
97
118
  }
119
+ ```
98
120
 
99
- // Failure
100
- {
101
- ok: false,
102
- error: "INSUFFICIENT_PAYER_BALANCE",
103
- details: "The sending account does not have enough HBAR."
104
- }
121
+ ### CLI
122
+
123
+ ```bash
124
+ # Validate all specs
125
+ npm run forge:validate
126
+
127
+ # Generate an action from a spec
128
+ npm run forge:generate -- specs/create_token.spec.json output.ts
105
129
  ```
106
130
 
107
- Error codes are mapped from Hedera's native codes to human-readable messages. Pre-flight checks (like association verification) prevent wasted transactions.
131
+ ### 15 Reference Specs
132
+
133
+ The kit includes specs for all 15 built-in actions in `src/forge/specs/`. These serve as the pattern library — examples of every structural pattern:
134
+
135
+ - **Queries** (free, no signing): `get_balance`, `get_topic_info`
136
+ - **Simple transactions**: `create_token`, `create_topic`, `delete_topic`, `mint_token`, `burn_token`, `associate_token`, `mint_nft`, `burn_nft`, `submit_message`, `create_nft_collection`
137
+ - **Multi-arg transfers**: `hbar_transfer`, `transfer_token`, `transfer_nft`
108
138
 
109
139
  ## Action Discovery
110
140
 
111
141
  ```typescript
112
142
  import { actions, getActionByName, findActionBySimile } from "dappily-agent-kit";
113
143
 
114
- // List all actions
115
- actions.forEach(a => console.log(a.name, a.description));
116
-
117
- // Lookup by name
118
- const action = getActionByName("HBAR_TRANSFER");
119
-
120
- // Fuzzy match (for AI agents)
121
- const match = findActionBySimile("send some hbar");
122
- // → hbarTransferAction
144
+ actions.forEach(a => console.log(a.name));
145
+ getActionByName("HBAR_TRANSFER");
146
+ findActionBySimile("send some hbar"); // → hbarTransferAction
123
147
  ```
124
148
 
125
149
  ## Examples
126
150
 
127
- See the [`examples/`](./examples) directory:
151
+ See [`examples/`](./examples):
128
152
 
129
- - **`balance.ts`** — Check account balance
130
- - **`fungible-lifecycle.ts`** — Create → Mint → Transfer → Burn
131
- - **`nft-lifecycle.ts`** — Create collection → Mint NFTs → Burn
132
-
133
- ```bash
134
- OPERATOR_ID=0.0.XXXXX OPERATOR_KEY=302e... npx ts-node examples/balance.ts
135
- ```
153
+ - `balance.ts` — Check account balance
154
+ - `fungible-lifecycle.ts` — Create → Mint → Transfer → Burn
155
+ - `nft-lifecycle.ts` — Create collection → Mint → Burn
156
+ - `hcs-lifecycle.ts` — Create topic → Submit messages → Query → Delete
136
157
 
137
158
  ## Security
138
159
 
139
- ⚠️ **Private keys in action inputs** are supported for development and testing. For production:
140
-
141
- - Use environment variables or a vault for key storage
142
- - Never log or persist private keys
143
- - Plan to integrate wallet signing (HashPack / WalletConnect) for third-party accounts
144
- - The `accountPrivateKey` and `supplyPrivateKey` fields will be replaced with a signing interface in a future version
160
+ ⚠️ Private keys in action inputs are supported for **development/testing only**. For production, use environment variables or wallet signing.
145
161
 
146
162
  ## Architecture
147
163
 
148
164
  ```
149
165
  dappily-agent-kit/
150
166
  ├── src/
151
- │ ├── index.ts # Public API surface
152
- │ ├── agent/index.ts # HederaAgentKit (client + operator)
153
- │ ├── actions/
154
- ├── index.ts # Registry + lookup helpers
155
- │ ├── get_balance.ts # GET_BALANCE
156
- ├── transfer.ts # HBAR_TRANSFER
157
- ├── create_token.ts # CREATE_TOKEN
158
- │ ├── associate_token.ts
159
- │ │ ├── transfer_token.ts
160
- │ │ ├── mint_token.ts
161
- │ │ ├── burn_token.ts
162
- │ │ ├── create_nft_collection.ts
163
- │ │ ├── mint_nft.ts
164
- │ │ ├── transfer_nft.ts
165
- │ │ └── burn_nft.ts
166
- │ └── types/action.ts # ActionResult, Action, etc.
167
+ │ ├── index.ts # Public API
168
+ │ ├── agent/ # HederaAgentKit
169
+ │ ├── actions/ # 15 built-in actions
170
+ │ ├── types/ # ActionResult types
171
+ └── forge/ # Self-Forging system
172
+ ├── actionSpec.ts # Spec schema (Zod, v4)
173
+ ├── generator.ts # Deterministic code generator
174
+ └── specs/ # 15 reference specs
167
175
  ├── examples/
168
- ├── balance.ts
169
- │ ├── fungible-lifecycle.ts
170
- │ └── nft-lifecycle.ts
171
- ├── dist/ # Built output (CJS + types)
172
- ├── package.json
173
- ├── tsconfig.build.json
174
- └── LICENSE
176
+ ├── dist/
177
+ └── package.json
175
178
  ```
176
179
 
177
180
  ## Roadmap
178
181
 
179
- - [ ] HCS (Hedera Consensus Service)topic create/submit
180
- - [ ] Mirror Node queries — token info, NFT metadata, transaction history
181
- - [ ] Wallet signing interface (replace private key inputs)
182
- - [ ] Smart contract deployment + invocation
183
- - [ ] Scheduled transactions
184
- - [ ] Multi-sig support
182
+ - [x] 15 actions across HTS, NFT, HCS all testnet-verified
183
+ - [x] Deterministic action generator (Forge)
184
+ - [x] 15 reference specs (v4 format)
185
+ - [ ] Sandbox runner (automated generate → compile → testnet)
186
+ - [ ] Prompt → Spec (LLM generates specs, generator does the rest)
187
+ - [ ] Mirror Node queries
188
+ - [ ] Framework adapters (Vercel AI, LangChain, MCP)
189
+ - [ ] Wallet signing interface
185
190
 
186
191
  ## License
187
192
 
@@ -0,0 +1,4 @@
1
+ import { Action } from "../types/action";
2
+ declare const hbarTransferAction: Action;
3
+ export default hbarTransferAction;
4
+ //# sourceMappingURL=_sandbox_hbar_transfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_sandbox_hbar_transfer.d.ts","sourceRoot":"","sources":["../../src/actions/_sandbox_hbar_transfer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAgB,MAAM,iBAAiB,CAAC;AAQvD,QAAA,MAAM,kBAAkB,EAAE,MA0DzB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const zod_1 = require("zod");
4
+ const sdk_1 = require("@hashgraph/sdk");
5
+ const hbarTransferAction = {
6
+ name: "HBAR_TRANSFER",
7
+ similes: ["send hbar", "pay hbar", "transfer hbar", "send money", "transfer funds", "tip hbar"],
8
+ description: "Send HBAR (native cryptocurrency) to another Hedera account.",
9
+ examples: [[]],
10
+ schema: zod_1.z.object({
11
+ to: zod_1.z.string().regex(/^\d+\.\d+\.\d+$/, "Invalid format").describe("The recipient's Hedera Account ID"),
12
+ amount: zod_1.z.number().min(0).describe("Amount of HBAR to send"),
13
+ memo: zod_1.z.string().max(100).optional().describe("Optional memo"),
14
+ }),
15
+ requiresConfirmation: true,
16
+ simulate: async (agent, input) => {
17
+ return {
18
+ summary: `Send HBAR (native cryptocurrency) to another Hedera account`,
19
+ estimatedFeeHbar: 0.0001,
20
+ warnings: [],
21
+ };
22
+ },
23
+ handler: async (agent, input) => {
24
+ try {
25
+ const tx = new sdk_1.TransferTransaction();
26
+ tx.addHbarTransfer(agent.accountId, new sdk_1.Hbar(input.amount).negated());
27
+ tx.addHbarTransfer(sdk_1.AccountId.fromString(input.to), new sdk_1.Hbar(input.amount));
28
+ if (input.memo) {
29
+ tx.setTransactionMemo(input.memo);
30
+ }
31
+ const response = await tx.execute(agent.client);
32
+ const receipt = await response.getReceipt(agent.client);
33
+ if (receipt.status !== sdk_1.Status.Success) {
34
+ return { ok: false, error: receipt.status.toString(), details: `HBAR_TRANSFER failed: ${receipt.status.toString()}` };
35
+ }
36
+ const txId = response.transactionId.toString();
37
+ return {
38
+ ok: true,
39
+ summary: "Send HBAR (native cryptocurrency) to another Hedera account",
40
+ txId,
41
+ receipt: { status: receipt.status.toString() },
42
+ data: {
43
+ from: agent.accountId.toString(),
44
+ to: input.to ?? null,
45
+ amount: input.amount ?? null,
46
+ memo: input.memo ?? null,
47
+ explorerUrl: agent.getExplorerUrl(txId),
48
+ },
49
+ };
50
+ }
51
+ catch (err) {
52
+ const message = err instanceof Error ? err.message : String(err);
53
+ const knownErrors = {
54
+ "INSUFFICIENT_PAYER_BALANCE": "Not enough HBAR.",
55
+ "INVALID_ACCOUNT_ID": "Recipient does not exist.",
56
+ "INVALID_SIGNATURE": "Invalid signature.",
57
+ };
58
+ const errorCode = Object.keys(knownErrors).find((c) => message.includes(c));
59
+ return { ok: false, error: errorCode || "HBAR_TRANSFER_FAILED", details: errorCode ? knownErrors[errorCode] : message };
60
+ }
61
+ },
62
+ };
63
+ exports.default = hbarTransferAction;
64
+ //# sourceMappingURL=_sandbox_hbar_transfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_sandbox_hbar_transfer.js","sourceRoot":"","sources":["../../src/actions/_sandbox_hbar_transfer.ts"],"names":[],"mappings":";;AAAA,6BAAwB;AAExB,wCAKwB;AAExB,MAAM,kBAAkB,GAAW;IACjC,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,CAAC,WAAW,EAAC,UAAU,EAAC,eAAe,EAAC,YAAY,EAAC,gBAAgB,EAAC,UAAU,CAAC;IAC1F,WAAW,EAAE,8DAA8D;IAC3E,QAAQ,EAAE,CAAC,EAAE,CAAC;IACd,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;QACf,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC,mCAAmC,CAAC;QACvG,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QAC5D,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC;KAC/D,CAAC;IACF,oBAAoB,EAAE,IAAI;IAC1B,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC/B,OAAO;YACL,OAAO,EAAE,6DAA6D;YACtE,gBAAgB,EAAE,MAAM;YACxB,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAyB,EAAE;QACrD,IAAI,CAAC;YACH,MAAM,EAAE,GAAG,IAAI,yBAAmB,EAAE,CAAC;YACrC,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,S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AAE,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;iBACxC;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,MAAM,WAAW,GAA2B;gBAC1C,4BAA4B,EAAE,kBAAkB;gBAChD,oBAAoB,EAAE,2BAA2B;gBACjD,mBAAmB,EAAE,oBAAoB;aAC1C,CAAC;YACF,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5E,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,IAAI,sBAAsB,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC1H,CAAC;IACH,CAAC;CACF,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Action } from "../types/action";
2
+ declare const createTopicAction: Action;
3
+ export default createTopicAction;
4
+ //# sourceMappingURL=create_topic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create_topic.d.ts","sourceRoot":"","sources":["../../src/actions/create_topic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAgB,MAAM,iBAAiB,CAAC;AAOvD,QAAA,MAAM,iBAAiB,EAAE,MAgJxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const zod_1 = require("zod");
4
+ const sdk_1 = require("@hashgraph/sdk");
5
+ const createTopicAction = {
6
+ name: "CREATE_TOPIC",
7
+ similes: [
8
+ "create topic",
9
+ "new topic",
10
+ "create channel",
11
+ "consensus topic",
12
+ "hcs topic",
13
+ "message topic",
14
+ ],
15
+ description: "Create a new topic on the Hedera Consensus Service (HCS). Topics act as message streams — any account (or only authorized ones if a submit key is set) can publish messages. The operator key is used as admin key by default.",
16
+ examples: [
17
+ [
18
+ {
19
+ input: {
20
+ memo: "dappily-agent-kit event log",
21
+ },
22
+ output: {
23
+ ok: true,
24
+ summary: "Created topic 0.0.77777",
25
+ txId: "0.0.12345@1700000000.000000000",
26
+ receipt: { status: "SUCCESS" },
27
+ data: {
28
+ topicId: "0.0.77777",
29
+ memo: "dappily-agent-kit event log",
30
+ hasAdminKey: true,
31
+ hasSubmitKey: false,
32
+ explorerUrl: "https://hashscan.io/testnet/transaction/...",
33
+ },
34
+ },
35
+ explanation: "Create an open topic (anyone can submit messages)",
36
+ },
37
+ ],
38
+ ],
39
+ schema: zod_1.z.object({
40
+ memo: zod_1.z
41
+ .string()
42
+ .max(100)
43
+ .optional()
44
+ .describe("Short description of the topic's purpose"),
45
+ requireSubmitKey: zod_1.z
46
+ .boolean()
47
+ .optional()
48
+ .default(false)
49
+ .describe("If true, only the operator (or provided key) can submit messages. Default: open to all."),
50
+ adminPrivateKey: zod_1.z
51
+ .string()
52
+ .optional()
53
+ .describe("⚠️ Admin key (only if different from operator key)"),
54
+ submitPrivateKey: zod_1.z
55
+ .string()
56
+ .optional()
57
+ .describe("⚠️ Submit key (only if different from operator key). Only used if requireSubmitKey is true."),
58
+ }),
59
+ requiresConfirmation: false,
60
+ simulate: async (_agent, input) => {
61
+ return {
62
+ summary: `Create HCS topic${input.memo ? `: "${input.memo}"` : ""}${input.requireSubmitKey ? " (restricted submit)" : " (open submit)"}`,
63
+ estimatedFeeHbar: 0.01,
64
+ warnings: [],
65
+ };
66
+ },
67
+ handler: async (agent, input) => {
68
+ try {
69
+ const adminKey = input.adminPrivateKey
70
+ ? sdk_1.PrivateKey.fromString(input.adminPrivateKey).publicKey
71
+ : agent.privateKey.publicKey;
72
+ const tx = new sdk_1.TopicCreateTransaction()
73
+ .setAdminKey(adminKey);
74
+ if (input.requireSubmitKey) {
75
+ const submitKey = input.submitPrivateKey
76
+ ? sdk_1.PrivateKey.fromString(input.submitPrivateKey).publicKey
77
+ : agent.privateKey.publicKey;
78
+ tx.setSubmitKey(submitKey);
79
+ }
80
+ if (input.memo) {
81
+ tx.setTopicMemo(input.memo);
82
+ }
83
+ const frozenTx = await tx.freezeWith(agent.client);
84
+ if (input.adminPrivateKey) {
85
+ await frozenTx.sign(sdk_1.PrivateKey.fromString(input.adminPrivateKey));
86
+ }
87
+ const response = await frozenTx.execute(agent.client);
88
+ const receipt = await response.getReceipt(agent.client);
89
+ if (receipt.status !== sdk_1.Status.Success) {
90
+ return {
91
+ ok: false,
92
+ error: receipt.status.toString(),
93
+ details: `Topic creation failed with status: ${receipt.status.toString()}`,
94
+ };
95
+ }
96
+ const topicId = receipt.topicId;
97
+ if (!topicId) {
98
+ return {
99
+ ok: false,
100
+ error: "NO_TOPIC_ID",
101
+ details: "Transaction succeeded but no topic ID was returned.",
102
+ };
103
+ }
104
+ const txId = response.transactionId.toString();
105
+ return {
106
+ ok: true,
107
+ summary: `Created topic ${topicId.toString()}`,
108
+ txId,
109
+ receipt: { status: receipt.status.toString() },
110
+ data: {
111
+ topicId: topicId.toString(),
112
+ memo: input.memo || null,
113
+ hasAdminKey: true,
114
+ hasSubmitKey: !!input.requireSubmitKey,
115
+ explorerUrl: agent.getExplorerUrl(txId),
116
+ },
117
+ };
118
+ }
119
+ catch (err) {
120
+ const message = err instanceof Error ? err.message : String(err);
121
+ const knownErrors = {
122
+ INVALID_SIGNATURE: "Transaction signature is invalid. Check your keys.",
123
+ INSUFFICIENT_PAYER_BALANCE: "Not enough HBAR to cover the transaction fee.",
124
+ AUTORENEW_DURATION_NOT_IN_RANGE: "The auto-renew duration is outside the allowed range.",
125
+ };
126
+ const errorCode = Object.keys(knownErrors).find((code) => message.includes(code));
127
+ return {
128
+ ok: false,
129
+ error: errorCode || "CREATE_TOPIC_FAILED",
130
+ details: errorCode ? knownErrors[errorCode] : message,
131
+ };
132
+ }
133
+ },
134
+ };
135
+ exports.default = createTopicAction;
136
+ //# sourceMappingURL=create_topic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create_topic.js","sourceRoot":"","sources":["../../src/actions/create_topic.ts"],"names":[],"mappings":";;AAAA,6BAAwB;AAExB,wCAIwB;AAExB,MAAM,iBAAiB,GAAW;IAChC,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE;QACP,cAAc;QACd,WAAW;QACX,gBAAgB;QAChB,iBAAiB;QACjB,WAAW;QACX,eAAe;KAChB;IACD,WAAW,EACT,gOAAgO;IAClO,QAAQ,EAAE;QACR;YACE;gBACE,KAAK,EAAE;oBACL,IAAI,EAAE,6BAA6B;iBACpC;gBACD,MAAM,EAAE;oBACN,EAAE,EAAE,IAAI;oBACR,OAAO,EAAE,yBAAyB;oBAClC,IAAI,EAAE,gCAAgC;oBACtC,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;oBAC9B,IAAI,EAAE;wBACJ,OAAO,EAAE,WAAW;wBACpB,IAAI,EAAE,6BAA6B;wBACnC,WAAW,EAAE,IAAI;wBACjB,YAAY,EAAE,KAAK;wBACnB,WAAW,EAAE,6CAA6C;qBAC3D;iBACF;gBACD,WAAW,EAAE,mDAAmD;aACjE;SACF;KACF;IACD,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;QACf,IAAI,EAAE,OAAC;aACJ,MAAM,EAAE;aACR,GAAG,CAAC,GAAG,CAAC;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,0CAA0C,CAAC;QACvD,gBAAgB,EAAE,OAAC;aAChB,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,OAAO,CAAC,KAAK,CAAC;aACd,QAAQ,CAAC,yFAAyF,CAAC;QACtG,eAAe,EAAE,OAAC;aACf,MAAM,EAAE;a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,EAAE;oBAC3B,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI;oBACxB,WAAW,EAAE,IAAI;oBACjB,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB;oBACtC,WAAW,EAAE,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;iBACxC;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAEjE,MAAM,WAAW,GAA2B;gBAC1C,iBAAiB,EAAE,oDAAoD;gBACvE,0BAA0B,EAAE,+CAA+C;gBAC3E,+BAA+B,EAAE,uDAAuD;aACzF,CAAC;YAEF,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CACvD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CACvB,CAAC;YAEF,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,SAAS,IAAI,qBAAqB;gBACzC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO;aACtD,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC;AAEF,kBAAe,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Action } from "../types/action";
2
+ declare const deleteTopicAction: Action;
3
+ export default deleteTopicAction;
4
+ //# sourceMappingURL=delete_topic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete_topic.d.ts","sourceRoot":"","sources":["../../src/actions/delete_topic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAgB,MAAM,iBAAiB,CAAC;AAOvD,QAAA,MAAM,iBAAiB,EAAE,MA0GxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}