Scan your whole stack
From OX Research Newsroom
Are you using @theoremjs/agents?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.3.5-next.1034.gfe14d6a
@theoremjs/agents was last scanned on 29 Nov 2026 at version 0.3.5-next.1034.gfe14d6a. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.3.5-next.1034.gfe14d6a LATEST | 29 Nov 2026 | No rules fired |
| 0.3.5-next.1033.g5c598ea | 29 Nov 2026 | No rules fired |
| 0.3.5-next.1032.g04dc504 | 29 Nov 2026 | No rules fired |
| 0.3.5-next.1031.g1faef7b | 29 Nov 2026 | Not shown |
| 0.3.5-next.1030.g3b5fcaa | 28 Nov 2026 | Not shown |
Findings for v0.3.5-next.1034.gfe14d6a. 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.3.5-next.1034.gfe14d6a; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Theorem runs AI agents from typed profiles. The profile declares the agent's models, tools, inputs, outputs, and guardrails.
Use Theorem when your application runs an AI agent and you need the agent to do what its profile says, on every turn. Theorem runs each turn from the profile and enforces the rules around it.
You describe an agent once, as a profile. A profile says:
Theorem then runs each request as a turn that follows the profile. It cleans the input. It selects the tools that the model can see. It executes client tools through one gated pipeline. It checks what the model says before any of it reaches your user. It writes a trace to the place that you choose.
Theorem does not include application prompts, personas, or databases. It does not read .env files for provider credentials.
Your application supplies credentials, trace storage, and product policy. You can replace kernel wording through the labels.
Install jsr:@theoremjs/agents from JSR or @theoremjs/agents from npm.
| You need to | Theorem gives you | Read |
|---|---|---|
| Describe the whole agent in one place | A profile type for each kind of model call, several models per profile, typed file inputs, and outputs that a schema checks | Profile types |
| Stop a prompt injection or a data leak | Input scanning by trust level, canary tokens, and egress checks that can send the model back to try again | Guardrails |
| Let the model act, safely | One tool registry for function, HTTP, MCP, and provider tools, gated in layers, with OAuth 2.1 and PKCE built in | Tools |
| Connect model servers | Protocols for Gemini, OpenRouter, TypeSafe, and OpenAI-compatible servers, and providers that you define | Providers |
| See what happened | Traces to JSONL, memory, or your own sink, with sampling, scrubbing, and retention | Observability |
| Trust the kernel | A kernel that imports with every Deno permission denied. A test proves it. | Package Boundary |
Use these steps to create a support agent and run one turn. Install the package, register the provider and tool, define the profile, then run the turn.
deno add jsr:@theoremjs/agents
# or
npm install @theoremjs/agents zod
The npm package runs on Node 22 and later and in browsers. Its type declarations need TypeScript 5.7 or later.
Register each tool once, when your application starts. A profile refers to it by name.
import { z } from "zod";
import { registerTool } from "@theoremjs/agents";
registerTool({
type: "function",
name: "search_tickets",
description: "Search support tickets by keyword.",
category: "support",
access: "read-only",
paths: ["*"],
loadTier: "T0",
permission: "auto",
input: z.object({ query: z.string().min(2) }),
output: z.object({ tickets: z.array(z.object({ id: z.string(), title: z.string() })) }),
handler: async ({ query }) => ({ tickets: await db.tickets.search(query) }),
});
A provider is data about a model service: its address, the protocols that it serves, and how to sign in. A protocol is the code for one API shape. It writes each request and reads each reply. Register the provider before the profile. The registration sets its connection and its credential slots.
import { openRouterProvider, registerProvider } from "@theoremjs/agents";
const router = registerProvider(openRouterProvider, { keySlot: "openrouter" });
Each run captures the registered provider. A later registration affects later runs only.
The profile selects models and tools. It also declares inputs, outputs, and guardrails.
The registered provider's .model() helper takes a protocol and a model ID. It checks the settings and returns plain binding data.
import { defineProfile, registerProfile } from "@theoremjs/agents";
const support = defineProfile({
type: "text",
id: "support.agent",
identity: {
handle: "support",
system: "You help customers with their account. Cite the docs you used.",
},
models: {
main: router.model("openRouterOpenAi", "openrouter/free"),
},
defaultModel: "main",
tools: { allow: ["search_tickets"] },
inputs: { text: true },
});
registerProfile(support);
The profile sets no guardrails, so input cleaning, sensitive-data redaction, and the canary stay on. Guardrails says what each one does.
runTurn resolves the registered provider from the profile. Pass credentials through the vault.
import { runTurn } from "@theoremjs/agents";
for await (const event of runTurn(
{ profile: "support.agent", input: { text: "Find support tickets about failed large CSV exports." } },
{ vault: { openrouter: apiKey } },
)) {
send(event); // text · thought · structured · media · tool · guardrail · stage · tokens · done
}
Every event is typed. A structured event arrives only after validation and the egress checks pass. The done event carries a normalized stop: completed, length, gate, cancelled, or another kind. Read stop to decide whether to continue, resume, or stop.
When your app adds to each turn (a system prompt, credentials, a stage handler), write it once as a TurnWiring and use it at every call site. A web handler takes the same prepare, and Theorem Studio runs your turns with it:
import { runTurn, type TurnWiring } from "@theoremjs/agents";
export const theorem = {
provider: { vault: { openrouter: apiKey } },
prepare: (turn) => ({ ...turn, system: "Answer in the customer's language." }),
} satisfies TurnWiring;
const turn = { profile: "support.agent", input: { text: "Why did the export fail?" } };
for await (const event of runTurn(await theorem.prepare(turn), theorem.provider)) send(event);
Use the type field to choose what the agent does. The type sets the shape of the profile and picks the runner.
| Type | Runner | Takes | Returns | First-party protocols |
|---|---|---|---|---|
text |
runTurn |
text, attachments, voice notes, options, history | text, thoughts, validated JSON, tool calls | geminiInteractions, openRouterOpenAi, openAi |
image |
runTurn |
prompt + reference images | images, optionally with interleaved text | geminiInteractions, openRouterImages |
speech |
runTurn |
text | audio (WAV, or MP3 on OpenRouter) | geminiInteractions, openRouterOpenAi, openAi |
transcription |
runTurn |
one voice clip | the words in the clip, as text | openRouterTranscriptions |
live |
runSession |
realtime mic audio, camera frames, typed text | streamed audio, transcripts, tool calls | geminiLive |
host |
invokeTool, invokeToolStep, runTool, runToolStep |
tool calls from your own code, one at a time or as a step; the run pair gives how each call ended |
guarded tool results | none; it never calls a model |
decision |
runDecision |
non-null JSON state plus declared questions | typed choices, probabilities, scores, boxes, or noul |
systemOne, openRouterDecisions |
embedding |
runEmbedding |
text, or text and media parts | one vector for each input | geminiEmbeddings, openRouterEmbeddings, ollamaEmbeddings |
A protocol that you define can serve the same profile types. Its endpoints name the profile types that it serves.
defineProfile rejects a field that does not belong to the type, so the mistake fails at startup, not halfway through a turn.
For example, live takes no attachments and image takes no steering.
A host profile sets only guardrails.detect and guardrails.network.
The runner is one deterministic path for one agent turn. A profile is a declaration that the host owns. Registered providers and their protocols supply model operations; runSession opens live sessions. Traces go to destinations that the host registers. There are no environment variables and no bundled database.
request
|
v
INGRESS sanitize by trust level, attachment limits, quota
RESOLVE pick model and effort, tool snapshot, canary
| stage: pre_turn
v
STEP LOOP (up to maxSteps)
provider stream --text--> progressive yield --> your client
|
'--validated calls--> tool pipeline --guarded results--> next model step
| stream ends
v
END OF ATTEMPT
reply blocked: blockedReply retry --> back to the step loop
output validation: fails --> repair round, back to the step loop
| stage: before_end
v
done + stop kind --> your client
| stage: post_turn
v
trace sink (scrubbed)
Use onStage to act at a fixed point in the turn:
pre_turn.pre_tool.post_tool.A turn that stops early can resume. After a gate stop, call invokeTool with resume. After a cut-off reply, start a new runTurn with continueFrom.
For a React interface, use the separate package @theoremjs/react. It builds on the headless projection @theoremjs/agents/interface. The agents package does not include React.
Use tools to let the model act: look something up, call an API, change a record. You register each tool once in a catalog that the whole host shares. A profile picks tools from the catalog, and each turn narrows the choice again.
| Type | What runs |
|---|---|
function |
Your handler, in process. |
http |
A declarative REST call. Auth is bearer, api_key, or oauth2. |
mcp |
One tool on a remote MCP server over Streamable HTTP. |
builtin |
A provider-native tool (Google Search, Maps, URL context, code execution) from a preset. |
Every client-tool call uses the same gated pipeline. Provider-native tools execute upstream through the protocol. Six layers decide whether the model can call a tool, and each layer has one owner.
| Layer | Owner | What it decides |
|---|---|---|
| Catalog | Host, at startup | registerTool: schema, handler, access, loadTier, permission |
| Allow | Profile | tools.allow for custom tools; models.*.builtInTools for provider tools |
| Paths | Tool | paths globs matched against TurnRequest.path |
| Visibility | Registry and profile | T0 always visible; T2 on demand: picked at turn start by tools.t1Policy(ctx) or loaded mid-turn by tools.t2Loader |
| Permission | Tool and host | auto runs; session_consent asks once per session; always_confirm asks every call |
| Hooks | Tool and host | The tool's preTool and the turn's onStage can deny, confirm, or rewrite the call |
A tool that must act as the signed-in user takes OAuth 2.1 with PKCE. The call becomes an auth gate, and the helpers in @theoremjs/agents/kernel finish the sign-in.
Each tool call gets an operation ID from the kernel, ToolContext.operationId. A ToolExecutionCoordinator that the host owns keeps a claim and an outcome for each ID, so a retried or resumed turn does not run the same action twice.
Pass it as execution on the TurnRequest. A tool that the page answers also needs pageExecution, a PageToolExecution.
Profile JSON and provider events cannot supply either one.
createMemoryToolExecution keeps claims and outcomes in memory. It refuses new operations after maxOperations, when you set it. Nothing survives a restart.@theoremjs/web server handler builds one from its session store.authorizeToolReplay. It checks that the call is still allowed and may still be shown, and it runs no handler.A claim that has no confirmed outcome (ToolOperationUncertainty) never becomes an approval again. Check the destination before you create a replacement action.
Theorem scans each piece of text according to where it came from.
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.
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).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.