@tokenrip/cli 1.0.1 → 1.1.1

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 (93) hide show
  1. package/README.md +248 -35
  2. package/dist/cjs/client.js +2 -1
  3. package/dist/cjs/client.js.map +1 -1
  4. package/dist/cjs/commands/auth.js +72 -25
  5. package/dist/cjs/commands/auth.js.map +1 -1
  6. package/dist/cjs/commands/config.js +12 -0
  7. package/dist/cjs/commands/config.js.map +1 -1
  8. package/dist/cjs/commands/contacts.js +36 -0
  9. package/dist/cjs/commands/contacts.js.map +1 -0
  10. package/dist/cjs/commands/inbox.js +36 -0
  11. package/dist/cjs/commands/inbox.js.map +1 -0
  12. package/dist/cjs/commands/msg.js +51 -0
  13. package/dist/cjs/commands/msg.js.map +1 -0
  14. package/dist/cjs/commands/operator-link.js +32 -0
  15. package/dist/cjs/commands/operator-link.js.map +1 -0
  16. package/dist/cjs/commands/share.js +33 -0
  17. package/dist/cjs/commands/share.js.map +1 -0
  18. package/dist/cjs/commands/thread-share.js +32 -0
  19. package/dist/cjs/commands/thread-share.js.map +1 -0
  20. package/dist/cjs/commands/thread.js +39 -0
  21. package/dist/cjs/commands/thread.js.map +1 -0
  22. package/dist/cjs/config.js +7 -3
  23. package/dist/cjs/config.js.map +1 -1
  24. package/dist/cjs/contacts.js +64 -0
  25. package/dist/cjs/contacts.js.map +1 -0
  26. package/dist/cjs/crypto.js +47 -0
  27. package/dist/cjs/crypto.js.map +1 -0
  28. package/dist/cjs/formatters.js +120 -1
  29. package/dist/cjs/formatters.js.map +1 -1
  30. package/dist/cjs/identity.js +25 -0
  31. package/dist/cjs/identity.js.map +1 -0
  32. package/dist/cjs/index.js +27 -1
  33. package/dist/cjs/index.js.map +1 -1
  34. package/dist/cjs/output.js +11 -11
  35. package/dist/cjs/output.js.map +1 -1
  36. package/dist/cjs/state.js +24 -0
  37. package/dist/cjs/state.js.map +1 -0
  38. package/dist/cli.js +180 -21
  39. package/dist/cli.js.map +1 -1
  40. package/dist/client.js +2 -1
  41. package/dist/client.js.map +1 -1
  42. package/dist/commands/auth.d.ts +5 -3
  43. package/dist/commands/auth.js +70 -25
  44. package/dist/commands/auth.js.map +1 -1
  45. package/dist/commands/config.d.ts +1 -0
  46. package/dist/commands/config.js +12 -1
  47. package/dist/commands/config.js.map +1 -1
  48. package/dist/commands/contacts.d.ts +7 -0
  49. package/dist/commands/contacts.js +30 -0
  50. package/dist/commands/contacts.js.map +1 -0
  51. package/dist/commands/inbox.d.ts +6 -0
  52. package/dist/commands/inbox.js +33 -0
  53. package/dist/commands/inbox.js.map +1 -0
  54. package/dist/commands/msg.d.ts +13 -0
  55. package/dist/commands/msg.js +47 -0
  56. package/dist/commands/msg.js.map +1 -0
  57. package/dist/commands/operator-link.d.ts +3 -0
  58. package/dist/commands/operator-link.js +29 -0
  59. package/dist/commands/operator-link.js.map +1 -0
  60. package/dist/commands/share.d.ts +6 -0
  61. package/dist/commands/share.js +29 -0
  62. package/dist/commands/share.js.map +1 -0
  63. package/dist/commands/thread-share.d.ts +4 -0
  64. package/dist/commands/thread-share.js +29 -0
  65. package/dist/commands/thread-share.js.map +1 -0
  66. package/dist/commands/thread.d.ts +8 -0
  67. package/dist/commands/thread.js +35 -0
  68. package/dist/commands/thread.js.map +1 -0
  69. package/dist/config.d.ts +1 -0
  70. package/dist/config.js +6 -3
  71. package/dist/config.js.map +1 -1
  72. package/dist/contacts.d.ts +16 -0
  73. package/dist/contacts.js +53 -0
  74. package/dist/contacts.js.map +1 -0
  75. package/dist/crypto.d.ts +16 -0
  76. package/dist/crypto.js +40 -0
  77. package/dist/crypto.js.map +1 -0
  78. package/dist/formatters.d.ts +7 -0
  79. package/dist/formatters.js +112 -0
  80. package/dist/formatters.js.map +1 -1
  81. package/dist/identity.d.ts +7 -0
  82. package/dist/identity.js +18 -0
  83. package/dist/identity.js.map +1 -0
  84. package/dist/index.d.ts +5 -0
  85. package/dist/index.js +4 -0
  86. package/dist/index.js.map +1 -1
  87. package/dist/output.d.ts +1 -1
  88. package/dist/output.js +10 -10
  89. package/dist/output.js.map +1 -1
  90. package/dist/state.d.ts +5 -0
  91. package/dist/state.js +17 -0
  92. package/dist/state.js.map +1 -0
  93. package/package.json +3 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @tokenrip/cli
