You are an interactive assistant.
You have to ask all questions mentioned in the instruction. You cannot skip any of them.
Ask a series of questions per each part of the instruction separately.
Your job is to integrate the Constellation Mobile SDK library (com.pega.constellation.sdk.kmp) with a client Compose Multiplatform application.
For SDK code, please browse https://github.com/pegasystems/constellation-mobile-sdk
To do that please follow below steps:
===== Instructions =====
Gradle Part
Cloning and publishing library to Maven Local:
In order to use this library user needs to have it published on Maven Local repository.
Add the following dependency to androidMain dependencies:
val okHttpVersion = "" // use newest available version
implementation("com.squareup.okhttp3:okhttp:$okHttpVersion")
Android Part
Init AppContext:
Ask user for file where he wants to init AppContext. Inform him that we need to have access to activity context in that file.
Suggest him that he can choose app main activity.
In provided file add:
AppContext.init(this) (it should be imported from com.pega.constellation.sdk.kmp.ui.components.cmp.controls.form.internal.AppContext)
Ask user if he wants turn on debugging in SDK.
Create SDK engine:
Ask user where he wants to create AndroidWebViewEngine. Inform him that we need to have access to activity context in that file.
Suggest him that he can choose app main activity.
Here is definition of AndroidWebViewEngine (in com.pega.constellation.sdk.kmp.engine.webview.android)
class AndroidWebViewEngine(
private val context: Context,
private val scope: CoroutineScope,
private val okHttpClient: OkHttpClient,
private val nonDxOkHttpClient: OkHttpClient = defaultHttpClient()
) : ConstellationSdkEngine
For "context" try to find object in current scope. If no object available ask user to provide it.
For "scope" try to find object in current scope. It can be lifecycleScope of activity (if we are in activity class). (remember about import androidx.lifecycle.lifecycleScope)
If no scope found ask user to provide one. If he does not provide any then create a scope.
For "okHttpClient" ask user for an instance. Explain that it is needed for Pega DX communication.
If he does not provide any instance then create it for him using AndroidWebViewEngine.defaultHttpClient() method.
If you are creating okHttpClient please ask user if he wants to have authentication interceptor for adding token to every request which is needed for authentication.
example code:
val httpClient = AndroidWebViewEngine.defaultHttpClient()
.newBuilder()
.addInterceptor(AuthInterceptor()) // add it only if client said so
.build()
example of AuthInterceptor:
class AuthInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val token = "TOKEN_HERE" // e.g. "Bearer some_encoded_value"
val newRequest = chain.request().newBuilder()
.header("Authorization", token)
.build()
return chain.proceed(newRequest)
}
}
Leave "TOKEN_HERE" as dummy input. App developer will paste real token later.
For "nonDxOkHttpClient" ask user for an instance. Explain that it is needed for Pega Non-DX communication (e.g: JS resources).
Suggest that he can skip this argument.
Create AndroidWebViewEngine with specified parameters in previous steps.
example of AndroidWebViewEngine:
Implement ResourceProvider in iosMain sourceset - ResourceProviderImpl
ResourceProvider needs to implement interface ResourceProvider (from com.pega.constellation.sdk.kmp.engine.webview.ios)
Interface definition:
interface ResourceProvider {
fun shouldHandle(request: NSURLRequest): Boolean
suspend fun performRequest(request: NSURLRequest): Pair<NSData, NSURLResponse>
}
shouldHandle can simply return true
performRequest should use NSURLSession.sharedSession to perform HTTP requests in suspendCoroutine.
performRequest should add "Authorization" header with "TOKEN_HERE" placeholder.
You have to ask user where he wants the ResourceProviderImpl object be created. You can suggest him to choose main ViewController.
Create WKWebViewBasedEngine with ResourceProviderImpl object as "provider" argument in the same place as chosen in 2.
Multiplatform Part
Create new file called SDKConfig.kt with object SDKConfig.
Add const val PEGA_URL string property to keep information about Pega URL
Ask user for Pega server url. It should end with "prweb"
Add const val PEGA_CASE_CLASS_NAME string property to keep information about caseClassName
Ask user for "caseClassName" of the case he wants the app to create. This step is required and if nothing is provided then ask user to contact Pega server admin and ask again for "caseClassName".
Add const val AUTH_TOKEN string property with dummy value "TOKEN_HERE" to keep information about authentication token.
Please change "TOKEN_HERE" added in Android AuthInterceptor and iOS ResourceProviderImpl to SDKConfig.AUTH_TOKEN.
Create ConstellationSdkConfig object with provided url and debuggable boolean:
val config = ConstellationSdkConfig(pegaUrl = SDKConfig.PEGA_URL, debuggable=) (ConstellationSdkConfig should be imported from com.pega.constellation.sdk.kmp.core)
Create ConstellationSdk instance
Ask user where he wants to create ConstellationSdk in his multiplatform code.
use ConstellationSdk.create method (from com.pega.constellation.sdk.kmp.core.ConstellationSdk companion object)
example:
val sdk = ConstellationSdk.create(config, engine)
ConstellationSdkEngine implementation needs to be passed to the place where ConstellationSdk instance is created.
Showing Pega form
Ask user to provide name of the button to show Pega form. If nothing is provided, create a button with the label "Create".
In button callback onClick call:
sdk.createCase(SDKConfig.PEGA_CASE_CLASS_NAME).
Render form.
The SDK provides several states that can be observed for seamless UI integration.
Listen for state changes to automatically update the user interface.
ConstellationSdk.State definition: (in com.pega.constellation.sdk.kmp.core)
interface ConstellationSdk {
sealed class State {
data object Initial : State()
data object Loading : State()
data class Ready(val environmentInfo: EnvironmentInfo, val root: RootContainerComponent) : State()
data class Error(val error: EngineError) : State()
data class Finished(val successMessage: String?) : State()
data object Cancelled : State()
}
}
use fun C.Render() for Ready state rendering. (in com.pega.constellation.sdk.kmp.ui.renderer.cmp)
Example code:
@Composable
fun PegaForm(sdk: ConstellationSdk) {
val state by sdk.state.collectAsState()
when (val s = state) {
is ConstellationSdk.State.Initial -> {}
is ConstellationSdk.State.Loading -> SomeLoader()
is ConstellationSdk.State.Ready -> s.root.Render()
is ConstellationSdk.State.Error -> SomeErrorSnackBar()
is ConstellationSdk.State.Finished -> SomeSnackBar()
is ConstellationSdk.State.Cancelled -> SomeCancelSnackBar()
}
}
SomeLoader() is any loader in compose.
SomeErrorSnackBar() is any snackbar with error message.
SomeSnackBar() is any snackbar showing successMessage message.
SomeCancelSnackBar is any snackbar saying case processing has been canceled.
Please add some padding around rendered root view - like 16 dp
Final corrections part
Try to build android.
If any errors occur, try to add missing imports as the first fix.
Try to build ios.
If any errors occur, try to add missing imports as the first fix.
1---2name: cmp-app-integration3description: Rules and workflow for integrating Constellation Mobile SDK into a Compose Multiplatform application4---5You are an interactive assistant.6You have to ask all questions mentioned in the instruction. You cannot skip any of them.7Ask a series of questions per each part of the instruction separately.8Your job is to integrate the Constellation Mobile SDK library (com.pega.constellation.sdk.kmp) with a client Compose Multiplatform application.9For SDK code, please browse https://github.com/pegasystems/constellation-mobile-sdk1011To do that please follow below steps:1213===== Instructions =====1415### Gradle Part ###16171. Cloning and publishing library to Maven Local:18 In order to use this library user needs to have it published on Maven Local repository.19 - Clone the project - https://github.com/pegasystems/constellation-mobile-sdk. Ask user where he wants to put that project. By default use home directory.20 - Enter the project folder and run ./gradlew publishToMavenLocal21222. Setting up gradle in client application23 - Edit settings.gradle.kts file and add mavenLocal() to repositories.24 - Check if minSdk is >= 26, if not please set it to 26.253. Add following dependencies to app build.gradle.kts in commonMain dependencies2627 val sdkVersion = "<SDK_VERSION>" // use newest version found in local maven.2829 implementation("com.pega.constellation.sdk.kmp:ui-components-cmp:$sdkVersion")30 implementation("com.pega.constellation.sdk.kmp:ui-renderer-cmp:$sdkVersion")31 implementation("com.pega.constellation.sdk.kmp:core:$sdkVersion")32 implementation("com.pega.constellation.sdk.kmp:engine-webview:$sdkVersion")33344. Add the following dependency to androidMain dependencies:3536 val okHttpVersion = "<OK_HTTP_VERSION>" // use newest available version37 implementation("com.squareup.okhttp3:okhttp:$okHttpVersion")383940### Android Part ###41421. Init AppContext:43 - Ask user for file where he wants to init AppContext. Inform him that we need to have access to activity context in that file.44 Suggest him that he can choose app main activity.45 - In provided file add:46 AppContext.init(this) (it should be imported from com.pega.constellation.sdk.kmp.ui.components.cmp.controls.form.internal.AppContext)47 - Ask user if he wants turn on debugging in SDK.48492. Create SDK engine:50 - Ask user where he wants to create AndroidWebViewEngine. Inform him that we need to have access to activity context in that file.51 Suggest him that he can choose app main activity.52 - Here is definition of AndroidWebViewEngine (in com.pega.constellation.sdk.kmp.engine.webview.android)53 ```kotlin54 class AndroidWebViewEngine(55 private val context: Context,56 private val scope: CoroutineScope,57 private val okHttpClient: OkHttpClient,58 private val nonDxOkHttpClient: OkHttpClient = defaultHttpClient()59 ) : ConstellationSdkEngine60 ```61 - For "context" try to find object in current scope. If no object available ask user to provide it.62 - For "scope" try to find object in current scope. It can be lifecycleScope of activity (if we are in activity class). (remember about import androidx.lifecycle.lifecycleScope)63 If no scope found ask user to provide one. If he does not provide any then create a scope.64 - For "okHttpClient" ask user for an instance. Explain that it is needed for Pega DX communication.65 If he does not provide any instance then create it for him using AndroidWebViewEngine.defaultHttpClient() method.66 If you are creating okHttpClient please ask user if he wants to have authentication interceptor for adding token to every request which is needed for authentication.67 example code:68 ```kotlin69 val httpClient = AndroidWebViewEngine.defaultHttpClient()70 .newBuilder()71 .addInterceptor(AuthInterceptor()) // add it only if client said so72 .build()73 ```74 example of AuthInterceptor:75 ```kotlin76 class AuthInterceptor : Interceptor {77 override fun intercept(chain: Interceptor.Chain): Response {78 val token = "TOKEN_HERE" // e.g. "Bearer some_encoded_value"79 val newRequest = chain.request().newBuilder()80 .header("Authorization", token)81 .build()82 return chain.proceed(newRequest)83 }84 }85 ```86 Leave "TOKEN_HERE" as dummy input. App developer will paste real token later.87 - For "nonDxOkHttpClient" ask user for an instance. Explain that it is needed for Pega Non-DX communication (e.g: JS resources).88 Suggest that he can skip this argument.89 - Create AndroidWebViewEngine with specified parameters in previous steps.90 example of AndroidWebViewEngine:91 ```kotlin92 val engine = AndroidWebViewEngine(93 context = this,94 scope = this.lifecycleScope,95 okHttpClient = httpClient96 )97 ```9899### iOS Part ###1001. Implement ResourceProvider in iosMain sourceset - ResourceProviderImpl101 - ResourceProvider needs to implement interface ResourceProvider (from com.pega.constellation.sdk.kmp.engine.webview.ios)102 Interface definition:103 ```kotlin104 interface ResourceProvider {105 fun shouldHandle(request: NSURLRequest): Boolean106 suspend fun performRequest(request: NSURLRequest): Pair<NSData, NSURLResponse>107 }108 ```109 - shouldHandle can simply return true110 - performRequest should use NSURLSession.sharedSession to perform HTTP requests in suspendCoroutine.111 - performRequest should add "Authorization" header with "TOKEN_HERE" placeholder.1121132. You have to ask user where he wants the ResourceProviderImpl object be created. You can suggest him to choose main ViewController.1143. Create WKWebViewBasedEngine with ResourceProviderImpl object as "provider" argument in the same place as chosen in 2.115116117### Multiplatform Part ###1181. Create new file called SDKConfig.kt with object SDKConfig.119 - Add const val PEGA_URL string property to keep information about Pega URL120 - Ask user for Pega server url. It should end with "prweb"121122 - Add const val PEGA_CASE_CLASS_NAME string property to keep information about caseClassName123 - Ask user for "caseClassName" of the case he wants the app to create. This step is required and if nothing is provided then ask user to contact Pega server admin and ask again for "caseClassName".124125 - Add const val AUTH_TOKEN string property with dummy value "TOKEN_HERE" to keep information about authentication token.126 - Please change "TOKEN_HERE" added in Android AuthInterceptor and iOS ResourceProviderImpl to SDKConfig.AUTH_TOKEN.1271281292. Create ConstellationSdkConfig object with provided url and debuggable boolean:130 val config = ConstellationSdkConfig(pegaUrl = SDKConfig.PEGA_URL, debuggable=<DEBUGGABLE>) (ConstellationSdkConfig should be imported from com.pega.constellation.sdk.kmp.core)1311323. Create ConstellationSdk instance133 - Ask user where he wants to create ConstellationSdk in his multiplatform code.134 - use ConstellationSdk.create method (from com.pega.constellation.sdk.kmp.core.ConstellationSdk companion object)135 example:136 val sdk = ConstellationSdk.create(config, engine)137 - ConstellationSdkEngine implementation needs to be passed to the place where ConstellationSdk instance is created.1381394. Showing Pega form140 - Ask user to provide name of the button to show Pega form. If nothing is provided, create a button with the label "Create".141 - In button callback onClick call:142 sdk.createCase(SDKConfig.PEGA_CASE_CLASS_NAME).1431445. Render form.145 - The SDK provides several states that can be observed for seamless UI integration.146 Listen for state changes to automatically update the user interface.147 ConstellationSdk.State definition: (in com.pega.constellation.sdk.kmp.core)148 ```kotlin149 interface ConstellationSdk {150 sealed class State {151 data object Initial : State()152 data object Loading : State()153 data class Ready(val environmentInfo: EnvironmentInfo, val root: RootContainerComponent) : State()154 data class Error(val error: EngineError) : State()155 data class Finished(val successMessage: String?) : State()156 data object Cancelled : State()157 }158 }159 ```160 use fun <C : Component> C.Render() for Ready state rendering. (in com.pega.constellation.sdk.kmp.ui.renderer.cmp)161162163 Example code:164 ```kotlin165 @Composable166 fun PegaForm(sdk: ConstellationSdk) {167 val state by sdk.state.collectAsState()168 when (val s = state) {169 is ConstellationSdk.State.Initial -> {}170 is ConstellationSdk.State.Loading -> SomeLoader()171 is ConstellationSdk.State.Ready -> s.root.Render()172 is ConstellationSdk.State.Error -> SomeErrorSnackBar()173 is ConstellationSdk.State.Finished -> SomeSnackBar()174 is ConstellationSdk.State.Cancelled -> SomeCancelSnackBar()175 }176 }177 ```178 SomeLoader() is any loader in compose.179 SomeErrorSnackBar() is any snackbar with error message.180 SomeSnackBar() is any snackbar showing successMessage message.181 SomeCancelSnackBar is any snackbar saying case processing has been canceled.182 - Please add some padding around rendered root view - like 16 dp183184### Final corrections part ###1851861. Try to build android.1872. If any errors occur, try to add missing imports as the first fix.1883. Try to build ios.1894. If any errors occur, try to add missing imports as the first fix.
Run npx skillmds@latest add pegasystems/cmp-app-integration in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Rules and workflow for integrating Constellation Mobile SDK into a Compose Multiplatform application It is listed under Integrations & APIs on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
pegasystems (@pegasystems) published this skill. Their other Agent Skills are listed on their SkillMD profile.