@vheins/opencode-9router 0.1.0 → 0.2.0

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/index.ts CHANGED
@@ -1 +1 @@
1
- export { default } from "./src/plugin";
1
+ export { NineRouterPlugin } from "./src/plugin";
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@vheins/opencode-9router",
3
3
  "module": "index.ts",
4
- "version": "0.1.0",
4
+ "main": "index.ts",
5
+ "version": "0.2.0",
5
6
  "description": "OpenCode plugin provider for 9Router — FREE AI Router & Token Saver. 40+ providers, 100+ models.",
6
7
  "author": "vheins",
7
8
  "keywords": [
@@ -14,7 +15,10 @@
14
15
  "token-saver",
15
16
  "plugin"
16
17
  ],
17
- "repository": "https://github.com/vheins/opencode-9router",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/vheins/opencode-9router.git"
21
+ },
18
22
  "files": [
19
23
  "index.ts",
20
24
  "src"
@@ -22,13 +26,12 @@
22
26
  "license": "MIT",
23
27
  "type": "module",
24
28
  "devDependencies": {
29
+ "@opencode-ai/plugin": "^1.0.182",
25
30
  "@opencode-ai/sdk": "^1.0.182",
26
31
  "@types/bun": "latest"
27
32
  },
28
33
  "peerDependencies": {
34
+ "@opencode-ai/plugin": "^1.0.182",
29
35
  "typescript": "^5.9.3"
30
- },
31
- "dependencies": {
32
- "@opencode-ai/plugin": "^1.0.182"
33
36
  }
34
37
  }
package/src/plugin.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Plugin, PluginInput } from "@opencode-ai/plugin";
1
+ import type { PluginInput } from "@opencode-ai/plugin";
2
2
  import type { Auth } from "@opencode-ai/sdk";
3
3
  import {
4
4
  PLUGIN_NAME,
@@ -45,8 +45,8 @@ async function discoverModels(
45
45
  }
46
46
  }
47
47
 
48
- const plugin: Plugin = async ({ client }: PluginInput, options?: { baseURL?: string }) => {
49
- const configuredBaseURL = options?.baseURL ?? DEFAULT_BASE_URL;
48
+ export const NineRouterPlugin = async ({ client }: PluginInput) => {
49
+ const configuredBaseURL = DEFAULT_BASE_URL;
50
50
 
51
51
  const discovered = await discoverModels(configuredBaseURL);
52
52
  const models = discovered ?? FALLBACK_MODELS;
@@ -62,7 +62,6 @@ const plugin: Plugin = async ({ client }: PluginInput, options?: { baseURL?: str
62
62
  }
63
63
 
64
64
  return {
65
- // provider hook: auto-registers 9Router with models — NO manual opencode.json config needed
66
65
  provider: {
67
66
  [PLUGIN_NAME]: {
68
67
  npm: "@ai-sdk/openai-compatible",
@@ -73,13 +72,10 @@ const plugin: Plugin = async ({ client }: PluginInput, options?: { baseURL?: str
73
72
  models,
74
73
  },
75
74
  },
76
-
77
- // auth hook: enables /connect flow with configurable baseURL + API key
78
75
  auth: {
79
76
  provider: PLUGIN_NAME,
80
- async loader(getAuth: () => Promise<Auth>, _provider: unknown) {
77
+ async loader(getAuth: () => Promise<Auth>) {
81
78
  const auth = await getAuth();
82
- // If user set custom baseURL via /connect, override the provider default
83
79
  if (auth && typeof auth === "object" && "baseURL" in auth) {
84
80
  return { baseURL: `${String(auth.baseURL)}${DEFAULT_API_PATH}` };
85
81
  }
@@ -107,5 +103,3 @@ const plugin: Plugin = async ({ client }: PluginInput, options?: { baseURL?: str
107
103
  },
108
104
  };
109
105
  };
110
-
111
- export default plugin;