Fix CutOS Agent models config path

This commit is contained in:
yankun
2026-08-02 19:17:31 +08:00
parent 9ccdd73955
commit 6488374da8
3 changed files with 15 additions and 1 deletions
+2
View File
@@ -201,6 +201,8 @@ CLAWD_LOG_FILE=1
# CLAWD_SERVER=wss://claw.cutos.ai/ws # CLAWD_SERVER=wss://claw.cutos.ai/ws
# Agent runtime: openclaw (default) or cutos-agent # Agent runtime: openclaw (default) or cutos-agent
# AGENT_TYPE=openclaw # AGENT_TYPE=openclaw
# CutOS Agent Pi models config path
# PI_MODELS_CONFIG=$HOME/.pi/agent/models.json
# Enable Bluetooth monitor (bluetoothctl); disabled by default # Enable Bluetooth monitor (bluetoothctl); disabled by default
# CLAWD_ENABLE_BT=1 # CLAWD_ENABLE_BT=1
# OpenVFD sysfs path (default: /sys/class/leds/openvfd) # OpenVFD sysfs path (default: /sys/class/leds/openvfd)
+1 -1
View File
@@ -14,7 +14,7 @@ let operationId = 0;
function resolvePiModelsConfigFile(env = process.env) { function resolvePiModelsConfigFile(env = process.env) {
const configured = String(env.PI_MODELS_CONFIG || '').trim(); const configured = String(env.PI_MODELS_CONFIG || '').trim();
return configured ? path.resolve(configured) : path.join(os.homedir(), '.pi', 'models.json'); return configured ? path.resolve(configured) : path.join(os.homedir(), '.pi', 'agent', 'models.json');
} }
function normalizeBaseUrl(baseUrl) { function normalizeBaseUrl(baseUrl) {
+12
View File
@@ -30,6 +30,18 @@ const payload = {
'api-key': 'test-key', 'api-key': 'test-key',
}; };
test('defaults to Pi agent models config path', () => {
assert.equal(
piProvider.resolvePiModelsConfigFile({}),
path.join(os.homedir(), '.pi', 'agent', 'models.json'),
);
});
test('allows PI_MODELS_CONFIG to override Pi models config path', () => {
const customPath = path.join(os.tmpdir(), 'custom-pi-models.json');
assert.equal(piProvider.resolvePiModelsConfigFile({ PI_MODELS_CONFIG: customPath }), path.resolve(customPath));
});
test('creates a Pi models file and maps models to reasoning entries', async () => { test('creates a Pi models file and maps models to reasoning entries', async () => {
const configFile = tempConfig(); const configFile = tempConfig();
await apply(payload, { await apply(payload, {