aweshare 0.3.3 → 0.3.5

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
@@ -14,7 +14,7 @@
14
14
  <a href="https://ko-fi.com/mugpeng"><img src="https://img.shields.io/badge/Ko--fi-Buy%20me%20a%20coffee-FF5E5B?style=flat-square&logo=ko-fi&logoColor=white" alt="Ko-fi"></a>
15
15
  </p>
16
16
  <p>
17
- <a href="https://github.com/wehuman01/aweshare-source/releases"><img src="https://img.shields.io/badge/version-0.3.3-7C3AED?style=flat-square" alt="Version"></a>
17
+ <a href="https://github.com/wehuman01/aweshare-source/releases"><img src="https://img.shields.io/badge/version-0.3.5-7C3AED?style=flat-square" alt="Version"></a>
18
18
  <a href="https://github.com/wehuman01/aweshare"><img src="https://img.shields.io/badge/node-%E2%89%A522-0EA5E9?style=flat-square" alt="Node"></a>
19
19
  <a href="https://github.com/wehuman01/aweshare/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-proprietary-E34F26?style=flat-square" alt="License"></a>
20
20
  <a href="https://www.npmjs.com/package/aweshare"><img src="https://img.shields.io/badge/npm-aweshare-7C3AED?style=flat-square" alt="npm package"></a>
@@ -55,7 +55,8 @@ Consumer (standard SDK, zero changes) Producer side
55
55
  ## Trust boundary (read this first)
56
56
 
57
57
  - To route and meter, **consumer prompts and model responses transit the hub in plaintext — this is not end-to-end encryption**. The hub persists no request/response content, but the hub operator can technically see it. Only use a hub instance you trust — which is why the hub is open source and self-hostable.
58
- - Upstream API keys never leave the producer's device and are never sent to consumers; the hub authenticates tokens by SHA-256 hash. Since v4 the hub also stores the plaintext of tokens and invite codes it issues (NULL for older rows) so admins can re-display them with `hub token list --reveal` / `hub invite list --reveal` — treat the hub database as secret-bearing: a DB leak exposes every secret issued since v4.
58
+ - Upstream API keys never leave the producer's device and are never sent to consumers. Tokens are stored **hash-only** (peppered SHA-256): the plaintext is shown exactly once at issue/redeem and can never be re-displayed. Invite codes are the deliberate exception their plaintext is kept so the operator can re-view them with `hub list --reveal`; a DB leak exposes unredeemed codes, but no tokens.
59
+ - Token revocation is **reversible suspension** (`hub revoke --id N` / `hub restore --id N`, by invite), and an invite and the producer it minted move together: revoking a redeemed code suspends that producer (and closes its tunnel), and restoring from either handle revives both. Nothing is deleted on revoke — grants, offerings and usage history survive a suspension.
59
60
 
60
61
  ### Compliance and disclaimer
61
62
 
@@ -86,42 +87,47 @@ docker run -d --name aweshare-hub --restart unless-stopped \
86
87
  docker exec aweshare-hub aweshare hub init # first run: prints the admin token, save it
87
88
  ```
88
89
 
89
- Then issue tokens (admin token in hand):
90
-
91
- ```bash
92
- aweshare hub token issue --role producer --name peng # → asp_..., give to the producer
93
- aweshare hub token issue --role consumer --name alice # → asc_..., give to the consumer
94
- ```
95
-
96
- For producers there is also a self-service path — invite codes (`asi_…`, single use). Two modes:
90
+ Then bring people in. Producers join on their own — invite codes (`asi_…`, single use). Two modes:
97
91
 
98
92
  ```bash
99
93
  # bound: lock the code to a specific name ("inviting that user")
100
- aweshare hub invite create --name peng [--expires-in 7d] # → asi_..., send to the producer
94
+ aweshare hub invite --name peng [--expires-in 7d] # → asi_..., send to the producer
101
95
 
102
96
  # unbound: batch hand-out; the producer submits name + email at redeem (stored on the hub)
103
- aweshare hub invite create --count 10 [--expires-in 7d]
97
+ aweshare hub invite --count 10 [--expires-in 7d]
104
98
 
105
99
  # the producer redeems it themselves (no token hand-off needed):
106
100
  aweshare agent join --hub https://hub.example.com --code asi_... [--name NAME --email YOU@EXAMPLE.COM]
