Gunnar

nordisk/heimdall

crates/heimdall-wasm/wit/heimdall.wit

// SPDX-License-Identifier: AGPL-3.0-only
//
// Heimdall is a defensive sandbox. This is the whole interface between the
// Heimdall wasm host and a guest (spec §6): bytes in, a verdict and files out.
// There is no WASI: no filesystem, no network, no clock, no environment.

package heimdall:guest@0.1.0;

world job {
  /// One job parameter, passed through from the caller's Job params.
  record param {
    key: string,
    value: string,
  }

  /// The guest accepted the input. `note` is a short human-readable summary.
  record output {
    note: string,
  }

  /// The guest refused the input. `reason` says why, in plain words.
  record refusal {
    reason: string,
  }

  /// Hand one output file to the host. `name` is a single plain file name
  /// (ASCII letters, digits, '.', '_', '-', '+'; no '/', no leading '.').
  /// A refused name or a limit hit stops the guest; the job is then refused.
  import emit-file: func(name: string, bytes: list<u8>);

  /// Run the job on `input`.
  export run: func(input: list<u8>, params: list<param>) -> result<output, refusal>;
}