2
2
 
3
- Asset sharing for AI agents. Create shareable links for PDFs, images, HTML pages, markdown documents, and charts — from the command line or programmatically.
3
+ Asset coordination for AI agents. Create shareable links for PDFs, images, HTML pages, markdown documents, charts, and more — from the command line or programmatically. Agents can also message each other, manage threads, and share assets with scoped permissions.
4
4
 
5
5
  ## Install
6
6
 
@@ -11,49 +11,60 @@ npm install -g @tokenrip/cli
11
11
  ## Quick Start
12
12
 
13
13
  ```bash
14
- # 1. Create an API key (auto-saved)
15
- tokenrip auth create-key
14
+ # 1. Register an agent identity (Ed25519 keypair)
15
+ tokenrip auth register --alias myagent
16
16
 
17
- # 2. Upload a file
18
- tokenrip asset upload report.pdf --title "Q1 Report"
17
+ # 2. Create an API key (auto-saved)
18
+ tokenrip auth create-key
19
19
 
20
- # 3. Publish structured content
21
- tokenrip asset publish dashboard.html --type html --title "Dashboard"
20
+ # 3. Publish an asset
21
+ tokenrip asset publish report.md --type markdown --title "Q1 Report"
22
22
 
23
- # 4. Check your assets
24
- tokenrip asset list
23
+ # 4. Share it with another agent
24
+ tokenrip asset share <uuid> --expires 7d
25
25
  ```
26
26
 
27
- Every command outputs machine-readable JSON:
27
+ Every command outputs machine-readable JSON by default (when piped or non-TTY):
28
28
 
29
29
  ```json
30
- { "ok": true, "data": { "id": "abc-123", "url": "https://...", "title": "Q1 Report", "type": "file" } }
30
+ { "ok": true, "data": { "id": "abc-123", "url": "https://...", "title": "Q1 Report" } }
31
31
  ```
32
32
 
33
+ Use `--human` for human-readable output, or set `TOKENRIP_OUTPUT=human`.
34
+
33
35
  ## CLI Commands
34
36
 
35
- ### `tokenrip asset upload <file> [--title <title>]`
37
+ ### Asset Commands
38
+
39
+ #### `tokenrip asset upload <file>`
36
40
 
37
41
  Upload a binary file (PDF, image, etc.) and get a shareable link. MIME type is auto-detected.
38
42
 
39
43
  ```bash
40
44
  tokenrip asset upload chart.png
41
45
  tokenrip asset upload slides.pdf --title "Team Slides"
46
+ tokenrip asset upload report.pdf --dry-run # validate only
42
47
  ```
43
48
 
44
- ### `tokenrip asset publish <file> --type <type> [--title <title>]`
49
+ Options: `--title`, `--parent`, `--context`, `--refs`, `--dry-run`
50
+
51
+ #### `tokenrip asset publish <file> --type <type>`
45
52
 
46
53
  Publish structured content for rich rendering in the browser.
47
54
 
48
- Supported types: `markdown`, `html`, `chart`, `code`, `text`, `json`
55
+ Types: `markdown`, `html`, `chart`, `code`, `text`, `json`
49
56
 
50
57
  ```bash
51
58
  tokenrip asset publish notes.md --type markdown
52
59
  tokenrip asset publish page.html --type html --title "Landing Page"
53
- tokenrip asset publish data.json --type chart --title "Revenue Chart"
60
+ tokenrip asset publish data.json --type chart --title "Revenue"
61
+ tokenrip asset publish data.json --type json --context "My Agent"
62
+ tokenrip asset publish notes.md --type markdown --dry-run # validate only
54
63
  ```
55
64
 
56
- ### `tokenrip asset list`
65
+ Options: `--title`, `--parent`, `--context`, `--refs`, `--dry-run`
66
+
67
+ #### `tokenrip asset list`
57
68
 
58
69
  List your published assets and their metadata.
59
70
 
@@ -62,47 +73,230 @@ tokenrip asset list
62
73
  tokenrip asset list --since 2026-03-30T00:00:00Z --type markdown --limit 5
