osagent 0.1.68 → 0.1.70

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/dist/cli.js +105 -37
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -142630,6 +142630,18 @@ var init_openrouter = __esm({
142630
142630
  });
142631
142631
 
142632
142632
  // packages/core/dist/src/core/openaiContentGenerator/provider/ollama.js
142633
+ function getEffectiveOllamaUrl() {
142634
+ const ollamaHost = process.env["OLLAMA_HOST"];
142635
+ if (ollamaHost) {
142636
+ const url3 = ollamaHost.startsWith("http") ? ollamaHost : `http://${ollamaHost}`;
142637
+ return url3.replace(/\/$/, "");
142638
+ }
142639
+ const ollamaBaseUrl = process.env["OLLAMA_BASE_URL"];
142640
+ if (ollamaBaseUrl) {
142641
+ return ollamaBaseUrl.replace(/\/v1\/?$/, "").replace(/\/$/, "");
142642
+ }
142643
+ return "http://localhost:11434";
142644
+ }
142633
142645
  var OllamaOpenAICompatibleProvider;
142634
142646
  var init_ollama = __esm({
142635
142647
  "packages/core/dist/src/core/openaiContentGenerator/provider/ollama.js"() {
@@ -142637,6 +142649,7 @@ var init_ollama = __esm({
142637
142649
  init_esbuild_shims();
142638
142650
  init_openai();
142639
142651
  init_constants2();
142652
+ __name(getEffectiveOllamaUrl, "getEffectiveOllamaUrl");
142640
142653
  OllamaOpenAICompatibleProvider = class {
142641
142654
  static {
142642
142655
  __name(this, "OllamaOpenAICompatibleProvider");
@@ -142652,7 +142665,9 @@ var init_ollama = __esm({
142652
142665
  */
142653
142666
  static isOllamaProvider(config2) {
142654
142667
  const baseUrl = config2.baseUrl?.toLowerCase() || "";
142655
- return baseUrl.includes("ollama.com") || baseUrl.includes("localhost:11434") || baseUrl.includes("127.0.0.1:11434");
142668
+ const effectiveUrl = getEffectiveOllamaUrl().toLowerCase();
142669
+ return baseUrl.includes("ollama.com") || baseUrl.includes("localhost:11434") || baseUrl.includes("127.0.0.1:11434") || // Also check for OLLAMA_HOST configured URLs
142670
+ effectiveUrl.includes(baseUrl.replace(/https?:\/\//, "").replace("/v1", ""));
142656
142671
  }
142657
142672
  /**
142658
142673
  * Check if this is OS Agent Cloud (vs Local)
@@ -142694,7 +142709,7 @@ var init_ollama = __esm({
142694
142709
  * Check if Ollama server is running and accessible
142695
142710
  */
142696
142711
  async checkHealth() {
142697
- const baseUrl = this.contentGeneratorConfig.baseUrl?.replace("/v1", "") || "http://localhost:11434";
142712
+ const baseUrl = this.contentGeneratorConfig.baseUrl?.replace("/v1", "") || getEffectiveOllamaUrl();
142698
142713
  try {
142699
142714
  const response = await fetch(`${baseUrl}/api/version`, {
142700
142715
  method: "GET",
@@ -142720,7 +142735,7 @@ var init_ollama = __esm({
142720
142735
  * Check if a specific model is available on the Ollama server
142721
142736
  */
142722
142737
  async isModelAvailable(model) {
142723
- const baseUrl = this.contentGeneratorConfig.baseUrl?.replace("/v1", "") || "http://localhost:11434";
142738
+ const baseUrl = this.contentGeneratorConfig.baseUrl?.replace("/v1", "") || getEffectiveOllamaUrl();
142724
142739
  try {
142725
142740
  const response = await fetch(`${baseUrl}/api/tags`, {
142726
142741
  method: "GET",
@@ -142749,7 +142764,7 @@ var init_ollama = __esm({
142749
142764
  * Pull a model from Ollama registry
142750
142765
  */
142751
142766
  async pullModel(model) {
142752
- const baseUrl = this.contentGeneratorConfig.baseUrl?.replace("/v1", "") || "http://localhost:11434";
142767
+ const baseUrl = this.contentGeneratorConfig.baseUrl?.replace("/v1", "") || getEffectiveOllamaUrl();
142753
142768
  try {
142754
142769
  const response = await fetch(`${baseUrl}/api/pull`, {
142755
142770
  method: "POST",
@@ -146447,6 +146462,20 @@ var init_qwenContentGenerator = __esm({
146447
146462
  });
146448
146463
 
146449
146464
  // packages/core/dist/src/core/contentGenerator.js
146465
+ function getEffectiveOllamaUrl2(includeV1 = true) {
146466
+ const ollamaHost = process.env["OLLAMA_HOST"];
146467
+ if (ollamaHost) {
146468
+ const url3 = ollamaHost.startsWith("http") ? ollamaHost : `http://${ollamaHost}`;
146469
+ const baseUrl = url3.replace(/\/$/, "");
146470
+ return includeV1 ? `${baseUrl}/v1` : baseUrl;
146471
+ }
146472
+ const ollamaBaseUrl = process.env["OLLAMA_BASE_URL"];
146473
+ if (ollamaBaseUrl) {
146474
+ const baseUrl = ollamaBaseUrl.replace(/\/v1\/?$/, "").replace(/\/$/, "");
146475
+ return includeV1 ? `${baseUrl}/v1` : baseUrl;
146476
+ }
146477
+ return includeV1 ? "http://localhost:11434/v1" : "http://localhost:11434";
146478
+ }
146450
146479
  function createCleanConfigBase(config2, authType, generationConfig) {
146451
146480
  return {
146452
146481
  authType,
@@ -146522,7 +146551,8 @@ function createContentGeneratorConfig(config2, authType, generationConfig) {
146522
146551
  return {
146523
146552
  ...baseConfig,
146524
146553
  model: ollamaModel,
146525
- baseUrl: "http://localhost:11434/v1",
146554
+ baseUrl: getEffectiveOllamaUrl2(true),
146555
+ // Gets OLLAMA_HOST or defaults to localhost:11434/v1
146526
146556
  apiKey: "ollama",
146527
146557
  authType: AuthType2.OLLAMA_LOCAL,
146528
146558
  // Ollama doesn't need special cache control handling
@@ -146557,7 +146587,7 @@ function createContentGeneratorConfig(config2, authType, generationConfig) {
146557
146587
  };
146558
146588
  }
146559
146589
  async function createContentGenerator(config2, gcConfig, sessionId2, isInitialAuth) {
146560
- const version3 = "0.1.68";
146590
+ const version3 = "0.1.70";
146561
146591
  const userAgent2 = `OSAgent/${version3} (${process.platform}; ${process.arch})`;
146562
146592
  const baseHeaders = {
146563
146593
  "User-Agent": userAgent2
@@ -146632,6 +146662,7 @@ var init_contentGenerator = __esm({
146632
146662
  init_models();
146633
146663
  init_installationManager();
146634
146664
  init_loggingContentGenerator();
146665
+ __name(getEffectiveOllamaUrl2, "getEffectiveOllamaUrl");
146635
146666
  (function(AuthType4) {
146636
146667
  AuthType4["LOGIN_WITH_OSAGENT"] = "oauth-personal";
146637
146668
  AuthType4["USE_OSA"] = "OSA-api-key";
@@ -224007,7 +224038,10 @@ var init_ollamaEmbedding = __esm({
224007
224038
  timeoutMs;
224008
224039
  dimensions;
224009
224040
  constructor(config2 = {}) {
224010
- this.baseUrl = config2.baseUrl ?? "http://localhost:11434";
224041
+ const ollamaHost = process.env["OLLAMA_HOST"];
224042
+ const ollamaBaseUrl = process.env["OLLAMA_BASE_URL"];
224043
+ const effectiveUrl = ollamaHost ? ollamaHost.startsWith("http") ? ollamaHost : `http://${ollamaHost}` : ollamaBaseUrl?.replace(/\/v1\/?$/, "") ?? "http://localhost:11434";
224044
+ this.baseUrl = config2.baseUrl ?? effectiveUrl.replace(/\/$/, "");
224011
224045
  this.model = config2.model ?? "nomic-embed-text";
224012
224046
  this.timeoutMs = config2.timeoutMs ?? 3e4;
224013
224047
  this.dimensions = this.model.includes("nomic") ? 768 : 384;
@@ -335686,7 +335720,7 @@ __name(getPackageJson, "getPackageJson");
335686
335720
  // packages/cli/src/utils/version.ts
335687
335721
  async function getCliVersion() {
335688
335722
  const pkgJson = await getPackageJson();
335689
- return "0.1.68";
335723
+ return "0.1.70";
335690
335724
  }
335691
335725
  __name(getCliVersion, "getCliVersion");
335692
335726
 
@@ -339855,8 +339889,8 @@ var formatDuration = /* @__PURE__ */ __name((milliseconds) => {
339855
339889
 
339856
339890
  // packages/cli/src/generated/git-commit.ts
339857
339891
  init_esbuild_shims();
339858
- var GIT_COMMIT_INFO2 = "8eb2854";
339859
- var CLI_VERSION2 = "0.1.68";
339892
+ var GIT_COMMIT_INFO2 = "3160e61";
339893
+ var CLI_VERSION2 = "0.1.70";
339860
339894
 
339861
339895
  // packages/cli/src/utils/systemInfo.ts
339862
339896
  async function getNpmVersion() {
@@ -341934,37 +341968,71 @@ function checkOllamaInstalled2() {
341934
341968
  }
341935
341969
  }
341936
341970
  __name(checkOllamaInstalled2, "checkOllamaInstalled");
341971
+ function getOllamaEndpoint() {
341972
+ const ollamaHost = process.env["OLLAMA_HOST"];
341973
+ if (ollamaHost) {
341974
+ const url3 = ollamaHost.startsWith("http") ? ollamaHost : `http://${ollamaHost}`;
341975
+ return { url: url3.replace(/\/$/, ""), source: "OLLAMA_HOST" };
341976
+ }
341977
+ const ollamaBaseUrl = process.env["OLLAMA_BASE_URL"];
341978
+ if (ollamaBaseUrl) {
341979
+ return { url: ollamaBaseUrl.replace(/\/v1\/?$/, "").replace(/\/$/, ""), source: "OLLAMA_BASE_URL" };
341980
+ }
341981
+ return { url: "http://localhost:11434", source: "default" };
341982
+ }
341983
+ __name(getOllamaEndpoint, "getOllamaEndpoint");
341937
341984
  function checkOllamaRunning2() {
341938
- try {
341939
- execSync6("curl -s --max-time 2 http://localhost:11434/api/tags", { encoding: "utf-8" });
341940
- return { name: "Ollama Server", status: "ok", message: "running on :11434" };
341941
- } catch {
341942
- return {
341943
- name: "Ollama Server",
341944
- status: "warning",
341945
- message: "not running",
341946
- fix: "Run: ollama serve",
341947
- autoFix: /* @__PURE__ */ __name(async () => {
341985
+ const { url: primaryUrl, source: source2 } = getOllamaEndpoint();
341986
+ const endpoints = [
341987
+ primaryUrl,
341988
+ // WSL-specific fallbacks (only try if primary is localhost)
341989
+ ...primaryUrl.includes("localhost") || primaryUrl.includes("127.0.0.1") ? ["http://host.docker.internal:11434", "http://172.17.0.1:11434"] : []
341990
+ ];
341991
+ for (const endpoint of endpoints) {
341992
+ try {
341993
+ execSync6(`curl -s --max-time 2 ${endpoint}/api/tags`, { encoding: "utf-8" });
341994
+ const displayEndpoint = endpoint.replace("http://", "").replace(":11434", ":11434");
341995
+ const sourceNote = source2 !== "default" ? ` (from ${source2})` : "";
341996
+ return {
341997
+ name: "Ollama Server",
341998
+ status: "ok",
341999
+ message: `running on ${displayEndpoint}${sourceNote}`,
342000
+ details: endpoint !== primaryUrl ? [`Fallback: ${endpoint}`] : void 0
342001
+ };
342002
+ } catch {
342003
+ }
342004
+ }
342005
+ const isWSL = platform14() === "linux" && release3().toLowerCase().includes("microsoft");
342006
+ const fix = isWSL ? "WSL detected. Set OLLAMA_HOST=host.docker.internal:11434 or your Windows IP" : "Run: ollama serve";
342007
+ return {
342008
+ name: "Ollama Server",
342009
+ status: "warning",
342010
+ message: "not reachable",
342011
+ fix,
342012
+ details: isWSL ? [
342013
+ `Tried: ${endpoints.join(", ")}`,
342014
+ "Windows Ollama needs: export OLLAMA_HOST=host.docker.internal:11434"
342015
+ ] : [`Tried: ${primaryUrl}`],
342016
+ autoFix: /* @__PURE__ */ __name(async () => {
342017
+ try {
342018
+ const { spawn: spawn11 } = await import("child_process");
342019
+ const child = spawn11("ollama", ["serve"], {
342020
+ detached: true,
342021
+ stdio: "ignore"
342022
+ });
342023
+ child.unref();
342024
+ await new Promise((resolve25) => setTimeout(resolve25, 2e3));
341948
342025
  try {
341949
- const { spawn: spawn11 } = await import("child_process");
341950
- const child = spawn11("ollama", ["serve"], {
341951
- detached: true,
341952
- stdio: "ignore"
341953
- });
341954
- child.unref();
341955
- await new Promise((resolve25) => setTimeout(resolve25, 2e3));
341956
- try {
341957
- execSync6("curl -s --max-time 2 http://localhost:11434/api/tags", { encoding: "utf-8" });
341958
- return true;
341959
- } catch {
341960
- return false;
341961
- }
342026
+ execSync6(`curl -s --max-time 2 ${primaryUrl}/api/tags`, { encoding: "utf-8" });
342027
+ return true;
341962
342028
  } catch {
341963
342029
  return false;
341964
342030
  }
341965
- }, "autoFix")
341966
- };
341967
- }
342031
+ } catch {
342032
+ return false;
342033
+ }
342034
+ }, "autoFix")
342035
+ };
341968
342036
  }
341969
342037
  __name(checkOllamaRunning2, "checkOllamaRunning");
341970
342038
  function checkGitInstalled() {
@@ -350998,7 +351066,7 @@ function useHistory() {
350998
351066
  setHistory((prevHistory) => {
350999
351067
  if (prevHistory.length > 0) {
351000
351068
  const lastItem = prevHistory[prevHistory.length - 1];
351001
- if (lastItem.type === "user" && newItem.type === "user" && lastItem.text === newItem.text) {
351069
+ if (lastItem.type === newItem.type && "text" in lastItem && "text" in newItem && lastItem.text === newItem.text) {
351002
351070
  return prevHistory;
351003
351071
  }
351004
351072
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osagent",
3
- "version": "0.1.68",
3
+ "version": "0.1.70",
4
4
  "description": "OS Agent - AI-powered CLI for autonomous coding with Ollama Cloud and Qwen models",
5
5
  "author": "Roberto Luna",
6
6
  "license": "Apache-2.0",