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

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
@@ -19,6 +19,12 @@ magpie plugin login opencode-zen-free
19
19
  ## Sign in
20
20
 
21
21
  Enter `public` in the key field. No personal API key is needed.
22
+
23
+ Whatever is typed in the key field, the plugin signs in with the one
24
+ shared `public` credential: a key made under your own OpenCode account
25
+ does nothing here, and several of them don't make several accounts. Your
26
+ own Zen keys go in magpie's built-in OpenCode Zen provider (or OpenCode's
27
+ `opencode` provider), which takes several keys.
22
28
  The credential is kept in OpenCode's `auth.json` or magpie's
23
29
  `plugin-auth.json`.
24
30
 
@@ -31,7 +37,10 @@ windows and reasoning levels. Use `opencode-zen-free/<model>`, for example
31
37
  Retired models and SystemOne models are excluded. The list is asked
32
38
  again each time the host lists models (magpie does this on start and every
33
39
  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
40
+ it. A model Zen lists as `-free` that OpenCode's catalog and docs don't
41
+ describe yet (or can't be read) is offered too, on Chat Completions, as
42
+ OpenCode asks a model with no package of its own. When Zen's list can't be
43
+ read, the last list is kept. A request for a
35
44
  model that isn't free now gets a 404 naming the free ones; one made free
36
45
  since the last list is served after the list is asked again (at most once a
37
46
  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.10",
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;
@@ -253,7 +257,7 @@ async function server(_input, options = {}) {
253
257
  methods: [
254
258
  {
255
259
  type: "api",
256
- label: "Zen 免费访问(密钥填写 public)",
260
+ label: "Zen 免费访问(密钥填 public;自己的 OpenCode Key 请加到内置的 OpenCode Zen)",
257
261
  placeholder: "public",
258
262
  async authorize() {
259
263
  return { type: "success", key: "public" };