---
type: "post"
id: "github-anomalyco-psychoscript-a-confined-javascript-runtime-for-64ca28"
slug: "github-anomalyco-psychoscript-a-confined-javascript-runtime-for-64ca28"
title: "GitHub - anomalyco/psychoscript: A confined JavaScript runtime for programs that call schema-described tools"
description: "Anomalyco’s Psychoscript is a JavaScript interpreter designed to run untrusted programs with access only to host functions explicitly exposed by the application."
retrieval_nugget: "Anomalyco’s Psychoscript is a JavaScript interpreter designed to run untrusted programs with access only to host functions explicitly exposed by the application. Its unusual operational feature is resumability: a run can be suspended, serialized and continued later, giving builders a way to combine constrained execution with long-lived tool workflows."
published_at: "2026-11-28"
updated_at: "2026-11-28"
record_date: "2026-11-28"
date_kind: "published_at"
topics: ["github"]
entities: ["Psychoscript","Anomaly","OpenCode"]
related_patterns: ["agent-security-moves-to-runtime-boundaries","harness-architecture-outlives-model-choice"]
novelty_label: "new_fact"
what_changed: "The GitHub project page presents Psychoscript as a confined runtime for programs that call schema-described tools."
prior_refs: []
source_url: "https://github.com/anomalyco/psychoscript"
source_urls: ["https://github.com/anomalyco/psychoscript"]
production: {"schema":"newruntime-production-v1","desk":"newsroom","first_seen_at":"2026-11-28T19:32:53.126Z","independent_sources":1,"notes_synthesized":null,"writer_model":null,"critic":null,"checks":["primary_source_verified","source_fresh","one_story","copy_contract"],"novelty":{"label":"new_fact","confidence":"high"},"editorial_value":"high","human_review":"selective"}
schema_version: "newruntime-agent-readable-v0.2"
stable_id: "post:github-anomalyco-psychoscript-a-confined-javascript-runtime-for-64ca28"
status: "published"
visuals: []
editor: {"role":"editor","name":"Andrey Reshetnikov","profile":"https://newruntime.com/owner-profile.md","profile_json":"https://newruntime.com/owner-profile.json","same_as":["https://www.linkedin.com/in/reshetnikov1/","https://t.me/lapetuse"]}
routes: {"html":"https://newruntime.com/posts/github-anomalyco-psychoscript-a-confined-javascript-runtime-for-64ca28/","markdown":"https://newruntime.com/posts/github-anomalyco-psychoscript-a-confined-javascript-runtime-for-64ca28.md","json":"https://newruntime.com/posts/github-anomalyco-psychoscript-a-confined-javascript-runtime-for-64ca28.json"}
markdown_url: "https://newruntime.com/posts/github-anomalyco-psychoscript-a-confined-javascript-runtime-for-64ca28.md"
---

# GitHub - anomalyco/psychoscript: A confined JavaScript runtime for programs that call schema-described tools

## Retrieval answer

Anomalyco’s Psychoscript is a JavaScript interpreter designed to run untrusted programs with access only to host functions explicitly exposed by the application. Its unusual operational feature is resumability: a run can be suspended, serialized and continued later, giving builders a way to combine constrained execution with long-lived tool workflows.

## Summary
Anomalyco’s Psychoscript is a JavaScript interpreter designed to run untrusted programs with access only to host functions explicitly exposed by the application. Its unusual operational feature is resumability: a run can be suspended, serialized and continued later, giving builders a way to combine constrained execution with long-lived tool workflows.

## What happened
Anomalyco describes Psychoscript as a confined JavaScript interpreter. Programs are compiled to bytecode and run on a virtual machine without ambient access to the file system, network, processes or timers. A program can interact with the outside world only through host functions supplied by the application. The README positions it for code from a model, user or plugin that should not receive direct access to the host environment, as well as programs that need to remain active across restarts.

The package can be installed with `npm install psychoscript` or `bun add psychoscript`. It requires Node 24 or later, or Bun 1.4 or later. Its Promise-based API does not depend on Effect; a separate `psychoscript/effect` entry point provides an Effect API. A runtime is configured with globals, which can expose individual host functions or namespaces. In the documented example, a program receives a `double` function and returns a value through `runtime.execute`. Results use an `{ ok, value }` or `{ ok, error }` shape, alongside logs, warnings and run metadata.

