@magpie-community/opencode-zen-free-auth 0.1.8 → 0.1.9

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.md CHANGED
@@ -31,7 +31,10 @@ windows and reasoning levels. Use `opencode-zen-free/<model>`, for example
31
31
  Retired models and SystemOne models are excluded. The list is asked
32
32
  again each time the host lists models (magpie does this on start and every
33
33
  hour): a model Zen no longer gives free leaves it, and a new free one joins
34
- it. When Zen's list can't be read, the last list is kept. A request for a
34
+ it. A model Zen lists as `-free` that OpenCode's catalog and docs don't
35
+ describe yet (or can't be read) is offered too, on Chat Completions, as
36
+ OpenCode asks a model with no package of its own. When Zen's list can't be
37
+ read, the last list is kept. A request for a
35
38
  model that isn't free now gets a 404 naming the free ones; one made free
36
39
  since the last list is served after the list is asked again (at most once a
37
40
  minute). Availability and rate limits are set by Zen; the plugin has no
package/models.mjs CHANGED
@@ -41,13 +41,31 @@ export function isFree(id, model = {}) {
41
41
  );
42
42
  }
43
43
 
44
+ // A model Zen lists whose id says it is free (Zen names them "-free"), and
45
+ // that neither the catalog nor the docs describe yet: Zen made it free
46
+ // after they were last written (deepseek-v4.1-flash-free, yetone/magpie#2385),
47
+ // or they couldn't be read. It is asked as OpenCode asks a model with no
48
+ // package of its own, through the provider's (openai-compatible, chat), so
49
+ // a new free model is offered the hour Zen lists it, not when the catalog
50
+ // or this plugin catch up. A paid or zero-cost id the id doesn't call free
51
+ // still needs the catalog's word.
52
+ function listedFree(id) {
53
+ return /-free$/.test(id);
54
+ }
55
+
44
56
  export function buildModels(ids, provider, protocols, baseURL) {
45
57
  const result = {};
46
58
  for (const id of ids) {
47
59
  if (typeof id !== "string" || !id || id === "__proto__") continue;
48
60
  const raw = provider.models?.[id];
49
61
  const model = raw ?? {};
50
- const protocol = protocols[id] ?? (raw && sdkProtocol(model.provider?.npm ?? provider.npm));
62
+ const protocol =
63
+ protocols[id] ??
64
+ (raw
65
+ ? sdkProtocol(model.provider?.npm ?? provider.npm)
66
+ : listedFree(id)
67
+ ? (sdkProtocol(provider.npm) ?? "chat")
68
+ : undefined);
51
69
  if (!isFree(id, model) || !Object.hasOwn(SDK, protocol)) continue;
52
70
  const input = model.modalities?.input ?? ["text"];
53
71
  const output = model.modalities?.output ?? ["text"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-zen-free-auth",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "OpenCode Zen free models through the public credential, with native streaming protocols",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
package/provider.mjs CHANGED
@@ -228,7 +228,11 @@ async function server(_input, options = {}) {
228
228
  discovered[id] = known[id];
229
229
  }
230
230
  }
231
- discovered[Symbol.for("magpie.fellBack")] = true;
231
+ // Not said as fallen back: Zen's own list was read, and what it
232
+ // lists is what is offered. Said so, magpie kept the last list read
233
+ // in full instead, and a user who can't reach the catalog or the
234
+ // docs (GitHub's raw host, from mainland China) never saw a model
235
+ // Zen made free since (yetone/magpie#2385).
232
236
  }
233
237
  known = discovered;
234
238
  listed = true;