feat: add agent API and operational analytics
This commit is contained in:
1 parent
720ea0652a
commit
e8b730b592
65 files changed
+2650
-1214
No files matched your search
@@ -3,7 +3,7 @@ import { ConfigSchema, type Config } from './index.js';
|
||||
|
||||
type StoredConfig = Omit<Config, 'database' | 'openrouter' | 'web'> & {
|
||||
openrouter: Omit<Config['openrouter'], 'apiKey'>;
|
||||
web: Omit<Config['web'], 'authToken'>;
|
||||
web: Omit<Config['web'], 'authToken' | 'agentReadToken' | 'agentControlToken'>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -45,7 +45,12 @@ export class ConfigStore {
|
||||
function toStoredConfig(config: Config): StoredConfig {
|
||||
const { database: _database, ...applicationConfig } = config;
|
||||
const { apiKey: _apiKey, ...openrouter } = applicationConfig.openrouter;
|
||||
const { authToken: _authToken, ...web } = applicationConfig.web;
|
||||
const {
|
||||
authToken: _authToken,
|
||||
agentReadToken: _agentReadToken,
|
||||
agentControlToken: _agentControlToken,
|
||||
...web
|
||||
} = applicationConfig.web;
|
||||
return { ...applicationConfig, openrouter, web };
|
||||
}
|
||||
|
||||
@@ -58,7 +63,12 @@ function withBootstrapSettings(stored: unknown, environment: NodeJS.ProcessEnv):
|
||||
...record,
|
||||
database: { path: environment.DATABASE_PATH ?? './data/reddit-bot.db' },
|
||||
openrouter: { ...openrouter, apiKey: environment.OPENROUTER_API_KEY },
|
||||
web: { ...web, authToken: environment.WEB_DASHBOARD_TOKEN },
|
||||
web: {
|
||||
...web,
|
||||
authToken: environment.WEB_DASHBOARD_TOKEN,
|
||||
agentReadToken: optionalSecret(environment.REDDIT_BOT_AGENT_READ_TOKEN),
|
||||
agentControlToken: optionalSecret(environment.REDDIT_BOT_AGENT_CONTROL_TOKEN),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -68,6 +78,10 @@ function objectValue(value: unknown): Record<string, unknown> {
|
||||
: {};
|
||||
}
|
||||
|
||||
function optionalSecret(value: string | undefined): string | undefined {
|
||||
return value?.trim() ? value : undefined;
|
||||
}
|
||||
|
||||
function validateConfig(raw: unknown): Config {
|
||||
const result = ConfigSchema.safeParse(raw);
|
||||
if (!result.success) {
|
||||
|
||||
Reference in new issue
Block a user