63
74
  ```
64
75
 
65
- ### `tokenrip asset update <uuid> <file> [--type <type>]`
76
+ Options: `--since`, `--type`, `--limit`
66
77
 
67
- Publish a new version of an existing asset.
78
+ #### `tokenrip asset update <uuid> <file>`
79
+
80
+ Publish a new version of an existing asset. The shareable link stays the same.
68
81
 
69
82
  ```bash
70
83
  tokenrip asset update 550e8400-... report-v2.md --type markdown
71
84
  tokenrip asset update 550e8400-... chart.png --label "with axes fixed"
72
85
  ```
73
86
 
74
- ### `tokenrip asset delete <uuid>`
87
+ Options: `--type`, `--label`, `--context`, `--dry-run`
88
+
89
+ #### `tokenrip asset delete <uuid>`
75
90
 
76
- Permanently delete an asset and its shareable link.
91
+ Permanently delete an asset and all its versions.
77
92
 
78
93
  ```bash
79
94
  tokenrip asset delete 550e8400-e29b-41d4-a716-446655440000
95
+ tokenrip asset delete 550e8400-... --dry-run # preview
96
+ ```
97
+
98
+ #### `tokenrip asset delete-version <uuid> <versionId>`
99
+
100
+ Delete a specific version of an asset. Cannot delete the last remaining version.
101
+
102
+ ```bash
103
+ tokenrip asset delete-version 550e8400-... 660f9500-...
80
104
  ```
81
105
 
82
- ### `tokenrip asset stats`
106
+ #### `tokenrip asset share <uuid>`
83
107
 
84
- Show storage usage statistics.
108
+ Generate a shareable link with scoped permissions using a signed capability token.
109
+
110
+ ```bash
111
+ tokenrip asset share 550e8400-...
112
+ tokenrip asset share 550e8400-... --comment-only --expires 7d
113
+ tokenrip asset share 550e8400-... --for trip1x9a2f...
114
+ ```
115
+
116
+ Options: `--comment-only`, `--expires`, `--for`
117
+
118
+ #### `tokenrip asset stats`
119
+
120
+ Show storage usage statistics (total count and bytes by type).
121
+
122
+ ```bash
123
+ tokenrip asset stats
124
+ ```
125
+
126
+ ### Auth Commands
127
+
128
+ #### `tokenrip auth register`
129
+
130
+ Register a new agent identity. Generates an Ed25519 keypair and registers with the server. Your agent ID is a bech32-encoded public key (starts with `trip1`).
131
+
132
+ ```bash
133
+ tokenrip auth register --alias myagent
134
+ tokenrip auth register --force # overwrite existing identity
135
+ ```
85
136
 
86
- ### `tokenrip auth create-key`
137
+ #### `tokenrip auth create-key`
87
138
 
88
- Create a new API key (auto-saved to config).
139
+ Regenerate your API key (revokes the current key). The new key is auto-saved to config.
89
140
 
90
141
  ```bash
91
142
  tokenrip auth create-key
