diff --git a/src/config/index.ts b/src/config/index.ts index 43328ceba3..b2404d58c7 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -34,6 +34,12 @@ * ``` */ +// ============================================================================ +// Shared Primitives (cross-project compatibility) +// ============================================================================ + +export * from "./shared"; + // ============================================================================ // Legacy Types (backward compatibility) // ============================================================================ diff --git a/src/config/shared.ts b/src/config/shared.ts new file mode 100644 index 0000000000..dabab283af --- /dev/null +++ b/src/config/shared.ts @@ -0,0 +1,170 @@ +/** + * Shared Configuration Primitives + * + * Types shared between agent-core and zee gateway. + * These are the canonical definitions - both projects should use these. + */ + +// ============================================================================= +// Session Primitives +// ============================================================================= + +/** How sessions are scoped */ +export type SessionScope = "per-sender" | "global"; + +/** Reply behavior mode */ +export type ReplyMode = "text" | "command"; + +/** When to show typing indicator */ +export type TypingMode = "never" | "instant" | "thinking" | "message"; + +/** Reply-to threading behavior */ +export type ReplyToMode = "off" | "first" | "all"; + +// ============================================================================= +// Access Policy Primitives +// ============================================================================= + +/** Direct message access policy */ +export type DmPolicy = "pairing" | "allowlist" | "open" | "disabled"; + +/** Group message access policy */ +export type GroupPolicy = "open" | "disabled" | "allowlist"; + +// ============================================================================= +// Logging Primitives +// ============================================================================= + +/** Log levels (compatible with pino/tslog) */ +export type LogLevel = + | "silent" + | "fatal" + | "error" + | "warn" + | "info" + | "debug" + | "trace"; + +/** Console output style */ +export type ConsoleStyle = "pretty" | "compact" | "json"; + +/** Base logging configuration */ +export interface LoggingConfig { + /** Log level threshold */ + level?: LogLevel; + /** Log file path */ + file?: string; + /** Console-specific log level */ + consoleLevel?: LogLevel; + /** Console output format */ + consoleStyle?: ConsoleStyle; +} + +// ============================================================================= +// Retry Configuration +// ============================================================================= + +/** Outbound request retry configuration */ +export interface RetryConfig { + /** Max retry attempts (default: 3) */ + attempts?: number; + /** Minimum retry delay in ms */ + minDelayMs?: number; + /** Maximum retry delay cap in ms */ + maxDelayMs?: number; + /** Jitter factor (0-1) applied to delays */ + jitter?: number; +} + +// ============================================================================= +// Model/Provider Primitives +// ============================================================================= + +/** API type for model providers */ +export type ModelApi = + | "anthropic-messages" + | "openai-chat" + | "openai-responses" + | "google-genai" + | "bedrock-converse"; + +/** Model input modalities */ +export type ModelInputModality = "text" | "image" | "audio" | "video" | "file"; + +/** Token cost structure */ +export interface TokenCost { + input: number; + output: number; + cacheRead?: number; + cacheWrite?: number; +} + +/** Model definition */ +export interface ModelDefinition { + /** Model identifier */ + id: string; + /** Display name */ + name?: string; + /** Supports extended thinking */ + reasoning?: boolean; + /** Supported input types */ + input?: ModelInputModality[]; + /** Token costs per million */ + cost?: TokenCost; + /** Context window size in tokens */ + contextWindow?: number; + /** Max output tokens */ + maxTokens?: number; + /** Custom headers for this model */ + headers?: Record; +} + +/** Provider configuration */ +export interface ProviderDefinition { + /** API base URL */ + baseUrl: string; + /** API key (or env var reference) */ + apiKey?: string; + /** API type */ + api?: ModelApi; + /** Custom headers */ + headers?: Record; + /** Available models */ + models?: ModelDefinition[]; +} + +// ============================================================================= +// Thinking Configuration +// ============================================================================= + +/** Thinking/reasoning level */ +export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high"; + +// ============================================================================= +// Queue/Processing Configuration +// ============================================================================= + +/** Queue processing mode */ +export type QueueMode = "fifo" | "lifo" | "priority" | "debounce"; + +/** Queue drop policy when full */ +export type QueueDropPolicy = "oldest" | "newest" | "none"; + +// ============================================================================= +// Bind/Network Configuration +// ============================================================================= + +/** Network bind mode */ +export type BindMode = "auto" | "lan" | "tailnet" | "loopback"; + +// ============================================================================= +// Re-exports for convenience +// ============================================================================= + +export type { + SessionScope as SessionScopeType, + DmPolicy as DmPolicyType, + GroupPolicy as GroupPolicyType, + LogLevel as LogLevelType, + ThinkingLevel as ThinkingLevelType, +}; diff --git a/src/config/types.ts b/src/config/types.ts index e0275d2ea7..5a3c125457 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -14,6 +14,7 @@ import type { AgentConfig, AgentPersona } from "../agent/types"; import type { McpServerConfig as MCPConfig } from "../mcp/types"; import type { MemoryConfig } from "../memory/types"; import type { SurfaceType } from "../surface/types"; +import type { LogLevel, DmPolicy, GroupPolicy, RetryConfig } from "./shared"; // ============================================================================= // Main Configuration @@ -150,7 +151,6 @@ export interface SurfaceConfigs { api?: APIConfig; whatsapp?: WhatsAppConfig; telegram?: TelegramConfig; - discord?: DiscordConfig; } /** CLI/TUI configuration */ @@ -213,6 +213,18 @@ export interface WhatsAppConfig { /** Session data path */ sessionPath?: string; + /** Direct message access policy (shared with zee) */ + dmPolicy?: DmPolicy; + + /** Group message access policy (shared with zee) */ + groupPolicy?: GroupPolicy; + + /** Allowlist for direct chats (E.164 format) */ + allowFrom?: string[]; + + /** Retry configuration for outbound messages */ + retry?: RetryConfig; + /** Auto-reply settings */ autoReply?: { /** Enable auto-reply */ @@ -241,36 +253,33 @@ export interface TelegramConfig { /** Bot token */ botToken?: string; - /** Allowed user IDs (empty = all) */ + /** Direct message access policy (shared with zee) */ + dmPolicy?: DmPolicy; + + /** Group message access policy (shared with zee) */ + groupPolicy?: GroupPolicy; + + /** Allowlist for direct chats (user IDs or usernames) */ + allowFrom?: Array; + + /** Retry configuration for outbound messages */ + retry?: RetryConfig; + + /** Allowed user IDs (empty = all) - legacy, prefer allowFrom */ allowedUsers?: string[]; /** Webhook URL (if using webhooks) */ webhookUrl?: string; } -/** Discord configuration */ -export interface DiscordConfig { - /** Bot token */ - botToken?: string; - - /** Application ID */ - applicationId?: string; - - /** Allowed server IDs */ - allowedServers?: string[]; - - /** Allowed channel IDs */ - allowedChannels?: string[]; -} - // ============================================================================= // General Settings // ============================================================================= /** General application settings */ export interface GeneralSettings { - /** Log level */ - logLevel?: "debug" | "info" | "warn" | "error"; + /** Log level (uses shared LogLevel type) */ + logLevel?: LogLevel; /** Data directory for storage */ dataDir?: string;