Skip to content

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

Merged
kostandinang merged 6 commits into
mainfrom
kostandin/h-6763-petrinaut-composer-api
Sep 1, 2026
Merged

H-6763: Add a generic Petrinaut composer submission API#9355
kostandinang merged 6 commits into
mainfrom
kostandin/h-6763-petrinaut-composer-api

Conversation

@kostandinang

@kostandinang kostandinang commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🌟 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
hash Ready Ready Preview Sep 1, 2026 10:30am UTC
petrinaut Ready Ready Preview Sep 1, 2026 10:30am UTC
petrinaut-docs Ready Ready Preview Sep 1, 2026 10:30am UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Sep 1, 2026 10:30am UTC

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
Comment thread libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel.tsx Outdated
kostandinang and others added 5 commits September 1, 2026 11:22
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>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
lunelson
lunelson previously approved these changes Sep 1, 2026

@lunelson lunelson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a clean split: Petrinaut gets a host control and one submission path, and provider/audio stay out. Sharing useChat between the keyboard and submitText is the right boundary for the rest of the stack.

One question on the public shape. fromComposerText plus the “exactly one pending mapped tool” rule in ai-assistant-panel.tsx (with target: "message" to opt out) reads like the brunch_ask interview turn, published as a generic Petrinaut contract. That’s fine if you expect other tools to need the same routing. If brunch_ask is the only caller, a narrower host API — complete this pending tool, or send a normal message — might age better than teaching every interactive tool how to parse composer text.

Approving as-is. Flagging it because this is the published seam the later PRs will be stuck with.

@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 feaefa5. Configure here.

@kostandinang

Copy link
Copy Markdown
Contributor Author

@lunelson Intentional: fromComposerText is the generic seam for any interactive tool that can map free text; brunch_ask is the first consumer.

Only mark an abort as user-requested while a response is active, preventing a later incidental abort from showing a stale stopped state.

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.

2 participants