aweshare 0.3.6 → 0.3.8

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.
@@ -4,18 +4,65 @@ export declare function formatTable(headers: string[], rows: string[][]): string
4
4
  export declare function fmtTime(iso: string | null | undefined): string;
5
5
  export interface InviteListRow {
6
6
  id: number;
7
+ role: 'producer' | 'consumer';
7
8
  name: string | null;
8
9
  created_at: string;
9
10
  expires_at: string | null;
10
11
  revoked_at: string | null;
11
12
  redeemed_at: string | null;
12
13
  producer_id: number | null;
13
- /** Suspension state of the producer this invite redeemed (NULL while pending). */
14
+ consumer_id: number | null;
15
+ /** Suspension state of the identity this invite redeemed (NULL while pending). */
14
16
  producer_revoked_at?: string | null;
15
- /** The producer token this invite minted (NULL while pending) — shown with --token. */
17
+ consumer_revoked_at?: string | null;
18
+ /** The token this invite minted (NULL while pending) — shown with --token. */
16
19
  producer_name?: string | null;
17
20
  producer_last_seen_at?: string | null;
21
+ consumer_name?: string | null;
22
+ consumer_last_seen_at?: string | null;
18
23
  /** Present only with --reveal — codes stay recoverable, tokens never were. */
19
24
  code?: string | null;
20
25
  }
21
26
  export declare function renderInvites(invites: InviteListRow[], reveal?: boolean, tokens?: boolean): string;
27
+ /** Rows of GET /admin/v1/tokens (hash-only view of the identity tables). */
28
+ export interface ProducerListRow {
29
+ id: number;
30
+ name: string;
31
+ email: string | null;
32
+ created_at: string;
33
+ revoked_at: string | null;
34
+ last_seen_at: string | null;
35
+ }
36
+ export interface ConsumerListRow {
37
+ id: number;
38
+ name: string;
39
+ created_at: string;
40
+ revoked_at: string | null;
41
+ last_seen_at: string | null;
42
+ }
43
+ export declare function renderProducers(rows: ProducerListRow[]): string;
44
+ export declare function renderConsumers(rows: ConsumerListRow[]): string;
45
+ /** Rows of GET /admin/v1/usage (one per proxied request; zero content stored). */
46
+ export interface UsageRow {
47
+ id: number;
48
+ at: string;
49
+ consumer_id: number;
50
+ producer_id: number;
51
+ alias: string;
52
+ upstream_model: string;
53
+ protocol: string;
54
+ streaming: number;
55
+ status: number | null;
56
+ error_code: string | null;
57
+ duration_ms: number;
58
+ bytes_in: number;
59
+ bytes_out: number;
60
+ prompt_tokens: number | null;
61
+ completion_tokens: number | null;
62
+ }
63
+ /**
64
+ * Newest-first usage log; the CLI maps consumer ids to names via the roster
65
+ * (fallback '#id'). Token counts are best-effort — NULL (Ollama streams)
66
+ * renders as '-'.
67
+ */
68
+ export declare function renderUsage(rows: UsageRow[], consumerName: (id: number) => string): string;
@@ -13,12 +13,14 @@ export function fmtTime(iso) {
13
13
  return iso ? `${iso.slice(0, 16).replace('T', ' ')}Z` : '-';
14
14
  }
15
15
  /**
16
- * Lifecycle derived from timestamps: a redeemed code mirrors its producer's
16
+ * Lifecycle derived from timestamps: a redeemed code mirrors its identity's
17
17
  * suspension (used > suspended), then revoked, then expired, else pending.
18
18
  */
