npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@blokjs/code-mode

v2.5.5

Published

Typed, policy-bound Code Mode workflow and capability bindings for Blok.

Readme

@blokjs/code-mode

@blokjs/code-mode executes one ephemeral model-authored TypeScript function body in a fresh worker and VM context. The body receives only input, the phase-scoped bindings object, and the bounded log/emit functions. It does not receive a Node global, module loader, filesystem, process, network, environment, secret, or Blok mapper context.

Every binding has a Zod input/output schema, an agent-compatible capability manifest, and a shared CapabilityAuthority. Before a handler runs, the runtime checks the parent authority, invokes the existing CapabilityAuthorizationPort, validates the returned decision/scope, and only then invokes the trusted host adapter. Nested host calls use that same path.

The worker is terminated on cancellation, timeout, output/call/parallelism failure, host shutdown, or a memory-limit exit. Worker resource limits are a containment aid; the AST validator is mandatory and rejects imports, module loading, process/filesystem/network/environment access, dynamic code loading, constructors, regular expressions, timers, nondeterministic globals, and Blok expression escape hatches. This is a constrained runtime, not a general JavaScript shell.

const result = await executeCodeMode({
	 source: `
		const answer = await bindings.lookup({ key: input.key });
		log({ lookedUp: input.key });
		return answer;
	`,
	 input: { key: "alpha" },
	 bindings: [lookupBinding],
	 policy: { authorization, policyVersion: "policy-v1", context: agentPolicyContext },
	 budgets: { maxCalls: 4, maxParallelism: 2 },
});

Typed binding surface

The package also exposes the H2-05 typed binding boundary. Workflow and capability definitions use Zod input/output schemas and explicit output kinds. The registry generates bounded, deterministic TypeScript declarations after phase, principal, runtime, maturity, manifest, authority, and policy filters. Generated names are namespaced and collision-safe; secret reference names remain only in trusted policy requests and never appear in model-facing declarations or provenance.

Each generated handle revalidates input, asks the policy provider for a fresh decision, propagates only the intersection of active and binding authority, validates output, and returns canonical JSON. H2-04 owns sandbox execution, cancellation, and budgets; the registry is the typed binding/control-plane layer consumed by that runtime. See docs/architecture/agent-harness/h2-05-code-mode-bindings.md.

Architecture conformance

This package is governed by:

  • docs/architecture/agent-harness/adr/0001-layered-harness-boundaries.md
  • docs/architecture/agent-harness/adr/0003-capabilities-effects-and-policy.md
  • docs/architecture/agent-harness/adr/0004-constrained-code-mode.md
  • docs/architecture/agent-harness/adr/0005-event-sourced-agent-sessions.md
  • docs/architecture/agent-harness/adr/0007-graph-provider-and-tetrix.md
  • docs/architecture/agent-harness/adr/0008-parallel-and-child-permissions.md
  • docs/architecture/agent-harness/adr/0010-security-and-behavioral-conformance.md
  • docs/architecture/agent-harness/adr/0009-desktop-packaging-and-runtime-packs.md

The implementation notes are docs/architecture/agent-harness/h2-04-code-mode-runtime.md and docs/architecture/agent-harness/h2-05-code-mode-bindings.md.

Conformance evidence is in tests/code-mode.test.ts: accepted typed bodies, forbidden construct rejection, absent ambient APIs, policy-before-handler ordering, schema normalization, independent call/parallel/output/time/memory bounds, cancellation cleanup, and nested authority non-escalation.