nectar/kinode/packages/app_store/api/app_store:sys-v1.wit

321 lines
8.8 KiB
Plaintext
Raw Normal View History

2024-09-17 18:58:42 +03:00
/// The App Store manages the discovery, download, and installation of packages (apps)
/// in the Kinode ecosystem. It consists of three main processes: main, chain, and downloads.
2024-05-27 02:40:41 +03:00
2024-09-17 18:58:42 +03:00
/// main:app_store:sys
interface main {
2024-05-29 00:51:55 +03:00
use standard.{package-id};
2024-09-17 18:58:42 +03:00
use chain.{onchain-metadata, chain-error};
use downloads.{download-error};
2024-09-17 18:58:42 +03:00
/// Represents various requests that can be made to the main App Store interface
variant request {
local(local-request),
2024-05-27 02:40:41 +03:00
}
2024-09-17 18:58:42 +03:00
/// Represents various responses from the main App Store interface
variant response {
local(local-response),
chain-error(chain-error),
download-error(download-error),
handling-error(string),
2024-08-20 17:16:48 +03:00
}
2024-09-17 18:58:42 +03:00
/// Local requests that can be made to the App Store
variant local-request {
/// Request to add a new package to app_store. Includes zip and an optional onchain-metadata.
/// This is used by kit start
new-package(new-package-request),
/// Request to install a package
install(install-package-request),
/// Request to uninstall a package
uninstall(package-id),
/// Request to list all available APIs
apis,
/// Request to get a specific API
get-api(package-id),
}
2024-09-17 18:58:42 +03:00
/// Local responses from the App Store
variant local-response {
new-package-response(new-package-response),
install-response(install-response),
uninstall-response(uninstall-response),
apis-response(apis-response),
get-api-response(get-api-response),
2024-08-08 14:26:07 +03:00
}
2024-09-17 18:58:42 +03:00
/// Request to add a new package
record new-package-request {
package-id: package-id,
2024-09-17 18:58:42 +03:00
mirror: bool,
2024-08-15 15:26:17 +03:00
}
2024-09-17 18:58:42 +03:00
/// Request to install a package
record install-package-request {
2024-08-08 14:26:07 +03:00
package-id: package-id,
2024-09-17 18:58:42 +03:00
metadata: option<onchain-metadata>, // if None, local sideloaded package.
2024-08-08 14:26:07 +03:00
version-hash: string,
2024-08-15 17:15:55 +03:00
}
2024-09-17 18:58:42 +03:00
/// Response for a new package request
enum new-package-response {
success,
no-blob,
install-failed,
already-exists,
}
2024-09-17 18:58:42 +03:00
/// Response for an install request
enum install-response {
success,
failure,
2024-08-16 01:23:47 +03:00
}
2024-09-17 18:58:42 +03:00
/// Response for an uninstall request
enum uninstall-response {
success,
failure,
}
2024-09-17 18:58:42 +03:00
/// Response containing a list of available APIs
record apis-response {
apis: list<package-id>,
2024-08-08 14:26:07 +03:00
}
2024-09-17 18:58:42 +03:00
/// Response for a get-api request
/// The API itself will be in the response blob if successful
enum get-api-response {
success,
failure,
2024-08-06 21:06:43 +03:00
}
}
2024-09-17 18:58:42 +03:00
/// chain:app_store:sys
/// This process holds information about on-chain ~uri and ~hash notes,
/// and fetches the metadata with the http_client:distro:sys when necessary.
2024-08-06 21:06:43 +03:00
interface chain {
use standard.{package-id};
2024-09-17 18:58:42 +03:00
/// Requests that can be made to the chain component
variant chain-requests {
2024-09-17 18:58:42 +03:00
/// Get information about a specific app
2024-08-08 18:52:53 +03:00
get-app(package-id),
2024-09-17 18:58:42 +03:00
/// Get information about all apps
2024-08-13 17:27:41 +03:00
get-apps,
2024-09-17 18:58:42 +03:00
/// Get information about apps published by the current node
2024-08-13 17:27:41 +03:00
get-our-apps,
2024-09-17 18:58:42 +03:00
/// Start auto-updating an app
2024-08-08 18:52:53 +03:00
start-auto-update(package-id),
2024-09-17 18:58:42 +03:00
/// Stop auto-updating an app
2024-08-08 18:52:53 +03:00
stop-auto-update(package-id),
}
2024-09-17 18:58:42 +03:00
/// Responses from the chain component
variant chain-responses {
2024-08-15 15:26:17 +03:00
get-app(option<onchain-app>),
get-apps(list<onchain-app>),
get-our-apps(list<onchain-app>),
auto-update-started,
auto-update-stopped,
2024-09-04 01:15:16 +03:00
err(chain-error),
}
2024-09-17 18:58:42 +03:00
/// Possible errors from the chain component
2024-08-15 15:26:17 +03:00
variant chain-error {
no-package,
}
2024-09-04 00:40:47 +03:00
2024-09-17 18:58:42 +03:00
/// Represents an app as stored on-chain
record onchain-app {
2024-08-13 17:27:41 +03:00
package-id: package-id,
tba: string,
2024-08-06 21:06:43 +03:00
metadata-uri: string,
metadata-hash: string,
metadata: option<onchain-metadata>,
2024-08-13 17:27:41 +03:00
auto-update: bool,
2024-08-08 18:52:53 +03:00
}
2024-09-17 18:58:42 +03:00
/// Metadata associated with an on-chain app
record onchain-metadata {
2024-08-08 18:52:53 +03:00
name: option<string>,
description: option<string>,
image: option<string>,
external-url: option<string>,
animation-url: option<string>,
properties: onchain-properties,
2024-08-06 21:06:43 +03:00
}
2024-09-17 18:58:42 +03:00
/// Properties associated with an on-chain app
record onchain-properties {
2024-05-27 02:40:41 +03:00
package-name: string,
publisher: string,
current-version: string,
mirrors: list<string>,
code-hashes: list<tuple<string, string>>,
license: option<string>,
screenshots: option<list<string>>,
wit-version: option<u32>,
dependencies: option<list<string>>,
}
2024-08-06 21:06:43 +03:00
}
2024-09-17 18:58:42 +03:00
/// downloads:app_store:sys
/// This process is responsible for downloading app packages from remote mirrors,
/// spawning ft_workers, and serves the files to the main:app_store:sys process.
/// It also manages the local storage of downloaded app zip packages.
///
interface downloads {
2024-08-08 14:26:07 +03:00
use standard.{package-id};
2024-09-17 18:58:42 +03:00
use chain.{onchain-metadata};
2024-09-17 18:58:42 +03:00
/// Requests that can be made to the downloads component
variant download-requests {
/// Request a remote download
remote-download(remote-download-request),
/// Request a chunk of a file
chunk(chunk-request),
/// Update download progress
progress(progress-update),
/// Update file size information
size(size-update),
/// Request a local download
local-download(local-download-request),
/// Request an auto-update
auto-update(auto-update-request),
/// Notify that a download is complete
download-complete(download-complete-request),
2024-10-09 16:55:22 +03:00
/// Auto-update-download complete
auto-download-complete(auto-download-complete-request),
2024-09-17 18:58:42 +03:00
/// Get files for a package
get-files(option<package-id>),
/// Remove a file
remove-file(remove-file-request),
/// Add a download
add-download(add-download-request),
/// Start mirroring a package
start-mirroring(package-id),
/// Stop mirroring a package
stop-mirroring(package-id),
2024-08-08 14:26:07 +03:00
}
2024-09-17 18:58:42 +03:00
/// Responses from the downloads component
variant download-responses {
success,
err(download-error),
get-files(list<entry>),
}
2024-08-08 14:26:07 +03:00
2024-09-17 18:58:42 +03:00
/// Request for a local download
record local-download-request {
package-id: package-id,
download-from: string,
desired-version-hash: string,
2024-05-27 02:40:41 +03:00
}
2024-09-17 18:58:42 +03:00
/// Request for an auto-update
record auto-update-request {
package-id: package-id,
metadata: onchain-metadata,
}
2024-09-17 18:58:42 +03:00
/// Request for a remote download
record remote-download-request {
package-id: package-id,
worker-address: string,
desired-version-hash: string,
}
2024-09-17 18:58:42 +03:00
/// Possible errors during download operations
variant download-error {
no-package,
not-mirroring,
hash-mismatch(hash-mismatch),
file-not-found,
worker-spawn-failed,
http-client-error,
blob-not-found,
vfs-error,
handling-error(string),
}
/// Notification that a download is complete
record download-complete-request {
2024-08-08 14:26:07 +03:00
package-id: package-id,
2024-09-17 18:58:42 +03:00
version-hash: string,
err: option<download-error>,
2024-08-08 14:26:07 +03:00
}
2024-09-04 00:40:47 +03:00
2024-10-09 16:55:22 +03:00
/// Request for an auto-download complete
record auto-download-complete-request {
download-info: download-complete-request,
manifest-hash: string,
}
2024-09-17 18:58:42 +03:00
/// Represents a hash mismatch error
record hash-mismatch {
desired: string,
actual: string,
}
/// Request for a specific chunk of a file
record chunk-request {
package-id: package-id,
version-hash: string,
2024-09-17 18:58:42 +03:00
offset: u64,
length: u64,
}
2024-05-27 02:40:41 +03:00
2024-09-17 18:58:42 +03:00
/// Represents an entry in the file system (either a file or a directory)
variant entry {
file(file-entry),
dir(dir-entry),
2024-08-08 14:26:07 +03:00
}
2024-09-17 18:58:42 +03:00
/// Represents a file entry
record file-entry {
name: string,
size: u64,
manifest: string,
2024-05-27 02:40:41 +03:00
}
2024-09-17 18:58:42 +03:00
/// Represents a directory entry
record dir-entry {
name: string,
mirroring: bool,
2024-05-27 02:40:41 +03:00
}
2024-09-17 18:58:42 +03:00
/// Request to remove a file
record remove-file-request {
package-id: package-id,
version-hash: string,
2024-05-27 02:40:41 +03:00
}
2024-09-17 18:58:42 +03:00
/// Request to add a download
record add-download-request {
package-id: package-id,
version-hash: string,
mirror: bool,
}
/// Update on the progress of a download
record progress-update {
package-id: package-id,
version-hash: string,
downloaded: u64,
total: u64,
}
/// Update on the size of a file
record size-update {
package-id: package-id,
size: u64,
2024-05-27 02:40:41 +03:00
}
}
2024-09-17 18:58:42 +03:00
/// The app-store-sys-v1 world, which includes the main, downloads, and chain interfaces
2024-09-04 00:40:47 +03:00
world app-store-sys-v1 {
2024-05-27 02:40:41 +03:00
import main;
2024-08-08 14:26:07 +03:00
import downloads;
2024-08-06 21:06:43 +03:00
import chain;
2024-05-27 02:40:41 +03:00
include process-v0;
2024-09-17 18:58:42 +03:00
}