managarten/packages
Till JS a4bc7d2ee3 feat(invoices): M8 AI tools — create/mark_paid/list/stats
The last open item from the plan. Missions can now draft invoices from
chat context, mark customer payments, and read status for autonomous
follow-up cadences.

Tool catalog (packages/shared-ai/src/tools/schemas.ts)
- create_invoice (propose) — clientName + lines[] + currency + due
- mark_invoice_paid (propose) — by id, optional back-dated paidAt
- list_invoices (auto) — with status + limit filter
- get_invoice_stats (auto) — open/overdue/YTD per currency

Had to widen the tool-parameter type vocabulary so create_invoice can
declare lines as a typed array. Touched three places:
- ToolSchema-side: the catalog's `type` string is already free-form so
  'array' / 'object' just pass through
- ModuleTool-side (apps/mana/apps/web/src/lib/data/tools/types.ts): added
  'array' | 'object' to the union so TS doesn't narrow the executor's
  param signatures
- function-schema translator (packages/shared-ai): mapParamType +
  JsonSchemaProperty both gained the two new types; the catalog-typo
  guard test now uses 'fruit' as its sentinel (array no longer unknown)

Executor (apps/mana/apps/web/src/lib/modules/invoices/tools.ts)
- coerceLines accepts either a real array or a JSON-stringified array
  (planners vary), skips malformed entries, converts major→minor units
- create_invoice pulls the generated number back from Dexie so the
  success message shows "Entwurf 2026-0042 …" — the user recognises it
- mark_invoice_paid normalises YYYY-MM-DD → ISO so the store's timestamp
  invariant (ISO throughout) stays intact
- list_invoices derives overdue on read (consistent with useAllInvoices),
  returns major-unit amounts so the LLM reasons in user-facing numbers
- get_invoice_stats returns counts + open/overdue/YTD per currency

Registration: invoicesTools added to tools/init.ts. mana-ai drift guard
is happy (41/41 green); webapp + shared-ai type-check 0 errors; full
invoice test suite 59/59 green.

Closes: docs/plans/invoices-module.md §M8. All plan milestones now DONE.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 18:22:20 +02:00
..
credits fix(type-check): repair silently broken per-package type-check scripts 2026-04-20 15:13:54 +02:00
eslint-config fix(timeblocks): type errors from recurrence migration 2026-04-07 13:22:59 +02:00
feedback fix(packages): cross-package broken imports + missing exports 2026-04-09 20:23:34 +02:00
help refactor: rename planta → plants, clean up codebase 2026-04-12 18:59:44 +02:00
local-llm fix(type-check): repair silently broken per-package type-check scripts 2026-04-20 15:13:54 +02:00
local-store fix(mana/web): sprint 2 — auth-aware data layer + guest migration 2026-04-07 13:07:12 +02:00
local-stt fix(type-check): repair silently broken per-package type-check scripts 2026-04-20 15:13:54 +02:00
notify-client chore(matrix): final scrub of stale matrix references 2026-04-08 16:47:54 +02:00
qr-export chore(workspace): unify vitest to ^4.1.2 across all packages 2026-04-07 13:58:29 +02:00
shared-ai feat(invoices): M8 AI tools — create/mark_paid/list/stats 2026-04-20 18:22:20 +02:00
shared-auth refactor(credits): simplify credit system — remove productivity credits, guild pools, complex gift types 2026-04-10 19:08:42 +02:00
shared-auth-ui chore: final cleanup — dead link, security status, showTitle, drop subscriptions 2026-04-16 14:27:46 +02:00
shared-branding feat(spaces): validate space metadata on Better Auth organization hooks 2026-04-20 16:05:38 +02:00
shared-drizzle-config feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
shared-error-tracking feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
shared-go chore: complete ManaCore → Mana rename (docs, go modules, plists, images) 2026-04-07 12:26:10 +02:00
shared-hono fix(type-check): clear the last five failures — monorepo type-check is now 76/76 green 2026-04-20 15:53:07 +02:00
shared-i18n chore: complete ManaCore → Mana rename (docs, go modules, plists, images) 2026-04-07 12:26:10 +02:00
shared-icons perf(shared-icons): mark package as side-effect-free for tree-shaking 2026-04-14 17:16:19 +02:00
shared-landing-ui refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
shared-links refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
shared-llm fix(type-check): unblock two more pre-existing failures 2026-04-20 15:20:08 +02:00
shared-logger fix(type-check): clear the last five failures — monorepo type-check is now 76/76 green 2026-04-20 15:53:07 +02:00
shared-pwa fix(pwa): wire up manifest link + SW registration so install prompt works 2026-04-14 14:05:49 +02:00
shared-python/manacore_auth feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
shared-research feat(research-lab): tier gate (beta+), 1–5 star ratings, run detail route 2026-04-17 15:28:02 +02:00
shared-rss refactor(shared-rss): extract RSS parsing + Readability into one package 2026-04-15 22:30:44 +02:00
shared-storage chore(ci): add v8 test coverage tracking (non-blocking baseline) 2026-04-19 19:21:14 +02:00
shared-stores fix(ai): P1 batch — N+1 queries, vault-locked, debug hardening, timeout 2026-04-16 16:25:17 +02:00
shared-tags chore: complete ManaCore → Mana rename (docs, go modules, plists, images) 2026-04-07 12:26:10 +02:00
shared-tailwind chore: final cleanup — dead link, security status, showTitle, drop subscriptions 2026-04-16 14:27:46 +02:00
shared-theme refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
shared-theme-ui feat(web): wallpaper system + sticky PageHeader 2026-04-12 16:00:03 +02:00
shared-types feat(spaces): validate space metadata on Better Auth organization hooks 2026-04-20 16:05:38 +02:00
shared-ui chore(ci): add v8 test coverage tracking (non-blocking baseline) 2026-04-19 19:21:14 +02:00
shared-uload fix(packages): modal keydown handlers, $derived.by usage, UserData fields 2026-04-09 20:24:05 +02:00
shared-utils refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
shared-vite-config chore(packages): remove 4 dead zero-consumer packages 2026-04-09 11:56:25 +02:00
spiral-db refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
test-config fix(type-check): repair silently broken per-package type-check scripts 2026-04-20 15:13:54 +02:00
wallpaper-generator fix(a11y): replace 215 suppression comments with real fixes 2026-04-10 22:43:05 +02:00