diff --git a/vendor/integrations/docs/content/docs/flue.mdx b/vendor/integrations/docs/content/docs/flue.mdx index 48f857a7..4e92a2ba 100644 --- a/vendor/integrations/docs/content/docs/flue.mdx +++ b/vendor/integrations/docs/content/docs/flue.mdx @@ -48,7 +48,7 @@ npx flue init --target node ```sh -npm add @rivet-dev/flue @rivet-dev/agentos @rivet-dev/agentos-flue rivetkit@next +npm add @rivet-dev/flue @rivet-dev/agentos @rivet-dev/agentos-flue rivetkit ``` - `@rivet-dev/labs-flue-*`: Rivet-maintained preview builds of Flue's proposed extension APIs. diff --git a/vendor/integrations/docs/content/docs/turso.mdx b/vendor/integrations/docs/content/docs/turso.mdx index 54045a29..f38f4ce4 100644 --- a/vendor/integrations/docs/content/docs/turso.mdx +++ b/vendor/integrations/docs/content/docs/turso.mdx @@ -56,7 +56,16 @@ npm install rivetkit @libsql/client @tursodatabase/api Create `.env` with your organization slug and token: - +```sh title=".env" +# Your Turso organization slug from `turso org list`. +TURSO_ORG= + +# Platform API token from `turso auth api-tokens mint rivet-todos`. +TURSO_PLATFORM_TOKEN= + +# Group to create each actor's database in. Defaults to "default". +# TURSO_GROUP=default +``` @@ -118,12 +127,6 @@ The Platform API token can create and delete every database in its organization, `createVars` must finish within `createVarsTimeout`, which defaults to 5 seconds. Its first query opens the connection to Turso, so a node far from the database's region spends part of that budget on the round trip. Raise `options.createVarsTimeout` if starts time out. See [Options](/actors/docs/lifecycle#options). -## Testing - -The test creates real Turso databases, so it reads the same environment variables and is skipped without them. It checks that each list gets its own database and that destroying a list deletes it: - - - See the [Turso Platform API](https://docs.turso.tech/api-reference/introduction) and [TypeScript reference](https://docs.turso.tech/sdk/ts/reference) for the full APIs. ## Local disk diff --git a/vendor/integrations/docs/content/docs/vercel-eve.mdx b/vendor/integrations/docs/content/docs/vercel-eve.mdx index 8a77b3b1..3f683841 100644 --- a/vendor/integrations/docs/content/docs/vercel-eve.mdx +++ b/vendor/integrations/docs/content/docs/vercel-eve.mdx @@ -38,7 +38,7 @@ cd my-agent ```sh -npm add @rivet-dev/agentos @rivet-dev/agentos-eve @rivet-dev/workflow-world@next +npm add @rivet-dev/agentos @rivet-dev/agentos-eve @rivet-dev/workflow-world ``` - `@rivet-dev/agentos`: Provides the agentOS VM. diff --git a/vendor/integrations/docs/content/docs/workflow-sdk.mdx b/vendor/integrations/docs/content/docs/workflow-sdk.mdx index 605a889b..5a8b6abb 100644 --- a/vendor/integrations/docs/content/docs/workflow-sdk.mdx +++ b/vendor/integrations/docs/content/docs/workflow-sdk.mdx @@ -29,7 +29,7 @@ Start, and Vite. ```sh -npm install workflow @rivet-dev/workflow-world@next +npm install workflow @rivet-dev/workflow-world ``` @@ -141,7 +141,13 @@ npm test Select the World and point it at your own HTTP server: - +```sh title=".env" +WORKFLOW_TARGET_WORLD=@rivet-dev/workflow-world +WORKFLOW_RUNTIME_URL=http://127.0.0.1:3000 + +# The Rivet connection uses the standard RivetKit environment variables. Local +# development needs none of them. +``` | Variable | Required | Purpose | | --- | --- | --- | @@ -169,7 +175,7 @@ rejects requests without it. ## Deploying -Deploy the app as a Rivet node like any other. See [Deploy nodes](/docs/deploy/self-host/nodes/). +Deploy the app as a Rivet node like any other. See [Deploy nodes](/docs/deploy/self-host/workers/). Two constraints come from this World specifically: - **The process must be long-lived.** The first World operation opens a @@ -198,9 +204,41 @@ SDK. ## Testing - +```ts title="vitest.integration.config.ts" +import { workflow } from "@workflow/vitest"; +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + plugins: [workflow()], + test: { + include: ["workflows/**/*.integration.test.ts"], + setupFiles: ["./vitest.setup.ts"], + testTimeout: 60_000, + }, +}); +``` + +```ts title="workflows/order.integration.test.ts" +import { waitForSleep } from "@workflow/vitest"; +import { expect, test } from "vitest"; +import { getRun, start } from "workflow/api"; - +import { processOrder } from "./order.ts"; + +test("runs the workflow end to end", async () => { + const run = await start(processOrder, ["42"]); + const sleepId = await waitForSleep(run); + + await getRun(run.runId).wakeUp({ correlationIds: [sleepId] }); + + await expect(run.returnValue).resolves.toEqual({ + id: "42", + reservationId: "reservation-42", + status: "charged", + }); + expect(await run.status).toBe("completed"); +}); +``` `waitForSleep` observes the durable sleep, `wakeUp` resumes that exact correlation, and the assertions wait for the final persisted result. diff --git a/vendor/integrations/examples/docs/actors-quickstart-next-js/app/page.tsx b/vendor/integrations/examples/docs/actors-quickstart-next-js/app/page.tsx deleted file mode 100644 index a0c8ade1..00000000 --- a/vendor/integrations/examples/docs/actors-quickstart-next-js/app/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { Counter } from "../rivet/Counter"; - -export default function Home() { - return ; -} diff --git a/vendor/integrations/examples/docs/actors-quickstart-next-js/rivet/Counter.tsx b/vendor/integrations/examples/docs/actors-quickstart-next-js/rivet/Counter.tsx deleted file mode 100644 index f13b0c67..00000000 --- a/vendor/integrations/examples/docs/actors-quickstart-next-js/rivet/Counter.tsx +++ /dev/null @@ -1,23 +0,0 @@ -"use client"; - -import { createRivetKit } from "@rivetkit/next-js/client"; -import { useState } from "react"; -import type { registry } from "./registry"; - -const { useActor } = createRivetKit({ - endpoint: process.env.NEXT_PUBLIC_RIVET_ENDPOINT ?? "http://localhost:6420", -}); - -export function Counter() { - const [count, setCount] = useState(0); - const counter = useActor({ name: "counter", key: ["my-counter"] }); - - counter.useEvent("newCount", (value: number) => setCount(value)); - - return ( -
-

