Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

theokit

Latest version: v0.87.0

Overview

Last scanned
23 Nov 2026
Published
23 Nov 2026
npm package Publisher: usetheodev
5 Stars
1 Forks
85 Versions
15.5K Downloads
TypeScript Repo language

Scan summary

theokit was last scanned on 23 Nov 2026 at version 0.87.0. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 85 versions; the latest 5 were published within 2 days (22 and 23 Nov 2026).
  • Findings: No rules fired in version 0.87.0.
  • Downloads: 15,489 downloads.

Versions

85 versions published
Versions and the rules that fired in each
VersionPublishedStatus
0.87.0 LATEST 23 Nov 2026 No rules fired
0.86.1 23 Nov 2026 No rules fired
0.86.0 23 Nov 2026 No rules fired
0.85.2 22 Nov 2026 Not shown
0.85.1 22 Nov 2026 Not shown

No rules fired in 0.87.0

Findings

Findings for v0.87.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.87.0; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

theokit

Build the app your agent lives in. Routing, auth, real-time, deploy — wired.

This is the framework core: the file-based router, the server surfaces, the Vite plugin, the CLI, the deploy adapters and the devtools. The agent pipeline lives in @theokit/agents, the decorator pipeline in @theokit/http, and the runtime in @theokit/sdk — TheoKit compiles and serves; the SDK runs the agent.

Full documentation, examples and the changelog live in the repository.

Install

Scaffold rather than install by hand — the app layout is a convention the framework reads:

npx create-theokit my-app
cd my-app
pnpm dev

Node >= 22.12.0. Peers: react, react-dom, react-router, zod, and — where you use them — @theokit/sdk, @theokit/ui, @theokit/studio, ws, db0, unstorage.

The conventions

