Getting started
tungsten is a deterministic compiler written in Rust. It reads one API description — an OpenAPI 3.0 or 3.1 document (JSON or YAML), a Swagger 2.0 document, a Postman Collection v2.1 file, a saved cURL command, an HTTP request file (.http/.rest), a HAR 1.2 capture or an endpoint manifest with JSON Schema 2020-12 models — plus two small manifests, builds one typed intermediate representation (IR), and emits TypeScript, Python, Rust, Go, Java, Kotlin, C#, F#, Dart and Ruby SDKs, a Rust command-line client, an MCP server, browser WebMCP tools and LLM-oriented docs. Documents are parsed locally; optional HTTP/Git acquisition pins the downloaded source for verified offline reuse. Every emitted client is built for an autonomous caller: failures are instructions, side effects are never duplicated, and irreversible calls need an explicit confirmation. See Supported inputs for the exact alternatives, their limits and the review each requires.
Why tungsten
Most SDK generators optimize for a person reading autocomplete. An agent has a finite context window, no memory between retries, and no sense of what is irreversible. tungsten changes the design goal of each stage:
- Diagnostic error envelopes. Every failure, from argument validation to a transport error to an HTTP status, is one closed JSON shape with a category, the failing parameter, the received value, what was expected, a remediation sentence and an explicit
retryableverdict. The same 14 members in every runtime, ready to paste into a model's context. - Safety tiers. Each operation is
read_only,mutating,destructiveorirreversible, defaulted from the HTTP method and refined inagent.yml. Tiers drive retries, MCP tool annotations and confirmation rules. Ordinary spec annotations cannot lower the method tier or remove preview from an operation with side effects: those decisions require an explicit per-operationtoolsentry inagent.yml(safetyandpreview: none, respectively). The compiler keeps the safe policy and reports TG0615/TG0616;--strictrejects these warnings. Imported operations retain their separate reviewed-policy floor. - Previews and confirmation tokens. A destructive or irreversible call must be previewed first. The preview returns the request that would be sent and its effects, plus a confirmation token that is valid only for identical arguments. The generated CLI replaces tokens with
--yes(and--i-understandfor irreversible operations). - Idempotency and unknown outcomes. Mutations are retried only with an idempotency key (or an identity body), always with the same key. A timeout or reset after a write is reported as
OUTCOME_UNKNOWNwith the call to verify it, not as a failure to retry blindly. - Verification. An operation can name a read to run after success and the state to expect, attached to the result.
- MCP progressive disclosure. Past a tool-count threshold the server lists a few meta-tools (
search_tools,describe_tool,invoke,preview,list_clusters) instead of every operation. In the maintainers' measurement on the ZROtext pilot (October 2026, BPE token counts), the progressive listing of its 41 tools costs 765 tokens, against 9,473 for the 14 tools of that project's hand-written MCP server. - Deterministic output. The same inputs produce byte-identical files. Generated files record the generator version and the digest of their inputs, and
tungsten generate --checkfails when output is stale.
Supported inputs
init --from also accepts HTTP(S) document URLs for these formats. OpenAPI
URLs work directly as compiler paths or inputs[].spec in tungsten.yml.
Other formats go through the same local importer and its required review flags:
tungsten init --from https://example.com/contracts/openapi.json --dir my-api
tungsten generate my-api --offline
tungsten check my-api --refresh-inputs
The first fetch records the source URL and SHA256 under
.tungsten-inputs/<url-sha256>/source.lock.json, beside immutable downloaded
content. Retain the complete source cache directory for offline use. Online commands verify upstream
bytes against the pin and refuse changed content. --refresh-inputs explicitly
accepts a new OpenAPI pin; converted imports instead require re-import into a
fresh project and another operation review. Their source_url and
source_sha256 manifest fields preserve that provenance on every compilation.
For authentication, repeat --input-header 'Authorization: Bearer ...', or set
TUNGSTEN_INPUT_HEADERS to newline-separated Name: value headers to keep
secrets out of command history. Unscoped headers apply only to the exact URL
typed on the command line. For URLs in a manifest, scope each header to an
origin: --input-header '[https://api.example.com] Authorization: Bearer ...'.
The scheme, host and effective port must match; redirects remain refused.
Header values are excluded from pins and fetch
diagnostics. URLs must have no credentials, query or fragment. Downloads are
limited to 8 MiB and 30 seconds; redirects are refused. Remote references are
still blocked, including relative references from a remote OpenAPI document.
The cache contains original input bytes, so retain it with the same access
controls as the source document and review it before sharing.
Git inputs use git+https://git.example.test/owner/repository@ref#path in init --from,
compiler paths or OpenAPI manifest inputs. A branch or tag resolves to exactly
one commit, which is fetched shallowly into a disposable bare repository. No
checkout, hooks, submodules or repository code runs. Git supplies private-source
credentials through trusted user or system configuration. Project Git config
and inherited GIT_* overrides are ignored. --input-header
applies only to HTTP document downloads. Local repositories for offline workflows
and hermetic validation use git+file:///absolute/repository@ref#path.
tungsten init --from 'git+https://github.com/example/api@main#contracts/openapi.yaml' --dir my-api
tungsten generate my-api --offline
The Git source lock under .tungsten-inputs/git/ records the repository URL,
requested ref, resolved commit, selected document and SHA256 of every materialized
file. Ordinary runs retain that commit; --refresh-inputs is the explicit request
to resolve a moving ref again. Converted imports retain their review provenance
and require re-import into a fresh project to change source commits. Discovery
recognizes all supported input formats and requires an explicit #path when
multiple documents are found. Relative references retain the compiler's local
input-root confinement. Acquisition is limited to 60 seconds, 512 files, 8 MiB per
file and 64 MiB of materialized content and fetched Git object data. Narrow
#path to bound discovery; the shallow fetch itself must still fit the object
budget. Git redirects, symlinks, submodules and unsafe paths are refused.
Retain the complete .tungsten-inputs/git/ cache for offline use, including its
locks and materialized files; offline reuse needs no Git executable. Every
materialized file is verified, and unexpected cached files or directories are
rejected. HTTP/Git pins verify source consistency, not the publisher's identity:
review and protect the cache and lock files together.
On Windows, Git's disposable bare repository uses a fresh private child of the
local temporary directory, so a deeply nested project cache does not become
Git's working directory or object-store path. Pins and verified input files
remain under the project's .tungsten-inputs/git/ directory. TMP/TEMP must
select a writable local disk directory with room for Git's pack and lock
filenames; network, unusable or overly long temporary roots fail with TG0133.
Choose a shorter local temporary path when needed. Offline pin reuse needs no
temporary repository. Git's source repository paths and external credential
helpers retain their own platform limits.
tungsten init takes one input of any of the kinds below — OpenAPI OR Swagger OR Postman OR saved cURL OR HTTP request files OR HAR, with the endpoint-manifest and manual paths alongside them — not a bundle. Acquisition may download a document or fetch a Git commit; parsing never sends or replays the API requests described by that input, and no shell, script or capture is ever executed. Non-OpenAPI inputs are converted to a normalized OpenAPI document that init saves next to the manifests (imported.openapi.json, with an import-report.json where listed; the manual path writes inferred.openapi.json and inference-report.json), so the accepted input stays separate from the normalized artifact and the typed IR the compiler builds from it.
| Input | You provide | Entry point and conversion | Limits and required review |
|---|---|---|---|
| OpenAPI 3.0 / 3.1 | JSON or YAML document | tungsten init --from openapi.json (default when unset: openapi.json, openapi.yaml or openapi.yml in the target directory). The document is kept in place, so relative references retain meaning, and goes through the native frontend: $ref resolution, overlays | The full frontend surface; overlays remain optional |
| Swagger 2.0 | JSON or YAML document | tungsten init --from swagger.json (also a default name) or any path. Bounded offline conversion to OpenAPI, saved as imported.openapi.json | Unsupported semantics fail explicitly instead of being guessed; conversion never resolves external references |
| Postman Collection v2.1 | JSON collection | tungsten init --from collection.json. Structural import; omissions are listed in import-report.json | Scripts and requests are never executed: script-dependent behavior, non-JSON bodies and saved responses and unsupported auth helpers are omitted per item, not interpreted — this is not a Postman runtime |
| Saved cURL command | A saved command as text | tungsten init --from command.curl --route '/pets/{id}' (auto-detected by a leading curl, a .curl extension, or --input-format curl). Parsed as data against POSIX, cmd or PowerShell quoting (--shell-dialect) | Exactly one explicit --route path template is required; the command is parsed, never executed |
| HTTP request files | .http or .rest file | tungsten init --from requests.http --route '/pets/{id}' (extension-detected, or --input-format http) | An explicit --route template per request |
| HAR 1.2 | A capture file | tungsten init --from capture.har --har-origin https://api.example.com --har-paths paths.json. Bounded offline observations of the recorded traffic | A multi-origin capture needs --har-origin; every captured path needs a reviewed template (--route, or a --har-paths JSON mapping) before anything is saved; --include-prefix/--exclude-prefix narrow the capture and --redact-property redacts property names. Captured traffic provides incomplete observations of past behavior, not the live API |
| Endpoint manifest v1 | JSON manifest with declared models | tungsten init --from endpoints.json. Loaded by the endpoint-manifest frontend | Explicit HTTP routing metadata (base URL and endpoints) and JSON Schema 2020-12 models within the supported subset are required — not arbitrary standalone JSON-Schema-to-API inference |
| Manual endpoint | No document | tungsten init --method get --endpoint /pets/{id}, with optional --request-example and --response-example JSON files (only their structure is persisted; the response is recorded at status 200). Writes inferred.openapi.json and inference-report.json | Explicit offline observations only; not schema-free API discovery |
All conversion routes share these limits: setup inputs are bounded (8 MiB, with larger OpenAPI documents served by the explicit compiler flow below); every converted operation is marked as imported, and targets that cannot enforce imported-operation policy refuse it (TG0705 for built-in targets, TG0808 for external emitters that do not declare support) — typescript, python, rust, mcp, webmcp and docs are supported, the Java, Kotlin, C#, F#, Dart and Ruby targets and non-opted-in external emitters are not, and init refuses unsupported built-in selections before saving the converted input or project manifests. Imported observations are incomplete contracts: review the inferred response types, authentication, safety tiers and origins in agent.yml and mark reviewed operations before live use.
init is the only entry point for the alternative inputs. The other commands (check, generate, mock, diff, report) take an initialized project (a directory with tungsten.yml, or the manifest), or — for the native format only — a single OpenAPI document passed directly.
Targets
| Target | Emits | Minimum toolchain | Runtime and installation |
|---|---|---|---|
typescript | Typed SDK, Result values, Zod validation | Node 22 | @elysra/tungsten-runtime: matching npm package or built source |
python | Sync and async SDK, Pydantic v2 or dataclass models | Python 3.12 by default; opt-in 3.10/3.11 | PyPI runtime for a matching published release, or matching runtimes/python source |
rust | Async SDK (serde, reqwest) and optional generated CLI | Rust 1.88 | Matching source paths to runtimes/rust/runtime and, for a CLI, runtimes/rust/cli-kit; see installation |
go (external) | Models, resources, typed client, pagination and stream helpers | Go 1.22 | Build tungsten-emit-go from emitters/go; use runtime_path to matching runtimes/go source; see module status |
java | Java SDK | Java 17 and Maven | Use runtime_path to matching runtimes/java source |
kotlin (kt) | Kotlin/JVM SDK (data classes, sealed interfaces, blocking functions returning Result; opt-in suspend functions and cold Flows with coroutines: true) | Java 17 and Gradle | Use runtime_path to matching runtimes/kotlin (limits); it builds on the Java runtime in runtimes/java (java_runtime_path). The coroutine surface adds the tungsten-runtime-kotlin-coroutines artifact (runtimes/kotlin/coroutines, coroutines_runtime_path) and kotlinx-coroutines-core |
csharp (cs) | C# SDK | .NET 10 | Use runtime_path to matching runtimes/csharp, referencing Tungsten.Runtime.csproj (limits) |
fsharp (fs) | F# SDK (records, discriminated unions, Task of Result) | .NET 10 | Use runtime_path to matching runtimes/fsharp (limits); it references the .NET runtime in runtimes/csharp (csharp_runtime_path) |
dart | Dart SDK (final model classes, sealed unions, Future methods returning Result, Stream pages) | Dart 3.6 | Use runtime_path to matching runtimes/dart (tungsten_runtime, a dart:io package; limits) |
ruby (rb) | Ruby SDK | Ruby 3.3 and Bundler | Use runtime_path to matching runtimes/ruby source |
mcp | MCP server over stdio or Streamable HTTP, discrete or progressive | Node 22.13+; Node 23 needs 23.2+ | @elysra/tungsten-mcp: matching npm package or built source |
webmcp | Browser ESM package with tool manifest and registration helper | Node 22 to build; compatible browser to run | @elysra/tungsten-webmcp and the generated TypeScript SDK |
docs | llms.txt, llms-full.txt, tools.json, README | None beyond the compiler | No runtime dependency |
These targets are implemented in source. Starting with 0.1.3,
compiler and runtime package versions advance together with the release tag.
Generated packages default to compatible 0.1.3 runtime floors; an explicit
runtime setting remains yours to qualify. The earlier 0.1.2 release has
independently versioned non-npm runtime sources. Use the matching source checkout
when a registry artifact is unavailable: source version metadata does not prove publication. Published 0.1.3 packages are available for npm, Python, Rust, Java,
C# and Ruby, and 0.1.2 packages remain available; use the explicit
released-consumer overrides below to stay on 0.1.2. Go also has a
matching-source route for stable consumers. Its v0.1.3
module has a verified Apache-2.0 archive; the older stable-commit
pseudo-version's archive notice differs, as explained in that guide.
Target runtime_path values resolve from the generated package or crate
directory; see the target's installation guidance.
Kotlin, F# and Dart are 0.1.3 targets. They require the 0.1.3 or newer compiler and matching wrapper/core runtime sources; the 0.1.2 compiler does not generate these targets.
Targets and the mock server (tungsten mock) share one IR. Generated-package and contract checks exercise each language, but source availability and passing shared scenarios do not establish complete validation, protocol or distribution parity. Unsupported features can vary by target. Review all compiler diagnostics: --strict rejects warnings, including unsupported if/then/else constraints, but informational diagnostics can still describe other unsupported features. Local checks do not establish live API acceptance or registry installation readiness.
Install
Install the compiler first. The runtime packages below
support generated output; they do not install the tungsten compiler command.
The latest published compiler release is v0.1.3,
published October 19, 2026, and includes HTTP/Git inputs and Python 3.10/3.11
compatibility. This branch can contain changes after that release; see the
Unreleased section of the changelog.
Prebuilt binaries for Linux, macOS and Windows are attached to each GitHub release. The installer checks the archive against the release's SHA256SUMS before it installs anything:
curl -fsSL https://raw.githubusercontent.com/pboachie/tungsten/main/install.sh | sh # Linux and macOS, into ~/.local/bin
irm https://raw.githubusercontent.com/pboachie/tungsten/main/install.ps1 | iex # Windows
Pass --version v0.1.2 to install.sh (or -Version v0.1.2 to install.ps1) to pin a release, and --dir (-InstallDir) to choose the target directory.
To intentionally install using only SHA256SUMS, set
TUNGSTEN_NO_ATTESTATION=1. The installer prints a checksum-only warning and
still rejects checksum mismatches. TUNGSTEN_REQUIRE_ATTESTATION=1 remains an
explicit assertion of the default policy and conflicts with that opt-out;
setting it to 0 does not disable default verification. Both settings accept
only 0 or 1.
TUNGSTEN_REPO, TUNGSTEN_RELEASE_BASE_URL and PowerShell -BaseUrl change
download locations, not trusted signer identities. Mirrors can supply the same
official release bytes for verification. Custom builds or restricted/offline
mirrors without verifiable official provenance need the explicit checksum-only
choice; their origin is not authenticated by a matching checksum. Older tagged
installers retain their released behavior.
On Linux the musl archives (the installer default) are statically linked and
avoid a glibc dependency. Prefer them on older distributions. The published
v0.1.2 gnu archives (TUNGSTEN_LIBC=gnu) require glibc 2.34 on x86_64
and 2.39 on aarch64, as verified from their required symbol versions. Check
your architecture and glibc version before selecting a stable GNU archive:
install.sh currently checks only a 2.34 floor and does not enforce the stable
aarch64 archive's higher requirement. The 0.1.3 release targets
a common glibc 2.34 floor for both architectures; that target does not describe
the published v0.1.2 binaries.
Release archives, the Homebrew formula, the winget manifests and the ghcr.io/pboachie/tungsten container image carry build provenance attestations. To verify them with the GitHub CLI:
gh attestation verify oci://ghcr.io/pboachie/tungsten:0.1.2 --repo pboachie/tungsten
gh attestation verify tungsten.rb --repo pboachie/tungsten
To run the guided tungsten init setup right after installing, pass --init to install.sh (-Init to install.ps1). It needs a terminal, and the installer prints the PATH note first. A cancelled setup leaves the installed binary in place and exits with status 4 (5 when setup fails); run tungsten init again when ready:
curl -fsSL https://raw.githubusercontent.com/pboachie/tungsten/main/install.sh | sh -s -- --init
The irm … | iex form cannot pass -Init. Run the downloaded script as a script block instead, or save it and run .\install.ps1 -Init:
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/pboachie/tungsten/main/install.ps1))) -Init
Or build from source, with Rust 1.95 or newer (the repository pins 1.97.0 in rust-toolchain.toml for development):
git clone https://github.com/pboachie/tungsten
cd tungsten
git checkout v0.1.3 # latest release
cargo install --path crates/tungsten-cli # installs the `tungsten` binary
tungsten doctor # reports optional tools (node, python3, uv, formatters)
Node, Python and the formatters are optional: a missing tool only disables the target or --format option that needs it.
Runtime packages
For a published compiler release and generated client, choose the runtime for the output you use. These package versions were verified on October 20, 2026; Node 22+ is required for TypeScript/MCP, Python needs 3.10+, Java needs 17+, C# needs .NET 10, and Ruby needs 3.3+. Run Python installation commands in an activated virtual environment.
For current source builds, MCP servers require Node 22.13+ (Node 23 requires 23.2+); TypeScript SDKs and WebMCP build tooling retain their Node 22 prerequisite.
| Output | Runtime package | Install the published runtime |
|---|---|---|
| TypeScript SDK | @elysra/tungsten-runtime | npm install --save-exact @elysra/tungsten-runtime@0.1.3 |
| MCP server | @elysra/tungsten-mcp | npm install --save-exact @elysra/tungsten-mcp@0.1.3 |
| Browser WebMCP | @elysra/tungsten-webmcp | npm install --save-exact @elysra/tungsten-webmcp@0.1.3 |
| Python SDK | tungsten-runtime | python -m pip install tungsten-runtime==0.1.3 |
| Rust SDK | tungsten-runtime | cargo add tungsten-runtime@0.1.3 |
| Rust CLI | tungsten-cli-kit | cargo add tungsten-cli-kit@0.1.3 |
| Java SDK | io.github.pboachie.tungsten:tungsten-runtime | mvn dependency:get -Dartifact=io.github.pboachie.tungsten:tungsten-runtime:0.1.3 |
| C# SDK | Tungsten.Runtime | dotnet add package Tungsten.Runtime --version 0.1.3 |
| Ruby SDK | tungsten-runtime | gem install tungsten-runtime --version 0.1.3 |
Verify a TypeScript runtime installation with
node --input-type=module -e 'import("@elysra/tungsten-runtime").then(() => console.log("runtime ready"))',
or Python with python -c 'import tungsten_runtime; print("runtime ready")'.
Then install and build your generated package as its README describes. These
runtime imports do not generate a client or call an API.
Published 0.1.2 packages do not satisfy dependencies on 0.1.3 runtime
capabilities; use the 0.1.3 packages above, or matching runtime source as in the
quickstart below. Go supports matching stable source and the v0.1.3 module. See
the Rust installation and
Go installation options. Runtime libraries do not install
the Tungsten compiler. The runnable gallery
shows complete installation and first-use flows for each output.
Released 0.1.2 consumers
Keep the compiler and generated clients on the released route when deploying
on 0.1.2 instead of the latest release. Pin the installer to v0.1.2 as above and confirm
tungsten --version prints tungsten 0.1.2. Merge these exact runtime settings
into the targets you use in tungsten.yml; your output paths, API package names
and generated package versions remain your own:
targets:
typescript: {out: generated/typescript, runtime: "0.1.2"}
python: {out: generated/python, runtime: "==0.1.2"}
java: {out: generated/java, runtime: "0.1.2"}
csharp: {out: generated/csharp, runtime: "0.1.2"}
ruby: {out: generated/ruby, runtime: "= 0.1.2"}
mcp: {out: generated/mcp, runtime: "0.1.2", sdk_runtime: "0.1.2", sdk_path: "../typescript"}
webmcp: {out: generated/webmcp, runtime: "0.1.2", sdk_runtime: "0.1.2", sdk_path: "../typescript"}
Run tungsten generate ., then follow each generated README to install and
build it. Build the TypeScript SDK before the adapters that reference it.
The 0.1.2 compiler's native runtime defaults predate the 0.1.2
packages, so keep the Java, C# and Ruby overrides explicit. Registry
consumers use those packages without a runtime source checkout.
The stable Rust source recipe
uses the unchanged v0.1.2 checkout for both Rust crates. This source route
remains valid and does not require a 0.1.3 upgrade; the 0.1.3 crates are also
available from crates.io. Newer compiler features require matching runtime source or
the 0.1.3 packages; Python 3.10/3.11 output belongs to the 0.1.3 route. Generated SDK compatibility still needs qualification against
your own API and deployment.
For Go, build the external emitter from v0.1.2 and set runtime_path to that
checkout's runtimes/go; the stable Go recipe
retains its Apache source/license context and avoids the old pseudo-version
ZIP's inherited repository-root notice.
Quickstart
Install the compiler above first. This walkthrough uses Python 3.12 or newer and uv. TypeScript targets require Node 22 or newer. Installing the compiler does not install generated SDKs or their language runtimes.
This walkthrough continues from the 0.1.3 source installation above, using the same
checkout for the compiler and runtime. From that tungsten directory, set
its absolute path and create a separate project. If you installed a release
binary, obtain its matching source archive from the release first:
export TUNGSTEN_SOURCE="$(pwd)"
mkdir ../petstore-demo
cd ../petstore-demo
Use your own openapi.json, or create this complete tiny example:
{"openapi":"3.1.0","info":{"title":"Acme Petstore","version":"1"},"paths":{"/pets":{"get":{"operationId":"listPets","responses":{"200":{"description":"Pets","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}}}}}}}
The walkthrough uses an OpenAPI document, the native input. init --from also accepts Swagger 2.0, Postman collections, saved cURL commands, .http/.rest files, HAR captures and endpoint manifests — one of them, not a bundle — each with its own flags and review steps; see Supported inputs.
The importing guide gives
per-format commands, diagnostic families, saved-command shell dialects, HAR path
review and the supported JSON Schema subset. Imported operations stay unreviewed
until you explicitly review their safety and allowed origins in agent.yml.
init writes tungsten.yml and agent.yml with TypeScript, Python and docs
targets by default. Edit the existing targets block rather than appending a
second one. For this example, replace its Python entry with:
python: { package: acme-petstore, module: acme_petstore, out: generated/python }
Review agent.yml and resolve the TODO entries for operations with side effects
before generating. The tiny example has only a read operation.
tungsten init --from openapi.json
# Edit tungsten.yml and agent.yml as described above.
tungsten check
tungsten generate
uv venv --python 3.12 .venv
# Install the language runtime and generated SDK into this environment.
# The local runtime satisfies the generated package's runtime dependency.
uv pip install --python .venv/bin/python "$TUNGSTEN_SOURCE/runtimes/python" ./generated/python
tungsten mock . --port 8099
Leave the mock running. In another terminal in petstore-demo, make the first
call using the environment where you installed the SDK:
.venv/bin/python - <<'PYTHON'
from acme_petstore import AcmePetstoreClient, Ok
with AcmePetstoreClient(base_url="http://127.0.0.1:8099") as client:
result = client.pets.list()
assert isinstance(result, Ok), result
print(result.value)
PYTHON
The tiny example returns a successful list. For your own spec, the client class,
resource and method names follow its title and operation IDs. Calls return a
Result; API and transport errors carry a diagnostic envelope. When installing
a generated TypeScript SDK, build its matching source runtime first with
npm ci && npm run build in runtimes/ts, then install that directory and the
SDK's dependencies in the generated package and run npm run build. The Python
route above works without assuming runtime registry publication.
Destructive operations use the preview flow. From the TypeScript SDK generated for the ZROtext pilot:
const preview = await client.public.webhooks.disable.preview({ endpointId });
if (preview.ok && preview.value.confirmation_token) {
console.log(preview.value.effects);
await client.public.webhooks.disable({ endpointId }, { confirm: preview.value.confirmation_token });
}
Redirects default to bounded same-origin reads; mutations never follow redirects
under any policy. Set defaults.redirects: none in agent.yml, or the SDK client's
redirects option to none, to follow no redirect at all. A 3xx the operation
declares (exactly or by class) is still its success response; a 3xx it does not
declare fails as UNEXPECTED_RESPONSE without a second request or retry.
Either none setting wins: client options cannot relax a manifest restriction.
Rust and C# require the runtime-owned HTTP client for this policy; omit a custom
http_client/HttpClient. Custom fetch/transport callbacks must honor the runtime's
no-follow contract. Upgrade runtimes together with generated clients; older
runtimes fail explicitly when a generated client requires this capability.
Python's ClientOptions.timeout_ms covers each native HTTP attempt through headers
and the complete ordinary body, with cancellation cleanup joined before capacity
is released. It is not an overall deadline across retries. Streaming bodies use
the idle timeout after successful headers. Custom transports must cooperate;
uninterruptible callbacks retain capacity until completion and late results are
rejected, without a hard settlement deadline. OS resolver cancellation depends on
the platform.
More examples: the runnable example gallery covers first SDKs, supported input routes, local mocks, destructive confirmation and CI/surface review workflows. Typed Python SSE shows how to declare or overlay an incomplete stream response and consume named events with sync/async cleanup. Response-contract quality shows the opt-in audit and reviewed schema overlays without inferring guaranteed types. Tungsten on six public APIs uses the public OpenAPI descriptions of Stripe, GitHub, Twilio, OpenAI, Kubernetes and Discord to show diagnostics, MCP listing sizes and generated SDK code in TypeScript, Python and Rust, reproducible with one script. The external Markdown emitter shows how to write an external emitter.
An external: target in tungsten.yml names a command that tungsten starts as a process, unsandboxed and with your privileges. It runs on every command that produces output in memory, not only on a writing generate: generate --dry-run and --check, check --ci, diff and report run it too (plain check and ir dump do not). A CI job that runs tungsten check --ci on pull requests therefore executes whatever the pull request puts in tungsten.yml. Pass --no-external or set TUNGSTEN_NO_EXTERNAL=1 to skip external targets (reported as TG0807) when the manifest is not trusted.
Hosts can explicitly select stricter external-emitter constraints with both
--policy PATH and --policy-digest blake3:<64 lowercase hex digits>. First review
a local JSON document, for example:
{"tungsten_policy":1,"external":{"deny":true,"timeout_ms":10000,"max_output_bytes":1048576}}
Run tungsten policy digest PATH separately to validate and hash those exact
bytes; it prints the core BLAKE3 digest and writes no files. Execution never
creates or updates a pin. A relative policy path resolves against invocation cwd.
There is no automatic discovery, environment selection, include, interpolation,
URL fetch or replay from exported configuration. Selected symlink/reparse entries,
nonregular files and unsupported local namespaces are refused. Capture reads one
regular handle once, with a 64 KiB byte limit and nesting limit eight; strict JSON
rejects duplicate/unknown members, null, trailing data and empty constraints.
deny is a boolean; timeout is 1..=3,600,000 ms and output is 1..=2^40 bytes,
subject to platform representation. Missing constraints add no restriction.
| Command | Supplied execution policy |
|---|---|
generate (write, check, dry-run), check (including CI), report, diff, emitters | Capture and enforce before external run/descriptor probes |
config | Capture and inspect, without acquiring API inputs or running tools |
policy digest | Reject execution-policy flags; validate/hash only its named file |
doctor, init/wizard, scenario, lsp, mock, ir, overlay, explain, capabilities, schema, any unlisted command | Reject supplied policy before reads or command effects |
--help, --version | Parser-owned; no policy read |
Embedding hosts select immutable CapturedPolicy documents with expected digests,
then a fresh InvocationPolicy for each invocation. CliEnv.policy intersects
the CLI selection instead of replacing it; CompileOptions.policy stays outside
editor overrides. At most 16 submitted documents and 1 MiB of captured bytes are
accepted, counting duplicates. Denials combine by OR and ceilings by minimum;
false or a weaker later document cannot undo a restriction. Config inspection
reports opaque policy[N] sources, exact digests, known pointers and all contributing
constraints, including ties, without physical paths or replayable authority.
Absent policy retains existing behavior and is reported as absent; a permissive
selection is never approval. Prepared IR does not retain a fallback context.
Long-lived hosts must explicitly recapture/revalidate pins for new invocations.
Library callers must migrate external::run and external::describe to supply
&InvocationPolicy and raw RequestedExternalLimits; a precomputed Limits
cannot substitute for context. Select InvocationPolicy::absent() explicitly
only when legacy behavior is intended. Keep missing/default requested values as
None, rather than converting them to explicit defaults that could exceed a
protected ceiling. Exhaustive CliEnv/CompileOptions literals also need their
new optional policy field (or ..Default::default()).
Explicit project timeout/output values above a protected ceiling fail (TG0810)
before input acquisition or external descriptor negotiation. Missing/null project
limits use existing defaults, then clamp to the ceiling. Descriptor probes use
their own 5 s/1 MiB defaults, also clamped. Generation requests advertise the
effective output cap. Denied execution is TG0811 and fails the requested operation;
--no-external remains an independent unconditional TG0807 skip. Invalid captures
or mismatched pins are TG0809. tungsten schema execution-policy publishes the
strict document shape.
These are per-external-operation limits, not whole-command time or heap limits. The exact pinned capture is authoritative for that invocation; canonical paths are local provenance, not replacement-safe executable identity. Restrictions do not verify parent symlinks/junctions, mounts or mapped-volume locality; a selected regular file can reside on network-backed storage, and OS file operations are not hard real-time bounded. They do not approve executables, minimize inherited environment, revoke running work, protect acquisition Git/providers, doctor tools, setup/package managers or scenario subprocesses, or isolate filesystem/network access. Policies do not establish a sandbox.
External emission and --describe own a Unix process group or Windows Job Object.
Leader exit, timeout and output overflow trigger group/job termination and leader
reaping. timeout_ms includes process launch, pipe work and cleanup; one quarter,
up to one second, is reserved for cleanup. OS calls and scheduling can exceed that
budget. Zero or unrepresentable timeouts refuse execution. Each launch reserves
four of 16 process-wide worker slots. Unfinished workers retain
their handles and slots until they finish and a later invocation joins them;
capacity exhaustion refuses before execution. TG0803 reports incomplete cleanup
and accepts no files. Investigate remaining emitter processes before retrying.
Unix descendants can escape their group or pass pipes elsewhere; these lifecycle
controls do not establish that every descendant stopped, approve an executable,
filter inherited credentials or isolate filesystem/network access. Library
embeddings must exclusively reap their external children and must not auto-reap
children or change SIGCHLD during execution.
On Linux, an unreadable /proc/self/status or an ignored/caught SIGCHLD disposition
refuses external execution before launch. That check cannot detect every signal
flag or competing reaper; the embedding ownership requirement still applies.
The same opt-out disables tungsten emitters discovery, including --describe
probes of executables on PATH. Its empty result means discovery was disabled;
it does not establish that no emitters are installed. Without the opt-out,
discovery executes those programs and requires the same trust as generation.
Python interpreter compatibility
Python targets default to Python 3.12+. To generate a client for Python 3.10
or 3.11, set a quoted python_version in targets.python:
targets:
python:
python_version: "3.10"
Supported values are "3.10", "3.11" and "3.12" (the default). Both
Pydantic and models: dataclasses support these modes. Compatibility output
uses typing_extensions aliases and retains forward references, validation
and transport behavior. The matching runtime supports Python 3.10 and newer;
compatibility clients require tungsten-runtime>=0.1.3,<0.2.0, including when
an explicit runtime specifier is supplied. A runtime_path checkout must
contain this compatibility support. Publishing the matching runtime remains
part of the coordinated release.
Architecture
- The frontend reads OpenAPI 3.0 and 3.1, resolves references and applies overlays. The other supported inputs (Swagger 2.0, Postman, saved cURL,
.http/.rest, HAR, endpoint manifests) are converted offline to a normalized OpenAPI document first;initwrites it asimported.openapi.jsonand the frontend reads it like any OpenAPI document. - The IR is a versioned JSON document (
tungsten ir dump, schema viatungsten schema ir). - The agent compiler merges
agent.ymlinto it: safety tiers, idempotency, confirmation, remediation text, verification hooks, macros and the disclosure mode for MCP. - Emitters (
crates/tungsten-emit-*) write each target from the IR. They are pure functions of their inputs. - Runtimes (
runtimes/) hold the behaviour shared by generated code: validation, auth, retries, idempotency stores, the envelope, previews, pagination and middleware.
Repository layout: crates/ is the compiler (AGPL-3.0-only); runtimes/ts, runtimes/mcp, runtimes/webmcp, runtimes/python, runtimes/rust, runtimes/go, runtimes/java, runtimes/kotlin, runtimes/csharp, runtimes/fsharp, runtimes/dart and runtimes/ruby contain the libraries generated code depends on (Apache-2.0).
Licensing
- The compiler (
crates/) is licensed under AGPL-3.0-only. - The runtime libraries that generated code depends on (
runtimes/) and the external Go emitter (emitters/go) are licensed under Apache-2.0. - Output generated by tungsten is not a work covered by the AGPL and carries no licence from tungsten. The owner of the API description chooses the licence of the generated code.