Implementation:0xranx OpenContext Agent Constants
| Knowledge Sources | |
|---|---|
| Domains | Agent_Chat, React |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Shared constants, intent configuration builders, and utility functions for the agent chat UI, including model merging and tool status styling.
Description
The constants.js module in src/ui/src/components/agent/ exports intent configuration, tool status styles, default Codex models, and several utility functions. INTENT_CONFIG maps intent IDs to label/placeholder keys. buildIntentConfig merges icons into intent configs. getIntentAction, getIntentLabel, getIntentIcon, and getIntentPlaceholder resolve intent metadata. TOOL_STATUS_STYLES provides Tailwind classes for neutral/success/error tool call states. DEFAULT_CODEX_MODELS lists default model options. toModelOptions and mergeModelDefaults manage model list deduplication and merging.
Usage
Import these constants and functions in agent sidebar components for intent resolution, model management, and tool call styling.
Code Reference
Source Location
- Repository: 0xranx_OpenContext
- File: src/ui/src/components/agent/constants.js
- Lines: 1-91
Signature
export const INTENT_CONFIG = { create, iterate, search }
export const TOOL_STATUS_STYLES = { neutral, success, error }
export const DEFAULT_CODEX_MODELS = ['gpt-5.2-codex', ...]
export function buildIntentConfig(baseConfig, icons)
export function getIntentAction(intentId, intentConfig)
export function getIntentLabel(t, intentId, intentConfig)
export function getIntentIcon(intentId, intentConfig, fallbackIcon)
export function getIntentPlaceholder(t, intentId, intentConfig)
export function toModelOptions(models)
export function mergeModelDefaults(models, defaults)
Import
import { INTENT_CONFIG, buildIntentConfig, getIntentLabel, mergeModelDefaults, TOOL_STATUS_STYLES } from './components/agent/constants';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| models | Array<string> | Yes | Raw model list |
| defaults | Array<string> | Yes | Default model list to merge |
| intentId | string | Yes | Intent identifier |
Outputs
| Name | Type | Description |
|---|---|---|
| toModelOptions | Array<{value,label}> | Normalized model options array |
| mergeModelDefaults | Array<string> | Deduplicated merged model list |
| getIntentLabel | string | i18n-translated intent label |
Usage Examples
Building Intent Config
import { INTENT_CONFIG, buildIntentConfig } from './components/agent/constants';
import { SparklesIcon, PlusIcon, MagnifyingGlassIcon } from '@heroicons/react/24/outline';
const icons = { create: PlusIcon, iterate: SparklesIcon, search: MagnifyingGlassIcon };
const intentConfig = buildIntentConfig(INTENT_CONFIG, icons);
// { create: { labelKey, placeholderKey, icon: PlusIcon }, ... }
Merging Model Lists
import { mergeModelDefaults, toModelOptions } from './components/agent/constants';
const merged = mergeModelDefaults(['custom-model'], ['gpt-5.2-codex', 'gpt-5.1-codex-max']);
// ['gpt-5.2-codex', 'gpt-5.1-codex-max', 'custom-model']
const options = toModelOptions(merged);
// [{ value: 'gpt-5.2-codex', label: 'gpt-5.2-codex' }, ...]