wattetheria 0.3.4 → 0.3.6

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 (3) hide show
  1. package/README.md +4 -4
  2. package/lib/cli.js +34 -78
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -557,10 +557,10 @@ native `wattetheria-client-cli`; installed release packages should not require R
557
557
  machine. The JS wrapper resolves `WATTETHERIA_CLI_BIN` first, then the matching optional native
558
558
  package such as `@wattetheria/cli-win32-x64`, then `bin/native/<platform>-<arch>/`, then `PATH`.
559
559
  `identity` and `wallet` are lightweight local setup commands for ServiceNet publishing and wallet
560
- binding when no local Wattetheria node identity or wallet exists. If a local node already has
561
- identity or wallet state, the wrapper refuses to create a separate local identity or wallet through
562
- those setup commands. ServiceNet commands can still run through an installed node when no host
563
- native CLI is available.
560
+ binding before a local Wattetheria node is installed. If a local node deployment is already
561
+ installed, the wrapper refuses `identity` and `wallet` commands so users do not create or modify a
562
+ separate local identity or wallet outside the node. ServiceNet commands can still run through an
563
+ installed node when no host native CLI is available.
564
564
 
565
565
  NPM publish flow:
566
566
 
package/lib/cli.js CHANGED
@@ -73,6 +73,20 @@ Commands:
73
73
  doctor Check local prerequisites
74
74
  help Show this help
75
75
 
76
+ Global options:
77
+ --version, -v Alias for \`version\`
78
+ --cli With \`version\`, show deployment CLI version instead
79
+ --images With \`version\`, print configured image refs
80
+ --dir <path> Deployment directory (default: ${DEFAULT_DEPLOY_DIR})
81
+ --project-name <name> Docker compose project name (default: ${DEFAULT_PROJECT_NAME})
82
+ --tag <tag> Override all release image tags
83
+ --force Refresh deployment defaults and compose assets
84
+ --no-health-checks Skip HTTP health checks
85
+ --volumes With uninstall, remove named docker volumes
86
+ --purge With uninstall, remove the deployment directory
87
+ --data-dir <path> With mcp-proxy, override Wattetheria host state directory
88
+ --control-plane <url> With mcp-proxy, override local control-plane endpoint
89
+
76
90
  Agent subcommands:
77
91
  identity
78
92
  init Initialize a lightweight local identity for ServiceNet publishing or wallet binding
@@ -92,20 +106,6 @@ Agent subcommands:
92
106
  register --card <path-to-agent-card.json>
93
107
  Register the agent card and local identity with ServiceNet; returns agent_id and provider_id
94
108
  publish <agent-id> Publish a registered ServiceNet agent using the agent_id returned by register
95
-
96
- Options:
97
- --version, -v Alias for \`version\`
98
- --cli With \`version\`, show deployment CLI version instead
99
- --images With \`version\`, print configured image refs
100
- --dir <path> Deployment directory (default: ${DEFAULT_DEPLOY_DIR})
101
- --project-name <name> Docker compose project name (default: ${DEFAULT_PROJECT_NAME})
102
- --tag <tag> Override all release image tags
103
- --force Refresh deployment defaults and compose assets
104
- --no-health-checks Skip HTTP health checks
105
- --volumes With uninstall, remove named docker volumes
106
- --purge With uninstall, remove the deployment directory
107
- --data-dir <path> With mcp-proxy, override Wattetheria host state directory
108
- --control-plane <url> With mcp-proxy, override local control-plane endpoint
109
109
  `);
110
110
  }
111
111
 
@@ -1344,36 +1344,6 @@ function missingNativeCliError(commandName) {
1344
1344
  );
1345
1345
  }
1346
1346
 