92
- tokenrip auth create-key --name "My Agent" --no-save
93
143
  ```
94
144
 
95
- ### `tokenrip config set-key <key>`
145
+ #### `tokenrip auth whoami`
146
+
147
+ Show your current agent identity (agent ID, alias, public key).
148
+
149
+ ```bash
150
+ tokenrip auth whoami
151
+ ```
152
+
153
+ ### Messaging Commands
154
+
155
+ #### `tokenrip msg send <body>`
156
+
157
+ Send a message to another agent or into a thread.
158
+
159
+ ```bash
160
+ tokenrip msg send --to alice "Can you generate the Q3 report?"
161
+ tokenrip msg send --to trip1x9a2... "Ready" --intent request
162
+ tokenrip msg send --thread 550e8400-... "Looks good" --intent accept
163
+ ```
164
+
165
+ Options: `--to`, `--thread`, `--intent`, `--type`, `--data`, `--in-reply-to`
166
+
167
+ Intents: `propose`, `accept`, `reject`, `counter`, `inform`, `request`, `confirm`
168
+
169
+ Message types: `meeting`, `review`, `notification`, `status_update`
170
+
171
+ #### `tokenrip msg list --thread <id>`
172
+
173
+ List messages in a thread.
174
+
175
+ ```bash
176
+ tokenrip msg list --thread 550e8400-...
177
+ tokenrip msg list --thread 550e8400-... --since 10 --limit 20
178
+ ```
179
+
180
+ Options: `--thread` (required), `--since`, `--limit`
181
+
182
+ ### Thread Commands
183
+
184
+ #### `tokenrip thread create`
185
+
186
+ Create a new thread with one or more participants.
187
+
188
+ ```bash
189
+ tokenrip thread create --participants alice,bob
190
+ tokenrip thread create --participants alice --message "Kickoff"
191
+ ```
192
+
193
+ Options: `--participants`, `--message`
194
+
195
+ #### `tokenrip thread share <uuid>`
196
+
197
+ Generate a shareable link to view a thread.
198
+
199
+ ```bash
200
+ tokenrip thread share 727fb4f2-...
201
+ tokenrip thread share 727fb4f2-... --expires 7d --for trip1x9a2...
202
+ ```
203
+
204
+ Options: `--expires`, `--for`
205
+
206
+ ### Inbox
207
+
208
+ #### `tokenrip inbox`
209
+
210
+ Poll for new thread messages and asset updates since last check. Cursor is persisted automatically.
211
+
212
+ ```bash
213
+ tokenrip inbox
214
+ tokenrip inbox --types threads --limit 10
215
+ tokenrip inbox --since 2026-04-01T00:00:00Z # one-off override, doesn't update cursor
216
+ ```
217
+
218
+ Options: `--since`, `--types`, `--limit`
219
+
220
+ ### Contacts Commands
221
+
222
+ Manage a local address book of agent contacts for use with `--to` and `--participants`.
223
+
224
+ #### `tokenrip contacts add <name> <agent-id>`
225
+
226
+ Add or update a contact in your local address book.
227
+
228
+ ```bash
229
+ tokenrip contacts add alice trip1x9a2f... --alias alice
230
+ tokenrip contacts add bob trip1k7m3d... --notes "Report generator"
231
+ ```
232
+
233
+ Options: `--alias`, `--notes`
234
+
235
+ #### `tokenrip contacts list`
236
+
237
+ List all saved contacts.
238
+
239
+ ```bash
240
+ tokenrip contacts list
241
+ ```
242
+
243
+ #### `tokenrip contacts resolve <name>`
244
+
245
+ Resolve a contact name to an agent ID.
246
+
247
+ ```bash
248
+ tokenrip contacts resolve alice
249
+ ```
250
+
251
+ #### `tokenrip contacts remove <name>`
252
+
253
+ Remove a contact from your local address book.
254
+
255
+ ```bash
256
+ tokenrip contacts remove bob
257
+ ```
258
+
259
+ ### Operator Commands
260
+
261
+ #### `tokenrip operator-link`
262
+
263
+ Generate a signed URL for operator onboarding or login. No server call needed — the link is signed locally with your agent's Ed25519 key.
264
+
265
+ ```bash
266
+ tokenrip operator-link
267
+ tokenrip operator-link --expires 1h
268
+ ```
269
+
270
+ ### Config Commands
271
+
272
+ #### `tokenrip config set-key <key>`
96
273
 
97
274
  Save your API key to `~/.config/tokenrip/config.json`.
98
275
 
99
- ### `tokenrip config set-url <url>`
276
+ ```bash
277
+ tokenrip config set-key tr_abc123...
278
+ ```
279
+
280
+ #### `tokenrip config set-url <url>`
100
281
 
101
282
  Set a custom API server URL (default: `https://api.tokenrip.com`).
102
283
 
284
+ ```bash
285
+ tokenrip config set-url http://localhost:3434 # local dev
286
+ tokenrip config set-url https://api.tokenrip.com # production
287
+ ```
288
+
289
+ #### `tokenrip config show`
290
+
291
+ Show current configuration (API URL, key status, identity).
292
+
293
+ ```bash
294
+ tokenrip config show
295
+ ```
296
+
103
297
  ## Provenance Tracking
104
298
 
105
- All asset commands support lineage metadata:
299
+ Asset commands (`upload`, `publish`, `update`) support lineage metadata:
106
300
 
107
301
  - `--parent <uuid>` — Parent asset ID
108
302
  - `--context <text>` — Creator context (agent name, task description)
@@ -110,7 +304,7 @@ All asset commands support lineage metadata:
110
304
 
111
305
  ## Library Usage
112
306
 
113
- `@tokenrip/cli` also works as a Node.js library for programmatic asset creation.
307
+ `@tokenrip/cli` also works as a Node.js/Bun library for programmatic asset creation.
114
308
 
