managarten/packages
Till JS 101af462a8 feat(shared-ai): LLM-facing task tool wrapper for runSubAgent (M3.2)
Exposes runSubAgent() as a tool the planner LLM can call natively,
matching Claude Code's `Task` tool shape: { subagent_type, description,
prompt } -> single-string summary.

New exports from @mana/shared-ai:

  - TASK_TOOL_NAME = 'task'
  - TASK_TOOL_SCHEMA — ToolSchema ready to drop into a runPlannerLoop
    `tools` array. subagent_type enum = research|plan|general;
    description+prompt required; defaultPolicy: 'auto' (control-flow,
    not a user-data write).
  - createTaskToolHandler(opts) — factory returning:
      - handle(call): structured ToolResult with the sub-agent's
        summary as message + data {subAgentType, toolsCalled,
        rounds, stopReason, usage}
      - cumulativeUsage(): rolled-up TokenUsage across all sub-agent
        invocations — parent budget accounting reads from here
      - invocationCount(): metric-ready counter

Why not in mana-tool-registry: `task` is a loop-internal control-flow
primitive, not a user-data operation. Registry is for habits/notes/etc.
where MCP exposure and space-scoping matter. task never touches mana-
sync and never crosses the MCP boundary.

Recursion guard is defense-in-depth: the primitive throws
SubAgentRecursionError, this handler catches parentDepth >=
MAX_SUB_AGENT_DEPTH up front and returns a structured ToolResult
instead so the LLM sees it as regular tool-feedback.

Exceptions from the sub-agent (provider down, network) get wrapped
as `{ success: false, message: 'Sub-agent failed: ...' }`. The parent
loop's round continues.

14 new tests covering schema shape, recursion rejection, argument
validation (4 cases), happy path with tool dispatch, cumulative
usage tracking across multiple invocations, exception wrapping,
and parent-dispatcher routing.

107 shared-ai tests green total (was 93).

M3.3 consumer wiring follows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 19:05:09 +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
mana-tool-registry feat(tool-registry): wardrobe.* MCP tools — listGarments/listOutfits/createOutfit/tryOn (M5) 2026-04-23 18:59:31 +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(shared-ai): LLM-facing task tool wrapper for runSubAgent (M3.2) 2026-04-23 19:05:09 +02:00
shared-auth feat(broadcast): M2 audience + editor + compose wizard 2026-04-20 20:41:09 +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(wardrobe): module foundation — garments + outfits space-scoped data layer (M1) 2026-04-23 18:27:37 +02:00
shared-crypto feat(mcp): M1+M1.5 MCP gateway + tool-registry + shared-crypto 2026-04-23 13:18:35 +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 feat(articles): M7 share-target + bookmarklet — save from anywhere 2026-04-21 19:03:33 +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(mana-research): add Gemini 3.1 Pro Deep Research async providers 2026-04-22 17:55:30 +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 refactor(theming): migrate who semantic colours to theme tokens 2026-04-22 17:19:53 +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(wardrobe): module foundation — garments + outfits space-scoped data layer (M1) 2026-04-23 18:27:37 +02:00
shared-ui feat(pill-nav): show Anmelden pill for guests next to menu icon 2026-04-23 15:36:09 +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
website-blocks feat(wardrobe): module foundation — garments + outfits space-scoped data layer (M1) 2026-04-23 18:27:37 +02:00