dsh-agy-link 0.6.34 → 0.6.36
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/CHANGELOG.md +28 -0
- package/README.md +2 -2
- package/dist/cli-image.mjs +1359 -621
- package/dist/client.js +428 -166
- package/dist/index.js +21844 -20664
- package/docs/AUTH.md +19 -14
- package/docs/KNOWN-GAPS.md +1 -3
- package/docs/SECURITY-NOTES.md +14 -53
- package/package.json +2 -3
- package/dist/assets/icon.svg +0 -54
- package/dist/assets/mermaid.min.js +0 -3636
- package/dist/mermaid.min.js +0 -3636
- package/docs/REFACTORING-PLAN.md +0 -51
- package/docs/REFACTORING-RESULTS.md +0 -52
- package/docs/adr-012-account-pool.md +0 -58
- package/docs/spec-account-pool.md +0 -229
- package/icon.svg +0 -54
package/docs/REFACTORING-PLAN.md
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Refactoring plan (modular monolith, behavior-preserving)
|
|
2
|
-
|
|
3
|
-
Status: **implemented** on branch `refactor/modular-monolith` (worktree). Results: [REFACTORING-RESULTS.md](./REFACTORING-RESULTS.md).
|
|
4
|
-
Rules: one phase per commit, moves must not change behavior, public surface frozen
|
|
5
|
-
(`AgyAdapter.stream`, `apply`, route paths/status/JSON, command names, config keys, CLI flags).
|
|
6
|
-
|
|
7
|
-
## Guardrails (done)
|
|
8
|
-
- `scripts/check-architecture.mjs`: dependency direction + zero cycles.
|
|
9
|
-
- `scripts/check-budgets.mjs` + `scripts/budgets-allowlist.json`: size ratchet.
|
|
10
|
-
- `npm run verify` = check + architecture + budgets + build + test.
|
|
11
|
-
- `npm run test:coverage`: Node's built-in coverage with thresholds.
|
|
12
|
-
|
|
13
|
-
## Phase 1 (done)
|
|
14
|
-
- `src/common/protocol.ts`: typed `AgyGenerateOptions` (removes option casts).
|
|
15
|
-
- `src/runtime/net/account-env.ts`: one proxy precedence + env assembly.
|
|
16
|
-
- `src/provider/call-context.ts`: purpose/permission/session/workspace resolution.
|
|
17
|
-
- `src/provider/purpose-policy.ts`: aux/tools/binding/effort policy table.
|
|
18
|
-
|
|
19
|
-
## Phase 3 — routes (done)
|
|
20
|
-
`src/index.ts` is 1,634 lines; `apply` is 1,521 and inlines 29 HTTP routes.
|
|
21
|
-
Target:
|
|
22
|
-
- `src/host/services.ts`: `createHostServices(ctx, entryConfig)` returning the shared
|
|
23
|
-
services (cfg/log/bin/store/pool/quota/warmup/translation/adapter/auth/poolAuth/catalog/lastRun).
|
|
24
|
-
- `src/transport/http/respond.ts`: `sendJson`, `methodOf`, `queryParam`, `readBody`.
|
|
25
|
-
- `src/transport/http/router.ts`: `registerRoutes(webServer, services)`.
|
|
26
|
-
- `src/transport/http/routes/{status,pool,auth,config,translate,media}.ts`: move the
|
|
27
|
-
handlers verbatim; each exports `register(reg, services)`.
|
|
28
|
-
- `src/index.ts` keeps: config, service construction, commands/tools, lifecycle, and
|
|
29
|
-
calls `registerRoutes`.
|
|
30
|
-
Acceptance: route paths/methods/status/JSON unchanged; `apply` ≤ 400 lines; 29 routes
|
|
31
|
-
covered by `test/http-contract.test.ts`; `pnpm check` + affected tests green.
|
|
32
|
-
|
|
33
|
-
## Phase 4 — client (done)
|
|
34
|
-
`src/client/index.ts` is 3,031 lines; `apply` is 1,466 and contains the whole settings
|
|
35
|
-
panel + account console. Target files:
|
|
36
|
-
- `api.ts` (postJson/getJson), `status.ts` (cache/poll/useAgyStatus), `icons.ts`,
|
|
37
|
-
`styles.ts` (tokens + global CSS), `hooks/{useConfig,useAccounts,useAuthFlow}.ts`,
|
|
38
|
-
`ui/{Button,Row,Select,Toggle,Modal,Toast,Spinner}.ts`,
|
|
39
|
-
`sections/{SettingsSection,AccountsPanel,ModelsPanel,QuotaPanel}.ts`.
|
|
40
|
-
- `index.ts` only: styles + locale + slot registration (≤ 250 lines).
|
|
41
|
-
Acceptance: same UI behavior; `pnpm check` + `pnpm build`; client tests green; no
|
|
42
|
-
inline button style outside `ui/`.
|
|
43
|
-
|
|
44
|
-
## Phase 2 — adapter (done: spawn/parse/outcome + policy/model modules)
|
|
45
|
-
Extracted `call-context` + `purpose-policy`. Remaining: prompt assembly, attempt
|
|
46
|
-
(spawn/parse), finalize (failure classification/rotation), continuation. Target
|
|
47
|
-
`streamAttempt` ≤ 250 lines, `adapter.ts` ≤ 1,800.
|
|
48
|
-
|
|
49
|
-
## Phase 5 — stateful domain (done: store/admin/refresh/http/token/credentials extracted)
|
|
50
|
-
`pool.ts` → store/selection/admin; `quota.ts` → fetch/parse/buckets; `credential-slot.ts`
|
|
51
|
-
→ state machine. Public methods unchanged; do last, separate release.
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# Refactoring results
|
|
2
|
-
|
|
3
|
-
Branch `refactor/modular-monolith` (git worktree), based on `main` @ v0.6.18.
|
|
4
|
-
|
|
5
|
-
## Before / after
|
|
6
|
-
|
|
7
|
-
| Metric | Before | After |
|
|
8
|
-
| --- | ---: | ---: |
|
|
9
|
-
| `src/index.ts` | 1,634 | **414** |
|
|
10
|
-
| `src/client/index.ts` | 3,031 | **219** |
|
|
11
|
-
| `src/host/adapter.ts` | 3,152 | **593** |
|
|
12
|
-
| `src/host/pool.ts` | 1,179 | **546** |
|
|
13
|
-
| `src/host/quota.ts` | 1,455 | **462** |
|
|
14
|
-
| Longest function (`streamAttempt`) | 1,673 | **384** |
|
|
15
|
-
| Modules | 54 | **205** |
|
|
16
|
-
| Import cycles | 0 | **0** |
|
|
17
|
-
| Tests | 754 | **1021** |
|
|
18
|
-
| Coverage (lines / branches / functions) | 78.79 / 75.73 / 75.82 | **88.44 / 80.94 / 84.09** |
|
|
19
|
-
| Files > 600 lines | 19 | **0** (largest: 597) |
|
|
20
|
-
|
|
21
|
-
New modules:
|
|
22
|
-
- `provider/`: call-context, purpose-policy, account-selection, failure, prompt,
|
|
23
|
-
prompt-text, finalize, span, attempt, attempt-outcome, notices.
|
|
24
|
-
- `transport/http/`: respond, router, routes/{status,pool,auth,config,translate,media}.
|
|
25
|
-
- `domain/`: quota/{buckets,identity,parse}, accounts/{selection,paths,store,admin},
|
|
26
|
-
credentials/{mutex,lock,docs,platform,lease,handoff,resolve,slot,errors}.
|
|
27
|
-
- `features/quota/`: refresh, http, token.
|
|
28
|
-
- `client/`: api, status, icons, styles, global-css, react, ui/*, hooks/*, sections/*,
|
|
29
|
-
toolview/*, images/*, translate-*.ts, mermaid-*.ts.
|
|
30
|
-
- `runtime/agy/`: bin, env, keychain, process, console, db/*.
|
|
31
|
-
- `host/commands/`, `provider/mapper/`, `provider/mirror/`.
|
|
32
|
-
- `host/services.ts` + `host/boot-hygiene.ts` (composition factory).
|
|
33
|
-
|
|
34
|
-
## Verification commands
|
|
35
|
-
```bash
|
|
36
|
-
npm run check # tsc --noEmit
|
|
37
|
-
npm run lint:arch # 103 modules, 0 cycles, 0 direction violations
|
|
38
|
-
npm run lint:budget # 103 files, 17 legacy ratchet entries
|
|
39
|
-
npm run build # host + client + bridge + image CLI
|
|
40
|
-
npm test # 788 pass / 0 fail
|
|
41
|
-
npm run test:coverage # Node coverage gate (85/80/80)
|
|
42
|
-
npm run verify # check + arch + budget + build + test
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Size status
|
|
46
|
-
- **Every source file is ≤ 600 lines** (largest: `src/host/services.ts` 597).
|
|
47
|
-
`scripts/budgets-allowlist.json` is now empty: the budget gate is strict for
|
|
48
|
-
all files, no legacy exceptions.
|
|
49
|
-
- `streamAttempt` is 384 lines; the adapter is a 593-line composition/delegate
|
|
50
|
-
layer. Spawn/parse/outcome, prompt, account selection, failure, finalize and
|
|
51
|
-
span streaming are separate provider modules.
|
|
52
|
-
- Client split is guarded by `test/client-architecture.test.ts`.
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# ADR-012: Multi-Account Pool & Sequential Drain Architecture
|
|
2
|
-
|
|
3
|
-
## Status
|
|
4
|
-
Proposed (2026-08-20)
|
|
5
|
-
|
|
6
|
-
## Context
|
|
7
|
-
Google Antigravity (via agy CLI) provides access to Gemini, Claude (Sonnet/Opus), and GPT-OSS models with generous rate limits. However, heavy agentic workflows (large code refactors, multi-step tool loops, reasoning-heavy turns) can hit per-model rate limits (`429 Too Many Requests`, `RESOURCE_EXHAUSTED`, or upstream capacity warnings).
|
|
8
|
-
|
|
9
|
-
Single-account users face blocking interruptions when an account hits quota. Users with multiple Google accounts (e.g. A, B, C) want to pool their accounts so that when Account A's quota for a model family is exhausted, the system automatically falls back to Account B, then Account C, without manual switching or disrupting active conversations.
|
|
10
|
-
|
|
11
|
-
### Architectural Approaches Considered
|
|
12
|
-
|
|
13
|
-
1. **Reverse-Engineering HTTP/SSE Protocol (The `chaos-03x/dsh-agy` approach)**:
|
|
14
|
-
- *Pros*: Pure TypeScript HTTP requests, sub-millisecond account switching in memory.
|
|
15
|
-
- *Cons*: High ban/risk profile (needs manual fingerprint spoofing), brittle Tool Calling schema translation (frequent 400 Bad Request crashes on Protobuf / JSON-Schema mismatch, as seen in dsh-agy issues #1, #2, #4), loss of agy's 50+ native tools and subagent execution sandbox.
|
|
16
|
-
|
|
17
|
-
2. **Multi-Profile agy CLI Process Isolation (Our chosen approach)**:
|
|
18
|
-
- *Pros*: 100% official Google agy binary execution (zero account ban risk, zero schema translation issues, full native tool execution); clean physical process-level credential isolation via `HOME=~/.dsh/agy-accounts/<id>/`; optional per-account proxy via `ALL_PROXY` injection.
|
|
19
|
-
- *Cons*: Light process spawn overhead (~50-100ms), requires directory management.
|
|
20
|
-
|
|
21
|
-
## Decisions
|
|
22
|
-
|
|
23
|
-
### 1. Multi-Profile Storage Structure
|
|
24
|
-
Each managed account has an isolated home directory under the DSH state directory:
|
|
25
|
-
```
|
|
26
|
-
~/.dsh/agy-accounts/
|
|
27
|
-
├── accounts.json # Metadata index (accounts, proxies, aliases, active order)
|
|
28
|
-
├── acc_a1b2c3/ # Account A isolated environment
|
|
29
|
-
│ └── .gemini/
|
|
30
|
-
│ └── antigravity-cli/ # agy CLI credentials, tokens, settings for Account A
|
|
31
|
-
├── acc_d4e5f6/ # Account B isolated environment
|
|
32
|
-
│ └── .gemini/
|
|
33
|
-
│ └── antigravity-cli/
|
|
34
|
-
```
|
|
35
|
-
Spawning agy for Account $X$ simply injects `HOME=/path/to/~/.dsh/agy-accounts/acc_X/` into `env`. No Docker containers or root privileges required.
|
|
36
|
-
|
|
37
|
-
### 2. Sticky Sequential Drain Strategy (按模型家族顺次耗尽)
|
|
38
|
-
- **Family-Scoped Cooldown**: Quota is tracked per model family (`google`, `anthropic`, `openai`). If Account A hits 429 on Claude 4.6, only Account A's `anthropic` family is marked in cooldown. Account A can still serve Gemini 3.7 Flash requests.
|
|
39
|
-
- **Sticky Affinity**: Requests stick to the first healthy account (e.g., Account A) to maximize conversation continuity and token caching.
|
|
40
|
-
- **Transparent Fallback**: When a request on Account A is refused for an account-scoped reason (429 / quota, region eligibility, transport-flavoured auth, soft capacity), the adapter records the cooldown or rotates the sticky pointer, and the SAME step continues on Account B — either through DSH's automatic retry (the first-span case) or by discarding the dead recording and re-assembling on the next account (the post-tool case). The user experiences no interruption and never resends.
|
|
41
|
-
- Account failover is bounded by the pool: DSH's retry budget is `min(enabled accounts - 1, 2)` retries, and the post-tool failover allows at most `enabled accounts - 1` re-spawns per session inside a 2-minute window. A deterministic (request-level) failure is never failed over, so a broken request cannot loop through the pool re-running its tools.
|
|
42
|
-
- A genuine sign-out (`AUTH`) is retryable only when the pool has another account that may still be signed in; the failed account is flagged `authRequired` and leaves rotation.
|
|
43
|
-
|
|
44
|
-
### 3. Cooldown & Reset Handling
|
|
45
|
-
- If the error contains a server reset time (or `Retry-After`), cooldown is set to `Date.now() + resetMs`.
|
|
46
|
-
- Default cooldown window is 15 minutes (`defaultCooldownMs`, tiered up to 60 minutes on consecutive 429s).
|
|
47
|
-
- Cooldown expires automatically; when Account A recovers, it resumes primary position.
|
|
48
|
-
- Soft capacity refusals ("model overloaded" / high traffic) NEVER set a cooldown: nothing was spent. They rotate the pointer and are retryable anyway, so an idle account can still serve the turn.
|
|
49
|
-
- "All accounts unavailable" reports the real state (N in cooldown, N signed out) with the earliest availability, which includes quota-window resets and not just cooldowns; a reset that is ≤ 20s away is waited out instead of failing the turn.
|
|
50
|
-
|
|
51
|
-
### 4. Optional Per-Account Proxy (防关联支持)
|
|
52
|
-
Each account can optionally specify a dedicated proxy URL (`socks5://...` or `http://...`). When set, `ALL_PROXY` / `HTTPS_PROXY` / `HTTP_PROXY` are scoped exclusively to that account's child process. If unconfigured, it inherits the global host environment proxy.
|
|
53
|
-
|
|
54
|
-
## Consequences
|
|
55
|
-
|
|
56
|
-
- **Reliability**: No 400 schema crashes, full native tools support.
|
|
57
|
-
- **Smooth UX**: Multiple accounts can be registered via Web QR codes or CLI, providing 3x-5x continuous quota.
|
|
58
|
-
- **Safety**: Safe for single-user multiple accounts without requiring heavy containerization.
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
# Comprehensive Specification: Multi-Account Pool, Quota Statistics & Sequential Drain
|
|
2
|
-
|
|
3
|
-
> **Document Type**: Technical Specification & Architecture Design
|
|
4
|
-
> **Status**: Approved for Implementation
|
|
5
|
-
> **Scope**: Host Backend, Account Engine, Quota Statistics, Transparent Retry Pipeline, DSH Attached WebUI, CLI Family
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 1. Executive Summary & Core Tenets
|
|
10
|
-
|
|
11
|
-
### 1.1 Background & Motivation
|
|
12
|
-
In agentic coding workflows using Google Antigravity models (Gemini 3.7 Flash, Claude 4.6 Sonnet/Opus, GPT-OSS 120B), heavy usage can hit rate limits (`429 Too Many Requests`, `RESOURCE_EXHAUSTED`, or upstream capacity warnings).
|
|
13
|
-
|
|
14
|
-
This specification details a **Multi-Account Pool (号池系统)** that enables pooling multiple Google accounts (e.g. Accounts A, B, C) with **Live Quota Statistics (实时配额进度条)**, **Sticky Sequential Drain (按模型家族顺次耗尽)**, **Zero-Interruption In-Flight Fallback (零感知自动重试)**, and full integration into the **DSH Built-in Settings WebUI**.
|
|
15
|
-
|
|
16
|
-
### 1.2 Core Architectural Principles
|
|
17
|
-
1. **Zero Ban Risk via Official CLI Execution**: Execution runs through the official Google `agy` binary (`agy -p ...`). No reverse-engineered chat streaming, no fragile Protobuf schema translation, no spoofed fingerprinting. Full access to agy's 50+ native Agent tools.
|
|
18
|
-
2. **Multi-Profile Directory Isolation (Verified)**: Local process isolation via dedicated `HOME` directories (`~/.dsh/agy-accounts/<id>/`). Zero Docker containers or background daemons. Verified to boot isolated agy processes in ~50ms.
|
|
19
|
-
3. **Live Quota Inspection (实时额度统计)**: Direct upstream query of `v1internal:fetchAvailableModels` to extract `remainingFraction` (0.0~1.0) and `resetTime` per model family (`google`, `anthropic`, `openai`), visually rendered as colorful progress bars in the DSH settings panel.
|
|
20
|
-
4. **Zero-Config Proxy Inheritance (零配置开箱即用)**: All accounts default to inheriting the active system/terminal proxy (`HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`) from DSH. Single-proxy-port users (e.g. Clash on 7890) can use 3+ accounts seamlessly without configuring proxy settings.
|
|
21
|
-
5. **Family-Scoped Precise Cooldown (按模型家族精准冷却)**: Cooldowns are tracked per model family (`google`, `anthropic`, `openai`). A 429 on Claude only cools down Claude; Gemini requests remain active on that same account. Cooldown duration leverages the server's exact `resetTime`.
|
|
22
|
-
6. **Sticky Sequential Drain**: Always prioritize Account A until a specific model family is exhausted, then fail over to Account B, then C. Minimizes context thrashing and maximizes session token cache hits.
|
|
23
|
-
7. **Native DSH WebUI Attachment**: Fully integrated into the native DSH Web interface via `settings.section` slot — zero external ports or separate web servers needed.
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## 2. Multi-Profile Isolation & OAuth Flow (Verified)
|
|
28
|
-
|
|
29
|
-
### 2.1 Directory Structure
|
|
30
|
-
```
|
|
31
|
-
~/.dsh/agy-accounts/
|
|
32
|
-
├── pool.json # Account registry, active mode, and cached quota metadata
|
|
33
|
-
├── acc_1700000000_a1/ # Account A (e.g. work@gmail.com)
|
|
34
|
-
│ └── .gemini/
|
|
35
|
-
│ └── antigravity-cli/
|
|
36
|
-
│ └── antigravity-oauth-token
|
|
37
|
-
├── acc_1700000000_b2/ # Account B (e.g. personal@gmail.com)
|
|
38
|
-
│ └── .gemini/
|
|
39
|
-
│ └── antigravity-cli/
|
|
40
|
-
│ └── antigravity-oauth-token
|
|
41
|
-
└── acc_1700000000_c3/ # Account C (e.g. backup@gmail.com)
|
|
42
|
-
└── .gemini/
|
|
43
|
-
└── antigravity-cli/
|
|
44
|
-
└── antigravity-oauth-token
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### 2.2 Verified Add-Account OAuth Workflow
|
|
48
|
-
```
|
|
49
|
-
[ User clicks: "➕ 添加新 Google 账号" ]
|
|
50
|
-
│
|
|
51
|
-
▼
|
|
52
|
-
1. Backend allocates directory: ~/.dsh/agy-accounts/acc_<id>/
|
|
53
|
-
│
|
|
54
|
-
▼
|
|
55
|
-
2. Generates Google OAuth PKCE authorization URL:
|
|
56
|
-
- Client ID: AGY_PUBLIC_CLIENT_ID (Antigravity Consumer Public OAuth Client)
|
|
57
|
-
- Scopes: cloud-platform, userinfo.email, userinfo.profile, cclog, experimentsandconfigs
|
|
58
|
-
│
|
|
59
|
-
▼
|
|
60
|
-
3. WebUI renders:
|
|
61
|
-
- 👉 Button: Open authorization page in browser (works through local proxy)
|
|
62
|
-
- 📱 Inline Base64 QR code
|
|
63
|
-
- 📋 Authorization code input field
|
|
64
|
-
│
|
|
65
|
-
▼
|
|
66
|
-
[ User authorizes & pastes code back ]
|
|
67
|
-
│
|
|
68
|
-
▼
|
|
69
|
-
4. Backend exchanges code at https://oauth2.googleapis.com/token:
|
|
70
|
-
- Receives: { access_token, refresh_token, expires_in }
|
|
71
|
-
- Resolves email via https://www.googleapis.com/oauth2/v1/userinfo
|
|
72
|
-
- Fetches live quota stats via v1internal:fetchAvailableModels
|
|
73
|
-
│
|
|
74
|
-
▼
|
|
75
|
-
5. Writes token into ~/.dsh/agy-accounts/acc_<id>/.gemini/antigravity-cli/antigravity-oauth-token
|
|
76
|
-
and registers account in pool.json.
|
|
77
|
-
│
|
|
78
|
-
▼
|
|
79
|
-
6. Account is live and immediately ready for use!
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## 3. Real-Time Quota Statistics (实时配额统计)
|
|
85
|
-
|
|
86
|
-
### 3.1 Quota API Endpoint & Payload
|
|
87
|
-
- **Endpoint**: `https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels` (Fallback: `https://daily-cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels`)
|
|
88
|
-
- **Headers**: `Authorization: Bearer <access_token>`, `User-Agent: antigravity/1.1.15 darwin/arm64`
|
|
89
|
-
- **Response Format**:
|
|
90
|
-
```json
|
|
91
|
-
{
|
|
92
|
-
"models": {
|
|
93
|
-
"gemini-3.7-flash": {
|
|
94
|
-
"displayName": "Gemini 3.7 Flash",
|
|
95
|
-
"quotaInfo": {
|
|
96
|
-
"remainingFraction": 0.85,
|
|
97
|
-
"resetTime": "2026-08-20T16:00:00Z"
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
"claude-3-7-sonnet": {
|
|
101
|
-
"displayName": "Claude 3.7 Sonnet",
|
|
102
|
-
"quotaInfo": {
|
|
103
|
-
"remainingFraction": 0.40,
|
|
104
|
-
"resetTime": "2026-08-20T18:30:00Z"
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"gpt-oss-120b-medium": {
|
|
108
|
-
"displayName": "GPT-OSS 120B",
|
|
109
|
-
"quotaInfo": {
|
|
110
|
-
"remainingFraction": 1.0,
|
|
111
|
-
"resetTime": "2026-08-21T00:00:00Z"
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### 3.2 Family-Scoped Quota Aggregation
|
|
119
|
-
Each model maps to a family:
|
|
120
|
-
- **`google`**: `gemini-*`, `gemma-*`
|
|
121
|
-
- **`anthropic`**: `claude-*`
|
|
122
|
-
- **`openai`**: `gpt-*`, `openai/*`
|
|
123
|
-
|
|
124
|
-
For each family $F$:
|
|
125
|
-
$$\text{remainingFraction}(F) = \min_{m \in F} (\text{model.quotaInfo.remainingFraction})$$
|
|
126
|
-
$$\text{resetTime}(F) = \min_{m \in F} (\text{model.quotaInfo.resetTime})$$
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## 4. Scheduling & Transparent Fallback Engine
|
|
131
|
-
|
|
132
|
-
### 4.1 Account Selection Algorithm (Sequential Drain)
|
|
133
|
-
|
|
134
|
-
```
|
|
135
|
-
[ Request: model = "claude-sonnet-4-6", family = "anthropic" ]
|
|
136
|
-
│
|
|
137
|
-
▼
|
|
138
|
-
Get candidate accounts in priority order:
|
|
139
|
-
[ Account A, Account B, Account C ]
|
|
140
|
-
│
|
|
141
|
-
Filter: enabled === true
|
|
142
|
-
│
|
|
143
|
-
Filter: cooldowns['anthropic'].cooldownUntil <= Date.now()
|
|
144
|
-
AND remainingFraction['anthropic'] > 0.05
|
|
145
|
-
│
|
|
146
|
-
┌─────────────┴─────────────┐
|
|
147
|
-
▼ ▼
|
|
148
|
-
Candidates Available? All in Cooldown?
|
|
149
|
-
│ │
|
|
150
|
-
├── Yes: Pick first └── No: Throw POOL_EXHAUSTED
|
|
151
|
-
│ (Account A) (with earliest reset countdown)
|
|
152
|
-
▼
|
|
153
|
-
Spawn agy with Account A (HOME=~/.dsh/agy-accounts/acc_A)
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### 4.2 In-Flight Transparent Fallback (429 Zero-Interruption Retry)
|
|
157
|
-
- When Account A hits 429, `RESOURCE_EXHAUSTED`, or upstream capacity errors:
|
|
158
|
-
1. Record cooldown on Account A for `anthropic`:
|
|
159
|
-
$$\text{cooldownUntil} = \text{server.resetTime} \parallel (\text{Date.now()} + 600\,000)$$
|
|
160
|
-
2. Select next healthy account (Account B).
|
|
161
|
-
3. Re-spawn agy under Account B with the conversation digest prefix.
|
|
162
|
-
4. Stream chunks directly to the caller. The user experiences zero interruption or error modals.
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## 5. DSH Attached WebUI Specification
|
|
167
|
-
|
|
168
|
-
Attached via `settings.section` slot under DSH Settings $\rightarrow$ Antigravity.
|
|
169
|
-
|
|
170
|
-
### 5.1 Visual Mockup with Quota Bars
|
|
171
|
-
|
|
172
|
-
```
|
|
173
|
-
┌──────────────────────────────────────────────────────────────────────────┐
|
|
174
|
-
│ 👥 Antigravity Account Pool (Google 多账号池) │
|
|
175
|
-
│ 调度模式: [ 顺次耗尽 (Sequential Drain) ▾ ] | [ 🔄 刷新全部额度 ] │
|
|
176
|
-
│ 提示: 默认共用本地系统/代理环境,账号 A 额度耗尽自动无缝切换到账号 B │
|
|
177
|
-
├──────────────────────────────────────────────────────────────────────────┤
|
|
178
|
-
│ 1. 🟢 Account A (work@gmail.com) [当前主用] │
|
|
179
|
-
│ 📊 额度余量: │
|
|
180
|
-
│ • Gemini: [████████████████████░░] 85% (重置时间: 16:00) │
|
|
181
|
-
│ • Claude: [████████░░░░░░░░░░░░░░] 40% (重置时间: 18:30) │
|
|
182
|
-
│ • GPT-OSS: [██████████████████████] 100% │
|
|
183
|
-
│ [ 🔍 刷新额度 ] [ ⚙️ 代理设置 ] [ 🔄 重新认证 ] │
|
|
184
|
-
├──────────────────────────────────────────────────────────────────────────┤
|
|
185
|
-
│ 2. 🟡 Account B (personal@gmail.com) │
|
|
186
|
-
│ 📊 额度余量: │
|
|
187
|
-
│ • Gemini: [██████████████████████] 100% │
|
|
188
|
-
│ • Claude: [░░░░░░░░░░░░░░░░░░░░░░] 0% (已耗尽 · 7分12秒后重置) │
|
|
189
|
-
│ • GPT-OSS: [██████████████████████] 100% │
|
|
190
|
-
│ [ 🔍 刷新额度 ] [ ⚙️ 代理设置 ] [ ⬆️ 设为主用 ] [ 🗑️ 移除 ] │
|
|
191
|
-
├──────────────────────────────────────────────────────────────────────────┤
|
|
192
|
-
│ 3. ⚪ Account C (backup@gmail.com) │
|
|
193
|
-
│ 📊 额度余量: │
|
|
194
|
-
│ • Gemini: [██████████████████████] 100% │
|
|
195
|
-
│ • Claude: [██████████████████████] 100% │
|
|
196
|
-
│ • GPT-OSS: [██████████████████████] 100% │
|
|
197
|
-
│ [ 🔍 刷新额度 ] [ ⚙️ 代理设置 ] [ ⬆️ 设为主用 ] [ 🗑️ 移除 ] │
|
|
198
|
-
├──────────────────────────────────────────────────────────────────────────┤
|
|
199
|
-
│ [ ➕ 添加新 Google 账号 (Add Account) ] │
|
|
200
|
-
└──────────────────────────────────────────────────────────────────────────┘
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## 6. Host Web Server Routes
|
|
206
|
-
|
|
207
|
-
All host routes are namespaced under `/plugins/agy-link/`:
|
|
208
|
-
|
|
209
|
-
| Method | Endpoint | Description |
|
|
210
|
-
|---|---|---|
|
|
211
|
-
| `GET` | `/plugins/agy-link/pool` | Get all accounts, live quota bars, cooldown timers, mode |
|
|
212
|
-
| `POST` | `/plugins/agy-link/pool/add` | Allocate a new account slot and generate OAuth URL & QR |
|
|
213
|
-
| `POST` | `/plugins/agy-link/pool/auth-code` | Submit OAuth code, exchange tokens, fetch initial quota |
|
|
214
|
-
| `POST` | `/plugins/agy-link/pool/auth-cancel` | Cancel in-progress OAuth for a slot |
|
|
215
|
-
| `POST` | `/plugins/agy-link/pool/refresh-quota`| Refresh real-time quota for one or all accounts |
|
|
216
|
-
| `POST` | `/plugins/agy-link/pool/remove` | Delete an account directory and its records |
|
|
217
|
-
| `POST` | `/plugins/agy-link/pool/reorder` | Update account priority order |
|
|
218
|
-
| `POST` | `/plugins/agy-link/pool/proxy` | Update optional proxy override for an account |
|
|
219
|
-
| `POST` | `/plugins/agy-link/pool/test` | Test connectivity & quota health of an account slot |
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
## 7. CLI Family Commands
|
|
224
|
-
|
|
225
|
-
- `/agy pool` / `/agy accounts`: Print summary table of pooled accounts, live quota %, and family cooldowns.
|
|
226
|
-
- `/agy add-account [alias]`: Start terminal-guided OAuth login for a new account slot.
|
|
227
|
-
- `/agy refresh-quota [id]`: Fetch fresh quota percentages from Google backend.
|
|
228
|
-
- `/agy remove-account <id>`: Delete an account slot.
|
|
229
|
-
- `/agy clear-cooldown [id]`: Manually reset cooldown timers for accounts. It also lifts the proactive low-quota bench for the cached quota snapshot; the bench re-arms as soon as a quota refresh writes newer data.
|
package/icon.svg
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<defs>
|
|
3
|
-
<!-- Core Orb Gradient -->
|
|
4
|
-
<linearGradient id="agy-orb-gradient" x1="12" y1="11" x2="25" y2="25" gradientUnits="userSpaceOnUse">
|
|
5
|
-
<stop offset="0%" stop-color="#38BDF8"/>
|
|
6
|
-
<stop offset="45%" stop-color="#6366F1"/>
|
|
7
|
-
<stop offset="85%" stop-color="#9333EA"/>
|
|
8
|
-
<stop offset="100%" stop-color="#C026D3"/>
|
|
9
|
-
</linearGradient>
|
|
10
|
-
|
|
11
|
-
<!-- Front Orbit Ring Gradient (Glowing Vibrant Gradient) -->
|
|
12
|
-
<linearGradient id="agy-ring-front" x1="6" y1="24" x2="31" y2="12" gradientUnits="userSpaceOnUse">
|
|
13
|
-
<stop offset="0%" stop-color="#00D2FF"/>
|
|
14
|
-
<stop offset="40%" stop-color="#38BDF8"/>
|
|
15
|
-
<stop offset="70%" stop-color="#818CF8"/>
|
|
16
|
-
<stop offset="100%" stop-color="#F43F5E"/>
|
|
17
|
-
</linearGradient>
|
|
18
|
-
|
|
19
|
-
<!-- Back Orbit Ring Gradient (Subtle Occluded Depth) -->
|
|
20
|
-
<linearGradient id="agy-ring-back" x1="7" y1="12" x2="29" y2="24" gradientUnits="userSpaceOnUse">
|
|
21
|
-
<stop offset="0%" stop-color="#38BDF8" stop-opacity="0.35"/>
|
|
22
|
-
<stop offset="100%" stop-color="#A855F7" stop-opacity="0.35"/>
|
|
23
|
-
</linearGradient>
|
|
24
|
-
|
|
25
|
-
<!-- Specular Highlight Curve -->
|
|
26
|
-
<linearGradient id="agy-highlight-grad" x1="14" y1="12" x2="19" y2="18" gradientUnits="userSpaceOnUse">
|
|
27
|
-
<stop offset="0%" stop-color="#FFFFFF" stop-opacity="0.6"/>
|
|
28
|
-
<stop offset="100%" stop-color="#FFFFFF" stop-opacity="0.05"/>
|
|
29
|
-
</linearGradient>
|
|
30
|
-
</defs>
|
|
31
|
-
|
|
32
|
-
<!-- Back Segment of Orbit Ring (passes behind central sphere) -->
|
|
33
|
-
<path d="M 6.8 14.2 C 8.2 9.6 17.8 7.2 26.2 10.8 C 28.0 11.6 29.3 12.6 30.2 13.8"
|
|
34
|
-
stroke="url(#agy-ring-back)" stroke-width="2.4" stroke-linecap="round"/>
|
|
35
|
-
|
|
36
|
-
<!-- Central Antigravity Sphere -->
|
|
37
|
-
<circle cx="18" cy="18" r="7.5" fill="url(#agy-orb-gradient)"/>
|
|
38
|
-
|
|
39
|
-
<!-- Elegant Crescent Specular Highlight (adds glass/liquid depth) -->
|
|
40
|
-
<path d="M 13.2 15.2 A 5.5 5.5 0 0 1 21.0 13.0 A 6.2 6.2 0 0 0 14.0 18.0 Z"
|
|
41
|
-
fill="url(#agy-highlight-grad)"/>
|
|
42
|
-
|
|
43
|
-
<!-- Front Segment of Orbit Ring (sweeps in front with vibrant glow) -->
|
|
44
|
-
<path d="M 30.2 13.8 C 31.4 18.2 21.8 26.2 12.8 24.2 C 9.4 23.4 7.4 21.8 6.6 19.6"
|
|
45
|
-
stroke="url(#agy-ring-front)" stroke-width="2.6" stroke-linecap="round"/>
|
|
46
|
-
|
|
47
|
-
<!-- Left Satellite Node (DSH Cyan Anchor) -->
|
|
48
|
-
<circle cx="8.2" cy="18.2" r="2.2" fill="#00D2FF"/>
|
|
49
|
-
<circle cx="8.2" cy="18.2" r="1.0" fill="#FFFFFF"/>
|
|
50
|
-
|
|
51
|
-
<!-- Right Satellite Node (Antigravity Magenta Particle) -->
|
|
52
|
-
<circle cx="28.4" cy="20.4" r="1.8" fill="#F43F5E"/>
|
|
53
|
-
<circle cx="28.4" cy="20.4" r="0.8" fill="#FFFFFF"/>
|
|
54
|
-
</svg>
|