Skip to content

Commit 9de6731

Browse files
SéafraSéafra
authored andcommitted
chore: Suppress("unused") on DSL
chore: more unused stuff deleted chore: no more magic numbers chore: more instant/duration usage
1 parent 133b0fa commit 9de6731

27 files changed

Lines changed: 58 additions & 66 deletions

src/main/kotlin/org/coralprotocol/coralserver/agent/graph/GraphAgentProvider.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ import org.koin.core.component.KoinComponent
1313
@Serializable
1414
@JsonClassDiscriminator("type")
1515
@Description("A local or remote provider for an agent")
16-
sealed class GraphAgentProvider : KoinComponent {
17-
abstract val runtime: RuntimeId
16+
@Suppress("unused")
17+
sealed interface GraphAgentProvider : KoinComponent {
18+
val runtime: RuntimeId
1819

1920
@Serializable
2021
@SerialName("local")
2122
@Description("The agent will be provided by this server")
2223
data class Local(
2324
override val runtime: RuntimeId,
24-
) : GraphAgentProvider()
25+
) : GraphAgentProvider
2526

2627
@Serializable
2728
@SerialName("linked")
2829
@Description("The agent will be provided by a linked server")
2930
data class Linked(
3031
val linkedServerName: String,
3132
override val runtime: RuntimeId,
32-
) : GraphAgentProvider()
33+
) : GraphAgentProvider
3334
}

