Skip to content

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

Open
kostandinang wants to merge 4 commits into
mainfrom
kostandin/h-6763-petrinaut-composer-api
Open

H-6763: Add a generic Petrinaut composer submission API#9355
kostandinang wants to merge 4 commits into
mainfrom
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 31, 2026 7:54pm
petrinaut Ready Ready Preview Aug 31, 2026 7:54pm
petrinaut-docs Ready Ready Preview Aug 31, 2026 7:54pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 31, 2026 7:54pm

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
@github-actions github-actions Bot added area/apps area/apps > hash-graph type/legal Owned by the @legal team area/apps > hash.design Affects the `hash.design` design site (app) labels Aug 31, 2026
@kostandinang
kostandinang changed the base branch from graphite-base/9355 to main August 31, 2026 18:06
@github-actions github-actions Bot removed area/deps Relates to third-party dependencies (area) area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) type/eng > backend Owned by the @backend team area/tests New or updated tests area/tests > integration New or updated integration tests area/tests > playwright New or updated Playwright tests area/apps area/apps > hash-graph type/legal Owned by the @legal team area/apps > hash.design Affects the `hash.design` design site (app) labels Aug 31, 2026
kostandinang and others added 4 commits August 31, 2026 21:25
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>

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

setStopped(false);
stopRequestedRef.current = false;
void sendMessage({ text: trimmed });
void submitText({ text: prompt }).catch(() => {});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Chips answer pending mapped tools

Medium Severity

Review prompt chips now go through submitText with default target: "auto". If a mapped interactive tool is pending, a chip such as Suggest improvements or Explain this model completes that tool instead of sending the review prompt. REVIEW_CHIPS stay visible on a non-empty net after the conversation has started, so this happens as soon as a host registers fromComposerText.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e15b65f. Configure here.

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