107
101
  ```
108
102
 
103
+ Consumers are few and known — their keys (`asc_…`) are issued directly via the admin API (the hub CLI is invite-only):
104
+
105
+ ```bash
106
+ curl -X POST https://hub.example.com/admin/v1/tokens \
107
+ -H "Authorization: Bearer asa_... (the admin token)" -H "content-type: application/json" \
108
+ -d '{"role":"consumer","name":"alice"}' # → asc_..., give to the consumer
109
+ ```
110
+
109
111
  Three token roles, one per party:
110
112
 
111
113
  | Role | Who holds it | How it's used |
112
114
  |---|---|---|
113
- | `admin` | hub operator (you only) | management commands: `hub token issue` / `grant add` / `token revoke` / `usage` |
115
+ | `admin` | hub operator (you only) | the admin REST API (`/admin/v1/*`); CLI side: `hub invite` / `list` / `revoke` / `restore` |
114
116
  | `producer` (`asp_...`) | the agent on the producer's machine | set as `token` in `~/.aweshare/config.toml`; the agent registers its offerings with it |
115
117
  | `consumer` (`asc_...`) | whoever calls the models | set in SDK env vars (`ANTHROPIC_AUTH_TOKEN` / `OPENAI_API_KEY`); the hub uses it to decide which aliases they may call |
116
118
 
117
119
  The producer's `name` becomes their alias namespace (the `peng/` in `peng/gpt-4o`).
118
120
 
121
+ Identity and permission are deliberately split. The operator issues identities — invite codes for producers, `asc_…` keys for consumers — while each producer alone decides who may call their own aliases (`aweshare agent grant`; the admin API can read grants for audit but cannot write them). A fresh consumer key can call nothing until a producer grants it, so the hub works the same whether you run everything yourself (private hub) or producers who don't know each other share yours (community hub).
122
+
119
123
  ### 2. Producer first run (in this order)
120
124
 
121
125
  ```bash
122
126
  npm install -g aweshare # ⓪ once, on the producer machine (Node ≥ 22)
123
127
 
124
- # ① init: writes ~/.aweshare/config.toml + secrets.json (0600)
128
+ # ① join with your invite code (writes ~/.aweshare/config.toml + secrets.json, 0600)
129
+ aweshare agent join --hub https://hub.example.com --code asi_...
130
+ # or, with a producer token handed to you directly:
125
131
  aweshare agent init --hub https://hub.example.com --token asp_...
126
132
 
127
133
  # ② Edit the config (see below); put upstream keys in secrets.json — they never leave this machine
@@ -146,7 +152,7 @@ curl https://hub.example.com/v1/chat/completions \
146
152
  -d '{"model":"peng/qwen2.5.7b","messages":[{"role":"user","content":"ping"}]}'
147
153
 
148
154
  # ② configure your tool (below) → run one minimal task
149
- # ③ check usage: aweshare hub usage --alias peng/qwen2.5.7b
155
+ # ③ check usage: GET /admin/v1/usage with your consumer key (you only see your own rows)
150
156
  # ④ only then move to real workloads
151
157
  ```
152
158
 
@@ -215,10 +221,13 @@ Key hygiene: use dedicated, least-privilege, revocable keys with budget alerts;
215
221
  Every consumer gets the hub-wide defaults (`AWESHARE_CONSUMER_RPS` / `BURST` / `CONCURRENCY`, see Operations). On top of that, the hub admin can set **sparse per-consumer overrides** — only the keys you set take effect, everything else keeps the defaults:
216
222
 
217
223
  ```bash
218
- aweshare hub consumer limits --name alice # show current overrides
219
- aweshare hub consumer limits --name alice --tpm 60000 --max-total-tokens 5000000
220
- aweshare hub consumer limits --name alice --rps 2 # later calls merge, not replace
221
- aweshare hub consumer limits --name alice --clear # back to hub-wide defaults
224
+ # PUT /admin/v1/consumers/{name}/limits sparse JSON; unset keys keep the defaults,
225
+ # later PUTs merge into what is stored
226
+ curl -X PUT https://hub.example.com/admin/v1/consumers/alice/limits \
227
+ -H "Authorization: Bearer asa_... (the admin token)" -H "content-type: application/json" \
228
+ -d '{"tpm":60000,"maxTotalTokens":5000000}'
229
+
230
+ # DELETE the same path clears all overrides back to the hub-wide defaults
222
231
  ```
223
232
 
224
233
  | Key | Meaning | Enforcement |
@@ -227,9 +236,9 @@ aweshare hub consumer limits --name alice --clear # back to hub-wide defaults
227
236
  | `tpm` | max tokens (prompt + completion) in any sliding 60s window | 429 `RATE_LIMITED` (in-memory window, like the RPS bucket) |
228
237
  | `maxTotalTokens` | lifetime token budget for this consumer | 429 `QUOTA_EXCEEDED` (sums `usage_events`) |
229
238
 
230
- Grants can also carry an expiry: `aweshare hub grant add --alias peng/gpt-4o --consumer alice --expires-in 7d` (or `aweshare agent grant --expires-in 7d` on the producer side). An expired grant returns `403 GRANT_EXPIRED`; re-granting refreshes the expiry.
239
+ Grants can also carry an expiry: `aweshare agent grant --alias peng/gpt-4o --consumer alice --expires-in 7d`. Grant writes are producer-owned the admin API keeps read-only audit access but rejects admin-token writes with `403 NOT_GRANTED`. An expired grant returns `403 GRANT_EXPIRED`; re-granting refreshes the expiry.
231
240
 
232
- Honest limits: token-based caps count what upstreams report — Ollama streams report no usage, so they contribute 0. TPM is best-effort (concurrent requests that all pass before any finishes can overshoot); the lifetime budget is exact because it sums persisted rows.
241
+ Honest limits: token-based caps count what upstreams report — Ollama streams report no usage, so they contribute 0. Both TPM and the lifetime budget are observed-usage thresholds, not hard reservations: one request can cross the threshold, and concurrent requests that start before earlier usage is recorded can overshoot it further. Once recorded usage has reached the threshold, new requests are rejected.
233
242
 
234
243
  ## Endpoints and errors
235
244
 
@@ -238,11 +247,11 @@ Honest limits: token-based caps count what upstreams report — Ollama streams r
238
247
  | `POST /v1/chat/completions` · `POST /v1/messages` · `POST /v1/responses` | inference (Bearer or `x-api-key`) |
239
248
  | `GET /v1/models` | aliases visible to this key, with status |
240
249
  | `GET /healthz` | liveness |
241
- | `/admin/v1/*` | token/grant/usage management (admin or producer token) · consumer limit overrides: `GET`/`PUT`/`DELETE /admin/v1/consumers/{name}/limits` (admin only) |
250
+ | `/admin/v1/*` | token/limit/usage management (admin or producer token) · grants: writes producer-only, admin reads for audit · consumer limit overrides: `GET`/`PUT`/`DELETE /admin/v1/consumers/{name}/limits` (admin only) |
242
251
 
243
- Error semantics: `401` invalid key · `403` not granted or `GRANT_EXPIRED` · `404` unknown alias · `400 PROTOCOL_MISMATCH` protocol/alias mismatch · `429` rate limit, TPM or producer concurrency cap (`QUOTA_EXCEEDED` = lifetime token budget hit) · `502` upstream/tunnel failure (upstream 4xx/5xx passes through verbatim) · `503` producer offline / backend degraded · `504` timeout. Errors carry `{error:{code,message,requestId}}`; the requestId spans both sides' logs.
252
+ Error semantics: `401` invalid key · `401 TOKEN_REVOKED` suspended token (ask the operator to restore it) · `403` not granted or `GRANT_EXPIRED` · `403 HUB_FULL` producer capacity reached · `404` unknown alias · `400 PROTOCOL_MISMATCH` protocol/alias mismatch · `429` rate limit, TPM or producer concurrency cap (`QUOTA_EXCEEDED` = lifetime token budget hit) · `502` upstream/tunnel failure (upstream 4xx/5xx passes through verbatim) · `503` producer offline / backend degraded · `504` timeout. Errors carry `{error:{code,message,requestId}}`; the requestId spans both sides' logs.
244
253
 
245
- Usage metering: one row per request (alias, real model, status, duration, byte counts, best-effort token counts), **zero content stored**. Producers list grants with `aweshare agent list`; query usage with `aweshare hub usage`.
254
+ Usage metering: one row per request (alias, real model, status, duration, byte counts, best-effort token counts), **zero content stored**. Producers list grants with `aweshare agent list`; usage is queried via `GET /admin/v1/usage` (admin sees everything, producers and consumers their own slice).
246
255
 
247
256
  ## Command reference
248
257
 
@@ -254,16 +263,13 @@ Both sides at a glance — details in the sections above.
254
263
  |---|---|
255
264
  | `aweshare hub init` | create data dir + admin token (printed once) |
256
265
  | `aweshare hub serve [--host H] [--port N]` | run the hub |
257
- | `aweshare hub token issue --role producer\|consumer --name NAME` | issue a producer (`asp_…`) or consumer (`asc_…`) token |
258
- | `aweshare hub token list [--reveal]` · `aweshare hub token revoke --role R --id N` | list / revoke tokens (`--reveal` also shows the stored plaintext of tokens issued since v4) |
259
- | `aweshare hub invite create [--name NAME] [--count N] [--expires-in 7d]` | create one-time invite codes (`asi_…`, printed once; re-view with `invite list --reveal`); with `--name` bound to that producer, without it the producer submits name + email at redeem |
260
- | `aweshare hub invite list [--reveal]` · `aweshare hub invite revoke --id N` | list / revoke (unredeemed) invites (`--reveal` re-shows codes created since v4) |
261
- | `aweshare hub grant add --alias ns/model --consumer NAME [--expires-in 7d]` | grant (or refresh) access to an alias |
262
- | `aweshare hub grant list` · `aweshare hub grant remove --alias A --consumer NAME` | list / remove grants |
263
- | `aweshare hub consumer limits --name NAME [--rps N] [--burst N] [--concurrency N] [--tpm N] [--max-total-tokens N] [--clear]` | per-consumer overrides (see Consumer limits) |
264
- | `aweshare hub usage [--alias A] [--limit N]` | usage metering |
266
+ | `aweshare hub invite [--name NAME] [--count N] [--expires-in 7d]` | mint one-time invite codes (`asi_…`, printed once; re-view with `list --reveal`); with `--name` bound to that producer, without it the producer submits name + email at redeem |
267
+ | `aweshare hub list [--reveal] [--token]` | list invites (status: pending/used/suspended/revoked/expired); `--reveal` shows the codes, `--token` shows the producer token each minted, with last seen |
268
+ | `aweshare hub revoke --id N` · `aweshare hub restore --id N` | kill an invite / undo a redeemed code suspends the producer it minted, restore revives both |
269
+
270
+ The CLI is invite-only: token issuance, consumer limits and usage left it when it narrowed — they live on the admin REST API (`/admin/v1/*`, see Endpoints and errors). Grants are producer-owned and were never the operator's CLI: manage them with `aweshare agent grant`/`revoke`/`list` on the producer machine (the admin API keeps read-only audit access).
265
271
 
266
- List and usage commands print aligned tables by default; append `--json` for the raw API response.
272
+ `list` prints an aligned table by default; append `--json` for the raw API response.
267
273
 
268
274
  **Agent (producer)** — runs on the producer's machine (the one with the backends); consumers run no aweshare commands — they point a standard SDK at the hub (see Consumer tool configuration):
269
275
 
@@ -289,6 +295,8 @@ CLI maintenance: `aweshare self-update [--check]` updates the npm-installed CLI
289
295
  | `AWESHARE_CONSUMER_RPS` / `BURST` / `CONCURRENCY` | 10 / 20 / 8 | per-consumer limits |
290
296
  | `AWESHARE_HEAD_TIMEOUT_MS` / `IDLE_TIMEOUT_MS` | 120000 / 300000 | response-head timeout / stream idle timeout |
291
297
  | `AWESHARE_MAX_BODY_BYTES` | 32MB | request body cap |
298
+ | `AWESHARE_INVITE_REDEEM_PER_MIN` | 10 | rate limit for the unauthenticated redeem endpoint |
299
+ | `AWESHARE_MAX_PRODUCERS` | 10 | max active producers — token issuance (admin API), invite redeem and restore refuse with `403 HUB_FULL` when full |
292
300
  | `AWESHARE_NO_UPDATE_CHECK` | unset | set to `1` to disable the passive update reminder |
293
301
 
294
302
  Health: agent heartbeats every 15s, silent 45s = dead; backends with 2 consecutive AUTH/QUOTA failures auto-degrade (alias shows `degraded`, dispatch stops), 30s probes recover. A new connection with the same producer token replaces the old one (latest-wins).
@@ -8,37 +8,89 @@ import { agentDir, applyJoinToConfig, CONFIG_TEMPLATE, loadAgentConfig, redactCo
8
8
  import { AgentConnection } from './connection.js';
9
9
  import { runDoctor } from './doctor.js';
10
10
  import { renderGrants } from './table.js';
11
- const VERSION = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
12
- const USAGE = `aweshare agent share local/authorized AI capacity through an aweshare hub
11
+ const VERSION = JSON.parse(readFileSync(new URL('../../../package.json', import.meta.url), 'utf8')).version;
12
+ // One-liners only; flags per command live in their own -h, everything else in README.
13
+ const USAGE = `Usage: aweshare agent [OPTIONS] COMMAND [ARGS]...
13
14
 
14
- Usage: aweshare agent <command>
15
+ Share local/authorized AI capacity through an aweshare hub.
15
16
 
16
- Onboarding:
17
- init [--hub URL] [--token asp_...] write config template + empty secrets
18
- join --hub URL --code asi_... [--name NAME] [--email EMAIL]
19
- redeem an invite into a producer token
20
- (unbound codes ask for --name/--email)
17
+ Options:
18
+ -v, --version Show the version and exit.
19
+ -h, --help Show this message and exit.
21
20
 
22
- Config:
23
- config path print config path
24
- config show show config with secrets redacted
25
- config edit open config in $VISUAL, $EDITOR or vi
26
- config init write config template + empty secrets
21
+ Commands:
22
+ init Write the config template and empty secrets.
23
+ join Redeem an invite code into a producer token.
24
+ config Show or edit the config (path | show | edit).
25
+ doctor Pre-flight checks: config, backends, hub.
26
+ start Connect, register offerings, relay requests.
27
+ grant Allow a consumer to call your offering.
28
+ revoke Remove a grant.
29
+ list List grants for your namespace.`;
30
+ const COMMAND_HELP = {
31
+ init: `Usage: aweshare agent init [OPTIONS]
27
32
 
28
- Run:
29
- start connect, register offerings, relay
30
- doctor pre-flight checks (direct replay first, hub last)
33
+ Write the config template and empty secrets (kept if they exist).
31
34
 
32
- Grants:
33
- grant --alias ALIAS --consumer NAME [--expires-in 7d|12h|30m|90s]
34
- allow a consumer to call your offering
35
- revoke --alias ALIAS --consumer NAME remove a grant
36
- list [--json] list grants for your namespace
35
+ Options:
36
+ --hub URL Pre-fill the hub URL in the template.
37
+ --token ASP Pre-fill a producer token (asp_...) in the template.
38
+ -h, --help Show this message and exit.`,
39
+ join: `Usage: aweshare agent join [OPTIONS]
37
40
 
38
- --json on list prints the raw API response instead of a table.
41
+ Redeem an invite code into a producer token and write the config.
39
42
 
40
- Environment:
41
- AWESHARE_AGENT_DIR config directory (default ~/.aweshare)`;
43
+ Options:
44
+ --hub URL The hub to join (required, http(s) URL).
45
+ --code CODE The invite code from the hub operator (asi_..., required).
46
+ --name NAME Your producer name (unbound codes only — bound ones ignore it).
47
+ --email EMAIL Your contact email (unbound codes only).
48
+ -h, --help Show this message and exit.`,
49
+ config: `Usage: aweshare agent config [COMMAND]
50
+
51
+ Show or edit the config (default: path).
52
+
53
+ Commands:
54
+ path Print the config path.
55
+ show Show the config with secrets redacted.
56
+ edit Open the config in $VISUAL, $EDITOR or vi.`,
57
+ doctor: `Usage: aweshare agent doctor
58
+
59
+ Pre-flight checks: config validity, backend reachability, hub connectivity.
60
+
61
+ Options:
62
+ -h, --help Show this message and exit.`,
63
+ start: `Usage: aweshare agent start
64
+
65
+ Connect to the hub, register offerings, relay requests (runs in the foreground).
66
+
67
+ Options:
68
+ -h, --help Show this message and exit.`,
69
+ grant: `Usage: aweshare agent grant [OPTIONS]
70
+
71
+ Allow a consumer to call your offering.
72
+
73
+ Options:
74
+ --alias ALIAS The offering alias, e.g. your-name/model (required).
75
+ --consumer NAME Who may call it (required).
76
+ --expires-in D Optional expiry: 90s, 30m, 12h or 7d.
77
+ -h, --help Show this message and exit.`,
78
+ revoke: `Usage: aweshare agent revoke [OPTIONS]
79
+
80
+ Remove a grant.
81
+
82
+ Options:
83
+ --alias ALIAS The offering alias (required).
84
+ --consumer NAME Whose grant to remove (required).
85
+ -h, --help Show this message and exit.`,
86
+ list: `Usage: aweshare agent list [OPTIONS]
87
+
88
+ List grants for your namespace.
89
+
90
+ Options:
91
+ --json Print the raw API response instead of a table.
92
+ -h, --help Show this message and exit.`,
93
+ };
42
94
  function parseFlags(argv) {
43
95
  const positional = [];
44
96
  const flags = new Map();
@@ -66,6 +118,12 @@ function fail(message) {
66
118
  console.error(`error: ${message}`);
67
119
  process.exit(1);
68
120
  }
121
+ /** Only `config` takes a positional (its subcommand); every other command is flags-only. */
122
+ function noPositionals(cmd, positional) {
123
+ const arg = positional[0];
124
+ if (arg)
125
+ fail(`unexpected argument '${arg}' — this command takes flags only (see: aweshare agent ${cmd} -h)`);
126
+ }
69
127
  /** Node fetch reports "fetch failed" without the reason; surface the cause. */
