INNER CODE UNIT · Python
tokenize_prompt
ASCIT31/Dark-Moon · mcp/src/server.py:141
def tokenize_prompt(text: str, session_id: Optional[str] = None) -> Dict[str, Any]:
"""
Tokenize a launch prompt BEFORE it reaches the model.
The Darkmoon privacy boundary normally acts only on tool calls and their
output. The initial campaign prompt (TARGET / CREDS / SCOPE / TOKEN / IP /
port) is sent to the model first, so without this it would reach the model in
clear (issue #40, section 3). This applies the SAME per-session vault the
tool calls use, so every placeholder is identical to the ones the gateway
rehydrates during the run and restores into the local report — no value is
ever hard-coded.
Intended caller: the Darkmoon OpenCode privacy plugin, which rewrites the
outgoing user message with the returned `tokenized` text before the model
sees it. Safe to call repeatedly (deterministic per session).
Args:
text: the raw prompt text to tokenize.