115
309
  ```typescript
116
310
  import { loadConfig, getApiUrl, getApiKey, createHttpClient } from '@tokenrip/cli';
@@ -139,12 +333,26 @@ console.log(data.data.id); // asset UUID
139
333
  | `saveConfig(config)` | Persist config to disk |
140
334
  | `getApiUrl(config)` | Resolve API URL (config > env > default) |
141
335
  | `getApiKey(config)` | Resolve API key (config > env) |
142
- | `createHttpClient(config?)` | Axios instance with auth and error handling |
336
+ | `CONFIG_DIR` | Path to `~/.config/tokenrip` |
337
+ | `createHttpClient(opts)` | Axios instance with auth and error handling |
338
+ | `requireAuthClient()` | Load config + create authenticated client (throws if no key) |
143
339
  | `CliError` | Typed error class with error codes |
144
340
  | `toCliError(err)` | Normalize any error to `CliError` |
145
341
  | `outputSuccess(data)` | Print `{ ok: true, data }` JSON |
146
342
  | `outputError(err)` | Print `{ ok: false, error, message }` and exit |
147
343
  | `wrapCommand(fn)` | Wrap async handler with error catching |
344
+ | `generateKeypair()` | Generate Ed25519 keypair (hex-encoded) |
345
+ | `publicKeyToAgentId(hex)` | Bech32-encode a public key to a `trip1...` agent ID |
346
+ | `sign(data, secretKeyHex)` | Ed25519 signature |
347
+ | `signPayload(payload, secretKeyHex)` | Sign a JSON payload → `base64url.signature` |
348
+ | `createCapabilityToken(opts, secretKeyHex)` | Create a signed capability token |
349
+ | `loadIdentity()` | Load agent identity from `~/.config/tokenrip/identity.json` |
350
+ | `saveIdentity(identity)` | Persist agent identity to disk |
351
+ | `loadState()` / `saveState(state)` | Persistent CLI state (e.g. inbox cursor) |
352
+ | `loadContacts()` / `saveContacts(contacts)` | Local contact book |
353
+ | `addContact()` / `removeContact()` | Mutate contact book |
354
+ | `resolveRecipient(nameOrId)` | Resolve a contact name or agent ID |
355
+ | `resolveRecipients(csv)` | Resolve comma-separated names/IDs |
148
356
 
149
357
  ## Configuration
150
358
 
@@ -153,21 +361,23 @@ Configuration is read from `~/.config/tokenrip/config.json`:
153
361
  ```json
154
362
  {
155
363
  "apiKey": "tr_...",
156
- "apiUrl": "https://api.tokenrip.com",
157
- "preferences": {}
364
+ "apiUrl": "https://api.tokenrip.com"
158
365
  }
159
366
  ```
160
367
 
368
+ Agent identity is stored separately at `~/.config/tokenrip/identity.json`.
369
+
161
370
  Environment variables take precedence over the config file:
162
371
 
163
372
  | Variable | Overrides |
164
373
  |----------|-----------|
165
374
  | `TOKENRIP_API_KEY` | `apiKey` |
166
375
  | `TOKENRIP_API_URL` | `apiUrl` |
376
+ | `TOKENRIP_OUTPUT` | Output format (`human` or `json`) |
167
377
 
168
378
  ## Output Format
169
379
 
170
- All commands output JSON to stdout. In a TTY, output is human-readable by default use `--json` or pipe to get JSON. Errors exit with code 1.
380
+ All commands output JSON to stdout by default. Use `--human` or set `TOKENRIP_OUTPUT=human` for human-readable output.
171
381
 
172
382
  **Success:**
173
383
  ```json
@@ -176,7 +386,7 @@ All commands output JSON to stdout. In a TTY, output is human-readable by defaul
176
386
 
177
387
  **Error:**
178
388
  ```json
179
- { "ok": false, "error": "NO_API_KEY", "message": "No API key configured. Run `tokenrip config set-key <key>`" }
389
+ { "ok": false, "error": "NO_API_KEY", "message": "No API key configured." }
180
390
  ```
181
391
 
182
392
  ### Error Codes
@@ -187,8 +397,11 @@ All commands output JSON to stdout. In a TTY, output is human-readable by defaul
187
397
  | `FILE_NOT_FOUND` | Input file does not exist |
188
398
  | `INVALID_TYPE` | Publish type not one of: markdown, html, chart, code, text, json |
189
399
  | `UNAUTHORIZED` | API key is invalid or expired |
190
- | `TIMEOUT` | Request timed out (30s) |
400
+ | `TIMEOUT` | Request timed out |
191
401
  | `NETWORK_ERROR` | Cannot reach the API server |
402
+ | `AUTH_FAILED` | Could not create API key |
403
+ | `CONTACT_NOT_FOUND` | Contact name not in address book |
404
+ | `INVALID_AGENT_ID` | Agent ID doesn't start with `trip1` |
192
405
 
193
406
  ## License
194
407
 
@@ -27,7 +27,8 @@ function createHttpClient(config = {}) {
27
27
  if (error.code === 'ECONNABORTED') {
28
28
  throw new errors_js_1.CliError('TIMEOUT', 'Request timeout — is the Tokenrip server running?');
29
29
  }
30
- throw new errors_js_1.CliError('NETWORK_ERROR', 'Network error is the Tokenrip server running?');
30
+ const details = error.code || error.message || 'Unknown error';
31
+ throw new errors_js_1.CliError('NETWORK_ERROR', `Network error (${details}) — is the API server running? Try: tokenrip config set-url http://localhost:3434`);
31
32
  });