1347
- function forwardedSubcommand(rawArgv) {
1348
- for (let index = 1; index < rawArgv.length; index += 1) {
1349
- const arg = rawArgv[index];
1350
- if (arg.startsWith("-")) {
1351
- if (!arg.includes("=")) {
1352
- index += 1;
1353
- }
1354
- continue;
1355
- }
1356
- return arg;
1357
- }
1358
- return "";
1359
- }
1360
-
1361
- function isIdentityWriteCommand(commandName, rawArgv) {
1362
- return commandName === "identity" && forwardedSubcommand(rawArgv) === "init";
1363
- }
1364
-
1365
- function isWalletWriteCommand(commandName, rawArgv) {
1366
- if (commandName !== "wallet") {
1367
- return false;
1368
- }
1369
- return new Set([
1370
- "create-payment-account",
1371
- "import-payment-account",
1372
- "watch-payment-account",
1373
- "bind-payment-account"
1374
- ]).has(forwardedSubcommand(rawArgv));
1375
- }
1376
-
1377
1347
  function installedNodeArtifacts(deployment = deploymentState()) {
1378
1348
  return {
1379
1349
  identityPath: path.join(deployment.stateDir, "identity.json"),
@@ -1382,60 +1352,46 @@ function installedNodeArtifacts(deployment = deploymentState()) {
1382
1352
  };
1383
1353
  }
1384
1354
 
1385
- function explicitDataDir(rawArgv) {
1386
- const option = parsePathOption(rawArgv, "--data-dir", 1);
1387
- if (!option) {
1388
- return "";
1389
- }
1390
- if (!option.value) {
1391
- throw new Error("Missing value for --data-dir");
1392
- }
1393
- return path.resolve(option.value);
1394
- }
1395
-
1396
- function usesSeparateDataDir(rawArgv, deployment) {
1397
- const dataDir = explicitDataDir(rawArgv);
1398
- return Boolean(dataDir) && dataDir !== path.resolve(deployment.stateDir);
1355
+ function isLightweightLocalCommand(commandName) {
1356
+ return commandName === "identity" || commandName === "wallet";
1399
1357
  }
1400
1358
 
1401
- function ensureLightweightCommandAllowed(commandName, rawArgv) {
1402
- if (!(isIdentityWriteCommand(commandName, rawArgv) || isWalletWriteCommand(commandName, rawArgv))) {
1359
+ function ensureLightweightCommandAllowed(commandName) {
1360
+ if (!isLightweightLocalCommand(commandName)) {
1403
1361
  return;
1404
1362
  }
1405
1363
  const deployment = deploymentState();
1406
- if (!deployment.installed || usesSeparateDataDir(rawArgv, deployment)) {
1364
+ if (!deployment.installed) {
1407
1365
  return;
1408
1366
  }
1409
1367
  const artifacts = installedNodeArtifacts(deployment);
1410
- if (isIdentityWriteCommand(commandName, rawArgv) && fs.existsSync(artifacts.identityPath)) {
1368
+ if (commandName === "identity") {
1411
1369
  throw new Error(
1412
1370
  [
1413
- "Refusing to initialize a separate local identity.",
1371
+ "Refusing to run a separate local identity command.",
1414
1372
  "",
1415
- "A local Wattetheria node is already installed and has an identity at:",
1373
+ fs.existsSync(artifacts.identityPath)
1374
+ ? "A local Wattetheria node is already installed and has an identity at:"
1375
+ : "A local Wattetheria node is already installed at:",
1416
1376
  deployment.stateDir,
1417
1377
  "",
1418
- "`wattetheria identity init` is only for lightweight local setup when no Wattetheria",
1419
- "node identity exists. Use the installed node's identity instead, or choose a separate",
1420
- "data directory only for isolated testing."
1378
+ "`wattetheria identity` is only for lightweight local setup when no Wattetheria",
1379
+ "node is installed. Use the installed node's identity instead."
1421
1380
  ].join("\n")
1422
1381
  );
1423
1382
  }
1424
- if (
1425
- isWalletWriteCommand(commandName, rawArgv)
1426
- && fs.existsSync(artifacts.walletMetadataPath)
1427
- && fs.existsSync(artifacts.walletKeystorePath)
1428
- ) {
1383
+ if (commandName === "wallet") {
1429
1384
  throw new Error(
1430
1385
  [
1431
- "Refusing to modify a separate local wallet.",
1386
+ "Refusing to run a separate local wallet command.",
1432
1387
  "",
1433
- "A local Wattetheria node is already installed and has wallet state at:",
1388
+ fs.existsSync(artifacts.walletMetadataPath) && fs.existsSync(artifacts.walletKeystorePath)
1389
+ ? "A local Wattetheria node is already installed and has wallet state at:"
1390
+ : "A local Wattetheria node is already installed at:",
1434
1391
  deployment.stateDir,
1435
1392
  "",
1436
- "`wattetheria wallet` setup commands are only for lightweight local setup when no",
1437
- "Wattetheria node wallet exists. Use the installed node's wallet instead, or choose a",
1438
- "separate data directory only for isolated testing."
1393
+ "`wattetheria wallet` is only for lightweight local setup when no Wattetheria",
1394
+ "node is installed. Use the installed node's wallet instead."
1439
1395
  ].join("\n")
1440
1396
  );
1441
1397
  }
@@ -1670,7 +1626,7 @@ function runInstalledNodeCli(commandName, rawArgv, deployment) {
1670
1626
  }
1671
1627
 
1672
1628
  function forwardToRustBinary(commandName, rawArgv) {
1673
- ensureLightweightCommandAllowed(commandName, rawArgv);
1629
+ ensureLightweightCommandAllowed(commandName);
1674
1630
 
1675
1631
  // Only the Rust binary name is allowed here. The bare `wattetheria` name
1676
1632
  // resolves to this JS shim on most user PATHs (via the npm bin link), so
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattetheria",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Wattetheria deployment CLI",
5
5
  "license": "Apache-2.0",
6
6
  "type": "commonjs",