Skip to content

Lasm 0.9.0

Choose a tag to compare

@github-actions github-actions released this 18 Nov 00:16
· 122 commits to main since this release
d3229b7

Lasm 0.9.0

A minor release with many breaking changes: the first release of Stage 0, which settles Lasm's public API before 1.0. Upgrade with npm install -D @lasm/cli@0.9.0; ^0.8.0 does not pick it up. Every breaking change has a migration note below, under "Breaking changes and migration".

What breaks: the function platforms (AWS Lambda and Lambda@Edge, Vercel, Netlify, Azure Functions, Google Cloud Functions) no longer run an HTTP server inside the function; the program publishes a fetch handler with exportDefault and the generated platform file calls it directly (#222). The fetch and hono templates write one entry module per serving model, the Lambda container image is Lambda's own Node image, and HTTP on WASI is wasi-http only (#322); the fullstack template speaks plain REST and keeps its todos through each platform's own store (#331, #344). Lasm.RPC is deleted (#341). On the CLI, lasm build takes one Lean source and names its output only with --output, --output names the package on function platforms, lasm version is gone, and lasm init --deploy lambda now writes the .zip setup (#304, #316). The generated bindings follow one set of rules, which renames two FormData methods and makes Node's integer arguments Nat (#301). Lasm.UI is cut to its core: its HTTP, storage, focus, title and other browser commands are gone, and effects go through Cmd.task with the generated browser bindings (#311). Lasm.JS.Web is the whole web platform, one module per spec with no umbrella module, and Lasm.JS.Web.Browser is gone (#319); lasm build --target refuses a web API the target lacks unless the program checks for it with the API's guard X? (#319, #337); Lasm.JS.Node, Lasm.JS.Deno, Lasm.JS.Bun and Lasm.JS.Cloudflare have no umbrella modules either, so every program imports the binding modules it uses (#317, #320, #329). A few generated names change (#301, #307, #312, #317, #319, #320).

What's new: Node.serve, a Lean server on Node shaped like Bun.serve, with no npm dependencies (#222); Lasm.JS.Cloudflare, every API of Cloudflare Workers' own declarations (KV, D1, R2, Durable Objects, Queues, Workers AI, Vectorize, Hyperdrive and the rest), with the Worker's env typed (#216, #320); Lasm.JS.Node is every documented Node core module, with typed event listeners (#220, #317); the whole web platform from Lean: IndexedDB, WebGL, WebGPU, Web Audio, WebRTC and every other spec of webref (#319); Lasm.JS.Deno and Lasm.JS.Bun are the whole Deno and Bun namespaces, with Deno KV, bun:sqlite and WebSockets in Bun.serve (#307, #312); Lasm.JS binds the project's own JavaScript files and defines JavaScript classes from Lean (#309); checked downcasts (I.cast?) on every generated interface (#301); helpers for whole bodies and responses in Lasm.WASI.Http (#306). Generated binding modules outside a small core set now ship as Lean source and compile on first import, so the package does not grow with them (#313, #321), and Lake builds them in the editor too (#332).

Lasm.Fetch and Lasm.KV still ship in 0.9.0; their removal is decided and follows in a later release. Every API decision is recorded, with its alternatives, in docs/API_DECISIONS.md and the per-milestone files in docs/api/decisions/, each pending Jordan's sign-off at the end of its milestone.

Breaking changes and migration

Function platforms call the program's fetch handler directly (#222)

  • lasm package and lasm build --target netlify|vercel|lambda|lambda-edge|azure|gcf
    no longer run an HTTP server.
    The program publishes a fetch handler with
    Lasm.JS.exportDefault, as on Cloudflare Workers. The platform file that
    Lasm generates exports the handler the platform expects and calls it in the
    same process: there is no $HOST/$PORT server, no free port and no
    loopback forwarding.

    • Netlify: export default async (request, context) => ….
    • Vercel and Google Cloud Functions: Node's (req, res) as a web Request,
      with the Response streamed back.
    • AWS Lambda and Lambda@Edge: each event shape as a Request, and the
      Response as the event's result.
    • Azure Functions: the Request, and the Response as HttpResponseInit.

    The security fixes stay in place: the Host checks, the Cookie and
    Set-Cookie handling, base64 bodies, __proto__ header names, decoded paths,
    and empty replies (#80, #82).

  • What breaks: a program that brings its own HTTP server (Express,
    Fastify, Std.Http, or Node.serve) can no longer be packaged for a
    function platform. Port it to a fetch handler:

    Before Now
    main listens on $HOST:$PORT (Express, Hono on @hono/node-server, Std.Http) def main : IO Unit := exportDefault handle, with handle : Request → Async Response (or exportDefault app for a Hono app)
    src/serverless/lasm-server.mjs in the package lasm-function.mjs and lasm-node-serve.mjs

    Repeated response fields other than Set-Cookie now reach Lambda REST and ALB
    multi-value replies joined (x: p, q), as a web Response holds them. A
    handler that throws is answered with a 500. A request that no web Request
    can hold (TRACE, CONNECT, the target *) is answered with a 400.

Templates serve with one entry module per platform kind (#322)

  • lasm init --template fetch writes Handler.lean (the handler),
    Main.lean (Node: Node.serve { fetch := Handler.handle }) and
    Export.lean (exportDefault Handler.handle, built by build:bun,
    build:deno and every edge and function-platform build:<target>). It no
    longer imports Lasm.Fetch, and no program branches on Lasm.JS.onEdge.

  • lasm init --template hono writes Routes.lean (the Hono app),
    Main.lean (Node, @hono/node-server) and Export.lean
    (exportDefault (← Routes.app)).

  • The function platforms (--deploy lambda, lambda-container, lambda-edge,
    vercel, netlify, azure, gcf) take the fetch and hono templates.
    express, fastify and std-http bring their own server, so they have no
    --deploy target: they run wherever their Dockerfile runs.

  • --deploy lambda-container's Dockerfile.lambda is Lambda's own Node 24 image with
    the .zip package's files and CMD ["lasm-lambda.handler"]: the runtime calls
    the handler Export.lean publishes. The AWS Lambda Web Adapter (which ran a
    server inside the function) is gone, with deploy/lambda/Dockerfile.

  • --deploy wasi is for the plain template (command-line programs). The
    fetch template's Cgi.lean is gone: HTTP on WASI is wasi-http
    (--deploy wasi-http, spin).

  • lasm init --template fullstack speaks plain REST (#331). The
    server answers GET/POST /api/todos, PATCH/DELETE /api/todos/ID
    (JSON in and out, {"error"} on 4xx) instead of POST /rpc/<name>, and the
    browser app calls it with the web's fetch through Cmd.task. The template
    no longer imports Lasm.RPC or Lasm.Fetch: Server.lean serves Node with
    Node.serve, Export.lean publishes the default export for Bun, Vercel
    Edge and Netlify Edge, Fastly.lean and WasiHttp.lean serve their
    platforms, and Http.lean, Embed.lean and Site.lean are the template's
    own code. It has a program per store, each through the platform's own API,
    and no Lasm.KV (#344): Workers.lean takes the Worker's bindings as a
    typed Env (TODOS : KVNamespace; wrangler.toml declares the binding),
    Deno.lean uses Deno KV, Fastly.lean the Fastly KV Store TODOS; Node,
    Bun, Vercel Edge, Netlify Edge and wasi-http keep them in memory. A declared
    store that is missing is an error naming it, never a silent fallback to
    memory. build:workers builds Workers.lean, and build:deno and
    build:deno-deploy build Deno.lean. The
    store still takes only validated titles: ValidTitle, a title with its
    proof. Migrating a project made by 0.8.0: replace the Endpoint definitions
    with routes in a match on method and path segments, and each e.call with
    a Cmd.task that calls Lasm.JS.Web.fetch, as the new template does.

Migrating a project made by 0.8.0's fetch template:

Before Now
Main.lean: handle, then if ← onEdge then exportDefault … else serveNode Handler.lean: handle; Main.lean: def main := Node.serve { fetch := Handler.handle }; Export.lean: def main := exportDefault Handler.handle
"build:workers": "lasm build Main.lean --target workers" (and the other edge, Bun, Deno and function targets) lasm build Export.lean --target …
Cgi.lean, "build:wasi" WasiHttp.lean, "build:wasi-http"

The CLI (#304, #316, #318)

  • lasm build takes one Lean source; the output is named only with
    --output
    (0.7-2). lasm build Main.lean dist now
    fails with Unexpected argument "dist": lasm build takes one Lean source. Name the output with --output. Migration: lasm build Main.lean dist →
    lasm build Main.lean --output dist.
  • With a function platform, --output names the package (0.7-5).
    lasm build Main.lean --target lambda --output app.zip writes
    app.zip; before, --output named the Node build and the package went to
    its default place. As with the edge, WASI and browser targets since 0.5.0,
    the Node build a package is made from now stays in the build cache
    (.lake/lasm/), so lasm build --target lambda (lambda-edge, vercel,
    netlify, azure, gcf) no longer writes dist/. Migration: drop
    --output to keep the default package place, or pass the package's path;
    to also keep a Node build, run lasm build Main.lean (writes dist/) and
    lasm package --target lambda.
  • lasm version is gone; lasm --version and lasm -v print the
    version
    (0.7-1). Migration: lasm version → lasm --version.
  • lasm init --deploy lambda writes the Lambda .zip setup
    (npm run build:lambda, which was --deploy lambda-zip); the container image
    (Dockerfile.lambda) is now --deploy lambda-container (0.7-9). Every
    --deploy name is now the lasm build --target it builds, except
    lambda-container and spin. Migration: --deploy lambda-zip →
    --deploy lambda; --deploy lambda → --deploy lambda-container. Existing
    projects are unchanged (lasm init writes files once).
  • The same option rules in every command (0.7-23): lasm dev refuses --dev
    with --release (Choose one of --dev and --release) and a repeated
    --target, --port, --host or --output (Specify --port only once), as
    lasm build does; lasm init refuses a repeated --template. An unknown
    lasm dev --target, lasm init --template or lasm init --deploy value
    names the closest one, as lasm build --target does:
    lasm dev --target worker → … not "worker" (did you mean --target workers?).
    Migration: give each option once.
  • lasm build lasm.json is refused as not a Lean source (0.7-15,
    #318): Expected a Lean source file (Main.lean), not lasm.json, like any
    other non-.lean input. The lasm.json pipeline was retired on 2026-11-03;
    only its stale message is gone. No migration: such builds already failed.

Generated bindings follow one set of rules (#301)

  • One set of rules for every generated binding
    (docs/BINDING_RULES.md, API decisions A9–A12).
  • FormData.appendWithBlobValue is now FormData.appendBlob, and
    FormData.setWithBlobValue is now FormData.setBlob (A9.1). Migration:
    rename the calls.
  • In Lasm.JS.Node, a documented {number} that is an integer is now Nat
    (or Int for pid) instead of Float (A11.1). Migration: pass whole
    numbers (crypto.randomBytes 32, not 32.0). This affects:
    • crypto.randomBytes, crypto.pbkdf2, crypto.hkdf and crypto.scrypt
      (sizes, key lengths, iterations, and ScryptOptions);
    • process.kill's pid (Int);
    • FileHandle.fd;
    • the uid, gid, timeout and maxBuffer options of child_process;
    • highWaterMark in the stream options.

Lasm.JS.Web is the whole web platform, one module per spec (#319)

  • Lasm.JS.Web is the whole web platform, one module per spec, and
    Lasm.JS.Web.Browser is gone
    (decisions 0.3-1, 0.3-2, 0.3-18). Every spec
    of w3c/webref is generated as it is, and each spec is the module
    Lasm.JS.Web.<Spec>. There is no umbrella module. Migration: names do not
    change; imports do:

    Before Now
    import Lasm.JS.Web (the WinterTC subset) the modules you use: import Lasm.JS.Web.Fetch, Lasm.JS.Web.Url, Lasm.JS.Web.Dom (events, AbortController), Lasm.JS.Web.Webcrypto (crypto), Lasm.JS.Web.Html (timers, atob, structuredClone, navigator, MessageChannel), Lasm.JS.Web.Streams, Lasm.JS.Web.Encoding, Lasm.JS.Web.FileAPI (Blob), Lasm.JS.Web.Xhr (FormData), Lasm.JS.Web.Webidl (DOMException)
    import Lasm.JS.Web.Browser import Lasm.JS.Web.Dom and Lasm.JS.Web.Html (the tree, the elements, the window, canvas 2D), Lasm.JS.Web.Uievents, Lasm.JS.Web.Cssom, Lasm.JS.Web.Geometry, Lasm.JS.Web.Websockets, …
    import Lasm.JS.Web.Messaging, .Timers, .Global import Lasm.JS.Web.Html
    import Lasm.JS.Web.File, .Crypto, .Performance, .Wasm, .WebSocket .FileAPI, .Webcrypto, .HrTime, .WasmJsApi, .Websockets

    The members the browser tier had left out, or that are in other specs, are
    now there too (CanvasRenderingContext2D.filter, Element.animate,
    Navigator.clipboard).

  • lasm build --target X refuses a web API that X does not provide
    (decision 0.3-10), with an error that names the API, the target and where it
    is available, from @mdn/browser-compat-data (browsers, Node, Deno) and
    runtime-compat data (Bun, Workers, Vercel Edge, Netlify Edge). A program that
    used, say, document in a server build now fails to build instead of
    failing when it runs.

  • Web enums are strings with named values (decision 0.3-17). RequestMode,
    KeyUsage and every other WebIDL enum is
    structure E where unsafeOfString :: val : String, with one match pattern
    per value (.noCors). Equality and construction are unchanged
    ((← res.type) == .basic). Migration: a match on an enum needs a final
    | _ => …, because a runtime may return a value newer than the pinned IDL,
    which now reads as it is instead of failing.

  • Lasm.JS.Web.Support's helpers moved to Lasm.JS.Web.Internal
    (decision 0.3-3). They are internal to the generated bindings: use
    Lasm.JS directly. Lasm.JS.Web.Record is unchanged.

  • An overload that differs only in its argument types is named after them
    (A9.2): RTCDataChannel.sendWithBlob, sendWithArrayBuffer.

Lasm.JS.Node, Lasm.JS.Deno, Lasm.JS.Bun and Lasm.JS.Cloudflare have no umbrella modules (#317, #320, #329)

  • import Lasm.JS.Node, import Lasm.JS.Deno, import Lasm.JS.Bun and
    import Lasm.JS.Cloudflare are gone
    (0.4-21 and the 0.4 and 0.5
    decisions). Import the modules whose members you call, and a program
    compiles and links only those:
    • Node: import Lasm.JS.Node.Fs, .Path, .Crypto, .Http, …
    • Deno: import Lasm.JS.Deno.Serve for Deno.serve, import Lasm.JS.Deno.Kv
      for Deno KV, …
    • Bun: import Lasm.JS.Bun.Serve for Bun.serve, import Lasm.JS.Bun.Sqlite
      for bun:sqlite, …
    • Cloudflare: import Lasm.JS.Cloudflare.Kv, .D1, .Workers, .Handlers
      (ExportedHandler), .Queues (the queue handler), …
  • Lasm.JS.Node: crypto.randomUUID (and getRandomValues, subtle)
    moved to Lasm.JS.Web: import Lasm.JS.Web.Webcrypto, then
    (← Lasm.JS.Web.crypto).randomUUID. Buffer.from s (some "hex") is
    Buffer.fromWithString s (some "hex") (Buffer.from has four documented
    forms: fromWithString, fromWithArrayBuffer, fromWithBuffer,
    fromWithObject). Other names whose documented form gained overloads follow
    the same rule; scripts/bindings/node-surface.json lists every generated
    name.
  • Lasm.JS.Cloudflare: overloads with the same parameter names give the
    plain name to the least constrained one (R2Bucket.get key (options?)), and
    overloads are named for what they do (0.5-17, #336): KVNamespace.getMany
    (and getManyText, getManyJson, getManyWithMetadata…) read several keys
    at once; Ai.run is the common call, and runStream, runWebSocket,
    runRawResponse and runOtherModel are its other forms;
    AiSearch*.chatCompletionsStream, ToMarkdownService.transformMany,
    Ai.toMarkdownFile/toMarkdownFiles and
    WorkflowStep.doWithDelayFunction/doWithStaticDelay complete the set.

Lasm.UI is cut to its core; browser effects go through Cmd.task (#311)

  • Cmd.task (run : Async Msg) runs any action with the generated browser
    bindings (import Lasm.JS.Web.Dom, Lasm.JS.Web.Html, Lasm.JS.Web.Fetch, …) and delivers its message;
    Lasm.UI.afterFrame waits for the next frame. Cmd.delay, Cmd.pushUrl and
    Cmd.replaceUrl stay (0.6-8, A35). Migration:

    Before After
    Http.get url .loaded Cmd.task do let r ← Lasm.JS.Web.fetch (.usvString url); return .loaded (← r.text) (catch errors with try … catch)
    Http.post url body h, Http.request req h the same, with some { method := some "POST", body := some (.usvString body), headers := … }
    Cmd.storageSet k v Cmd.ofEffect (.task fun _ => do (← Lasm.JS.Web.localStorage).setItem k v)
    Cmd.storageGet k h Cmd.task do return h (← (← Lasm.JS.Web.localStorage).getItem k)
    Cmd.storageRemove k … (← Lasm.JS.Web.localStorage).removeItem k
    Cmd.focus id, Cmd.blur id Cmd.ofEffect (.task fun _ => do afterFrame; …getElementById id… .focus) (docs/UI.md, "Commands")
    Cmd.title t … (← Lasm.JS.Web.document).setTitle t
    Cmd.port name v … (← Lasm.UI.Mount.port name).send v
    Cmd.now h, Cmd.randomBytes n h Cmd.task with Date.now / crypto.getRandomValues, or Lean's IO.monoMsNow / IO.getRandomBytes
    Cmd.back n, Cmd.forward n, Cmd.load url history.go, location.assign through Cmd.ofEffect (.task …)
    Cmd.io run Cmd.ofEffect (.task fun deliver => run deliver)

    Apps that want to test their effects declare them as data and interpret
    them (docs/UI.md, "Effects you can test"; examples/ui/todomvc).

Lasm.JS.Deno and Lasm.JS.Bun (#307, #312)

  • Lasm.JS.Deno.TlsCertifiedKeyPemKeyFormat is now
    Lasm.JS.Deno.ServeTcpTlsOptionsKeyFormat (the type of
    ServeTcpTlsOptions.keyFormat; its constructor .pem is unchanged).
  • Lasm.JS.Deno.NetAddr moved from Lasm.JS.Deno.Serve to Lasm.JS.Deno.Net
    (import Lasm.JS.Deno.Serve still brings it).
  • Deno.utime, utimeSync and FsFile.utime take Data for the times (a
    number of seconds or a Date): toJS (1000000 : Float). A union with an
    object member (number | Date) is now Data.
  • Lasm.JS.Bun.ServeOptions.fetch is optional (Option ServeOptionsFetch): a
    value still coerces ({ fetch, port := … } compiles unchanged).
    ServeOptions gains routes, websocket, unix, tls, development and
    the http1/http2/http3 flags.

Lasm.RPC is deleted (#341)

  • Lasm.RPC, Lasm.RPC.Core, Lasm.RPC.Server and Lasm.RPC.Client are
    gone
    (API decision 0.6-13), with docs/RPC.md, their 13 proved propositions
    and 4 candidates (library/PROOFS.md) and the lean-rpc fuzz target. A server
    and a browser app share plain Lean types and talk plain REST over each
    host's own fetch API. Migration, as lasm init --template fullstack now
    does it (templates/fullstack):
    • server: replace each Endpoint and Endpoint.serve with a route, a
      match on the request's method and path segments (GET/POST /api/todos,
      PATCH/DELETE /api/todos/ID) that reads the JSON body, validates it once
      and hands the handler the validated value as a subtype
      (ValidTitle := { t : String // checkTitle t = .ok () }), answering JSON
      and {"error"} with a 4xx status when validation fails;
    • browser: replace each e.call req onResult with a Cmd.task that calls
      Lasm.JS.Web.fetch and decodes the answer with FromJson;
    • for request bodies from the network, use a parseJson that refuses
      exponents of more than four digits (Lean's parser computes
      10 ^ exponent), as the template's Shared.lean and the examples'
      SafeJson modules do.

Lake projects require Lasm's library as a package (#332)

  • A Lake project requires Lasm's library as a Lake package (decision 0.3-7).
    lasm init writes this in the templates that use the library, and
    npx lasm editor adds it to an existing project:

    [[require]]
    name = "lasm"
    path = ".lake/lasm-library"

    Every lasm command also writes Lasm's package into lake-manifest.json, as
    lake update does, keeping the project's other packages (#338).
    Migration: run npx lasm editor once in an existing Lake project to add the
    require. On a fresh clone, run any lasm command once (npm run dev,
    npx lasm editor) before a plain lake build.

Lasm.WASI.Http exports respond (#306)

  • Lasm.WASI.Http now imports Lasm.WASI.Http.Respond, which defines
    respond and the other helpers below. Migration: a program that defines its
    own top-level respond while open Lasm.WASI.Http renames it or refers to
    it with its namespace.

New

Node.serve (#222)

  • Node.serve (import Lasm.JS.Node.Serve) serves a Lean
    Request → Async Response on Node: Node.serve { fetch := handle, port := some 3000 }.
    It is provided by Lasm, not a Node API, and shaped like Bun.serve.
    • Options: fetch, port, hostname, signal, onListen, error.
    • Server handle (passed to onListen): hostname, port, url,
      stop, finished.
    • Lifetime: it returns once the server stops (stop, the signal,
      SIGTERM or SIGINT).
    • Behavior: bodies stream both ways with backpressure, and a client that
      goes away aborts request.signal. Each Set-Cookie line is sent on its
      own. HEAD and null-body statuses send no body. An empty body is sent with
      content-length: 0 and no content type added. A forged Host cannot change
      the request's URL.
    • Dependencies: none from npm.
  • Typed exportDefault: exportDefault handle takes a Lean function
    directly, and any ToJS value (it took a Value), so a handler object such
    as an ExportedHandler can be published as it is. exportDefault (v : Value)
    still works.

Lasm.JS.Cloudflare, Cloudflare Workers' runtime APIs (#216, #320)

  • Lasm.JS.Cloudflare.* (import Lasm.JS.Cloudflare.Kv, .D1, .Workers, …) binds the runtime APIs of Cloudflare
    Workers, generated from Cloudflare's own TypeScript declarations
    (@cloudflare/workers-types 5.20261019.1, pinned by hash): Workers KV
    (KVNamespace), D1 (D1Database, prepared statements, batches, sessions),
    R2 (R2Bucket, objects, ranges, conditions, checksums, multipart uploads),
    Durable Objects (namespaces, ids, stubs, DurableObjectState and its
    storage, transactions and alarms), Queues (Queue.send, sendBatch;
    MessageBatch and Message in the queue handler), the handler's
    ExecutionContext (waitUntil, passThroughOnException), the Cache API
    (caches), TCP sockets (connect of cloudflare:sockets) and env of
    cloudflare:workers. Lasm.JS.Web's Request, Response and streams are
    their web types. A Worker publishes an ExportedHandler with fetch,
    scheduled and queue:

    import Lasm.JS
    import Lasm.JS.Cloudflare.Kv
    import Lasm.JS.Cloudflare.Workers
    import Lasm.JS.Cloudflare.Handlers
    open Lasm.JS Lasm.JS.Web Lasm.JS.Cloudflare
    
    structure Env where
      KV : KVNamespace     -- wrangler.toml: [[kv_namespaces]] binding = "KV"
      deriving FromJS
    
    def main : IO Unit := do
      let fetch ← ExportedHandlerFetchHandler.ofFn fun _request (env : Env) ctx => do
        let hits := ((← env.KV.get "hits").bind String.toNat?).getD 0
        ctx.waitUntil (← Async.toPromise (env.KV.put "hits" (.domString (toString (hits + 1)))))
        Response.new (some (.usvString s!"{hits + 1}")) none
      let scheduled ← ExportedHandlerScheduledHandler.ofFn fun controller (env : Env) _ => do
        env.KV.put "last-cron" (.domString (← controller.cron))
      exportDefault ({ fetch := some fetch, scheduled := some scheduled } : ExportedHandler)

    The handlers receive the Worker's env typed: the program declares its
    bindings as a structure with deriving FromJS, and each handler's ofFn takes
    it as a type parameter (Data also works). Build with
    lasm build Main.lean --target workers. A Durable Object's
    class stays a few lines of JavaScript that call Lean functions. Guide,
    coverage and mapping rules: docs/JS_BINDINGS.md, "Cloudflare Workers:
    Lasm.JS.Cloudflare". Tested under wrangler dev with local emulation only.

  • Every API of Cloudflare's own in @cloudflare/workers-types is
    generated (#320), 838 declarations in 24 modules: besides KV, D1, R2,
    Durable Objects and Queues, also Workers AI with every model's inputs and
    outputs (Lasm.JS.Cloudflare.Ai), AI Gateway and AI Search, Vectorize,
    Hyperdrive, Images, Email, Tail Workers and tracing, Containers, Workflows,
    service bindings and RPC, Browser Rendering, Analytics Engine, Stream,
    HTMLRewriter and the other bindings. Support, Kv, D1 and Workers
    ship compiled; the others compile on first import.

  • Lasm.JS.Async.toPromise : Async α → IO Value starts a Lean Async
    computation and returns a JavaScript promise of its result, for APIs that take
    a promise of running work (Workers' ctx.waitUntil, state.waitUntil).

  • The Workers entry forwards cron triggers, queue batches and the other
    events.
    The generated workers/worker.mjs now exports scheduled,
    queue, email, tail, trace, tailStream, connect and test besides
    fetch, calling the published object's methods of those names (a handler
    without them fails those events with a message saying so), and imports
    cloudflare:workers and cloudflare:sockets for Lasm.JS.Cloudflare.

Lasm.JS core (#309)

  • Bind your own JavaScript files (A6.1):
    @[js "./ffi/stream.mjs" "writeAndEnd"] names an ES module of the project,
    relative to the Lean file, and lasm build ships it, with the files it
    imports by relative path, on every target. A local file: npm package used
    only for this can become a project file.
  • JavaScript classes from Lean (A6.2): Lasm.JS.Class.define (import Lasm.JS.Class) makes a real class Name extends Base whose constructor,
    methods and getters are Lean functions given this, for APIs that take a
    class (customElements.define, Error subclasses).
  • Functions made with Function.ofFn report their length (A4).
    ofFn, ofFnReply and ofSyncFn take (length := 0); ofFn1 reports 1,
    ofFn2 and ofSyncFn2 report 2. APIs that read a function's length now
    work with Lean handlers: Deno.serve passes its request to an
    ofFn1/ofFn2 handler, and Function.ofFn (length := 4) is an Express
    error handler. A program that relied on ofFn1 or ofFn2 reporting 0
    passes Function.ofFn instead.
  • The binding check only warns about a global the build's target provides
    (A5). @[js "globalThis" "Deno.serve"] and other globals that Node lacks
    now build for --target deno, bun, the edge targets and browser, with a
    warning; a Node build still fails on them.

Standard bindings: Node, Deno and Bun (#220, #307, #312)

  • Lasm.JS.Node is every Node core module (#317; decisions 0.4-33 to
    0.4-38): all of Node's documented modules (zlib, dns, tls, http2,
    worker_threads, util, v8, vm, sqlite, readline, node:test, …),
    the callback and synchronous forms of node:fs, and Experimental,
    Deprecated and Legacy members (marked in their doc comments), plus what only
    Node 26 documents (marked "Node.js 26 and later"). Example:
    examples/node-core. The core set (fs, path, os, process, buffer,
    crypto, child_process, events, stream, with async_hooks, net and
    readline) ships compiled; every other module compiles on first use.
  • node:net, node:http and node:https (#220):
    import Lasm.JS.Node.Net, .Http, .Https gives
    net.createServer, net.connect, net.Server, net.Socket,
    net.BlockList, net.SocketAddress; http.createServer, http.request,
    http.get, http.Server, http.IncomingMessage, http.ServerResponse,
    http.ClientRequest, http.Agent; and the https equivalents, generated
    from Node 24.22.2's documentation like the rest of Lasm.JS.Node
    (docs/JS_BINDINGS.md, "Standard bindings for Node"; API decisions A18,
    0.4-30 to 0.4-32).
  • Documented Node events are typed listeners. server.onRequest,
    socket.onData, req.onceResponse, child.onceExit, stream.onEnd, …
    take a listener made from a Lean function of the event's documented
    arguments (http.Server.RequestListener.ofFn fun req res => …), on every
    generated class. ChildProcess's 'exit' and 'close' give the exit code
    and signal as Options.
  • stream.Readable and stream.Writable are EventEmitters and gain
    pause, resume, isPaused, setEncoding, destroy, write and end;
    stream.Duplex is new (toWeb, fromWeb).
  • Lasm.JS.Deno is the whole Deno namespace (#307). Generated from Deno
    2.9.6's own TypeScript declarations (lib.deno.ns.d.ts, lib.deno_net.d.ts,
    and Deno KV and Deno.cron from lib.deno.unstable.d.ts) by the new
    scripts/bindings/ts-auto.mjs: the file system (Deno.readFile, Deno.open,
    FsFile, Deno.readDir, watchFs, …), subprocesses (Deno.Command,
    ChildProcess), TCP, TLS and Unix sockets and DNS (Deno.listen,
    Deno.connect, Deno.resolveDnsMx, …), the process (Deno.env,
    Deno.args, Deno.exit, signals), permissions, standard streams,
    Deno.upgradeWebSocket, Deno.createHttpClient, and Deno KV
    (Deno.openKv, Kv, AtomicOperation, KvU64) with Deno.cron. New
    modules: Lasm.JS.Deno.Runtime, .Permissions, .Io, .Fs, .Subprocess,
    .Net, .WebSockets, .Fetch, .Kv (import the ones you use). Exclusions, each with its reason, are in
    scripts/bindings/deno-tier2.mjs (FFI, Deno.test, in-place buffer reads).
    docs/JS_BINDINGS.md, "Standard bindings for Deno"; API decisions 0.4-5,
    0.4-7, 0.4-9, 0.4-10 to 0.4-15.
    • Deno KV needs Deno's --unstable-kv flag on the Deno CLI (deno run -A --unstable-kv deno/main.mjs); Deno Deploy provides KV without it.
    • Deno.serveWithUnixOptions serves on a Unix domain socket.
    • Async iterables (Deno.readDir, Kv.list, a listener's connections,
      FsWatcher) have values (every value, read to the end) and iterator
      with next (one at a time).
    • Deno's experimental and unstable APIs that work from Wasm are generated
      too (#312): Deno.spawn, VSOCK (serveWithVsockOptions, listen,
      connect), QUIC (Deno.connectQuic, QuicEndpoint),
      Deno.listenDatagram. Run them with Deno's --unstable-* flags.
  • Lasm.JS.Bun is the whole Bun namespace and bun:sqlite (#312).
    Generated from Bun 1.4.4's bun-types by the same generator: files
    (Bun.file, Bun.write), processes (Bun.spawn, Bun.spawnSync), TCP and
    UDP sockets (Bun.listen, Bun.connect, Bun.udpSocket), bun:sqlite
    (Bun.Database, Bun.Statement), Bun.SQL, Bun.RedisClient,
    Bun.S3Client, Bun.password, Bun.CryptoHasher, Bun.Glob, compression,
    Bun.TOML/YAML/JSON5/XML, and WebSockets in Bun.serve
    (websocket handlers, Server.upgrade, Server.publish,
    ServerWebSocket). New modules Lasm.JS.Bun.Core, .Shell, .Sqlite,
    .Sql, .Redis, .S3. Excluded with reasons: the $ shell and the sql
    tagged templates, the bundler, Bun.fetch (Lasm.JS.Web's), deprecated and
    experimental members. docs/JS_BINDINGS.md, "Standard bindings for Bun"; API
    decisions 0.4-4, 0.4-7, 0.4-8, A24.1, 0.4-17.x.
  • Lasm.JS.Deno and Lasm.JS.Bun are not prebuilt. Their modules ship as
    source and compile on the first build that imports them (0.4-20), so the
    package does not grow with them.
  • New examples: examples/deno-kv, a todo API on Deno
    KV, and examples/bun-sqlite, a todo API on
    bun:sqlite, both built and checked by CI.

The whole web platform from Lean (#319)

  • IndexedDB, WebGL 1 and 2, WebGPU, Web Audio, WebRTC, Media Capture,
    WebCodecs, SVG, Web Animations, the observers, Service Workers, and every
    other spec
    , as Lasm.JS.Web.<Spec>
    (docs/JS_BINDINGS.md).
    Modules outside the small prebuilt core compile on first import (0.3-6).

  • Availability guards for feature detection (decision 0.3-11, #337).
    Every web binding that some target lacks has a guard X?, which checks the
    platform when the program runs ('gpu' in navigator) and gives the typed
    value or none:

    if let some gpu ← (← navigator).gpu? then
      IO.println (← gpu.getPreferredCanvasFormat).val
    else
      IO.println "no WebGPU"

    lasm build --target accepts guarded uses on targets without the API,
    including the members of what the guard gives
    (gpu.getPreferredCanvasFormat), and the program runs the else branch
    there. Unguarded uses are still refused, and the error names the guard.

  • Errors from generated bindings name the binding, for example
    Lasm.JS.Web.URL.new: … (0.3-12).

  • Lasm.UI.Mount.signal: an AbortSignal that aborts when the app is
    unmounted, for the platform's own cleanup (addEventListener's signal,
    fetch's) (A14.1).

Generated bindings (#301)

  • Checked downcasts: I.cast? (v : Value) : IO (Option I) (instanceof)
    for every generated interface JavaScript can name (A12), for example
    if let some input ← HTMLInputElement.cast? e.val then …. The unchecked
    { val := v } stays.

Lasm.WASI.Http (#306)

  • Helpers for whole bodies and responses (A31): InputStream.readAll,
    OutputStream.writeAll (4,096 bytes per call), IncomingRequest.readBody
    and respond out status headers body, in Lasm.WASI.Http.Respond, imported
    by Lasm.WASI.Http. Programs may replace their own copies of these helpers.

Changes

  • Generated binding modules are compiled on first import (decision 0.3-6,
    #313, #321, docs/HOW_LASM_WORKS.md). Modules of
    Lasm.JS.Web, Lasm.JS.Node, Lasm.JS.Deno, Lasm.JS.Bun and
    Lasm.JS.Cloudflare outside the small core set ship as Lean source. The
    first build (or npx lasm editor) that imports one compiles it once into
    Lasm's cache ([lasm] Compiling Lasm.JS.Web.IndexedDB (first use)…), and
    every later build reuses it. The cache's lock lives outside the installed
    prefix, so the next build's integrity check passes (#321).

  • Lake builds Lasm's library modules compiled on first import, in the editor
    too
    (#332, decision 0.3-7). .lake/lasm-library is a link (a junction on
    Windows) that every lasm command makes or repairs. An editor opening
    import Lasm.JS.Web.IndexedDB now builds the module instead of reporting a
    missing .olean. lasm build takes those modules from Lake and links them
    once.

  • Missing-import hints (decision 0.3-20, #334). The generated bindings
    have no catch-all import, so a program that uses, for example, fetch must
    import its module. When lasm build or lasm dev fails on a name that a
    generated module defines, the error is followed by the import to add:

    Main.lean:4:12: error: Unknown identifier `fetch`
    hint: fetch is defined in Lasm.JS.Web.Fetch; add: import Lasm.JS.Web.Fetch
    

    A name that several runtimes define lists one import per runtime (serve:
    Lasm.JS.Node.Serve, Lasm.JS.Deno.Serve, Lasm.JS.Bun.Serve).

  • One help text (0.7-1): lasm --help prints the same usage whether or not
    the CLI is a release candidate, with every command, the targets of
    lasm build and lasm package, and what --output names.

  • lasm dev --help lists --verbose, --dev and the supabase-edge target
    (0.7-6); lasm package --help lists the browser target (0.7-7, #318).

  • npm create @lasm with no directory prints a usage line that no longer lists
    only four templates; npx @lasm/cli init --help lists them all.

  • npm create @lasm no longer reads the CLI's files for its template list
    (0.7-20, #318).

  • The README's environment variables list LASM_VM_STACK_MB (0.7-13) and
    LASM_DEV_SERVER, which lasm dev sets (0.7-14, #318).

Fixes

  • A program on a function platform no longer fails at start-up with "The
    Lean program ended (exit code 0) without publishing a fetch handler" (#327).
    The platform file took the exit code that Emscripten sets while the runtime
    starts for the end of the program. It now waits for the runtime's own end
    (Module.onExit) or a nonzero exit code, so main can publish its handler
    with exportDefault (found by the serverless platform check after the
    direct handler calls landed).

Internals (no change to how programs build or run)

  • Every public surface is inventoried (#300, #302, #314): each Lasm.*
    namespace, generated binding, CLI command and flag, target, template and
    LASM_* environment variable is named in
    docs/API_DECISIONS.md, with its decision in the
    milestone files under docs/api/decisions/, and
    scripts/api/inventory.mjs fails the unit job when one is missing. Release
    notes are now collected as one file per pull request in
    docs/release/next/.
  • Instances of generated Lasm.JS.Node types now have explicit names
    (instFromJSFsStats); nothing refers to the automatic ones (#220).
  • Lasm.Serverless left Lasm's library (#324, API decisions A23 and
    0.2-7). It had no runtime API: it was a Lean model of the function-platform
    files (src/serverless/) and its 20 proved propositions. The files moved
    unchanged to verification/cli/Lasm/Serverless/, beside the other models of
    the CLI's JavaScript, and verification/cli/README.md lists the
    propositions instead of library/PROOFS.md. No program imported it.
  • The library prebuilt is smaller (#333): 96.3 MB instead of 114.4 MB, with
    the generated bindings outside each core set compiled on first import.
  • lasm:ui-dom is private to Lasm.UI, and the error corpus has 5 new cases
    (#330).
  • Conduit and Ledger keep their own hardened JSON parser (#308) instead of
    importing Lasm.RPC.Core, a step toward removing Lasm.RPC. No behaviour
    change.
  • Candidates keep building on Lean 4.35.0 (#325): Lean 4.36.0 shipped on
    2026-11-16, and its upgrade follows Stage 0's binding work; the acceptance
    pins defer exactly 4.36.0.
  • The roadmap is in seven stages (#300, #310, #326): Stage 0 settles the
    API surface; Stage 1 requires every platform at evidence level L3 and adds
    selective testing on pull requests (ROADMAP.md).