19
19
  function inviteStatus(inv, now) {
20
- if (inv.redeemed_at)
21
- return inv.producer_revoked_at ? 'suspended' : 'used';
20
+ if (inv.redeemed_at) {
21
+ const suspended = inv.producer_revoked_at ?? inv.consumer_revoked_at;
22
+ return suspended ? 'suspended' : 'used';
23
+ }
22
24
  if (inv.revoked_at)
23
25
  return 'revoked';
24
26
  if (inv.expires_at && Date.parse(inv.expires_at) <= now)
@@ -31,6 +33,7 @@ export function renderInvites(invites, reveal = false, tokens = false) {
31
33
  const now = Date.now();
32
34
  return formatTable([
33
35
  'ID',
36
+ 'ROLE',
34
37
  'BOUND TO',
35
38
  'CREATED',
36
39
  'EXPIRES',
@@ -39,17 +42,65 @@ export function renderInvites(invites, reveal = false, tokens = false) {
39
42
  ...(reveal ? ['CODE'] : []),
40
43
  ], invites.map((i) => [
41
44
  String(i.id),
45
+ i.role,
42
46
  i.name ?? '-',
43
47
  fmtTime(i.created_at),
44
48
  fmtTime(i.expires_at),
45
49
  inviteStatus(i, now),
46
50
  ...(tokens
47
51
  ? [
48
- i.producer_id !== null ? `#${i.producer_id} ${i.producer_name ?? '-'}` : '-',
49
- fmtTime(i.producer_last_seen_at),
52
+ i.producer_id !== null
53
+ ? `#${i.producer_id} ${i.producer_name ?? '-'}`
54
+ : i.consumer_id !== null
55
+ ? `#${i.consumer_id} ${i.consumer_name ?? '-'}`
56
+ : '-',
57
+ fmtTime(i.producer_last_seen_at ?? i.consumer_last_seen_at),
50
58
  ]
51
59
  : []),
52
60
  ...(reveal ? [i.code ?? '-'] : []),
53
61
  ]));
54
62
  }
63
+ export function renderProducers(rows) {
64
+ if (rows.length === 0)
65
+ return 'no producers — mint invites with: aweshare hub invite --name NAME';
66
+ return formatTable(['ID', 'NAME', 'EMAIL', 'STATUS', 'LAST SEEN', 'CREATED'], rows.map((p) => [
67
+ String(p.id),
68
+ p.name,
69
+ p.email ?? '-',
70
+ p.revoked_at ? 'suspended' : 'active',
71
+ fmtTime(p.last_seen_at),
72
+ fmtTime(p.created_at),
73
+ ]));
74
+ }
75
+ export function renderConsumers(rows) {
76
+ if (rows.length === 0)
77
+ return 'no consumers — invite one with: aweshare hub invite --role consumer --name NAME';
78
+ return formatTable(['ID', 'NAME', 'STATUS', 'LAST SEEN', 'CREATED'], rows.map((c) => [
79
+ String(c.id),
80
+ c.name,
81
+ c.revoked_at ? 'suspended' : 'active',
82
+ fmtTime(c.last_seen_at),
83
+ fmtTime(c.created_at),
84
+ ]));
85
+ }
86
+ /**
87
+ * Newest-first usage log; the CLI maps consumer ids to names via the roster
88
+ * (fallback '#id'). Token counts are best-effort — NULL (Ollama streams)
89
+ * renders as '-'.
90
+ */
91
+ export function renderUsage(rows, consumerName) {
92
+ if (rows.length === 0)
93
+ return 'no usage yet — rows appear after the first consumer request';
94
+ return formatTable(['TIME', 'CONSUMER', 'ALIAS', 'MODEL', 'STATUS', 'TOOK', 'TOKENS'], rows.map((r) => [
95
+ fmtTime(r.at),
96
+ consumerName(r.consumer_id),
97
+ r.alias,
98
+ r.upstream_model,
99
+ r.error_code ? `${r.status ?? '-'} ${r.error_code}` : String(r.status ?? '-'),
100
+ `${r.duration_ms}ms`,
101
+ r.prompt_tokens === null && r.completion_tokens === null
102
+ ? '-'
103
+ : `${r.prompt_tokens ?? 0}+${r.completion_tokens ?? 0}`,
104
+ ]));
105
+ }
55
106
  //# sourceMappingURL=table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"table.js","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAEzF,iFAAiF;AACjF,MAAM,UAAU,WAAW,CAAC,OAAiB,EAAE,IAAgB;IAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/F,MAAM,IAAI,GAAG,CAAC,KAAe,EAAU,EAAE,CACvC,KAAK;SACF,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;SACvC,IAAI,CAAC,IAAI,CAAC;SACV,OAAO,EAAE,CAAA;IACd,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACtD,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,OAAO,CAAC,GAA8B;IACpD,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;AAC7D,CAAC;AAmBD;;;GAGG;A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,IAAI,CAAC,CAAC,iBAAiB,KAAK,IAAI;YACtD,CAAC,CAAC,GAAG;YACL,CAAC,CAAC,GAAG,CAAC,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,CAAC,iBAAiB,IAAI,CAAC,EAAE;KAC1D,CAAC,CACH,CAAA;AACH,CAAC"}
package/bin/aweshare.mjs CHANGED
@@ -27,7 +27,7 @@ Options:
27
27
  -h, --help Show this message and exit.
28
28
 
29
29
  Commands:
30
- hub <command> Run the hub: init, serve, invite, list, revoke, restore.
30
+ hub <command> Run the hub: init, serve, invite, list, limits, usage, revoke, restore.
31
31
  agent <command> Run the producer agent: init, join, config, doctor, start, grant, revoke, list.
32
32
  self-update Update the aweshare CLI itself.`)
33
33
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aweshare",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "type": "module",
5
5
  "description": "Open-source, local-first AI capability relay",
6
6
  "license": "UNLICENSED",