Skip to content

H-6763: Add a generic Petrinaut composer submission API - #9355

Open
kostandinang wants to merge 4 commits into
graphite-base/9355from
kostandin/h-6763-petrinaut-composer-api
Open

H-6763: Add a generic Petrinaut composer submission API#9355
kostandinang wants to merge 4 commits into
graphite-base/9355from
kostandin/h-6763-petrinaut-composer-api

Conversation

@kostandinang

@kostandinang kostandinang commented Aug 26, 2026

Copy link
Copy Markdown

🌟 What is the purpose of this PR?

Add a provider-neutral API for controls embedded in Petrinaut's AI composer. A host can submit finalized text—voice transcripts are the first consumer—through the same AI SDK conversation and correlated interactive-tool path used by keyboard submissions.

This PR deliberately contains no OpenAI, audio, or Brunch-specific runtime code.

🔗 Related links

🚫 Blocked by

🔍 What does this change?

  • Adds renderComposerControl, allowing an application-owned control to render beside the Petrinaut composer.
  • Gives that control the effective AI SDK conversation ID, current messages/status, and stable submitText and stop callbacks.
    • The ID is the exact useChat ID, whether supplied by the host or generated by the SDK.
    • Stable callbacks use the latest committed conversation after an ID change rather than targeting the previous chat.
  • Routes keyboard and host-submitted text through one submission function and one useChat instance.
    • Supplied user-message IDs remain stable across transport retries.
    • target: "message" explicitly submits a normal message without consuming a pending tool, which supports later correction turns.
  • Extends interactive tools with an optional schema-validated fromComposerText mapper.
    • One eligible unresolved tool is completed through its existing correlated tool call.
    • Unknown or unmapped tools fall back to a normal message.
    • Multiple eligible tools fail visibly instead of guessing.
    • Duplicate tool submissions are suppressed.
  • Records the ownership boundary in ADR-0009, Brunch steering/strategy records, and the Petrinaut integration specification: Petrinaut owns the generic composer seam; applications own provider integrations; Brunch remains provider-free.
  • Updates the Petrinaut user guide/changelog and adds the required npm changeset.

Stack record: direct base 359afceabaac841b8e6d88f877e5daaf92026528; #9345 head 146d7895d41eaf7092571ff36b4b08bba7cc18ed; #9346 head 359afceabaac841b8e6d88f877e5daaf92026528.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies an npm-publishable library and I have added a changeset file(s)

📜 Does this require a change to the docs?

The changes in this PR:

  • require changes to docs which are made as part of this PR

The existing AI-assistant guide has no screenshot for this surface, so no screenshot is made stale.

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

🐾 Next steps

🛡 What tests cover this?

ai-assistant-panel.test.tsx, ai-assistant-contents.test.tsx, and the interactive-tool registry tests cover effective/generated conversation identity, callback freshness, shared keyboard/control submission, stable IDs, mapping validation, correlated tool output, ambiguity, duplicate suppression, explicit message targeting, and stop behavior.

Validation run
yarn workspace @hashintel/petrinaut test:unit --run
yarn workspace @hashintel/petrinaut lint:eslint
yarn workspace @hashintel/petrinaut lint:tsc
yarn workspace @hashintel/petrinaut build
yarn workspace @apps/petrinaut-website test:unit
yarn workspace @apps/petrinaut-website lint:eslint
yarn workspace @apps/petrinaut-website lint:tsc
yarn workspace @apps/petrinaut-website build
yarn workspace @hashintel/brunch-agent-transport-aisdk test:unit
yarn workspace @hashintel/brunch-agent-transport-aisdk lint:eslint
yarn workspace @hashintel/brunch-agent-transport-aisdk lint:tsc
yarn workspace @hashintel/brunch-agent-transport-aisdk build
yarn workspace @apps/brunch-agent test:unit
yarn workspace @apps/brunch-agent lint:eslint
yarn workspace @apps/brunch-agent lint:tsc
yarn workspace @apps/brunch-agent build
yarn workspace @local/petrinaut-arch-docs lint:arch-docs
yarn oxfmt --check apps/petrinaut-website apps/brunch-agent libs/@hashintel/petrinaut libs/@hashintel/brunch-agent

