vibe.workbench.routes

Workbench API Routes.

Provides stateless API endpoints for managing template drafts. All state-changing endpoints require CSRF protection and author authentication.

get_draft_manager

get_draft_manager() -> DraftStateManager

Get the DraftStateManager instance.

get_docx_service

get_docx_service() -> DOCXService

Get the DOCXService instance.

create_draft

create_draft() -> Response | tuple[Response, int]

Create a new draft from an uploaded DOCX file.

Expects
  • template_file: The uploaded .docx file
Returns:
  • JSON( Response | tuple[Response, int] ) –

    {"draft_id": "uuid4_string"}

create_draft_from_template

create_draft_from_template(template_id: str) -> Response | tuple[Response, int]

Create a new draft from an existing published template.

Parameters:
  • template_id (str) –

    ID of the existing template to copy

Returns:
  • JSON( Response | tuple[Response, int] ) –

    {"draft_id": "uuid4_string"}

get_draft

get_draft(draft_id: str) -> Response | tuple[Response, int]

Get draft data including config, markup overlay, and HTML content with stable IDs.

Parameters:
  • draft_id (str) –

    The draft identifier

Returns:
  • JSON( Response | tuple[Response, int] ) –

    { "draft_id": "uuid4_string", "config": {...}, "markup_overlay": {...}, "html_content": "..."

  • Response | tuple[Response, int]

    }

update_draft_config

update_draft_config(draft_id: str) -> Response | tuple[Response, int]

Update the draft configuration.

Parameters:
  • draft_id (str) –

    The draft identifier

Expects

JSON: The complete config object to save

Returns:
  • JSON( Response | tuple[Response, int] ) –

    {"message": "Config updated successfully"}

update_draft_markup

update_draft_markup(draft_id: str) -> Response | tuple[Response, int]

Update the draft markup overlay.

Parameters:
  • draft_id (str) –

    The draft identifier

Expects

JSON: The complete markup overlay object to save

Returns:
  • JSON( Response | tuple[Response, int] ) –

    {"message": "Markup updated successfully"}

validate_draft

validate_draft(draft_id: str) -> Response | tuple[Response, int]

Validate the draft configuration against VIBE template requirements.

Uses the core VIBE validation engine to perform comprehensive validation of the draft's template configuration and structure.

Parameters:
  • draft_id (str) –

    The draft identifier

Returns:
  • JSON( Response | tuple[Response, int] ) –

    { "valid": boolean, "status": "valid" | "degraded" | "invalid", "errors": [...], "warnings": [], "execution_time": float

  • Response | tuple[Response, int]

    }

test_draft

test_draft(draft_id: str) -> Response | tuple[Response, int]

Run a test interview session with the draft template.

Uses the headless interview engine to process the template configuration and generate appropriate questions and responses.

Parameters:
  • draft_id (str) –

    The draft identifier

Expects

JSON: { "session_state": {...}, "form_data": {...} # Optional form submission data }

Returns:
  • JSON( Response | tuple[Response, int] ) –

    { "html_content": "...", "session_state": {...}, "completion_status": "incomplete" | "preview" | "complete", "relevant_questions": [...], "validation_errors": [...], "error": "..." # If an error occurred

  • Response | tuple[Response, int]

    }

publish_draft

publish_draft(draft_id: str) -> Response | tuple[Response, int]

Publish the draft as a live template using DOCXService.

Parameters:
  • draft_id (str) –

    The draft identifier

Expects

JSON: { "template_id": "new_template_id", "title": "Template Title" }

Returns:
  • JSON( Response | tuple[Response, int] ) –

    { "template_id": "new_template_id", "message": "Template published successfully"

  • Response | tuple[Response, int]

    }

new_draft_page

new_draft_page() -> str

Serve the page for uploading a new DOCX to start a draft.

editor_page

editor_page(draft_id: str) -> str | tuple[str, int]

Serve the workbench editor page for a specific draft.

Parameters:
  • draft_id (str) –

    The draft identifier

Returns:
  • HTML( str | tuple[str, int] ) –

    The workbench editor interface