wattetheria 0.1.6 → 0.1.7

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 CHANGED
@@ -98,7 +98,7 @@ Read the diagram in layers:
98
98
 
99
99
  ### Operator Apps
100
100
 
101
- - `wattetheria-client-cli`
101
+ - `wattetheria` CLI
102
102
  - bootstrap and lifecycle commands: `init`, `up`, `doctor`, `upgrade-check`
103
103
  - policy, governance, MCP, brain, data, oracle, night-shift, and summary posting commands
104
104
  - cross-platform install and package scripts in `scripts/`
@@ -196,6 +196,9 @@ Read the diagram in layers:
196
196
  - Authenticated local HTTP API and WebSocket stream
197
197
  - Bearer token auth
198
198
  - Request rate limiting
199
+ - Local MCP endpoint at `POST /mcp` for attached agent runtimes; its tool catalog mirrors the
200
+ `.agent-participation/manifest.json` endpoint surface and dispatches calls through the existing
201
+ authenticated control-plane routes.
199
202
  - Append-only control-plane audit log
200
203
  - Core endpoints for health, state, events, exports, audit, night shift, autonomy, and action execution
201
204
  - Node-local client DTO endpoints:
@@ -209,7 +212,7 @@ Read the diagram in layers:
209
212
  - `/v1/client/leaderboard`
210
213
  - Public signed export endpoint:
211
214
  - `/v1/client/export` returns a signed public snapshot for local inspection
212
- - `wattetheria-gateway` ingests snapshots via wattswarm; pull data from wattetheria
215
+ - `wattetheria-gateway` can ingest snapshots either by pulling `/v1/client/export` or by receiving node pushes when the kernel is started with one or more `--gateway-url` values
213
216
  - social snapshot arrays currently include `friend_relationships`, `pending_friend_requests`, `public_blocks`, `dm_threads`, and `dm_messages`
214
217
  - additive swarm bridge views now include `swarm_task_activity`
215
218
  - Civilization endpoints for profile, metrics, emergencies, briefing, world zones/events, and mission lifecycle
@@ -673,9 +676,21 @@ WATTETHERIA_BRAIN_PROVIDER_KIND=openai-compatible
673
676
  WATTETHERIA_BRAIN_BASE_URL=http://host.docker.internal:18789/v1
674
677
  WATTETHERIA_BRAIN_MODEL=openclaw
675
678
  WATTETHERIA_BRAIN_API_KEY_ENV=OPENCLAW_API_KEY
679
+ WATTETHERIA_GATEWAY_URLS=http://gateway.example.com:8080
676
680
  OPENCLAW_API_KEY=replace-me
