@gopersonal/advisor 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/build/index.js +24 -13
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -7,35 +7,45 @@ import { createOpencode, createOpencodeClient } from "@opencode-ai/sdk/v2";
7
7
  //
8
8
  // Pass these via the "env" field in the MCP config JSON.
9
9
  //
10
- // Option A: OpenAI-compatible endpoint
10
+ // Option A: OpenAI-compatible endpoint (most providers, proxies, etc.)
11
11
  // ADVISOR_PROVIDER = "openai"
12
- // ADVISOR_MODEL = "gpt-4o" (just the model name)
12
+ // ADVISOR_MODEL = "gpt-4o"
13
13
  // ADVISOR_API_KEY = "sk-..."
14
- // ADVISOR_BASE_URL = "https://api.openai.com/v1" (optional, default OpenAI)
14
+ // ADVISOR_BASE_URL = "https://api.openai.com/v1"
15
15
  //
16
16
  // Option B: Anthropic-compatible endpoint
17
17
  // ADVISOR_PROVIDER = "anthropic"
18
- // ADVISOR_MODEL = "claude-sonnet-4-5" (just the model name)
18
+ // ADVISOR_MODEL = "claude-sonnet-4-5"
19
19
  // ADVISOR_API_KEY = "sk-ant-..."
20
- // ADVISOR_BASE_URL = "https://api.anthropic.com" (optional, default Anthropic)
20
+ // ADVISOR_BASE_URL = "https://api.anthropic.com"
21
21
  //
22
- // Legacy format (still works):
23
- // ADVISOR_MODEL = "anthropic/claude-sonnet-4-5" (provider/model combined)
22
+ // ADVISOR_BASE_URL is required when using a custom/proxy endpoint.
23
+ // If omitted, the default API URL for the provider is used.
24
24
  //
25
25
  function resolveProviderAndModel() {
26
26
  const explicitProvider = process.env.ADVISOR_PROVIDER?.toLowerCase();
27
27
  const rawModel = process.env.ADVISOR_MODEL;
28
28
  if (!rawModel)
29
29
  return undefined;
30
- // Option 1: explicit ADVISOR_PROVIDER + ADVISOR_MODEL (recommended)
31
30
  if (explicitProvider) {
31
+ // "openai" provider in opencode uses OpenAI's Responses API which most
32
+ // compatible endpoints don't support. Use @ai-sdk/openai-compatible instead,
33
+ // which calls the standard /v1/chat/completions endpoint.
34
+ if (explicitProvider === "openai") {
35
+ return {
36
+ provider: "openai-compat",
37
+ model: rawModel,
38
+ fullModel: `openai-compat/${rawModel}`,
39
+ npm: "@ai-sdk/openai-compatible",
40
+ };
41
+ }
32
42
  return {
33
43
  provider: explicitProvider,
34
44
  model: rawModel,
35
45
  fullModel: `${explicitProvider}/${rawModel}`,
36
46
  };
37
47
  }
38
- // Option 2: legacy "provider/model" format in ADVISOR_MODEL
48
+ // Legacy "provider/model" format in ADVISOR_MODEL
39
49
  if (rawModel.includes("/")) {
40
50
  const [provider, ...rest] = rawModel.split("/");
41
51
  return {
@@ -44,18 +54,19 @@ function resolveProviderAndModel() {
44
54
  fullModel: rawModel,
45
55
  };
46
56
  }
47
- // Just a model name with no provider — default to openai
57
+ // Just a model name with no provider — use openai-compatible
48
58
  return {
49
- provider: "openai",
59
+ provider: "openai-compat",
50
60
  model: rawModel,
51
- fullModel: `openai/${rawModel}`,
61
+ fullModel: `openai-compat/${rawModel}`,
62
+ npm: "@ai-sdk/openai-compatible",
52
63
  };
53
64
  }
54
65
  function buildOpencodeConfig() {
55
66
  const resolved = resolveProviderAndModel();
56
67
  const apiKey = process.env.ADVISOR_API_KEY;
57
68
  const baseURL = process.env.ADVISOR_BASE_URL;
58
- const npm = process.env.ADVISOR_NPM;
69
+ const npm = process.env.ADVISOR_NPM || resolved?.npm;
59
70
  const config = {
60
71
  // Disable title generation (it uses small_model which may not work with custom providers)
61
72
  small_model: resolved?.fullModel || undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopersonal/advisor",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "main": "./build/index.js",
6
6
  "bin": {