7df0569a39
Implement first-class Z.AI credential storage and authentication: - New auth provider: src/auth/zai.ts for Z.AI API key management - New CLI command: flynn zai-auth to store Z.AI API keys - New TUI command: /login zai for interactive credential entry - Modified src/auth/index.ts to register zai provider - Modified src/cli/index.ts to register zai-auth command - Modified src/cli/setup/providers.ts to include Z.AI in setup wizard - Modified src/daemon/models.ts to support zhipuai use_oauth flag - Modified src/daemon/clientFactory.test.ts to add Z.AI tests - Modified src/frontends/tui/commands.ts to add login command - Modified src/frontends/tui/minimal.ts to support credential prompts This allows users to authenticate with Z.AI (GLM models) without embedding secrets in config files. Credentials are stored securely in ~/.config/flynn/auth.json and resolved at runtime. Updated state.json with new feature entry documenting the integration.
62 lines
2.2 KiB
JavaScript
62 lines
2.2 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Load .env file from project root (Node >= 20.12 built-in, no dotenv needed).
|
|
// Silent no-op if the file doesn't exist.
|
|
try { process.loadEnvFile(); } catch { /* .env not found — that's fine */ }
|
|
|
|
import { Command } from 'commander';
|
|
import { registerStartCommand } from './start.js';
|
|
import { registerSendCommand } from './send.js';
|
|
import { registerSessionsCommand } from './sessions.js';
|
|
import { registerDoctorCommand } from './doctor.js';
|
|
import { registerConfigCommand } from './config-cmd.js';
|
|
import { registerTuiCommand } from './tui.js';
|
|
import { registerCompletionCommand } from './completion.js';
|
|
import { registerSetupCommand } from './setup.js';
|
|
import { registerGmailAuthCommand } from './gmail-auth.js';
|
|
import { registerGcalAuthCommand } from './gcal-auth.js';
|
|
import { registerGdocsAuthCommand } from './gdocs-auth.js';
|
|
import { registerGdriveAuthCommand } from './gdrive-auth.js';
|
|
import { registerGtasksAuthCommand } from './gtasks-auth.js';
|
|
import { registerOpenaiAuthCommand } from './openai-auth.js';
|
|
import { registerZaiAuthCommand } from './zai-auth.js';
|
|
import { registerSkillsCommand } from './skills.js';
|
|
|
|
export function createProgram(): Command {
|
|
const program = new Command();
|
|
|
|
program
|
|
.name('flynn')
|
|
.description('Flynn — self-hosted personal AI agent')
|
|
.version('0.1.0');
|
|
|
|
registerStartCommand(program);
|
|
registerTuiCommand(program);
|
|
registerSendCommand(program);
|
|
registerSessionsCommand(program);
|
|
registerDoctorCommand(program);
|
|
registerConfigCommand(program);
|
|
registerCompletionCommand(program);
|
|
registerSetupCommand(program);
|
|
registerGmailAuthCommand(program);
|
|
registerGcalAuthCommand(program);
|
|
registerGdocsAuthCommand(program);
|
|
registerGdriveAuthCommand(program);
|
|
registerGtasksAuthCommand(program);
|
|
registerOpenaiAuthCommand(program);
|
|
registerZaiAuthCommand(program);
|
|
registerSkillsCommand(program);
|
|
|
|
return program;
|
|
}
|
|
|
|
// Only run when executed directly (not imported in tests)
|
|
const isDirectRun = process.argv[1] &&
|
|
(process.argv[1].endsWith('/cli/index.js') ||
|
|
process.argv[1].endsWith('/cli/index.ts'));
|
|
|
|
if (isDirectRun) {
|
|
const program = createProgram();
|
|
program.parse(process.argv);
|
|
}
|