@gruu6y/page-clean-login 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -293,6 +293,19 @@ Run `bun bin/clean-login.mjs help` for the full command list. A remote service (
293
293
 
294
294
  Pull requests are welcome. The test suite is the contract: `bun test` runs all of it, and a change without a test is a change nobody will dare trust later. Touching `lib/`, `ui/`, `page/` or `index.mjs` does **not** require a version bump of your own -- the merger assigns the version at the merge point; `node scripts/check-version-bump.mjs` still refuses a downgrade or a number already released. Read [AGENTS.md](AGENTS.md) and [docs/releasing.md](docs/releasing.md) before you start.
295
295
 
296
+ ### Submitting issues and dual-line triage
297
+
298
+ When opening a bug report or feature request, the **预计改动范围 / 风险区域** (`route_scope`) dropdown in the issue form determines which maintainer line handles the issue (see [docs/auto-maintainer.md](docs/auto-maintainer.md) for full rules):
299
+
300
+ - **`agent:cindy` (Cindy line)**: handles clearly scoped, low-risk tasks. An issue is routed here only when `route_scope` selects one of:
301
+ - `纯文档 / README / Issue 模板修改` (docs / README / issue templates only)
302
+ - `纯文案或不涉及逻辑的简单样式修改` (copy or non-logic styling only)
303
+ - `纯测试补充` (tests only)
304
+ - `单个非核心文件小 Bug(已附完整复现步骤与验收条件)` (single non-core-file bug with both **reproduction steps** and **acceptance criteria** filled in)
305
+ - For Feature Requests, **是否需要对应 CLI 支持** must also be `不需要(仅涉及页面展示或内部逻辑)` (no CLI support needed).
306
+ - **`agent:agy` (agy line)**: handles general, complex, cross-platform, core-logic, or CLI-related tasks. Keeping the default `核心功能 / 复杂改动 / 跨平台 / 不确定`, omitting required fields, selecting `需要` or `不确定` for CLI support on a feature request, opening a blank issue, or reporting via the card's **Report a problem** button (`from-plugin`) all route to `agent:agy`.
307
+ - **Not sure which to pick?** Keep the default `核心功能 / 复杂改动 / 跨平台 / 不确定`. Maintainers can manually adjust `agent:cindy` / `agent:agy` labels at any time, and Cindy will also hand the issue back to `agent:agy` if it finds the change is out of scope.
308
+
296
309
  <a id="license"></a>
297
310
 
298
311
  ## License
package/README.md CHANGED
@@ -298,6 +298,19 @@ bun bin/clean-login.mjs score cancel # 停掉信任度评分
298
298
 
299
299
  欢迎 pull request。测试套件就是契约:`bun test` 跑全部,一个没有测试的改动就是以后没人敢信的改动。改 `lib/`、`ui/`、`page/` 或 `index.mjs` **不需要自己升版本号**——版本由合并方在合并点分配;`node scripts/check-version-bump.mjs` 仍会拒绝降级或等于已发布的版本号。动手前先读 [AGENTS.md](AGENTS.md) 与 [docs/releasing.md](docs/releasing.md)。
300
300
 
301
+ ### 提交 Issue 与双线自动分流
302
+
303
+ 提交问题或功能建议时,Issue 表单中的 **预计改动范围 / 风险区域**(`route_scope` 字段)用于自动分流处理执行器(完整规则见 [docs/auto-maintainer.md](docs/auto-maintainer.md)):
304
+
305
+ - **`agent:cindy`(Cindy 自动线)**:处理范围明确的低风险 / 简单任务。仅当 `route_scope` 选择以下之一时才会路由到此线:
306
+ - `纯文档 / README / Issue 模板修改`
307
+ - `纯文案或不涉及逻辑的简单样式修改`
308
+ - `纯测试补充`
309
+ - `单个非核心文件小 Bug(已附完整复现步骤与验收条件)`(须同时填写非空的 **复现步骤** 与 **验收条件**)
310
+ - 若为功能建议(Feature Request),还要求 **是否需要对应 CLI 支持** 选择 `不需要(仅涉及页面展示或内部逻辑)`。
311
+ - **`agent:agy`(agy 代理线)**:处理常规、复杂、跨平台或涉及核心逻辑 / CLI 的任务。当 `route_scope` 保留默认的 `核心功能 / 复杂改动 / 跨平台 / 不确定`,或缺少上述必要字段、功能建议需要或不确定是否同步 CLI、空白 Issue 以及卡片 **报告问题**(`from-plugin`)提交的 Issue 时,均由 `agent:agy` 接管。
312
+ - **拿不准怎么选?** 直接保留默认的 `核心功能 / 复杂改动 / 不确定` 即可。维护者也可随时手工增删 `agent:cindy` / `agent:agy` 标签改判;若 Cindy 评估后发现超出范围,也会自动退回给 `agent:agy` 接管。
313
+
301
314
  <a id="license"></a>
302
315
 
303
316
  ## 许可
@@ -382,6 +382,7 @@ export async function rotateIdentity(
382
382
  await sweep();
383
383
  throw error;
384
384
  }
385
+ await rm(join(dir, "check-profile"), { recursive: true, force: true }).catch(() => {});
385
386
  await rename(pendingFile, join(dir, IDENTITY_FILE));
386
387
  return { identity, clearedProfile: true };
387
388
  }
