Merge conflicts were handled by Claude AI - please verify the changes: - src/commands/chat.ts: Integrated flag processing with main branch changes - src/commands/serve.ts: Updated logger import and integrated flag processing - src/services/index.ts: Updated logger import and maintained initialization logic - src/services/index.test.ts: Accepted main branch version 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
101 lines
No EOL
2.2 KiB
TypeScript
101 lines
No EOL
2.2 KiB
TypeScript
import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml";
|
|
import { BaseLlmApi } from "@continuedev/openai-adapters";
|
|
import { DefaultApiInterface } from "@continuedev/sdk/dist/api/dist/index.js";
|
|
|
|
import { AuthConfig } from "../auth/workos.js";
|
|
import { MCPService } from "../mcp.js";
|
|
import { PermissionMode, ToolPermissions } from "../permissions/types.js";
|
|
|
|
/**
|
|
* Service lifecycle states
|
|
*/
|
|
export type ServiceState = 'idle' | 'loading' | 'ready' | 'error';
|
|
|
|
/**
|
|
* Generic service result with state tracking
|
|
*/
|
|
export interface ServiceResult<T> {
|
|
value: T | null;
|
|
state: ServiceState;
|
|
error: Error | null;
|
|
lastUpdated?: Date;
|
|
}
|
|
|
|
/**
|
|
* Service event types for the EventEmitter
|
|
*/
|
|
export interface ServiceEvents {
|
|
[key: `${string}:loading`]: [];
|
|
[key: `${string}:ready`]: [any];
|
|
[key: `${string}:error`]: [Error];
|
|
[key: `${string}:changed`]: [any];
|
|
}
|
|
|
|
/**
|
|
* Core service types
|
|
*/
|
|
export interface AuthServiceState {
|
|
authConfig: AuthConfig | null;
|
|
isAuthenticated: boolean;
|
|
organizationId?: string;
|
|
}
|
|
|
|
export interface ConfigServiceState {
|
|
config: AssistantUnrolled | null;
|
|
configPath?: string;
|
|
}
|
|
|
|
export interface ModelServiceState {
|
|
llmApi: BaseLlmApi | null;
|
|
model: ModelConfig | null;
|
|
}
|
|
|
|
export interface MCPServiceState {
|
|
mcpService: MCPService | null;
|
|
}
|
|
|
|
export interface ApiClientServiceState {
|
|
apiClient: DefaultApiInterface | null;
|
|
}
|
|
|
|
export interface ToolPermissionServiceState {
|
|
permissions: ToolPermissions;
|
|
currentMode: PermissionMode;
|
|
modePolicyCount?: number;
|
|
originalPolicies?: ToolPermissions;
|
|
}
|
|
|
|
/**
|
|
* Service names as constants to prevent typos
|
|
*/
|
|
export const SERVICE_NAMES = {
|
|
AUTH: 'auth',
|
|
CONFIG: 'config',
|
|
MODEL: 'model',
|
|
MCP: 'mcp',
|
|
API_CLIENT: 'apiClient',
|
|
TOOL_PERMISSIONS: 'toolPermissions'
|
|
} as const;
|
|
|
|
/**
|
|
* Service initialization options
|
|
*/
|
|
export interface ServiceInitOptions {
|
|
configPath?: string;
|
|
rules?: string[];
|
|
headless?: boolean;
|
|
skipOnboarding?: boolean; // Skip onboarding check even in TUI mode
|
|
toolPermissionOverrides?: {
|
|
allow?: string[];
|
|
ask?: string[];
|
|
exclude?: string[];
|
|
mode?: PermissionMode;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Service initialization result
|
|
*/
|
|
export interface ServiceInitResult {
|
|
wasOnboarded?: boolean;
|
|
} |