Ketoy
Reference

Capability Registry

The full table of standard library `CapabilityIds` plus the app-specific range. Every ID below is from

dev.ketoy.capabilities.core.CapabilityIds (or the navigation / runtime modules where noted).

For the what and why, see the guides (Networking, DataStore, Room, Navigation, Custom Capability). This page is the what in table form.


ID ranges

RangeOwnerPurpose
0x00010x00FFLayout (legacy)First-pass capabilities — superseded by adapters in most cases. Don't add new IDs here.
0x01000x01FFText (legacy)Same as above.
0x02000x02FFButtons (legacy)Same.
0x03000x03FFMedia (legacy)Same.
0x05000x05FFNetworkHTTP/SSE.
0x06000x06FFStorage KVDataStore Preferences.
0x06100x06FFStorage RoomGeneric Room operations (typed via KBCRoomBridge).
0x07000x07FFNavigationNAV_*.
0x08000x08FFModifierGeneric Modifier ops (reserved).
0x09000x09FFPlatformToast / vibrate / clipboard / locale / log.
0x0A000x0AFFViewModel stateVM_GET_STATE, etc.
0x0B000x0BFFDispatchersDISPATCHER_*.
0x0C000x0CFFFlow operatorsFLOW_MAP, etc.
0x40000x7FFFApp-specificYour custom capabilities.

APP_SPECIFIC_START = 0x4000. KBCRoomBridge enforces id >= 0x4000 on all three registration helpers (suspendCapability, flowCapability, syncCapability).


Network (0x0500–0x05FF)

Registered by CapabilityRegistry.registerNetworkCapabilities(client), which is called transitively by registerCoreCapabilities(...).

IDNameKindSignature
0x0500HTTP_GETsuspend(url: String) -> String
0x0501HTTP_POSTsuspend(url: String, body: String) -> String
0x0502HTTP_PUTsuspend(url: String, body: String) -> String
0x0503HTTP_DELETEsuspend(url: String) -> String
0x0504HTTP_REQUESTsuspend(request: KetoyHttpRequest) -> KetoyHttpResponse
0x0505SSE_SUBSCRIBEflow(url: String) -> Flow<String>
0x0506WEBSOCKET_CONNECTreservednot registered today

Storage — KV (0x0600–0x0605)

Registered by registerCoreCapabilities(...) when you pass a DataStore<Preferences>.

IDNameKindSignature
0x0600KV_GETsuspend(key: String) -> Any?
0x0601KV_SETsuspend(key: String, value: Any?) -> Unit
0x0602KV_DELETEsuspend(key: String) -> Unit
0x0603KV_OBSERVEflow(key: String) -> Flow<Any?>
0x0604KV_GET_ALLsuspend() -> Map<String, Any?>
0x0605KV_CLEARsuspend() -> Unit

Supported value types: String, Int, Long, Float, Double, Boolean. Anything else throws KetoyException on KV_SET.


Storage — Room (0x0610–0x0614)

Generic IDs. Typed Room operations are app-specific (0x4000+) via KBCRoomBridge.

IDNameKindSignature
0x0610DB_QUERYsuspend(query: KBCDbQuery) -> List<Any?>
0x0611DB_INSERTsuspend(entityClass: String, fields: Map<String, Any?>) -> Long
0x0612DB_UPDATEsuspend(entityClass: String, id: Long, fields: Map<String, Any?>) -> Int
0x0613DB_DELETEsuspend(entityClass: String, id: Long) -> Int
0x0614DB_OBSERVEflow(query: KBCDbQuery) -> Flow<List<Any?>>

In practice, prefer KBCRoomBridge + per-operation app-specific IDs.


Registered by CapabilityRegistry.registerNavigationCapabilities(navigator) from dev.ketoy.vm:ketoy-capabilities-navigation.

IDNameKindSignature
0x0700NAV_PUSHsync(route: String) -> Unit
0x0701NAV_POPsync() -> Unit
0x0702NAV_REPLACEsync(route: String) -> Unit
0x0703NAV_POP_TOsync(route: String, inclusive: Boolean) -> Boolean
0x0704NAV_DEEP_LINKsync(uri: String) -> Unit
0x0705NAV_SET_RESULTsync(key: String, value: Any?) -> Unit
0x0706NAV_GET_RESULTsuspend(key: String) -> Any?
0x0707NAV_CAN_POPsync() -> Boolean
0x0708NAV_CURRENT_ROUTEsync() -> String?

Platform (0x0900–0x090A)

Registered by registerPlatformCapabilities(context, analyticsTracker?).

