Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ metadata.*
.DS_Store
test_config.json
/experiment/search_lambda/terraform/.terraform/
symbol_analysis.json
symbol_graph.graphml
symbol_graph.json
workspaces
105 changes: 0 additions & 105 deletions Documentation:

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ class AndroidCognotikApps private constructor(
publicName: String = "localhost",
port: Int = 12891
) : ApplicationDirectory(
localName = localName,
publicName = publicName,
localName = localName,
publicName = publicName,
port = port
) {

companion object {
private val log = LoggerFactory.getLogger(AndroidCognotikApps::class.java.name)
private const val MAX_PORT_ATTEMPTS = 10
private val isInitialized = AtomicBoolean(false)

/**
* Create a new instance with the given context and port
*/
Expand All @@ -71,6 +71,7 @@ class AndroidCognotikApps private constructor(
override fun authenticatedWebsite() = object : OAuthBase("") {
override fun configure(context: WebAppContext, addFilter: Boolean) = context
}

private fun createAndroidWelcomeResources(): Resource {
try {
// Create a temporary directory for welcome resources
Expand Down Expand Up @@ -130,7 +131,7 @@ class AndroidCognotikApps private constructor(
return PathResource(emptyDir.toPath())
}
}

override val welcomeResources: Resource by lazy {
try {
log.debug("Initializing welcome resources for Android")
Expand All @@ -155,11 +156,11 @@ class AndroidCognotikApps private constructor(
log.debug("Platform already initialized, skipping setup")
return
}

super.setupPlatform()
log.debug("Creating mock authentication and authorization managers")
log.debug("Created mock user: ${UserSettingsManager.Companion.defaultUser.email}")

ApplicationServices.authenticationManager = object : AuthenticationInterface {
override fun getUser(accessToken: String?) = UserSettingsManager.Companion.defaultUser
override fun putUser(accessToken: String, user: User) = throw UnsupportedOperationException()
Expand All @@ -179,7 +180,7 @@ class AndroidCognotikApps private constructor(
private val describer = AbbrevWhitelistYamlDescriber(
"com.cognotik", "com.simiacryptus"
)
private val model : ApiChatModel = AnthropicModels.Claude35Haiku.let {
private val model: ApiChatModel = AnthropicModels.Claude35Haiku.let {
ApiChatModel(
model = it,
provider = ApiData(
Expand All @@ -199,13 +200,13 @@ class AndroidCognotikApps private constructor(
emptyList()
}
}

private fun createChildWebApps(): List<ChildWebApp> {
val filesDir = androidContext.filesDir.absolutePath
log.info("Using files directory: $filesDir")
log.debug("Parsing model: ${model.javaClass.simpleName}")
log.debug("Default model: ${model.javaClass.simpleName}")

val planSettings = object : PlanSettings(
defaultModel = model.instance()!!,
parsingModel = model.instance()!!,
Expand All @@ -217,7 +218,7 @@ class AndroidCognotikApps private constructor(

}
log.debug("Created plan settings with working directory: ${planSettings.workingDir}")

val webApps = listOf(
ChildWebApp("/chat", BasicChatApp(File(filesDir), model.model!!, model.model!!)),
ChildWebApp(
Expand Down Expand Up @@ -311,18 +312,18 @@ class AndroidCognotikApps private constructor(
fun startServer(): Int {
log.info("Starting Android Cognotik server...")
log.debug("Current thread: ${Thread.currentThread().name}")




try {
// Ensure platform is set up before accessing childWebApps
log.debug("Setting up platform...")
setupPlatform()
log.debug("Finding available port...")
val actualPort = findAvailablePort(port)
log.info("Server will use port: $actualPort")

// Create a new instance with the correct port
log.debug("Creating server instance with port: $actualPort")
val serverInstance = create(androidContext, actualPort)
Expand All @@ -335,7 +336,7 @@ class AndroidCognotikApps private constructor(
log.debug("Pre-initializing child web apps...")
val apps = serverInstance.childWebApps
log.debug("Child web apps initialized: ${apps.size} apps")

log.debug("Starting server main process...")
serverInstance._main() // Start the server
log.info("Android Cognotik server started successfully on port $actualPort")
Expand Down
Loading
Loading