magpie-aside 0.0.0-stage → 0.1.6
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 +102 -0
- package/LICENSE +21 -0
- package/NOTICE +17 -0
- package/README.md +168 -2
- package/README.zh-CN.md +157 -0
- package/icon.svg +8 -0
- package/index.mjs +355 -0
- package/package.json +61 -4
- package/src/auth.mjs +75 -0
- package/src/billing.mjs +59 -0
- package/src/catalog.mjs +203 -0
- package/src/constants.mjs +265 -0
- package/src/credentials.mjs +134 -0
- package/src/fetch.mjs +149 -0
- package/src/google.mjs +217 -0
- package/src/http.mjs +56 -0
- package/src/i18n.mjs +127 -0
- package/src/icon.mjs +5 -0
- package/src/login.mjs +153 -0
- package/src/modes.mjs +39 -0
- package/src/session.mjs +260 -0
- package/src/usage.mjs +96 -0
- package/src/util.mjs +138 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.6 - 2026-11-25
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Every successful refresh writes `token refreshed: expires <iso> (written)` to magpie's plugin log,
|
|
8
|
+
so a long run can be audited after the fact. The session window in the quota card still shows the
|
|
9
|
+
live remaining lifetime.
|
|
10
|
+
|
|
11
|
+
### Verified
|
|
12
|
+
|
|
13
|
+
- A live agent message crossed the refresh boundary at 13:47:30Z: the plugin refreshed with about
|
|
14
|
+
3.5 minutes left, wrote the token back, and the message continued without interruption.
|
|
15
|
+
|
|
16
|
+
## 0.1.5 - 2026-11-25
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- The quota card keeps the token expiry meter alongside the real credit window. The session window is
|
|
21
|
+
display-only (`aside: true`) and shows `Access token valid for ...`, so a long task can be watched
|
|
22
|
+
across a refresh. The billing fallback still uses it when the credit call fails.
|
|
23
|
+
|
|
24
|
+
## 0.1.4 - 2026-11-25
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- `package.json` now declares `magpie.options`, so magpie shows the Options button for the plugin.
|
|
29
|
+
The editor starts from the plugin defaults and accepts raw JSON; `lang`, `showHiddenModels`,
|
|
30
|
+
`allowRefresh`, `dataDir`, `baseOrigin` and `debug` can be set there.
|
|
31
|
+
|
|
32
|
+
## 0.1.3 - 2026-11-25
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Real quota card from `GET /billing/subscription`: plan, monthly credit remaining and grant, percent
|
|
37
|
+
used, reset date and add-on credit. Cached for 60 seconds, with the session-lifetime window as the
|
|
38
|
+
fallback when the call fails.
|
|
39
|
+
|
|
40
|
+
### Verified
|
|
41
|
+
|
|
42
|
+
- `GET /billing/subscription` returned 200 with the account token: `balance_micros` 17,990,498 of an
|
|
43
|
+
18,000,000 grant, `used_percent` 1.
|
|
44
|
+
- The daemon's own `billing.*` tRPC procedures return 401 to a plain local client, so the plugin uses
|
|
45
|
+
the cloud endpoint.
|
|
46
|
+
- 79 tests (78 pass, 1 live skipped).
|
|
47
|
+
|
|
48
|
+
## 0.1.2 - 2026-11-25
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- `showHiddenModels` option (default `false`): also expose the six catalog models hidden by
|
|
53
|
+
`visibleModelIds`, including the 1M-context `glm-5.3`, `glm-5.3-flash`, `deepseek-v4-flash`,
|
|
54
|
+
`deepseek-v4-pro` and `kimi-k3.1`. Plan filtering still applies.
|
|
55
|
+
|
|
56
|
+
### Verified
|
|
57
|
+
|
|
58
|
+
- All six hidden models answered 200 on a `pro` account. `kimi-k3.1`, `glm-5.3` and
|
|
59
|
+
`glm-5.3-flash` spend their first output tokens on reasoning, so a 16-token request returns empty
|
|
60
|
+
content; with 256 tokens they answer normally.
|
|
61
|
+
|
|
62
|
+
## 0.1.1 - 2026-11-25
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- UI language now defaults to `auto` and follows the system locale (`MAGPIE_LANG`, `LC_ALL`,
|
|
67
|
+
`LC_MESSAGES`, `LANG`, then `Intl`). English systems show English method labels; `lang: "zh"` or
|
|
68
|
+
`lang: "en"` still pins a language.
|
|
69
|
+
|
|
70
|
+
## 0.1.0 - 2026-11-25
|
|
71
|
+
|
|
72
|
+
### Added
|
|
73
|
+
|
|
74
|
+
- Provider `aside` with `@ai-sdk/openai-compatible` as the default SDK.
|
|
75
|
+
- Per-model endpoint routing: `@ai-sdk/openai` for `openai-responses`, `@ai-sdk/anthropic` for
|
|
76
|
+
`anthropic-messages`, chat completions for everything else.
|
|
77
|
+
- Catalog from `GET /ai/catalog/v2` with a 60 second cache, plan filtering (`free` < `pro` < `max`)
|
|
78
|
+
and `visibleModelIds` filtering. Built-in 2026-11-25 snapshot as fallback.
|
|
79
|
+
- Sign-in methods: Sign in with Google (opens Aside and adopts the session), read the local Aside
|
|
80
|
+
account, paste an access token.
|
|
81
|
+
- Access token refresh through `POST /auth/token/refresh`, with atomic write-back to
|
|
82
|
+
`accounts.json` and a compare-and-set guard.
|
|
83
|
+
- Loader that injects the browser User-Agent, `x-aside-provider`, `Authorization`, and
|
|
84
|
+
`x-aside-model-id`, rewrites every URL from the configured origin, refuses redirects, and retries
|
|
85
|
+
once after a 401 when the account file changed.
|
|
86
|
+
- Quota card with the plan, the account email and the remaining token lifetime.
|
|
87
|
+
- `chat.headers` hook that forwards magpie's session id as `x-aside-session-id`.
|
|
88
|
+
- Probe and E2E scripts; E2E writes a JSON and Markdown artifact.
|
|
89
|
+
|
|
90
|
+
### Verified
|
|
91
|
+
|
|
92
|
+
- 66 unit tests pass.
|
|
93
|
+
- Live E2E on 2026-11-25: chat streaming, tool calls, Anthropic Messages, OpenAI Responses and
|
|
94
|
+
image input all returned 200 on a `pro` account.
|
|
95
|
+
- The gateway does not rotate the refresh token: two refreshes with the same token both returned
|
|
96
|
+
200 and an identical refresh token.
|
|
97
|
+
|
|
98
|
+
### Known limits
|
|
99
|
+
|
|
100
|
+
- Google sign-in requires the Aside app. The OAuth flow is brokered by Aside's local daemon and
|
|
101
|
+
cannot be completed by a plugin.
|
|
102
|
+
- No usage or billing API is reachable from a plugin, so the quota card shows no consumed amounts.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 magpie-aside contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
magpie-aside
|
|
2
|
+
Copyright (c) 2026 magpie-aside contributors
|
|
3
|
+
|
|
4
|
+
## Interoperability
|
|
5
|
+
|
|
6
|
+
The plugin interoperates with the public HTTP API at api.aside.com. No Aside source code or assets
|
|
7
|
+
are included in this repository.
|
|
8
|
+
|
|
9
|
+
## magpie plugin specification
|
|
10
|
+
|
|
11
|
+
The plugin follows the magpie plugin documentation (https://usemagpie.ai/docs/zh/plugins) and is an
|
|
12
|
+
OpenCode v1 style provider plugin.
|
|
13
|
+
|
|
14
|
+
## Third-party names
|
|
15
|
+
|
|
16
|
+
"Aside" and the model names are trademarks of their respective owners. This plugin is an unofficial
|
|
17
|
+
integration and is not affiliated with or endorsed by Aside.
|
package/README.md
CHANGED
|
@@ -1,3 +1,169 @@
|
|
|
1
|
-
#
|
|
1
|
+
# magpie-aside
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A magpie provider plugin that makes **Aside** subscription models available to every agent as
|
|
4
|
+
`aside/<model>`. It talks to Aside's own AI gateway (`https://api.aside.com/ai/v1`), reads the
|
|
5
|
+
signed-in Aside browser account, and routes each model to the endpoint it actually speaks.
|
|
6
|
+
|
|
7
|
+
> Status: v0.1.6. 81 unit tests green. Live checks on 2026-11-25 passed for chat streaming, tool
|
|
8
|
+
> calls, Anthropic Messages, OpenAI Responses and image input. See [CHANGELOG.md](./CHANGELOG.md).
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
magpie plugin add ./magpie-aside # a local folder
|
|
14
|
+
magpie plugin add magpie-aside # npm, once published
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
In the app: **Plugins -> Add plugin** -> paste the folder path or package name.
|
|
18
|
+
|
|
19
|
+
## Sign in
|
|
20
|
+
|
|
21
|
+
`magpie plugin login aside` offers three methods:
|
|
22
|
+
|
|
23
|
+
| Method | Needs | What it does |
|
|
24
|
+
| ------------------------------------ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
25
|
+
| **Sign in with Google** | the Aside app installed | returns immediately if a fresh session already exists; otherwise opens Aside so you can finish the Google sign-in there, then adopts the new session automatically |
|
|
26
|
+
| **Read the signed-in Aside account** | the Aside browser signed in once | reads `~/.aside/accounts.json` (or `ASIDE_HOME`), refreshes the token if needed, and validates it against the gateway |
|
|
27
|
+
| **Paste an Aside access token** | an access token (JWT) | validates the token with a 1-token request; useful for a quick check or a non-standard install |
|
|
28
|
+
|
|
29
|
+
In the first two methods the key prompt accepts `auto` (the default) meaning "read the local
|
|
30
|
+
account". Typing a token there behaves like the paste method.
|
|
31
|
+
|
|
32
|
+
### About the Google method
|
|
33
|
+
|
|
34
|
+
Aside's Google OAuth is brokered by its local daemon: every tRPC call, including
|
|
35
|
+
`accounts.auth.startGoogleOAuth` and the `/auth/callback/*` endpoints, resolves to
|
|
36
|
+
`http://127.0.0.1:21420`, and the daemon only accepts a session token signed by the browser
|
|
37
|
+
extension. A plugin cannot register a redirect URI or sign that challenge, so it cannot complete the
|
|
38
|
+
consent flow by itself. The plugin therefore launches Aside, lets the app do the Google sign-in, and
|
|
39
|
+
adopts the session it writes.
|
|
40
|
+
|
|
41
|
+
## Use
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
aside/gpt-6-luna # OpenAI Responses
|
|
45
|
+
aside/claude-haiku-5-5 # Anthropic Messages
|
|
46
|
+
aside/gemini-4-argon # Chat Completions
|
|
47
|
+
aside/glm-5.3-flash # Chat Completions
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The catalog is fetched from `/ai/catalog/v2` (no auth, 60 second cache) and filtered by the
|
|
51
|
+
account's plan (`free` < `pro` < `max`) and by `visibleModelIds`. A 2026-11-25 snapshot is built in
|
|
52
|
+
as a fallback for the signed-out state and for catalog outages.
|
|
53
|
+
|
|
54
|
+
| Family | Endpoint | SDK |
|
|
55
|
+
| -------------------- | ------------------------- | ---------------------------------------------- |
|
|
56
|
+
| `openai-responses` | `/ai/v1/responses` | `@ai-sdk/openai` (per-model override) |
|
|
57
|
+
| `anthropic-messages` | `/ai/v1/messages` | `@ai-sdk/anthropic` (per-model override) |
|
|
58
|
+
| chat | `/ai/v1/chat/completions` | `@ai-sdk/openai-compatible` (provider default) |
|
|
59
|
+
|
|
60
|
+
The plugin's loader rewrites every request URL from the configured origin, so credentials only ever
|
|
61
|
+
go to the host you configured.
|
|
62
|
+
|
|
63
|
+
## Quota card
|
|
64
|
+
|
|
65
|
+
The plugin reads the real subscription credit from `GET /billing/subscription` with the account
|
|
66
|
+
token. The card shows:
|
|
67
|
+
|
|
68
|
+
- the plan, the account email and the renewal date,
|
|
69
|
+
- the monthly credit window: remaining and granted amount, percent used and reset date
|
|
70
|
+
(for example `$17.99 / $18.00 left`, resets 2026-12-24),
|
|
71
|
+
- an add-on credit window when the account has one,
|
|
72
|
+
- a display-only session window with the remaining access-token lifetime
|
|
73
|
+
(for example `Access token valid for 52m`), so a long task can be watched across a token refresh.
|
|
74
|
+
|
|
75
|
+
Results are cached for 60 seconds. If the billing call fails, the card falls back to the plan plus
|
|
76
|
+
the session window, so a temporary outage never hides the account. No `used` or `limit` value is
|
|
77
|
+
invented.
|
|
78
|
+
|
|
79
|
+
## Token handling
|
|
80
|
+
|
|
81
|
+
- The access token lasts one hour. The plugin refreshes it when less than five minutes remain.
|
|
82
|
+
- The refresh token is **not** rotated by the gateway. Two refreshes with the same refresh token
|
|
83
|
+
both returned 200 and an identical `refreshToken`, so a refresh does not sign the browser out.
|
|
84
|
+
- A successful refresh is written back to `accounts.json` atomically. The write is skipped if the
|
|
85
|
+
file changed underneath, so a token refreshed by the Aside daemon is never overwritten.
|
|
86
|
+
- The file is read on each use with a 3 second cache; the loader retries a request once after a 401
|
|
87
|
+
when the file has picked up a newer token.
|
|
88
|
+
- Every successful refresh writes a `token refreshed: expires <iso> (written)` line to magpie's
|
|
89
|
+
plugin log, so a long run can be audited after the fact.
|
|
90
|
+
|
|
91
|
+
## Options
|
|
92
|
+
|
|
93
|
+
The plugin declares its defaults in `package.json`, so **Plugins -> installed -> Options** shows a
|
|
94
|
+
raw JSON editor. The CLI equivalent is `magpie plugin options aside '<json>'`. The editor starts from:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"lang": "auto",
|
|
99
|
+
"showHiddenModels": false,
|
|
100
|
+
"allowRefresh": true,
|
|
101
|
+
"dataDir": "",
|
|
102
|
+
"baseOrigin": "https://api.aside.com",
|
|
103
|
+
"debug": false
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
If nothing is saved, the plugin's built-in defaults apply.
|
|
108
|
+
|
|
109
|
+
| Option | Default | Meaning |
|
|
110
|
+
| ------------------ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
111
|
+
| `baseOrigin` | `https://api.aside.com` | upstream origin |
|
|
112
|
+
| `dataDir` | `""` | Aside data dir or `accounts.json` path; empty means `ASIDE_HOME` then `~/.aside` |
|
|
113
|
+
| `lang` | `auto` | UI language: `auto` follows the system locale, or pin `zh` / `en` |
|
|
114
|
+
| `allowRefresh` | `true` | refresh an expired token with `/auth/token/refresh`; set to `false` to only read the file |
|
|
115
|
+
| `showHiddenModels` | `false` | also expose the 6 catalog models that `visibleModelIds` hides, including the 1M-context `glm-5.3`, `glm-5.3-flash`, `deepseek-v4-flash`, `deepseek-v4-pro` and `kimi-k3.1` |
|
|
116
|
+
| `debug` | `false` | verbose `console.error` logging, field names only, never values |
|
|
117
|
+
|
|
118
|
+
## Troubleshooting
|
|
119
|
+
|
|
120
|
+
Run the probe first. It prints the account, the token expiry and the live catalog, and it never
|
|
121
|
+
prints the token:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm run probe
|
|
125
|
+
npm run probe -- --live # adds a 1-token chat request
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
| Symptom | Likely cause | What to do |
|
|
129
|
+
| ------------------------------------------------ | ------------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
130
|
+
| `Aside 登录已失效` / `The Aside sign-in expired` | the token expired and refresh failed | open Aside, or use **Sign in with Google** |
|
|
131
|
+
| `The Aside app was not found` | Aside is not installed in a standard location | install it from `aside.com/download`, or use the paste method |
|
|
132
|
+
| `403` with `error code: 1010` | Cloudflare rejected the User-Agent | check that no host setting overrides the plugin's `User-Agent` |
|
|
133
|
+
| `426` | the model was sent to the wrong endpoint | update the plugin; endpoint selection is per model family |
|
|
134
|
+
| Quota card shows `Access token expired` | the file token is stale and `allowRefresh` is off | re-enable refresh or sign in again |
|
|
135
|
+
| A refresh write fails | `accounts.json` is read-only | the plugin keeps using the refreshed token in memory; fix permissions to persist it |
|
|
136
|
+
|
|
137
|
+
## Security
|
|
138
|
+
|
|
139
|
+
- The access token is sent only to the configured `baseOrigin`; request URLs are rebuilt from that
|
|
140
|
+
origin, never from the incoming URL.
|
|
141
|
+
- Redirects are refused (`redirect: "error"`).
|
|
142
|
+
- Tokens never appear in logs or error messages; `debug` logs field names only.
|
|
143
|
+
- `accounts.json` is read-only for the plugin except for the atomic, compare-and-set write-back of a
|
|
144
|
+
refreshed session.
|
|
145
|
+
- The Google method launches only the Aside binary found under `%ProgramFiles%\Aside\Application`
|
|
146
|
+
(or `/Applications/Aside.app`); it never runs a user-supplied command.
|
|
147
|
+
|
|
148
|
+
## Limitations
|
|
149
|
+
|
|
150
|
+
- Google sign-in requires the Aside app, because the consent flow lives inside it.
|
|
151
|
+
- There is no quota API; the card is plan plus token lifetime.
|
|
152
|
+
- The catalog has no modality field; every model is advertised as text plus image. Image input was
|
|
153
|
+
verified on `gemini-4-argon`; a text-only model will surface its own error.
|
|
154
|
+
- The plugin is an unofficial integration and is not affiliated with Aside.
|
|
155
|
+
|
|
156
|
+
## Development
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npm test # unit tests, offline
|
|
160
|
+
ASIDE_E2E=1 npm test # adds the live gateway test
|
|
161
|
+
npm run e2e # live E2E, writes a local report
|
|
162
|
+
npm run probe # read-only protocol probe
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Chinese README: [README.zh-CN.md](./README.zh-CN.md).
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# magpie-aside
|
|
2
|
+
|
|
3
|
+
把 **Aside** 订阅模型接入任意 agent 的 magpie 供应商插件,模型以 `aside/<model>` 的形式出现。插件直连
|
|
4
|
+
Aside 自己的 AI 网关(`https://api.aside.com/ai/v1`),读取本机已登录的 Aside 浏览器账号,并按模型把请求
|
|
5
|
+
发到它真正使用的端点。
|
|
6
|
+
|
|
7
|
+
> 状态:v0.1.6。81 个单测通过。2026-11-25 真机验证通过:聊天流式、工具调用、Anthropic Messages、
|
|
8
|
+
> OpenAI Responses、图片输入。详情见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
magpie plugin add ./magpie-aside # 本地目录
|
|
14
|
+
magpie plugin add magpie-aside # npm,发布后可用
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
应用内:**插件 -> 添加插件** -> 粘贴目录路径或包名。
|
|
18
|
+
|
|
19
|
+
## 登录
|
|
20
|
+
|
|
21
|
+
`magpie plugin login aside` 提供三种方式:
|
|
22
|
+
|
|
23
|
+
| 方式 | 前提 | 行为 |
|
|
24
|
+
| --------------------------- | ---------------------- | ------------------------------------------------------------------------------------ |
|
|
25
|
+
| **使用 Google 登录** | 已安装 Aside 应用 | 本地已有可用会话时直接成功;否则打开 Aside,在应用里完成 Google 登录后自动接管新会话 |
|
|
26
|
+
| **读取本机 Aside 登录账号** | Aside 浏览器登录过一次 | 读取 `~/.aside/accounts.json`(或 `ASIDE_HOME`),必要时刷新令牌,并向网关验活 |
|
|
27
|
+
| **粘贴 Aside 访问令牌** | 一个访问令牌(JWT) | 用 1 个 token 的请求验活;适合临时排查或非标准安装 |
|
|
28
|
+
|
|
29
|
+
前两种方式的密钥输入框接受 `auto`(默认值),表示"读取本机账号"。直接输入令牌则等同于粘贴方式。
|
|
30
|
+
|
|
31
|
+
### 关于 Google 登录
|
|
32
|
+
|
|
33
|
+
Aside 的 Google OAuth 由它的本地守护进程代理:包括 `accounts.auth.startGoogleOAuth` 和
|
|
34
|
+
`/auth/callback/*` 在内的所有 tRPC 调用都指向 `http://127.0.0.1:21420`,而守护进程只接受由浏览器扩展
|
|
35
|
+
私钥签名的会话令牌。插件既不能注册回调地址,也不能签这个挑战,因此无法独立完成授权流程。插件的做法是:
|
|
36
|
+
打开 Aside,让应用完成 Google 登录,再接管它写入的会话。
|
|
37
|
+
|
|
38
|
+
## 使用
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
aside/gpt-6-luna # OpenAI Responses
|
|
42
|
+
aside/claude-haiku-5-5 # Anthropic Messages
|
|
43
|
+
aside/gemini-4-argon # Chat Completions
|
|
44
|
+
aside/glm-5.3-flash # Chat Completions
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
模型目录来自 `/ai/catalog/v2`(免鉴权,60 秒缓存),按账号套餐(`free` < `pro` < `max`)和
|
|
48
|
+
`visibleModelIds` 过滤。未登录或目录不可用时使用 2026-11-25 的内置快照。
|
|
49
|
+
|
|
50
|
+
| 家族 | 端点 | SDK |
|
|
51
|
+
| -------------------- | ------------------------- | ----------------------------------------- |
|
|
52
|
+
| `openai-responses` | `/ai/v1/responses` | `@ai-sdk/openai`(模型级覆盖) |
|
|
53
|
+
| `anthropic-messages` | `/ai/v1/messages` | `@ai-sdk/anthropic`(模型级覆盖) |
|
|
54
|
+
| chat | `/ai/v1/chat/completions` | `@ai-sdk/openai-compatible`(供应商默认) |
|
|
55
|
+
|
|
56
|
+
插件会从配置的 origin 重建每个请求的 URL,凭据只会发往你配置的主机。
|
|
57
|
+
|
|
58
|
+
## 额度卡片
|
|
59
|
+
|
|
60
|
+
插件用账号令牌读取 `GET /billing/subscription`,展示真实订阅额度:
|
|
61
|
+
|
|
62
|
+
- 套餐、账号邮箱与续费日期;
|
|
63
|
+
- 本月额度窗口:剩余与总额、已用百分比、重置日期(例如 `剩 $17.99 / $18.00`,2026-12-24 重置);
|
|
64
|
+
- 账号有附加额度时,额外显示一个附加额度窗口;
|
|
65
|
+
- 一个只用于展示的会话窗口,显示访问令牌剩余时间(例如 `访问令牌剩余 52 分钟`),方便观察长任务跨越
|
|
66
|
+
令牌刷新。
|
|
67
|
+
|
|
68
|
+
结果缓存 60 秒。计费接口不可用时,回退为套餐加会话窗口,临时故障不会让账号信息消失。不会编造
|
|
69
|
+
`used` 或 `limit`。
|
|
70
|
+
|
|
71
|
+
## 令牌处理
|
|
72
|
+
|
|
73
|
+
- 访问令牌有效期 1 小时。剩余不足 5 分钟时插件会刷新。
|
|
74
|
+
- 网关**不会**轮换 refresh token。用同一个 refresh token 连续刷新两次都返回 200,且返回的
|
|
75
|
+
`refreshToken` 完全相同(实测),因此刷新不会把浏览器踢下线。
|
|
76
|
+
- 刷新成功后原子写回 `accounts.json`;若文件已被其他进程改过则跳过写入,不会覆盖 Aside 守护进程刚写入的
|
|
77
|
+
令牌。
|
|
78
|
+
- 每次使用都读文件(3 秒缓存);请求遇到 401 且文件里已有更新令牌时,自动重试一次。
|
|
79
|
+
- 每次成功刷新都会往 magpie 插件日志写一行 `token refreshed: expires <iso> (written)`,长任务结束后可以
|
|
80
|
+
据此核对刷新记录。
|
|
81
|
+
|
|
82
|
+
## 选项
|
|
83
|
+
|
|
84
|
+
插件在 `package.json` 里声明了默认选项,所以 **插件 -> 已安装 -> 选项** 会出现一个 JSON 编辑框。命令行
|
|
85
|
+
等价写法是 `magpie plugin options aside '<json>'`。编辑框的起始内容:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"lang": "auto",
|
|
90
|
+
"showHiddenModels": false,
|
|
91
|
+
"allowRefresh": true,
|
|
92
|
+
"dataDir": "",
|
|
93
|
+
"baseOrigin": "https://api.aside.com",
|
|
94
|
+
"debug": false
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
没有保存过时,使用插件内置的默认值。
|
|
99
|
+
|
|
100
|
+
| 选项 | 默认值 | 含义 |
|
|
101
|
+
| ------------------ | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
102
|
+
| `baseOrigin` | `https://api.aside.com` | 上游地址 |
|
|
103
|
+
| `dataDir` | `""` | Aside 数据目录或 `accounts.json` 路径;留空按 `ASIDE_HOME`、`~/.aside` 探测 |
|
|
104
|
+
| `lang` | `auto` | 界面语言:`auto` 跟随系统区域设置,也可固定为 `zh` 或 `en` |
|
|
105
|
+
| `allowRefresh` | `true` | 允许用 `/auth/token/refresh` 刷新过期令牌;设为 `false` 则只读文件 |
|
|
106
|
+
| `showHiddenModels` | `false` | 同时暴露被 `visibleModelIds` 隐藏的 6 个模型,包括 1M 上下文的 `glm-5.3`、`glm-5.3-flash`、`deepseek-v4-flash`、`deepseek-v4-pro`、`kimi-k3.1` |
|
|
107
|
+
| `debug` | `false` | 输出调试日志,只记录字段名,绝不记录值 |
|
|
108
|
+
|
|
109
|
+
## 排查
|
|
110
|
+
|
|
111
|
+
先跑探针。它会打印账号、令牌到期时间和实时目录,且不会打印令牌:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm run probe
|
|
115
|
+
npm run probe -- --live # 追加一个 1 token 的聊天请求
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| 现象 | 可能原因 | 处理 |
|
|
119
|
+
| ----------------------------- | -------------------------------------- | -------------------------------------------- |
|
|
120
|
+
| `登录已失效` | 令牌过期且刷新失败 | 打开 Aside,或用 **使用 Google 登录** |
|
|
121
|
+
| `没有找到 Aside 应用` | Aside 不在标准安装位置 | 从 `aside.com/download` 安装,或改用粘贴令牌 |
|
|
122
|
+
| `403` 且含 `error code: 1010` | Cloudflare 拦了 User-Agent | 检查宿主是否覆盖了插件的 `User-Agent` |
|
|
123
|
+
| `426` | 模型被发到了错误端点 | 更新插件;端点选择是按模型家族做的 |
|
|
124
|
+
| 额度卡片显示 `访问令牌已过期` | 文件里的令牌过期且 `allowRefresh` 关闭 | 重新开启刷新或重新登录 |
|
|
125
|
+
| 刷新写回失败 | `accounts.json` 只读 | 插件在内存里继续用新令牌;修好权限即可持久化 |
|
|
126
|
+
|
|
127
|
+
## 安全
|
|
128
|
+
|
|
129
|
+
- 访问令牌只发往配置的 `baseOrigin`;请求 URL 从该 origin 重建,从不使用传入的 URL。
|
|
130
|
+
- 禁止跟随重定向(`redirect: "error"`)。
|
|
131
|
+
- 令牌不会出现在日志或错误信息里;`debug` 只记录字段名。
|
|
132
|
+
- 除刷新后的原子、带比较的写回外,插件对 `accounts.json` 只读。
|
|
133
|
+
- Google 方式只启动 `%ProgramFiles%\Aside\Application`(或 `/Applications/Aside.app`)下找到的 Aside
|
|
134
|
+
可执行文件,绝不执行用户提供的命令。
|
|
135
|
+
|
|
136
|
+
## 限制
|
|
137
|
+
|
|
138
|
+
- Google 登录需要安装 Aside 应用,授权流程在应用内部。
|
|
139
|
+
- 没有额度接口,卡片只显示套餐和令牌剩余时间。
|
|
140
|
+
- 模型目录没有模态字段,插件统一声明为文本加图片。图片输入已在 `gemini-4-argon` 上验证;纯文本模型会
|
|
141
|
+
透出厂商自己的错误。
|
|
142
|
+
- 本插件是非官方集成,与 Aside 官方无关。
|
|
143
|
+
|
|
144
|
+
## 开发
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm test # 单测,离线
|
|
148
|
+
ASIDE_E2E=1 npm test # 追加真机网关测试
|
|
149
|
+
npm run e2e # 真机 E2E,本地生成报告
|
|
150
|
+
npm run probe # 只读协议探针
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
英文 README:[README.md](./README.md)。
|
|
154
|
+
|
|
155
|
+
## 许可
|
|
156
|
+
|
|
157
|
+
MIT。见 [LICENSE](./LICENSE) 与 [NOTICE](./NOTICE)。
|
package/icon.svg
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg width="108" height="40" viewBox="0 0 108 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.556 4.74023C27.738 4.74023 34.3708 11.572 34.3708 19.9995C34.3708 28.4269 27.738 35.2587 19.556 35.2587C11.374 35.2587 4.74121 28.4269 4.74121 19.9995C4.74121 11.572 11.374 4.74023 19.556 4.74023ZM30.8802 14.1553C30.7449 13.8937 30.3552 13.9896 30.3243 14.2825C30.0203 17.172 28.7008 20.6029 26.4659 23.8914C26.4236 23.9536 26.4341 24.038 26.491 24.0873C27.1113 24.6244 27.8098 25.2109 28.588 25.8635C28.6774 25.9385 28.6936 26.07 28.625 26.1644L28.1896 26.7638C28.121 26.8582 27.9909 26.8835 27.892 26.8216C27.0297 26.2825 26.2553 25.7989 25.5521 25.3746C25.4877 25.3357 25.4045 25.3517 25.3583 25.4109C22.9189 28.5357 20.0672 30.8341 17.4194 32.0012C17.1494 32.1203 17.1776 32.5219 17.4689 32.5699C18.148 32.6819 18.8452 32.7402 19.556 32.7402C26.5596 32.7402 32.2431 27.0893 32.2962 20.0982C32.2964 20.0653 32.2968 20.0324 32.2968 19.9995C32.2968 19.9438 32.2963 19.8882 32.2957 19.8327C32.2694 17.788 31.7615 15.8595 30.8802 14.1553ZM14.4211 17.9809C14.3548 17.9154 14.244 17.9265 14.1937 18.0049C13.9023 18.4591 13.6304 18.9129 13.3778 19.3642C12.1538 21.574 11.4069 23.7352 11.1363 25.5915C10.878 27.3637 11.1007 28.6274 11.5039 29.4468C11.7336 29.9133 12.1408 30.2893 12.6487 30.4012C13.4702 30.5822 14.7501 30.4335 16.539 29.5058C18.5575 28.459 20.8016 26.603 22.8362 24.089C22.8965 24.0144 22.8693 23.9024 22.7818 23.8631C19.9518 22.5911 18.4598 23.2017 15.711 26.272C15.6346 26.3573 15.5048 26.3729 15.4122 26.3057L14.8034 25.8634C14.7108 25.7961 14.6857 25.6675 14.7432 25.5686C16.9026 21.8517 16.8518 20.3811 14.4211 17.9809ZM19.556 7.25875C12.5752 7.25875 6.9056 12.873 6.8163 19.8327C6.81564 19.8882 6.81528 19.9438 6.81528 19.9995C6.81528 20.0324 6.81563 20.0653 6.81586 20.0982C6.83235 22.2711 7.39272 24.3147 8.36766 26.0992C8.50717 26.3546 8.89023 26.2563 8.92155 25.967C9.16905 23.6806 10.0739 21.017 11.5764 18.3362C11.9061 17.7422 12.266 17.1481 12.6553 16.5578C12.6966 16.4953 12.6851 16.4118 12.6282 16.3632C11.9438 15.7787 11.1623 15.1307 10.2822 14.3936C10.1927 14.3186 10.1765 14.1871 10.2451 14.0926L11.0289 13.0139C11.0976 12.9195 11.2276 12.8943 11.3266 12.9562C12.2982 13.5645 13.1549 14.1068 13.9214 14.5766C13.9854 14.6158 14.0685 14.6007 14.1152 14.5419C14.1846 14.4543 14.2543 14.3674 14.3243 14.2812C16.6833 11.3542 19.3679 9.17543 21.8486 8.01939C22.1113 7.89691 22.0808 7.50547 21.7953 7.45486C21.0683 7.32597 20.32 7.25875 19.556 7.25875ZM26.385 9.43938C25.4796 9.20563 24.1187 9.33455 22.2918 10.2373C20.2775 11.2326 17.9712 13.1215 15.9632 15.556C15.9038 15.628 15.9272 15.7372 16.0101 15.7801C19.0489 17.3545 20.4632 16.9504 23.3332 13.7455C23.4095 13.6603 23.5396 13.6444 23.6321 13.7117L24.241 14.154C24.3335 14.2212 24.3588 14.3496 24.3013 14.4485C22.2287 18.0151 22.1108 19.6224 24.2013 21.9244C24.2655 21.995 24.3798 21.9867 24.4324 21.907C26.2533 19.1449 27.3581 16.3782 27.7368 14.0934C28.0124 12.4305 27.8797 11.2747 27.5796 10.5166C27.3721 9.99253 26.9308 9.58029 26.385 9.43938Z" fill="currentColor"/>
|
|
3
|
+
<path d="M69.012 28.3431V14.8684H71.6765V28.3431H69.012ZM70.3443 13.4723C69.8746 13.4723 69.4732 13.3101 69.1401 12.9856C68.8156 12.6525 68.6533 12.2469 68.6533 11.7687C68.6533 11.2991 68.8199 10.902 69.1529 10.5775C69.486 10.2531 69.8831 10.0908 70.3443 10.0908C70.8396 10.0908 71.2495 10.2531 71.574 10.5775C71.8986 10.902 72.0608 11.2991 72.0608 11.7687C72.0608 12.2469 71.8986 12.6525 71.574 12.9856C71.2495 13.3101 70.8396 13.4723 70.3443 13.4723Z" fill="#090B0C"/>
|
|
4
|
+
<path d="M95.9681 28.436C94.0629 28.436 92.4511 27.7982 91.1327 26.5225C89.8229 25.2469 89.168 23.6268 89.168 21.6622V21.2923C89.168 19.3363 89.8229 17.7204 91.1327 16.4448C92.4426 15.1691 94.0331 14.5312 95.9043 14.5312C97.8181 14.5312 99.3618 15.1266 100.536 16.3172C101.709 17.5078 102.296 19.0173 102.296 20.8458V22.147H90.5076V20.3228H99.7701V20.1697C99.7276 19.2087 99.3533 18.4135 98.6474 17.7842C97.9499 17.1464 97.0398 16.8275 95.9171 16.8275C94.7518 16.8275 93.7482 17.2527 92.9061 18.1031C92.0726 18.9536 91.6558 20.0294 91.6558 21.3306V21.726C91.6558 23.0442 92.0939 24.1158 92.9699 24.9407C93.8545 25.7656 94.8624 26.1781 95.9936 26.1781C96.606 26.1781 97.1419 26.0931 97.6012 25.923C98.0605 25.7529 98.473 25.4977 98.8387 25.1576C99.2045 24.8089 99.5745 24.3114 99.9487 23.665L102.028 24.5963C101.56 25.5403 101.05 26.2802 100.497 26.8159C99.9444 27.3432 99.3023 27.7472 98.5708 28.0278C97.8393 28.3 96.9718 28.436 95.9681 28.436Z" fill="#090B0C"/>
|
|
5
|
+
<path d="M80.0873 28.4357C78.3522 28.4357 76.8807 27.8021 75.6729 26.535C74.4737 25.2593 73.874 23.652 73.874 21.713V21.292C73.874 19.3189 74.4822 17.6988 75.6985 16.4317C76.9232 15.1645 78.4245 14.5309 80.2021 14.5309C81.2058 14.5309 82.1414 14.7393 83.0089 15.156C83.885 15.5727 84.5357 16.1468 84.961 16.8782L84.7823 16.7506V9.92578H87.4361V28.1933H84.9099V25.8844L85.0375 25.693L85.063 25.9482C84.6462 26.7221 83.9871 27.3301 83.0855 27.7724C82.1924 28.2146 81.193 28.4357 80.0873 28.4357ZM80.7252 26.063C81.9585 26.063 82.9622 25.6463 83.7362 24.8128C84.5102 23.9709 84.8972 22.9376 84.8972 21.713V21.3047C84.8972 20.0206 84.4974 18.9745 83.6979 18.1666C82.9069 17.3587 81.916 16.9547 80.7252 16.9547C79.4834 16.9547 78.4627 17.3502 77.6632 18.1411C76.8722 18.932 76.4767 19.9865 76.4767 21.3047V21.713C76.4767 23.0396 76.8765 24.0984 77.676 24.8894C78.484 25.6718 79.5004 26.063 80.7252 26.063Z" fill="#090B0C"/>
|
|
6
|
+
<path d="M48.8061 10.2471L55.2606 28.2346H52.3315L46.525 11.7503H47.8211L42.0146 28.2346H39.1113L45.5918 10.2471H48.8061ZM42.4812 22.1955H51.7353L52.4611 24.4505H41.7554L42.4812 22.1955Z" fill="#090B0C"/>
|
|
7
|
+
<path d="M61.6785 28.4445C60.7073 28.4445 59.8431 28.2799 59.0859 27.9506C58.3287 27.605 57.7032 27.1441 57.2093 26.5679C56.732 25.9918 56.4027 25.3663 56.2217 24.6914L58.7649 24.1482C58.9295 24.7737 59.2669 25.2758 59.7772 25.6544C60.304 26.0165 60.9213 26.1976 61.6291 26.1976C62.4686 26.1976 63.1023 26.0412 63.5303 25.7284C63.9748 25.3992 64.197 24.9877 64.197 24.4939C64.197 24.033 64.0077 23.679 63.6291 23.4321C63.2505 23.1688 62.7567 22.9548 62.1476 22.7902C61.555 22.6255 60.913 22.4527 60.2217 22.2716C59.5468 22.0906 58.9048 21.8519 58.2958 21.5556C57.7032 21.2593 57.2176 20.8642 56.839 20.3704C56.4604 19.8601 56.2711 19.1935 56.2711 18.3704C56.2711 17.6626 56.4768 17.0124 56.8883 16.4198C57.3163 15.8272 57.9172 15.3663 58.6908 15.0371C59.4645 14.6914 60.3781 14.5186 61.4316 14.5186C62.3534 14.5186 63.1599 14.6667 63.8513 14.963C64.5591 15.2593 65.1353 15.679 65.5797 16.2223C66.0406 16.749 66.3451 17.3745 66.4933 18.0988L63.9995 18.7408C63.8348 18.1153 63.5385 17.6297 63.1106 17.284C62.6826 16.9218 62.09 16.7408 61.3328 16.7408C60.5591 16.7408 59.9665 16.8889 59.555 17.1852C59.1435 17.4815 58.9377 17.8683 58.9377 18.3457C58.9377 18.8231 59.127 19.1935 59.5056 19.4568C59.8842 19.7202 60.3698 19.9424 60.9624 20.1235C61.5715 20.3046 62.2052 20.4856 62.8637 20.6667C63.5385 20.8478 64.1723 21.0782 64.7649 21.3581C65.3739 21.6379 65.8678 22.033 66.2464 22.5432C66.625 23.0371 66.8143 23.6873 66.8143 24.4939C66.8143 25.2017 66.6003 25.8601 66.1723 26.4692C65.7608 27.0618 65.1682 27.5391 64.3945 27.9013C63.6373 28.2634 62.732 28.4445 61.6785 28.4445Z" fill="#090B0C"/>
|
|
8
|
+
</svg>
|