Skip to content

Parser

Parses rendered prompt text into an array of structured messages with role markers.

---
title: Parser
config:
  look: handDrawn
  theme: colorful
  class:
    hideEmptyMembersBox: true
---
classDiagram
    class Parser {
      <<protocol>>
        +preRender(template: string) unknown? [sync]
        +parse(agent: Prompty, rendered: string, context: Record<unknown>?) Message[] [async-capable]
    }

The following helper methods are declared via @method and must be implemented by every runtime. The schema declares the logical protocol contract; each runtime maps async-capable methods to idiomatic sync/async shapes for that language.

NameSignatureRuntime shapeDescription
preRenderpreRender(template: string) -> unknown?sync (optional default)Pre-process a template before rendering, returning modified template and context
parseparse(agent: Prompty, rendered: string, context: Record<unknown>?) -> Message[]async-capableParse rendered text into a structured message array