70
128
  function errorMessage(err) {
71
129
  if (err instanceof Error) {
@@ -89,13 +147,19 @@ async function main() {
89
147
  console.log(`aweshare agent ${VERSION}`);
90
148
  return;
91
149
  }
92
- if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h' || flags.get('help') === 'true') {
150
+ if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h') {
93
151
  console.log(USAGE);
94
152
  return;
95
153
  }
154
+ const help = COMMAND_HELP[cmd];
155
+ if (help && (positional.includes('-h') || flags.get('help') === 'true')) {
156
+ console.log(help);
157
+ return;
158
+ }
96
159
  const dir = agentDir();
97
160
  switch (cmd) {
98
161
  case 'init': {
162
+ noPositionals(cmd, positional);
99
163
  const configPath = join(dir, 'config.toml');
100
164
  const secretsPath = join(dir, 'secrets.json');
101
165
  if (!existsSync(configPath)) {
@@ -128,6 +192,7 @@ async function main() {
128
192
  return;
129
193
  }
130
194
  case 'join': {
195
+ noPositionals(cmd, positional);
131
196
  const hub = flags.get('hub');
132
197
  const code = flags.get('code');
133
198
  if (!hub || !/^https?:\/\//.test(hub))
@@ -189,30 +254,16 @@ async function main() {
189
254
  }
190
255
  else if (sub === 'show') {
191
256
  if (!existsSync(configPath)) {
192
- fail(`no config at ${configPath} — run 'aweshare agent config init' first`);
257
+ fail(`no config at ${configPath} — run 'aweshare agent init' first`);
193
258
  }
194
259
  console.log(redactConfig(readFileSync(configPath, 'utf8'), existsSync(secretsPath) ? readFileSync(secretsPath, 'utf8') : undefined));
195
260
  }
196
261
  else if (sub === 'init') {
197
- // same as top-level init: write templates only if missing
198
- if (!existsSync(configPath)) {
199
- writeFileAtomic(configPath, CONFIG_TEMPLATE, 0o600);
200
- console.log(`wrote ${configPath}`);
201
- }
202
- else {
203
- console.log(`exists, kept: ${configPath}`);
204
- }
205
- if (!existsSync(secretsPath)) {
206
- writeFileAtomic(secretsPath, SECRETS_TEMPLATE, 0o600);
207
- console.log(`wrote ${secretsPath}`);
208
- }
209
- else {
210
- console.log(`exists, kept: ${secretsPath}`);
211
- }
262
+ fail(`config init is now 'aweshare agent init' (same behavior, plus --hub/--token pre-fill)`);
212
263
  }
213
264
  else if (sub === 'edit') {
214
265
  if (!existsSync(configPath)) {
215
- fail(`no config at ${configPath} — run 'aweshare agent config init' first`);
266
+ fail(`no config at ${configPath} — run 'aweshare agent init' first`);
216
267
  }
217
268
  const editor = process.env.VISUAL ?? process.env.EDITOR ?? 'vi';
218
269
  const child = spawn(editor, [configPath], { stdio: 'inherit' });
@@ -220,11 +271,12 @@ async function main() {
220
271
  return await new Promise(() => { });
221
272
  }
222
273
  else {
223
- fail(`unknown config subcommand: ${sub} (expected path, show, edit or init)`);
274
+ fail(`unknown config subcommand: ${sub} (expected path, show or edit)`);
224
275
  }
225
276
  return;
226
277
  }
227
278
  case 'doctor': {
279
+ noPositionals(cmd, positional);
228
280
  const report = await runDoctor(dir);
229
281
  for (const check of report.checks) {
230
282
  console.log(`${check.ok ? ' ok ' : 'FAIL '} ${check.name}: ${check.detail}`);
@@ -234,6 +286,7 @@ async function main() {
234
286
  return;
235
287
  }
236
288
  case 'start': {
289
+ noPositionals(cmd, positional);
237
290
  const { config, secrets } = loadAgentConfig(dir);
238
291
  const connection = new AgentConnection({
239
292
  config,
@@ -252,6 +305,7 @@ async function main() {
252
305
  case 'grant':
253
306
  case 'revoke':
254
307
  case 'list': {
308
+ noPositionals(cmd, positional);
255
309
  const { config } = loadAgentConfig(dir);
256
310
  const base = config.hubUrl;
257
311
  const auth = { authorization: `Bearer ${config.token}`, 'content-type': 'application/json' };
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EA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,GAAG,CAAC,UAAU,EAAE,CAAC,CAAA;gBAC3E,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;gBACjC,OAAM;YACR,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,kBAAkB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;YACrE,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAE/C,CAAA;YACD,IAAI,CAAC,GAAG,CAAC,EAAE;gBAAE,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAA;YAC3E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;YAC9F,OAAM;QACR,CAAC;QAED;YACE,IAAI,CAAC,oBAAoB,GAAG,OAAO,KAAK,EAAE,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA"}
@@ -1,10 +1,13 @@
1
1
  import type Database from 'better-sqlite3';
2
2
  import type { Logger } from 'pino';
3
3
  import type { AuthContext } from './auth.js';
4
+ import type { HubConfig } from './config.js';
4
5
  import { type Router } from './http.js';
5
6
  export interface AdminDeps {
6
7
  db: Database.Database;
7
8
  auth: AuthContext;
8
9
  log: Logger;
10
+ config: HubConfig;
11
+ onProducerRevoked: (producerId: number) => void;
9
12
  }
10
13
  export declare function registerAdminRoutes(router: Router, deps: AdminDeps): void;
@@ -1,25 +1,38 @@
1
1
  import { parseAlias, roleForToken } from '../../../packages/protocol/dist/index.js';
2
2
  import { requireAdmin, requireConsumer, requireProducer } from './auth.js';
3
- import { addGrant, getConsumerByName, getProducerByName, insertConsumer, insertProducer, listGrants, listTokens, queryUsage, removeGrant, revokeToken, setConsumerConfig, } from './db.js';
3
+ import { addGrant, countActiveProducers, getConsumerById, getConsumerByName, getProducerById, getProducerByName, insertConsumer, insertProducer, listGrants, listTokens, queryUsage, removeGrant, restoreProducer, restoreToken, revokeToken, setConsumerConfig, suspendProducer, } from './db.js';
4
4
  import { HttpError, readJson, sendJson } from './http.js';
5
5
  import { parseLimits, safeParseLimits } from './limits.js';
6
6
  import { generateToken, hashToken } from './tokens.js';
7
- /** Grants are managed by the producer owning the alias namespace, or by admin. */
7
+ /** Producer admission and restore share one scarce resource: active tenant slots. */
8
+ function requireProducerCapacity(db, config) {
9
+ const active = countActiveProducers(db);
10
+ if (active >= config.maxProducers) {
11
+ throw new HttpError(403, 'HUB_FULL', `hub is full (${active} active producers, max ${config.maxProducers}) — suspend one first: aweshare hub revoke --id N`);
12
+ }
13
+ }
14
+ function tokenRoleParam(raw) {
15
+ if (raw === 'producers')
16
+ return 'producer';
17
+ if (raw === 'consumers')
18
+ return 'consumer';
19
+ throw new HttpError(400, 'INVALID_ROLE', 'path must be /admin/v1/tokens/{producers|consumers}/{id}[/restore]');
20
+ }
21
+ function tokenIdParam(raw) {
22
+ const id = Number(raw);
23
+ if (!Number.isInteger(id))
24
+ throw new HttpError(400, 'INVALID_ID', 'token id must be an integer');
25
+ return id;
26
+ }
27
+ /** Grants are producer-owned: only the producer of the alias namespace may change them. */
8
28
  function authorizeGrantChange(req, auth, alias) {
9
29
  const token = req.headers.authorization?.startsWith('Bearer ')
10
30
  ? req.headers.authorization.slice(7).trim()
11
31
  : null;
12
32
  if (!token)
13
- throw new HttpError(401, 'INVALID_KEY', 'admin or producer token required');
33
+ throw new HttpError(401, 'INVALID_KEY', 'producer token required');
14
34
  if (roleForToken(token) === 'admin') {
15
- requireAdmin(req, auth);
16
- const parsed = parseAlias(alias);
17
- if (!parsed)
18
- throw new HttpError(400, 'PROTOCOL_MISMATCH', `invalid alias: ${alias}`);
19
- const producer = getProducerByName(auth.db, parsed.namespace);
20
- if (!producer)
21
- throw new HttpError(404, 'ALIAS_NOT_FOUND', `unknown producer namespace: ${parsed.namespace}`);
22
- return { producerId: producer.id };
35
+ throw new HttpError(403, 'NOT_GRANTED', 'grants are producer-owned — manage them with the producer token (aweshare agent grant)');
23
36
  }
24
37
  if (roleForToken(token) === 'consumer') {
25
38
  throw new HttpError(403, 'NOT_GRANTED', 'consumer keys cannot manage grants');
@@ -42,6 +55,9 @@ export function registerAdminRoutes(router, deps) {
42
55
  if (typeof body.name !== 'string' || !/^[a-z0-9][a-z0-9-]{1,31}$/.test(body.name)) {
43
56
  throw new HttpError(400, 'INVALID_NAME', 'name must match ^[a-z0-9][a-z0-9-]{1,31}$ (it becomes the alias namespace for producers)');
44
57
  }
58
+ if (getProducerByName(db, body.name) || getConsumerByName(db, body.name)) {
59
+ throw new HttpError(409, 'NAME_TAKEN', `the name '${body.name}' is already in use`);
60
+ }
45
61
  let email = null;
46
62
  if (body.email !== undefined) {
47
63
  if (typeof body.email !== 'string' || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(body.email)) {
@@ -49,37 +65,62 @@ export function registerAdminRoutes(router, deps) {
49
65
  }
50
66
  email = body.email;
51
67
  }
68
+ if (body.role === 'producer')
69
+ requireProducerCapacity(db, deps.config);
52
70
  const token = generateToken(body.role);
53
71
  const tokenHash = hashToken(token, auth.pepper);
54
72
  const row = body.role === 'producer'
55
- ? insertProducer(db, body.name, tokenHash, email, token)
56
- : insertConsumer(db, body.name, tokenHash, token);
73
+ ? insertProducer(db, body.name, tokenHash, email)
74
+ : insertConsumer(db, body.name, tokenHash);
57
75
  deps.log.info({ role: body.role, name: body.name }, 'token issued');
58
76
  sendJson(ctx.res, 201, { id: row.id, role: body.role, name: row.name, token });
59
77
  });
60
78
  router.add('GET', '/admin/v1/tokens', (ctx) => {
61
79
  requireAdmin(ctx.req, auth);
62
- // ?reveal=true adds each row's stored plaintext (post-v4 issuances only)
63
- // admin-only by construction, but it is the secret itself: log nothing.
64
- sendJson(ctx.res, 200, listTokens(db, ctx.query.get('reveal') === 'true'));
80
+ sendJson(ctx.res, 200, listTokens(db));
65
81
  });
66
82
  router.add('DELETE', '/admin/v1/tokens/:role/:id', (ctx) => {
67
83
  requireAdmin(ctx.req, auth);
68
- const role = ctx.params.role === 'producers'
69
- ? 'producer'
70
- : ctx.params.role === 'consumers'
71
- ? 'consumer'
72
- : null;
73
- if (role !== 'producer' && role !== 'consumer') {
74
- throw new HttpError(400, 'INVALID_ROLE', 'path must be /admin/v1/tokens/{producers|consumers}/{id}');
75
- }
76
- const id = Number(ctx.params.id);
77
- if (!Number.isInteger(id))
78
- throw new HttpError(400, 'INVALID_ID', 'token id must be an integer');
79
- revokeToken(db, role, id);
80
- deps.log.info({ role, id }, 'token revoked');
84
+ const role = tokenRoleParam(ctx.params.role);
85
+ const id = tokenIdParam(ctx.params.id);
86
+ if (role === 'producer') {
87
+ // suspension also flags the invite that redeemed this producer — one
88
+ // pairing, one state, whichever handle the operator revokes through
89
+ suspendProducer(db, id);
90
+ deps.onProducerRevoked(id);
91
+ }
92
+ else {
93
+ revokeToken(db, role, id);
94
+ }
95
+ deps.log.info({ role, id }, 'token suspended (restorable)');
81
96
  sendJson(ctx.res, 200, { revoked: true, role, id });
82
97
  });
98
+ // The undo of DELETE above: revocation is reversible suspension, and slots
99
+ // freed by a revoke are retaken here — restoring re-runs the capacity check.
100
+ router.add('POST', '/admin/v1/tokens/:role/:id/restore', (ctx) => {
101
+ requireAdmin(ctx.req, auth);
102
+ const role = tokenRoleParam(ctx.params.role);
103
+ const id = tokenIdParam(ctx.params.id);
104
+ if (role === 'producer') {
105
+ const producer = getProducerById(db, id);
106
+ if (!producer)
107
+ throw new HttpError(404, 'NOT_FOUND', `no producer token with id ${id}`);
108
+ if (producer.revoked_at)
109
+ requireProducerCapacity(db, deps.config);
110
+ const restored = restoreProducer(db, id);
111
+ if (restored)
112
+ deps.log.info({ role, id }, 'producer token restored');
113
+ sendJson(ctx.res, 200, { restored, role, id });
114
+ return;
115
+ }
116
+ const consumer = getConsumerById(db, id);
117
+ if (!consumer)
118
+ throw new HttpError(404, 'NOT_FOUND', `no consumer token with id ${id}`);
119
+ const restored = restoreToken(db, role, id);
120
+ if (restored)
121
+ deps.log.info({ role, id }, 'consumer token restored');
122
+ sendJson(ctx.res, 200, { restored, role, id });
123
+ });
83
124
  router.add('PUT', '/admin/v1/grants', async (ctx) => {
84
125
  const body = (await readJson(ctx.req, 64 * 1024));
85
126
  if (typeof body.alias !== 'string' || typeof body.consumer !== 'string') {