source dump of claude code
at main 49 lines 1.5 kB view raw
1import type { QuerySource } from 'src/constants/querySource.js' 2import { 3 DEFAULT_OUTPUT_STYLE_NAME, 4 OUTPUT_STYLE_CONFIG, 5} from '../constants/outputStyles.js' 6import { getSettings_DEPRECATED } from './settings/settings.js' 7 8/** 9 * Determines the prompt category for agent usage. 10 * Used for analytics to track different agent patterns. 11 * 12 * @param agentType - The type/name of the agent 13 * @param isBuiltInAgent - Whether this is a built-in agent or custom 14 * @returns The agent prompt category string 15 */ 16export function getQuerySourceForAgent( 17 agentType: string | undefined, 18 isBuiltInAgent: boolean, 19): QuerySource { 20 if (isBuiltInAgent) { 21 // TODO: avoid this cast 22 return agentType 23 ? (`agent:builtin:${agentType}` as QuerySource) 24 : 'agent:default' 25 } else { 26 return 'agent:custom' 27 } 28} 29 30/** 31 * Determines the prompt category based on output style settings. 32 * Used for analytics to track different output style usage. 33 * 34 * @returns The prompt category string or undefined for default 35 */ 36export function getQuerySourceForREPL(): QuerySource { 37 const settings = getSettings_DEPRECATED() 38 const style = settings?.outputStyle ?? DEFAULT_OUTPUT_STYLE_NAME 39 40 if (style === DEFAULT_OUTPUT_STYLE_NAME) { 41 return 'repl_main_thread' 42 } 43 44 // All styles in OUTPUT_STYLE_CONFIG are built-in 45 const isBuiltIn = style in OUTPUT_STYLE_CONFIG 46 return isBuiltIn 47 ? (`repl_main_thread:outputStyle:${style}` as QuerySource) 48 : 'repl_main_thread:outputStyle:custom' 49}