Skip to content

Commit 80a6ef5

Browse files
authored
Hide implementation details (#9)
1 parent 0efa287 commit 80a6ef5

File tree

11 files changed

+22
-30
lines changed

11 files changed

+22
-30
lines changed

agents/agents-local-features/agents-local-features-common/src/commonMain/kotlin/ai/grazie/code/agents/local/features/common/ExceptionExtractor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package ai.grazie.code.agents.local.features.common
22

33
import kotlinx.coroutines.CancellationException
44

5-
object ExceptionExtractor {
5+
internal object ExceptionExtractor {
66

77
/**
88
* Extension property that retrieves the root cause of a [CancellationException].

agents/agents-local-features/agents-local-features-common/src/commonMain/kotlin/ai/grazie/code/agents/local/features/common/MutexCheck.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ai.grazie.utils.mpp.LoggerFactory
44
import kotlinx.coroutines.sync.Mutex
55
import kotlinx.coroutines.sync.withLock
66

7-
object MutexCheck {
7+
internal object MutexCheck {
88

99
private val logger = LoggerFactory.create("ai.grazie.code.agents.local.features.common.provider.WriterLockUtil")
1010

@@ -30,4 +30,4 @@ object MutexCheck {
3030
action()
3131
}
3232
}
33-
}
33+
}

agents/agents-local/src/commonMain/kotlin/ai/grazie/code/agents/local/agent/LocalAgentState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ai.grazie.code.agents.local.agent
22

3-
import ai.grazie.code.agents.core.utils.ActiveProperty
3+
import ai.grazie.code.agents.local.utils.ActiveProperty
44
import kotlinx.coroutines.sync.Mutex
55
import kotlinx.coroutines.sync.withLock
66

agents/agents-local/src/commonMain/kotlin/ai/grazie/code/agents/local/agent/stage/LocalAgentStageContext.kt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import ai.grazie.code.agents.core.tools.Tool
55
import ai.grazie.code.agents.core.tools.ToolDescriptor
66
import ai.grazie.code.agents.core.tools.ToolRegistry
77
import ai.grazie.code.agents.core.tools.ToolResult
8-
import ai.grazie.code.agents.core.utils.ActiveProperty
9-
import ai.grazie.code.agents.core.utils.RWLock
8+
import ai.grazie.code.agents.local.utils.ActiveProperty
9+
import ai.grazie.code.agents.local.utils.RWLock
1010
import ai.grazie.code.agents.local.InternalAgentsApi
1111
import ai.grazie.code.agents.local.agent.LocalAgentConfig
1212
import ai.grazie.code.agents.local.agent.LocalAgentStateManager
@@ -579,7 +579,6 @@ class LocalAgentLLMWriteSession internal constructor(
579579
* @param args the arguments required to execute the tool.
580580
* @return a `SafeTool.Result` containing the tool's execution result of type `TResult`.
581581
*/
582-
@Suppress("UNCHECKED_CAST")
583582
suspend inline fun <reified TArgs : Tool.Args, reified TResult : ToolResult> callTool(
584583
tool: Tool<TArgs, TResult>,
585584
args: TArgs
@@ -594,7 +593,6 @@ class LocalAgentLLMWriteSession internal constructor(
594593
* @param args The arguments required to execute the tool, which must be a subtype of [Tool.Args].
595594
* @return A [SafeTool.Result] containing the result of the tool execution, which is a subtype of [ToolResult].
596595
*/
597-
@Suppress("UNCHECKED_CAST")
598596
suspend inline fun <reified TArgs : Tool.Args> callTool(
599597
toolName: String,
600598
args: TArgs
@@ -609,7 +607,6 @@ class LocalAgentLLMWriteSession internal constructor(
609607
* @param args The arguments to be passed to the tool, conforming to the [Tool.Args] type.
610608
* @return The raw result of the tool's execution as a String.
611609
*/
612-
@Suppress("UNCHECKED_CAST")
613610
suspend inline fun <reified TArgs : Tool.Args> callToolRaw(
614611
toolName: String,
615612
args: TArgs
@@ -626,7 +623,6 @@ class LocalAgentLLMWriteSession internal constructor(
626623
* @param args The arguments to be passed to the tool for its execution.
627624
* @return A result wrapper containing either the successful result of the tool's execution or an error.
628625
*/
629-
@Suppress("UNCHECKED_CAST")
630626
suspend inline fun <reified TArgs : Tool.Args, reified TResult : ToolResult> callTool(
631627
toolClass: KClass<out Tool<TArgs, TResult>>,
632628
args: TArgs
@@ -644,8 +640,8 @@ class LocalAgentLLMWriteSession internal constructor(
644640
* @return A SafeTool instance wrapping the found tool and its environment.
645641
* @throws IllegalArgumentException if the specified tool is not found in the tool registry.
646642
*/
647-
@Suppress("UNCHECKED_CAST")
648643
inline fun <reified TArgs : Tool.Args, reified TResult : ToolResult> findTool(toolClass: KClass<out Tool<TArgs, TResult>>): SafeTool<TArgs, TResult> {
644+
@Suppress("UNCHECKED_CAST")
649645
val tool = (toolRegistry.stages.first().tools.find(toolClass::isInstance) as? Tool<TArgs, TResult>
650646
?: throw IllegalArgumentException("Tool with type ${toolClass.simpleName} is not defined"))
651647

@@ -658,7 +654,6 @@ class LocalAgentLLMWriteSession internal constructor(
658654
* @param args The input arguments required for the tool execution, represented as an instance of `Tool.Args`.
659655
* @return A `SafeTool.Result` containing the outcome of the tool's execution, which may be of any type that extends `ToolResult`.
660656
*/
661-
@Suppress("UNCHECKED_CAST")
662657
suspend inline fun <reified ToolT : Tool<*, *>> callTool(
663658
args: Tool.Args
664659
): SafeTool.Result<out ToolResult> {
@@ -724,7 +719,6 @@ class LocalAgentLLMWriteSession internal constructor(
724719
* @param concurrency The maximum number of concurrent executions. Default value is 16.
725720
* @return A flow emitting the results of the tool executions wrapped in a SafeTool.Result object.
726721
*/
727-
@Suppress("UNCHECKED_CAST")
728722
inline fun <reified TArgs : Tool.Args, reified TResult : ToolResult> Flow<TArgs>.toParallelToolCalls(
729723
tool: Tool<TArgs, TResult>,
730724
concurrency: Int = 16
@@ -744,7 +738,6 @@ class LocalAgentLLMWriteSession internal constructor(
744738
* @param concurrency The maximum number of parallel executions allowed. Default is 16.
745739
* @return A Flow containing the results of the tool executions, wrapped in `SafeTool.Result`.
746740
*/
747-
@Suppress("UNCHECKED_CAST")
748741
inline fun <reified TArgs : Tool.Args, reified TResult : ToolResult> Flow<TArgs>.toParallelToolCalls(
749742
toolClass: KClass<out Tool<TArgs, TResult>>,
750743
concurrency: Int = 16
@@ -762,7 +755,6 @@ class LocalAgentLLMWriteSession internal constructor(
762755
* @param concurrency the number of concurrent tool calls to be executed. Defaults to 16.
763756
* @return a flow of raw string results from the parallel tool calls.
764757
*/
765-
@Suppress("UNCHECKED_CAST")
766758
inline fun <reified TArgs : Tool.Args, reified TResult : ToolResult> Flow<TArgs>.toParallelToolCallsRaw(
767759
toolClass: KClass<out Tool<TArgs, TResult>>,
768760
concurrency: Int = 16
@@ -782,8 +774,8 @@ class LocalAgentLLMWriteSession internal constructor(
782774
* @return the tool that matches the specified name and types
783775
* @throws IllegalArgumentException if the tool is not defined or the types are incompatible
784776
*/
785-
@Suppress("UNCHECKED_CAST")
786777
inline fun <reified TArgs : Tool.Args, reified TResult : ToolResult> findToolByNameAndArgs(toolName: String): Tool<TArgs, TResult> =
778+
@Suppress("UNCHECKED_CAST")
787779
(toolRegistry.getTool(toolName) as? Tool<TArgs, TResult>
788780
?: throw IllegalArgumentException("Tool \"$toolName\" is not defined or has incompatible arguments"))
789781

@@ -795,8 +787,8 @@ class LocalAgentLLMWriteSession internal constructor(
795787
* @throws IllegalArgumentException If the tool with the specified name is not defined or its arguments
796788
* are incompatible with the expected type.
797789
*/
798-
@Suppress("UNCHECKED_CAST")
799790
inline fun <reified TArgs : Tool.Args> findToolByName(toolName: String): SafeTool<TArgs, *> {
791+
@Suppress("UNCHECKED_CAST")
800792
val tool = (toolRegistry.getTool(toolName) as? Tool<TArgs, *>
801793
?: throw IllegalArgumentException("Tool \"$toolName\" is not defined or has incompatible arguments"))
802794

agents/agents-local/src/commonMain/kotlin/ai/grazie/code/agents/local/dsl/builders/LocalAgentEdgeBuilder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ai.grazie.code.agents.local.dsl.builders
22

3-
import ai.grazie.code.agents.core.utils.Option
3+
import ai.grazie.code.agents.local.utils.Option
44
import ai.grazie.code.agents.local.agent.stage.LocalAgentStageContext
55
import ai.grazie.code.agents.local.graph.LocalAgentEdge
66
import ai.grazie.code.agents.local.graph.LocalAgentNode

agents/agents-local/src/commonMain/kotlin/ai/grazie/code/agents/local/dsl/builders/LocalAgentNodeBuilder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ai.grazie.code.agents.local.dsl.builders
22

3-
import ai.grazie.code.agents.core.utils.Some
3+
import ai.grazie.code.agents.local.utils.Some
44
import ai.grazie.code.agents.local.agent.stage.LocalAgentStageContext
55
import ai.grazie.code.agents.local.graph.LocalAgentNode
66
import ai.grazie.code.agents.local.graph.SimpleLocalAgentNode

agents/agents-local/src/commonMain/kotlin/ai/grazie/code/agents/local/graph/LocalAgentEdge.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package ai.grazie.code.agents.local.graph
22

3-
import ai.grazie.code.agents.core.utils.Option
3+
import ai.grazie.code.agents.local.utils.Option
44
import ai.grazie.code.agents.local.agent.stage.LocalAgentStageContext
55

66
class LocalAgentEdge<IncomingOutput, OutgoingInput> internal constructor(
77
val toNode: LocalAgentNode<OutgoingInput, *>,
8-
val forwardOutput: suspend (context: LocalAgentStageContext, output: IncomingOutput) -> Option<OutgoingInput>,
8+
internal val forwardOutput: suspend (context: LocalAgentStageContext, output: IncomingOutput) -> Option<OutgoingInput>,
99
) {
1010
@Suppress("UNCHECKED_CAST")
1111
internal suspend fun forwardOutputUnsafe(output: Any?, context: LocalAgentStageContext): Option<OutgoingInput> =

agents/agents-core/src/commonMain/kotlin/ai/grazie/code/agents/core/utils/ActiveProperty.kt renamed to agents/agents-local/src/commonMain/kotlin/ai/grazie/code/agents/local/utils/ActiveProperty.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.grazie.code.agents.core.utils
1+
package ai.grazie.code.agents.local.utils
22

33
import kotlin.reflect.KProperty
44

@@ -10,7 +10,7 @@ import kotlin.reflect.KProperty
1010
* @property value The initial value of the property.
1111
* @property checkIsActive A lambda function that determines if the property is active.
1212
*/
13-
class ActiveProperty<T>(
13+
internal class ActiveProperty<T>(
1414
private var value: T,
1515
private val checkIsActive: () -> Boolean
1616
) {

agents/agents-core/src/commonMain/kotlin/ai/grazie/code/agents/core/utils/Option.kt renamed to agents/agents-local/src/commonMain/kotlin/ai/grazie/code/agents/local/utils/Option.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package ai.grazie.code.agents.core.utils
1+
package ai.grazie.code.agents.local.utils
22

3-
sealed class Option<out A> {
3+
internal sealed class Option<out A> {
44
abstract val value: A
55

66
abstract val isEmpty: Boolean
@@ -19,12 +19,12 @@ sealed class Option<out A> {
1919
}
2020
}
2121

22-
data object None : Option<Nothing>() {
22+
internal data object None : Option<Nothing>() {
2323
override val isEmpty: Boolean = true
2424

2525
override val value get() = throw NoSuchElementException("None.value")
2626
}
2727

28-
data class Some<T>(override val value: T) : Option<T>() {
28+
internal data class Some<T>(override val value: T) : Option<T>() {
2929
override val isEmpty: Boolean = false
3030
}

agents/agents-core/src/commonMain/kotlin/ai/grazie/code/agents/core/utils/RWLock.kt renamed to agents/agents-local/src/commonMain/kotlin/ai/grazie/code/agents/local/utils/RWLock.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ai.grazie.code.agents.core.utils
1+
package ai.grazie.code.agents.local.utils
22

33
import kotlinx.coroutines.sync.Mutex
44
import kotlinx.coroutines.sync.withLock
@@ -8,7 +8,7 @@ import kotlinx.coroutines.sync.withLock
88
*
99
* This implementation uses `kotlinx.coroutines.sync.Mutex` to coordinate access for both readers and writers.
1010
*/
11-
class RWLock {
11+
internal class RWLock {
1212
private val writeMutex = Mutex()
1313
private var readersCount = 0
1414
private val readersCountMutex = Mutex()

0 commit comments

Comments
 (0)