src/main/kotlin/org/coralprotocol/coralserver/agent/registry/AgentRegistrySource.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ sealed class AgentRegistrySourceIdentifier {
4242
*/
4343
@Serializable
4444
open class AgentRegistrySource(val identifier: AgentRegistrySourceIdentifier) : KoinComponent {
45-
@Suppress("unused")
4645
@Serializable(with = InstantSerializer::class)
4746
val timestamp = utcTimeNow()
4847

src/main/kotlin/org/coralprotocol/coralserver/agent/registry/RegistryAgent.kt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import kotlinx.serialization.Transient
55
import org.coralprotocol.coralserver.agent.registry.option.AgentOption
66
import org.coralprotocol.coralserver.agent.registry.option.AgentOptionSerializerMap
77
import org.coralprotocol.coralserver.agent.runtime.LocalAgentRuntimes
8-
import org.coralprotocol.coralserver.agent.runtime.RuntimeId
98
import java.nio.file.Path
109

1110
/**
@@ -81,19 +80,4 @@ data class RegistryAgent(
8180
@Transient
8281
val requiredOptions = options
8382
.filterValues { it.required }
84-
}
85-
86-
@Serializable
87-
data class PublicRegistryAgent(
88-
val id: RegistryAgentIdentifier,
89-
val runtimes: List<RuntimeId>,
90-
91-
@Serializable(with = AgentOptionSerializerMap::class)
92-
val options: Map<String, AgentOption>,
93-
)
94-
95-
fun RegistryAgent.toPublic(): PublicRegistryAgent = PublicRegistryAgent(
96-
id = identifier,
97-
runtimes = runtimes.toRuntimeIds(),
98-
options = options
99-
)
83+
}

src/main/kotlin/org/coralprotocol/coralserver/agent/registry/RegistryAgentStringSerializer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ sealed interface PotentialStringReference {
8484
}
8585

8686
open class RegistryAgentStringSerializer : KSerializer<String>, KoinComponent {
87-
open fun defaultInputEncodingOptions(reference: PotentialStringReference) =
87+
open fun defaultInputEncodingOptions(@Suppress("unused") reference: PotentialStringReference) =
8888
EncodingOptions()
8989

90-
open fun defaultOutputEncodingOptions(reference: PotentialStringReference) =
90+
open fun defaultOutputEncodingOptions(@Suppress("unused") reference: PotentialStringReference) =
9191
EncodingOptions()
9292

9393
private val stringSerializer = PotentialStringReference.String.serializer()

src/main/kotlin/org/coralprotocol/coralserver/agent/registry/option/AgentOptionValidation.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,69 +90,79 @@ abstract class NumericAgentOptionValidation<T : Comparable<T>> {
9090
}
9191

9292
@Serializable
93+
@Suppress("unused")
9394
data class ByteAgentOptionValidation(
9495
override val variants: List<Byte>? = null,
9596
override val min: Byte? = null,
9697
override val max: Byte? = null
9798
) : NumericAgentOptionValidation<Byte>()
9899

99100
@Serializable
101+
@Suppress("unused")
100102
data class ShortAgentOptionValidation(
101103
override val variants: List<Short>? = null,
102104
override val min: Short? = null,
103105
override val max: Short? = null
104106
) : NumericAgentOptionValidation<Short>()
105107

106108
@Serializable
109+
@Suppress("unused")
107110
data class IntAgentOptionValidation(
108111
override val variants: List<Int>? = null,
109112
override val min: Int? = null,
110113
override val max: Int? = null
111114
) : NumericAgentOptionValidation<Int>()
112115

113116
@Serializable
117+
@Suppress("unused")
114118
data class LongAgentOptionValidation(
115119
override val variants: List<Long>? = null,
116120
override val min: Long? = null,
117121
override val max: Long? = null
118122
) : NumericAgentOptionValidation<Long>()
119123

120124
@Serializable
125+
@Suppress("unused")
121126
data class UByteAgentOptionValidation(
122127
override val variants: List<UByte>? = null,
123128
override val min: UByte? = null,
124129
override val max: UByte? = null
125130
) : NumericAgentOptionValidation<UByte>()
126131

127132
@Serializable
133+
@Suppress("unused")
128134
data class UShortAgentOptionValidation(
129135
override val variants: List<UShort>? = null,
130136
override val min: UShort? = null,
131137
override val max: UShort? = null
132138
) : NumericAgentOptionValidation<UShort>()
133139

134140
@Serializable
141+
@Suppress("unused")
135142
data class UIntAgentOptionValidation(
136143
override val variants: List<UInt>? = null,
137144
override val min: UInt? = null,
138145
override val max: UInt? = null
139146
) : NumericAgentOptionValidation<UInt>()
140147

141148
@Serializable
149+
@Suppress("unused")
142150
data class ULongAgentOptionValidation(
143151
override val variants: List<ULong>? = null,
144152
override val min: ULong? = null,
145153
override val max: ULong? = null
146154
) : NumericAgentOptionValidation<ULong>()
147155

148156
@Serializable
157+
@Suppress("unused")
149158
data class FloatAgentOptionValidation(
150159
override val variants: List<Float>? = null,
151160
override val min: Float? = null,
152161
override val max: Float? = null
153162
) : NumericAgentOptionValidation<Float>()
154163

155164
@Serializable
165+
@Suppress("unused")
156166
data class DoubleAgentOptionValidation(
157167
override val variants: List<Double>? = null,
158168
override val min: Double? = null,

src/main/kotlin/org/coralprotocol/coralserver/agent/runtime/LocalAgentRuntimes.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ data class LocalAgentRuntimes(
4444
RuntimeId.PROTOTYPE -> prototypeRuntime
4545
}
4646

47+
@Suppress("unused")
4748
fun toRuntimeIds(): List<RuntimeId> {
4849
return buildList {
4950
executableRuntime?.let { add(RuntimeId.EXECUTABLE) }

src/main/kotlin/org/coralprotocol/coralserver/dsl/AgentOptionBuilder.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -561,55 +561,48 @@ fun blobListOptionWithValue(value: List<String>, block: BlobListAgentOptionBuild
561561
fun booleanOptionWithValue(value: Boolean, block: BooleanAgentOptionBuilder.() -> Unit = {}) =
562562
AgentOptionWithValue(booleanOption(block), PolymorphicAgentOptionValue.Boolean(value))
563563

564-
@Suppress("unused")
565564
fun byteOptionWithValue(value: Byte, block: ByteAgentOptionBuilder.() -> Unit = {}) =
566565
AgentOptionWithValue(byteOption(block), PolymorphicAgentOptionValue.Byte(value))
567566

568567
@Suppress("unused")
569568
fun byteListOptionWithValue(value: List<Byte>, block: ByteListAgentOptionBuilder.() -> Unit = {}) =
570569
AgentOptionWithValue(byteListOption(block), PolymorphicAgentOptionValue.ByteList(value))
571570

572-
@Suppress("unused")
573571
fun shortOptionWithValue(value: Short, block: ShortAgentOptionBuilder.() -> Unit = {}) =
574572
AgentOptionWithValue(shortOption(block), PolymorphicAgentOptionValue.Short(value))
575573

576574
@Suppress("unused")
577575
fun shortListOptionWithValue(value: List<Short>, block: ShortListAgentOptionBuilder.() -> Unit = {}) =
578576
AgentOptionWithValue(shortListOption(block), PolymorphicAgentOptionValue.ShortList(value))
579577

580-
@Suppress("unused")
581578
fun intOptionWithValue(value: Int, block: IntAgentOptionBuilder.() -> Unit = {}) =
582579
AgentOptionWithValue(intOption(block), PolymorphicAgentOptionValue.Int(value))
583580

584581
@Suppress("unused")
585582
fun intListOptionWithValue(value: List<Int>, block: IntListAgentOptionBuilder.() -> Unit = {}) =
586583
AgentOptionWithValue(intListOption(block), PolymorphicAgentOptionValue.IntList(value))
587584

588-
@Suppress("unused")
589585
fun longOptionWithValue(value: Long, block: LongAgentOptionBuilder.() -> Unit = {}) =
590586
AgentOptionWithValue(longOption(block), PolymorphicAgentOptionValue.Long(value))
591587

592588
@Suppress("unused")
593589
fun longListOptionWithValue(value: List<Long>, block: LongListAgentOptionBuilder.() -> Unit = {}) =
594590
AgentOptionWithValue(longListOption(block), PolymorphicAgentOptionValue.LongList(value))
595591

596-
@Suppress("unused")
597592
fun unsignedByteOptionWithValue(value: UByte, block: UByteAgentOptionBuilder.() -> Unit = {}) =
598593
AgentOptionWithValue(unsignedByteOption(block), PolymorphicAgentOptionValue.UByte(value))
599594

600595
@Suppress("unused")
601596
fun unsignedByteListOptionWithValue(value: List<UByte>, block: UByteListAgentOptionBuilder.() -> Unit = {}) =
602597
AgentOptionWithValue(unsignedByteListOption(block), PolymorphicAgentOptionValue.UByteList(value))
603598

604-
@Suppress("unused")
605599
fun unsignedShortOptionWithValue(value: UShort, block: UShortAgentOptionBuilder.() -> Unit = {}) =
606600
AgentOptionWithValue(unsignedShortOption(block), PolymorphicAgentOptionValue.UShort(value))
607601

608602
@Suppress("unused")
609603
fun unsignedShortListOptionWithValue(value: List<UShort>, block: UShortListAgentOptionBuilder.() -> Unit = {}) =
610604
AgentOptionWithValue(unsignedShortListOption(block), PolymorphicAgentOptionValue.UShortList(value))
611605

612-
@Suppress("unused")
613606
fun unsignedIntOptionWithValue(value: UInt, block: UIntAgentOptionBuilder.() -> Unit = {}) =
614607
AgentOptionWithValue(unsignedIntOption(block), PolymorphicAgentOptionValue.UInt(value))
615608

@@ -625,15 +618,13 @@ fun unsignedLongOptionWithValue(value: String, block: ULongAgentOptionBuilder.()
625618
fun unsignedLongListOptionWithValue(value: List<String>, block: ULongListAgentOptionBuilder.() -> Unit = {}) =
626619
AgentOptionWithValue(unsignedLongListOption(block), PolymorphicAgentOptionValue.ULongList(value))
627620

628-
@Suppress("unused")
629621
fun floatOptionWithValue(value: Float, block: FloatAgentOptionBuilder.() -> Unit = {}) =
630622
AgentOptionWithValue(floatOption(block), PolymorphicAgentOptionValue.Float(value))
631623

632624
@Suppress("unused")
633625
fun floatListOptionWithValue(value: List<Float>, block: FloatListAgentOptionBuilder.() -> Unit = {}) =
634626
AgentOptionWithValue(floatListOption(block), PolymorphicAgentOptionValue.FloatList(value))
635627

636-
@Suppress("unused")
637628
fun doubleOptionWithValue(value: Double, block: DoubleAgentOptionBuilder.() -> Unit = {}) =
638629
AgentOptionWithValue(doubleOption(block), PolymorphicAgentOptionValue.Double(value))
639630

src/main/kotlin/org/coralprotocol/coralserver/dsl/CommonGraphAgentBuilder.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import kotlin.time.Duration
1414
import kotlin.time.Duration.Companion.milliseconds
1515

1616
@CoralDsl
17+
@Suppress("unused")
1718
open class CommonGraphAgentBuilder(
1819
open var name: String,
1920
) {
@@ -50,6 +51,7 @@ open class CommonGraphAgentBuilder(
5051
}
5152

5253
@CoralDsl
54+
@Suppress("unused")
5355
class GraphAgentBuilder(name: String) : CommonGraphAgentBuilder(name) {
5456
private val registryAgentBuilder = RegistryAgentBuilder(name)
5557
private val options = mutableMapOf<String, AnyAgentOptionWithValue>()
@@ -269,6 +271,7 @@ class GraphAgentBuilder(name: String) : CommonGraphAgentBuilder(name) {
269271
}
270272

271273
@CoralDsl
274+
@Suppress("unused")
272275
open class GraphAgentRequestBuilder(
273276
val identifier: RegistryAgentIdentifier,
274277
override var name: String = identifier.name

src/main/kotlin/org/coralprotocol/coralserver/dsl/RegistryAgentBuilder.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ import org.coralprotocol.coralserver.util.streamableHttpFunctionRuntime
1717
import java.nio.file.Path
1818

1919
@CoralDsl
20+
@Suppress("unused")
2021
class PrototypeStringBuilder {
2122
fun inline(value: String): PrototypeString = PrototypeString.Inline(value)
2223
fun option(name: String): PrototypeString = PrototypeString.Option(name)
2324
}
2425

2526
@CoralDsl
27+
@Suppress("unused")
2628
class PrototypeStringListBuilder {
2729
private val parts = mutableListOf<PrototypeString>()
2830

@@ -52,6 +54,7 @@ class PrototypeStringListBuilder {
5254
}
5355

5456
@CoralDsl
57+
@Suppress("unused")
5558
class UrlPartListBuilder {
5659
private val parts = mutableListOf<PrototypeUrlPart>()
5760

@@ -92,6 +95,7 @@ inline fun <OptionType : PolymorphicAgentOption<ValueType, BackingType>, reified
9295

9396

9497
@CoralDsl
98+
@Suppress("unused")
9599
class RegistryAgentBuilder(
96100
var name: String,
97101
) {

src/main/kotlin/org/coralprotocol/coralserver/dsl/SessionRequestBuilder.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,6 @@ val Double.cents: AgentBudgetUnit
212212
val Int.dollars: AgentBudgetUnit
213213
get() = AgentBudgetUnit(this.toULong() * MICRO_CENTS_TO_DOLLARS)
214214

215+
@Suppress("unused")
215216
val Double.dollars: AgentBudgetUnit
216217
get() = AgentBudgetUnit((this * MICRO_CENTS_TO_DOLLARS.toDouble()).toULong())

0 commit comments

Comments
 (0)