@@ -292,6 +292,7 @@ export async function importAccounts(env = process.env, deps = {}) {
292
292
  key: item.key,
293
293
  accountId: item.accountId,
294
294
  uid: item.uid,
295
+ email: item.email ?? null,
295
296
  // Honest: importing is not a sign-in and the auth file does not record
296
297
  // when the account last signed in.
297
298
  signedInAt: null,
@@ -365,19 +365,50 @@ export async function writeAccountExit({
365
365
 
366
366
  // A finished sign-in: the account's own entry follows the exit it just used.
367
367
  // `proxy` is the full stored record (credentials included) when the page named
368
- // a stored exit; a direct sign-in has none and leaves magpie untouched.
369
- export async function syncSignInProxy({ env = process.env, provider, accountId, proxy } = {}) {
368
+ // a stored exit. A direct sign-in (`proxy == null`) leaves a clean account
369
+ // untouched so magpie keeps inheriting; if magpie already holds an entry for
370
+ // this account from an earlier exit, re-signing in as direct switches it to
371
+ // `"direct"` so traffic does not remain pinned to the stale proxy.
372
+ export async function syncSignInProxy({
373
+ env = process.env,
374
+ provider,
375
+ accountId,
376
+ proxy,
377
+ file = providersFile(env),
378
+ } = {}) {
370
379
  const url = proxyUrlFor(proxy);
371
- if (!url || !accountProxyKey(accountId) || !provider) {
380
+ const key = accountProxyKey(accountId);
381
+ if (!key || RESERVED_KEYS.has(key) || !provider) {
382
+ return { ok: true, changed: [], skipped: [], reason: "no_proxy" };
383
+ }
384
+ if (!url) {
385
+ if (proxy === null || proxy === undefined) {
386
+ const loaded = await readProvidersDoc(file);
387
+ const entry = loaded.ok ? findProvider(loaded.doc, provider) : null;
388
+ const map = accountProxyMap(entry);
389
+ if (entry && Object.hasOwn(map, key) && map[key] !== "direct") {
390
+ const res = await writeAccountExit({ env, provider, accountId, mode: "direct", file });
391
+ return {
392
+ ok: res.ok,
393
+ changed: res.changed ? [{ provider, accountId, key: res.key, url: "direct" }] : [],
394
+ skipped: [],
395
+ reason: res.changed ? "cleared_to_direct" : (res.reason ?? "no_proxy"),
396
+ };
397
+ }
398
+ }
372
399
  return { ok: true, changed: [], skipped: [], reason: "no_proxy" };
373
400
  }
374
- return writeAccountProxies({ env, entries: [{ provider, accountId, url }] });
401
+ return writeAccountProxies({ env, entries: [{ provider, accountId, url }], file });
375
402
  }
376
403
 
377
- // Startup backfill: every ledger that remembers which exit it signed in
378
- // through gets that exit into magpie, but only where magpie has no entry yet.
379
- // This is what repairs accounts signed in before this feature existed, without
380
- // touching anything the user configured by hand.
404
+ function accountActiveProxyId(meta) {
405
+ const picked = meta?.exit && typeof meta.exit === "object" ? meta.exit : meta?.lastLogin;
406
+ return typeof picked?.proxyId === "string" && picked.proxyId ? picked.proxyId : null;
407
+ }
408
+
409
+ // Startup backfill: every ledger that remembers which exit it is bound to
410
+ // (`exit`, falling back to `lastLogin`) gets that exit into magpie, but only
411
+ // where magpie has no entry yet.
381
412
  export async function backfillAccountProxies({
382
413
  env = process.env,
383
414
  store,
@@ -398,7 +429,7 @@ export async function backfillAccountProxies({
398
429
  const seen = new Set();
399
430
  for (const account of Array.isArray(accounts) ? accounts : []) {
400
431
  const meta = account?.meta;
401
- const proxyId = meta?.lastLogin?.proxyId;
432
+ const proxyId = accountActiveProxyId(meta);
402
433
  const accountId = meta?.accountId;
403
434
  const provider = meta?.provider ?? account?.provider;
404
435
  if (!proxyId || !accountProxyKey(accountId) || !provider) continue;
@@ -415,7 +446,7 @@ export async function backfillAccountProxies({
415
446
  report.skipped.push({ provider, accountId, reason: "proxy_missing" });
416
447
  continue;
417
448
  }
418
- const key = `${provider}${accountProxyKey(accountId)}`;
449
+ const key = `${provider}\u0000${accountProxyKey(accountId)}`;
419
450
  if (seen.has(key)) continue;
420
451
  seen.add(key);
421
452
  wanted.push({ provider, accountId, url });
@@ -430,6 +461,99 @@ export async function backfillAccountProxies({
430
461
  return { ...written, ledgers: report.ledgers, skipped: [...report.skipped, ...written.skipped] };
431
462
  }
432
463
 
464
+ // Re-sync every account whose active exit points to `proxyId` after that
465
+ // proxy's connection or credentials are updated.
466
+ export async function syncProxyUpdate({
467
+ env = process.env,
468
+ store,
469
+ proxyId,
470
+ listAccounts = listAccountDirsWithMeta,
471
+ file = providersFile(env),
472
+ } = {}) {
473
+ if (typeof proxyId !== "string" || !proxyId) {
474
+ return { ok: false, file, changed: [], skipped: [], reason: "invalid_proxy" };
475
+ }
476
+ let record = null;
477
+ try {
478
+ record = await store?.get?.(proxyId);
479
+ } catch {
480
+ record = null;
481
+ }
482
+ const url = proxyUrlFor(record);
483
+ let accounts;
484
+ try {
485
+ accounts = await listAccounts(env);
486
+ } catch (error) {
487
+ return {
488
+ ok: false,
489
+ file,
490
+ changed: [],
491
+ skipped: [],
492
+ reason: "accounts_unreadable",
493
+ error: String(error?.message ?? error),
494
+ };
495
+ }
496
+ const entries = [];
497
+ const seen = new Set();
498
+ for (const account of Array.isArray(accounts) ? accounts : []) {
499
+ const meta = account?.meta;
500
+ if (accountActiveProxyId(meta) !== proxyId) continue;
501
+ const accountId = meta?.accountId;
502
+ const provider = meta?.provider ?? account?.provider;
503
+ const accountKey = accountProxyKey(accountId);
504
+ if (!provider || !accountKey || RESERVED_KEYS.has(accountKey)) continue;
505
+ const dedupeKey = `${provider}\u0000${accountKey}`;
506
+ if (seen.has(dedupeKey)) continue;
507
+ seen.add(dedupeKey);
508
+ entries.push({ provider, accountId, url });
509
+ }
510
+ if (!entries.length) {
511
+ return { ok: true, file, changed: [], skipped: [], reason: "nothing_to_sync" };
512
+ }
513
+ if (!url) {
514
+ return {
515
+ ok: false,
516
+ file,
517
+ changed: [],
518
+ skipped: entries.map(({ provider, accountId }) => ({
519
+ provider,
520
+ accountId,
521
+ reason: "proxy_missing",
522
+ })),
523
+ reason: "proxy_missing",
524
+ };
525
+ }
526
+ return writeAccountProxies({ env, entries, onlyMissing: false, file });
527
+ }
528
+
529
+ // Removes an account's per-account proxy override from magpie's providers.json
530
+ // when the account is deleted.
531
+ export async function clearAccountProxy({
532
+ env = process.env,
533
+ provider,
534
+ accountId,
535
+ file = providersFile(env),
536
+ } = {}) {
537
+ const key = accountProxyKey(accountId);
538
+ if (!provider || !key || RESERVED_KEYS.has(key)) {
539
+ return { ok: true, changed: false, reason: "account_name_unknown" };
540
+ }
541
+ const loaded = await readProvidersDoc(file);
542
+ if (!loaded.ok) {
543
+ return loaded.reason === "providers_missing"
544
+ ? { ok: true, changed: false, reason: "providers_missing" }
545
+ : { ok: false, changed: false, reason: loaded.reason };
546
+ }
547
+ const entry = findProvider(loaded.doc, provider);
548
+ if (!entry) return { ok: true, changed: false, reason: "provider_missing" };
549
+ const map = accountProxyMap(entry);
550
+ if (!Object.hasOwn(map, key)) {
551
+ return { ok: true, changed: false, reason: "unchanged" };
552
+ }
553
+ const res = await writeAccountExit({ env, provider, accountId, mode: "inherit", file });
554
+ return { ok: res.ok, changed: Boolean(res.changed), reason: res.reason };
555
+ }
556
+
433
557
  // The flow's default: build the sync from the environment alone, so a sign-in
434
558
  // driven without the HTTP service still lands in magpie. The proxy store is
435
559
  // only read here, never written.
@@ -450,6 +574,10 @@ export function createAccountProxySync({ env = process.env, store, dataDir = plu
450
574
  }
451
575
  return syncSignInProxy({ env, provider, accountId, proxy: record });
452
576
  },
577
+ syncProxyUpdate: async ({ proxyId }) =>
578
+ syncProxyUpdate({ env, store: await ensureStore(), proxyId }),
579
+ clearAccountProxy: async ({ provider, accountId }) =>
580
+ clearAccountProxy({ env, provider, accountId }),
453
581
  backfill: async () =>
454
582
  backfillAccountProxies({ env, store: await ensureStore() }),
455
583
  };
package/lib/agent-cli.mjs CHANGED
@@ -74,7 +74,7 @@ function addOption(options, key, value) {
74
74
  // an optional-value flag stays bare only when another flag or the end of the
75
75
  // line follows (a token it does take is validated by the command), and a
76
76
  // required value flag errors instead of quietly storing `true`.
77
- const BOOLEAN_FLAGS = new Set(["help", "raw", "single"]);
77
+ const BOOLEAN_FLAGS = new Set(["help", "raw", "single", "clear-password"]);
78
78
  const OPTIONAL_VALUE_FLAGS = new Set(["wait"]);
79
79
  const VALUE_FLAGS = new Set([
80
80
  "url",
@@ -101,6 +101,8 @@ const VALUE_FLAGS = new Set([
101
101
  "name",
102
102
  "host",
103
103
  "exit-port",
104
+ "file",
105
+ "prefix",
104
106
  ]);
105
107
 
106
108
  export function parseArgs(argv) {
@@ -284,7 +286,8 @@ export function usage() {
284
286
  " providers Merged provider cards, compact.",
285
287
  " proxies Stored proxies, compact (no credentials).",
286
288
  " proxies add <name> <type> <host> <port> Store an exit (type http|https|socks5).",
287
- " proxies update <id> [--name N] [--type T] [--host H] [--exit-port P] [--user U] [--pass P]",
289
+ " proxies import [--file PATH | <text>] [--type T] [--prefix P] Bulk import exits.",
290
+ " proxies update <id> [--name N] [--type T] [--host H] [--exit-port P] [--user U] [--pass P] [--clear-password]",
288
291
  " Change an exit; a connection change clears its per-provider latency and score.",
289
292
  " proxies delete <proxyId> Remove a stored exit.",
290
293
  " proxies targets The endpoints a proxy probe can be aimed at.",
@@ -310,7 +313,7 @@ export function usage() {
310
313
  " native status [--wait ms] The current native sign-in flow.",
311
314
  " native paste <text> Paste a callback URL or code into it.",
312
315
  " native cancel Cancel the native sign-in.",
313
- " proxy test <proxyId> Probe a stored proxy and persist the result.",
316
+ " proxy test <proxyId> [--provider ID] Probe a stored proxy and persist the result.",
314
317
  " proxy score <proxyId> Start the Claude trust-score check.",
315
318
  " score status [--wait ms] The trust-score job.",
316
319
  " score cancel Stop the trust-score job.",
@@ -335,6 +338,9 @@ export function usage() {
335
338
  " --mode M Exit mode for accounts exit: inherit, direct or custom.",
336
339
  " --note TEXT Note for assets add/update, or the report note.",
337
340
  " --user / --pass Optional credentials for proxies add and update.",
341
+ " --clear-password Clear a stored proxy password on proxies update.",
342
+ " --file PATH Read bulk proxy lines from a UTF-8 file for proxies import.",
343
+ " --prefix TEXT Name prefix for imported proxies on proxies import.",
338
344
  " --exit-port N Exit port for proxies update (--port is the service port).",
339
345
  " --single Replace the single stored account for this provider.",
340
346
  "",
@@ -409,6 +415,28 @@ export async function runCli(argv, {
409
415
  noSurplus(positional, 3);
410
416
  return emit(await del(`/api/proxies/${encodeURIComponent(required(positional[2] ?? options.id, "<proxyId>"))}`), options, write);
411
417
  }
418
+ if (action === "import") {
419
+ noSurplus(positional, 3);
420
+ let text = "";
421
+ if (options.file !== undefined) {
422
+ const filePath = required(options.file, "--file");
423
+ try {
424
+ const { readFile } = await import("node:fs/promises");
425
+ text = await readFile(filePath, "utf8");
426
+ } catch (error) {
427
+ throw new CliError(
428
+ `Could not read proxy file ${filePath}: ${String(error?.message || error)}`,
429
+ { code: "file_unreadable" },
430
+ );
431
+ }
432
+ } else {
433
+ text = required(positional[2] ?? options.text, "<text> or --file");
434
+ }
435
+ const body = { text };
436
+ if (options.type) body.defaultType = String(options.type);
437
+ if (options.prefix !== undefined) body.prefix = String(options.prefix);
438
+ return emit(await post("/api/proxies/bulk", body), options, write);
439
+ }
412
440
  if (action === "update") {
413
441
  // Only fields the caller spelled out are sent, so a later read cannot
414
442
  // mistake an omitted flag for a request to clear it. The exit's port
@@ -424,9 +452,10 @@ export async function runCli(argv, {
424
452
  if (Object.prototype.hasOwnProperty.call(options, "exit-port")) body.port = String(options["exit-port"]);
425
453
  if (Object.prototype.hasOwnProperty.call(options, "user")) body.username = String(options.user);
426
454
  if (Object.prototype.hasOwnProperty.call(options, "pass")) body.password = String(options.pass);
455
+ if (options["clear-password"] === true) body.clearPassword = true;
427
456
  if (!Object.keys(body).length) {
428
457
  throw new CliError(
429
- "Nothing to update; pass --name, --type, --host, --exit-port, --user or --pass.",
458
+ "Nothing to update; pass --name, --type, --host, --exit-port, --user, --pass or --clear-password.",
430
459
  { code: "bad_command" },
431
460
  );
432
461
  }
@@ -632,7 +661,8 @@ export async function runCli(argv, {
632
661
  const id = required(positional[2] ?? options.id, "<proxyId>");
633
662
  const path = `/api/proxies/${encodeURIComponent(id)}`;
634
663
  if (action === "test") {
635
- const payload = await post(`${path}/test`, {});
664
+ const body = options.provider ? { provider: String(options.provider) } : {};
665
+ const payload = await post(`${path}/test`, body);
636
666
  emit(payload, options, write);
637
667
  // The probe answered but reported a dead exit: that is a failure the
638
668
  // caller must see in the exit code, not just in the JSON body.
@@ -53,6 +53,7 @@ export const AGENT_COMMANDS = Object.freeze([
53
53
  Object.freeze({ command: "status", http: "GET /api/health", args: "", summary: "Liveness and the account-prune summary." }),
54
54
  Object.freeze({ command: "providers", http: "GET /api/agent", args: "", summary: "The merged provider cards, compact." }),
55
55
  Object.freeze({ command: "proxies", http: "GET /api/agent", args: "", summary: "Stored proxies, compact, without credentials." }),
56
+ Object.freeze({ command: "proxies import", http: "POST /api/proxies/bulk", args: "[--file <path> | <text>] [--type T] [--prefix P]", summary: "Bulk import proxies from text lines." }),
56
57
  Object.freeze({ command: "accounts", http: "GET /api/agent", args: "", summary: "Known accounts and whether each is signed in." }),
57
58
  Object.freeze({ command: "signin start", http: "POST /api/signin", args: "--provider <id> [--proxy <id>] [--method <label>] [--input k=v]... [--single] [--wait ms]", summary: "Start a sign-in, optionally waiting until it settles." }),
58
59
  Object.freeze({ command: "signin status", http: "GET /api/signin?wait=ms", args: "[--wait ms]", summary: "The current sign-in flow." }),
@@ -62,7 +63,7 @@ export const AGENT_COMMANDS = Object.freeze([
62
63
  Object.freeze({ command: "native status", http: "GET /api/native-signin?wait=ms", args: "[--wait ms]", summary: "The current native sign-in flow." }),
63
64
  Object.freeze({ command: "native paste", http: "POST /api/native-signin/paste", args: "<text>", summary: "Paste a callback URL or code into the native flow." }),
64
65
  Object.freeze({ command: "native cancel", http: "POST /api/native-signin/cancel", args: "", summary: "Cancel the native sign-in." }),
65
- Object.freeze({ command: "proxy test", http: "POST /api/proxies/:id/test", args: "<proxyId>", summary: "Probe a stored proxy and persist the result." }),
66
+ Object.freeze({ command: "proxy test", http: "POST /api/proxies/:id/test", args: "<proxyId> [--provider <id>]", summary: "Probe a stored proxy and persist the result." }),
66
67
  Object.freeze({ command: "proxy score", http: "POST /api/proxies/:id/score", args: "<proxyId> [--wait ms]", summary: "Start the Claude trust-score check." }),
67
68
  Object.freeze({ command: "score status", http: "GET /api/proxy-score?wait=ms", args: "[--wait ms]", summary: "The trust-score job." }),
68
69
  Object.freeze({ command: "env", http: "GET /api/environment/job?wait=ms", args: "[--wait ms]", summary: "The login browser and its download job." }),
@@ -16,34 +16,68 @@
16
16
  // longer writes a reason about it.
17
17
 
18
18
  export const PROVIDER_CAPABILITY_STATES = Object.freeze(["pending", "ready", "blocked"]);
19
+ export const PROVIDER_NOTICE_TONES = Object.freeze(["warn", "danger"]);
19
20
 
20
- // Antigravity risk notice: free-tier / unpaid accounts get disabled by Google's ToS enforcement.
21
- const ANTIGRAVITY_NOTICE = Object.freeze({
22
- en: "Heads-up: A subscription account that hasn't paid Google a single cent is bound to get banned, no matter what.",
23
- "zh-Hans": "提醒:一块钱都没给 Google 付的订阅账号,神仙来了也得封了。",
24
- "zh-Hant": "提醒:一塊錢都沒給 Google 付的訂閱帳號,神仙來了也得封。",
25
- ja: "注意:Google に 1 円も支払っていないサブスクアカウントは、どうあがいても BAN されます。",
21
+ // Google AGY family risk notice: unpaid accounts cannot avoid Google's ToS
22
+ // bans through this plugin, and using AGY providers through magpie is not
23
+ // recommended for now.
24
+ export const AGY_FAMILY_NOTICE = Object.freeze({
25
+ en: "Heads-up: This plugin cannot ease ban risk on accounts without real paid billing, and using Google AGY providers through magpie is not recommended for now.",
26
+ "zh-Hans": "提醒:未实付的账号无法通过本插件缓解你的封禁焦虑,且暂时不建议通过 magpie 使用 agy 供应商。",
27
+ "zh-Hant": "提醒:未實付的帳號無法透過本外掛緩解你的封禁焦慮,且暫時不建議透過 magpie 使用 agy 供應商。",
28
+ ja: "注意:実際に課金していないアカウントの BAN 不安はこのプラグインでは解消できず、当面は magpie 経由での agy プロバイダー利用もおすすめしません。",
26
29
  });
27
30
 
28
- // Codex and Claude are magpie built-ins: this plugin has no plugin to scan for
29
- // them and reaches the sign-in through magpie's own command line, which ends in
30
- // a browser this plugin cannot seal off yet. Until the sandbox service exists,
31
- // both cards say plainly that they are not the way to sign in for now.
32
- const NO_SANDBOX_NOTICE = Object.freeze({
33
- en: "Not recommended for now: do not sign in through this plugin yet, because the sandbox service is not ready.",
34
- "zh-Hans": "暂时不建议使用本插件登录:沙箱服务暂未准备提供。",
35
- "zh-Hant": "暫時不建議使用此外掛登入:沙箱服務暫未準備提供。",
36
- ja: "当面はこのプラグインでのログインはおすすめしません。サンドボックスサービスをまだ用意していないためです。",
31
+ // Claude family risk notice: users should use claude-cage instead of this plugin.
32
+ export const CLAUDE_NOTICE = Object.freeze({
33
+ en: "Notice: Do not use Claude through this plugin. Please use claude-cage instead.",
34
+ "zh-Hans": "提醒:请不要通过本插件来使用 Claude,请使用 claude-cage。",
35
+ "zh-Hant": "提醒:請不要透過本外掛來使用 Claude,請使用 claude-cage。",
36
+ ja: "注意:このプラグイン経由で Claude を使わないでください。代わりに claude-cage をご利用ください。",
37
37
  });
38
38
 
39
- // What magpie itself does for Claude. Kept next to the sandbox line so the
40
- // Claude card states both facts in one notice.
41
- const CLAUDE_TOKEN_NOTICE = Object.freeze({
42
- en: "magpie signs in to Claude by importing a token (POST /api/signin/claude-token), not through a web account page.",
43
- "zh-Hans": "magpie 通过导入 token(POST /api/signin/claude-token)来登录 Claude,而不是通过网页账号页面。",
44
- "zh-Hant": "magpie 透過匯入 token(POST /api/signin/claude-token)來登入 Claude,而不是透過網頁帳號頁面。",
45
- ja: "magpie は Web のアカウントページではなく、token のインポート(POST /api/signin/claude-token)で Claude にサインインします。",
46
- });
39
+ function providerSlug(value) {
40
+ return String(value || "")
41
+ .trim()
42
+ .toLowerCase()
43
+ .replace(/[^a-z0-9]+/g, "-")
44
+ .replace(/^-+|-+$/g, "");
45
+ }
46
+
47
+ const AGY_ID_PATTERN = /^(?:google-)?(?:antigravity|agy)(?:-|$)/;
48
+ const AGY_TOKEN_PATTERN = /(?:^|-)(?:antigravity|agy)(?:-|$)/;
49
+ const CLAUDE_ID_PATTERN = /^(?:anthropic-)?claude(?:code)?(?:-|$)/;
50
+ const CLAUDE_TOKEN_PATTERN = /(?:^|-)claude(?:code)?(?:-|$)/;
51
+
52
+ // Curated family-level notices so plugin-derived and market cards (such as
53
+ // `agy-cli` or `claude-code`) inherit the same specialized warning as the
54
+ // built-in registry entries.
55
+ export function providerSpecialNotice(provider = {}) {
56
+ if (!provider || typeof provider !== "object") return null;
57
+ const ids = [provider.id, provider.agentId, provider.signInProvider]
58
+ .map(providerSlug)
59
+ .filter(Boolean);
60
+ const name = providerSlug(provider.name);
61
+ const pkg = providerSlug(provider.pluginPackage || provider.package);
62
+
63
+ if (
64
+ ids.some((id) => AGY_ID_PATTERN.test(id)) ||
65
+ (name && AGY_TOKEN_PATTERN.test(name)) ||
66
+ (pkg && AGY_TOKEN_PATTERN.test(pkg))
67
+ ) {
68
+ return { notice: { ...AGY_FAMILY_NOTICE }, noticeTone: "warn" };
69
+ }
70
+
71
+ if (
72
+ ids.some((id) => CLAUDE_ID_PATTERN.test(id)) ||
73
+ (name && CLAUDE_TOKEN_PATTERN.test(name)) ||
74
+ (pkg && CLAUDE_TOKEN_PATTERN.test(pkg))
75
+ ) {
76
+ return { notice: { ...CLAUDE_NOTICE }, noticeTone: "danger" };
77
+ }
78
+
79
+ return null;
80
+ }
47
81
 
48
82
  const definitions = [
49
83
  {
@@ -64,7 +98,8 @@ const definitions = [
64
98
  linkOnly: true,
65
99
  authHosts: ["accounts.google.com"],
66
100
  callbackPort: 45171,
67
- notice: { ...ANTIGRAVITY_NOTICE },
101
+ notice: { ...AGY_FAMILY_NOTICE },
102
+ noticeTone: "warn",
68
103
  capability: { state: "pending", reason: {} },
69
104
  },
70
105
  {
@@ -82,7 +117,8 @@ const definitions = [
82
117
  linkOnly: true,
83
118
  authHosts: ["auth.openai.com"],
84
119
  callbackPort: 45172,
85
- notice: { ...NO_SANDBOX_NOTICE },
120
+ notice: {},
121
+ noticeTone: null,
86
122
  capability: { state: "pending", reason: {} },
87
123
  },
88
124
  {
@@ -90,26 +126,21 @@ const definitions = [
90
126
  name: "Claude",
91
127
  mark: { kind: "letter", text: "Cl", tone: "clay" },
92
128
  description: {
93
- en: "Anthropic's Claude. magpie links it by importing a token; this plugin has not implemented token import yet.",
94
- "zh-Hans": "Anthropic 的 Claude。magpie 通过导入 token 来关联;本插件尚未实现 token 导入。",
95
- "zh-Hant": "Anthropic 的 Claude。magpie 透過匯入 token 來關聯;本外掛尚未實作 token 匯入。",
96
- ja: "Anthropic の Claude。magpie は token のインポートで連携します。このプラグインでは token インポートをまだ実装していません。",
129
+ en: "Anthropic's Claude.",
130
+ "zh-Hans": "Anthropic 的 Claude。",
131
+ "zh-Hant": "Anthropic 的 Claude。",
132
+ ja: "Anthropic の Claude。",
97
133
  },
98
134
  agentId: "claude",
99
135
  // magpie signs in to Claude with `POST /api/signin/claude-token`, which
100
136
  // imports a token. It is not a browser OAuth flow, so there is no web auth
101
- // host and no callback port to claim. The URL in this description was read
102
- // from the magpie binary; the import itself is not implemented here yet.
137
+ // host and no callback port to claim.
103
138
  signInMode: "token-import",
104
139
  linkOnly: true,
105
140
  authHosts: [],
106
141
  callbackPort: null,
107
- notice: {
108
- en: `${NO_SANDBOX_NOTICE.en} ${CLAUDE_TOKEN_NOTICE.en}`,
109
- "zh-Hans": `${NO_SANDBOX_NOTICE["zh-Hans"]}${CLAUDE_TOKEN_NOTICE["zh-Hans"]}`,
110
- "zh-Hant": `${NO_SANDBOX_NOTICE["zh-Hant"]}${CLAUDE_TOKEN_NOTICE["zh-Hant"]}`,
111
- ja: `${NO_SANDBOX_NOTICE.ja}${CLAUDE_TOKEN_NOTICE.ja}`,
112
- },
142
+ notice: { ...CLAUDE_NOTICE },
143
+ noticeTone: "danger",
113
144
  capability: { state: "pending", reason: {} },
114
145
  },
115
146
  ];
@@ -130,6 +161,7 @@ export const PROVIDER_PUBLIC_FIELDS = Object.freeze([
130
161
  "authHosts",
131
162
  "callbackPort",
132
163
  "notice",
164
+ "noticeTone",
133
165
  "capability",
134
166
  ]);
135
167
 
@@ -145,6 +177,7 @@ export function publicProvider(provider) {
145
177
  authHosts: [...provider.authHosts],
146
178
  callbackPort: provider.callbackPort,
147
179
  notice: { ...provider.notice },
180
+ noticeTone: PROVIDER_NOTICE_TONES.includes(provider.noticeTone) ? provider.noticeTone : null,
148
181
  capability: {
149
182
  state: provider.capability.state,
150
183
  reason: { ...provider.capability.reason },
@@ -23,6 +23,7 @@ export const MAGPIE_PROVIDERS_READ = "providers:list";
23
23
 
24
24
  import { projectPrompts, requiresFormInput, requiresSecretInput } from "./magpie-plugins.mjs";
25
25
  import { methodInputFields } from "./method-inputs.mjs";
26
+ import { providerSpecialNotice } from "./provider-registry.mjs";
26
27
 
27
28
  // Five presences. The first four only compare the local registry with
28
29
  // magpie's own list. The fifth exists because an installed plugin can expose a
@@ -52,9 +53,9 @@ export const PROVIDER_PRESENCES = Object.freeze([
52
53
  // `accounts add`), so it explains nothing and prints no note at all.
53
54
  // A registry-only card sits in the "other providers" list, next to cards that
54
55
  // print no prose at all, so it gets one line and no more: the curated notice,
55
- // when the registry has one ("do not sign in through this plugin yet", plus the
56
- // token import note for Claude). Its own description and the generic "magpie
57
- // does not list it" note were two further paragraphs around that one sentence.
56
+ // when the registry has one (such as the AGY family or Claude warnings). Its
57
+ // own description and the generic "magpie does not list it" note were two
58
+ // further paragraphs around that one sentence.
58
59
  const PROSE_FREE_PRESENCES = Object.freeze(["local-only"]);
59
60
 
60
61
  // A scan that BROKE is not a flow that was never implemented. When the
@@ -371,6 +372,12 @@ function magpieOnlyProvider(item, pluginItem, scanFailure) {
371
372
  // plugin has no browser login" sentence used to sit here and contradicted
372
373
  // cards that listed a browser method while claiming there was no add entry.)
373
374
  const reason = scanFailure ? { ...scanFailure } : {};
375
+ const special = providerSpecialNotice({
376
+ id: item.id,
377
+ name: item.name,
378
+ signInProvider: pluginItem ? pluginItem.id : null,
379
+ pluginPackage: pluginItem ? pluginItem.package : null,
380
+ });
374
381
  return {
375
382
  id: item.id,
376
383
  name: item.name,
@@ -381,7 +388,8 @@ function magpieOnlyProvider(item, pluginItem, scanFailure) {
381
388
  linkOnly: true,
382
389
  authHosts: [],
383
390
  callbackPort: null,
384
- notice: null,
391
+ notice: special ? special.notice : null,
392
+ noticeTone: special ? special.noticeTone : null,
385
393
  capability: { state: "pending", reason },
386
394
  presence: "magpie-only",
387
395
  presenceNote: null,
@@ -418,6 +426,12 @@ function pluginOnlyProvider(item) {
418
426
  // One plugin can expose several providers, so the card is named after the
419
427
  // provider the plugin declared, never after the package it came from.
420
428
  const name = item.name || item.id;
429
+ const special = providerSpecialNotice({
430
+ id: item.id,
431
+ name,
432
+ signInProvider: item.id,
433
+ pluginPackage: item.package,
434
+ });
421
435
  return {
422
436
  id: item.id,
423
437
  name,
@@ -428,7 +442,8 @@ function pluginOnlyProvider(item) {
428
442
  linkOnly: true,
429
443
  authHosts: [],
430
444
  callbackPort: null,
431
- notice: null,
445
+ notice: special ? special.notice : null,
446
+ noticeTone: special ? special.noticeTone : null,
432
447
  capability: { state: "pending", reason: {} },
433
448
  presence: "plugin-only",
434
449
  presenceNote: null,
@@ -647,6 +662,7 @@ export function mergeProviderSources({ local = [], magpie, plugins, catalog } =
647
662
  // line and the registry's own notice say everything the description and
648
663
  // the presence note used to repeat.
649
664
  description: PROSE_FREE_PRESENCES.includes(presence) ? {} : provider.description,
665
+ noticeTone: provider.noticeTone ?? null,
650
666
  capability,
651
667
  presence,
652
668
  presenceNote,
@@ -718,6 +734,11 @@ export function mergeProviderSources({ local = [], magpie, plugins, catalog } =
718
734
  if (keys.some((key) => covered.has(key))) continue;
719
735
  for (const key of keys) covered.add(key);
720
736
  const flags = methodFlags([]);
737
+ const special = providerSpecialNotice({
738
+ id: item.id,
739
+ name: item.name,
740
+ pluginPackage: item.package || null,
741
+ });
721
742
  providers.push({
722
743
  id: item.id,
723
744
  name: item.name,
@@ -728,7 +749,8 @@ export function mergeProviderSources({ local = [], magpie, plugins, catalog } =
728
749
  linkOnly: true,
729
750
  authHosts: [],
730
751
  callbackPort: null,
731
- notice: null,
752
+ notice: special ? special.notice : null,
753
+ noticeTone: special ? special.noticeTone : null,
732
754
  capability: { state: "pending", reason: {} },
733
755
  presence: "catalog",
734
756
  presenceNote: null,