Count: {count}

- -
- ); -} diff --git a/vendor/integrations/examples/docs/actors-quickstart-next-js/rivet/node.ts b/vendor/integrations/examples/docs/actors-quickstart-next-js/rivet/node.ts deleted file mode 100644 index aa0ee6ed..00000000 --- a/vendor/integrations/examples/docs/actors-quickstart-next-js/rivet/node.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { registry } from "./registry"; - -registry.start(); diff --git a/vendor/integrations/examples/docs/actors-quickstart-next-js/rivet/registry.ts b/vendor/integrations/examples/docs/actors-quickstart-next-js/rivet/registry.ts deleted file mode 100644 index 4afe732a..00000000 --- a/vendor/integrations/examples/docs/actors-quickstart-next-js/rivet/registry.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { actor, setup } from "rivetkit"; - -export const counter = actor({ - state: { count: 0 }, - actions: { - increment: (c, x: number) => { - c.state.count += x; - c.broadcast("newCount", c.state.count); - return c.state.count; - }, - }, -}); - -export const registry = setup({ - use: { counter }, -}); diff --git a/vendor/integrations/examples/docs/actors-quickstart-react/index.ts b/vendor/integrations/examples/docs/actors-quickstart-react/backend/index.ts similarity index 100% rename from vendor/integrations/examples/docs/actors-quickstart-react/index.ts rename to vendor/integrations/examples/docs/actors-quickstart-react/backend/index.ts diff --git a/vendor/integrations/examples/docs/actors-quickstart-react/Counter.tsx b/vendor/integrations/examples/docs/actors-quickstart-react/frontend/Counter.tsx similarity index 85% rename from vendor/integrations/examples/docs/actors-quickstart-react/Counter.tsx rename to vendor/integrations/examples/docs/actors-quickstart-react/frontend/Counter.tsx index a62ee024..26aa5be7 100644 --- a/vendor/integrations/examples/docs/actors-quickstart-react/Counter.tsx +++ b/vendor/integrations/examples/docs/actors-quickstart-react/frontend/Counter.tsx @@ -1,16 +1,16 @@ import { createRivetKit } from "@rivetkit/react"; import { useState } from "react"; -import type { registry } from "./index"; +import type { registry } from "../backend/index"; const { useActor } = createRivetKit("http://localhost:6420"); -function Counter() { +export function Counter() { const [count, setCount] = useState(0); // Get or create a counter actor for the key "my-counter" const counter = useActor({ name: "counter", - key: ["my-counter"] + key: ["my-counter"], }); // Listen to realtime events diff --git a/vendor/integrations/examples/docs/actors-quickstart-react/frontend/main.tsx b/vendor/integrations/examples/docs/actors-quickstart-react/frontend/main.tsx new file mode 100644 index 00000000..a8e4ea9d --- /dev/null +++ b/vendor/integrations/examples/docs/actors-quickstart-react/frontend/main.tsx @@ -0,0 +1,9 @@ +import { StrictMode } from "react"; +import { createRoot } from "react-dom/client"; +import { Counter } from "./Counter"; + +createRoot(document.getElementById("root")!).render( + + + , +); diff --git a/vendor/integrations/examples/docs/actors-versions/programmatic-version.ts b/vendor/integrations/examples/docs/actors-versions/programmatic-version.ts deleted file mode 100644 index 9763d971..00000000 --- a/vendor/integrations/examples/docs/actors-versions/programmatic-version.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { actor, setup } from "rivetkit"; - -const myActor = actor({ state: {}, actions: {} }); - -const registry = setup({ - use: { myActor }, - envoy: { - version: 2, - }, -}); diff --git a/vendor/integrations/examples/docs/api/inspector-action.ts b/vendor/integrations/examples/docs/api/inspector-action.ts deleted file mode 100644 index 78a79d4a..00000000 --- a/vendor/integrations/examples/docs/api/inspector-action.ts +++ /dev/null @@ -1,14 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/action/increment`, - { - method: "POST", - headers: { - Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}`, - "Content-Type": "application/json", - }, - body: JSON.stringify({ args: [1] }), - }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-connections.ts b/vendor/integrations/examples/docs/api/inspector-connections.ts deleted file mode 100644 index e9bb0ade..00000000 --- a/vendor/integrations/examples/docs/api/inspector-connections.ts +++ /dev/null @@ -1,7 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/connections`, - { headers: { Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}` } }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-database-execute.ts b/vendor/integrations/examples/docs/api/inspector-database-execute.ts deleted file mode 100644 index d657c202..00000000 --- a/vendor/integrations/examples/docs/api/inspector-database-execute.ts +++ /dev/null @@ -1,17 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/database/execute`, - { - method: "POST", - headers: { - Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}`, - "Content-Type": "application/json", - }, - body: JSON.stringify({ - sql: "SELECT * FROM users WHERE id = ?", - args: ["user-123"], - }), - }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-database-rows.ts b/vendor/integrations/examples/docs/api/inspector-database-rows.ts deleted file mode 100644 index 060781c7..00000000 --- a/vendor/integrations/examples/docs/api/inspector-database-rows.ts +++ /dev/null @@ -1,12 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const query = new URLSearchParams({ - table: "users", - limit: "100", - offset: "0", -}); -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/database/rows?${query}`, - { headers: { Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}` } }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-database-schema.ts b/vendor/integrations/examples/docs/api/inspector-database-schema.ts deleted file mode 100644 index b95bd360..00000000 --- a/vendor/integrations/examples/docs/api/inspector-database-schema.ts +++ /dev/null @@ -1,7 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/database/schema`, - { headers: { Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}` } }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-queue-delete.ts b/vendor/integrations/examples/docs/api/inspector-queue-delete.ts deleted file mode 100644 index 0786860a..00000000 --- a/vendor/integrations/examples/docs/api/inspector-queue-delete.ts +++ /dev/null @@ -1,10 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/queue`, - { - method: "DELETE", - headers: { Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}` }, - }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-queue-get.ts b/vendor/integrations/examples/docs/api/inspector-queue-get.ts deleted file mode 100644 index 82528552..00000000 --- a/vendor/integrations/examples/docs/api/inspector-queue-get.ts +++ /dev/null @@ -1,7 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/queue?limit=50`, - { headers: { Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}` } }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-queue-post.ts b/vendor/integrations/examples/docs/api/inspector-queue-post.ts deleted file mode 100644 index 9a5d80ad..00000000 --- a/vendor/integrations/examples/docs/api/inspector-queue-post.ts +++ /dev/null @@ -1,14 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/queue`, - { - method: "POST", - headers: { - Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}`, - "Content-Type": "application/json", - }, - body: JSON.stringify({ name: "increment", body: { amount: 1 } }), - }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-rpcs.ts b/vendor/integrations/examples/docs/api/inspector-rpcs.ts deleted file mode 100644 index 4f9f0c7c..00000000 --- a/vendor/integrations/examples/docs/api/inspector-rpcs.ts +++ /dev/null @@ -1,7 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/rpcs`, - { headers: { Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}` } }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-state-get.ts b/vendor/integrations/examples/docs/api/inspector-state-get.ts deleted file mode 100644 index 53eacb7e..00000000 --- a/vendor/integrations/examples/docs/api/inspector-state-get.ts +++ /dev/null @@ -1,7 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/state`, - { headers: { Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}` } }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-state-patch.ts b/vendor/integrations/examples/docs/api/inspector-state-patch.ts deleted file mode 100644 index bcdf52c1..00000000 --- a/vendor/integrations/examples/docs/api/inspector-state-patch.ts +++ /dev/null @@ -1,14 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/state`, - { - method: "PATCH", - headers: { - Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}`, - "Content-Type": "application/json", - }, - body: JSON.stringify({ state: { count: 2 } }), - }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-summary.ts b/vendor/integrations/examples/docs/api/inspector-summary.ts deleted file mode 100644 index 5ddc54d9..00000000 --- a/vendor/integrations/examples/docs/api/inspector-summary.ts +++ /dev/null @@ -1,7 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/summary`, - { headers: { Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}` } }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-traces.ts b/vendor/integrations/examples/docs/api/inspector-traces.ts deleted file mode 100644 index c9fc7ca1..00000000 --- a/vendor/integrations/examples/docs/api/inspector-traces.ts +++ /dev/null @@ -1,7 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/traces?startMs=0&limit=100`, - { headers: { Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}` } }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-workflow-history.ts b/vendor/integrations/examples/docs/api/inspector-workflow-history.ts deleted file mode 100644 index 0e1ed297..00000000 --- a/vendor/integrations/examples/docs/api/inspector-workflow-history.ts +++ /dev/null @@ -1,7 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/workflow-history`, - { headers: { Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}` } }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/inspector-workflow-replay.ts b/vendor/integrations/examples/docs/api/inspector-workflow-replay.ts deleted file mode 100644 index 23736edb..00000000 --- a/vendor/integrations/examples/docs/api/inspector-workflow-replay.ts +++ /dev/null @@ -1,14 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const response = await fetch( - `${endpoint}/gateway/${process.env.ACTOR_ID}/inspector/workflow/replay`, - { - method: "POST", - headers: { - Authorization: `Bearer ${process.env.INSPECTOR_TOKEN}`, - "Content-Type": "application/json", - }, - body: JSON.stringify({ entryId: "entry-123" }), - }, -); -console.log(await response.json()); -export {}; diff --git a/vendor/integrations/examples/docs/api/workers-configs-delete.ts b/vendor/integrations/examples/docs/api/pools-delete.ts similarity index 51% rename from vendor/integrations/examples/docs/api/workers-configs-delete.ts rename to vendor/integrations/examples/docs/api/pools-delete.ts index f830246e..ad9c5134 100644 --- a/vendor/integrations/examples/docs/api/workers-configs-delete.ts +++ b/vendor/integrations/examples/docs/api/pools-delete.ts @@ -1,13 +1,16 @@ const endpoint = "https://api.rivet.dev"; const namespace = process.env.RIVET_NAMESPACE ?? "default"; const token = process.env.RIVET_TOKEN ?? ""; -const workerName = process.env.RUNNER_NAME ?? "default"; +const pool = process.env.RIVET_POOL ?? "default"; const params = new URLSearchParams({ namespace }); const response = await fetch( - `${endpoint}/runner-configs/${encodeURIComponent(workerName)}?${params}`, - { method: "DELETE", headers: { Authorization: `Bearer ${token}` } }, + `${endpoint}/pools/${encodeURIComponent(pool)}?${params}`, + { + method: "DELETE", + headers: { Authorization: `Bearer ${token}` }, + }, ); -console.log(response.ok); +console.log(response.status); export {}; diff --git a/vendor/integrations/examples/docs/api/pools-get.ts b/vendor/integrations/examples/docs/api/pools-get.ts new file mode 100644 index 00000000..852a5f71 --- /dev/null +++ b/vendor/integrations/examples/docs/api/pools-get.ts @@ -0,0 +1,13 @@ +const endpoint = "https://api.rivet.dev"; +const namespace = process.env.RIVET_NAMESPACE ?? "default"; +const token = process.env.RIVET_TOKEN ?? ""; +const pool = process.env.RIVET_POOL ?? "default"; + +const params = new URLSearchParams({ namespace }); +const response = await fetch( + `${endpoint}/pools/${encodeURIComponent(pool)}?${params}`, + { headers: { Authorization: `Bearer ${token}` } }, +); +console.log(await response.json()); + +export {}; diff --git a/vendor/integrations/examples/docs/api/pools-list-nodes.ts b/vendor/integrations/examples/docs/api/pools-list-nodes.ts new file mode 100644 index 00000000..b55c107f --- /dev/null +++ b/vendor/integrations/examples/docs/api/pools-list-nodes.ts @@ -0,0 +1,14 @@ +const endpoint = "https://api.rivet.dev"; +const namespace = process.env.RIVET_NAMESPACE ?? "default"; +const token = process.env.RIVET_TOKEN ?? ""; +const pool = process.env.RIVET_POOL ?? "default"; + +const params = new URLSearchParams({ namespace }); +const response = await fetch( + `${endpoint}/pools/${encodeURIComponent(pool)}/nodes?${params}`, + { headers: { Authorization: `Bearer ${token}` } }, +); +const { nodes, pagination } = await response.json(); +console.log(nodes, pagination.cursor); + +export {}; diff --git a/vendor/integrations/examples/docs/api/workers-configs-list.ts b/vendor/integrations/examples/docs/api/pools-list.ts similarity index 63% rename from vendor/integrations/examples/docs/api/workers-configs-list.ts rename to vendor/integrations/examples/docs/api/pools-list.ts index 8f13f84f..eac08588 100644 --- a/vendor/integrations/examples/docs/api/workers-configs-list.ts +++ b/vendor/integrations/examples/docs/api/pools-list.ts @@ -3,10 +3,10 @@ const namespace = process.env.RIVET_NAMESPACE ?? "default"; const token = process.env.RIVET_TOKEN ?? ""; const params = new URLSearchParams({ namespace }); -const response = await fetch(`${endpoint}/runner-configs?${params}`, { +const response = await fetch(`${endpoint}/pools?${params}`, { headers: { Authorization: `Bearer ${token}` }, }); -const { runner_configs } = await response.json(); -console.log(runner_configs); +const { pools, pagination } = await response.json(); +console.log(pools, pagination.cursor); export {}; diff --git a/vendor/integrations/examples/docs/api/workers-configs-upsert.ts b/vendor/integrations/examples/docs/api/pools-upsert.ts similarity index 66% rename from vendor/integrations/examples/docs/api/workers-configs-upsert.ts rename to vendor/integrations/examples/docs/api/pools-upsert.ts index f46c7f76..0097c1c7 100644 --- a/vendor/integrations/examples/docs/api/workers-configs-upsert.ts +++ b/vendor/integrations/examples/docs/api/pools-upsert.ts @@ -1,18 +1,18 @@ const endpoint = "https://api.rivet.dev"; const namespace = process.env.RIVET_NAMESPACE ?? "default"; const token = process.env.RIVET_TOKEN ?? ""; -const workerName = process.env.RUNNER_NAME ?? "default"; +const pool = process.env.RIVET_POOL ?? "default"; const params = new URLSearchParams({ namespace }); const response = await fetch( - `${endpoint}/runner-configs/${encodeURIComponent(workerName)}?${params}`, + `${endpoint}/pools/${encodeURIComponent(pool)}?${params}`, { method: "PUT", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", }, - body: JSON.stringify({ datacenters: { local: { normal: {} } } }), + body: JSON.stringify({ drain_on_version_upgrade: true }), }, ); console.log(await response.json()); diff --git a/vendor/integrations/examples/docs/api/workers-list.ts b/vendor/integrations/examples/docs/api/workers-list.ts deleted file mode 100644 index 7d627ad4..00000000 --- a/vendor/integrations/examples/docs/api/workers-list.ts +++ /dev/null @@ -1,12 +0,0 @@ -const endpoint = "https://api.rivet.dev"; -const namespace = process.env.RIVET_NAMESPACE ?? "default"; -const token = process.env.RIVET_TOKEN ?? ""; - -const params = new URLSearchParams({ namespace }); -const response = await fetch(`${endpoint}/envoys?${params}`, { - headers: { Authorization: `Bearer ${token}` }, -}); -const { envoys: workers, pagination } = await response.json(); -console.log(workers, pagination.cursor); - -export {}; diff --git a/vendor/integrations/examples/docs/durable-streams/client.ts b/vendor/integrations/examples/docs/durable-streams/client.ts new file mode 100644 index 00000000..97fdedf0 --- /dev/null +++ b/vendor/integrations/examples/docs/durable-streams/client.ts @@ -0,0 +1,14 @@ +import { DurableStream } from "@durable-streams/client"; + +const stream = await DurableStream.create({ + url: "http://127.0.0.1:8642/durable-streams/v1/stream/demo", + contentType: "application/json", +}); + +await stream.append(JSON.stringify({ message: "hello" })); + +// Read from the beginning, then keep receiving new messages live +const res = await stream.stream<{ message: string }>(); +res.subscribeJson(async (batch) => { + for (const item of batch.items) console.log(item.message); +}); diff --git a/vendor/integrations/examples/docs/durable-streams/create.ts b/vendor/integrations/examples/docs/durable-streams/create.ts new file mode 100644 index 00000000..582ec8f2 --- /dev/null +++ b/vendor/integrations/examples/docs/durable-streams/create.ts @@ -0,0 +1,11 @@ +import { DurableStream } from "@durable-streams/client"; + +// One stream per chat session +const stream = await DurableStream.create({ + url: "http://127.0.0.1:8642/durable-streams/v1/stream/chat/session-1", + contentType: "application/json", + // Delete the stream after a day with no reads or writes + ttlSeconds: 86400, +}); + +console.log("created", stream.url); diff --git a/vendor/integrations/examples/docs/durable-streams/producer.ts b/vendor/integrations/examples/docs/durable-streams/producer.ts new file mode 100644 index 00000000..eb2f8a16 --- /dev/null +++ b/vendor/integrations/examples/docs/durable-streams/producer.ts @@ -0,0 +1,21 @@ +import { DurableStream, IdempotentProducer } from "@durable-streams/client"; + +const stream = new DurableStream({ + url: "http://127.0.0.1:8642/durable-streams/v1/stream/chat/session-1", + contentType: "application/json", +}); + +// Keep the producer ID the same across restarts. With autoClaim, a restarted +// agent takes over and the old one can no longer write. +const producer = new IdempotentProducer(stream, "agent-session-1", { + autoClaim: true, + onError: (error) => console.error("append failed", error), +}); + +for (const token of ["It's", " sunny", " today"]) { + producer.append(JSON.stringify({ token })); +} + +// Wait until every token is stored, then close the stream +await producer.flush(); +await producer.close(); diff --git a/vendor/integrations/examples/docs/durable-streams/read-history.ts b/vendor/integrations/examples/docs/durable-streams/read-history.ts new file mode 100644 index 00000000..457570d7 --- /dev/null +++ b/vendor/integrations/examples/docs/durable-streams/read-history.ts @@ -0,0 +1,10 @@ +import { stream } from "@durable-streams/client"; + +const url = "http://127.0.0.1:8642/durable-streams/v1/stream/chat/session-1"; + +// Everything written so far, then stop +const res = await stream<{ token: string }>({ url, offset: "-1", live: false }); +const messages = await res.json(); + +console.log(messages); +console.log("read from here next:", res.offset); diff --git a/vendor/integrations/examples/docs/durable-streams/read-live.ts b/vendor/integrations/examples/docs/durable-streams/read-live.ts new file mode 100644 index 00000000..362854f3 --- /dev/null +++ b/vendor/integrations/examples/docs/durable-streams/read-live.ts @@ -0,0 +1,14 @@ +import { stream } from "@durable-streams/client"; + +const url = "http://127.0.0.1:8642/durable-streams/v1/stream/chat/session-1"; + +// "-1" starts at the beginning. Pass a saved offset to pick up where you left off. +const savedOffset: string = "-1"; + +const res = await stream<{ token: string }>({ url, offset: savedOffset, live: "sse" }); +res.subscribeJson(async (batch) => { + for (const item of batch.items) console.log(item.token); + + // Save this to resume from the same place after a refresh + console.log("offset", batch.offset); +}); diff --git a/vendor/integrations/examples/docs/durable-streams/write.ts b/vendor/integrations/examples/docs/durable-streams/write.ts new file mode 100644 index 00000000..c68ab7ce --- /dev/null +++ b/vendor/integrations/examples/docs/durable-streams/write.ts @@ -0,0 +1,13 @@ +import { DurableStream } from "@durable-streams/client"; + +const stream = new DurableStream({ + url: "http://127.0.0.1:8642/durable-streams/v1/stream/chat/session-1", + contentType: "application/json", +}); + +// Each append is one message +await stream.append(JSON.stringify({ token: "It's" })); +await stream.append(JSON.stringify({ token: " sunny" })); + +// Close with a final message: readers know the reply is complete +await stream.close({ body: JSON.stringify({ token: "." }) }); diff --git a/vendor/integrations/examples/docs/general-edge/client.ts b/vendor/integrations/examples/docs/general-edge/client.ts new file mode 100644 index 00000000..fde898f5 --- /dev/null +++ b/vendor/integrations/examples/docs/general-edge/client.ts @@ -0,0 +1,12 @@ +import { createClient } from "rivetkit/client"; +import { actor, setup } from "rivetkit"; + +const example = actor({ state: {}, actions: {} }); +const registry = setup({ use: { example } }); + +const client = createClient("http://localhost:6420"); + +// Create actor in a specific region using getOrCreate +const actorHandle = client.example.getOrCreate(["my-actor"], { + createInRegion: "atl" +}); diff --git a/vendor/integrations/examples/docs/onboarding-actors/client.ts b/vendor/integrations/examples/docs/onboarding-actors/client.ts new file mode 100644 index 00000000..307c6365 --- /dev/null +++ b/vendor/integrations/examples/docs/onboarding-actors/client.ts @@ -0,0 +1,20 @@ +import { createClient } from "rivetkit/client"; +import type { registry } from "./index"; + +// Connect to the server from index.ts. The registry type checks every call. +const client = createClient("http://localhost:6420"); + +// Get the room keyed "general", creating it on first use. +const room = client.chatRoom.getOrCreate(["general"]); + +// Open a realtime connection and print each message as it arrives. +const connection = room.connect(); +connection.on("newMessage", (message: { sender: string; text: string }) => { + console.log(`${message.sender}: ${message.text}`); +}); + +// Send a message. The Actor saves it to SQLite before broadcasting it. +await connection.sendMessage("alice", "Hello, Rivet!"); + +// The history is still there after the Actor sleeps or restarts. +console.log(await room.getHistory()); diff --git a/vendor/integrations/examples/docs/onboarding-actors/index.ts b/vendor/integrations/examples/docs/onboarding-actors/index.ts new file mode 100644 index 00000000..0cf38744 --- /dev/null +++ b/vendor/integrations/examples/docs/onboarding-actors/index.ts @@ -0,0 +1,43 @@ +import { actor, setup } from "rivetkit"; +import { db } from "rivetkit/db"; + +// A chat room Actor. Every room key gets its own instance with its own SQLite +// database, which survives restarts and redeploys. +export const chatRoom = actor({ + // Create the messages table the first time a room starts. + db: db({ + onMigrate: async (db) => { + await db.execute(` + CREATE TABLE IF NOT EXISTS messages ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + sender TEXT NOT NULL, + text TEXT NOT NULL + ) + `); + }, + }), + + actions: { + // Save a message, then push it to everyone connected to this room. + sendMessage: async (c, sender: string, text: string) => { + await c.db.execute( + "INSERT INTO messages (sender, text) VALUES (?, ?)", + sender, + text, + ); + + c.broadcast("newMessage", { sender, text }); + }, + + // Read the room's history, oldest first. + getHistory: async (c) => { + return (await c.db.execute( + "SELECT sender, text FROM messages ORDER BY id", + )) as { sender: string; text: string }[]; + }, + }, +}); + +// Register the Actor and start serving it on http://localhost:6420. +export const registry = setup({ use: { chatRoom } }); +registry.start(); diff --git a/vendor/integrations/examples/docs/package.json b/vendor/integrations/examples/docs/package.json index a0e98db3..3ddcea78 100644 --- a/vendor/integrations/examples/docs/package.json +++ b/vendor/integrations/examples/docs/package.json @@ -1,4 +1,5 @@ { + "license": "MIT", "name": "docs-snippets", "version": "2.0.21", "private": true, @@ -11,10 +12,7 @@ "rivetkit": "workspace:*", "@rivetkit/react": "workspace:*", "@rivetkit/engine-api-full": "workspace:*", - "@rivetkit/next-js": "workspace:*", - "@rivetkit/cloudflare-workers": "workspace:*", "@rivetkit/rivetkit-wasm": "workspace:*", - "@rivetkit/supabase": "workspace:*", "@rivetkit/effect": "workspace:*", "effect": "4.0.0", "@effect/platform-node": "4.0.0", diff --git a/vendor/integrations/examples/docs/tsconfig.json b/vendor/integrations/examples/docs/tsconfig.json index 498e3a9a..ee88fd1d 100644 --- a/vendor/integrations/examples/docs/tsconfig.json +++ b/vendor/integrations/examples/docs/tsconfig.json @@ -13,5 +13,12 @@ "jsx": "react-jsx" }, "include": ["**/*.ts", "**/*.tsx"], - "exclude": ["node_modules"] + "exclude": [ + "node_modules", + "actors-quickstart-next-js", + "general-http-server/elysia-handler.ts", + "general-http-server/hono-handler.ts", + "general-http-server/serve.ts", + "actors-actions/calling-backend.ts" + ] } diff --git a/vendor/integrations/examples/turso/.env.example b/vendor/integrations/examples/turso/.env.example deleted file mode 100644 index 22904074..00000000 --- a/vendor/integrations/examples/turso/.env.example +++ /dev/null @@ -1,8 +0,0 @@ -# Your Turso organization slug from `turso org list`. -TURSO_ORG= - -# Platform API token from `turso auth api-tokens mint rivet-todos`. -TURSO_PLATFORM_TOKEN= - -# Group to create each actor's database in. Defaults to "default". -# TURSO_GROUP=default diff --git a/vendor/integrations/examples/turso/package.json b/vendor/integrations/examples/turso/package.json index c7770146..46e57102 100644 --- a/vendor/integrations/examples/turso/package.json +++ b/vendor/integrations/examples/turso/package.json @@ -13,7 +13,7 @@ "dependencies": { "@libsql/client": "^0.18.0", "@tursodatabase/api": "^2.0.5", - "rivetkit": "^2.3.31" + "rivetkit": "^3.0.3" }, "devDependencies": { "@types/node": "^22.13.9", @@ -22,8 +22,13 @@ "vitest": "^3.1.1" }, "template": { - "technologies": ["typescript", "turso"], - "tags": ["database"], + "technologies": [ + "typescript", + "turso" + ], + "tags": [ + "database" + ], "noFrontend": true }, "stableVersion": "0.8.0", diff --git a/vendor/integrations/examples/turso/tests/turso.test.ts b/vendor/integrations/examples/turso/tests/turso.test.ts deleted file mode 100644 index b450c548..00000000 --- a/vendor/integrations/examples/turso/tests/turso.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { createClient } from "@tursodatabase/api"; -import { setupTest } from "rivetkit/test"; -import { expect, test, vi } from "vitest"; - -// Each actor creates a real Turso database, so this test needs Turso credentials. -test.skipIf(!process.env.TURSO_PLATFORM_TOKEN)( - "each list gets its own database, deleted with the list", - async (ctx) => { - const { registry, databaseName } = await import("../src/index.ts"); - const { client } = await setupTest(ctx, registry); - const turso = createClient({ - org: process.env.TURSO_ORG as string, - token: process.env.TURSO_PLATFORM_TOKEN as string, - }); - - const groceries = client.todoList.getOrCreate(["groceries"]); - const chores = client.todoList.getOrCreate(["chores"]); - const milk = await groceries.addTodo("Buy milk"); - await groceries.addTodo("Buy eggs"); - await chores.addTodo("Do laundry"); - await groceries.toggleTodo(milk.id); - - // Separate databases, so both lists number their rows from 1. - expect(await groceries.listTodos()).toMatchObject([ - { id: 1, title: "Buy milk", completed: true }, - { id: 2, title: "Buy eggs", completed: false }, - ]); - expect(await chores.listTodos()).toMatchObject([ - { id: 1, title: "Do laundry" }, - ]); - - const groceriesDb = databaseName(await groceries.resolve()); - const choresDb = databaseName(await chores.resolve()); - await expect(turso.databases.get(groceriesDb)).resolves.toBeDefined(); - - await groceries.deleteList(); - await chores.deleteList(); - - // Destroy is asynchronous, so poll until onDestroy has deleted both databases. - await vi.waitFor( - async () => { - const names = (await turso.databases.list()).map( - (db) => db.name, - ); - expect(names).not.toContain(groceriesDb); - expect(names).not.toContain(choresDb); - }, - { timeout: 30_000, interval: 1_000 }, - ); - }, -); diff --git a/vendor/integrations/examples/turso/vitest.config.ts b/vendor/integrations/examples/turso/vitest.config.ts deleted file mode 100644 index 63d4d87d..00000000 --- a/vendor/integrations/examples/turso/vitest.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { defineConfig } from "vitest/config"; - -export default defineConfig({ - test: { - include: ["tests/**/*.test.ts"], - // Creating and deleting Turso databases takes a few seconds. - testTimeout: 60_000, - }, -}); diff --git a/vendor/integrations/examples/workflow-sdk/.env.example b/vendor/integrations/examples/workflow-sdk/.env.example deleted file mode 100644 index 084e37cc..00000000 --- a/vendor/integrations/examples/workflow-sdk/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -WORKFLOW_TARGET_WORLD=@rivet-dev/workflow-world -WORKFLOW_RUNTIME_URL=http://127.0.0.1:3000 - -# The Rivet connection uses the standard RivetKit environment variables. Local -# development needs none of them. diff --git a/vendor/integrations/examples/workflow-sdk/package.json b/vendor/integrations/examples/workflow-sdk/package.json index 9833a95e..f5d3e00c 100644 --- a/vendor/integrations/examples/workflow-sdk/package.json +++ b/vendor/integrations/examples/workflow-sdk/package.json @@ -6,8 +6,7 @@ "scripts": { "build": "nitro build", "check-types": "tsc --noEmit", - "dev": "nitro dev", - "test": "RIVET_RUN_ENGINE_PORT=16420 RIVETKIT_STORAGE_PATH=$PWD/.workflow-data vitest --config vitest.integration.config.ts run" + "dev": "nitro dev" }, "dependencies": { "@rivet-dev/workflow-world": "workspace:*", @@ -18,17 +17,21 @@ }, "devDependencies": { "@types/node": "^24.0.0", - "@workflow/vitest": "5.0.0-beta.35", "typescript": "^5.9.3", - "vite": "^7.0.0", - "vitest": "^4.1.9" + "vite": "^7.0.0" }, "engines": { "node": ">=22.0.0" }, "template": { - "technologies": ["typescript", "workflow-sdk"], - "tags": ["workflow", "durable"], + "technologies": [ + "typescript", + "workflow-sdk" + ], + "tags": [ + "workflow", + "durable" + ], "noFrontend": true, "skipVercel": true }, diff --git a/vendor/integrations/examples/workflow-sdk/vitest.integration.config.ts b/vendor/integrations/examples/workflow-sdk/vitest.integration.config.ts deleted file mode 100644 index a10370c8..00000000 --- a/vendor/integrations/examples/workflow-sdk/vitest.integration.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { workflow } from "@workflow/vitest"; -import { defineConfig } from "vitest/config"; - -export default defineConfig({ - plugins: [workflow()], - test: { - include: ["workflows/**/*.integration.test.ts"], - setupFiles: ["./vitest.setup.ts"], - testTimeout: 60_000, - }, -}); diff --git a/vendor/integrations/examples/workflow-sdk/vitest.setup.ts b/vendor/integrations/examples/workflow-sdk/vitest.setup.ts deleted file mode 100644 index efd68fa8..00000000 --- a/vendor/integrations/examples/workflow-sdk/vitest.setup.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { registry } from "@rivet-dev/workflow-world/registry"; -import { afterAll } from "vitest"; - -registry.config.shutdown = { - disableSignalHandlers: true, - gracePeriodMs: 1_000, -}; -afterAll(async () => { - await registry.shutdown(); -}); diff --git a/vendor/integrations/examples/workflow-sdk/workflows/order.integration.test.ts b/vendor/integrations/examples/workflow-sdk/workflows/order.integration.test.ts deleted file mode 100644 index c7b66904..00000000 --- a/vendor/integrations/examples/workflow-sdk/workflows/order.integration.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { waitForSleep } from "@workflow/vitest"; -import { expect, test } from "vitest"; -import { getRun, start } from "workflow/api"; - -import { processOrder } from "./order.ts"; - -test("runs the workflow end to end", async () => { - const run = await start(processOrder, ["42"]); - const sleepId = await waitForSleep(run); - - await getRun(run.runId).wakeUp({ correlationIds: [sleepId] }); - - await expect(run.returnValue).resolves.toEqual({ - id: "42", - reservationId: "reservation-42", - status: "charged", - }); - expect(await run.status).toBe("completed"); -});