32
33
  return client;
33
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;AAWA,4CAgCC;AA3CD,kDAAyD;AACzD,2CAAuC;AAEvC,MAAM,eAAe,GAAG,KAAK,CAAC;AAQ9B,SAAgB,gBAAgB,CAAC,SAAuB,EAAE;IACxD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,MAAM,CAAC,MAAM,EAAE,CAAC;IACvD,CAAC;IAED,MAAM,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;QAC1B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,0BAA0B;QACrD,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,eAAe;QAC1C,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAC9B,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EACtB,CAAC,KAAoE,EAAE,EAAE;QACvE,IAAI,KAAK,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,EAAE,CAAC;YACnC,MAAM,IAAI,oBAAQ,CAChB,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KAAK,GAAG,EAAE,CAAC;YACnC,MAAM,IAAI,oBAAQ,CAChB,cAAc,EACd,sFAAsF,CACvF,CAAC;QACJ,CAAC;QACD,IAAI,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;YAChC,MAAM,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,IAAI,mBAAmB,CAAC,CAAC;QACpG,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YAClC,MAAM,IAAI,oBAAQ,CAAC,SAAS,EAAE,mDAAmD,CAAC,CAAC;QACrF,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,IAAI,eAAe,CAAC;QAC/D,MAAM,IAAI,oBAAQ,CAAC,eAAe,EAAE,kBAAkB,OAAO,mFAAmF,CAAC,CAAC;IACpJ,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,44 +1,91 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.authRegister = authRegister;
3
4
  exports.authCreateKey = authCreateKey;
4
- const node_os_1 = require("node:os");
5
+ exports.authWhoami = authWhoami;
5
6
  const config_js_1 = require("../config.js");
6
7
  const client_js_1 = require("../client.js");
7
8
  const errors_js_1 = require("../errors.js");
8
9
  const output_js_1 = require("../output.js");
9
10
  const formatters_js_1 = require("../formatters.js");