Results: 214 Petrinaut tests, 4 website tests, 12 transport tests, and 35 Brunch tests passed. Lint, typecheck, build, formatting, and architecture-doc checks passed. Transport emitted 4 inherited no-await-in-loop warnings and Brunch emitted 12 inherited warnings.

The direct-base no-ElevenLabs audit and git diff --check passed. No package, lockfile, environment, or deployment configuration changed. No provider credential check applies to this PR.

❓ How to test this?

  1. Run yarn workspace @hashintel/petrinaut test:unit --run src/ui/views/Editor/panels/ai-assistant-panel.test.tsx.
  2. Confirm keyboard and host-control submissions use the same chat ID and preserve a supplied message ID.
  3. Confirm one mapped pending tool receives correlated output, ambiguous mappings fail, and target: "message" leaves a pending tool untouched.

📹 Demo

Not applicable: this PR adds a host integration API without a new standalone user experience.

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview Aug 27, 2026 12:41pm
petrinaut Ready Ready Preview Aug 27, 2026 12:41pm
petrinaut-docs Ready Ready Preview Aug 27, 2026 12:41pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 27, 2026 12:41pm

Request Review

@github-actions github-actions Bot added area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team labels Aug 26, 2026
@kostandinang kostandinang changed the title Add generic Petrinaut composer submission H-6763: Add a generic Petrinaut composer submission API Aug 26, 2026

kostandinang commented Aug 26, 2026

Copy link
Copy Markdown
Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@lunelson
lunelson changed the base branch from ln/fe-1506-legible-panel-status to graphite-base/9355 August 27, 2026 08:39
@kostandinang
kostandinang force-pushed the kostandin/h-6763-petrinaut-composer-api branch from 3152049 to 5b2cf27 Compare August 27, 2026 10:52
@kostandinang
kostandinang changed the base branch from graphite-base/9355 to ln/fe-1506-legible-panel-status August 27, 2026 10:52
kostandinang and others added 3 commits August 27, 2026 13:18
Expose stable host-owned composer controls, conversation identity, and schema-validated text mapping through the existing AI SDK chat path.

Record the app-owned OpenAI voice boundary and the production contracts that gate rollout.

Amp-Thread-ID: https://ampcode.com/threads/T-01a03fb3-fd3d-737f-b4c6-1fc9282950bf
Co-authored-by: Amp <amp@ampcode.com>
Preserve automatic pending-tool correlation for ordinary submissions while letting explicit corrections bypass a pending interactive ask. Document and test the generic target contract at the Petrinaut boundary.

Amp-Thread-ID: https://ampcode.com/threads/T-01a03fb3-fd3d-737f-b4c6-1fc9282950bf
Co-authored-by: Amp <amp@ampcode.com>
@kostandinang
kostandinang changed the base branch from ln/fe-1506-legible-panel-status to graphite-base/9355 August 27, 2026 11:19
@kostandinang
kostandinang force-pushed the kostandin/h-6763-petrinaut-composer-api branch from 5b2cf27 to 3e9d09b Compare August 27, 2026 11:19
@kostandinang
kostandinang changed the base branch from graphite-base/9355 to ln/fe-1507-topology August 27, 2026 11:19
@kostandinang
kostandinang marked this pull request as ready for review August 27, 2026 11:25
@cursor

cursor Bot commented Aug 27, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes central AI assistant submission and pending interactive-tool correlation; mistakes could mis-route user text or break ask flows, though behavior is heavily unit-tested.

Overview
Adds a provider-neutral seam so embedders can render a control beside the Petrinaut AI composer and submit finalized text through the same useChat conversation as keyboard input—intended for voice transcripts in follow-up PRs, with no OpenAI or audio runtime in this change.

@hashintel/petrinaut gains optional conversationId, renderComposerControl, and a context with stable submitText / stop, messages, and status. One submitText path handles chips, Enter, and host input (trim, busy checks, stable message IDs). Interactive tools may opt into schema-validated fromComposerText so a single pending mapped tool completes via correlated tool output; ambiguous mappings error, unmapped tools become normal messages, and target: "message" forces a separate user message for corrections. The composer form only submits from the send button so untyped host buttons do not post the draft.

Docs and governance record the boundary in ADR-0009, S-012, the Petrinaut integration attach contract (fourth seam: composer submission), steering/index updates, user guide, changeset, and changelog.

Reviewed by Cursor Bugbot for commit 0e49270. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3e9d09b. Configure here.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

1 participant