Put a file here Get
app/page.tsx the / route (layout · loading · error · not-found beside it)
app/(group)/pricing/page.tsx /pricing — the group organizes without entering the URL
agents/support.ts POST /api/agents/support, bound on the client by useAgent
server/routes/users.ts /api/users, one export per HTTP verb
server/actions/*.ts server actions, with CSRF and validation handled
server/controllers/*.ts @Controller classes
server/ws/chat.ts ws://…/ws/chat
server/middleware/01-cors.ts request middleware, in filename order
next is supported on one of the two paths

A middleware receives (request, context, next). What next does depends on which runner is executing it, and the two differ today:

path next
executeWebRequest — the Web runner runs the rest of the chain and the route, so code after await next() observes the route's response
server/middleware/*.ts — the file-scan runner refuses. It runs BEFORE routing, so there is no downstream to await

The file-scan path throws MiddlewareNextUnavailableError, naming the alternative. It used to accept the call and continue silently, which meant the code after await next() never ran and nothing said so.

This is a real limitation, not a bug being hidden. Closing it means either folding the file-scan path so the chain wraps the route, or retiring this contract for a single one; both are large and the choice is open — docs/adr/0003 § AMENDED 2026-09-21 records what each costs.

Write a server/middleware/*.ts middleware that returns a Response to answer the request, or returns nothing to continue. Use the Web path when you need code to run after the route.

Posting a file to a server action

An action reads multipart/form-data through its Zod schema. objectToFormData (from theokit/client) is the matching encoder: dot paths for nested objects, a repeated key for arrays, 'true'/'false' for booleans.

import { objectToFormData } from 'theokit/client'
import { z } from 'zod'

// server/actions/profile.ts — served at /api/__actions/profile/uploadAvatar
import { action } from 'theokit/server'

export const uploadAvatar = action()
  .input(z.object({ title: z.string(), avatar: z.instanceof(File) }))
  .accept('form')
  .handler(async ({ input }) => ({ name: input.avatar.name }))
  .build()

// browser
const schema = z.object({ title: z.string(), avatar: z.instanceof(File) })

await fetch('/api/__actions/profile/uploadAvatar', {
  method: 'POST',
  headers: { 'X-Theo-Action': '1' }, // required by the default strict CSRF check
  body: objectToFormData({ title: 'Me', avatar: input.files![0] }, schema),
})

An array of objects, or an array of arrays, throws FormDataEncodingError, because the server cannot read it back.

Authoring surfaces

Every surface is a fluent builder whose .build() is a compile error while a required link is missing:

import { route, action, websocket, middleware, tool, plugin } from 'theokit/server'

export const GET = route()
  .policy('public')
  .query(z.object({ search: z.string().optional() }))
  .handler(({ query }) => ({ results: search(query.search) }))
  .build()

Subpaths

Subpath What lives there
. config() and the framework entry
./server The authoring builders plus every server/* capability re-exported
./server/{agent,auth,cost,cron,define,http,jobs,observability,plugins,rate-limit,realtime,scan,security,storage,webhook} The capabilities on their own doors
./client theoFetch, useAgent, Link, Metadata, Image, the transports
./client/core The framework-agnostic client (no React)
./react-query The TanStack Query adapter over theoFetch
./vite-plugin The plugin that makes all of the above work
./testing startTestServer: boot the app as a real process from a test
./boot, ./adapters/web-shim, ./adapters/ws-shim Runtime shims

OIDC discovery

discoverOidcProvider(issuer) from theokit/server/auth fetches and caches a provider's metadata. The issuer and every endpoint it returns (authorization_endpoint, token_endpoint, and userinfo_endpoint, jwks_uri, end_session_endpoint when present) must be https, or http on a loopback host (localhost, [::1], 127.0.0.0/8; never 0.0.0.0). Endpoints need not share the issuer's host. Otherwise it throws OidcInsecureEndpointError (code: 'oidc_insecure_endpoint', with field and url), and the failure is not cached. isSafeOidcUrl(url) applies the same rule.

Serving a hosted chat page

createHostedChat from theokit/server/http mounts a chat page behind one handler, (request) => Promise<Response>:

import { createHostedChat, hashedSessionScope } from 'theokit/server/http'

const chat = createHostedChat({
  route: '/chat',
  assetsDir: new URL('./dist/web/assets/', import.meta.url), // app.js and app.css
  maxBodyBytes: 65_536,
  auth: (request) => (isSignedIn(request) ? { identity: userOf(request) } : new Response(null, { status: 401 })),
  sessionScope: hashedSessionScope,
  createRun: (message, chatId, signal) => runAgent(message, chatId, signal), // an AsyncIterable of stream events
})

It serves GET /chat (the shell, with a CSP), GET /chat/sandbox (the sandboxed widget frame), GET /chat/assets/<name> (only the names in assets) and POST /chat/chat. auth runs before the body is read: return a Response to refuse, or { identity } to let the post in. Past maxBodyBytes the post is 413, a message with no valid chat id is 400, both before createRun is called. sessionScope(identity) prefixes the chat id, so two identities naming one chat id get two sessions. The signal aborts when the client leaves or cancels the stream.

Testing

theokit/testing starts the app's own theokit dev (or theokit start) on a free port and resolves once /__theo/ready answers. No stdout parsing, no npx, no hand-rolled process-group kill.

import { afterAll, beforeAll, expect, it } from 'vitest'
import { startTestServer, type TestServer } from 'theokit/testing'

let server: TestServer
beforeAll(async () => {
  server = await startTestServer({ cwd: process.cwd() }) // mode: 'dev' by default
})
afterAll(async () => {
  await server.close()
})

it('is healthy', async () => {
  expect((await fetch(`${server.origin}/__theo/health`)).status).toBe(200)
})

If the child exits or the deadline (timeoutMs, default 60 s) passes, startTestServer throws TestServerBootError with the child's output. mode: 'start' expects a prior theokit build.

Storage

theo.config.ts > storage declares servers and databases; route code gets a cached client from getStorageManager() in theokit/server/storage, built by a factory you write so the driver stays optional:

import pg from 'pg'
import { getStorageManager } from 'theokit/server/storage'

const pool = getStorageManager().usePostgres('main', (server, db) => {
  const { host, port, user, password } = server
  const p = new pg.Pool({ host, port, user, password, database: db.database })
  p.on('error', (err) => console.warn('[pg] idle client error:', err.message))
  return p
}) as pg.Pool

A pg.Pool emits error when Postgres drops an idle connection (restart, failover, pg_terminate_backend, a proxy timeout), and Node exits on an error event with no listener. If the factory attaches none, usePostgres attaches one that logs a structured warning, so the process stays up and the next query reconnects. Attach your own, as above, to handle it differently.

Jobs

Declare a backend in theo.config.ts and every file route and server action gets ctx.queue:

import { config } from 'theokit'
import { PostgresJobBackend } from 'theokit/server/jobs'

export default config()
  .set({ jobs: { backend: new PostgresJobBackend({ pool }) } })
  .build()

ctx.queue.enqueue('send-email', input) hands the job to the backend when the response succeeds (a 4xx, a 5xx or an aborted request discards it). A job is a file under <serverDir>/jobs/ exporting defineJob(name, { handler }).

A route or action handler's ctx is a RouteContext (from theokit/server/define), whose keys are unknown until the app declares them. ctx.queue is there only when jobs.backend is set, so declare it yourself in a .d.ts file, together with the job names in JobRegistry (the scaffold's types/jobs.d.ts has both blocks):

declare module 'theokit/server/jobs' {
  interface JobRegistry {
    'send-email': { to: string; subject: string }
  }
}
declare module 'theokit/server/define' {
  interface RouteContext {
    queue: import('theokit/server/jobs').QueueClient
  }
}
export {}

theokit start and theokit dev call the backend's migrate() once at boot, so the theokit_jobs table is created (or upgraded) before the first request. If that fails, for example because the database is unreachable, the boot fails rather than serving routes whose jobs would be lost. Do not call migrate() from theo.config.ts: theokit build loads that file too, and the build would then need a database.

The outbox hands jobs over after the response, on a different connection from the one your route wrote with, so a route can commit a row and then lose its job to a failure in between. When the job table lives in your own database, write the job inside your transaction instead:

const client = await pool.connect()
try {
  await client.query('BEGIN')
  const task = await client.query('INSERT INTO task (title) VALUES ($1) RETURNING id', [title])
  await ctx.queue.enqueueInTransaction(client, 'process-task', { taskId: task.rows[0].id })
  await client.query('COMMIT')
} catch (err) {
  await client.query('ROLLBACK')
  throw err
} finally {
  client.release()
}

The job commits or rolls back with the row, and workers cannot see it before the commit. It needs a backend with enqueueInTransaction (PostgresJobBackend has it); any other backend rejects with TransactionalEnqueueUnsupportedError instead of enqueueing outside the transaction.

PostgresJobBackend also moves pending jobs in the caller's transaction, skipping jobs a worker has leased: defer(client, { name, where, until }) moves the jobs whose input matches where (top-level keys, compared as text) to until (a Date or 'infinity') and remembers the time each had; restore(client, { name, where }) gives that time back; reschedule(client, jobId, { availableAt }) sets one job's time, to bring it ahead of others.

To take back a queued job in a transaction, call ctx.queue.cancelInTransaction(client, 'process-task', { idempotencyKey }). It removes the job only while no worker ever leased it and resolves true if it removed one; a leased job (even with an expired lease) or a failed one is left alone. A backend without cancelInTransaction rejects with TransactionalCancelUnsupportedError.

theokit start and theokit dev run a job worker in the same process whenever jobs are declared and a backend is set: it polls the backend, runs each job and backs off while the backend is unreachable. On SIGTERM, start stops polling and waits for the job in progress before closing storage, up to jobs.worker.shutdownTimeoutMs (20 seconds by default). Jobs that run longer need a larger value, and a process manager that waits as long before it kills the process (systemd TimeoutStopSec, Kubernetes terminationGracePeriodSeconds). jobs.worker also takes pollIntervalMs, batchSize and lockSeconds, and enabled: false turns it off in a process that should only serve requests, for example enabled: process.env.ROLE !== 'web'. Several workers can share one Postgres backend; each job is leased to one of them. To run a worker on its own, call createJobWorker(createJobRunner(backend, definitions)).start() from theokit/server/jobs.

A job leases for lockSeconds, and ctx.signal aborts when the lease runs out, so a handler that may run longer than that calls await ctx.extendLease(seconds) while it makes progress. The deadline of signal moves with it, and the call rejects with JobLeaseLostError (and aborts the signal) if another worker holds the job by then. PostgresJobBackend and InMemoryJobBackend can extend a lease; a custom backend opts in with extendLease, and without it the call rejects with JobLeaseExtensionUnsupportedError.

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm theokit

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Plug and Pray: Your AI Agents Are Taking Orders From Strangers
Research

Plug and Pray: Your AI Agents Are Taking Orders From Strangers

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Vulnerability Insights

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?

Critical Apache HTTP Server Flaw Exposes Web Servers to RCE (1)
CVE

CVE-2026-119618: Critical Apache HTTP Server Flaw Exposes Web Servers to Remote Code Execution

Frame 2085668439 (1)
Group 1261154229