@origintrail-official/dkg-adapter-openclaw 0.0.1-dev.1773506972.23bf9c0

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2018 OriginTrail
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,341 @@
1
+ # DKG V9 OpenClaw Adapter
2
+
3
+ `@origintrail-official/dkg-adapter-openclaw` connects an existing OpenClaw agent to a DKG V9 node.
4
+
5
+ The adapter is a thin HTTP client — it does **not** run its own DKG node. A single DKG daemon process (`dkg start`) owns the node, triple store, P2P networking, and Node UI. The adapter registers tools and integration modules that route through the daemon's HTTP API.
6
+
7
+ This gives your OpenClaw agent:
8
+
9
+ - **Verifiable memory** — DKG-backed memory recall/import plus file-watcher sync for `MEMORY.md` and `memory/*.md`
10
+ - **Agent Hub chat** — a local chat surface in the DKG Node UI via the OpenClaw bridge
11
+ - **DKG tools** — `dkg_status`, `dkg_query`, `dkg_publish`, `dkg_find_agents`, `dkg_send_message`, `dkg_read_messages`, `dkg_invoke_skill`, `dkg_list_paranets`
12
+ - **OriginTrail Game** — 10 game tools for discovering, joining, and autonomously playing the cooperative multiplayer game on the DKG
13
+
14
+ ## Architecture
15
+
16
+ ```
17
+ ┌──────────────────────────────┐ HTTP ┌──────────────────────────┐
18
+ │ OpenClaw Gateway │ ──────────────► │ DKG Daemon (dkg start) │
19
+ │ ┌──────────────────────┐ │ localhost:9200 │ ┌────────────────────┐ │
20
+ │ │ adapter-openclaw │ │ │ │ DKGAgent │ │
21
+ │ │ ┌─ DkgDaemonClient ─┤────┤───────────────►───│ │ Triple Store │ │
22
+ │ │ │ (thin HTTP) │ │ │ │ P2P / libp2p │ │
23
+ │ │ └───────────────────┘ │ │ │ Node UI │ │
24
+ │ │ DkgChannelPlugin │ │ └────────────────────┘ │
25
+ │ │ DkgGamePlugin │ └──────────────────────────┘
26
+ │ │ DkgMemoryPlugin │
27
+ │ │ WriteCapture │
28
+ │ └──────────────────────┘ │
29
+ └──────────────────────────────┘
30
+ ```
31
+
32
+ One process. One node on the network.
33
+
34
+ ## Config Files
35
+
36
+ | File | Owner | Purpose |
37
+ | --- | --- | --- |
38
+ | `~/.dkg/config.json` | Agent (during setup) | THE node config: name, relay, chain, auth |
39
+ | `WORKSPACE_DIR/config.json` | Agent (during setup) | Adapter feature flags: `daemonUrl`, `memory`, `channel`, `game` |
40
+ | `~/.openclaw/openclaw.json` | Agent (merge) | Plugin load path + entry |
41
+
42
+ Auto-generated on first `dkg start`:
43
+ - `~/.dkg/wallets.json` — 3 operational wallets (address + private key)
44
+ - `~/.dkg/auth.token` — API bearer token
45
+ - `~/.dkg/agent-key.bin` — Ed25519 identity key
46
+
47
+ ## Setup
48
+
49
+ ### 1. Clone and build this repo
50
+
51
+ ```bash
52
+ git clone https://github.com/OriginTrail/dkg-v9.git
53
+ cd dkg-v9
54
+ pnpm install
55
+ pnpm build
56
+ ```
57
+
58
+ Use a stable checkout path because OpenClaw loads the adapter directly from this path.
59
+
60
+ ### 2. Write `~/.dkg/config.json`
61
+
62
+ Read `network/testnet.json` from the cloned repo for relay, chain, and paranet defaults. Read the agent's name from `WORKSPACE_DIR/IDENTITY.md` (e.g. `~/.openclaw/workspace/IDENTITY.md` for the default workspace).
63
+
64
+ Write `~/.dkg/config.json` directly (skip `dkg init` — it just prompts for the same values):
65
+
66
+ ```json
67
+ {
68
+ "name": "<agent's OpenClaw name from IDENTITY.md>",
69
+ "apiPort": 9200,
70
+ "nodeRole": "edge",
71
+ "relay": "/ip4/167.71.33.105/tcp/9090/p2p/12D3KooWEpSGSVRZx3DqBijai85PLitzWjMzyFVMP4qeqSBUinxj",
72
+ "paranets": ["testing", "origin-trail-game"],
73
+ "chain": {
74
+ "type": "evm",
75
+ "rpcUrl": "https://sepolia.base.org",
76
+ "hubAddress": "0xC056e67Da4F51377Ad1B01f50F655fFdcCD809F6",
77
+ "chainId": "base:84532"
78
+ },
79
+ "auth": { "enabled": true },
80
+ "openclawAdapter": true
81
+ }
82
+ ```
83
+
84
+ ### 3. Start the DKG daemon
85
+
86
+ ```bash
87
+ pnpm dkg start
88
+ ```
89
+
90
+ On first start, the daemon auto-generates:
91
+ - `~/.dkg/wallets.json` — 3 operational wallets
92
+ - `~/.dkg/auth.token` — API bearer token
93
+ - `~/.dkg/agent-key.bin` — Ed25519 identity key
94
+
95
+ **Present wallet addresses to the user.** Read `~/.dkg/wallets.json` and show the public addresses so the user can fund them with testnet ETH + TRAC for on-chain operations. Remind the user to back up `~/.dkg/wallets.json` securely — never paste private keys into chat, logs, or screenshots.
96
+
97
+ **Fund the wallets.** Use the [V9 Testnet Faucet](../../docs/setup/TESTNET_FAUCET.md) to get both Base Sepolia ETH and TRAC in one call:
98
+
99
+ ```bash
100
+ curl -X POST "https://euphoria.origin-trail.network/faucet/fund" \
101
+ -H "Content-Type: application/json" \
102
+ -H "Idempotency-Key: $(uuidgen || date +%s)" \
103
+ --data-raw '{
104
+ "mode": "v9_base_sepolia",
105
+ "wallets": ["0xWALLET1", "0xWALLET2", "0xWALLET3"]
106
+ }'
107
+ ```
108
+
109
+ Replace the wallet addresses with the ones from `wallets.json`. Each wallet receives ETH (for gas) and TRAC (for on-chain operations). See the [full faucet reference](../../docs/setup/TESTNET_FAUCET.md) for rate limits, dry-run, and error handling.
110
+
111
+ What the running daemon provides:
112
+ - Local API at `http://127.0.0.1:9200`
113
+ - Node UI at `http://127.0.0.1:9200/ui`
114
+ - OpenClaw bridge endpoints under `/api/openclaw-channel/*`
115
+
116
+ ### 4. Enable the adapter in OpenClaw
117
+
118
+ Read `~/.openclaw/openclaw.json` and discover `agents.defaults.workspace`.
119
+
120
+ Merge three things into the existing `plugins` block:
121
+
122
+ 1. Add `"adapter-openclaw"` to `plugins.allow`
123
+ 2. Add the adapter path to `plugins.load.paths`
124
+ 3. Add the entry to `plugins.entries`
125
+
126
+ ```json
127
+ {
128
+ "plugins": {
129
+ "allow": ["adapter-openclaw"],
130
+ "load": {
131
+ "paths": [
132
+ "~/dkg-v9/packages/adapter-openclaw"
133
+ ]
134
+ },
135
+ "entries": {
136
+ "adapter-openclaw": {
137
+ "enabled": true
138
+ }
139
+ }
140
+ }
141
+ }
142
+ ```
143
+
144
+ Rules:
145
+ - The plugin entry key must be `adapter-openclaw` (matches `openclaw.plugin.json` `id`).
146
+ - `adapter-openclaw` must appear in `plugins.allow` or the gateway will not load it.
147
+ - Do not put DKG config in `plugins.entries` — that goes in the workspace `config.json`.
148
+ - Merge into existing plugin config — do not replace the whole `plugins` block.
149
+
150
+ ### 5. Configure the adapter in the workspace
151
+
152
+ Create or update `WORKSPACE_DIR/config.json` with a `"dkg-node"` block:
153
+
154
+ ```json
155
+ {
156
+ "dkg-node": {
157
+ "daemonUrl": "http://127.0.0.1:9200",
158
+ "memory": { "enabled": true },
159
+ "channel": { "enabled": true },
160
+ "game": { "enabled": true }
161
+ }
162
+ }
163
+ ```
164
+
165
+ Notes:
166
+ - `daemonUrl` defaults to `http://127.0.0.1:9200`, but set it explicitly for clarity.
167
+ - `memory.enabled: true` enables `dkg_memory_search`, `dkg_memory_import`, first-run backlog import, and file watching for `WORKSPACE_DIR/MEMORY.md` and `WORKSPACE_DIR/memory/**/*.md`.
168
+ - `channel.enabled: true` enables the DKG UI ↔ OpenClaw bridge used by Agent Hub.
169
+ - `game.enabled: true` enables the 10 OriginTrail Game tools. Autopilot requires `channel.enabled: true` for agent consultation; without it, only manual `game_vote` is available.
170
+
171
+ ### 6. Copy the skill files into the workspace
172
+
173
+ The package ships two skill files that teach the agent how to use DKG tools and game tools:
174
+
175
+ ```bash
176
+ mkdir -p WORKSPACE_DIR/skills/dkg-node WORKSPACE_DIR/skills/origin-trail-game
177
+ cp ~/dkg-v9/packages/adapter-openclaw/skills/dkg-node/SKILL.md WORKSPACE_DIR/skills/dkg-node/SKILL.md
178
+ cp ~/dkg-v9/packages/adapter-openclaw/skills/origin-trail-game/SKILL.md WORKSPACE_DIR/skills/origin-trail-game/SKILL.md
179
+ ```
180
+
181
+ - `dkg-node/SKILL.md` — teaches memory, publishing, querying, and agent discovery tools
182
+ - `origin-trail-game/SKILL.md` — teaches game mechanics, actions, strategy, and autopilot usage
183
+
184
+ ### 7. Restart the OpenClaw gateway
185
+
186
+ Restart the OpenClaw gateway so it reloads the plugin and workspace config.
187
+
188
+ ## Verification
189
+
190
+ A setup is healthy when all of the following are true.
191
+
192
+ ### Daemon and tools
193
+
194
+ Ask the OpenClaw agent to call `dkg_status`.
195
+
196
+ Expected: the daemon's peer ID, connected peers, multiaddrs, and wallet addresses.
197
+
198
+ ### Node UI and Agent Hub bridge
199
+
200
+ Open `http://127.0.0.1:9200/ui`.
201
+
202
+ Then open Agent Hub and use the OpenClaw tab.
203
+
204
+ Expected:
205
+ - The tab reports the local bridge as healthy
206
+ - Sending a message produces a reply from the OpenClaw agent
207
+ - Chat appears in the DKG graph-backed history
208
+
209
+ ### Memory integration
210
+
211
+ If `memory.enabled` is on:
212
+ - Ask the agent to call `dkg_memory_import` with some text
213
+ - Ask the agent to call `dkg_memory_search` to find it
214
+ - Or edit `WORKSPACE_DIR/MEMORY.md` and wait for the file-watcher to pick it up
215
+
216
+ Expected: imported memories become searchable in the daemon-backed `agent-memory` graph.
217
+
218
+ ## Tools
219
+
220
+ ### Always available (8 tools)
221
+
222
+ | Tool | Purpose |
223
+ | --- | --- |
224
+ | `dkg_status` | Show DKG node status: peer ID, connected peers, multiaddrs, wallet addresses |
225
+ | `dkg_list_paranets` | List paranets known to the node |
226
+ | `dkg_publish` | Publish N-Quads triples to a paranet |
227
+ | `dkg_query` | Run a local SPARQL query |
228
+ | `dkg_find_agents` | Discover agents on the DKG network (filter by framework or skill type) |
229
+ | `dkg_send_message` | Send an encrypted P2P message to another DKG agent |
230
+ | `dkg_read_messages` | Read P2P messages from other DKG agents (filter by peer, limit, since) |
231
+ | `dkg_invoke_skill` | Invoke a remote agent's skill over the DKG network |
232
+
233
+ ### When `game.enabled` is true (10 additional tools)
234
+
235
+ | Tool | Purpose |
236
+ | --- | --- |
237
+ | `game_lobby` | List joinable and current swarms |
238
+ | `game_join` | Join an existing swarm |
239
+ | `game_create` | Create a new swarm (you become leader) |
240
+ | `game_start` | Launch the expedition (leader only) |
241
+ | `game_status` | Check game state, resources, party health, autopilot status |
242
+ | `game_vote` | Cast a manual vote for the current turn |
243
+ | `game_locations` | Get all 18 trail locations with details |
244
+ | `game_leaderboard` | Scores from completed games |
245
+ | `game_autopilot_start` | Start autonomous play (requires `channel.enabled`) |
246
+ | `game_autopilot_stop` | Stop autonomous play |
247
+
248
+ ### When `memory.enabled` is true (2 additional tools)
249
+
250
+ | Tool | Purpose |
251
+ | --- | --- |
252
+ | `dkg_memory_search` | Search the daemon-backed `agent-memory` graph |
253
+ | `dkg_memory_import` | Import memory text into the daemon-backed graph |
254
+
255
+ ## Adapter Config Reference
256
+
257
+ These keys live under `"dkg-node"` in `WORKSPACE_DIR/config.json`.
258
+
259
+ | Key | Default | Purpose |
260
+ | --- | --- | --- |
261
+ | `daemonUrl` | `http://127.0.0.1:9200` | DKG daemon HTTP URL |
262
+ | `memory.enabled` | `false` | Enable `dkg_memory_*` tools, file-watcher sync, and backlog import |
263
+ | `memory.memoryDir` | `WORKSPACE_DIR/memory` | Override the watched memory directory |
264
+ | `memory.watchDebounceMs` | `1500` | File watcher debounce interval (ms) |
265
+ | `channel.enabled` | `false` | Enable the Agent Hub ↔ OpenClaw bridge |
266
+ | `channel.port` | `9201` | Standalone bridge port (when gateway route registration unavailable) |
267
+ | `game.enabled` | `false` | Enable the 10 OriginTrail Game tools |
268
+ | `game.pollIntervalMs` | `2000` | Autopilot polling interval (ms) |
269
+ | `game.decisionTimeoutMs` | `15000` | Agent consultation timeout per turn (ms) — falls back to safe default |
270
+
271
+ ## Agent Runbook
272
+
273
+ If another agent is performing the setup, these are the exact steps:
274
+
275
+ 1. Read `~/.openclaw/openclaw.json` and discover `agents.defaults.workspace`.
276
+ 2. Clone this repo to a stable path such as `~/dkg-v9`, then `pnpm install && pnpm build`.
277
+ 3. Read `network/testnet.json` for relay, chain, and paranet defaults.
278
+ 4. Read the agent name from `WORKSPACE_DIR/IDENTITY.md`.
279
+ 5. Write `~/.dkg/config.json` programmatically using the agent name and network defaults. Include `"openclawAdapter": true`.
280
+ 6. Run `pnpm dkg start` — wallets, auth token, and identity key are auto-generated on first start.
281
+ 7. Read `~/.dkg/wallets.json` and show the public addresses so the user can fund them with testnet ETH + TRAC for on-chain operations. Remind the user to back up `~/.dkg/wallets.json` securely — never paste private keys into chat, logs, or screenshots. Fund the wallets by calling `POST https://euphoria.origin-trail.network/faucet/fund` with `{"mode": "v9_base_sepolia", "wallets": ["0xADDR1", "0xADDR2", "0xADDR3"]}`. Include an `Idempotency-Key` header. See [Testnet Faucet](../../docs/setup/TESTNET_FAUCET.md) for details.
282
+ 8. Merge into `~/.openclaw/openclaw.json`: add `"adapter-openclaw"` to `plugins.allow`, add the adapter path to `plugins.load.paths`, and add `adapter-openclaw` to `plugins.entries`.
283
+ 9. Write the `"dkg-node"` block into `WORKSPACE_DIR/config.json` with `daemonUrl`, `memory.enabled`, `channel.enabled`, and `game.enabled`.
284
+ 10. Copy `skills/dkg-node/SKILL.md` into `WORKSPACE_DIR/skills/dkg-node/SKILL.md` and `skills/origin-trail-game/SKILL.md` into `WORKSPACE_DIR/skills/origin-trail-game/SKILL.md`.
285
+ 11. Restart the OpenClaw gateway.
286
+ 12. Verify:
287
+ - `dkg_status` returns daemon info + wallet addresses
288
+ - `http://127.0.0.1:9200/ui` loads
289
+ - Agent Hub → OpenClaw bridge is healthy
290
+ 13. Report: `Setup complete, DKG V9 UI accessible at http://127.0.0.1:9200/ui`
291
+
292
+ Replace the URL if the daemon binds to a different host or port.
293
+
294
+ ## Troubleshooting
295
+
296
+ ### `dkg_status` returns "daemon is not reachable"
297
+
298
+ The daemon is not running or not reachable at the configured URL.
299
+
300
+ Check:
301
+ - `dkg start` was run and the process is still alive
302
+ - `daemonUrl` in `WORKSPACE_DIR/config.json` matches the daemon's `apiPort`
303
+ - No firewall blocking `127.0.0.1:9200`
304
+
305
+ ### Node UI works, but Agent Hub → OpenClaw is offline
306
+
307
+ The daemon is up but the OpenClaw bridge is not reachable.
308
+
309
+ Check:
310
+ - `channel.enabled` is `true` in `WORKSPACE_DIR/config.json`
311
+ - The OpenClaw gateway was restarted after config changes
312
+ - The daemon is using the current token from `~/.dkg/auth.token`
313
+ - If the gateway does not expose adapter HTTP routes, the standalone bridge port must be reachable on `127.0.0.1`
314
+
315
+ ### `dkg_memory_search` or `dkg_memory_import` is missing
316
+
317
+ `memory.enabled` is off, or the plugin did not reload after config changes.
318
+
319
+ ### Memory tools exist but return nothing
320
+
321
+ The daemon is reachable, but the `agent-memory` graph has no content yet.
322
+
323
+ Try:
324
+ - `dkg_memory_import` with some text
325
+ - Editing `WORKSPACE_DIR/MEMORY.md`
326
+ - Adding a Markdown file under `WORKSPACE_DIR/memory/`
327
+
328
+ ### Advanced daemon routing
329
+
330
+ For non-default layouts, the daemon supports explicit OpenClaw bridge hints in `~/.dkg/config.json`:
331
+
332
+ ```json
333
+ {
334
+ "openclawChannel": {
335
+ "bridgeUrl": "http://127.0.0.1:9201",
336
+ "gatewayUrl": "http://127.0.0.1:3000/api/dkg-channel"
337
+ }
338
+ }
339
+ ```
340
+
341
+ Use this only if the daemon cannot autodetect the local bridge/gateway path.
@@ -0,0 +1,94 @@
1
+ /**
2
+ * DkgChannelPlugin — Spike A: DKG UI ↔ OpenClaw channel bridge.
3
+ *
4
+ * Makes the DKG Node UI a first-class OpenClaw channel. Messages sent
5
+ * through the Agent Hub chat go through this channel into the OpenClaw
6
+ * gateway's session system, meaning they share the same transcript and
7
+ * context as messages from Telegram, WhatsApp, or any other channel
8
+ * (when `dmScope: "main"`).
9
+ *
10
+ * Transport: The DKG daemon exposes `/api/openclaw-channel/send` for
11
+ * the frontend. The daemon forwards the message to this plugin via
12
+ * a standalone HTTP server on a dedicated port (bridge mode).
13
+ *
14
+ * Message routing uses OpenClaw's plugin-sdk `dispatchInboundReplyWithBase`
15
+ * helper — the same pathway used by built-in channels (Telegram, Discord,
16
+ * etc.). This ensures the message enters the agent's session system with
17
+ * full context continuity.
18
+ */
19
+ import type { ChannelOutboundReply, DkgOpenClawConfig, OpenClawPluginApi } from './types.js';
20
+ import type { DkgDaemonClient } from './dkg-client.js';
21
+ export declare const CHANNEL_NAME = "dkg-ui";
22
+ export declare class DkgChannelPlugin {
23
+ private readonly config;
24
+ private readonly client;
25
+ private api;
26
+ /** OpenClaw runtime — provides channel routing, session, and reply subsystems. */
27
+ private runtime;
28
+ /** Full OpenClawConfig — needed for agent dispatch. */
29
+ private cfg;
30
+ /** Plugin-sdk helpers — lazily loaded at first dispatch. */
31
+ private sdk;
32
+ /** True after the first loadSdk() attempt — prevents re-trying and re-logging every turn. */
33
+ private sdkLoaded;
34
+ private server;
35
+ private serverStart;
36
+ private readonly pendingRequests;
37
+ private readonly port;
38
+ private useGatewayRoute;
39
+ private inFlight;
40
+ private readonly maxInFlight;
41
+ constructor(config: NonNullable<DkgOpenClawConfig['channel']>, client: DkgDaemonClient);
42
+ register(api: OpenClawPluginApi): void;
43
+ start(): Promise<void>;
44
+ stop(): Promise<void>;
45
+ private loadSdk;
46
+ private buildRegisteredChannelPlugin;
47
+ private resolveRegisteredAccount;
48
+ private buildStreamingReplyOptions;
49
+ /**
50
+ * Process an inbound message from the DKG UI.
51
+ * Routes through the OpenClaw session system and returns the agent reply.
52
+ */
53
+ processInbound(text: string, correlationId: string, identity: string): Promise<ChannelOutboundReply>;
54
+ /**
55
+ * Dispatch an inbound message using OpenClaw's plugin-sdk dispatch system.
56
+ * This is the same pathway used by Telegram, Discord, and other built-in channels.
57
+ */
58
+ private dispatchViaPluginSdk;
59
+ private dispatchWithSdk;
60
+ private dispatchWithRuntime;
61
+ /**
62
+ * Stream variant of processInbound. Yields events as the agent produces them.
63
+ * The caller is responsible for writing SSE frames and calling persistTurn after.
64
+ */
65
+ processInboundStream(text: string, correlationId: string, identity: string): AsyncGenerator<{
66
+ type: 'text_delta';
67
+ delta: string;
68
+ } | {
69
+ type: 'final';
70
+ text: string;
71
+ correlationId: string;
72
+ }>;
73
+ private handleOutboundReply;
74
+ private dispatchRuntimeReply;
75
+ private buildSdkCore;
76
+ private recordRuntimeInboundSession;
77
+ private handleUnexpectedHttpError;
78
+ private handleUnexpectedGatewayError;
79
+ /**
80
+ * Persist a chat turn to the DKG agent-memory graph.
81
+ * Fire-and-forget — errors are logged but don't affect the reply.
82
+ */
83
+ private persistTurn;
84
+ private handleHttpRequest;
85
+ private handleInboundHttp;
86
+ /** SSE streaming handler — yields events as the agent produces them. */
87
+ private handleInboundStreamHttp;
88
+ /** Handler for api.registerHttpRoute() — same logic, different req/res shape. */
89
+ private handleGatewayRoute;
90
+ private authorizeBridgeRequest;
91
+ get bridgePort(): number;
92
+ get isUsingGatewayRoute(): boolean;
93
+ }
94
+ //# sourceMappingURL=DkgChannelPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DkgChannelPlugin.d.ts","sourceRoot":"","sources":["../src/DkgChannelPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,eAAO,MAAM,YAAY,WAAW,CAAC;AAerC,qBAAa,gBAAgB;IAmBzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAnBzB,OAAO,CAAC,GAAG,CAAkC;IAC7C,kFAAkF;IAClF,OAAO,CAAC,OAAO,CAAa;IAC5B,uDAAuD;IACvD,OAAO,CAAC,GAAG,CAAa;IACxB,4DAA4D;IAC5D,OAAO,CAAC,GAAG,CAAa;IACxB,6FAA6F;IAC7F,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqC;IACrE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAK;gBAGd,MAAM,EAAE,WAAW,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,EACjD,MAAM,EAAE,eAAe;IAS1C,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI;IA2EhC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmCtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB3B,OAAO,CAAC,OAAO;IAkDf,OAAO,CAAC,4BAA4B;IAoCpC,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,0BAA0B;IAUlC;;;OAGG;IACG,cAAc,CAClB,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,oBAAoB,CAAC;IA8ChC;;;OAGG;YACW,oBAAoB;IAkFlC,OAAO,CAAC,eAAe;IAmDvB,OAAO,CAAC,mBAAmB;IAsD3B;;;OAGG;IACI,oBAAoB,CACzB,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf,cAAc,CAAC;QAAE,IAAI,EAAE,YAAY,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;YAyInG,mBAAmB;IAgBjC,OAAO,CAAC,oBAAoB;IA2B5B,OAAO,CAAC,YAAY;YAwBN,2BAA2B;IA4BzC,OAAO,CAAC,yBAAyB;IAWjC,OAAO,CAAC,4BAA4B;IAUpC;;;OAGG;YACW,WAAW;YAwBX,iBAAiB;YA4BjB,iBAAiB;IAkD/B,wEAAwE;YAC1D,uBAAuB;IA+DrC,iFAAiF;YACnE,kBAAkB;IAoBhC,OAAO,CAAC,sBAAsB;IAuB9B,IAAI,UAAU,IAAI,MAAM,CAGvB;IAED,IAAI,mBAAmB,IAAI,OAAO,CAEjC;CACF"}