aisubs 0.3.8 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.9 - 2026-09-22
4
+
5
+ - Resolve the current OpenCode release for every authorized request instead of
6
+ caching or falling back to a stale compatibility version.
7
+ - Rebuild AISubs before Core Loop release bundling so packaged consumers receive
8
+ the current provider authorization logic.
9
+
3
10
  ## 0.3.8 - 2026-09-19
4
11
 
5
12
  - Breaking: `createSubscriptionAuth` now requires an explicit credential store.
@@ -1,6 +1,5 @@
1
1
  import type { ProviderAdapter, ProviderUsageData } from "../types.js";
2
2
  export interface OpenCodeProviderOptions {
3
- compatibilityVersion?: string;
4
3
  fetch?: typeof globalThis.fetch;
5
4
  }
6
5
  export declare function parseOpenCodeGoUsage(raw: unknown): ProviderUsageData | null;
@@ -2,8 +2,6 @@ import { randomBytes } from "node:crypto";
2
2
  import { bearerRequest, isRecord, numberValue, requireAllowedHost, responseJson, stringArray, stringValue, } from "../utils.js";
3
3
  const API_HOST = "opencode.ai";
4
4
  const API_KEY_LIFETIME_MS = 365 * 24 * 60 * 60_000;
5
- const DEFAULT_COMPATIBILITY_VERSION = "1.18.31";
6
- const COMPATIBILITY_VERSION_TTL_MS = 60 * 60_000;
7
5
  const ID_PATTERN = /^(ses|msg)_[0-9a-f]{12}[0-9A-Za-z]{14}$/;
8
6
  const ID_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
9
7
  function openCodeUsageMeter(id, label, raw) {
@@ -40,26 +38,15 @@ export function parseOpenCodeGoUsage(raw) {
40
38
  }
41
39
  function openCodeProvider(config, options = {}) {
42
40
  const fetcher = options.fetch ?? globalThis.fetch;
43
- let versionRequest;
44
- let versionExpiresAt = 0;
45
- const compatibilityVersion = () => {
46
- if (options.compatibilityVersion)
47
- return Promise.resolve(options.compatibilityVersion);
48
- if (!versionRequest || Date.now() >= versionExpiresAt) {
49
- versionExpiresAt = Date.now() + COMPATIBILITY_VERSION_TTL_MS;
50
- versionRequest = fetcher("https://api.github.com/repos/anomalyco/opencode/releases/latest", {
51
- headers: { accept: "application/vnd.github+json", "user-agent": "aisubs" },
52
- })
53
- .then(async (response) => {
54
- if (!response.ok)
55
- throw new Error(`OpenCode version lookup failed: ${response.status}`);
56
- const raw = await response.json();
57
- return isRecord(raw) ? stringValue(raw.tag_name)?.replace(/^v/, "") : undefined;
58
- })
59
- .then((version) => version || DEFAULT_COMPATIBILITY_VERSION)
60
- .catch(() => DEFAULT_COMPATIBILITY_VERSION);
61
- }
62
- return versionRequest;
41
+ const compatibilityVersion = async () => {
42
+ const response = await fetcher("https://api.github.com/repos/anomalyco/opencode/releases/latest", { headers: { accept: "application/vnd.github+json", "user-agent": "aisubs" } });
43
+ if (!response.ok)
44
+ throw new Error(`OpenCode version lookup failed: ${response.status}`);
45
+ const raw = await response.json();
46
+ const version = isRecord(raw) ? stringValue(raw.tag_name)?.replace(/^v/, "") : undefined;
47
+ if (!version)
48
+ throw new Error("OpenCode version lookup returned no release version");
49
+ return version;
63
50
  };
64
51
  const routingIds = new Map();
65
52
  let lastTimestamp = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aisubs",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Connect AI provider accounts and use those subscriptions from any local tool or as api.",
5
5
  "keywords": [
6
6
  "ai",