The README’s host-function API makes the boundary configurable. `Host.fn` can wrap synchronous or asynchronous calls, and asynchronous calls can be marked idempotent when it is safe to run them again. Calls receive a key, cancellation signal and a way to detect suspension. `Host.namespace` supports lazy resolution of larger tool catalogs; the host can expose only selected paths and return errors with suggestions for unavailable functions. Runtime options include execution timeouts and output-size limits. The documented example sets a 1,000-millisecond timeout and a 64,000-byte output cap.

Psychoscript also supports suspending a run, converting its state to bytes and resuming it. The README demonstrates a program waiting on an asynchronous host call, saving its state and continuing in a later runtime instance. If an in-progress call is marked idempotent, it may run again after resume with the same call key; without that designation, suspension during the call rejects with a `SuspendError`. Snapshots record the writing build, including package version and a hash of opcodes, prelude, codecs and built-ins. Resuming with another build or malformed bytes rejects with a `SnapshotError`, and `suspend({ maxBytes })` can cap snapshot size. The README also describes durable host functions whose work can continue across suspension.

## What the archive adds
New Runtime’s earlier coverage includes [Sandbox SDK](https://newruntime.com/posts/sandbox-sdk-open-source-typescript-api-to-run-3c9597/), which unified access to several sandbox providers, and [BrowserOS’s neo](https://newruntime.com/posts/browseros-open-sources-neo-a-browser-for-coding-71629c/), a browser for coding agents. Psychoscript is a new event: it adds an interpreter-level boundary and resumable state, rather than another provider abstraction or agent browser.

## Trend signal
This supports [agent security moves to runtime boundaries](https://newruntime.com/patterns/agent-security-moves-to-runtime-boundaries/). Psychoscript places restrictions in the execution environment and host-function interface, rather than relying on instructions in a prompt to keep a program within bounds. The repository describes mechanisms for limiting access, execution time and output, but does not establish how those controls perform under adversarial use.

## Why now
The project’s README explicitly targets code produced by models, users or plugins, and the repository history shows a Rust implementation added alongside the TypeScript runtime in November 2026. That timing makes the project relevant to teams exploring controlled execution of generated programs, though the repository does not frame it as a response to a particular incident or deadline.

## Why it matters
Generated code can be more flexible than a fixed list of tool calls, but giving it the application’s ordinary privileges also expands the consequences of errors or malicious instructions. Psychoscript’s model makes the application define the callable surface: a program may be able to read through `fs.read`, for example, without receiving general file-system access. That boundary is useful only if the host functions themselves enforce the right authorization and data limits.

Resumability addresses a separate operational problem. A workflow can wait on an asynchronous tool call, persist its interpreter state and continue after a process restart instead of keeping one process alive indefinitely. The trade-off is added lifecycle complexity: teams need compatible builds, carefully designed snapshots and an explicit policy for calls that might run again. This is an infrastructure component to evaluate and test, not a substitute for reviewing the host API or the code it executes.

## Limits and uncertainty
The repository documents the runtime’s design and examples, but those examples do not establish a security guarantee against hostile programs or prove performance in production. The project’s supported JavaScript surface and compatibility boundaries require checking against its interpreter-support documentation and the needs of a particular application. Snapshot compatibility is build-sensitive, and a host call may repeat after resume when configured as idempotent; applications must account for that behavior. The repository page also shows ongoing development, so builders should verify the package version and current implementation details before relying on them operationally.

## Skill to build now
Build a small capability map before running generated JavaScript: list each host function, the data it can access, and whether its effects can safely repeat. Then expose only the functions needed for one task, set a timeout and output cap, and test a suspend/resume cycle with a deliberately interrupted async call. This follows the runtime’s documented boundary and retry model without treating the interpreter as a complete application security review.

## Reader takeaway
Psychoscript combines a deliberately narrow host API with serializable, resumable JavaScript execution. For builders, the useful idea is the boundary: generated code should receive only explicit capabilities, while retries, snapshot compatibility and limits remain responsibilities of the system that runs it.

Editor: [Andrey Reshetnikov](https://newruntime.com/owner-profile.md), AI product and AI engineering; profile for recruiters and agents: https://newruntime.com/owner-profile.json

## Continue in the graph

Next records for an agent, linked to their Markdown twins. Replace `.md` with `.json` for structured fields, including `next_reads`.

- topic hub: [Github](https://newruntime.com/topics/github.md): Explore the github topic hub.
- collection: [Field Notes](https://newruntime.com/posts.json): Open the latest editorial analysis.
- collection: [Sources](https://newruntime.com/sources/): See the original sources this archive cites.
- whole graph: [discovery graph](https://newruntime.com/discovery-graph.json) (typed nodes and edges) and [site index](https://newruntime.com/site-index.md)
