Skip to content

enh: add API for POST events and add to event stream - #812

Merged
heerambavi1998 merged 29 commits into
mainfrom
ha/api
Sep 24, 2026
Merged

heerambavi1998 merged 29 commits into
mainfrom
ha/api

Conversation

@heerambavi1998

@heerambavi1998 heerambavi1998 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

add API for POST events and add to event stream

Changes

Also persist the post events to DB.

How was this tested?

unit tests

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, python/trueforge_sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

Medium Risk
New authenticated turn-control surface for tool approval and policy events; handler does not yet persist or apply them, which can mislead integrators expecting HITL to resume execution.

Overview
Adds POST /api/v1/sessions/{session_id}/turns/{turn_id}/events so the session creator can send mid-turn human-in-the-loop inputs: tool approvals, client tool responses, and session-scoped approval policies (user.tool_* types). Requests accept a batch of inbound events; the handler mints id and created_at and returns 201 with the durable-shaped payloads (session-owner checks mirror other turn routes).

The OpenAPI contract, Zod/core schemas, and regenerated TS/Python SDKs (createTurnEvent / create_turn_event) are extended with CreateTurnEventRequest/Response, TurnInboundEventItem, tool-approval policy types, and persisted/stream variants of the user events on SessionEvent, TurnStreamingEvent, and related unions. trueforge-ui still drops these (and turn.update) until the runtime union catches up.

Note: In this diff, DB insert / resume-the-turn wiring is stubbed (insertTurnInboundEvents remains commented in createTurnEventHandler), so clients get stable IDs but events are not yet persisted or applied server-side.

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

@changeset-bot

changeset-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ff0937d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@truefoundry/trueforge-sdk Patch
@truefoundry/trueforge Patch
@truefoundry/trueforge-core Patch
@truefoundry/trueforge-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@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.

Stale Bugbot comment from a previous run.

Comment thread .github/fern/openapi/openapi.json
@heerambavi1998
heerambavi1998 added this pull request to stack #808 September 22, 2026 08:28
@heerambavi1998 heerambavi1998 changed the title enh: add API for session event creation enh: add API for POST events and add to event stream Sep 23, 2026
Base automatically changed from ha/approval to main September 24, 2026 06:43

@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 using default effort and found 4 potential issues.

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 cadcd5e. Configure here.

Comment thread packages/trueforge/src/apis/turns.ts
Comment thread packages/trueforge/src/apis/turns.ts
Comment thread packages/trueforge-core/src/core/events/schema.ts
@heerambavi1998
heerambavi1998 merged commit 0c82412 into main Sep 24, 2026
13 checks passed
@heerambavi1998
heerambavi1998 deleted the ha/api branch September 24, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants