Skip to content

feat: add @rivetkit/effect package#4312

Open
Makisuo wants to merge 4 commits intorivet-dev:mainfrom
Makisuo:feat/rivetkit-effect
Open

feat: add @rivetkit/effect package#4312
Makisuo wants to merge 4 commits intorivet-dev:mainfrom
Makisuo:feat/rivetkit-effect

Conversation

@Makisuo
Copy link

@Makisuo Makisuo commented Feb 25, 2026

Summary

  • Adds @rivetkit/effect at rivetkit-typescript/packages/effect/ — first-class Effect-TS integration for RivetKit actors
  • Provides RivetActorContext tag, Effect wrappers for all lifecycle hooks and actions, ManagedRuntime support, queue helpers, and tagged errors
  • Includes 13 unit tests covering runtime execution, queue helpers, action/lifecycle wrappers, and error mapping
  • Adds examples/effect/ — a full counter example with React frontend and integration tests

Motivation

Effect-TS is increasingly popular for building reliable TypeScript applications. This package lets developers use Effect's composable error handling, dependency injection, and runtime management when building RivetKit actors — without giving up any of the existing actor API.

What's Included

Package (rivetkit-typescript/packages/effect/)

Module Purpose
actor.ts RivetActorContext tag + accessor helpers (state, vars, broadcast, etc.)
action.ts Action.effect() wrapper for action handlers
lifecycle.ts OnCreate.effect(), OnWake.effect(), etc. for all lifecycle hooks
rivet-actor.ts actor() factory with optional runtime for ManagedRuntime
runtime.ts ManagedRuntime integration — runPromise / runPromiseExit
queue.ts Queue.next() / Queue.nextMultiple() helpers
log.ts Effect-aware logging via actor context
errors.ts RuntimeExecutionError + StatePersistenceError tagged errors

Example (examples/effect/)

Counter actor demonstrating:

  • Action.effect() for all action handlers (increment, decrement, reset, batchIncrement)
  • OnCreate.effect() lifecycle hook
  • Log.info() for structured logging
  • React frontend with @rivetkit/react
  • Integration tests with setupTest

Test plan

  • 13 unit tests pass (pnpm run test in rivetkit-typescript/packages/effect/)
  • Package builds successfully (pnpm run build)
  • Example follows upstream conventions (vite, vitest, hono, turbo.json)
  • Integration tests pass in CI (requires full build chain)
  • Verify pnpm run check-types passes in CI

Makisuo and others added 3 commits February 25, 2026 23:52
Adds first-class Effect-TS support for RivetKit actors with:
- RivetActorContext tag for injecting actor context into Effect pipelines
- Effect wrappers for all lifecycle hooks and actions
- ManagedRuntime support for bringing custom Effect layers
- Queue helpers for message processing
- Tagged errors (RuntimeExecutionError, StatePersistenceError)
- Comprehensive test suite (13 tests)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Adds an example at examples/effect/ demonstrating @rivetkit/effect usage:
- Counter actor using Action.effect() for all actions
- OnCreate lifecycle hook with Effect-TS
- Log helpers for structured logging
- Batch increment, decrement, and reset operations
- React frontend with @rivetkit/react
- Integration tests using setupTest from rivetkit/test
- Fixes @rivetkit/effect package.json exports to match tsup output
@Makisuo Makisuo marked this pull request as ready for review February 27, 2026 13:07
@bam4564
Copy link

bam4564 commented Feb 27, 2026

Super happy to see this near completion. Nice work @Makisuo! Excited to try this out

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