677
681
  ```
678
682
 
683
+ `docker-compose.release.yml` also mounts `${WATTSWARM_HOST_STATE_DIR}/startup_config.json` into the
684
+ kernel container. If `WATTETHERIA_GATEWAY_URLS` is unset, the kernel now falls back to `gateway_urls`
685
+ saved by the Wattswarm startup UI in that file.
686
+
687
+ When Wattetheria registers `core-agent` with Wattswarm, it keeps the brain/runtime
688
+ `base_url` pointed at the OpenAI-compatible gateway for `/execute` work and exposes a
689
+ separate local `POST /agent-events` adapter on the Wattetheria control-plane endpoint
690
+ for structured agent-event callbacks. This keeps local-mode task execution and
691
+ topic/consensus flows on the existing runtime path while letting agent events reach
692
+ OpenClaw/NanoClaw-style runtimes through Wattetheria's adapter.
693
+
679
694
  When `servicenet_base_url` is configured, the control plane exposes local proxy routes for external agent discovery and execution:
680
695
 
681
696
  - `GET /v1/servicenet/agents`
@@ -683,12 +698,134 @@ When `servicenet_base_url` is configured, the control plane exposes local proxy
683
698
  - `POST /v1/servicenet/agents/:agent_id/invoke`
684
699
  - `POST /v1/servicenet/agents/:agent_id/tasks/:task_id/get`
685
700
 
701
+ `POST /v1/servicenet/agents/:agent_id/invoke` now accepts an optional `settlement` object so a
702
+ Wattetheria-hosted agent can carry its selected payment rail and bound payment account reference
703
+ into downstream A2A/service execution. Current first-party settlement shape is:
704
+
705
+ ```json
706
+ {
707
+ "message": "buy the selected itinerary",
708
+ "input": {
709
+ "offer_id": "offer-123"
710
+ },
711
+ "settlement": {
712
+ "layer": "web3",
713
+ "rail": "x402",
714
+ "request": {
715
+ "protocol": "x402",
716
+ "payment_account_ref": "payment-account-123",
717
+ "network": "base-sepolia"
718
+ }
719
+ }
720
+ }
721
+ ```
722
+
723
+ For local payment account setup, the CLI now exposes:
724
+
725
+ ```bash
726
+ cargo run -p wattetheria-client-cli -- wallet --data-dir .wattetheria create-payment-account --label settlement --network base-sepolia
727
+ cargo run -p wattetheria-client-cli -- wallet --data-dir .wattetheria import-payment-account --private-key-hex <hex> --label settlement --network base-sepolia
728
+ cargo run -p wattetheria-client-cli -- wallet --data-dir .wattetheria watch-payment-account --address 0xabc... --label inbound --network base-sepolia
729
+ cargo run -p wattetheria-client-cli -- wallet --data-dir .wattetheria list-payment-accounts
730
+ cargo run -p wattetheria-client-cli -- wallet --data-dir .wattetheria bind-payment-account --account-id <account-id>
731
+ cargo run -p wattetheria-client-cli -- wallet --data-dir .wattetheria active-payment-account
732
+ ```
733
+
734
+ The Wattetheria agent-side control plane also exposes payment session endpoints. The payment
735
+ state machine lives on the agent side, while propagation continues to use the wattswarm-backed
736
+ swarm bridge peer direct message transport. These routes persist a local payment ledger, send
737
+ payment session messages to the counterpart agent over wattswarm, and reconcile inbound payment
738
+ messages from the swarm bridge:
739
+
740
+ - `GET /v1/payments/agent-payments`
741
+ - `GET /v1/payments/agent-payments/:payment_id`
742
+ - `POST /v1/payments/agent-payments/propose`
743
+ - `POST /v1/payments/agent-payments/:payment_id/authorize`
744
+ - `POST /v1/payments/agent-payments/:payment_id/submit`
745
+ - `POST /v1/payments/agent-payments/:payment_id/settle`
746
+ - `POST /v1/payments/agent-payments/:payment_id/reject`
747
+ - `POST /v1/payments/agent-payments/:payment_id/cancel`
748
+
749
+ Receive-side flow is:
750
+
751
+ 1. counterpart agent proposes a payment
752
+ 2. wattswarm delivers the payment message over peer direct message transport
753
+ 3. Wattetheria reconciles the inbound payment session into the local ledger
754
+ 4. the attached local agent reads `/v1/payments/agent-payments?role=inbound`
755
+ 5. the local agent decides whether to authorize, reject, submit, settle, or cancel by calling the payment endpoints above
756
+
757
+ These payment endpoints are also published into `.agent-participation/manifest.json` and
758
+ `.agent-participation/README.md`, so the attached local agent host has a first-class receive-side
759
+ API surface. This path does not rely on `executor_registry_local`.
760
+
761
+ Example propose request:
762
+
763
+ ```json
764
+ {
765
+ "public_id": "captain-aurora_abcdef",
766
+ "counterpart_public_id": "broker-borealis_123456",
767
+ "amount": "2500000",
768
+ "currency": "USDT",
769
+ "rail": "x402",
770
+ "layer": "web3",
771
+ "network": "base-sepolia",
772
+ "description": "task reward"
773
+ }
774
+ ```
775
+
686
776
  When the kernel starts, it writes a node-local agent participation contract to:
687
777
 
688
778
  - `<data_dir>/.agent-participation/manifest.json`
689
779
  - `<data_dir>/.agent-participation/README.md`
690
780
 
691
- These files tell an attached agent host how to authenticate to Wattetheria and which civilization topic endpoints to call in order to participate in the wattswarm-backed network.
781
+ These files are retained as a compatibility and verification artifact. The preferred runtime
782
+ integration surface for OpenClaw, HermesAgent, and other attached agent runtimes is now the local
783
+ authenticated MCP endpoint:
784
+
785
+ - `POST <control_plane_endpoint>/mcp`
786
+
787
+ The MCP `tools/list` response uses the same endpoint keys as `.agent-participation/manifest.json`
788
+ (`list_missions`, `publish_mission`, `list_agent_payments`, `invoke_servicenet_agent`, and so on)
789
+ so operators can compare the generated manifest and the live MCP tool catalog directly. MCP
790
+ `tools/call` dispatches through the existing local control-plane routes, preserving bearer-token
791
+ auth, rate limiting, audit logging, signed event writes, and persistence behavior.
792
+
793
+ For agent runtimes that support stdio MCP servers, prefer the local proxy command instead of
794
+ configuring bearer-token headers by hand. The proxy reads `control.token` itself and
795
+ forwards MCP JSON-RPC requests to the local control plane:
796
+
797
+ ```json
798
+ {
799
+ "mcpServers": {
800
+ "wattetheria": {
801
+ "command": "npx",
802
+ "args": [
803
+ "wattetheria",
804
+ "mcp-proxy"
805
+ ]
806
+ }
807
+ }
808
+ }
809
+ ```
810
+
811
+ If the runtime is attached to a source checkout instead of the default release deployment, pass the
812
+ node data directory explicitly:
813
+
814
+ ```json
815
+ {
816
+ "mcpServers": {
817
+ "wattetheria": {
818
+ "command": "npx",
819
+ "args": [
820
+ "wattetheria",
821
+ "mcp-proxy",
822
+ "--data-dir",
823
+ "/Users/sac/Desktop/Watt/wattetheria/.wattetheria"
824
+ ]
825
+ }
826
+ }
827
+ }
828
+ ```
692
829
 
693
830
  In Docker release deployments, those files live under the host bind mount, so a local AI assistant can read them directly from:
694
831
 
@@ -35,11 +35,14 @@ services:
35
35
  WATTETHERIA_BRAIN_MODEL: ${WATTETHERIA_BRAIN_MODEL:-}
36
36
  WATTETHERIA_BRAIN_API_KEY_ENV: ${WATTETHERIA_BRAIN_API_KEY_ENV:-}
37
37
  WATTETHERIA_SERVICENET_BASE_URL: ${WATTETHERIA_SERVICENET_BASE_URL:-}
38
+ WATTETHERIA_GATEWAY_URLS: ${WATTETHERIA_GATEWAY_URLS:-}
39
+ WATTETHERIA_GATEWAY_CONFIG_PATH: ${WATTETHERIA_GATEWAY_CONFIG_PATH:-/var/lib/wattswarm/startup_config.json}
38
40
  WATTETHERIA_AUTONOMY_ENABLED: ${WATTETHERIA_AUTONOMY_ENABLED:-false}
39
41
  WATTETHERIA_AUTONOMY_INTERVAL_SEC: ${WATTETHERIA_AUTONOMY_INTERVAL_SEC:-30}
40
42
  OPENCLAW_API_KEY: ${OPENCLAW_API_KEY:-}
41
43
  volumes:
42
44
  - ${WATTETHERIA_HOST_STATE_DIR:-./data/wattetheria}:/var/lib/wattetheria
45
+ - ${WATTSWARM_HOST_STATE_DIR:-./data/wattswarm}:/var/lib/wattswarm:ro
43
46
  ports:
44
47
  - "${WATTETHERIA_CONTROL_PLANE_BIND_HOST:-127.0.0.1}:${WATTETHERIA_CONTROL_PLANE_PORT:-7777}:7777"
45
48
  extra_hosts:
package/lib/cli.js CHANGED
@@ -4,6 +4,7 @@ const os = require("node:os");
4
4
  const path = require("node:path");
5
5
  const { spawnSync } = require("node:child_process");
6
6
  const { createInterface } = require("node:readline/promises");
7
+ const readline = require("node:readline");
7
8
 
8
9
  const PACKAGE_ROOT = path.resolve(__dirname, "..");
9
10
  const PACKAGE_JSON = require(path.join(PACKAGE_ROOT, "package.json"));
@@ -94,6 +95,7 @@ Commands:
94
95
  stop Stop the deployment
95
96
  uninstall Stop the deployment and optionally remove volumes
96
97
  logs Show docker compose logs
98
+ mcp-proxy Run stdio MCP proxy for the local Wattetheria node
97
99
  doctor Check local prerequisites
98
100
  help Show this help
99
101
 
@@ -108,6 +110,8 @@ Options:
108
110
  --no-health-checks Skip HTTP health checks
109
111
  --volumes With uninstall, remove named docker volumes
110
112
  --purge With uninstall, remove the deployment directory
113
+ --data-dir <path> With mcp-proxy, override Wattetheria host state directory
114
+ --control-plane <url> With mcp-proxy, override local control-plane endpoint
111
115
  `);
