New package @magpie-community/opencode-inkstone-auth 0.1.0 for Intern InkStone (书生·端砚, Shanghai AI Lab) Token Plan, provider id `intern-inkstone`. Community package by yunwang2442-creator. What it does: - Browser sign-in (Edge/Chrome, its own profile under $XDG_CONFIG_HOME or ~/.config/magpie/inkstone-browser, or %LOCALAPPDATA%\magpie\inkstone-browser). The login window has no debugging port. A headless CDP read takes the uaa-token cookie, and the same read renews it silently later. - Usage card: ink-credit balance, 5-hour and 7-day windows, credit packs. - Chat: a pasted ink-* API key, or one the sign-in creates, named ink-<host4>-<acct4>-<rand4> (18 of the console's 20 characters). An idempotency clash (-15109) retries with a fresh name, up to three times. Pruning is on by default. It only touches this machine's and account's prefix, keeps the newest two and the key this sign-in created, and never deletes manual keys or keys of unknown age. - Closing on Unix: SIGTERM, then SIGKILL only after a 15s grace. Leftover browsers are matched by --user-data-dir=<escaped profile>, and Windows uses .Contains(). - The login wait comes from an injected waitForLogin in tests. No env hook is left in production code. - Hosts: discovery.intern-ai.org.cn, discovery-api.intern-ai.org.cn, 127.0.0.1 (CDP). Outside the package: scripts/opencode2.mjs lets a prompt with `required: false` stay optional (`p.required !== false`). Every package's copy is synced byte for byte, so all 39 copies in the merged tree are blobafe074cb. No other package sets `required: false` on a prompt, so this changes nothing for them. Also a root README row and a registry entry. Review at 36412a15, on mote, HOME=$(mktemp -d), Bun 1.4.2: - bun test packages/inkstone: 68 pass, 0 fail in Asia/Shanghai, UTC, America/Los_Angeles and Pacific/Kiritimati. - bun scripts/check.mjs inkstone and bun scripts/check.mjs: ok. - bun test (repo), on 36412a15 merged with origin/maine7cb9dc5: 6743 pass, 20 skip, 0 fail. main has since moved by cline 0.1.14 and zcode 0.1.55 only, and none of the adapter copies changed. - Broken by hand, each red: no protectName protection; prune_keys default off; no post-sign-in prune; no SIGTERM on close; the -15109 retry keeping its name. Not tried: a real InkStone account sign-in on macOS, Linux or Windows (no account here); a live chat request; magpie end to end with the plugin.
48 lines
2.0 KiB
JavaScript
48 lines
2.0 KiB
JavaScript
// The GUI's option page keeps at most 60 characters per localized label and
|
|
// 300 per localized description or confirm. The English `label` / `description`
|
|
// / `confirm` fields are the fallback for older hosts and OpenCode, so the
|
|
// localized `labels` / `descriptions` / `confirms` carry the same rules in
|
|
// the same five languages.
|
|
import "./nonet.mjs"
|
|
import { expect, test } from "bun:test"
|
|
import { InkStoneAuthPlugin } from "./index.mjs"
|
|
|
|
const languages = ["de", "ja", "zh", "zh-TW"]
|
|
const lengthOf = (text) => [...String(text)].length
|
|
|
|
test("the config screen's strings stay inside the host's caps and stay translated", async () => {
|
|
const plugin = await InkStoneAuthPlugin({ client: { auth: { set: async () => {} } } })
|
|
const options = plugin.auth.options
|
|
expect(options.map((option) => option.key)).toEqual([
|
|
"create_key",
|
|
"prune_keys",
|
|
"keep_sign_in",
|
|
])
|
|
|
|
for (const option of options) {
|
|
expect(lengthOf(option.label)).toBeLessThanOrEqual(60)
|
|
expect(lengthOf(option.description)).toBeLessThanOrEqual(300)
|
|
|
|
for (const field of ["labels", "descriptions"]) {
|
|
const localized = option[field]
|
|
expect(localized).toBeDefined()
|
|
expect(Object.keys(localized).sort()).toEqual(languages)
|
|
const cap = field === "labels" ? 60 : 300
|
|
for (const lang of languages) {
|
|
expect(lengthOf(localized[lang])).toBeLessThanOrEqual(cap)
|
|
}
|
|
}
|
|
}
|
|
|
|
const prune = options.find((option) => option.key === "prune_keys")
|
|
expect(lengthOf(prune.confirm)).toBeLessThanOrEqual(300)
|
|
expect(Object.keys(prune.confirms).sort()).toEqual(languages)
|
|
for (const lang of languages) expect(lengthOf(prune.confirms[lang])).toBeLessThanOrEqual(300)
|
|
|
|
// The English fallback tells every account where the line is: the key
|
|
// created on this sign-in, and keys whose creation time is unreadable.
|
|
expect(prune.description).toContain("The key created on this sign-in is always kept")
|
|
expect(prune.description).toContain("manual keys")
|
|
expect(prune.description).toContain("creation time cannot be read")
|
|
})
|