Files
clawmates/Cargo.toml
T
Omar SobhandClaude Opus 4.7 3ac3d53da7
ci / gates (push) Successful in 6s
ci / frontend (push) Successful in 38s
ci / rust (push) Successful in 3m28s
ci / e2e (push) Skipped
ci / publish (push) Successful in 3m4s
slice 6: LLM + Chromium PDF renderer worker
Watches mission_artifacts for MD entries with render_pdf_status='pending'
and turns them into styled PDFs via:
  1. Read source MD from <mission_root>/<path>
  2. Call configured LLM (default gemini-2.5-flash) with a document-
     typesetter system prompt that constrains style to a self-contained
     HTML doc with inline CSS + our color palette
  3. Print to PDF via `chromium --headless=new --print-to-pdf`
  4. Save alongside source MD (foo.md → foo.pdf) + update
     mission_artifacts.rendered_pdf_path + render_pdf_status='done'

Graceful degradation: GEMINI_API_KEY unset OR chromium missing =
row marked failed with a descriptive error, worker keeps ticking.
The frontend's "Open PDF" affordance (Slice 2) light up automatically
when render succeeds.

Boot ordering: PDF worker spawns after task_card_worker. Poll every
30s over up to MAX_PARALLEL=2 rows at a time — respects LLM rate
limits and keeps chromium's peak RAM under control.

Env knobs:
  GEMINI_API_KEY                    — required for LLM step
  CLAWMATES_PDF_RENDERER_MODEL      — model id, default gemini-2.5-flash
  CHROMIUM_BIN                      — chromium binary, default `chromium`
  CLAWMATES_MISSIONS_ROOT           — artifact dir root, default /var/lib/clawmates-missions

Dockerfile now installs chromium + fonts-liberation and sets
CHROMIUM_BIN=/usr/bin/chromium so the container image has everything
the renderer needs.

Also bumps workspace tokio deps to include the `process` feature
(required for tokio::process::Command).

Follow-ups:
  - Anthropic + OpenAI provider variants (only Gemini in this slice)
  - SSE stream on /api/missions/{id}/artifacts for the "PDF ready"
    notification instead of poll-via-mission-GET
  - Per-template PDF style overrides (currently one house style
    for all missions)

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-07-19 15:16:57 -07:00

77 lines
2.7 KiB
TOML

[workspace]
resolver = "2"
members = [
"crates/cm-domain",
"crates/cm-topology",
"crates/cm-orchestrator",
"crates/cm-config",
"crates/cm-db",
"crates/cm-llm",
"crates/cm-runtime",
"crates/cm-tools",
"crates/cm-safety",
"crates/cm-sandbox",
"crates/cm-secrets",
"crates/cm-files",
"crates/cm-scheduler",
"crates/cm-billing",
"crates/cm-telemetry",
"crates/cm-testkit",
"crates/cm-auth",
"crates/cm-brain",
"crates/cm-api",
"crates/bins/clawmates-server",
"crates/bins/clawmates-broker",
"crates/bins/clawmates-node",
"tools/bundler",
]
[workspace.package]
edition = "2021"
rust-version = "1.96"
license = "UNLICENSED"
publish = false
[workspace.dependencies]
# Shared dependency versions; crates opt in via { workspace = true }.
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "2"
uuid = { version = "1", features = ["v7", "serde"] }
proptest = "1"
time = { version = "0.3", features = ["serde", "serde-well-known"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread", "fs", "net", "time", "sync", "io-util", "process"] }
sqlx = { version = "0.8", default-features = false, features = [
"runtime-tokio",
"tls-rustls",
"postgres",
"uuid",
"time",
"json",
"migrate",
"macros",
"bigdecimal",
] }
testcontainers-modules = { version = "0.13", features = ["postgres"] }
[workspace.lints.rust]
unsafe_code = "deny"
[workspace.lints.clippy]
todo = "deny"
unimplemented = "deny"
dbg_macro = "deny"
# ClawSync (claw-brain `sync` feature) pulls clawhdf5-onion/clawsync-onion/
# clawsync-agent from the clawsync repo, whose crates internally path-dep on a
# sibling ../clawhdf5 (absent in a git checkout). clawverse patches this for its
# own build, but `[patch]` only applies from the root workspace — so we mirror it
# here, redirecting clawsync's clawhdf5 view to the same quantumclaw rev cm-brain
# already uses (one clawhdf5 in the graph, types unify).
[patch."https://git.redclaw.dev/redclaw/clawsync.git"]
clawhdf5 = { git = "https://git.redclaw.dev/quantumclaw/clawhdf5.git", rev = "8534c7d204959c6f8959f3983f3edf6475ba25b9" }
clawhdf5-format = { git = "https://git.redclaw.dev/quantumclaw/clawhdf5.git", rev = "8534c7d204959c6f8959f3983f3edf6475ba25b9" }
clawhdf5-io = { git = "https://git.redclaw.dev/quantumclaw/clawhdf5.git", rev = "8534c7d204959c6f8959f3983f3edf6475ba25b9" }
clawhdf5-filters = { git = "https://git.redclaw.dev/quantumclaw/clawhdf5.git", rev = "8534c7d204959c6f8959f3983f3edf6475ba25b9" }
clawhdf5-agent = { git = "https://git.redclaw.dev/quantumclaw/clawhdf5.git", rev = "8534c7d204959c6f8959f3983f3edf6475ba25b9" }