promptCategory.ts
utils/promptCategory.ts
No strong subsystem tag
50
Lines
1502
Bytes
2
Exports
3
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with general runtime concerns. It contains 50 lines, 3 detected imports, and 2 detected exports.
Important relationships
Detected exports
getQuerySourceForAgentgetQuerySourceForREPL
Keywords
agentquerysourcestylesettingspromptcategoryagenttypedefault_output_style_nameoutput_style_configisbuiltinagent
Detected imports
src/constants/querySource.js../constants/outputStyles.js./settings/settings.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import type { QuerySource } from 'src/constants/querySource.js'
import {
DEFAULT_OUTPUT_STYLE_NAME,
OUTPUT_STYLE_CONFIG,
} from '../constants/outputStyles.js'
import { getSettings_DEPRECATED } from './settings/settings.js'
/**
* Determines the prompt category for agent usage.
* Used for analytics to track different agent patterns.
*
* @param agentType - The type/name of the agent
* @param isBuiltInAgent - Whether this is a built-in agent or custom
* @returns The agent prompt category string
*/
export function getQuerySourceForAgent(
agentType: string | undefined,
isBuiltInAgent: boolean,
): QuerySource {
if (isBuiltInAgent) {
// TODO: avoid this cast
return agentType
? (`agent:builtin:${agentType}` as QuerySource)
: 'agent:default'
} else {
return 'agent:custom'
}
}
/**
* Determines the prompt category based on output style settings.
* Used for analytics to track different output style usage.
*
* @returns The prompt category string or undefined for default
*/
export function getQuerySourceForREPL(): QuerySource {
const settings = getSettings_DEPRECATED()
const style = settings?.outputStyle ?? DEFAULT_OUTPUT_STYLE_NAME
if (style === DEFAULT_OUTPUT_STYLE_NAME) {
return 'repl_main_thread'
}
// All styles in OUTPUT_STYLE_CONFIG are built-in
const isBuiltIn = style in OUTPUT_STYLE_CONFIG
return isBuiltIn
? (`repl_main_thread:outputStyle:${style}` as QuerySource)
: 'repl_main_thread:outputStyle:custom'
}