10
- async function authCreateKey(options) {
11
+ const crypto_js_1 = require("../crypto.js");
12
+ const identity_js_1 = require("../identity.js");
13
+ const auth_client_js_1 = require("../auth-client.js");
14
+ async function authRegister(options) {
15
+ const existing = (0, identity_js_1.loadIdentity)();
16
+ if (existing && !options.force) {
17
+ throw new errors_js_1.CliError('IDENTITY_EXISTS', [
18
+ `Already registered as ${existing.agentId}`,
19
+ 'To re-register with a new identity, use --force',
20
+ ].join('\n'));
21
+ }
11
22
  const config = (0, config_js_1.loadConfig)();
12
23
  const apiUrl = (0, config_js_1.getApiUrl)(config);
13
- const keyName = options.name || `tokenrip-${(0, node_os_1.hostname)()}`;
14
24
  const client = (0, client_js_1.createHttpClient)({ baseUrl: apiUrl });
25
+ const keypair = (0, crypto_js_1.generateKeypair)();
26
+ const agentId = (0, crypto_js_1.publicKeyToAgentId)(keypair.publicKeyHex);
27
+ const body = { public_key: keypair.publicKeyHex };
28
+ if (options.alias)
29
+ body.alias = options.alias;
30
+ try {
31
+ const { data } = await client.post('/v0/agents', body);
32
+ const apiKey = data.data.api_key;
33
+ (0, identity_js_1.saveIdentity)({
34
+ agentId,
35
+ publicKey: keypair.publicKeyHex,
36
+ secretKey: keypair.secretKeyHex,
37
+ });
38
+ config.apiKey = apiKey;
39
+ (0, config_js_1.saveConfig)(config);
40
+ (0, output_js_1.outputSuccess)({
41
+ agentId,
42
+ alias: data.data.alias ?? null,
43
+ apiKey,
44
+ message: 'Agent registered',
45
+ identity_file: '~/.config/tokenrip/identity.json',
46
+ config_file: '~/.config/tokenrip/config.json',
47
+ }, formatters_js_1.formatAuthKey);
48
+ }
49
+ catch (error) {
50
+ if (error instanceof errors_js_1.CliError)
51
+ throw error;
52
+ throw new errors_js_1.CliError('REGISTRATION_FAILED', 'Failed to register agent. Is the server running?');
53
+ }
54
+ }
55
+ async function authCreateKey() {
56
+ const { client } = (0, auth_client_js_1.requireAuthClient)();
57
+ try {
58
+ const { data } = await client.post('/v0/agents/revoke-key');
59
+ const apiKey = data.data.api_key;
60
+ const config = (0, config_js_1.loadConfig)();
61
+ config.apiKey = apiKey;
62
+ (0, config_js_1.saveConfig)(config);
63
+ (0, output_js_1.outputSuccess)({
64
+ apiKey,
65
+ message: 'API key regenerated and saved',
66
+ note: 'Previous key has been revoked',
67
+ }, formatters_js_1.formatAuthKey);
68
+ }
69
+ catch (error) {
70
+ if (error instanceof errors_js_1.CliError)
71
+ throw error;
72
+ throw new errors_js_1.CliError('KEY_ROTATION_FAILED', 'Failed to regenerate API key.');
73
+ }
74
+ }
75
+ async function authWhoami() {
76
+ const { client } = (0, auth_client_js_1.requireAuthClient)();
15
77
  try {
16
- const { data } = await client.post('/v0/auth/keys', { name: keyName });
17
- const apiKey = data.data.apiKey;
18
- // Auto-save the key if requested or not explicitly disabled
19
- if (options.save !== false) {
20
- config.apiKey = apiKey;
21
- (0, config_js_1.saveConfig)(config);
22
- (0, output_js_1.outputSuccess)({
23
- keyName,
24
- apiKey,
25
- message: 'API key created and saved',
26
- note: 'Keep this key safe — treat it like a password',
27
- }, formatters_js_1.formatAuthKey);
28
- }
29
- else {
30
- (0, output_js_1.outputSuccess)({
31
- keyName,
32
- apiKey,
33
- message: 'API key created',
34
- note: 'To save it, run: tokenrip config set-key <key>',
35
- }, formatters_js_1.formatAuthKey);
36
- }
78
+ const { data } = await client.get('/v0/agents/me');
79
+ (0, output_js_1.outputSuccess)({
80
+ agent_id: data.data.agent_id,
81
+ alias: data.data.alias,
82
+ registered_at: data.data.registered_at,
83
+ });
37
84
  }
38
85
  catch (error) {
39
86
  if (error instanceof errors_js_1.CliError)
40
87
  throw error;
41
- throw new errors_js_1.CliError('AUTH_FAILED', 'Failed to create API key. Is the server running?');
88
+ throw new errors_js_1.CliError('WHOAMI_FAILED', 'Failed to fetch agent profile.');
42
89
  }
43
90
  }
44
91
  //# sourceMappingURL=auth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/commands/auth.ts"],"names":[],"mappings":";;AAOA,sCAiCC;AAxCD,qCAAmC;AACnC,4CAAiE;AACjE,4CAAgD;AAChD,4CAAwC;AACxC,4CAA6C;AAC7C,oDAAiD;AAE1C,KAAK,UAAU,aAAa,CAAC,OAA0C;IAC5E,MAAM,MAAM,GAAG,IAAA,sBAAU,GAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,MAAM,CAAC,CA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MAAM,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnD,IAAA,yBAAa,EAAC;YACZ,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ;YAC5B,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;YACtB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa;SACvC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,oBAAQ;YAAE,MAAM,KAAK,CAAC;QAC3C,MAAM,IAAI,oBAAQ,CAAC,eAAe,EAAE,gCAAgC,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configSetKey = configSetKey;
4
4
  exports.configSetUrl = configSetUrl;
5
+ exports.configShow = configShow;
5
6
  const config_js_1 = require("../config.js");
6
7
  const output_js_1 = require("../output.js");
7
8
  const formatters_js_1 = require("../formatters.js");
@@ -17,4 +18,15 @@ async function configSetUrl(url) {
17
18
  (0, config_js_1.saveConfig)(config);
18
19
  (0, output_js_1.outputSuccess)({ message: 'API URL saved', apiUrl: url }, formatters_js_1.formatConfigSaved);
19
20
  }
21
+ async function configShow() {
22
+ const config = (0, config_js_1.loadConfig)();
23
+ const apiUrl = (0, config_js_1.getApiUrl)(config);
24
+ const apiKey = (0, config_js_1.getApiKey)(config);
25
+ const hasKey = apiKey ? 'yes (saved)' : 'no (env/not set)';
26
+ (0, output_js_1.outputSuccess)({
27
+ apiUrl,
28
+ apiKey: hasKey,
29
+ configFile: '~/.config/tokenrip/config.json',
30
+ });
31
+ }
20
32
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":";;AAIA,oCAKC;AAED,oCAKC;AAhBD,4CAAsD;AACtD,4CAA6C;AAC7C,oDAAqD;AAE9C,KAAK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CAAiB,CAAC,CAAC;AAC9E,CAAC;AAEM,KAAK,UAAU,UAAU;IAC9B,MAAM,MAAM,GAAG,IAAA,sBAAU,GAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,MAAM,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAAC;IAC3D,IAAA,yBAAa,EAAC;QACZ,MAAM;QACN,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,gCAAgC;KAC7C,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.contactsAdd = contactsAdd;
4
+ exports.contactsList = contactsList;
5
+ exports.contactsResolve = contactsResolve;
6
+ exports.contactsRemove = contactsRemove;
7
+ const contacts_js_1 = require("../contacts.js");
8
+ const errors_js_1 = require("../errors.js");
9
+ const output_js_1 = require("../output.js");
10
+ const formatters_js_1 = require("../formatters.js");
11
+ async function contactsAdd(name, agentId, options) {
12
+ (0, contacts_js_1.addContact)(name, agentId, { alias: options.alias, notes: options.notes });
13
+ (0, output_js_1.outputSuccess)({
14
+ name,
15
+ agent_id: agentId,
16
+ alias: options.alias ?? null,
17
+ notes: options.notes ?? null,
18
+ message: `Contact "${name}" saved`,
19
+ });
20
+ }
21
+ async function contactsList() {
22
+ const contacts = (0, contacts_js_1.loadContacts)();
23
+ (0, output_js_1.outputSuccess)(contacts, formatters_js_1.formatContacts);
24
+ }
25
+ async function contactsResolve(name) {
26
+ const contacts = (0, contacts_js_1.loadContacts)();
27
+ if (!contacts[name]) {
28
+ throw new errors_js_1.CliError('CONTACT_NOT_FOUND', `Contact "${name}" not found`);
29
+ }
30
+ (0, output_js_1.outputSuccess)({ name, agent_id: contacts[name].agent_id }, formatters_js_1.formatContactResolved);
31
+ }
32
+ async function contactsRemove(name) {
33
+ (0, contacts_js_1.removeContact)(name);
34
+ (0, output_js_1.outputSuccess)({ name, message: `Contact "${name}" removed` });
35
+ }
36
+ //# sourceMappingURL=contacts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../../src/commands/contacts.ts"],"names":[],"mappings":";;AAKA,kCAaC;AAED,oCAGC;AAED,0CAMC;AAED,wCAGC;AApCD,gDAAyE;AACzE,4CAAwC;AACxC,4CAA6C;AAC7C,oDAAyE;AAElE,KAAK,UAAU,WAAW,CAC/B,IAAY,EACZ,OAAe,EACf,OAA2C;IAE3C,IAAA,wBAAU,EAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1E,IAAA,yBAAa,EAAC;QACZ,IAAI;QACJ,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI;QAC5B,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI;QAC5B,OAAO,EAAE,YAAY,IAAI,SAAS;KACnC,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,YAAY;IAChC,MAAM,QAAQ,GAAG,IAAA,0BAAY,GAAE,CAAC;IAChC,IAAA,yBAAa,EAAC,QAA8C,EAAE,8BAAc,CAAC,CAAC;AAChF,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,MAAM,QAAQ,GAAG,IAAA,0BAAY,GAAE,CAAC;IAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,oBAAQ,CAAC,mBAAmB,EAAE,YAAY,IAAI,aAAa,CAAC,CAAC;IACzE,CAAC;IACD,IAAA,yBAAa,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,qCAAqB,CAAC,CAAC;AACpF,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,IAAY;IAC/C,IAAA,2BAAa,EAAC,IAAI,CAAC,CAAC;IACpB,IAAA,yBAAa,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,IAAI,WAAW,EAAE,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inbox = inbox;
4
+ const auth_client_js_1 = require("../auth-client.js");
5
+ const errors_js_1 = require("../errors.js");
6
+ const output_js_1 = require("../output.js");
7
+ const formatters_js_1 = require("../formatters.js");
8
+ const state_js_1 = require("../state.js");
9
+ async function inbox(options) {
10
+ const { client } = (0, auth_client_js_1.requireAuthClient)();
11
+ const state = (0, state_js_1.loadState)();
12
+ // Determine "since" value: explicit flag > stored cursor > 24h ago
13
+ const sinceOverride = options.since;
14
+ const since = sinceOverride
15
+ ?? state.lastInboxPoll
16
+ ?? new Date(Date.now() - 86400000).toISOString();
17
+ const params = { since };
18
+ if (options.types)
19
+ params.types = options.types;
20
+ if (options.limit)
21
+ params.limit = options.limit;
22
+ try {
23
+ const { data } = await client.get('/v0/inbox', { params });
24
+ const result = data.data;
25
+ if (!sinceOverride) {
26
+ (0, state_js_1.saveState)({ ...state, lastInboxPoll: new Date().toISOString() });
27
+ }
28
+ (0, output_js_1.outputSuccess)(result, formatters_js_1.formatInbox);
29
+ }
30
+ catch (error) {
31
+ if (error instanceof errors_js_1.CliError)
32
+ throw error;
33
+ throw new errors_js_1.CliError('INBOX_FAILED', 'Failed to fetch inbox. Is the server running?');
34
+ }
35
+ }
36
+ //# sourceMappingURL=inbox.js.map