typ

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

typ

go get github.com/holon-sh/typ

typ.wasm also runs under any WASI preview 1 runtime: one JSON request on stdin, one answer on stdout. FORMAT.md describes the requests and answers, and examples/ holds a request for each function.

wasmtime typ.wasm < examples/same_contract.json

Each release attaches typ.wasm and typ.wasm.sha256.

typ.wasm is built from src/ with the pinned Rust toolchain:

scripts/build

Tests:

go test ./...
cargo test

The tests that run Node, Python and the type checkers against generated clients need tooling/ installed and the toolchains tag:

npm ci --prefix tooling
uv sync --project tooling
(cd tooling && go mod download)
go test -tags toolchains ./...

Documentation

Index

Constants

View Source
const Marker = "holon-generated-apps-v1"
View Source
const PythonOwnTypes = "_own.py"
View Source
const TypeScriptDeclarations = "index.d.mts"
View Source
const TypeScriptModule = "index.mjs"

Variables

This section is empty.

Functions

func Changes

func Changes(expected, published *Metadata) ([]string, error)

func CheckTools

func CheckTools(tools []Tool) error

CheckTools requires each tool to have a valid MCP name and an MCP Tool inputSchema that is an object of type object.

func Generate

func Generate(options GenerateRequest) (map[string][]byte, error)

func Load added in v0.0.4

func Load() error

func SameContract

func SameContract(a, b *Contract) (bool, error)

Types

type Contract

type Contract struct {
	Tools     []Tool     `json:"tools"`
	Resources []Resource `json:"resources,omitempty"`
	Events    []Event    `json:"events,omitempty"`
}

func (Contract) MarshalJSON

func (c Contract) MarshalJSON() ([]byte, error)

type Event

type Event struct {
	Name    string          `json:"name"`
	Input   json.RawMessage `json:"inputSchema"`
	Payload json.RawMessage `json:"payloadSchema"`
}

type GenerateRequest

type GenerateRequest struct {
	Target    Target               `json:"target"`
	Identity  Identity             `json:"identity"`
	Requires  map[string]Identity  `json:"requires,omitempty"`
	Contracts map[string]*Contract `json:"contracts,omitempty"`
	Own       string               `json:"own,omitempty"`
	OwnTools  *Contract            `json:"own_tools,omitempty"`
	App       string               `json:"app,omitempty"`
	Endpoint  string               `json:"endpoint,omitempty"`
}

type Identity

type Identity struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type Metadata

type Metadata struct {
	Identity Identity          `json:"identity"`
	Schema   *Contract         `json:"schema,omitempty"`
	Requires map[string]string `json:"requires,omitempty"`
}

func ParseMetadata

func ParseMetadata(data []byte) (*Metadata, error)

type Resource

type Resource struct {
	URI    string          `json:"uri"`
	Output json.RawMessage `json:"outputSchema"`
}

type Target added in v0.0.5

type Target string
const (
	TargetNode    Target = "node"
	TargetBrowser Target = "browser"
	TargetPython  Target = "python"
	TargetGo      Target = "go"
)

type Tool

type Tool struct {
	Name   string          `json:"name"`
	Input  json.RawMessage `json:"inputSchema"`
	Output json.RawMessage `json:"outputSchema,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL