fix: use Store class for v2 compat in model command, remove unused import

- Replace raw JSON parsing with Store class (v1+v2 format support)
- Remove unused listModels import from model.ts

Written by Cameron ◯ Letta Code

"Simplicity is the ultimate sophistication." -- Leonardo da Vinci
This commit is contained in:
Cameron
2026-02-09 10:55:21 -08:00
parent 4effadccb9
commit 32cf7169a6

View File

@@ -7,25 +7,17 @@
* lettabot model set <handle> - Set model by handle * lettabot model set <handle> - Set model by handle
*/ */
import { existsSync, readFileSync } from 'node:fs'; import { getAgentModel, updateAgentModel } from '../tools/letta-api.js';
import { resolve } from 'node:path';
import { getDataDir } from '../utils/paths.js';
import { getAgentModel, updateAgentModel, listModels } from '../tools/letta-api.js';
import { buildModelOptions, handleModelSelection, getBillingTier } from '../utils/model-selection.js'; import { buildModelOptions, handleModelSelection, getBillingTier } from '../utils/model-selection.js';
import { isLettaCloudUrl } from '../utils/server.js'; import { isLettaCloudUrl } from '../utils/server.js';
import { Store } from '../core/store.js';
/** /**
* Get agent ID from store file * Get agent ID from store file (supports v1 and v2 formats)
*/ */
function getAgentId(): string | null { function getAgentId(): string | null {
const storePath = resolve(getDataDir(), 'lettabot-agent.json'); const store = new Store();
if (!existsSync(storePath)) return null; return store.agentId;
try {
const store = JSON.parse(readFileSync(storePath, 'utf-8'));
return store.agentId || null;
} catch {
return null;
}
} }
/** /**