|
| 1 | +# agg |
| 2 | + |
| 3 | +A CLI tool for interacting with an Aggregator Server. It supports registering users via device flow, managing aggregators and services, and fetching service descriptions and outputs. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Node.js 18+ |
| 10 | +- npm |
| 11 | + |
| 12 | +### Install locally |
| 13 | + |
| 14 | +```bash |
| 15 | +npm run build |
| 16 | +npm link |
| 17 | +``` |
| 18 | + |
| 19 | +After linking, the `agg` command is available globally in your terminal. |
| 20 | + |
| 21 | +## Configuration |
| 22 | + |
| 23 | +Configuration is stored in a JSON file. The location is resolved in the following order: |
| 24 | + |
| 25 | +1. `$AGG_CONFIG` — if this environment variable is set, it is used as the config file path |
| 26 | +2. `$XDG_CONFIG_HOME/agg/config.json` — if `XDG_CONFIG_HOME` is set (Linux/macOS) |
| 27 | +3. `~/.agg/config.json` — default fallback |
| 28 | + |
| 29 | +To check where your config file is located: |
| 30 | + |
| 31 | +```bash |
| 32 | +agg where-config |
| 33 | +``` |
| 34 | + |
| 35 | +To load an existing JSON file as your config: |
| 36 | + |
| 37 | +```bash |
| 38 | +agg set-config ./my-config.json |
| 39 | +``` |
| 40 | + |
| 41 | +### Config structure |
| 42 | + |
| 43 | +```json |
| 44 | +{ |
| 45 | + "activeAggregator": "https://aggregator.example.org/some-id", |
| 46 | + "aggregators": { |
| 47 | + "https://aggregator.example.org/some-id": { |
| 48 | + "id": "https://aggregator.example.org/some-id", |
| 49 | + "services": [ |
| 50 | + { |
| 51 | + "name": "my-svc", |
| 52 | + "tf": "MyTransformation", |
| 53 | + "params": { |
| 54 | + "sources": "https://..." |
| 55 | + }, |
| 56 | + "outputs": ["w-dist"] |
| 57 | + } |
| 58 | + ] |
| 59 | + } |
| 60 | + }, |
| 61 | + "aggregator": { |
| 62 | + "server": "https://aggregator.example.org", |
| 63 | + "tf": "/transformations", |
| 64 | + "svc": "/services", |
| 65 | + "reg": "/register" |
| 66 | + }, |
| 67 | + "auth": { |
| 68 | + "username": "user@example.org", |
| 69 | + "password": "password", |
| 70 | + "clientId": "my-client", |
| 71 | + "clientSecret": "my-secret", |
| 72 | + "idp": "https://idp.example.org", |
| 73 | + "realm": "my-realm", |
| 74 | + "uma": "https://uma.example.org" |
| 75 | + }, |
| 76 | + "service": { |
| 77 | + "name": "my-svc", |
| 78 | + "tf": "MyTransformation", |
| 79 | + "params": {}, |
| 80 | + "outputs": ["w-dist"] |
| 81 | + } |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +## Commands |
| 86 | + |
| 87 | +### Authentication |
| 88 | + |
| 89 | +#### `agg set-auth` |
| 90 | + |
| 91 | +Set authentication configuration. All options are optional — only the provided values are updated. |
| 92 | + |
| 93 | +```bash |
| 94 | +agg set-auth --username user@example.org \ |
| 95 | + --password secret \ |
| 96 | + --client-id my-client \ |
| 97 | + --client-secret my-secret \ |
| 98 | + --idp https://idp.example.org \ |
| 99 | + --uma https://uma.example.org |
| 100 | +``` |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +### Aggregator management |
| 105 | + |
| 106 | +#### `agg register-user` |
| 107 | + |
| 108 | +Register a user on the aggregator server using a device flow. Opens a browser URL for the user to authenticate, then polls for completion. On success, the aggregator is added to the config. |
| 109 | + |
| 110 | +```bash |
| 111 | +agg register-user # register and add aggregator to config |
| 112 | +agg register-user --set-active # also set it as the active aggregator |
| 113 | +``` |
| 114 | + |
| 115 | +#### `agg set-active <id>` |
| 116 | + |
| 117 | +Set the active aggregator by its ID. |
| 118 | + |
| 119 | +```bash |
| 120 | +agg set-active https://aggregator.example.org/some-id |
| 121 | +``` |
| 122 | + |
| 123 | +#### `agg get-active` |
| 124 | + |
| 125 | +Show the currently active aggregator and its registered services. |
| 126 | + |
| 127 | +```bash |
| 128 | +agg get-active |
| 129 | +``` |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +### Service management |
| 134 | + |
| 135 | +#### `agg create-service` |
| 136 | + |
| 137 | +Create a service on the active aggregator using the service configuration. On success, the service is added to the aggregator's service list in the config. |
| 138 | + |
| 139 | +```bash |
| 140 | +agg create-service # use config defaults |
| 141 | +agg create-service --name my-svc --tf MyTransformation # override name and tf |
| 142 | +agg create-service --param sources=https://... \ |
| 143 | + --param weight-slice=abc # override params (repeatable) |
| 144 | +agg create-service --outputs w-dist,other # override outputs |
| 145 | +agg create-service --agg https://aggregator.example.org/other-id # use specific aggregator |
| 146 | +``` |
| 147 | + |
| 148 | +| Option | Description | |
| 149 | +|---|---| |
| 150 | +| `--name <name>` | Service name (overrides config) | |
| 151 | +| `--tf <tf>` | Transformation ID (overrides config) | |
| 152 | +| `--outputs <outputs>` | Comma-separated list of outputs (overrides config) | |
| 153 | +| `--param <key=value>` | Parameter as `key=value`, can be repeated | |
| 154 | +| `--agg <id>` | Aggregator ID to use instead of the active one | |
| 155 | + |
| 156 | +#### `agg get-service` |
| 157 | + |
| 158 | +Fetch the description of a service from the active aggregator. |
| 159 | + |
| 160 | +```bash |
| 161 | +agg get-service |
| 162 | +agg get-service --svc my-svc # specific service |
| 163 | +agg get-service --agg https://aggregator.example.org/id # specific aggregator |
| 164 | +``` |
| 165 | + |
| 166 | +| Option | Description | |
| 167 | +|---|---| |
| 168 | +| `--svc <name>` | Service name (overrides active) | |
| 169 | +| `--agg <id>` | Aggregator ID to use instead of the active one | |
| 170 | + |
| 171 | +#### `agg get-output` |
| 172 | + |
| 173 | +Fetch outputs of a service from the active aggregator. By default fetches all outputs registered for the service. |
| 174 | + |
| 175 | +```bash |
| 176 | +agg get-output # fetch all outputs |
| 177 | +agg get-output --outputs w-dist # fetch a subset |
| 178 | +agg get-output --svc my-svc --agg <id> # specific service and aggregator |
| 179 | +``` |
| 180 | + |
| 181 | +| Option | Description | |
| 182 | +|---|---| |
| 183 | +| `--outputs <outputs>` | Comma-separated subset of outputs to fetch | |
| 184 | +| `--svc <name>` | Service name (overrides active) | |
| 185 | +| `--agg <id>` | Aggregator ID to use instead of the active one | |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +### Config management |
| 190 | + |
| 191 | +#### `agg set-config <file>` |
| 192 | + |
| 193 | +Load a JSON file as the config, replacing the current config. |
| 194 | + |
| 195 | +```bash |
| 196 | +agg set-config ./my-config.json |
| 197 | +``` |
| 198 | + |
| 199 | +#### `agg where-config` |
| 200 | + |
| 201 | +Print the path to the current config file. |
| 202 | + |
| 203 | +```bash |
| 204 | +agg where-config |
| 205 | +``` |
0 commit comments