opencommand-plugin 0.0.13 → 0.0.15

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/dist/index.js CHANGED
@@ -96,6 +96,15 @@ export const COMMAND_CODE_GO_PLAN_MODELS = [
96
96
  output: 8192,
97
97
  cost: { input: 0.27, output: 0.95, cache_read: 0.03 },
98
98
  },
99
+ {
100
+ id: "Qwen/Qwen3.7-Max",
101
+ name: "Qwen 3.7 Max",
102
+ description: "State-of-the-art Qwen reasoning and agent execution",
103
+ reasoning: true,
104
+ context: 200000,
105
+ output: 8192,
106
+ cost: { input: 1.3, output: 7.8, cache_read: 0.26, cache_write: 1.63 },
107
+ },
99
108
  {
100
109
  id: "Qwen/Qwen3.6-Max-Preview",
101
110
  name: "Qwen 3.6 Max Preview",
@@ -939,12 +948,15 @@ function writeCachedOpenCommandModels(models) {
939
948
  function openCommandModelCachePath() {
940
949
  return path.join(process.env.HOME || "/tmp", ".opencommand", "model-cache.json");
941
950
  }
942
- function proxyBaseURLForRegistration() {
951
+ async function proxyBaseURLForRegistration() {
943
952
  const runtimeConfig = runtimePlugin?.getCurrentProxyConfig();
944
953
  if (runtimeConfig)
945
954
  return `http://localhost:${runtimeConfig.port}/v1`;
946
955
  const persistedBaseURL = readPersistedProxyBaseURL();
947
- return persistedBaseURL ?? DEFAULT_PROXY_BASE_URL;
956
+ if (persistedBaseURL && (await isProxyHealthy(persistedBaseURL))) {
957
+ return persistedBaseURL;
958
+ }
959
+ return DEFAULT_PROXY_BASE_URL;
948
960
  }
949
961
  function readPersistedProxyBaseURL() {
950
962
  try {
@@ -962,6 +974,33 @@ function readPersistedProxyBaseURL() {
962
974
  }
963
975
  return undefined;
964
976
  }
977
+ async function isProxyHealthy(baseURL) {
978
+ const controller = new AbortController();
979
+ const timeoutId = setTimeout(() => controller.abort(), 500);
980
+ try {
981
+ const response = await fetch(`${baseURL.replace(/\/v1\/?$/, "")}/healthz`, {
982
+ signal: controller.signal,
983
+ });
984
+ return response.ok;
985
+ }
986
+ catch {
987
+ return false;
988
+ }
989
+ finally {
990
+ clearTimeout(timeoutId);
991
+ }
992
+ }
993
+ async function currentProxyBaseURL(plugin) {
994
+ try {
995
+ const proxyConfig = await plugin.ensureStarted();
996
+ if (proxyConfig)
997
+ return `http://localhost:${proxyConfig.port}/v1`;
998
+ }
999
+ catch (error) {
1000
+ debugError("Failed to start OpenCommand proxy for provider registration:", error);
1001
+ }
1002
+ return proxyBaseURLForRegistration();
1003
+ }
965
1004
  function parseProxyPort(value) {
966
1005
  const port = Number(value);
967
1006
  return Number.isInteger(port) && port > 0 && port < 65536 ? port : undefined;
@@ -972,7 +1011,8 @@ function getRuntimePlugin() {
972
1011
  return runtimePlugin;
973
1012
  }
974
1013
  export const OpenCommandOpenCodePlugin = async () => {
975
- const baseURL = proxyBaseURLForRegistration();
1014
+ const plugin = getRuntimePlugin();
1015
+ const baseURL = await currentProxyBaseURL(plugin);
976
1016
  return {
977
1017
  provider: {
978
1018
  [PROVIDER_ID]: {
@@ -999,12 +1039,8 @@ export const OpenCommandOpenCodePlugin = async () => {
999
1039
  methods: [],
1000
1040
  },
1001
1041
  config: async (config) => {
1002
- const plugin = getRuntimePlugin();
1003
1042
  plugin.preloadForOpenCode();
1004
- const currentConfig = plugin.getCurrentProxyConfig();
1005
- const registrationBaseURL = currentConfig
1006
- ? `http://localhost:${currentConfig.port}/v1`
1007
- : proxyBaseURLForRegistration();
1043
+ const registrationBaseURL = await currentProxyBaseURL(plugin);
1008
1044
  registerOpenCommandProvider(config, registrationBaseURL, readCachedOpenCommandModels() ?? COMMAND_CODE_GO_PLAN_MODELS);
1009
1045
  },
1010
1046
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencommand-plugin",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "OpenCommand - CommandCode API Plugin for OpenCode",
5
5
  "main": "./bin/opencode-plugin.js",
6
6
  "module": "./bin/opencode-plugin.js",