diff --git a/catalog.json b/catalog.json index df3cc78..e841e0a 100644 --- a/catalog.json +++ b/catalog.json @@ -640,6 +640,81 @@ "workflows": 10, "miniapps": 6 }, + { + "key": "document-studio", + "name": "Document studio", + "version": "0.1.0", + "subpath": "document-studio", + "manifest": "document-studio/module.yaml", + "manifest_sha256": "89c05d34793969a8fccb1b767f9b6aa87bda29d6fb9edaf4f80e1f827e2a0299", + "tree_sha256": "5cc05c17fa5dea65b2b71bd76521530f4aa046fcb50a915c6b3aff3eb4bcb268", + "description": { + "en": "Document studio: draft business documents from a brief, render them to PDF from templates and the company profile, review, approve and issue them with a number, and keep every revision in Storage.", + "fr": "Studio de documents : rédiger des documents professionnels depuis un brief, les rendre en PDF avec des gabarits et la fiche entreprise, les relire, les approuver et les émettre avec un numéro, en gardant chaque révision dans Storage." + }, + "capabilities": [ + "documents", + "templates", + "pdf", + "review", + "numbering", + "storage" + ], + "actions": [ + { + "key": "document-studio-plan", + "name": "Plan a document" + }, + { + "key": "document-studio-draft", + "name": "Draft a document" + }, + { + "key": "document-studio-render", + "name": "Render a document preview" + }, + { + "key": "document-studio-finalize", + "name": "Approve a document" + }, + { + "key": "document-studio-publish", + "name": "Issue a document" + }, + { + "key": "document-studio-cancel", + "name": "Cancel a document" + }, + { + "key": "document-studio-export", + "name": "Export a document" + }, + { + "key": "document-studio-profile-save", + "name": "Save the company profile" + } + ], + "queries": [ + "document-studio-list", + "document-studio-review-read", + "document-studio-template-read" + ], + "requires": { + "runtimes": [ + "deno" + ], + "language_model": true, + "connectors": [], + "credentials": [], + "modules": [] + }, + "price": { + "model": "free" + }, + "maturity": "preview", + "workflows": 11, + "miniapps": 1 + }, { "key": "image-studio", "name": "Image studio", diff --git a/catalog/document-studio.yaml b/catalog/document-studio.yaml new file mode 100644 index 0000000..c9ef89a --- /dev/null +++ b/catalog/document-studio.yaml @@ -0,0 +1,19 @@ +{ + "capabilities": [ + "documents", + "templates", + "pdf", + "review", + "numbering", + "storage" + ], + "credentials": [], + "description": { + "en": "Document studio: draft business documents from a brief, render them to PDF from templates and the company profile, review, approve and issue them with a number, and keep every revision in Storage.", + "fr": "Studio de documents : rédiger des documents professionnels depuis un brief, les rendre en PDF avec des gabarits et la fiche entreprise, les relire, les approuver et les émettre avec un numéro, en gardant chaque révision dans Storage." + }, + "price": { + "model": "free" + }, + "schema": "agentmaurice.module_catalog_entry/v1" +} diff --git a/document-studio/README.md b/document-studio/README.md new file mode 100644 index 0000000..1e24b28 --- /dev/null +++ b/document-studio/README.md @@ -0,0 +1,121 @@ +# Document studio + +Reusable Module that turns a brief into a business document (quote, meeting +minutes): draft, PDF render from a template and the company profile, review, +approval and issue with a number. Everything lives in Storage; nothing is sent +outside. + +The Module contains no rendering engine. Rendering goes through the MCP tool +`artifact_render_v1` (mode `preview` for drafts, `final` for the issue). Code +steps are JavaScript (`code_execution`): no WASM in V0. No binary is versioned +here (no PDF, no PNG). The document content (prompts, templates, error +messages) is French; `fr` is the only locale in V0. + +## Workflows + +| Workflow | Role | +|---|---| +| `document-studio-plan` | picks the template from a brief, proposes a title, lists the missing data and the questions to ask. Writes nothing | +| `document-studio-draft` | fills the template data (model call, then strict validation) and creates the document record with status `draft`. For a quote, amounts and totals are computed here, in integer cents, from the lines: the model only provides quantities and prices | +| `document-studio-render` | renders the current state (PDF and PNG previews) and adds a revision. `data_patch` merges (shallow) corrections into the data, which is revalidated. An issued or cancelled document no longer renders (`document_locked`) | +| `document-studio-finalize` | `draft` to `approved`. Requires a render of the current revision and `confirmation_manuelle` | +| `document-studio-publish` | requires `approved` and `confirmation_manuelle`. Reserves the next number, renders in `final` mode, stores the issued PDF, moves to `issued` | +| `document-studio-cancel` | moves to `cancelled` with a reason. An issued number is never reused | +| `document-studio-export` | refuses a cancelled document (`document_cancelled`); otherwise copies the issued PDF (or the latest render, flagged as a draft) to a Storage path outside `/document-studio/`, with its SHA-256. Mail and SFTP are out of V0 | +| `document-studio-profile-save` | validates and stores the company profile and brand (`/document-studio/profile.json`), with manual confirmation | +| `document-studio-list` | lists the documents (identifier, title, status, number, revision, latest hash) | +| `document-studio-review-read` | full record of a document and previews of its latest render, for the MiniApp | +| `document-studio-template-read` | lists the templates, or the manifest and data schemas of one template | + +The `document-studio-review` MiniApp has no input component of its own (the +MiniApp vocabulary has none): the document identifier (`doc_id`) is typed in +the form "Relire un document" of `document-studio-review-read`, which loads +the document. The MiniApp then shows status, revision, number, pages and the +table of renders (revision, mode, hash, path), refreshes it, and triggers a +new render. Approval and issue go through the +Workflow forms, with the manual confirmation. + +## Lifecycle + +`draft` (successive renders) → `approved` → `issued`. `cancelled` is reachable +from every other status. A new render of an `approved` document brings it back +to `draft`: the approval must be given again. The manual confirmation is the +form field `confirmation_manuelle` (`oui` or `non`); without `oui`, the +Workflow refuses (`manual_confirmation_required`) before any read or write. +The Module never approves on a person's behalf. + +## Storage + +- `/document-studio/profile.json`: the brand, with the `{schema_version: 1, company, brand}` shape of the template contract. A fictitious example is in `examples/profile.example.json`. +- `/document-studio/docs//record.json`: the record (`document-studio.record/v1`): status, number, revision (+1 at every write), data, history, renders (path, SHA-256, previews, provenance), issue. +- `/document-studio/docs//r-/`: PDF and previews of one render attempt (12 first characters of the PDF SHA-256, so a losing attempt never overwrites another attempt's file). +- `/document-studio/docs//issued/-.pdf`: the issued PDF. +- `/document-studio/numbers/