Core

Viewport Core

The shared runtime under Viewport Evals, HITL and Context. Trajectories, the Matcher, tools, middlewares and the ambient event sink, in Python and TypeScript.

Status: Beta. Version 0.1.0 is on npm (@viewportai/core) and PyPI (viewport-core).

Viewport Core is the small runtime every Viewport package builds on. You use it directly when you write an adapter for an agent stack, a custom assertion, a tool middleware, or tests that need deterministic trajectories. Most users meet it through Evals, HITL and Context, which re-export what they need.

It gives you five things, identical in Python and TypeScript:

  1. Trajectory: the typed record of one agent run. JSON Schema is the source of truth; pydantic models and TypeScript types are generated from it.
  2. Matcher: one value-matching language for eval expectations and policy conditions, with tri-state results.
  3. Tools and middlewares: a stack-neutral Tool and (tool) => tool middlewares that record themselves.
  4. The ambient sink: events emitted inside trace() are collected into one trajectory, across packages.
  5. Deterministic building blocks: injectable clocks and ids, canonical JSON, RFC 8785 digests, strict YAML with source locations, and errors that say where and what.
main.py
from viewportai.core import match

result = match(
    {"tool_name": "issue_refund", "args": {"amount": {"lte": 100}}},
    {"tool_name": "issue_refund", "args": {"order_id": "A-1001", "amount": 42.5}},
)
print(str(result.passed).lower())  # true
main.ts
import { match } from "@viewportai/core";

const result = match(
  { tool_name: "issue_refund", args: { amount: { lte: 100 } } },
  { tool_name: "issue_refund", args: { order_id: "A-1001", amount: 42.5 } },
);
console.log(result.passed); // true

Both languages pass the same 600+ conformance vectors in spec/conformance, so a matcher, a YAML file or a digest gives the same answer, the same failure path and the same message in either one.

Next: the quickstart.