Skip to content

Commit 70b4265

Browse files
authored
JBAI-13681 Implement OpenRouter clients and prompt executor (#15)
1 parent 664ea99 commit 70b4265

File tree

13 files changed

+885
-3
lines changed

13 files changed

+885
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.gradle
22
.idea
33
.kotlin
4-
build
4+
build
5+
**/.claude/settings.local.json

CLAUDE.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This repository contains the Koan Agents framework, a Kotlin multiplatform library for building AI agents. The framework enables creating intelligent agents that interact with tools, handle complex workflows, and maintain context across conversations.
8+
9+
## Building and Testing
10+
11+
### Basic Commands
12+
13+
```bash
14+
# Build the project
15+
./gradlew assemble
16+
17+
# Compile test classes
18+
./gradlew jvmTestClasses jsTestClasses
19+
20+
# Run all JVM tests
21+
./gradlew jvmTest
22+
23+
# Run all JS tests
24+
./gradlew jsTest
25+
26+
# Run a specific test class
27+
./gradlew jvmTest --tests "fully.qualified.TestClassName"
28+
# Example:
29+
./gradlew jvmTest --tests "ai.grazie.code.agents.test.SimpleAgentIntegrationTest"
30+
31+
# Run a specific test method
32+
./gradlew jvmTest --tests "fully.qualified.TestClassName.testMethodName"
33+
# Example:
34+
./gradlew jvmTest --tests "ai.grazie.code.agents.test.SimpleAgentIntegrationTest.simpleChatAgent should call default tools"
35+
```
36+
37+
## Architecture
38+
39+
### Key Modules
40+
41+
1. **agents-core**: Core abstractions and interfaces
42+
- AIAgent, AIAgentStrategy, event handling system
43+
44+
2. **agents-core-tools**: Tool infrastructure
45+
- Tool, ToolRegistry, ToolDescriptor
46+
47+
3. **agents-local**: Local execution implementation
48+
- KotlinAIAgent, execution strategies, session management
49+
50+
4. **agents-local-features**: Extensible agent capabilities
51+
- Memory, tracing, and other features
52+
53+
5. **prompt**: LLM interaction layer
54+
- LLM executors, prompt construction, structured data processing
55+
56+
### Core Concepts
57+
58+
- **Agents**: State-machine graphs with nodes that process inputs and produce outputs
59+
- **Tools**: Encapsulated actions with standardized interfaces
60+
- **Strategies**: Define agent behavior and execution flow
61+
- **Features**: Installable extensions that enhance agent capabilities
62+
- **Event Handling**: System for intercepting and processing agent lifecycle events
63+
64+
### Implementation Pattern
65+
66+
1. Define tools that agents can use
67+
2. Register tools in the ToolRegistry
68+
3. Configure agent with strategy
69+
4. Set up communication (if integrating with external systems)
70+
71+
## Testing
72+
73+
The project has extensive testing support:
74+
75+
- **Mocking LLM responses**:
76+
```kotlin
77+
val mockLLMApi = getMockExecutor(toolRegistry, eventHandler) {
78+
mockLLMAnswer("Hello!") onRequestContains "Hello"
79+
mockLLMToolCall(CreateTool, CreateTool.Args("solve")) onRequestEquals "Solve task"
80+
}
81+
```
82+
83+
- **Mocking tool calls**:
84+
```kotlin
85+
mockTool(PositiveToneTool) alwaysReturns "The text has a positive tone."
86+
```
87+
88+
- **Testing agent graph structure**:
89+
```kotlin
90+
testGraph {
91+
assertStagesOrder("first", "second")
92+
// ...
93+
}
94+
```
95+
96+
For detailed testing guidelines, refer to `agents/TESTING.md`.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import ai.grazie.gradle.publish.maven.publishToGraziePublicMaven
2+
3+
group = "${rootProject.group}.prompt"
4+
version = rootProject.version
5+
6+
plugins {
7+
id("ai.kotlin.multiplatform")
8+
alias(libs.plugins.kotlin.serialization)
9+
}
10+
11+
kotlin {
12+
sourceSets {
13+
commonMain {
14+
dependencies {
15+
implementation(project(":agents:agents-core-tools"))
16+
implementation(project(":prompt:prompt-executor:prompt-executor-clients"))
17+
implementation(project(":prompt:prompt-llm"))
18+
implementation(project(":prompt:prompt-model"))
19+
implementation(libs.ai.grazie.utils.common)
20+
implementation(libs.kotlinx.coroutines.core)
21+
implementation(libs.ktor.client.content.negotiation)
22+
implementation(libs.ktor.serialization.kotlinx.json)
23+
}
24+
}
25+
26+
jvmMain {
27+
dependencies {
28+
implementation(libs.ktor.client.cio)
29+
}
30+
}
31+
32+
commonTest {
33+
dependencies {
34+
implementation(kotlin("test"))
35+
implementation(libs.kotlinx.coroutines.test)
36+
implementation(libs.kotlinx.serialization.core)
37+
implementation(libs.kotlinx.serialization.json)
38+
}
39+
}
40+
41+
jvmTest {
42+
dependencies {
43+
implementation(kotlin("test-junit5"))
44+
}
45+
}
46+
}
47+
}
48+
49+
publishToGraziePublicMaven()

0 commit comments

Comments
 (0)