Files
plugins/packages/window-warmup/web/index.html
T
YangHonghang 1ab8238ade window-warmup 0.1.0: a page that sends a short message after a quota window resets, daily or every few hours (#661)
Adds packages/window-warmup (@magpie-community/page-window-warmup 0.1.0), by YangHonghang:
a page plugin whose host part runs a service on 127.0.0.1:3492 and, on a schedule
(after a quota window resets, daily at a set time, or every N hours), sends "hi"
with max_tokens 16 through magpie's gateway to a provider/account/model the user picks.
The registry entry moves from the author's own npm package magpie-window-warmup to this one.
The package README opens with the zh/en warning that sends spend real quota and that some
vendors (Claude subscriptions especially) may treat scheduled requests as unusual use.

Reviewed at 07a0b217adb2a111f839c984cbc955c5bb45b68d:
- Outside packages/window-warmup only README.md and registry.json change; no workflow and no other package.
- The service binds 127.0.0.1, checks Host (DNS rebinding) and Origin (null or itself),
  needs a per-process 32-byte token on /api/*, and serves the index with a nonce CSP.
- It reaches only MAGPIE_ADDR (default 127.0.0.1:3425). providers.json is read for sha256
  key fingerprints only; no spawn, eval or outside hosts.
- A window task sends at most once per resetsAt (or once per hour when idle); daily/every
  tasks catch up only the latest missed point, once.

Run on mote (bun 1.4.2):
- HOME=$(mktemp -d) bun test at the repo root: 5142 pass, 15 skip, 0 fail.
- scripts/check.mjs ok.
- packages/window-warmup bun test: 242 pass (dist.test rebuilds dist byte for byte).
- browser.test.ts with Playwright 1.62.0: chromium and webkit pass. Bun ignores NODE_PATH,
  so it needs node_modules/playwright linked and PLAYWRIGHT_BROWSERS_PATH set under a temp HOME;
  without them it skips.
Not tried: a real send through a live magpie gateway, and tsc --noEmit (no typescript on mote).
2026-11-03 15:43:10 +08:00

25 lines
959 B
HTML

<!doctype html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>窗口预热</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main class="app">
<div class="wrap">
<div class="bar">
<span class="sum" id="sum"></span>
<span class="sp"></span>
<button class="qm" id="info" aria-label="说明">?<span class="tip">消息按供应商自己的额度规则计费,可能用到赠送额度或 API 余额;发送成功不代表窗口一定已开始计时。<br>Magpie 关闭期间不会执行,重新打开后每个任务最多补发一次。<br>失败不会暂停任务,下一次照常执行。</span></button>
<button class="btn" id="new">新建任务</button>
</div>
<div id="bars"></div>
<div class="list" id="list"></div>
</div>
</main>
<script src="app.js" type="module"></script>
</body>
</html>