There are two cases for WIT within Kinode OS:

  1. WIT for definition of process APIs,
  2. WIT for definition of libraries, to be imported into processes.

There is some overlap between the first and second case, but for the most part, process APIs will have only types, whereas libraries will have types and functions.

The distinction is important because it affects how much work is required to:

  1. Distribute the API/lib,
  2. Compile the final process.

This is because a WIT file that contains only types need only be placed within the importing process' wit/ directory and then it can be importd inside the top-level WIT file for that process. However, a WIT file that exports functions must also be packaged with a .wasm file defining those functions, and that must be composed with the process in order to create the final process .wasm file.

What do we want?

As a dev, I can:

  1. Easily write APIs for my processes and publish them with my applications,
  2. Easily find, get, import APIs for other processes to interact with them.

APIs must be easily accessible for programmatic AND human reading.

A natural place to put APIs is in the app_store alongside the process/package that they are for. With a node online, kit can then easily fetch lists of APIs or APIs themselves through the node, if they are exposed properly. Alternatively, they might be exposed over http. kit could pull down the files to /tmp/..cache.. and then access them from there. kit view-api package_name:publisher.os version

Parts of the system

  1. Packages incorporate API field in metadata.json,
  2. app_store exposes an app's API for querying,
  3. kit provides a way to pull down APIs for viewing. Longer term, probably want an mdbook-like system for APIs. Maybe mdbook-like system is first thing to build, actually? Use wit-bindgen rust -w api-world-name --generate-unused-types wit/ to go to Rust or lang of choice & display API?
  4. Cargo.toml/requirements.txt-like way to specify deps for my process. kit pulls down.

How do we get there?

  1. Add field(s) to metadata.json for API,
  2. Changes to on- & off-chain app_store code to add API,
  3. Add Kinode interface to app_store & allow querying via kit; this also gets us LLM stuff we want; future work to add HTTP interface.
  4. kit pulls interfaces from app_store interface above.

Things we need to figure out

Dependency versioning! I've written about this before. To have a serious Cargo.toml-like way to specify deps for my process we will need to be able to pull down specific versions of an API. But then we will need to be able to have our process interacting with others who implement that version of the API. This Might not be as big of an issue as I worry it is, because there are actually only two main bad cases:

  1. My version is off by a major version wrt process I am querying,
  2. My version is at a higher minor version wrt process I am querying, and that minor version bump added features that I'm trying to use.

At a minimum we'll probably need something like an address that has a version in it. I.e. I don't direct request to

target.os@process:package:publisher.os

but instead to

target.os@process:v0.1.0:package:publisher.os

and have kernel enforce version stuff somehow, i.e. v0.1.1 will work for that request but v1.0.0 will not.

Original gist on GitHub