@dccxx/auggiegw 1.0.15 → 1.0.17
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/API.md +96 -0
- package/README.md +33 -0
- package/auggiegw/activate.bru +20 -0
- package/auggiegw/augment-accounts-user-purchased.bru +26 -0
- package/auggiegw/bruno.json +6 -0
- package/auggiegw/environments/dev.bru +3 -0
- package/dist/cli.js +78 -0
- package/package.json +1 -1
package/API.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
### /augment-accounts/user/purchased
|
|
2
|
+
|
|
3
|
+
```shell
|
|
4
|
+
curl --request GET \
|
|
5
|
+
--url 'https://augmentgatewaydev.1app.space/augment-accounts/user/purchased?limit=0&sort=purchased_at&order=desc' \
|
|
6
|
+
--header 'authorization: Bearer {{token}}'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Response:
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"success": true,
|
|
13
|
+
"message": "Purchased accounts retrieved successfully",
|
|
14
|
+
"data": {
|
|
15
|
+
"accounts": [
|
|
16
|
+
{
|
|
17
|
+
"id": "cmhabuchz01wmru01qp3vfkmu",
|
|
18
|
+
"email": "Live2910P-20251028-0155@onkeydepzai.com",
|
|
19
|
+
"creator": "Hung998",
|
|
20
|
+
"description": "tắt toàn bộ IDE và chat new để tránh Die tài khoản",
|
|
21
|
+
"purchaseDate": "30/10/2025",
|
|
22
|
+
"expiryDate": "17/11/2025",
|
|
23
|
+
"status": "not-in-use",
|
|
24
|
+
"quota_used": 0,
|
|
25
|
+
"quota_limit": 50,
|
|
26
|
+
"is_hidden": false,
|
|
27
|
+
"pokemon_id": 836,
|
|
28
|
+
"credit_usage_remaining": null,
|
|
29
|
+
"credit_usage_total": null,
|
|
30
|
+
"credit_usage_current_cycle": null,
|
|
31
|
+
"transaction": {
|
|
32
|
+
"id": "cmhdslbcc0018p401m2dl2pjv",
|
|
33
|
+
"status": "HOLDING",
|
|
34
|
+
"dispute_deadline": "2025-11-06T19:03:13.826Z",
|
|
35
|
+
"can_dispute": true,
|
|
36
|
+
"completed_at": null
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "cmha8ltih01ixru01kzt94r4l",
|
|
41
|
+
"email": "Live2910P-20251028-0086@onkeydepzai.com",
|
|
42
|
+
"creator": "Hung998",
|
|
43
|
+
"description": "tắt toàn bộ IDE và chat new để tránh Die tài khoản",
|
|
44
|
+
"purchaseDate": "30/10/2025",
|
|
45
|
+
"expiryDate": "17/11/2025",
|
|
46
|
+
"status": "in-use",
|
|
47
|
+
"quota_used": 5,
|
|
48
|
+
"quota_limit": 50,
|
|
49
|
+
"is_hidden": false,
|
|
50
|
+
"pokemon_id": 578,
|
|
51
|
+
"credit_usage_remaining": 12492,
|
|
52
|
+
"credit_usage_total": 34000,
|
|
53
|
+
"credit_usage_current_cycle": 0,
|
|
54
|
+
"transaction": {
|
|
55
|
+
"id": "cmhd5d85l0833ru014u49p8w1",
|
|
56
|
+
"status": "HOLDING",
|
|
57
|
+
"dispute_deadline": "2025-11-06T08:13:05.282Z",
|
|
58
|
+
"can_dispute": true,
|
|
59
|
+
"completed_at": null
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"pagination": {
|
|
64
|
+
"page": 1,
|
|
65
|
+
"limit": 2,
|
|
66
|
+
"total": 2,
|
|
67
|
+
"totalPages": 1
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### /augment-accounts/:account_id/activate
|
|
74
|
+
|
|
75
|
+
```shell
|
|
76
|
+
curl --request PUT \
|
|
77
|
+
--url https://augmentgatewaydev.1app.space/augment-accounts/cmha8ltih01ixru01kzt94r4l/activate \
|
|
78
|
+
--header 'authorization: Bearer {{token}}'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Response:
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"success": true,
|
|
85
|
+
"message": "Account activation completed successfully",
|
|
86
|
+
"data": {
|
|
87
|
+
"activatedAccount": {
|
|
88
|
+
"id": "cmha8ltih01ixru01kzt94r4l",
|
|
89
|
+
"email": "Live2910P-20251028-0086@onkeydepzai.com",
|
|
90
|
+
"in_use": true
|
|
91
|
+
},
|
|
92
|
+
"deactivatedCount": 0,
|
|
93
|
+
"message": "Account was already active"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ A CLI tool for managing Augment Gateway authentication, proxy configuration, and
|
|
|
9
9
|
- 📝 **Custom Prompts**: Fetch and save custom prompts to `~/.augment/commands/`
|
|
10
10
|
- 🔄 **Auggie Integration**: Seamlessly forward commands to the Auggie CLI
|
|
11
11
|
- ⚡ **Command Execution**: Execute any command with automatic session setup
|
|
12
|
+
- 🔀 **Account Switching**: Automatically switch between purchased accounts
|
|
12
13
|
|
|
13
14
|
## Installation
|
|
14
15
|
|
|
@@ -191,6 +192,38 @@ auggiegw --preserve-session exec node script.js
|
|
|
191
192
|
|
|
192
193
|
---
|
|
193
194
|
|
|
195
|
+
### `auggiegw switch-account`
|
|
196
|
+
|
|
197
|
+
Automatically switch to a newer account from your purchased account list.
|
|
198
|
+
|
|
199
|
+
**Basic Usage**:
|
|
200
|
+
```bash
|
|
201
|
+
auggiegw switch-account
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**What it does**:
|
|
205
|
+
1. Fetches the list of purchased accounts from the API
|
|
206
|
+
2. Identifies the current account (status "in-use")
|
|
207
|
+
3. Switches to the next newer account (the account before the current one in the descending list)
|
|
208
|
+
4. Activates the new account via the API
|
|
209
|
+
5. Refreshes authentication with the new account (auth only, skips prompts)
|
|
210
|
+
|
|
211
|
+
**Example Output**:
|
|
212
|
+
```
|
|
213
|
+
✔ Successfully switched to account: Live2910P-20251028-0155@onkeydepzai.com
|
|
214
|
+
Refreshing authentication...
|
|
215
|
+
✔ Authentication successful (prompts skipped)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Notes**:
|
|
219
|
+
- The account list is sorted by purchase date in descending order (newest first)
|
|
220
|
+
- The command will fail if there are no newer accounts available
|
|
221
|
+
- After switching, the authentication session is automatically refreshed
|
|
222
|
+
- **The old session is preserved** - chat history and session data are not deleted when switching accounts
|
|
223
|
+
- Custom prompts are not re-fetched during the switch (use `auggiegw fetch` if needed)
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
194
227
|
## Authentication Methods
|
|
195
228
|
|
|
196
229
|
### Method 1: Login Command (Recommended for Local Development)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
meta {
|
|
2
|
+
name: /activate
|
|
3
|
+
type: http
|
|
4
|
+
seq: 2
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
put {
|
|
8
|
+
url: https://augmentgatewaydev.1app.space/augment-accounts/cmha8ltih01ixru01kzt94r4l/activate
|
|
9
|
+
body: none
|
|
10
|
+
auth: inherit
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
headers {
|
|
14
|
+
authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsInVzZXJuYW1lIjoicm9vdCIsImVtYWlsIjoiIiwiZGlzcGxheU5hbWUiOiJSb290IFVzZXIiLCJyb2xlIjoxMDAsInN0YXR1cyI6MSwibG9jYWxSb2xlIjp7InJvbGVUeXBlIjoiQURNSU4iLCJjcmVhdGVkQXQiOiIyMDI1LTA4LTI1VDA5OjQ2OjAyLjM5M1oiLCJ1cGRhdGVkQXQiOiIyMDI1LTA4LTI1VDA5OjQ2OjAyLjM5M1oifSwidGhpcmRQYXJ0eVNlc3Npb24iOnsiYWNjZXNzVG9rZW4iOiIiLCJjb29raWVzIjpbInNlc3Npb249TVRjMk1UUTRPREU1Tm54RVdEaEZRVkZNWDJkQlFVSkZRVVZSUVVGQ2MxODBRVUZDUVZwNlpFaEtjR0p0WTAxQ1FVRkRZVmRSUkdGWE5UQkNRVWxCUVdkYWVtUklTbkJpYldOTlEyZEJTV1JZVG14amJUVm9ZbGRWUjJNelVubGhWelZ1UkVGWlFVSklTblppTTFGSFl6TlNlV0ZYTlc1RVFWbEJRa2hLZG1KSFZVUmhWelV3UWtGTlFWODRaMGRqTTFKNVlWYzFia1JCWjBGQ2JrNHdXVmhTTVdOM1RuQmlibEZGUVdkQlEzeG9pbFVQeXNJQlhiY0ZyTWdsM08yZ3NIOGlEMHFLdmp4aXVjcHk3bjI0d1E9PTsgUGF0aD0vOyBFeHBpcmVzPVR1ZSIsIjI1IE5vdiAyMDI1IDE0OjE2OjM2IEdNVDsgTWF4LUFnZT0yNTkyMDAwIl19LCJxdW90YSI6MCwidXNlZFF1b3RhIjowLCJyZXF1ZXN0Q291bnQiOjAsImdyb3VwIjoiIiwiaWF0IjoxNzYxNDg4MTk2LCJleHAiOjE3OTMwMjQxOTYsImlzcyI6ImF1Z21lbnQtZ2F0ZXdheSJ9.OMnlQ6_aFLjPlAWoLs7z_VQBvu6YtEGbqWnKv06Xxyo
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
settings {
|
|
18
|
+
encodeUrl: false
|
|
19
|
+
timeout: 0
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
meta {
|
|
2
|
+
name: /augment-accounts/user/purchased
|
|
3
|
+
type: http
|
|
4
|
+
seq: 1
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
get {
|
|
8
|
+
url: https://augmentgatewaydev.1app.space/augment-accounts/user/purchased?limit=0&sort=purchased_at&order=desc
|
|
9
|
+
body: none
|
|
10
|
+
auth: inherit
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
params:query {
|
|
14
|
+
limit: 0
|
|
15
|
+
sort: purchased_at
|
|
16
|
+
order: desc
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
headers {
|
|
20
|
+
authorization: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oiIiwiaWF0IjoxNzYxNDg4MTk2LCJleHAiOjE3OTMwMjQxOTYsImlzcyI6ImF1Z21lbnQtZ2F0ZXdheSJ9.OMnlQ6_aFLjPlAWoLs7z_VQBvu6YtEGbqWnKv06Xxyo
|
|
3
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -235,6 +235,38 @@ async function authProxy(proxyId, proxyPassword, apiUrl) {
|
|
|
235
235
|
const data = (await response.json());
|
|
236
236
|
return data;
|
|
237
237
|
}
|
|
238
|
+
async function getPurchasedAccounts(token, apiUrl) {
|
|
239
|
+
const response = await fetch(`${apiUrl}/augment-accounts/user/purchased?limit=0&sort=purchased_at&order=desc`, {
|
|
240
|
+
method: 'GET',
|
|
241
|
+
headers: {
|
|
242
|
+
Authorization: `Bearer ${token}`,
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
if (!response.ok) {
|
|
246
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
247
|
+
}
|
|
248
|
+
const data = (await response.json());
|
|
249
|
+
if (!data.success) {
|
|
250
|
+
throw new Error(data.message || 'Failed to get purchased accounts');
|
|
251
|
+
}
|
|
252
|
+
return data;
|
|
253
|
+
}
|
|
254
|
+
async function activateAccount(accountId, token, apiUrl) {
|
|
255
|
+
const response = await fetch(`${apiUrl}/augment-accounts/${accountId}/activate`, {
|
|
256
|
+
method: 'PUT',
|
|
257
|
+
headers: {
|
|
258
|
+
Authorization: `Bearer ${token}`,
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
if (!response.ok) {
|
|
262
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
263
|
+
}
|
|
264
|
+
const data = (await response.json());
|
|
265
|
+
if (!data.success) {
|
|
266
|
+
throw new Error(data.message || 'Failed to activate account');
|
|
267
|
+
}
|
|
268
|
+
return data;
|
|
269
|
+
}
|
|
238
270
|
async function handleLogin(usernameArg, passwordArg) {
|
|
239
271
|
try {
|
|
240
272
|
const config = loadConfig();
|
|
@@ -376,6 +408,48 @@ async function handleExec(command, args, options) {
|
|
|
376
408
|
process.exit(code ?? 0);
|
|
377
409
|
});
|
|
378
410
|
}
|
|
411
|
+
async function handleSwitchAccount() {
|
|
412
|
+
const spinner = ora('Fetching account list...').start();
|
|
413
|
+
try {
|
|
414
|
+
const config = loadConfig();
|
|
415
|
+
const token = await getAuthToken();
|
|
416
|
+
const accountsResponse = await getPurchasedAccounts(token, config.apiUrl);
|
|
417
|
+
if (!accountsResponse.data.accounts || accountsResponse.data.accounts.length === 0) {
|
|
418
|
+
spinner.fail('No accounts available');
|
|
419
|
+
process.exit(1);
|
|
420
|
+
}
|
|
421
|
+
const accounts = accountsResponse.data.accounts;
|
|
422
|
+
// Find the current account (status "in-use")
|
|
423
|
+
const currentAccountIndex = accounts.findIndex((account) => account.status === 'in-use');
|
|
424
|
+
if (currentAccountIndex === -1) {
|
|
425
|
+
spinner.fail('No account is currently in use');
|
|
426
|
+
process.exit(1);
|
|
427
|
+
}
|
|
428
|
+
// Get the account before the current one (since list is sorted in descending order)
|
|
429
|
+
const nextAccountIndex = currentAccountIndex - 1;
|
|
430
|
+
if (nextAccountIndex < 0) {
|
|
431
|
+
spinner.fail('No newer account available to switch to');
|
|
432
|
+
process.exit(1);
|
|
433
|
+
}
|
|
434
|
+
const nextAccount = accounts[nextAccountIndex];
|
|
435
|
+
const currentAccount = accounts[currentAccountIndex];
|
|
436
|
+
if (!nextAccount || !currentAccount) {
|
|
437
|
+
spinner.fail('Failed to retrieve account information');
|
|
438
|
+
process.exit(1);
|
|
439
|
+
}
|
|
440
|
+
spinner.text = `Switching from ${currentAccount.email} to ${nextAccount.email}...`;
|
|
441
|
+
// Activate the next account
|
|
442
|
+
const activateResponse = await activateAccount(nextAccount.id, token, config.apiUrl);
|
|
443
|
+
spinner.succeed(`Successfully switched to account: ${activateResponse.data.activatedAccount.email}`);
|
|
444
|
+
// Execute account fetch logic again (auth only, preserve session)
|
|
445
|
+
console.log('Refreshing authentication...');
|
|
446
|
+
await handleFetch({ authOnly: true, deleteSession: false });
|
|
447
|
+
}
|
|
448
|
+
catch (error) {
|
|
449
|
+
spinner.fail(`Account switch failed: ${error}`);
|
|
450
|
+
process.exit(1);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
379
453
|
const program = new Command();
|
|
380
454
|
program
|
|
381
455
|
.name('auggiegw')
|
|
@@ -415,5 +489,9 @@ program
|
|
|
415
489
|
const sessionOptions = getSessionOptions(opts);
|
|
416
490
|
handleExec(command, args, sessionOptions);
|
|
417
491
|
});
|
|
492
|
+
program
|
|
493
|
+
.command('switch-account')
|
|
494
|
+
.description('Switch to a newer account from the purchased account list')
|
|
495
|
+
.action(handleSwitchAccount);
|
|
418
496
|
program.parse();
|
|
419
497
|
//# sourceMappingURL=cli.js.map
|