diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 14bb170..1029d5a 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -148,7 +148,7 @@ echo "$jwt" | cut -d. -f2 | base64 -d 2>/dev/null | jq '{aud, iss, sub}' The principled fix on the embedder side: ```ts -import { OAuth2ModelSyncPlugin } from "@vymalo/opencode-oauth2"; +import { OAuth2ModelSyncPlugin } from "@vymalo/opencode-oauth2/lib"; const runtime = new OAuth2ModelSyncPlugin(cfg, { /* ... */ }); await runtime.initialize(); await runtime.start({ warmup: true, interactive: false }); diff --git a/package.json b/package.json index 0793334..fe8de04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opencode-oauth2-workspace", - "version": "0.2.0", + "version": "0.2.1", "private": true, "description": "Workspace for @vymalo/opencode-oauth2 — OAuth2/OIDC-secured OpenAI-compatible providers for OpenCode.", "packageManager": "pnpm@11.3.0", diff --git a/packages/opencode-oauth2/package.json b/packages/opencode-oauth2/package.json index a12a9df..8c3bd1c 100644 --- a/packages/opencode-oauth2/package.json +++ b/packages/opencode-oauth2/package.json @@ -1,6 +1,6 @@ { "name": "@vymalo/opencode-oauth2", - "version": "0.2.0", + "version": "0.2.1", "description": "OpenCode plugin for OAuth2/OIDC-secured, OpenAI-compatible model providers with periodic model sync.", "license": "MIT", "author": "vymalo contributors", @@ -25,6 +25,17 @@ "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + }, + "./lib": { + "types": "./dist/lib.d.ts", + "import": "./dist/lib.js" + }, + "./package.json": "./package.json" + }, "sideEffects": false, "files": [ "dist" diff --git a/packages/opencode-oauth2/src/index.ts b/packages/opencode-oauth2/src/index.ts index df6500d..3f2c4d7 100644 --- a/packages/opencode-oauth2/src/index.ts +++ b/packages/opencode-oauth2/src/index.ts @@ -1,35 +1,5 @@ -export { - DEFAULT_HTTP_TIMEOUT_MS, - DEFAULT_SYNC_INTERVAL_MINUTES, - type OAuth2ModelSyncConfig, - type OAuth2ModelSyncConfigInput, - type OAuthServerConfig, - type OAuthServerConfigInput, - validateConfig -} from "./config.js"; - -export { createJsonConsoleLogger, type LogLevel, type Logger } from "./logging.js"; - -export { buildModelsUrl, fetchModels } from "./model-discovery.js"; - -export { diffModels, normalizeModelId, normalizeModelList } from "./model-normalization.js"; - -export { OAuth2ModelSyncPlugin, type PluginOptions } from "./plugin.js"; - -export { resolveCacheDir, FileCacheStore } from "./cache.js"; - -export { - createOpencodeOauth2Plugin, - OpencodeOauth2Plugin, - OpencodeOauth2Plugin as default -} from "./opencode.js"; -export type { OpenCodePluginFactoryOptions } from "./opencode.js"; - -export type { - CachedServerState, - ModelDiff, - NormalizedModel, - RawModel, - ServerSnapshot, - TokenSet -} from "./types.js"; +// OpenCode plugin entry. The host iterates every named export of this module +// and rejects any export that isn't a Plugin function (or { server: Plugin }). +// Only the plugin function lives here; the library API is in ./lib.ts and is +// exposed via the "./lib" subpath in package.json. +export { default } from "./opencode.js"; diff --git a/packages/opencode-oauth2/src/lib.ts b/packages/opencode-oauth2/src/lib.ts new file mode 100644 index 0000000..484dfdc --- /dev/null +++ b/packages/opencode-oauth2/src/lib.ts @@ -0,0 +1,31 @@ +export { + DEFAULT_HTTP_TIMEOUT_MS, + DEFAULT_SYNC_INTERVAL_MINUTES, + type OAuth2ModelSyncConfig, + type OAuth2ModelSyncConfigInput, + type OAuthServerConfig, + type OAuthServerConfigInput, + validateConfig +} from "./config.js"; + +export { createJsonConsoleLogger, type LogLevel, type Logger } from "./logging.js"; + +export { buildModelsUrl, fetchModels } from "./model-discovery.js"; + +export { diffModels, normalizeModelId, normalizeModelList } from "./model-normalization.js"; + +export { OAuth2ModelSyncPlugin, type PluginOptions } from "./plugin.js"; + +export { resolveCacheDir, FileCacheStore } from "./cache.js"; + +export { createOpencodeOauth2Plugin } from "./opencode.js"; +export type { OpenCodePluginFactoryOptions } from "./opencode.js"; + +export type { + CachedServerState, + ModelDiff, + NormalizedModel, + RawModel, + ServerSnapshot, + TokenSet +} from "./types.js"; diff --git a/packages/plugin-bundle/package.json b/packages/plugin-bundle/package.json index e8ef53c..27dd9b8 100644 --- a/packages/plugin-bundle/package.json +++ b/packages/plugin-bundle/package.json @@ -1,6 +1,6 @@ { "name": "@vymalo/opencode-oauth2-bundle", - "version": "0.2.0", + "version": "0.2.1", "private": true, "type": "module", "scripts": {