joycode 0.2.4: plan expiry, and one retry when gray access is denied (#701)

joycode 0.2.4 (kasisama):
- usage: the plan's expiry from the IDE's expireText (end of that day,
  China time) as `until`, with each pool's runsOutAt/runsOut; the package
  row decides, otherwise the earliest pool.
- a gray-access denial is retried once with the identity read again.
- gateway failures are read from a clone of the reply (64KB at most); a
  JSON reply over 8MB answers 502 response_too_large.
- an empty catalogue keeps the built-in models, which are text-only.

The first head (f16034b2) turned the repo suite red: usage.test.mjs
called t.mock.method(globalThis, 'fetch') several times in one test, Bun
1.4 restored the wrong function, and the next file (joycode/login.test)
and ~450 tests after it kept hitting the mock. b1f06b75 installs the
mock once per test; nothing outside usage.test.mjs changed.

Run at the reviewed head b1f06b7501bddb4f035eee069bf44d89f02e5349 (mote):
- whole repo `bun test`: 5374 pass, 19 skip, 0 fail (401 files).
- at f16034b2: the same run had its first red in joycode/login.test.mjs
  right after usage.test.mjs, an AssertionError from usage.test.mjs's
  mock (the leak above).
- CI run 41772835368 on b1f06b75: success.
Not tried: a real JoyCode account (none here); the gray-denial retry and
expiry phrases are checked against the tests' fixtures only.
This commit is contained in:
kassama
2026-11-04 12:42:45 +08:00
committed by GitHub
parent 075cd237e2
commit f6fdf8fee1
7 changed files with 317 additions and 53 deletions
+16
View File
@@ -68,3 +68,19 @@ test('catalogue fetch failure returns original fallback model list', async t =>
const { models, provider } = await load(t, { failList: true })
assert.equal(models, provider.models)
})
test('empty catalogue keeps the fallback model list', async t => {
const { models, provider } = await load(t, { list: [] })
assert.equal(models, provider.models)
})
test('a catalogue of only hidden models does not fall back', async t => {
const { models } = await load(t, { list: [{ chatApiModel: 'JoyAI-Code-1.6', hidden: true }] })
assert.deepEqual(models, {})
})
test('static fallback models do not advertise image input', async t => {
const hooks = await plugin.server({})
const cfg = {}
await hooks.config(cfg)
for (const id of ['Kimi-K2.6-agent', 'MiniMax-M3-agent', 'Doubao-Seed-2.0-pro-agent']) {
assert.deepEqual(cfg.provider.joycode.models[id].modalities.input, ['text'])
}
})