02: Native Assembly
此内容尚不支持你的语言。
Native assembly builds contributions and orders the completed blocks through
src/utils/text/context/promptLayout.ts. Contributor execution order allows RAG retrieval to overlap
other work. The registry defines emitted prompt order and system routing; the numbered pages follow
build stages and retain their URLs when the prompt order changes.
Persistent instructions, server knowledge, Always On lore, and conditioning enter the system zone. Participant profiles and personal memories remain above history. Changing information is positioned at the tail slot, after preset reassembly when applicable.
Contributor index
Section titled “Contributor index”| Contributor | Relationship |
|---|---|
| Prompt items | Establishes system and persona instructions. |
| Server info | Supplies the conversation’s server context. |
| Server memories | Reads persistent server knowledge for the active persona lineage. |
| Server emojis and stickers | Describe expressions available for output. |
| Participants | Resolves participant identity and personal context. |
| Short-term memory | Supplies recent memory and deferred refresh instructions. |
| Verbatim tool definitions | Adapts tool schemas for text-based calling. |
| RAG documents | Retrieves relevant uploaded document excerpts. |
| Lorebooks | Splits Always On system content from activated tail-slot content. |
| Conditioning | Adds server-configured reinforcement. |
| Sample dialogues | Shows persona response examples. |
| Dialogue history | Supplies recent messages and capability-neutral media descriptors. |
Output contract
Section titled “Output contract”Directives and deferred short-term memory items are kept out of contextItems so that the downstream chat pipeline can position them relative to assembled dialogue turns:
tailDirectivesreceive the impersonation command directive (Imitate <User>, start your message with <User>:).<User>uses the history’s resolved speaker label, and the stream cleaner strips that label as well as the webhook name.uncensorDirectivereceives cleaned uncensor text when enabled.nudgeItemholds the cadence-gatedupdate_short_term_memoryprompt.memoryInjectionItemsholds content needing positional placement: fresh or cross-channel STM uses the tail slot or a closer configured depth; stale same-channel content uses its saved depth, with-1staying above history.
Shared helpers used across contributors
Section titled “Shared helpers used across contributors”Several contributors import shared text and state utilities:
convertMentions(src/utils/text/context/mentionNormalizer.ts): Normalizes<@id>,<#id>,<@&id>, and macro placeholders ({bot},{user}) into readable names. It respects user privacy levels and blacklist settings. In dialogue message bodies, it preserves{bot}and{user}literals to avoid clobbering raw prompts.toolPromptMacroResolver(src/utils/tools/toolPromptMacros.ts): Evaluates{{if capability:...}}and{{if tool:...}}conditionals, and substitutes provider-specific tool function names (such as{short_term_memory_tool}or{sticker_tool}) based on active model capabilities and deliberate tool allowlists.history.ts(src/utils/text/context/history.ts): Provides media window filtering, timestamp formatting, image limit tracking (MEDIA_IMAGE_MESSAGE_LIMIT), and user presence formatting for participant cards.
Source pointers
Section titled “Source pointers”src/utils/text/context/nativeBuilder.ts:buildContextNativepipeline orchestrator.src/utils/text/context/mentionNormalizer.ts: Discord mention normalization and placeholder substitution.src/utils/tools/toolPromptMacros.ts: tool name and capability macro evaluation.src/utils/text/context/history.ts: shared history filtering and presence formatting helpers.