There are two cases for WIT within Kinode OS:
- WIT for definition of process APIs,
- 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:
- Distribute the API/lib,
- 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:
- Easily write APIs for my processes and publish them with my applications,
- 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
- Packages incorporate API field in
metadata.json, app_storeexposes an app's API for querying,kitprovides a way to pull down APIs for viewing. Longer term, probably want anmdbook-like system for APIs. Maybemdbook-like system is first thing to build, actually? Usewit-bindgen rust -w api-world-name --generate-unused-types wit/to go to Rust or lang of choice & display API?Cargo.toml/requirements.txt-like way to specify deps for my process.kitpulls down.
How do we get there?
- Add field(s) to
metadata.jsonfor API, - Changes to on- & off-chain
app_storecode to add API, - Add Kinode interface to
app_store& allow querying viakit; this also gets us LLM stuff we want; future work to add HTTP interface. kitpulls interfaces fromapp_storeinterface 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:
- My version is off by a major version wrt process I am querying,
- 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.