IDNameKindSignature
0x0900ANALYTICS_TRACKsync(event: String, props: Map<String, Any?>) -> Unit
0x0901TOASTsync(text: String) -> Unit
0x0904VIBRATEsync(durationMs: Long) -> Unit
0x0902CLIPBOARD_SETsync(text: String) -> Unit
0x0903CLIPBOARD_GETsuspend() -> String
0x0905OPEN_URLsync(url: String) -> Unit
0x0906REQUEST_PERMISSIONsuspend(permission: String) -> Boolean
0x0907CHECK_PERMISSIONsync(permission: String) -> Boolean
0x0908DEVICE_LOCALEsync() -> String
0x0909APP_VERSIONsync() -> String
0x090ALOGsync(level: Int, tag: String, msg: String) -> Unit

VIBRATE requires the host APK to declare <uses-permission android:name="android.permission.VIBRATE" />. REQUEST_PERMISSION requires the activity to inherit androidx.activity.ComponentActivity (which KetoyScreen's host already does).


ViewModel state (0x0A00–0x0A03)

Registered by registerViewModelStateCapabilities(viewModel) — done automatically by KetoyScreen when it instantiates a KetoyVirtualViewModel.

IDNameKindSignature
0x0A00VM_GET_STATEsync(key: String) -> Any?
0x0A01VM_SET_STATEsync(key: String, value: Any?) -> Unit
0x0A02VM_OBSERVE_STATEflow(key: String) -> Flow<Any?>
0x0A03VM_DISPATCHsync(eventName: String, payload: Any?) -> Unit

Dispatchers (0x0B00–0x0B03)

Registered by registerDispatcherCapabilities().

IDNameKindReturns
0x0B00DISPATCHER_IOsyncDispatchers.IO
0x0B01DISPATCHER_DEFAULTsyncDispatchers.Default
0x0B02DISPATCHER_MAINsyncDispatchers.Main
0x0B03DISPATCHER_UNCONFINEDsyncDispatchers.Unconfined

Used as the dispatcher argument to WITH_CONTEXT opcodes.


Flow operators (0x0C00–0x0C08)

Registered by registerFlowCapabilities(flowEngine).

IDNameKind
0x0C00FLOW_MAPflow operator
0x0C01FLOW_FILTERflow operator
0x0C02FLOW_FLAT_MAP_LATESTflow operator
0x0C03FLOW_COMBINEflow operator
0x0C04FLOW_TAKEflow operator
0x0C05FLOW_DEBOUNCEflow operator
0x0C06FLOW_DISTINCT_UNTIL_CHANGEDflow operator
0x0C07STATE_FLOW_CREATEsync constructor
0x0C08SHARED_FLOW_CREATEsync constructor

These don't usually appear in KBC source directly — the compiler recognises .map { }, .filter { }, etc. and lowers them onto these IDs through KBCFlowEngine.


registerCoreCapabilities(...) — one-stop bootstrap

kotlin
fun CapabilityRegistry.registerCoreCapabilities(
    context: Context,
    dataStore: DataStore<Preferences>? = null,
    httpClient: KetoyHttpClient = KetoyHttpClient.build(),
    analyticsTracker: (String, Map<String, Any?>) -> Unit = { _, _ -> }
)

Registers, in order:

  1. Network (always).
  2. Storage KV (only if dataStore != null).
  3. Platform (always; analytics tracker is optional).
  4. Dispatchers (always).

Not registered by registerCoreCapabilities:

  • Navigation — call registerNavigationCapabilities(navigator).
  • ViewModel state — registered by KetoyVirtualViewModel.
  • Flow operators — registered by KetoyVM against its KBCFlowEngine.
  • Room — register per-DAO via KBCRoomBridge.

Capability JSON schema

json
{
  "version": 1,
  "allowedStdlibFqNames": [ "kotlin.let", "kotlin.collections.listOf", ... ],
  "capabilities": [
    {
      "id": 16384,
      "name": "OBSERVE_TODOS",
      "fqName": "com.example.myapp.ketoyscreens.observeTodos",
      "kind": "FLOW",
      "parameterTypes": [],
      "returnType": "kotlinx.coroutines.flow.Flow"
    }
  ]
}
FieldMeaning
versionSchema version. Always 1 for now.
allowedStdlibFqNamesStdlib FQ names the validator permits as INVOKE_VIRTUAL/INVOKE_STATIC calls.
capabilities[].idDecimal ID. Hex equivalent shown above for readability.
capabilities[].kindSYNC, SUSPEND, FLOW, or COMPOSABLE.
capabilities[].parameterTypesFQ names of params (kotlin.String, kotlin.Long, etc.).
capabilities[].returnTypeFQ name of return type.

The compiler reads this at build time to validate each @KetoyCapabilityStub's ID and signature.

Next: Compose Adapters →