New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

codecli-hostapi

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codecli-hostapi - npm Package Compare versions

Comparing version
1.3.0
to
1.4.0
+43
-9
bin/activate.js

@@ -9,4 +9,2 @@ #!/usr/bin/env node

const PROXY_PORT = 18080;
const PROXY_HOST = '127.0.0.1';
const PROXY_BASE_URL = `http://${PROXY_HOST}:${PROXY_PORT}`;

@@ -21,7 +19,8 @@ // XDG-compliant paths

const PROXY_SCRIPT = `#!/usr/bin/env python3
function getProxyScript(host) {
return `#!/usr/bin/env python3
import json, subprocess, time, sys, uuid
from http.server import BaseHTTPRequestHandler, HTTPServer
HOST = "${PROXY_HOST}"
HOST = "${host}"
PORT = ${PROXY_PORT}

@@ -190,2 +189,3 @@

`;
}

@@ -200,2 +200,17 @@ // ============ Utility Functions ============

function getLocalIP() {
try {
const os = require('os');
const interfaces = os.networkInterfaces();
for (const name of Object.keys(interfaces)) {
for (const iface of interfaces[name]) {
if (iface.family === 'IPv4' && !iface.internal) {
return iface.address;
}
}
}
} catch {}
return '0.0.0.0';
}
function run(cmd, opts = {}) {

@@ -312,8 +327,17 @@ if (!opts.silent) console.log(`> ${cmd}`);

// Ask for access mode
console.log('\n🌐 选择访问模式:');
console.log(' 1. 仅本地 (127.0.0.1) - 只能本机访问');
console.log(' 2. 本地+远程 (0.0.0.0) - 允许外部访问');
const modeChoice = await prompt('请选择 (1/2, 默认1): ');
const proxyHost = modeChoice === '2' ? '0.0.0.0' : '127.0.0.1';
const isRemote = proxyHost === '0.0.0.0';
// Install proxy script
console.log('\n📦 安装代理脚本...');
ensureDir(DATA_DIR);
fs.writeFileSync(PROXY_SCRIPT_PATH, PROXY_SCRIPT);
fs.writeFileSync(PROXY_SCRIPT_PATH, getProxyScript(proxyHost));
fs.chmodSync(PROXY_SCRIPT_PATH, '755');
console.log(` ✓ 已安装: ${PROXY_SCRIPT_PATH}`);
console.log(` ✓ 绑定地址: ${proxyHost}:${PROXY_PORT}`);

@@ -363,6 +387,12 @@ // Setup systemd service (Linux only)

config.installedAt = new Date().toISOString();
config.proxyHost = proxyHost;
saveConfig(config);
const displayHost = isRemote ? getLocalIP() : '127.0.0.1';
console.log('\n✅ 安装完成!');
console.log(`\n📡 API 端点: ${PROXY_BASE_URL}/v1/messages`);
console.log(`\n📡 API 端点: http://${displayHost}:${PROXY_PORT}/v1/messages`);
if (isRemote) {
console.log(` 本地访问: http://127.0.0.1:${PROXY_PORT}/v1/messages`);
console.log(' 客户端 API Key 可填任意值 (如 sk-placeholder)');
}
console.log(' 将此地址作为 Anthropic API 的 baseUrl 使用');

@@ -541,6 +571,10 @@

const running = isProxyRunning();
const proxyHost = config.proxyHost || '127.0.0.1';
const isRemote = proxyHost === '0.0.0.0';
const displayHost = isRemote ? getLocalIP() : '127.0.0.1';
console.log(` 已安装: ${config.installed ? '✓ 是' : '○ 否'}`);
console.log(` 运行中: ${running ? '✓ 是' : '○ 否'}`);
console.log(` 端点: ${PROXY_BASE_URL}/v1/messages`);
console.log(` 模式: ${isRemote ? '本地+远程 (0.0.0.0)' : '仅本地 (127.0.0.1)'}`);
console.log(` 端点: http://${displayHost}:${PROXY_PORT}/v1/messages`);

@@ -561,3 +595,3 @@ if (process.platform === 'linux') {

const baseUrl = cfg?.models?.providers?.anthropic?.baseUrl || '(默认)';
const usingProxy = baseUrl === PROXY_BASE_URL;
const usingProxy = baseUrl.includes(`127.0.0.1:${PROXY_PORT}`) || baseUrl.includes(`localhost:${PROXY_PORT}`);
console.log(`\n Clawdbot: ${clawdbotConfig}`);

@@ -578,3 +612,3 @@ console.log(` BaseURL: ${baseUrl}`);

console.log('\n╔════════════════════════════════════════╗');
console.log('║ codecli-hostapi v1.3.0 ║');
console.log('║ codecli-hostapi v1.4.0 ║');
console.log('║ 将 Claude CLI 转为本地 API 端点 ║');

@@ -581,0 +615,0 @@ console.log('╚════════════════════════════════════════╝');

+1
-1
{
"name": "codecli-hostapi",
"version": "1.3.0",
"version": "1.4.0",
"description": "One-command setup to proxy Anthropic API requests through Claude Code CLI",

@@ -5,0 +5,0 @@ "bin": {