Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion examples/chat-room-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"scripts": {
"dev": "npx rivetkit/cli@latest dev actors/app.ts",
"dev": "tsx src/server.ts",
"check-types": "tsc --noEmit",
"pytest": "pytest tests/test_chat_room.py -v"
},
Expand All @@ -14,6 +14,9 @@
"tsx": "^3.12.7",
"typescript": "^5.5.2"
},
"dependencies": {
"@rivetkit/nodejs": "workspace:*"
},
"example": {
"platforms": [
"*"
Expand Down
4 changes: 4 additions & 0 deletions examples/chat-room-python/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { serve } from "@rivetkit/nodejs";
import { app } from "./workers/app";

serve(app);
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { actor, setup } from "rivetkit";
import { worker, setup } from "rivetkit";

// state managed by the actor
export interface State {
messages: { username: string; message: string }[];
}

export const chatRoom = actor({
export const chatRoom = worker({
// initialize state
state: { messages: [] } as State,

Expand All @@ -28,7 +28,7 @@ export const chatRoom = actor({

// Create and export the app
export const app = setup({
actors: { chatRoom },
workers: { chatRoom },
});

// Export type for client type checking
Expand Down
5 changes: 4 additions & 1 deletion examples/chat-room/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"scripts": {
"dev": "npx rivetkit/cli@latest dev actors/app.ts",
"dev": "tsx src/server.ts",
"check-types": "tsc --noEmit",
"test": "vitest run"
},
Expand All @@ -17,6 +17,9 @@
"typescript": "^5.5.2",
"vitest": "^3.1.1"
},
"dependencies": {
"@rivetkit/nodejs": "workspace:*"
},
"example": {
"platforms": [
"*"
Expand Down
4 changes: 4 additions & 0 deletions examples/chat-room/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { serve } from "@rivetkit/nodejs";
import { app } from "./workers/app";

serve(app);
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { actor, setup } from "rivetkit";
import { worker, setup } from "rivetkit";

// state managed by the actor
export interface State {
messages: { username: string; message: string }[];
}

export const chatRoom = actor({
export const chatRoom = worker({
// initialize state
state: { messages: [] } as State,

Expand All @@ -28,7 +28,7 @@ export const chatRoom = actor({

// Create and export the app
export const app = setup({
actors: { chatRoom },
workers: { chatRoom },
});

// Export type for client type checking
Expand Down
2 changes: 1 addition & 1 deletion examples/chat-room/tests/chat-room.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "vitest";
import { setupTest } from "rivetkit/test";
import { app } from "../actors/app";
import { app } from "../src/workers/app";

test("chat room should handle messages", async (test) => {
const { client } = await setupTest(test, app);
Expand Down
5 changes: 4 additions & 1 deletion examples/counter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"scripts": {
"dev": "npx rivetkit/cli@latest dev actors/app.ts",
"dev": "tsx src/server.ts",
"check-types": "tsc --noEmit",
"test": "vitest run"
},
Expand All @@ -15,6 +15,9 @@
"typescript": "^5.7.3",
"vitest": "^3.1.1"
},
"dependencies": {
"@rivetkit/nodejs": "workspace:*"
},
"example": {
"platforms": [
"*"
Expand Down
4 changes: 4 additions & 0 deletions examples/counter/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { serve } from "@rivetkit/nodejs";
import { app } from "./workers/app";

serve(app);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { actor, setup } from "rivetkit";
import { worker, setup } from "rivetkit";

const counter = actor({
const counter = worker({
state: { count: 0 },
actions: {
increment: (c, x: number) => {
Expand All @@ -15,7 +15,7 @@ const counter = actor({
});

export const app = setup({
actors: { counter },
workers: { counter },
});

export type App = typeof app;
2 changes: 1 addition & 1 deletion examples/counter/tests/counter.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "vitest";
import { setupTest } from "rivetkit/test";
import { app } from "../actors/app";
import { app } from "../src/workers/app";

test("it should count", async (test) => {
const { client } = await setupTest(test, app);
Expand Down
3 changes: 2 additions & 1 deletion examples/linear-coding-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "concurrently --raw \"yarn dev:actors\" \"yarn dev:server\" \"yarn dev:ngrok\"",
"dev:actors": "npx rivetkit/cli@latest dev src/actors/app.ts",
"dev:actors": "npx rivetkit/cli@latest dev src/workers/app.ts",
"dev:server": "tsx --watch src/server/index.ts",
"dev:ngrok": "ngrok http 3000",
"check-types": "tsc --noEmit"
Expand All @@ -27,6 +27,7 @@
"@hono/node-server": "^1.14.1",
"@linear/sdk": "^7.0.0",
"@octokit/rest": "^19.0.13",
"@rivetkit/nodejs": "workspace:*",
"ai": "^4.3.9",
"body-parser": "^2.2.0",
"dotenv": "^16.5.0",
Expand Down
4 changes: 4 additions & 0 deletions examples/linear-coding-agent/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { serve } from "@rivetkit/nodejs";
import { app } from "./workers/app";

serve(app);
4 changes: 2 additions & 2 deletions examples/linear-coding-agent/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Hono } from "hono";
import { serve } from "@hono/node-server";
import dotenv from "dotenv";
import { createClient } from "rivetkit/client";
import { app } from "../actors/app";
import type { App } from "../actors/app";
import { app } from "../workers/app";
import type { App } from "../workers/app";
import type { LinearWebhookEvent } from "../types";

// Load environment variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dotenv.config();

// Create and export the app
export const app = setup({
actors: { codingAgent },
workers: { codingAgent },
});

// Export type for client type checking
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ActionContextOf, type ActorContextOf, actor } from "rivetkit";
import { type ActionContextOf, type WorkerContextOf, worker } from "rivetkit";
import type {
CodingAgentState,
CodingAgentVars,
Expand All @@ -20,7 +20,7 @@ import {
} from "./linear";

export type Ctx =
| ActorContextOf<typeof codingAgent>
| WorkerContextOf<typeof codingAgent>
| ActionContextOf<typeof codingAgent>;

/**
Expand Down Expand Up @@ -353,7 +353,7 @@ function enqueueRequest(c: Ctx, type: RequestType, data: LinearWebhookEvent): st
}
}

export const codingAgent = actor({
export const codingAgent = worker({
// Initialize state
state: {
// Linear issue information
Expand Down
3 changes: 2 additions & 1 deletion examples/resend-streaks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"scripts": {
"dev": "npx rivetkit/cli@latest dev actors/app.ts",
"dev": "tsx src/server.ts",
"check-types": "tsc --noEmit",
"test": "vitest run"
},
Expand All @@ -17,6 +17,7 @@
},
"dependencies": {
"@date-fns/tz": "^1.2.0",
"@rivetkit/nodejs": "workspace:*",
"date-fns": "^4.1.0",
"resend": "^2.0.0"
},
Expand Down
4 changes: 4 additions & 0 deletions examples/resend-streaks/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { serve } from "@rivetkit/nodejs";
import { app } from "./workers/app";

serve(app);
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TZDate } from "@date-fns/tz";
import { UserError, actor, setup } from "rivetkit";
import { UserError, worker, setup } from "rivetkit";
import { addDays, set } from "date-fns";
import { Resend } from "resend";

const user = actor({
const user = worker({
state: {
email: null as string | null,
timeZone: "UTC",
Expand Down Expand Up @@ -105,7 +105,7 @@ function isSameDay(a: TZDate, b: TZDate) {
}

export const app = setup({
actors: { user },
workers: { user },
});

export type App = typeof app;
2 changes: 1 addition & 1 deletion examples/resend-streaks/tests/user.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect, vi, beforeEach } from "vitest";
import { setupTest } from "rivetkit/test";
import { app } from "../actors/app";
import { app } from "../src/workers/app";

// Create mock for send method
const mockSendEmail = vi.fn().mockResolvedValue({ success: true });
Expand Down
11 changes: 3 additions & 8 deletions packages/core/fixtures/driver-test-suite/action-inputs.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { worker, setup } from "rivetkit";
import { worker } from "rivetkit";

interface State {
export interface State {
initialInput?: unknown;
onCreateInput?: unknown;
}

// Test worker that can capture input during creation
const inputWorker = worker({
export const inputWorker = worker({
createState: (c, { input }): State => {
return {
initialInput: input,
Expand All @@ -28,8 +28,3 @@ const inputWorker = worker({
},
});

export const app = setup({
workers: { inputWorker },
});

export type App = typeof app;
20 changes: 5 additions & 15 deletions packages/core/fixtures/driver-test-suite/action-timeout.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { worker, setup } from "rivetkit";
import { worker } from "rivetkit";

// Short timeout worker
const shortTimeoutWorker = worker({
export const shortTimeoutWorker = worker({
state: { value: 0 },
options: {
action: {
Expand All @@ -21,7 +21,7 @@ const shortTimeoutWorker = worker({
});

// Long timeout worker
const longTimeoutWorker = worker({
export const longTimeoutWorker = worker({
state: { value: 0 },
options: {
action: {
Expand All @@ -38,7 +38,7 @@ const longTimeoutWorker = worker({
});

// Default timeout worker
const defaultTimeoutWorker = worker({
export const defaultTimeoutWorker = worker({
state: { value: 0 },
actions: {
normalAction: async (c) => {
Expand All @@ -49,7 +49,7 @@ const defaultTimeoutWorker = worker({
});

// Sync worker (timeout shouldn't apply)
const syncWorker = worker({
export const syncTimeoutWorker = worker({
state: { value: 0 },
options: {
action: {
Expand All @@ -63,14 +63,4 @@ const syncWorker = worker({
},
});

export const app = setup({
workers: {
shortTimeoutWorker,
longTimeoutWorker,
defaultTimeoutWorker,
syncWorker,
},
});

export type App = typeof app;

17 changes: 4 additions & 13 deletions packages/core/fixtures/driver-test-suite/action-types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { worker, setup, UserError } from "rivetkit";
import { worker, UserError } from "rivetkit";

// Worker with synchronous actions
const syncWorker = worker({
export const syncActionWorker = worker({
state: { value: 0 },
actions: {
// Simple synchronous action that returns a value directly
Expand All @@ -24,7 +24,7 @@ const syncWorker = worker({
});

// Worker with asynchronous actions
const asyncWorker = worker({
export const asyncActionWorker = worker({
state: { value: 0, data: null as any },
actions: {
// Async action with a delay
Expand Down Expand Up @@ -56,7 +56,7 @@ const asyncWorker = worker({
});

// Worker with promise actions
const promiseWorker = worker({
export const promiseWorker = worker({
state: { results: [] as string[] },
actions: {
// Action that returns a resolved promise
Expand All @@ -81,12 +81,3 @@ const promiseWorker = worker({
},
});

export const app = setup({
workers: {
syncWorker,
asyncWorker,
promiseWorker,
},
});

export type App = typeof app;
Loading
Loading