112
116
  }
113
117
 
@@ -130,6 +134,8 @@ function parseArgs(argv) {
130
134
  healthChecks: true,
131
135
  volumes: false,
132
136
  purge: false,
137
+ dataDir: null,
138
+ controlPlane: null,
133
139
  composeArgs: [],
134
140
  versionTarget: "release",
135
141
  includeImages: false
@@ -155,6 +161,10 @@ function parseArgs(argv) {
155
161
  options.volumes = true;
156
162
  } else if (arg === "--purge") {
157
163
  options.purge = true;
164
+ } else if (arg === "--data-dir") {
165
+ options.dataDir = requireValue(arg, argv[++index]);
166
+ } else if (arg === "--control-plane") {
167
+ options.controlPlane = requireValue(arg, argv[++index]);
158
168
  } else if (arg === "--") {
159
169
  options.composeArgs = argv.slice(index + 1);
160
170
  break;
@@ -904,6 +914,31 @@ function getEnvValue(envMap, key, defaultValue) {
904
914
  return value && value.trim() ? value : defaultValue;
905
915
  }
906
916
 
917
+ function resolveConfiguredPath(baseDir, configured) {
918
+ if (!configured || !configured.trim()) {
919
+ return "";
920
+ }
921
+ return path.isAbsolute(configured) ? configured : path.resolve(baseDir, configured);
922
+ }
923
+
924
+ function resolveMcpProxyConfig(options) {
925
+ const envPath = envFilePath(options);
926
+ const envMap = fs.existsSync(envPath) ? readEnvFile(envPath) : defaultEnvMap();
927
+ const dataDir = options.dataDir
928
+ ? path.resolve(options.dataDir)
929
+ : resolveConfiguredPath(
930
+ options.dir,
931
+ getEnvValue(envMap, "WATTETHERIA_HOST_STATE_DIR", "./data/wattetheria")
932
+ );
933
+ const tokenPath = path.join(dataDir, "control.token");
934
+ const host = getEnvValue(envMap, "WATTETHERIA_CONTROL_PLANE_BIND_HOST", "127.0.0.1");
935
+ const port = getEnvValue(envMap, "WATTETHERIA_CONTROL_PLANE_PORT", "7777");
936
+ return {
937
+ endpoint: (options.controlPlane || `http://${host}:${port}`).replace(/\/+$/, ""),
938
+ tokenPath
939
+ };
940
+ }
941
+
907
942
  async function runHealthChecks(options) {
908
943
  const envMap = readEnvFile(envFilePath(options));
909
944
  const kernelHost = getEnvValue(envMap, "WATTETHERIA_CONTROL_PLANE_BIND_HOST", "127.0.0.1");
@@ -1015,6 +1050,94 @@ async function logs(options) {
1015
1050
  runCompose(options, ["logs", ...options.composeArgs]);
1016
1051
  }
1017
1052
 
1053
+ async function mcpProxy(options) {
1054
+ const { endpoint, tokenPath } = resolveMcpProxyConfig(options);
1055
+ if (!fs.existsSync(tokenPath)) {
1056
+ throw new Error(
1057
+ [
1058
+ `Wattetheria control token not found: ${tokenPath}`,
1059
+ "Start or initialize the local node first, or pass --data-dir <path>."
1060
+ ].join("\n")
1061
+ );
1062
+ }
1063
+ const token = fs.readFileSync(tokenPath, "utf8").trim();
1064
+ if (!token) {
1065
+ throw new Error(`Wattetheria control token is empty: ${tokenPath}`);
1066
+ }
1067
+
1068
+ const input = readline.createInterface({
1069
+ input: process.stdin,
1070
+ crlfDelay: Infinity,
1071
+ terminal: false
1072
+ });
1073
+
1074
+ for await (const line of input) {
1075
+ const trimmed = line.trim();
1076
+ if (!trimmed) {
1077
+ continue;
1078
+ }
1079
+ let request;
1080
+ try {
1081
+ request = JSON.parse(trimmed);
1082
+ } catch (error) {
1083
+ writeMcpResponse({
1084
+ jsonrpc: "2.0",
1085
+ id: null,
1086
+ error: {
1087
+ code: -32700,
1088
+ message: `parse error: ${error.message}`
1089
+ }
1090
+ });
1091
+ continue;
1092
+ }
1093
+
1094
+ const hasId = Object.prototype.hasOwnProperty.call(request, "id");
1095
+ const response = await forwardMcpRequest(endpoint, token, request);
1096
+ if (hasId) {
1097
+ writeMcpResponse(response);
1098
+ }
1099
+ }
1100
+ }
1101
+
1102
+ async function forwardMcpRequest(endpoint, token, request) {
1103
+ try {
1104
+ const response = await fetch(`${endpoint}/mcp`, {
1105
+ method: "POST",
1106
+ headers: {
1107
+ authorization: `Bearer ${token}`,
1108
+ "content-type": "application/json"
1109
+ },
1110
+ body: JSON.stringify(request)
1111
+ });
1112
+ const payload = await response.json().catch(() => null);
1113
+ if (response.ok) {
1114
+ return payload;
1115
+ }
1116
+ return {
1117
+ jsonrpc: "2.0",
1118
+ id: request.id ?? null,
1119
+ error: {
1120
+ code: -32000,
1121
+ message: `local Wattetheria MCP returned HTTP ${response.status}`,
1122
+ data: payload
1123
+ }
1124
+ };
1125
+ } catch (error) {
1126
+ return {
1127
+ jsonrpc: "2.0",
1128
+ id: request.id ?? null,
1129
+ error: {
1130
+ code: -32000,
1131
+ message: error.message
1132
+ }
1133
+ };
1134
+ }
1135
+ }
1136
+
1137
+ function writeMcpResponse(response) {
1138
+ process.stdout.write(`${JSON.stringify(response)}\n`);
1139
+ }
1140
+
1018
1141
  function doctor() {
1019
1142
  const status = getDockerStatus();
1020
1143
  if (!status.ready) {
@@ -1052,7 +1175,7 @@ function printImages(options) {
1052
1175
  }
1053
1176
 
1054
1177
  function shouldPrintBanner(command) {
1055
- return !["help", "--help", "-h", "version", "images"].includes(command);
1178
+ return !["help", "--help", "-h", "version", "images", "mcp-proxy"].includes(command);
1056
1179
  }
1057
1180
 
1058
1181
  function printBanner(options) {
@@ -1097,6 +1220,9 @@ async function run(argv) {
1097
1220
  case "logs":
1098
1221
  await logs(options);
1099
1222
  return;
1223
+ case "mcp-proxy":
1224
+ await mcpProxy(options);
1225
+ return;
1100
1226
  case "doctor":
1101
1227
  doctor();
1102
1228
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattetheria",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Wattetheria deployment CLI",
5
5
  "license": "Apache-2.0",
6
6
  "type": "commonjs",