Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nemoclaw-blueprint/policies/presets/local-inference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ network_policies:
rules:
- allow: { method: GET, path: "/**" }
- allow: { method: POST, path: "/**" }
- host: host.openshell.internal
port: 11435
protocol: rest
enforcement: enforce
rules:
- allow: { method: GET, path: "/**" }
- allow: { method: POST, path: "/**" }
- host: host.openshell.internal
port: 8000
protocol: rest
Expand Down
16 changes: 12 additions & 4 deletions src/lib/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ function killStaleProxy(): void {
}
}

function startOllamaAuthProxy(): void {
function startOllamaAuthProxy(): boolean {
const crypto = require("crypto");
killStaleProxy();

Expand All @@ -1912,8 +1912,12 @@ function startOllamaAuthProxy(): void {
const pid = spawnOllamaAuthProxy(ollamaProxyToken);
sleep(1);
if (!isOllamaProxyProcess(pid)) {
console.error(` Warning: Ollama auth proxy did not start on :${OLLAMA_PROXY_PORT}`);
console.error(` Error: Ollama auth proxy failed to start on :${OLLAMA_PROXY_PORT}`);
console.error(` Containers will not be able to reach Ollama without the proxy.`);
console.error(` Check if port ${OLLAMA_PROXY_PORT} is already in use: lsof -ti :${OLLAMA_PROXY_PORT}`);
return false;
}
return true;
}

/**
Expand Down Expand Up @@ -4144,7 +4148,9 @@ async function setupNim(gpu) {
// WSL2 doesn't need the proxy — Docker can reach the host directly.
console.log(` ✓ Using Ollama on localhost:${OLLAMA_PORT}`);
} else {
startOllamaAuthProxy();
if (!startOllamaAuthProxy()) {
process.exit(1);
}
console.log(` ✓ Using Ollama on localhost:${OLLAMA_PORT} (proxy on :${OLLAMA_PROXY_PORT})`);
}
provider = "ollama-local";
Expand Down Expand Up @@ -4204,7 +4210,9 @@ async function setupNim(gpu) {
// Shell required: backgrounding (&), env var prefix, output redirection.
run(`OLLAMA_HOST=0.0.0.0:${OLLAMA_PORT} ollama serve > /dev/null 2>&1 &`, { ignoreError: true });
sleep(2);
startOllamaAuthProxy();
if (!startOllamaAuthProxy()) {
process.exit(1);
}
console.log(` ✓ Using Ollama on localhost:${OLLAMA_PORT} (proxy on :${OLLAMA_PROXY_PORT})`);
provider = "ollama-local";
credentialEnv = "OPENAI_API_KEY";
Expand Down
4 changes: 4 additions & 0 deletions test/onboard-selection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ runner.runCapture = (command) => {
if (cmd.includes("ollama list")) return "nemotron-3-nano:30b abc 24 GB now";
if (cmd.includes("127.0.0.1:8000/v1/models")) return "";
if (cmd.includes("api/generate")) return '{"response":"hello"}';
if (cmd.includes("-o args=")) return "node ollama-auth-proxy.js";
return "";
};

Expand Down Expand Up @@ -708,6 +709,7 @@ runner.runCapture = (command) => {
if (cmd.includes("ollama list")) return "nemotron-3-nano:30b abc 24 GB now";
if (cmd.includes("127.0.0.1:8000/v1/models")) return "";
if (cmd.includes("api/generate")) return '{"response":"hello"}';
if (cmd.includes("-o args=")) return "node ollama-auth-proxy.js";
return "";
};

Expand Down Expand Up @@ -811,6 +813,7 @@ runner.runCapture = (command) => {
if (cmd.includes("ollama list")) return "";
if (cmd.includes("127.0.0.1:8000/v1/models")) return "";
if (cmd.includes("api/generate")) return '{"response":"hello"}';
if (cmd.includes("-o args=")) return "node ollama-auth-proxy.js";
return "";
};

Expand Down Expand Up @@ -921,6 +924,7 @@ runner.runCapture = (command) => {
if (cmd.includes("ollama list")) return "";
if (cmd.includes("127.0.0.1:8000/v1/models")) return "";
if (cmd.includes("api/generate")) return '{"response":"hello"}';
if (cmd.includes("-o args=")) return "node ollama-auth-proxy.js";
return "";
};

Expand Down
3 changes: 2 additions & 1 deletion test/policies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ describe("policies", () => {
}
});

it("local-inference preset targets host.openshell.internal on Ollama and vLLM ports", () => {
it("local-inference preset targets host.openshell.internal on Ollama, proxy, and vLLM ports", () => {
const content = policies.loadPreset("local-inference");
expect(content).toContain("host.openshell.internal");
expect(content).toContain("port: 11434");
expect(content).toContain("port: 11435");
expect(content).toContain("port: 8000");
});

Expand Down
Loading