FE-1448: Let Petrinaut hosts render interactive chat tools - #9249
Draft
lunelson wants to merge 2 commits into
Draft
FE-1448: Let Petrinaut hosts render interactive chat tools#9249lunelson wants to merge 2 commits into
lunelson wants to merge 2 commits into
Conversation
Exercise the real AiAssistantPanel and AI SDK addToolOutput path, including exactly one automatic follow-up after duplicate submits. Keep rejected submissions retryable, use Panda styles in the visible story, and delimit the synthetic transport steps to prevent repeated follow-ups.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🌟 What is the purpose of this PR?
Brunch — the elicitation agent being integrated with Petrinaut — needs to ask its questions inline in Petrinaut's chat panel, but the panel could only render its own built-in interactive tool, and
@hashintel/petrinautmust stay free of Brunch-specific code. This PR adds a public, typed extension point through which an embedding application registers its own interactive chat tools: a registered tool renders inline, collects exactly one submitted answer, and returns it to the assistant through the same follow-up path the built-in tools use.🔗 Related links
🚫 Blocked by
Nothing.
🔍 What does this change?
Before this change, the chat panel's interactive-tool registry was private and hard-coded to Petrinaut's own
applyAutoLayoutconfirmation widget, so any other dynamic tool call was rejected before a host could render or handle it. The panel now accepts host-registered tools through the publicaiAssistantconfiguration: a host defines a tool withdefinePetrinautAiInteractiveTool— a tool name, input and output parsers, and a React component — and the panel renders it inline, keeps it visible as a read-only record after submission, and sends exactly one output back to the assistant. Built-in tools keep their behavior, and a dynamic tool that no host registered still fails loudly.🏗️ Agent notes
Public API and type erasure
definePetrinautAiInteractiveTooland thePetrinautAiInteractiveTool*types are exported from@hashintel/petrinaut; hosts pass registrations throughaiAssistant.interactiveTools.any.{ parse(value: unknown): Value }), so Zod, Valibot, or hand-written parsers all fit without a validation-library choice leaking into the public API.Lifecycle
state: "awaiting" | "submitted", with a stable AI SDKtoolCallId;submitaccepts exactly one output — duplicate submissions are ignored and produce exactly one automatic follow-up through the existingaddToolOutputpath.Verification
AiAssistantPanelthrough submission, duplicate submission, and rejected-then-retried submission, asserting exactly one follow-up request; the synthetic test transport's steps are delimited to prevent repeated follow-ups.Petrinaut / WithHostInteractiveAiToolstory registers a visible synthetic host tool, styled with Panda.Commits
57913da2bbadds the host interactive-tool API and registry routing.720c6b1097proves the follow-up lifecycle against the real panel and adds the visible story.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
@hashintel/petrinautis npm-publishable and this branch carries no changeset; the changeset for this extension point currently lives on #9274, so whether this branch needs its own depends on merge order — see Known issues.📜 Does this require a change to the docs?
The changes in this PR:
The end-user AI assistant guide now describes host-provided inline tools, and the package README documents the public API.
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
PR #9274 (FE-1437, the Brunch monorepo import) carries an evolved variant of this extension point together with a real host tool (
brunch_askinapps/petrinaut-website) and the@hashintel/petrinautchangeset. The two branches' Petrinaut trees have diverged, so whichever merges second must be reconciled against the first; merge order is an open sequencing decision.🐾 Next steps
FE-1449 (already done) built on this mechanism to prove that a structured Brunch question suspends and resumes through the real panel; that work now travels with the FE-1437 import branch (#9274). The remaining step for this PR is the reconciliation described under Known issues.
🛡 What tests cover this?
AiAssistantPanellifecycle tests: submission, duplicate submission, and rejected-then-retried submission, with exactly one follow-up request.WithHostInteractiveAiToolStorybook story exercising a synthetic host tool.❓ How to test this?
turbo run test:unit --filter '@hashintel/petrinaut'.Petrinaut / WithHostInteractiveAiTool.📹 Demo
The
WithHostInteractiveAiToolstory is the runnable demo surface: it shows the synthetic host tool inline in the chat panel, before and after submission.🤖 Generated with Claude Code