跳到內容

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.

ContributorRelationship
Prompt itemsEstablishes system and persona instructions.
Server infoSupplies the conversation’s server context.
Server memoriesReads persistent server knowledge for the active persona lineage.
Server emojis and stickersDescribe expressions available for output.
ParticipantsResolves participant identity and personal context.
Short-term memorySupplies recent memory and deferred refresh instructions.
Verbatim tool definitionsAdapts tool schemas for text-based calling.
RAG documentsRetrieves relevant uploaded document excerpts.
LorebooksSplits Always On system content from activated tail-slot content.
ConditioningAdds server-configured reinforcement.
Sample dialoguesShows persona response examples.
Dialogue historySupplies recent messages and capability-neutral media descriptors.

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:

  • tailDirectives receive 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.
  • uncensorDirective receives cleaned uncensor text when enabled.
  • nudgeItem holds the cadence-gated update_short_term_memory prompt.
  • memoryInjectionItems holds 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 -1 staying above history.

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.
  • src/utils/text/context/nativeBuilder.ts: buildContextNative pipeline 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.