capacitor-native-agent 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3082 @@
1
+ // This file was autogenerated by some hot garbage in the `uniffi` crate.
2
+ // Trust me, you don't want to mess with it!
3
+
4
+ @file:Suppress("NAME_SHADOWING")
5
+
6
+ package uniffi.native_agent_ffi
7
+
8
+ // Common helper code.
9
+ //
10
+ // Ideally this would live in a separate .kt file where it can be unittested etc
11
+ // in isolation, and perhaps even published as a re-useable package.
12
+ //
13
+ // However, it's important that the details of how this helper code works (e.g. the
14
+ // way that different builtin types are passed across the FFI) exactly match what's
15
+ // expected by the Rust code on the other side of the interface. In practice right
16
+ // now that means coming from the exact some version of `uniffi` that was used to
17
+ // compile the Rust component. The easiest way to ensure this is to bundle the Kotlin
18
+ // helpers directly inline like we're doing here.
19
+
20
+ import com.sun.jna.Library
21
+ import com.sun.jna.IntegerType
22
+ import com.sun.jna.Native
23
+ import com.sun.jna.Pointer
24
+ import com.sun.jna.Structure
25
+ import com.sun.jna.Callback
26
+ import com.sun.jna.ptr.*
27
+ import java.nio.ByteBuffer
28
+ import java.nio.ByteOrder
29
+ import java.nio.CharBuffer
30
+ import java.nio.charset.CodingErrorAction
31
+ import java.util.concurrent.atomic.AtomicLong
32
+ import java.util.concurrent.ConcurrentHashMap
33
+ import java.util.concurrent.atomic.AtomicBoolean
34
+
35
+ // This is a helper for safely working with byte buffers returned from the Rust code.
36
+ // A rust-owned buffer is represented by its capacity, its current length, and a
37
+ // pointer to the underlying data.
38
+
39
+ /**
40
+ * @suppress
41
+ */
42
+ @Structure.FieldOrder("capacity", "len", "data")
43
+ open class RustBuffer : Structure() {
44
+ // Note: `capacity` and `len` are actually `ULong` values, but JVM only supports signed values.
45
+ // When dealing with these fields, make sure to call `toULong()`.
46
+ @JvmField var capacity: Long = 0
47
+ @JvmField var len: Long = 0
48
+ @JvmField var data: Pointer? = null
49
+
50
+ class ByValue: RustBuffer(), Structure.ByValue
51
+ class ByReference: RustBuffer(), Structure.ByReference
52
+
53
+ internal fun setValue(other: RustBuffer) {
54
+ capacity = other.capacity
55
+ len = other.len
56
+ data = other.data
57
+ }
58
+
59
+ companion object {
60
+ internal fun alloc(size: ULong = 0UL) = uniffiRustCall() { status ->
61
+ // Note: need to convert the size to a `Long` value to make this work with JVM.
62
+ UniffiLib.INSTANCE.ffi_native_agent_ffi_rustbuffer_alloc(size.toLong(), status)
63
+ }.also {
64
+ if(it.data == null) {
65
+ throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})")
66
+ }
67
+ }
68
+
69
+ internal fun create(capacity: ULong, len: ULong, data: Pointer?): RustBuffer.ByValue {
70
+ var buf = RustBuffer.ByValue()
71
+ buf.capacity = capacity.toLong()
72
+ buf.len = len.toLong()
73
+ buf.data = data
74
+ return buf
75
+ }
76
+
77
+ internal fun free(buf: RustBuffer.ByValue) = uniffiRustCall() { status ->
78
+ UniffiLib.INSTANCE.ffi_native_agent_ffi_rustbuffer_free(buf, status)
79
+ }
80
+ }
81
+
82
+ @Suppress("TooGenericExceptionThrown")
83
+ fun asByteBuffer() =
84
+ this.data?.getByteBuffer(0, this.len.toLong())?.also {
85
+ it.order(ByteOrder.BIG_ENDIAN)
86
+ }
87
+ }
88
+
89
+ /**
90
+ * The equivalent of the `*mut RustBuffer` type.
91
+ * Required for callbacks taking in an out pointer.
92
+ *
93
+ * Size is the sum of all values in the struct.
94
+ *
95
+ * @suppress
96
+ */
97
+ class RustBufferByReference : ByReference(16) {
98
+ /**
99
+ * Set the pointed-to `RustBuffer` to the given value.
100
+ */
101
+ fun setValue(value: RustBuffer.ByValue) {
102
+ // NOTE: The offsets are as they are in the C-like struct.
103
+ val pointer = getPointer()
104
+ pointer.setLong(0, value.capacity)
105
+ pointer.setLong(8, value.len)
106
+ pointer.setPointer(16, value.data)
107
+ }
108
+
109
+ /**
110
+ * Get a `RustBuffer.ByValue` from this reference.
111
+ */
112
+ fun getValue(): RustBuffer.ByValue {
113
+ val pointer = getPointer()
114
+ val value = RustBuffer.ByValue()
115
+ value.writeField("capacity", pointer.getLong(0))
116
+ value.writeField("len", pointer.getLong(8))
117
+ value.writeField("data", pointer.getLong(16))
118
+
119
+ return value
120
+ }
121
+ }
122
+
123
+ // This is a helper for safely passing byte references into the rust code.
124
+ // It's not actually used at the moment, because there aren't many things that you
125
+ // can take a direct pointer to in the JVM, and if we're going to copy something
126
+ // then we might as well copy it into a `RustBuffer`. But it's here for API
127
+ // completeness.
128
+
129
+ @Structure.FieldOrder("len", "data")
130
+ internal open class ForeignBytes : Structure() {
131
+ @JvmField var len: Int = 0
132
+ @JvmField var data: Pointer? = null
133
+
134
+ class ByValue : ForeignBytes(), Structure.ByValue
135
+ }
136
+ /**
137
+ * The FfiConverter interface handles converter types to and from the FFI
138
+ *
139
+ * All implementing objects should be public to support external types. When a
140
+ * type is external we need to import it's FfiConverter.
141
+ *
142
+ * @suppress
143
+ */
144
+ public interface FfiConverter<KotlinType, FfiType> {
145
+ // Convert an FFI type to a Kotlin type
146
+ fun lift(value: FfiType): KotlinType
147
+
148
+ // Convert an Kotlin type to an FFI type
149
+ fun lower(value: KotlinType): FfiType
150
+
151
+ // Read a Kotlin type from a `ByteBuffer`
152
+ fun read(buf: ByteBuffer): KotlinType
153
+
154
+ // Calculate bytes to allocate when creating a `RustBuffer`
155
+ //
156
+ // This must return at least as many bytes as the write() function will
157
+ // write. It can return more bytes than needed, for example when writing
158
+ // Strings we can't know the exact bytes needed until we the UTF-8
159
+ // encoding, so we pessimistically allocate the largest size possible (3
160
+ // bytes per codepoint). Allocating extra bytes is not really a big deal
161
+ // because the `RustBuffer` is short-lived.
162
+ fun allocationSize(value: KotlinType): ULong
163
+
164
+ // Write a Kotlin type to a `ByteBuffer`
165
+ fun write(value: KotlinType, buf: ByteBuffer)
166
+
167
+ // Lower a value into a `RustBuffer`
168
+ //
169
+ // This method lowers a value into a `RustBuffer` rather than the normal
170
+ // FfiType. It's used by the callback interface code. Callback interface
171
+ // returns are always serialized into a `RustBuffer` regardless of their
172
+ // normal FFI type.
173
+ fun lowerIntoRustBuffer(value: KotlinType): RustBuffer.ByValue {
174
+ val rbuf = RustBuffer.alloc(allocationSize(value))
175
+ try {
176
+ val bbuf = rbuf.data!!.getByteBuffer(0, rbuf.capacity).also {
177
+ it.order(ByteOrder.BIG_ENDIAN)
178
+ }
179
+ write(value, bbuf)
180
+ rbuf.writeField("len", bbuf.position().toLong())
181
+ return rbuf
182
+ } catch (e: Throwable) {
183
+ RustBuffer.free(rbuf)
184
+ throw e
185
+ }
186
+ }
187
+
188
+ // Lift a value from a `RustBuffer`.
189
+ //
190
+ // This here mostly because of the symmetry with `lowerIntoRustBuffer()`.
191
+ // It's currently only used by the `FfiConverterRustBuffer` class below.
192
+ fun liftFromRustBuffer(rbuf: RustBuffer.ByValue): KotlinType {
193
+ val byteBuf = rbuf.asByteBuffer()!!
194
+ try {
195
+ val item = read(byteBuf)
196
+ if (byteBuf.hasRemaining()) {
197
+ throw RuntimeException("junk remaining in buffer after lifting, something is very wrong!!")
198
+ }
199
+ return item
200
+ } finally {
201
+ RustBuffer.free(rbuf)
202
+ }
203
+ }
204
+ }
205
+
206
+ /**
207
+ * FfiConverter that uses `RustBuffer` as the FfiType
208
+ *
209
+ * @suppress
210
+ */
211
+ public interface FfiConverterRustBuffer<KotlinType>: FfiConverter<KotlinType, RustBuffer.ByValue> {
212
+ override fun lift(value: RustBuffer.ByValue) = liftFromRustBuffer(value)
213
+ override fun lower(value: KotlinType) = lowerIntoRustBuffer(value)
214
+ }
215
+ // A handful of classes and functions to support the generated data structures.
216
+ // This would be a good candidate for isolating in its own ffi-support lib.
217
+
218
+ internal const val UNIFFI_CALL_SUCCESS = 0.toByte()
219
+ internal const val UNIFFI_CALL_ERROR = 1.toByte()
220
+ internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte()
221
+
222
+ @Structure.FieldOrder("code", "error_buf")
223
+ internal open class UniffiRustCallStatus : Structure() {
224
+ @JvmField var code: Byte = 0
225
+ @JvmField var error_buf: RustBuffer.ByValue = RustBuffer.ByValue()
226
+
227
+ class ByValue: UniffiRustCallStatus(), Structure.ByValue
228
+
229
+ fun isSuccess(): Boolean {
230
+ return code == UNIFFI_CALL_SUCCESS
231
+ }
232
+
233
+ fun isError(): Boolean {
234
+ return code == UNIFFI_CALL_ERROR
235
+ }
236
+
237
+ fun isPanic(): Boolean {
238
+ return code == UNIFFI_CALL_UNEXPECTED_ERROR
239
+ }
240
+
241
+ companion object {
242
+ fun create(code: Byte, errorBuf: RustBuffer.ByValue): UniffiRustCallStatus.ByValue {
243
+ val callStatus = UniffiRustCallStatus.ByValue()
244
+ callStatus.code = code
245
+ callStatus.error_buf = errorBuf
246
+ return callStatus
247
+ }
248
+ }
249
+ }
250
+
251
+ class InternalException(message: String) : kotlin.Exception(message)
252
+
253
+ /**
254
+ * Each top-level error class has a companion object that can lift the error from the call status's rust buffer
255
+ *
256
+ * @suppress
257
+ */
258
+ interface UniffiRustCallStatusErrorHandler<E> {
259
+ fun lift(error_buf: RustBuffer.ByValue): E;
260
+ }
261
+
262
+ // Helpers for calling Rust
263
+ // In practice we usually need to be synchronized to call this safely, so it doesn't
264
+ // synchronize itself
265
+
266
+ // Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err
267
+ private inline fun <U, E: kotlin.Exception> uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler<E>, callback: (UniffiRustCallStatus) -> U): U {
268
+ var status = UniffiRustCallStatus()
269
+ val return_value = callback(status)
270
+ uniffiCheckCallStatus(errorHandler, status)
271
+ return return_value
272
+ }
273
+
274
+ // Check UniffiRustCallStatus and throw an error if the call wasn't successful
275
+ private fun<E: kotlin.Exception> uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler<E>, status: UniffiRustCallStatus) {
276
+ if (status.isSuccess()) {
277
+ return
278
+ } else if (status.isError()) {
279
+ throw errorHandler.lift(status.error_buf)
280
+ } else if (status.isPanic()) {
281
+ // when the rust code sees a panic, it tries to construct a rustbuffer
282
+ // with the message. but if that code panics, then it just sends back
283
+ // an empty buffer.
284
+ if (status.error_buf.len > 0) {
285
+ throw InternalException(FfiConverterString.lift(status.error_buf))
286
+ } else {
287
+ throw InternalException("Rust panic")
288
+ }
289
+ } else {
290
+ throw InternalException("Unknown rust call status: $status.code")
291
+ }
292
+ }
293
+
294
+ /**
295
+ * UniffiRustCallStatusErrorHandler implementation for times when we don't expect a CALL_ERROR
296
+ *
297
+ * @suppress
298
+ */
299
+ object UniffiNullRustCallStatusErrorHandler: UniffiRustCallStatusErrorHandler<InternalException> {
300
+ override fun lift(error_buf: RustBuffer.ByValue): InternalException {
301
+ RustBuffer.free(error_buf)
302
+ return InternalException("Unexpected CALL_ERROR")
303
+ }
304
+ }
305
+
306
+ // Call a rust function that returns a plain value
307
+ private inline fun <U> uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U {
308
+ return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback)
309
+ }
310
+
311
+ internal inline fun<T> uniffiTraitInterfaceCall(
312
+ callStatus: UniffiRustCallStatus,
313
+ makeCall: () -> T,
314
+ writeReturn: (T) -> Unit,
315
+ ) {
316
+ try {
317
+ writeReturn(makeCall())
318
+ } catch(e: kotlin.Exception) {
319
+ callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
320
+ callStatus.error_buf = FfiConverterString.lower(e.toString())
321
+ }
322
+ }
323
+
324
+ internal inline fun<T, reified E: Throwable> uniffiTraitInterfaceCallWithError(
325
+ callStatus: UniffiRustCallStatus,
326
+ makeCall: () -> T,
327
+ writeReturn: (T) -> Unit,
328
+ lowerError: (E) -> RustBuffer.ByValue
329
+ ) {
330
+ try {
331
+ writeReturn(makeCall())
332
+ } catch(e: kotlin.Exception) {
333
+ if (e is E) {
334
+ callStatus.code = UNIFFI_CALL_ERROR
335
+ callStatus.error_buf = lowerError(e)
336
+ } else {
337
+ callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
338
+ callStatus.error_buf = FfiConverterString.lower(e.toString())
339
+ }
340
+ }
341
+ }
342
+ // Map handles to objects
343
+ //
344
+ // This is used pass an opaque 64-bit handle representing a foreign object to the Rust code.
345
+ internal class UniffiHandleMap<T: Any> {
346
+ private val map = ConcurrentHashMap<Long, T>()
347
+ private val counter = java.util.concurrent.atomic.AtomicLong(0)
348
+
349
+ val size: Int
350
+ get() = map.size
351
+
352
+ // Insert a new object into the handle map and get a handle for it
353
+ fun insert(obj: T): Long {
354
+ val handle = counter.getAndAdd(1)
355
+ map.put(handle, obj)
356
+ return handle
357
+ }
358
+
359
+ // Get an object from the handle map
360
+ fun get(handle: Long): T {
361
+ return map.get(handle) ?: throw InternalException("UniffiHandleMap.get: Invalid handle")
362
+ }
363
+
364
+ // Remove an entry from the handlemap and get the Kotlin object back
365
+ fun remove(handle: Long): T {
366
+ return map.remove(handle) ?: throw InternalException("UniffiHandleMap: Invalid handle")
367
+ }
368
+ }
369
+
370
+ // Contains loading, initialization code,
371
+ // and the FFI Function declarations in a com.sun.jna.Library.
372
+ @Synchronized
373
+ private fun findLibraryName(componentName: String): String {
374
+ val libOverride = System.getProperty("uniffi.component.$componentName.libraryOverride")
375
+ if (libOverride != null) {
376
+ return libOverride
377
+ }
378
+ return "native_agent_ffi"
379
+ }
380
+
381
+ private inline fun <reified Lib : Library> loadIndirect(
382
+ componentName: String
383
+ ): Lib {
384
+ return Native.load<Lib>(findLibraryName(componentName), Lib::class.java)
385
+ }
386
+
387
+ // Define FFI callback types
388
+ internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback {
389
+ fun callback(`data`: Long,`pollResult`: Byte,)
390
+ }
391
+ internal interface UniffiForeignFutureFree : com.sun.jna.Callback {
392
+ fun callback(`handle`: Long,)
393
+ }
394
+ internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback {
395
+ fun callback(`handle`: Long,)
396
+ }
397
+ @Structure.FieldOrder("handle", "free")
398
+ internal open class UniffiForeignFuture(
399
+ @JvmField internal var `handle`: Long = 0.toLong(),
400
+ @JvmField internal var `free`: UniffiForeignFutureFree? = null,
401
+ ) : Structure() {
402
+ class UniffiByValue(
403
+ `handle`: Long = 0.toLong(),
404
+ `free`: UniffiForeignFutureFree? = null,
405
+ ): UniffiForeignFuture(`handle`,`free`,), Structure.ByValue
406
+
407
+ internal fun uniffiSetValue(other: UniffiForeignFuture) {
408
+ `handle` = other.`handle`
409
+ `free` = other.`free`
410
+ }
411
+
412
+ }
413
+ @Structure.FieldOrder("returnValue", "callStatus")
414
+ internal open class UniffiForeignFutureStructU8(
415
+ @JvmField internal var `returnValue`: Byte = 0.toByte(),
416
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
417
+ ) : Structure() {
418
+ class UniffiByValue(
419
+ `returnValue`: Byte = 0.toByte(),
420
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
421
+ ): UniffiForeignFutureStructU8(`returnValue`,`callStatus`,), Structure.ByValue
422
+
423
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructU8) {
424
+ `returnValue` = other.`returnValue`
425
+ `callStatus` = other.`callStatus`
426
+ }
427
+
428
+ }
429
+ internal interface UniffiForeignFutureCompleteU8 : com.sun.jna.Callback {
430
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU8.UniffiByValue,)
431
+ }
432
+ @Structure.FieldOrder("returnValue", "callStatus")
433
+ internal open class UniffiForeignFutureStructI8(
434
+ @JvmField internal var `returnValue`: Byte = 0.toByte(),
435
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
436
+ ) : Structure() {
437
+ class UniffiByValue(
438
+ `returnValue`: Byte = 0.toByte(),
439
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
440
+ ): UniffiForeignFutureStructI8(`returnValue`,`callStatus`,), Structure.ByValue
441
+
442
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructI8) {
443
+ `returnValue` = other.`returnValue`
444
+ `callStatus` = other.`callStatus`
445
+ }
446
+
447
+ }
448
+ internal interface UniffiForeignFutureCompleteI8 : com.sun.jna.Callback {
449
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI8.UniffiByValue,)
450
+ }
451
+ @Structure.FieldOrder("returnValue", "callStatus")
452
+ internal open class UniffiForeignFutureStructU16(
453
+ @JvmField internal var `returnValue`: Short = 0.toShort(),
454
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
455
+ ) : Structure() {
456
+ class UniffiByValue(
457
+ `returnValue`: Short = 0.toShort(),
458
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
459
+ ): UniffiForeignFutureStructU16(`returnValue`,`callStatus`,), Structure.ByValue
460
+
461
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructU16) {
462
+ `returnValue` = other.`returnValue`
463
+ `callStatus` = other.`callStatus`
464
+ }
465
+
466
+ }
467
+ internal interface UniffiForeignFutureCompleteU16 : com.sun.jna.Callback {
468
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU16.UniffiByValue,)
469
+ }
470
+ @Structure.FieldOrder("returnValue", "callStatus")
471
+ internal open class UniffiForeignFutureStructI16(
472
+ @JvmField internal var `returnValue`: Short = 0.toShort(),
473
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
474
+ ) : Structure() {
475
+ class UniffiByValue(
476
+ `returnValue`: Short = 0.toShort(),
477
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
478
+ ): UniffiForeignFutureStructI16(`returnValue`,`callStatus`,), Structure.ByValue
479
+
480
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructI16) {
481
+ `returnValue` = other.`returnValue`
482
+ `callStatus` = other.`callStatus`
483
+ }
484
+
485
+ }
486
+ internal interface UniffiForeignFutureCompleteI16 : com.sun.jna.Callback {
487
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI16.UniffiByValue,)
488
+ }
489
+ @Structure.FieldOrder("returnValue", "callStatus")
490
+ internal open class UniffiForeignFutureStructU32(
491
+ @JvmField internal var `returnValue`: Int = 0,
492
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
493
+ ) : Structure() {
494
+ class UniffiByValue(
495
+ `returnValue`: Int = 0,
496
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
497
+ ): UniffiForeignFutureStructU32(`returnValue`,`callStatus`,), Structure.ByValue
498
+
499
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructU32) {
500
+ `returnValue` = other.`returnValue`
501
+ `callStatus` = other.`callStatus`
502
+ }
503
+
504
+ }
505
+ internal interface UniffiForeignFutureCompleteU32 : com.sun.jna.Callback {
506
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU32.UniffiByValue,)
507
+ }
508
+ @Structure.FieldOrder("returnValue", "callStatus")
509
+ internal open class UniffiForeignFutureStructI32(
510
+ @JvmField internal var `returnValue`: Int = 0,
511
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
512
+ ) : Structure() {
513
+ class UniffiByValue(
514
+ `returnValue`: Int = 0,
515
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
516
+ ): UniffiForeignFutureStructI32(`returnValue`,`callStatus`,), Structure.ByValue
517
+
518
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructI32) {
519
+ `returnValue` = other.`returnValue`
520
+ `callStatus` = other.`callStatus`
521
+ }
522
+
523
+ }
524
+ internal interface UniffiForeignFutureCompleteI32 : com.sun.jna.Callback {
525
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI32.UniffiByValue,)
526
+ }
527
+ @Structure.FieldOrder("returnValue", "callStatus")
528
+ internal open class UniffiForeignFutureStructU64(
529
+ @JvmField internal var `returnValue`: Long = 0.toLong(),
530
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
531
+ ) : Structure() {
532
+ class UniffiByValue(
533
+ `returnValue`: Long = 0.toLong(),
534
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
535
+ ): UniffiForeignFutureStructU64(`returnValue`,`callStatus`,), Structure.ByValue
536
+
537
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructU64) {
538
+ `returnValue` = other.`returnValue`
539
+ `callStatus` = other.`callStatus`
540
+ }
541
+
542
+ }
543
+ internal interface UniffiForeignFutureCompleteU64 : com.sun.jna.Callback {
544
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructU64.UniffiByValue,)
545
+ }
546
+ @Structure.FieldOrder("returnValue", "callStatus")
547
+ internal open class UniffiForeignFutureStructI64(
548
+ @JvmField internal var `returnValue`: Long = 0.toLong(),
549
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
550
+ ) : Structure() {
551
+ class UniffiByValue(
552
+ `returnValue`: Long = 0.toLong(),
553
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
554
+ ): UniffiForeignFutureStructI64(`returnValue`,`callStatus`,), Structure.ByValue
555
+
556
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructI64) {
557
+ `returnValue` = other.`returnValue`
558
+ `callStatus` = other.`callStatus`
559
+ }
560
+
561
+ }
562
+ internal interface UniffiForeignFutureCompleteI64 : com.sun.jna.Callback {
563
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructI64.UniffiByValue,)
564
+ }
565
+ @Structure.FieldOrder("returnValue", "callStatus")
566
+ internal open class UniffiForeignFutureStructF32(
567
+ @JvmField internal var `returnValue`: Float = 0.0f,
568
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
569
+ ) : Structure() {
570
+ class UniffiByValue(
571
+ `returnValue`: Float = 0.0f,
572
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
573
+ ): UniffiForeignFutureStructF32(`returnValue`,`callStatus`,), Structure.ByValue
574
+
575
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructF32) {
576
+ `returnValue` = other.`returnValue`
577
+ `callStatus` = other.`callStatus`
578
+ }
579
+
580
+ }
581
+ internal interface UniffiForeignFutureCompleteF32 : com.sun.jna.Callback {
582
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructF32.UniffiByValue,)
583
+ }
584
+ @Structure.FieldOrder("returnValue", "callStatus")
585
+ internal open class UniffiForeignFutureStructF64(
586
+ @JvmField internal var `returnValue`: Double = 0.0,
587
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
588
+ ) : Structure() {
589
+ class UniffiByValue(
590
+ `returnValue`: Double = 0.0,
591
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
592
+ ): UniffiForeignFutureStructF64(`returnValue`,`callStatus`,), Structure.ByValue
593
+
594
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructF64) {
595
+ `returnValue` = other.`returnValue`
596
+ `callStatus` = other.`callStatus`
597
+ }
598
+
599
+ }
600
+ internal interface UniffiForeignFutureCompleteF64 : com.sun.jna.Callback {
601
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructF64.UniffiByValue,)
602
+ }
603
+ @Structure.FieldOrder("returnValue", "callStatus")
604
+ internal open class UniffiForeignFutureStructPointer(
605
+ @JvmField internal var `returnValue`: Pointer = Pointer.NULL,
606
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
607
+ ) : Structure() {
608
+ class UniffiByValue(
609
+ `returnValue`: Pointer = Pointer.NULL,
610
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
611
+ ): UniffiForeignFutureStructPointer(`returnValue`,`callStatus`,), Structure.ByValue
612
+
613
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructPointer) {
614
+ `returnValue` = other.`returnValue`
615
+ `callStatus` = other.`callStatus`
616
+ }
617
+
618
+ }
619
+ internal interface UniffiForeignFutureCompletePointer : com.sun.jna.Callback {
620
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructPointer.UniffiByValue,)
621
+ }
622
+ @Structure.FieldOrder("returnValue", "callStatus")
623
+ internal open class UniffiForeignFutureStructRustBuffer(
624
+ @JvmField internal var `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(),
625
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
626
+ ) : Structure() {
627
+ class UniffiByValue(
628
+ `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(),
629
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
630
+ ): UniffiForeignFutureStructRustBuffer(`returnValue`,`callStatus`,), Structure.ByValue
631
+
632
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructRustBuffer) {
633
+ `returnValue` = other.`returnValue`
634
+ `callStatus` = other.`callStatus`
635
+ }
636
+
637
+ }
638
+ internal interface UniffiForeignFutureCompleteRustBuffer : com.sun.jna.Callback {
639
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructRustBuffer.UniffiByValue,)
640
+ }
641
+ @Structure.FieldOrder("callStatus")
642
+ internal open class UniffiForeignFutureStructVoid(
643
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
644
+ ) : Structure() {
645
+ class UniffiByValue(
646
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
647
+ ): UniffiForeignFutureStructVoid(`callStatus`,), Structure.ByValue
648
+
649
+ internal fun uniffiSetValue(other: UniffiForeignFutureStructVoid) {
650
+ `callStatus` = other.`callStatus`
651
+ }
652
+
653
+ }
654
+ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback {
655
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureStructVoid.UniffiByValue,)
656
+ }
657
+ internal interface UniffiCallbackInterfaceNativeEventCallbackMethod0 : com.sun.jna.Callback {
658
+ fun callback(`uniffiHandle`: Long,`eventType`: RustBuffer.ByValue,`payloadJson`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,)
659
+ }
660
+ @Structure.FieldOrder("onEvent", "uniffiFree")
661
+ internal open class UniffiVTableCallbackInterfaceNativeEventCallback(
662
+ @JvmField internal var `onEvent`: UniffiCallbackInterfaceNativeEventCallbackMethod0? = null,
663
+ @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null,
664
+ ) : Structure() {
665
+ class UniffiByValue(
666
+ `onEvent`: UniffiCallbackInterfaceNativeEventCallbackMethod0? = null,
667
+ `uniffiFree`: UniffiCallbackInterfaceFree? = null,
668
+ ): UniffiVTableCallbackInterfaceNativeEventCallback(`onEvent`,`uniffiFree`,), Structure.ByValue
669
+
670
+ internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceNativeEventCallback) {
671
+ `onEvent` = other.`onEvent`
672
+ `uniffiFree` = other.`uniffiFree`
673
+ }
674
+
675
+ }
676
+
677
+
678
+
679
+
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+
697
+
698
+
699
+
700
+
701
+
702
+
703
+
704
+
705
+
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
742
+
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+
768
+
769
+
770
+
771
+
772
+
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+
804
+
805
+
806
+
807
+
808
+
809
+
810
+
811
+
812
+
813
+
814
+
815
+
816
+
817
+
818
+ // A JNA Library to expose the extern-C FFI definitions.
819
+ // This is an implementation detail which will be called internally by the public API.
820
+
821
+ internal interface UniffiLib : Library {
822
+ companion object {
823
+ internal val INSTANCE: UniffiLib by lazy {
824
+ loadIndirect<UniffiLib>(componentName = "native_agent_ffi")
825
+ .also { lib: UniffiLib ->
826
+ uniffiCheckContractApiVersion(lib)
827
+ uniffiCheckApiChecksums(lib)
828
+ uniffiCallbackInterfaceNativeEventCallback.register(lib)
829
+ }
830
+ }
831
+
832
+ // The Cleaner for the whole library
833
+ internal val CLEANER: UniffiCleaner by lazy {
834
+ UniffiCleaner.create()
835
+ }
836
+ }
837
+
838
+ fun uniffi_native_agent_ffi_fn_clone_nativeagenthandle(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
839
+ ): Pointer
840
+ fun uniffi_native_agent_ffi_fn_free_nativeagenthandle(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
841
+ ): Unit
842
+ fun uniffi_native_agent_ffi_fn_constructor_nativeagenthandle_new(`config`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
843
+ ): Pointer
844
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_abort(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
845
+ ): Unit
846
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_add_cron_job(`ptr`: Pointer,`inputJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
847
+ ): RustBuffer.ByValue
848
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_add_skill(`ptr`: Pointer,`inputJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
849
+ ): RustBuffer.ByValue
850
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_clear_session(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
851
+ ): Unit
852
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_delete_auth(`ptr`: Pointer,`provider`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
853
+ ): Unit
854
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_end_skill(`ptr`: Pointer,`skillId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
855
+ ): Unit
856
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_follow_up(`ptr`: Pointer,`prompt`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
857
+ ): Unit
858
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_auth_status(`ptr`: Pointer,`provider`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
859
+ ): RustBuffer.ByValue
860
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_auth_token(`ptr`: Pointer,`provider`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
861
+ ): RustBuffer.ByValue
862
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_heartbeat_config(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
863
+ ): RustBuffer.ByValue
864
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_models(`ptr`: Pointer,`provider`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
865
+ ): RustBuffer.ByValue
866
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_scheduler_config(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
867
+ ): RustBuffer.ByValue
868
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_handle_wake(`ptr`: Pointer,`source`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
869
+ ): Unit
870
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_invoke_tool(`ptr`: Pointer,`toolName`: RustBuffer.ByValue,`argsJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
871
+ ): RustBuffer.ByValue
872
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_cron_jobs(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
873
+ ): RustBuffer.ByValue
874
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_cron_runs(`ptr`: Pointer,`jobId`: RustBuffer.ByValue,`limit`: Long,uniffi_out_err: UniffiRustCallStatus,
875
+ ): RustBuffer.ByValue
876
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_sessions(`ptr`: Pointer,`agentId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
877
+ ): RustBuffer.ByValue
878
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_skills(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
879
+ ): RustBuffer.ByValue
880
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_load_session(`ptr`: Pointer,`sessionKey`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
881
+ ): RustBuffer.ByValue
882
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_refresh_token(`ptr`: Pointer,`provider`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
883
+ ): RustBuffer.ByValue
884
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_remove_cron_job(`ptr`: Pointer,`id`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
885
+ ): Unit
886
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_remove_skill(`ptr`: Pointer,`id`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
887
+ ): Unit
888
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_approval(`ptr`: Pointer,`toolCallId`: RustBuffer.ByValue,`approved`: Byte,`reason`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
889
+ ): Unit
890
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_cron_approval(`ptr`: Pointer,`requestId`: RustBuffer.ByValue,`approved`: Byte,uniffi_out_err: UniffiRustCallStatus,
891
+ ): Unit
892
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_mcp_tool(`ptr`: Pointer,`toolCallId`: RustBuffer.ByValue,`resultJson`: RustBuffer.ByValue,`isError`: Byte,uniffi_out_err: UniffiRustCallStatus,
893
+ ): Unit
894
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_restart_mcp(`ptr`: Pointer,`toolsJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
895
+ ): Int
896
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_resume_session(`ptr`: Pointer,`sessionKey`: RustBuffer.ByValue,`agentId`: RustBuffer.ByValue,`messagesJson`: RustBuffer.ByValue,`provider`: RustBuffer.ByValue,`model`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
897
+ ): Unit
898
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_run_cron_job(`ptr`: Pointer,`jobId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
899
+ ): Unit
900
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_send_message(`ptr`: Pointer,`params`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
901
+ ): RustBuffer.ByValue
902
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_auth_key(`ptr`: Pointer,`key`: RustBuffer.ByValue,`provider`: RustBuffer.ByValue,`authType`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
903
+ ): Unit
904
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_event_callback(`ptr`: Pointer,`callback`: Long,uniffi_out_err: UniffiRustCallStatus,
905
+ ): Unit
906
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_heartbeat_config(`ptr`: Pointer,`configJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
907
+ ): Unit
908
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_scheduler_config(`ptr`: Pointer,`configJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
909
+ ): Unit
910
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_start_mcp(`ptr`: Pointer,`toolsJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
911
+ ): Int
912
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_start_skill(`ptr`: Pointer,`skillId`: RustBuffer.ByValue,`configJson`: RustBuffer.ByValue,`provider`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
913
+ ): RustBuffer.ByValue
914
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_steer(`ptr`: Pointer,`text`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
915
+ ): Unit
916
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_update_cron_job(`ptr`: Pointer,`id`: RustBuffer.ByValue,`patchJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
917
+ ): Unit
918
+ fun uniffi_native_agent_ffi_fn_method_nativeagenthandle_update_skill(`ptr`: Pointer,`id`: RustBuffer.ByValue,`patchJson`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
919
+ ): Unit
920
+ fun uniffi_native_agent_ffi_fn_init_callback_vtable_nativeeventcallback(`vtable`: UniffiVTableCallbackInterfaceNativeEventCallback,
921
+ ): Unit
922
+ fun uniffi_native_agent_ffi_fn_func_init_workspace(`config`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
923
+ ): Unit
924
+ fun ffi_native_agent_ffi_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus,
925
+ ): RustBuffer.ByValue
926
+ fun ffi_native_agent_ffi_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus,
927
+ ): RustBuffer.ByValue
928
+ fun ffi_native_agent_ffi_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
929
+ ): Unit
930
+ fun ffi_native_agent_ffi_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus,
931
+ ): RustBuffer.ByValue
932
+ fun ffi_native_agent_ffi_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
933
+ ): Unit
934
+ fun ffi_native_agent_ffi_rust_future_cancel_u8(`handle`: Long,
935
+ ): Unit
936
+ fun ffi_native_agent_ffi_rust_future_free_u8(`handle`: Long,
937
+ ): Unit
938
+ fun ffi_native_agent_ffi_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
939
+ ): Byte
940
+ fun ffi_native_agent_ffi_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
941
+ ): Unit
942
+ fun ffi_native_agent_ffi_rust_future_cancel_i8(`handle`: Long,
943
+ ): Unit
944
+ fun ffi_native_agent_ffi_rust_future_free_i8(`handle`: Long,
945
+ ): Unit
946
+ fun ffi_native_agent_ffi_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
947
+ ): Byte
948
+ fun ffi_native_agent_ffi_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
949
+ ): Unit
950
+ fun ffi_native_agent_ffi_rust_future_cancel_u16(`handle`: Long,
951
+ ): Unit
952
+ fun ffi_native_agent_ffi_rust_future_free_u16(`handle`: Long,
953
+ ): Unit
954
+ fun ffi_native_agent_ffi_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
955
+ ): Short
956
+ fun ffi_native_agent_ffi_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
957
+ ): Unit
958
+ fun ffi_native_agent_ffi_rust_future_cancel_i16(`handle`: Long,
959
+ ): Unit
960
+ fun ffi_native_agent_ffi_rust_future_free_i16(`handle`: Long,
961
+ ): Unit
962
+ fun ffi_native_agent_ffi_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
963
+ ): Short
964
+ fun ffi_native_agent_ffi_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
965
+ ): Unit
966
+ fun ffi_native_agent_ffi_rust_future_cancel_u32(`handle`: Long,
967
+ ): Unit
968
+ fun ffi_native_agent_ffi_rust_future_free_u32(`handle`: Long,
969
+ ): Unit
970
+ fun ffi_native_agent_ffi_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
971
+ ): Int
972
+ fun ffi_native_agent_ffi_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
973
+ ): Unit
974
+ fun ffi_native_agent_ffi_rust_future_cancel_i32(`handle`: Long,
975
+ ): Unit
976
+ fun ffi_native_agent_ffi_rust_future_free_i32(`handle`: Long,
977
+ ): Unit
978
+ fun ffi_native_agent_ffi_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
979
+ ): Int
980
+ fun ffi_native_agent_ffi_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
981
+ ): Unit
982
+ fun ffi_native_agent_ffi_rust_future_cancel_u64(`handle`: Long,
983
+ ): Unit
984
+ fun ffi_native_agent_ffi_rust_future_free_u64(`handle`: Long,
985
+ ): Unit
986
+ fun ffi_native_agent_ffi_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
987
+ ): Long
988
+ fun ffi_native_agent_ffi_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
989
+ ): Unit
990
+ fun ffi_native_agent_ffi_rust_future_cancel_i64(`handle`: Long,
991
+ ): Unit
992
+ fun ffi_native_agent_ffi_rust_future_free_i64(`handle`: Long,
993
+ ): Unit
994
+ fun ffi_native_agent_ffi_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
995
+ ): Long
996
+ fun ffi_native_agent_ffi_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
997
+ ): Unit
998
+ fun ffi_native_agent_ffi_rust_future_cancel_f32(`handle`: Long,
999
+ ): Unit
1000
+ fun ffi_native_agent_ffi_rust_future_free_f32(`handle`: Long,
1001
+ ): Unit
1002
+ fun ffi_native_agent_ffi_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1003
+ ): Float
1004
+ fun ffi_native_agent_ffi_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1005
+ ): Unit
1006
+ fun ffi_native_agent_ffi_rust_future_cancel_f64(`handle`: Long,
1007
+ ): Unit
1008
+ fun ffi_native_agent_ffi_rust_future_free_f64(`handle`: Long,
1009
+ ): Unit
1010
+ fun ffi_native_agent_ffi_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1011
+ ): Double
1012
+ fun ffi_native_agent_ffi_rust_future_poll_pointer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1013
+ ): Unit
1014
+ fun ffi_native_agent_ffi_rust_future_cancel_pointer(`handle`: Long,
1015
+ ): Unit
1016
+ fun ffi_native_agent_ffi_rust_future_free_pointer(`handle`: Long,
1017
+ ): Unit
1018
+ fun ffi_native_agent_ffi_rust_future_complete_pointer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1019
+ ): Pointer
1020
+ fun ffi_native_agent_ffi_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1021
+ ): Unit
1022
+ fun ffi_native_agent_ffi_rust_future_cancel_rust_buffer(`handle`: Long,
1023
+ ): Unit
1024
+ fun ffi_native_agent_ffi_rust_future_free_rust_buffer(`handle`: Long,
1025
+ ): Unit
1026
+ fun ffi_native_agent_ffi_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1027
+ ): RustBuffer.ByValue
1028
+ fun ffi_native_agent_ffi_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
1029
+ ): Unit
1030
+ fun ffi_native_agent_ffi_rust_future_cancel_void(`handle`: Long,
1031
+ ): Unit
1032
+ fun ffi_native_agent_ffi_rust_future_free_void(`handle`: Long,
1033
+ ): Unit
1034
+ fun ffi_native_agent_ffi_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
1035
+ ): Unit
1036
+ fun uniffi_native_agent_ffi_checksum_func_init_workspace(
1037
+ ): Short
1038
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_abort(
1039
+ ): Short
1040
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_add_cron_job(
1041
+ ): Short
1042
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_add_skill(
1043
+ ): Short
1044
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_clear_session(
1045
+ ): Short
1046
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_delete_auth(
1047
+ ): Short
1048
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_end_skill(
1049
+ ): Short
1050
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_follow_up(
1051
+ ): Short
1052
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_auth_status(
1053
+ ): Short
1054
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_auth_token(
1055
+ ): Short
1056
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_heartbeat_config(
1057
+ ): Short
1058
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_models(
1059
+ ): Short
1060
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_scheduler_config(
1061
+ ): Short
1062
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_handle_wake(
1063
+ ): Short
1064
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_invoke_tool(
1065
+ ): Short
1066
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_cron_jobs(
1067
+ ): Short
1068
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_cron_runs(
1069
+ ): Short
1070
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_sessions(
1071
+ ): Short
1072
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_skills(
1073
+ ): Short
1074
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_load_session(
1075
+ ): Short
1076
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_refresh_token(
1077
+ ): Short
1078
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_remove_cron_job(
1079
+ ): Short
1080
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_remove_skill(
1081
+ ): Short
1082
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_respond_to_approval(
1083
+ ): Short
1084
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_respond_to_cron_approval(
1085
+ ): Short
1086
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_respond_to_mcp_tool(
1087
+ ): Short
1088
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_restart_mcp(
1089
+ ): Short
1090
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_resume_session(
1091
+ ): Short
1092
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_run_cron_job(
1093
+ ): Short
1094
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_send_message(
1095
+ ): Short
1096
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_auth_key(
1097
+ ): Short
1098
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_event_callback(
1099
+ ): Short
1100
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_heartbeat_config(
1101
+ ): Short
1102
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_scheduler_config(
1103
+ ): Short
1104
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_start_mcp(
1105
+ ): Short
1106
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_start_skill(
1107
+ ): Short
1108
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_steer(
1109
+ ): Short
1110
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_update_cron_job(
1111
+ ): Short
1112
+ fun uniffi_native_agent_ffi_checksum_method_nativeagenthandle_update_skill(
1113
+ ): Short
1114
+ fun uniffi_native_agent_ffi_checksum_constructor_nativeagenthandle_new(
1115
+ ): Short
1116
+ fun uniffi_native_agent_ffi_checksum_method_nativeeventcallback_on_event(
1117
+ ): Short
1118
+ fun ffi_native_agent_ffi_uniffi_contract_version(
1119
+ ): Int
1120
+
1121
+ }
1122
+
1123
+ private fun uniffiCheckContractApiVersion(lib: UniffiLib) {
1124
+ // Get the bindings contract version from our ComponentInterface
1125
+ val bindings_contract_version = 26
1126
+ // Get the scaffolding contract version by calling the into the dylib
1127
+ val scaffolding_contract_version = lib.ffi_native_agent_ffi_uniffi_contract_version()
1128
+ if (bindings_contract_version != scaffolding_contract_version) {
1129
+ throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project")
1130
+ }
1131
+ }
1132
+
1133
+ @Suppress("UNUSED_PARAMETER")
1134
+ private fun uniffiCheckApiChecksums(lib: UniffiLib) {
1135
+ if (lib.uniffi_native_agent_ffi_checksum_func_init_workspace() != 39423.toShort()) {
1136
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1137
+ }
1138
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_abort() != 58908.toShort()) {
1139
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1140
+ }
1141
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_add_cron_job() != 52316.toShort()) {
1142
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1143
+ }
1144
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_add_skill() != 46434.toShort()) {
1145
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1146
+ }
1147
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_clear_session() != 28186.toShort()) {
1148
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1149
+ }
1150
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_delete_auth() != 2640.toShort()) {
1151
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1152
+ }
1153
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_end_skill() != 49984.toShort()) {
1154
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1155
+ }
1156
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_follow_up() != 816.toShort()) {
1157
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1158
+ }
1159
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_auth_status() != 31550.toShort()) {
1160
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1161
+ }
1162
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_auth_token() != 58380.toShort()) {
1163
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1164
+ }
1165
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_heartbeat_config() != 1627.toShort()) {
1166
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1167
+ }
1168
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_models() != 25637.toShort()) {
1169
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1170
+ }
1171
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_get_scheduler_config() != 3406.toShort()) {
1172
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1173
+ }
1174
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_handle_wake() != 29594.toShort()) {
1175
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1176
+ }
1177
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_invoke_tool() != 13537.toShort()) {
1178
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1179
+ }
1180
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_cron_jobs() != 44432.toShort()) {
1181
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1182
+ }
1183
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_cron_runs() != 27743.toShort()) {
1184
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1185
+ }
1186
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_sessions() != 20894.toShort()) {
1187
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1188
+ }
1189
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_list_skills() != 14677.toShort()) {
1190
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1191
+ }
1192
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_load_session() != 39832.toShort()) {
1193
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1194
+ }
1195
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_refresh_token() != 13290.toShort()) {
1196
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1197
+ }
1198
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_remove_cron_job() != 55519.toShort()) {
1199
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1200
+ }
1201
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_remove_skill() != 49129.toShort()) {
1202
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1203
+ }
1204
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_respond_to_approval() != 3194.toShort()) {
1205
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1206
+ }
1207
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_respond_to_cron_approval() != 851.toShort()) {
1208
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1209
+ }
1210
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_respond_to_mcp_tool() != 10295.toShort()) {
1211
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1212
+ }
1213
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_restart_mcp() != 8963.toShort()) {
1214
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1215
+ }
1216
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_resume_session() != 34699.toShort()) {
1217
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1218
+ }
1219
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_run_cron_job() != 11263.toShort()) {
1220
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1221
+ }
1222
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_send_message() != 53296.toShort()) {
1223
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1224
+ }
1225
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_auth_key() != 40485.toShort()) {
1226
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1227
+ }
1228
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_event_callback() != 56165.toShort()) {
1229
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1230
+ }
1231
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_heartbeat_config() != 33968.toShort()) {
1232
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1233
+ }
1234
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_set_scheduler_config() != 18609.toShort()) {
1235
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1236
+ }
1237
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_start_mcp() != 53972.toShort()) {
1238
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1239
+ }
1240
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_start_skill() != 7081.toShort()) {
1241
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1242
+ }
1243
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_steer() != 29790.toShort()) {
1244
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1245
+ }
1246
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_update_cron_job() != 40127.toShort()) {
1247
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1248
+ }
1249
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeagenthandle_update_skill() != 42452.toShort()) {
1250
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1251
+ }
1252
+ if (lib.uniffi_native_agent_ffi_checksum_constructor_nativeagenthandle_new() != 18383.toShort()) {
1253
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1254
+ }
1255
+ if (lib.uniffi_native_agent_ffi_checksum_method_nativeeventcallback_on_event() != 29742.toShort()) {
1256
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1257
+ }
1258
+ }
1259
+
1260
+ // Async support
1261
+
1262
+ // Public interface members begin here.
1263
+
1264
+
1265
+ // Interface implemented by anything that can contain an object reference.
1266
+ //
1267
+ // Such types expose a `destroy()` method that must be called to cleanly
1268
+ // dispose of the contained objects. Failure to call this method may result
1269
+ // in memory leaks.
1270
+ //
1271
+ // The easiest way to ensure this method is called is to use the `.use`
1272
+ // helper method to execute a block and destroy the object at the end.
1273
+ interface Disposable {
1274
+ fun destroy()
1275
+ companion object {
1276
+ fun destroy(vararg args: Any?) {
1277
+ args.filterIsInstance<Disposable>()
1278
+ .forEach(Disposable::destroy)
1279
+ }
1280
+ }
1281
+ }
1282
+
1283
+ /**
1284
+ * @suppress
1285
+ */
1286
+ inline fun <T : Disposable?, R> T.use(block: (T) -> R) =
1287
+ try {
1288
+ block(this)
1289
+ } finally {
1290
+ try {
1291
+ // N.B. our implementation is on the nullable type `Disposable?`.
1292
+ this?.destroy()
1293
+ } catch (e: Throwable) {
1294
+ // swallow
1295
+ }
1296
+ }
1297
+
1298
+ /**
1299
+ * Used to instantiate an interface without an actual pointer, for fakes in tests, mostly.
1300
+ *
1301
+ * @suppress
1302
+ * */
1303
+ object NoPointer
1304
+
1305
+ /**
1306
+ * @suppress
1307
+ */
1308
+ public object FfiConverterUInt: FfiConverter<UInt, Int> {
1309
+ override fun lift(value: Int): UInt {
1310
+ return value.toUInt()
1311
+ }
1312
+
1313
+ override fun read(buf: ByteBuffer): UInt {
1314
+ return lift(buf.getInt())
1315
+ }
1316
+
1317
+ override fun lower(value: UInt): Int {
1318
+ return value.toInt()
1319
+ }
1320
+
1321
+ override fun allocationSize(value: UInt) = 4UL
1322
+
1323
+ override fun write(value: UInt, buf: ByteBuffer) {
1324
+ buf.putInt(value.toInt())
1325
+ }
1326
+ }
1327
+
1328
+ /**
1329
+ * @suppress
1330
+ */
1331
+ public object FfiConverterLong: FfiConverter<Long, Long> {
1332
+ override fun lift(value: Long): Long {
1333
+ return value
1334
+ }
1335
+
1336
+ override fun read(buf: ByteBuffer): Long {
1337
+ return buf.getLong()
1338
+ }
1339
+
1340
+ override fun lower(value: Long): Long {
1341
+ return value
1342
+ }
1343
+
1344
+ override fun allocationSize(value: Long) = 8UL
1345
+
1346
+ override fun write(value: Long, buf: ByteBuffer) {
1347
+ buf.putLong(value)
1348
+ }
1349
+ }
1350
+
1351
+ /**
1352
+ * @suppress
1353
+ */
1354
+ public object FfiConverterBoolean: FfiConverter<Boolean, Byte> {
1355
+ override fun lift(value: Byte): Boolean {
1356
+ return value.toInt() != 0
1357
+ }
1358
+
1359
+ override fun read(buf: ByteBuffer): Boolean {
1360
+ return lift(buf.get())
1361
+ }
1362
+
1363
+ override fun lower(value: Boolean): Byte {
1364
+ return if (value) 1.toByte() else 0.toByte()
1365
+ }
1366
+
1367
+ override fun allocationSize(value: Boolean) = 1UL
1368
+
1369
+ override fun write(value: Boolean, buf: ByteBuffer) {
1370
+ buf.put(lower(value))
1371
+ }
1372
+ }
1373
+
1374
+ /**
1375
+ * @suppress
1376
+ */
1377
+ public object FfiConverterString: FfiConverter<String, RustBuffer.ByValue> {
1378
+ // Note: we don't inherit from FfiConverterRustBuffer, because we use a
1379
+ // special encoding when lowering/lifting. We can use `RustBuffer.len` to
1380
+ // store our length and avoid writing it out to the buffer.
1381
+ override fun lift(value: RustBuffer.ByValue): String {
1382
+ try {
1383
+ val byteArr = ByteArray(value.len.toInt())
1384
+ value.asByteBuffer()!!.get(byteArr)
1385
+ return byteArr.toString(Charsets.UTF_8)
1386
+ } finally {
1387
+ RustBuffer.free(value)
1388
+ }
1389
+ }
1390
+
1391
+ override fun read(buf: ByteBuffer): String {
1392
+ val len = buf.getInt()
1393
+ val byteArr = ByteArray(len)
1394
+ buf.get(byteArr)
1395
+ return byteArr.toString(Charsets.UTF_8)
1396
+ }
1397
+
1398
+ fun toUtf8(value: String): ByteBuffer {
1399
+ // Make sure we don't have invalid UTF-16, check for lone surrogates.
1400
+ return Charsets.UTF_8.newEncoder().run {
1401
+ onMalformedInput(CodingErrorAction.REPORT)
1402
+ encode(CharBuffer.wrap(value))
1403
+ }
1404
+ }
1405
+
1406
+ override fun lower(value: String): RustBuffer.ByValue {
1407
+ val byteBuf = toUtf8(value)
1408
+ // Ideally we'd pass these bytes to `ffi_bytebuffer_from_bytes`, but doing so would require us
1409
+ // to copy them into a JNA `Memory`. So we might as well directly copy them into a `RustBuffer`.
1410
+ val rbuf = RustBuffer.alloc(byteBuf.limit().toULong())
1411
+ rbuf.asByteBuffer()!!.put(byteBuf)
1412
+ return rbuf
1413
+ }
1414
+
1415
+ // We aren't sure exactly how many bytes our string will be once it's UTF-8
1416
+ // encoded. Allocate 3 bytes per UTF-16 code unit which will always be
1417
+ // enough.
1418
+ override fun allocationSize(value: String): ULong {
1419
+ val sizeForLength = 4UL
1420
+ val sizeForString = value.length.toULong() * 3UL
1421
+ return sizeForLength + sizeForString
1422
+ }
1423
+
1424
+ override fun write(value: String, buf: ByteBuffer) {
1425
+ val byteBuf = toUtf8(value)
1426
+ buf.putInt(byteBuf.limit())
1427
+ buf.put(byteBuf)
1428
+ }
1429
+ }
1430
+
1431
+
1432
+ // This template implements a class for working with a Rust struct via a Pointer/Arc<T>
1433
+ // to the live Rust struct on the other side of the FFI.
1434
+ //
1435
+ // Each instance implements core operations for working with the Rust `Arc<T>` and the
1436
+ // Kotlin Pointer to work with the live Rust struct on the other side of the FFI.
1437
+ //
1438
+ // There's some subtlety here, because we have to be careful not to operate on a Rust
1439
+ // struct after it has been dropped, and because we must expose a public API for freeing
1440
+ // theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are:
1441
+ //
1442
+ // * Each instance holds an opaque pointer to the underlying Rust struct.
1443
+ // Method calls need to read this pointer from the object's state and pass it in to
1444
+ // the Rust FFI.
1445
+ //
1446
+ // * When an instance is no longer needed, its pointer should be passed to a
1447
+ // special destructor function provided by the Rust FFI, which will drop the
1448
+ // underlying Rust struct.
1449
+ //
1450
+ // * Given an instance, calling code is expected to call the special
1451
+ // `destroy` method in order to free it after use, either by calling it explicitly
1452
+ // or by using a higher-level helper like the `use` method. Failing to do so risks
1453
+ // leaking the underlying Rust struct.
1454
+ //
1455
+ // * We can't assume that calling code will do the right thing, and must be prepared
1456
+ // to handle Kotlin method calls executing concurrently with or even after a call to
1457
+ // `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`.
1458
+ //
1459
+ // * We must never allow Rust code to operate on the underlying Rust struct after
1460
+ // the destructor has been called, and must never call the destructor more than once.
1461
+ // Doing so may trigger memory unsafety.
1462
+ //
1463
+ // * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner`
1464
+ // is implemented to call the destructor when the Kotlin object becomes unreachable.
1465
+ // This is done in a background thread. This is not a panacea, and client code should be aware that
1466
+ // 1. the thread may starve if some there are objects that have poorly performing
1467
+ // `drop` methods or do significant work in their `drop` methods.
1468
+ // 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`,
1469
+ // or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html).
1470
+ //
1471
+ // If we try to implement this with mutual exclusion on access to the pointer, there is the
1472
+ // possibility of a race between a method call and a concurrent call to `destroy`:
1473
+ //
1474
+ // * Thread A starts a method call, reads the value of the pointer, but is interrupted
1475
+ // before it can pass the pointer over the FFI to Rust.
1476
+ // * Thread B calls `destroy` and frees the underlying Rust struct.
1477
+ // * Thread A resumes, passing the already-read pointer value to Rust and triggering
1478
+ // a use-after-free.
1479
+ //
1480
+ // One possible solution would be to use a `ReadWriteLock`, with each method call taking
1481
+ // a read lock (and thus allowed to run concurrently) and the special `destroy` method
1482
+ // taking a write lock (and thus blocking on live method calls). However, we aim not to
1483
+ // generate methods with any hidden blocking semantics, and a `destroy` method that might
1484
+ // block if called incorrectly seems to meet that bar.
1485
+ //
1486
+ // So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track
1487
+ // the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy`
1488
+ // has been called. These are updated according to the following rules:
1489
+ //
1490
+ // * The initial value of the counter is 1, indicating a live object with no in-flight calls.
1491
+ // The initial value for the flag is false.
1492
+ //
1493
+ // * At the start of each method call, we atomically check the counter.
1494
+ // If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted.
1495
+ // If it is nonzero them we atomically increment it by 1 and proceed with the method call.
1496
+ //
1497
+ // * At the end of each method call, we atomically decrement and check the counter.
1498
+ // If it has reached zero then we destroy the underlying Rust struct.
1499
+ //
1500
+ // * When `destroy` is called, we atomically flip the flag from false to true.
1501
+ // If the flag was already true we silently fail.
1502
+ // Otherwise we atomically decrement and check the counter.
1503
+ // If it has reached zero then we destroy the underlying Rust struct.
1504
+ //
1505
+ // Astute readers may observe that this all sounds very similar to the way that Rust's `Arc<T>` works,
1506
+ // and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`.
1507
+ //
1508
+ // The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been
1509
+ // called *and* all in-flight method calls have completed, avoiding violating any of the expectations
1510
+ // of the underlying Rust code.
1511
+ //
1512
+ // This makes a cleaner a better alternative to _not_ calling `destroy()` as
1513
+ // and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop`
1514
+ // method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner
1515
+ // thread may be starved, and the app will leak memory.
1516
+ //
1517
+ // In this case, `destroy`ing manually may be a better solution.
1518
+ //
1519
+ // The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects
1520
+ // with Rust peers are reclaimed:
1521
+ //
1522
+ // 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen:
1523
+ // 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then:
1524
+ // 3. The memory is reclaimed when the process terminates.
1525
+ //
1526
+ // [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219
1527
+ //
1528
+
1529
+
1530
+ /**
1531
+ * The cleaner interface for Object finalization code to run.
1532
+ * This is the entry point to any implementation that we're using.
1533
+ *
1534
+ * The cleaner registers objects and returns cleanables, so now we are
1535
+ * defining a `UniffiCleaner` with a `UniffiClenaer.Cleanable` to abstract the
1536
+ * different implmentations available at compile time.
1537
+ *
1538
+ * @suppress
1539
+ */
1540
+ interface UniffiCleaner {
1541
+ interface Cleanable {
1542
+ fun clean()
1543
+ }
1544
+
1545
+ fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable
1546
+
1547
+ companion object
1548
+ }
1549
+
1550
+ // The fallback Jna cleaner, which is available for both Android, and the JVM.
1551
+ private class UniffiJnaCleaner : UniffiCleaner {
1552
+ private val cleaner = com.sun.jna.internal.Cleaner.getCleaner()
1553
+
1554
+ override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable =
1555
+ UniffiJnaCleanable(cleaner.register(value, cleanUpTask))
1556
+ }
1557
+
1558
+ private class UniffiJnaCleanable(
1559
+ private val cleanable: com.sun.jna.internal.Cleaner.Cleanable,
1560
+ ) : UniffiCleaner.Cleanable {
1561
+ override fun clean() = cleanable.clean()
1562
+ }
1563
+
1564
+ // We decide at uniffi binding generation time whether we were
1565
+ // using Android or not.
1566
+ // There are further runtime checks to chose the correct implementation
1567
+ // of the cleaner.
1568
+ private fun UniffiCleaner.Companion.create(): UniffiCleaner =
1569
+ try {
1570
+ // For safety's sake: if the library hasn't been run in android_cleaner = true
1571
+ // mode, but is being run on Android, then we still need to think about
1572
+ // Android API versions.
1573
+ // So we check if java.lang.ref.Cleaner is there, and use that…
1574
+ java.lang.Class.forName("java.lang.ref.Cleaner")
1575
+ JavaLangRefCleaner()
1576
+ } catch (e: ClassNotFoundException) {
1577
+ // … otherwise, fallback to the JNA cleaner.
1578
+ UniffiJnaCleaner()
1579
+ }
1580
+
1581
+ private class JavaLangRefCleaner : UniffiCleaner {
1582
+ val cleaner = java.lang.ref.Cleaner.create()
1583
+
1584
+ override fun register(value: Any, cleanUpTask: Runnable): UniffiCleaner.Cleanable =
1585
+ JavaLangRefCleanable(cleaner.register(value, cleanUpTask))
1586
+ }
1587
+
1588
+ private class JavaLangRefCleanable(
1589
+ val cleanable: java.lang.ref.Cleaner.Cleanable
1590
+ ) : UniffiCleaner.Cleanable {
1591
+ override fun clean() = cleanable.clean()
1592
+ }
1593
+ /**
1594
+ * Long-lived handle — one per app lifecycle.
1595
+ */
1596
+ public interface NativeAgentHandleInterface {
1597
+
1598
+ /**
1599
+ * Abort the current agent turn.
1600
+ */
1601
+ fun `abort`()
1602
+
1603
+ /**
1604
+ * Add a cron job.
1605
+ */
1606
+ fun `addCronJob`(`inputJson`: kotlin.String): kotlin.String
1607
+
1608
+ /**
1609
+ * Add a cron skill.
1610
+ */
1611
+ fun `addSkill`(`inputJson`: kotlin.String): kotlin.String
1612
+
1613
+ /**
1614
+ * Clear the current in-memory session state so the next sendMessage
1615
+ * starts a fresh conversation. The session row in SQLite is preserved
1616
+ * so it remains in the session index for later resume/switch.
1617
+ */
1618
+ fun `clearSession`()
1619
+
1620
+ /**
1621
+ * Delete auth for a provider.
1622
+ */
1623
+ fun `deleteAuth`(`provider`: kotlin.String)
1624
+
1625
+ /**
1626
+ * End a skill session.
1627
+ */
1628
+ fun `endSkill`(`skillId`: kotlin.String)
1629
+
1630
+ /**
1631
+ * Follow up on the current conversation.
1632
+ */
1633
+ fun `followUp`(`prompt`: kotlin.String)
1634
+
1635
+ /**
1636
+ * Get auth status (masked key).
1637
+ */
1638
+ fun `getAuthStatus`(`provider`: kotlin.String): AuthStatusResult
1639
+
1640
+ /**
1641
+ * Get auth token for a provider.
1642
+ */
1643
+ fun `getAuthToken`(`provider`: kotlin.String): AuthTokenResult
1644
+
1645
+ /**
1646
+ * Get heartbeat config.
1647
+ */
1648
+ fun `getHeartbeatConfig`(): kotlin.String
1649
+
1650
+ /**
1651
+ * Get available models for a provider.
1652
+ */
1653
+ fun `getModels`(`provider`: kotlin.String): kotlin.String
1654
+
1655
+ /**
1656
+ * Get scheduler config.
1657
+ */
1658
+ fun `getSchedulerConfig`(): kotlin.String
1659
+
1660
+ /**
1661
+ * Handle a wake event (evaluate due cron jobs).
1662
+ */
1663
+ fun `handleWake`(`source`: kotlin.String)
1664
+
1665
+ /**
1666
+ * Invoke a tool directly.
1667
+ */
1668
+ fun `invokeTool`(`toolName`: kotlin.String, `argsJson`: kotlin.String): kotlin.String
1669
+
1670
+ /**
1671
+ * List all cron jobs.
1672
+ */
1673
+ fun `listCronJobs`(): kotlin.String
1674
+
1675
+ /**
1676
+ * List cron run history.
1677
+ */
1678
+ fun `listCronRuns`(`jobId`: kotlin.String?, `limit`: kotlin.Long): kotlin.String
1679
+
1680
+ /**
1681
+ * List sessions for an agent.
1682
+ */
1683
+ fun `listSessions`(`agentId`: kotlin.String): kotlin.String
1684
+
1685
+ /**
1686
+ * List all cron skills.
1687
+ */
1688
+ fun `listSkills`(): kotlin.String
1689
+
1690
+ /**
1691
+ * Load session message history.
1692
+ */
1693
+ fun `loadSession`(`sessionKey`: kotlin.String): kotlin.String
1694
+
1695
+ /**
1696
+ * Refresh an OAuth token.
1697
+ */
1698
+ fun `refreshToken`(`provider`: kotlin.String): AuthTokenResult
1699
+
1700
+ /**
1701
+ * Remove a cron job.
1702
+ */
1703
+ fun `removeCronJob`(`id`: kotlin.String)
1704
+
1705
+ /**
1706
+ * Remove a cron skill.
1707
+ */
1708
+ fun `removeSkill`(`id`: kotlin.String)
1709
+
1710
+ /**
1711
+ * Respond to a tool approval request.
1712
+ */
1713
+ fun `respondToApproval`(`toolCallId`: kotlin.String, `approved`: kotlin.Boolean, `reason`: kotlin.String?)
1714
+
1715
+ /**
1716
+ * Respond to a cron approval request.
1717
+ */
1718
+ fun `respondToCronApproval`(`requestId`: kotlin.String, `approved`: kotlin.Boolean)
1719
+
1720
+ /**
1721
+ * Respond to a pending MCP tool call.
1722
+ */
1723
+ fun `respondToMcpTool`(`toolCallId`: kotlin.String, `resultJson`: kotlin.String, `isError`: kotlin.Boolean)
1724
+
1725
+ /**
1726
+ * Restart MCP server with new tools.
1727
+ */
1728
+ fun `restartMcp`(`toolsJson`: kotlin.String): kotlin.UInt
1729
+
1730
+ /**
1731
+ * Resume a session (load messages into agent context).
1732
+ */
1733
+ fun `resumeSession`(`sessionKey`: kotlin.String, `agentId`: kotlin.String, `messagesJson`: kotlin.String?, `provider`: kotlin.String?, `model`: kotlin.String?)
1734
+
1735
+ /**
1736
+ * Force-trigger a cron job.
1737
+ */
1738
+ fun `runCronJob`(`jobId`: kotlin.String)
1739
+
1740
+ /**
1741
+ * Send a message to the agent and start an agent loop turn.
1742
+ */
1743
+ fun `sendMessage`(`params`: SendMessageParams): kotlin.String
1744
+
1745
+ /**
1746
+ * Set an auth key for a provider.
1747
+ */
1748
+ fun `setAuthKey`(`key`: kotlin.String, `provider`: kotlin.String, `authType`: kotlin.String)
1749
+
1750
+ /**
1751
+ * Set the event callback for receiving agent events.
1752
+ */
1753
+ fun `setEventCallback`(`callback`: NativeEventCallback)
1754
+
1755
+ /**
1756
+ * Set heartbeat config.
1757
+ */
1758
+ fun `setHeartbeatConfig`(`configJson`: kotlin.String)
1759
+
1760
+ /**
1761
+ * Set scheduler config.
1762
+ */
1763
+ fun `setSchedulerConfig`(`configJson`: kotlin.String)
1764
+
1765
+ /**
1766
+ * Start MCP server with given tools.
1767
+ */
1768
+ fun `startMcp`(`toolsJson`: kotlin.String): kotlin.UInt
1769
+
1770
+ /**
1771
+ * Start a skill session.
1772
+ */
1773
+ fun `startSkill`(`skillId`: kotlin.String, `configJson`: kotlin.String, `provider`: kotlin.String?): kotlin.String
1774
+
1775
+ /**
1776
+ * Steer the running agent with additional context.
1777
+ */
1778
+ fun `steer`(`text`: kotlin.String)
1779
+
1780
+ /**
1781
+ * Update a cron job.
1782
+ */
1783
+ fun `updateCronJob`(`id`: kotlin.String, `patchJson`: kotlin.String)
1784
+
1785
+ /**
1786
+ * Update a cron skill.
1787
+ */
1788
+ fun `updateSkill`(`id`: kotlin.String, `patchJson`: kotlin.String)
1789
+
1790
+ companion object
1791
+ }
1792
+
1793
+ /**
1794
+ * Long-lived handle — one per app lifecycle.
1795
+ */
1796
+ open class NativeAgentHandle: Disposable, AutoCloseable, NativeAgentHandleInterface {
1797
+
1798
+ constructor(pointer: Pointer) {
1799
+ this.pointer = pointer
1800
+ this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer))
1801
+ }
1802
+
1803
+ /**
1804
+ * This constructor can be used to instantiate a fake object. Only used for tests. Any
1805
+ * attempt to actually use an object constructed this way will fail as there is no
1806
+ * connected Rust object.
1807
+ */
1808
+ @Suppress("UNUSED_PARAMETER")
1809
+ constructor(noPointer: NoPointer) {
1810
+ this.pointer = null
1811
+ this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer))
1812
+ }
1813
+ /**
1814
+ * Create a new native agent handle.
1815
+ */
1816
+ constructor(`config`: InitConfig) :
1817
+ this(
1818
+ uniffiRustCallWithError(NativeAgentException) { _status ->
1819
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_constructor_nativeagenthandle_new(
1820
+ FfiConverterTypeInitConfig.lower(`config`),_status)
1821
+ }
1822
+ )
1823
+
1824
+ protected val pointer: Pointer?
1825
+ protected val cleanable: UniffiCleaner.Cleanable
1826
+
1827
+ private val wasDestroyed = AtomicBoolean(false)
1828
+ private val callCounter = AtomicLong(1)
1829
+
1830
+ override fun destroy() {
1831
+ // Only allow a single call to this method.
1832
+ // TODO: maybe we should log a warning if called more than once?
1833
+ if (this.wasDestroyed.compareAndSet(false, true)) {
1834
+ // This decrement always matches the initial count of 1 given at creation time.
1835
+ if (this.callCounter.decrementAndGet() == 0L) {
1836
+ cleanable.clean()
1837
+ }
1838
+ }
1839
+ }
1840
+
1841
+ @Synchronized
1842
+ override fun close() {
1843
+ this.destroy()
1844
+ }
1845
+
1846
+ internal inline fun <R> callWithPointer(block: (ptr: Pointer) -> R): R {
1847
+ // Check and increment the call counter, to keep the object alive.
1848
+ // This needs a compare-and-set retry loop in case of concurrent updates.
1849
+ do {
1850
+ val c = this.callCounter.get()
1851
+ if (c == 0L) {
1852
+ throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed")
1853
+ }
1854
+ if (c == Long.MAX_VALUE) {
1855
+ throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow")
1856
+ }
1857
+ } while (! this.callCounter.compareAndSet(c, c + 1L))
1858
+ // Now we can safely do the method call without the pointer being freed concurrently.
1859
+ try {
1860
+ return block(this.uniffiClonePointer())
1861
+ } finally {
1862
+ // This decrement always matches the increment we performed above.
1863
+ if (this.callCounter.decrementAndGet() == 0L) {
1864
+ cleanable.clean()
1865
+ }
1866
+ }
1867
+ }
1868
+
1869
+ // Use a static inner class instead of a closure so as not to accidentally
1870
+ // capture `this` as part of the cleanable's action.
1871
+ private class UniffiCleanAction(private val pointer: Pointer?) : Runnable {
1872
+ override fun run() {
1873
+ pointer?.let { ptr ->
1874
+ uniffiRustCall { status ->
1875
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_free_nativeagenthandle(ptr, status)
1876
+ }
1877
+ }
1878
+ }
1879
+ }
1880
+
1881
+ fun uniffiClonePointer(): Pointer {
1882
+ return uniffiRustCall() { status ->
1883
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_clone_nativeagenthandle(pointer!!, status)
1884
+ }
1885
+ }
1886
+
1887
+
1888
+ /**
1889
+ * Abort the current agent turn.
1890
+ */
1891
+ @Throws(NativeAgentException::class)override fun `abort`()
1892
+ =
1893
+ callWithPointer {
1894
+ uniffiRustCallWithError(NativeAgentException) { _status ->
1895
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_abort(
1896
+ it, _status)
1897
+ }
1898
+ }
1899
+
1900
+
1901
+
1902
+
1903
+ /**
1904
+ * Add a cron job.
1905
+ */
1906
+ @Throws(NativeAgentException::class)override fun `addCronJob`(`inputJson`: kotlin.String): kotlin.String {
1907
+ return FfiConverterString.lift(
1908
+ callWithPointer {
1909
+ uniffiRustCallWithError(NativeAgentException) { _status ->
1910
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_add_cron_job(
1911
+ it, FfiConverterString.lower(`inputJson`),_status)
1912
+ }
1913
+ }
1914
+ )
1915
+ }
1916
+
1917
+
1918
+
1919
+ /**
1920
+ * Add a cron skill.
1921
+ */
1922
+ @Throws(NativeAgentException::class)override fun `addSkill`(`inputJson`: kotlin.String): kotlin.String {
1923
+ return FfiConverterString.lift(
1924
+ callWithPointer {
1925
+ uniffiRustCallWithError(NativeAgentException) { _status ->
1926
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_add_skill(
1927
+ it, FfiConverterString.lower(`inputJson`),_status)
1928
+ }
1929
+ }
1930
+ )
1931
+ }
1932
+
1933
+
1934
+
1935
+ /**
1936
+ * Clear the current in-memory session state so the next sendMessage
1937
+ * starts a fresh conversation. The session row in SQLite is preserved
1938
+ * so it remains in the session index for later resume/switch.
1939
+ */
1940
+ @Throws(NativeAgentException::class)override fun `clearSession`()
1941
+ =
1942
+ callWithPointer {
1943
+ uniffiRustCallWithError(NativeAgentException) { _status ->
1944
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_clear_session(
1945
+ it, _status)
1946
+ }
1947
+ }
1948
+
1949
+
1950
+
1951
+
1952
+ /**
1953
+ * Delete auth for a provider.
1954
+ */
1955
+ @Throws(NativeAgentException::class)override fun `deleteAuth`(`provider`: kotlin.String)
1956
+ =
1957
+ callWithPointer {
1958
+ uniffiRustCallWithError(NativeAgentException) { _status ->
1959
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_delete_auth(
1960
+ it, FfiConverterString.lower(`provider`),_status)
1961
+ }
1962
+ }
1963
+
1964
+
1965
+
1966
+
1967
+ /**
1968
+ * End a skill session.
1969
+ */
1970
+ @Throws(NativeAgentException::class)override fun `endSkill`(`skillId`: kotlin.String)
1971
+ =
1972
+ callWithPointer {
1973
+ uniffiRustCallWithError(NativeAgentException) { _status ->
1974
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_end_skill(
1975
+ it, FfiConverterString.lower(`skillId`),_status)
1976
+ }
1977
+ }
1978
+
1979
+
1980
+
1981
+
1982
+ /**
1983
+ * Follow up on the current conversation.
1984
+ */
1985
+ @Throws(NativeAgentException::class)override fun `followUp`(`prompt`: kotlin.String)
1986
+ =
1987
+ callWithPointer {
1988
+ uniffiRustCallWithError(NativeAgentException) { _status ->
1989
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_follow_up(
1990
+ it, FfiConverterString.lower(`prompt`),_status)
1991
+ }
1992
+ }
1993
+
1994
+
1995
+
1996
+
1997
+ /**
1998
+ * Get auth status (masked key).
1999
+ */
2000
+ @Throws(NativeAgentException::class)override fun `getAuthStatus`(`provider`: kotlin.String): AuthStatusResult {
2001
+ return FfiConverterTypeAuthStatusResult.lift(
2002
+ callWithPointer {
2003
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2004
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_auth_status(
2005
+ it, FfiConverterString.lower(`provider`),_status)
2006
+ }
2007
+ }
2008
+ )
2009
+ }
2010
+
2011
+
2012
+
2013
+ /**
2014
+ * Get auth token for a provider.
2015
+ */
2016
+ @Throws(NativeAgentException::class)override fun `getAuthToken`(`provider`: kotlin.String): AuthTokenResult {
2017
+ return FfiConverterTypeAuthTokenResult.lift(
2018
+ callWithPointer {
2019
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2020
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_auth_token(
2021
+ it, FfiConverterString.lower(`provider`),_status)
2022
+ }
2023
+ }
2024
+ )
2025
+ }
2026
+
2027
+
2028
+
2029
+ /**
2030
+ * Get heartbeat config.
2031
+ */
2032
+ @Throws(NativeAgentException::class)override fun `getHeartbeatConfig`(): kotlin.String {
2033
+ return FfiConverterString.lift(
2034
+ callWithPointer {
2035
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2036
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_heartbeat_config(
2037
+ it, _status)
2038
+ }
2039
+ }
2040
+ )
2041
+ }
2042
+
2043
+
2044
+
2045
+ /**
2046
+ * Get available models for a provider.
2047
+ */
2048
+ @Throws(NativeAgentException::class)override fun `getModels`(`provider`: kotlin.String): kotlin.String {
2049
+ return FfiConverterString.lift(
2050
+ callWithPointer {
2051
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2052
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_models(
2053
+ it, FfiConverterString.lower(`provider`),_status)
2054
+ }
2055
+ }
2056
+ )
2057
+ }
2058
+
2059
+
2060
+
2061
+ /**
2062
+ * Get scheduler config.
2063
+ */
2064
+ @Throws(NativeAgentException::class)override fun `getSchedulerConfig`(): kotlin.String {
2065
+ return FfiConverterString.lift(
2066
+ callWithPointer {
2067
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2068
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_get_scheduler_config(
2069
+ it, _status)
2070
+ }
2071
+ }
2072
+ )
2073
+ }
2074
+
2075
+
2076
+
2077
+ /**
2078
+ * Handle a wake event (evaluate due cron jobs).
2079
+ */
2080
+ @Throws(NativeAgentException::class)override fun `handleWake`(`source`: kotlin.String)
2081
+ =
2082
+ callWithPointer {
2083
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2084
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_handle_wake(
2085
+ it, FfiConverterString.lower(`source`),_status)
2086
+ }
2087
+ }
2088
+
2089
+
2090
+
2091
+
2092
+ /**
2093
+ * Invoke a tool directly.
2094
+ */
2095
+ @Throws(NativeAgentException::class)override fun `invokeTool`(`toolName`: kotlin.String, `argsJson`: kotlin.String): kotlin.String {
2096
+ return FfiConverterString.lift(
2097
+ callWithPointer {
2098
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2099
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_invoke_tool(
2100
+ it, FfiConverterString.lower(`toolName`),FfiConverterString.lower(`argsJson`),_status)
2101
+ }
2102
+ }
2103
+ )
2104
+ }
2105
+
2106
+
2107
+
2108
+ /**
2109
+ * List all cron jobs.
2110
+ */
2111
+ @Throws(NativeAgentException::class)override fun `listCronJobs`(): kotlin.String {
2112
+ return FfiConverterString.lift(
2113
+ callWithPointer {
2114
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2115
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_cron_jobs(
2116
+ it, _status)
2117
+ }
2118
+ }
2119
+ )
2120
+ }
2121
+
2122
+
2123
+
2124
+ /**
2125
+ * List cron run history.
2126
+ */
2127
+ @Throws(NativeAgentException::class)override fun `listCronRuns`(`jobId`: kotlin.String?, `limit`: kotlin.Long): kotlin.String {
2128
+ return FfiConverterString.lift(
2129
+ callWithPointer {
2130
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2131
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_cron_runs(
2132
+ it, FfiConverterOptionalString.lower(`jobId`),FfiConverterLong.lower(`limit`),_status)
2133
+ }
2134
+ }
2135
+ )
2136
+ }
2137
+
2138
+
2139
+
2140
+ /**
2141
+ * List sessions for an agent.
2142
+ */
2143
+ @Throws(NativeAgentException::class)override fun `listSessions`(`agentId`: kotlin.String): kotlin.String {
2144
+ return FfiConverterString.lift(
2145
+ callWithPointer {
2146
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2147
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_sessions(
2148
+ it, FfiConverterString.lower(`agentId`),_status)
2149
+ }
2150
+ }
2151
+ )
2152
+ }
2153
+
2154
+
2155
+
2156
+ /**
2157
+ * List all cron skills.
2158
+ */
2159
+ @Throws(NativeAgentException::class)override fun `listSkills`(): kotlin.String {
2160
+ return FfiConverterString.lift(
2161
+ callWithPointer {
2162
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2163
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_list_skills(
2164
+ it, _status)
2165
+ }
2166
+ }
2167
+ )
2168
+ }
2169
+
2170
+
2171
+
2172
+ /**
2173
+ * Load session message history.
2174
+ */
2175
+ @Throws(NativeAgentException::class)override fun `loadSession`(`sessionKey`: kotlin.String): kotlin.String {
2176
+ return FfiConverterString.lift(
2177
+ callWithPointer {
2178
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2179
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_load_session(
2180
+ it, FfiConverterString.lower(`sessionKey`),_status)
2181
+ }
2182
+ }
2183
+ )
2184
+ }
2185
+
2186
+
2187
+
2188
+ /**
2189
+ * Refresh an OAuth token.
2190
+ */
2191
+ @Throws(NativeAgentException::class)override fun `refreshToken`(`provider`: kotlin.String): AuthTokenResult {
2192
+ return FfiConverterTypeAuthTokenResult.lift(
2193
+ callWithPointer {
2194
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2195
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_refresh_token(
2196
+ it, FfiConverterString.lower(`provider`),_status)
2197
+ }
2198
+ }
2199
+ )
2200
+ }
2201
+
2202
+
2203
+
2204
+ /**
2205
+ * Remove a cron job.
2206
+ */
2207
+ @Throws(NativeAgentException::class)override fun `removeCronJob`(`id`: kotlin.String)
2208
+ =
2209
+ callWithPointer {
2210
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2211
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_remove_cron_job(
2212
+ it, FfiConverterString.lower(`id`),_status)
2213
+ }
2214
+ }
2215
+
2216
+
2217
+
2218
+
2219
+ /**
2220
+ * Remove a cron skill.
2221
+ */
2222
+ @Throws(NativeAgentException::class)override fun `removeSkill`(`id`: kotlin.String)
2223
+ =
2224
+ callWithPointer {
2225
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2226
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_remove_skill(
2227
+ it, FfiConverterString.lower(`id`),_status)
2228
+ }
2229
+ }
2230
+
2231
+
2232
+
2233
+
2234
+ /**
2235
+ * Respond to a tool approval request.
2236
+ */
2237
+ @Throws(NativeAgentException::class)override fun `respondToApproval`(`toolCallId`: kotlin.String, `approved`: kotlin.Boolean, `reason`: kotlin.String?)
2238
+ =
2239
+ callWithPointer {
2240
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2241
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_approval(
2242
+ it, FfiConverterString.lower(`toolCallId`),FfiConverterBoolean.lower(`approved`),FfiConverterOptionalString.lower(`reason`),_status)
2243
+ }
2244
+ }
2245
+
2246
+
2247
+
2248
+
2249
+ /**
2250
+ * Respond to a cron approval request.
2251
+ */
2252
+ @Throws(NativeAgentException::class)override fun `respondToCronApproval`(`requestId`: kotlin.String, `approved`: kotlin.Boolean)
2253
+ =
2254
+ callWithPointer {
2255
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2256
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_cron_approval(
2257
+ it, FfiConverterString.lower(`requestId`),FfiConverterBoolean.lower(`approved`),_status)
2258
+ }
2259
+ }
2260
+
2261
+
2262
+
2263
+
2264
+ /**
2265
+ * Respond to a pending MCP tool call.
2266
+ */
2267
+ @Throws(NativeAgentException::class)override fun `respondToMcpTool`(`toolCallId`: kotlin.String, `resultJson`: kotlin.String, `isError`: kotlin.Boolean)
2268
+ =
2269
+ callWithPointer {
2270
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2271
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_respond_to_mcp_tool(
2272
+ it, FfiConverterString.lower(`toolCallId`),FfiConverterString.lower(`resultJson`),FfiConverterBoolean.lower(`isError`),_status)
2273
+ }
2274
+ }
2275
+
2276
+
2277
+
2278
+
2279
+ /**
2280
+ * Restart MCP server with new tools.
2281
+ */
2282
+ @Throws(NativeAgentException::class)override fun `restartMcp`(`toolsJson`: kotlin.String): kotlin.UInt {
2283
+ return FfiConverterUInt.lift(
2284
+ callWithPointer {
2285
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2286
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_restart_mcp(
2287
+ it, FfiConverterString.lower(`toolsJson`),_status)
2288
+ }
2289
+ }
2290
+ )
2291
+ }
2292
+
2293
+
2294
+
2295
+ /**
2296
+ * Resume a session (load messages into agent context).
2297
+ */
2298
+ @Throws(NativeAgentException::class)override fun `resumeSession`(`sessionKey`: kotlin.String, `agentId`: kotlin.String, `messagesJson`: kotlin.String?, `provider`: kotlin.String?, `model`: kotlin.String?)
2299
+ =
2300
+ callWithPointer {
2301
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2302
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_resume_session(
2303
+ it, FfiConverterString.lower(`sessionKey`),FfiConverterString.lower(`agentId`),FfiConverterOptionalString.lower(`messagesJson`),FfiConverterOptionalString.lower(`provider`),FfiConverterOptionalString.lower(`model`),_status)
2304
+ }
2305
+ }
2306
+
2307
+
2308
+
2309
+
2310
+ /**
2311
+ * Force-trigger a cron job.
2312
+ */
2313
+ @Throws(NativeAgentException::class)override fun `runCronJob`(`jobId`: kotlin.String)
2314
+ =
2315
+ callWithPointer {
2316
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2317
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_run_cron_job(
2318
+ it, FfiConverterString.lower(`jobId`),_status)
2319
+ }
2320
+ }
2321
+
2322
+
2323
+
2324
+
2325
+ /**
2326
+ * Send a message to the agent and start an agent loop turn.
2327
+ */
2328
+ @Throws(NativeAgentException::class)override fun `sendMessage`(`params`: SendMessageParams): kotlin.String {
2329
+ return FfiConverterString.lift(
2330
+ callWithPointer {
2331
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2332
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_send_message(
2333
+ it, FfiConverterTypeSendMessageParams.lower(`params`),_status)
2334
+ }
2335
+ }
2336
+ )
2337
+ }
2338
+
2339
+
2340
+
2341
+ /**
2342
+ * Set an auth key for a provider.
2343
+ */
2344
+ @Throws(NativeAgentException::class)override fun `setAuthKey`(`key`: kotlin.String, `provider`: kotlin.String, `authType`: kotlin.String)
2345
+ =
2346
+ callWithPointer {
2347
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2348
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_auth_key(
2349
+ it, FfiConverterString.lower(`key`),FfiConverterString.lower(`provider`),FfiConverterString.lower(`authType`),_status)
2350
+ }
2351
+ }
2352
+
2353
+
2354
+
2355
+
2356
+ /**
2357
+ * Set the event callback for receiving agent events.
2358
+ */
2359
+ @Throws(NativeAgentException::class)override fun `setEventCallback`(`callback`: NativeEventCallback)
2360
+ =
2361
+ callWithPointer {
2362
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2363
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_event_callback(
2364
+ it, FfiConverterTypeNativeEventCallback.lower(`callback`),_status)
2365
+ }
2366
+ }
2367
+
2368
+
2369
+
2370
+
2371
+ /**
2372
+ * Set heartbeat config.
2373
+ */
2374
+ @Throws(NativeAgentException::class)override fun `setHeartbeatConfig`(`configJson`: kotlin.String)
2375
+ =
2376
+ callWithPointer {
2377
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2378
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_heartbeat_config(
2379
+ it, FfiConverterString.lower(`configJson`),_status)
2380
+ }
2381
+ }
2382
+
2383
+
2384
+
2385
+
2386
+ /**
2387
+ * Set scheduler config.
2388
+ */
2389
+ @Throws(NativeAgentException::class)override fun `setSchedulerConfig`(`configJson`: kotlin.String)
2390
+ =
2391
+ callWithPointer {
2392
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2393
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_set_scheduler_config(
2394
+ it, FfiConverterString.lower(`configJson`),_status)
2395
+ }
2396
+ }
2397
+
2398
+
2399
+
2400
+
2401
+ /**
2402
+ * Start MCP server with given tools.
2403
+ */
2404
+ @Throws(NativeAgentException::class)override fun `startMcp`(`toolsJson`: kotlin.String): kotlin.UInt {
2405
+ return FfiConverterUInt.lift(
2406
+ callWithPointer {
2407
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2408
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_start_mcp(
2409
+ it, FfiConverterString.lower(`toolsJson`),_status)
2410
+ }
2411
+ }
2412
+ )
2413
+ }
2414
+
2415
+
2416
+
2417
+ /**
2418
+ * Start a skill session.
2419
+ */
2420
+ @Throws(NativeAgentException::class)override fun `startSkill`(`skillId`: kotlin.String, `configJson`: kotlin.String, `provider`: kotlin.String?): kotlin.String {
2421
+ return FfiConverterString.lift(
2422
+ callWithPointer {
2423
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2424
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_start_skill(
2425
+ it, FfiConverterString.lower(`skillId`),FfiConverterString.lower(`configJson`),FfiConverterOptionalString.lower(`provider`),_status)
2426
+ }
2427
+ }
2428
+ )
2429
+ }
2430
+
2431
+
2432
+
2433
+ /**
2434
+ * Steer the running agent with additional context.
2435
+ */
2436
+ @Throws(NativeAgentException::class)override fun `steer`(`text`: kotlin.String)
2437
+ =
2438
+ callWithPointer {
2439
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2440
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_steer(
2441
+ it, FfiConverterString.lower(`text`),_status)
2442
+ }
2443
+ }
2444
+
2445
+
2446
+
2447
+
2448
+ /**
2449
+ * Update a cron job.
2450
+ */
2451
+ @Throws(NativeAgentException::class)override fun `updateCronJob`(`id`: kotlin.String, `patchJson`: kotlin.String)
2452
+ =
2453
+ callWithPointer {
2454
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2455
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_update_cron_job(
2456
+ it, FfiConverterString.lower(`id`),FfiConverterString.lower(`patchJson`),_status)
2457
+ }
2458
+ }
2459
+
2460
+
2461
+
2462
+
2463
+ /**
2464
+ * Update a cron skill.
2465
+ */
2466
+ @Throws(NativeAgentException::class)override fun `updateSkill`(`id`: kotlin.String, `patchJson`: kotlin.String)
2467
+ =
2468
+ callWithPointer {
2469
+ uniffiRustCallWithError(NativeAgentException) { _status ->
2470
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_method_nativeagenthandle_update_skill(
2471
+ it, FfiConverterString.lower(`id`),FfiConverterString.lower(`patchJson`),_status)
2472
+ }
2473
+ }
2474
+
2475
+
2476
+
2477
+
2478
+
2479
+
2480
+
2481
+ companion object
2482
+
2483
+ }
2484
+
2485
+ /**
2486
+ * @suppress
2487
+ */
2488
+ public object FfiConverterTypeNativeAgentHandle: FfiConverter<NativeAgentHandle, Pointer> {
2489
+
2490
+ override fun lower(value: NativeAgentHandle): Pointer {
2491
+ return value.uniffiClonePointer()
2492
+ }
2493
+
2494
+ override fun lift(value: Pointer): NativeAgentHandle {
2495
+ return NativeAgentHandle(value)
2496
+ }
2497
+
2498
+ override fun read(buf: ByteBuffer): NativeAgentHandle {
2499
+ // The Rust code always writes pointers as 8 bytes, and will
2500
+ // fail to compile if they don't fit.
2501
+ return lift(Pointer(buf.getLong()))
2502
+ }
2503
+
2504
+ override fun allocationSize(value: NativeAgentHandle) = 8UL
2505
+
2506
+ override fun write(value: NativeAgentHandle, buf: ByteBuffer) {
2507
+ // The Rust code always expects pointers written as 8 bytes,
2508
+ // and will fail to compile if they don't fit.
2509
+ buf.putLong(Pointer.nativeValue(lower(value)))
2510
+ }
2511
+ }
2512
+
2513
+
2514
+
2515
+ /**
2516
+ * Auth status result.
2517
+ */
2518
+ data class AuthStatusResult (
2519
+ var `hasKey`: kotlin.Boolean,
2520
+ var `masked`: kotlin.String,
2521
+ var `provider`: kotlin.String
2522
+ ) {
2523
+
2524
+ companion object
2525
+ }
2526
+
2527
+ /**
2528
+ * @suppress
2529
+ */
2530
+ public object FfiConverterTypeAuthStatusResult: FfiConverterRustBuffer<AuthStatusResult> {
2531
+ override fun read(buf: ByteBuffer): AuthStatusResult {
2532
+ return AuthStatusResult(
2533
+ FfiConverterBoolean.read(buf),
2534
+ FfiConverterString.read(buf),
2535
+ FfiConverterString.read(buf),
2536
+ )
2537
+ }
2538
+
2539
+ override fun allocationSize(value: AuthStatusResult) = (
2540
+ FfiConverterBoolean.allocationSize(value.`hasKey`) +
2541
+ FfiConverterString.allocationSize(value.`masked`) +
2542
+ FfiConverterString.allocationSize(value.`provider`)
2543
+ )
2544
+
2545
+ override fun write(value: AuthStatusResult, buf: ByteBuffer) {
2546
+ FfiConverterBoolean.write(value.`hasKey`, buf)
2547
+ FfiConverterString.write(value.`masked`, buf)
2548
+ FfiConverterString.write(value.`provider`, buf)
2549
+ }
2550
+ }
2551
+
2552
+
2553
+
2554
+ /**
2555
+ * Auth token result.
2556
+ */
2557
+ data class AuthTokenResult (
2558
+ var `apiKey`: kotlin.String?,
2559
+ var `isOauth`: kotlin.Boolean
2560
+ ) {
2561
+
2562
+ companion object
2563
+ }
2564
+
2565
+ /**
2566
+ * @suppress
2567
+ */
2568
+ public object FfiConverterTypeAuthTokenResult: FfiConverterRustBuffer<AuthTokenResult> {
2569
+ override fun read(buf: ByteBuffer): AuthTokenResult {
2570
+ return AuthTokenResult(
2571
+ FfiConverterOptionalString.read(buf),
2572
+ FfiConverterBoolean.read(buf),
2573
+ )
2574
+ }
2575
+
2576
+ override fun allocationSize(value: AuthTokenResult) = (
2577
+ FfiConverterOptionalString.allocationSize(value.`apiKey`) +
2578
+ FfiConverterBoolean.allocationSize(value.`isOauth`)
2579
+ )
2580
+
2581
+ override fun write(value: AuthTokenResult, buf: ByteBuffer) {
2582
+ FfiConverterOptionalString.write(value.`apiKey`, buf)
2583
+ FfiConverterBoolean.write(value.`isOauth`, buf)
2584
+ }
2585
+ }
2586
+
2587
+
2588
+
2589
+ /**
2590
+ * Configuration for initializing the native agent handle.
2591
+ */
2592
+ data class InitConfig (
2593
+ /**
2594
+ * Path to the SQLite database.
2595
+ */
2596
+ var `dbPath`: kotlin.String,
2597
+ /**
2598
+ * Path to the workspace root.
2599
+ */
2600
+ var `workspacePath`: kotlin.String,
2601
+ /**
2602
+ * Path to auth-profiles.json.
2603
+ */
2604
+ var `authProfilesPath`: kotlin.String
2605
+ ) {
2606
+
2607
+ companion object
2608
+ }
2609
+
2610
+ /**
2611
+ * @suppress
2612
+ */
2613
+ public object FfiConverterTypeInitConfig: FfiConverterRustBuffer<InitConfig> {
2614
+ override fun read(buf: ByteBuffer): InitConfig {
2615
+ return InitConfig(
2616
+ FfiConverterString.read(buf),
2617
+ FfiConverterString.read(buf),
2618
+ FfiConverterString.read(buf),
2619
+ )
2620
+ }
2621
+
2622
+ override fun allocationSize(value: InitConfig) = (
2623
+ FfiConverterString.allocationSize(value.`dbPath`) +
2624
+ FfiConverterString.allocationSize(value.`workspacePath`) +
2625
+ FfiConverterString.allocationSize(value.`authProfilesPath`)
2626
+ )
2627
+
2628
+ override fun write(value: InitConfig, buf: ByteBuffer) {
2629
+ FfiConverterString.write(value.`dbPath`, buf)
2630
+ FfiConverterString.write(value.`workspacePath`, buf)
2631
+ FfiConverterString.write(value.`authProfilesPath`, buf)
2632
+ }
2633
+ }
2634
+
2635
+
2636
+
2637
+ /**
2638
+ * Parameters for sending a message.
2639
+ */
2640
+ data class SendMessageParams (
2641
+ var `prompt`: kotlin.String,
2642
+ var `sessionKey`: kotlin.String,
2643
+ var `model`: kotlin.String?,
2644
+ var `provider`: kotlin.String?,
2645
+ var `systemPrompt`: kotlin.String,
2646
+ var `maxTurns`: kotlin.UInt?,
2647
+ /**
2648
+ * JSON-encoded list of allowed tool names. Empty = all tools.
2649
+ */
2650
+ var `allowedToolsJson`: kotlin.String?
2651
+ ) {
2652
+
2653
+ companion object
2654
+ }
2655
+
2656
+ /**
2657
+ * @suppress
2658
+ */
2659
+ public object FfiConverterTypeSendMessageParams: FfiConverterRustBuffer<SendMessageParams> {
2660
+ override fun read(buf: ByteBuffer): SendMessageParams {
2661
+ return SendMessageParams(
2662
+ FfiConverterString.read(buf),
2663
+ FfiConverterString.read(buf),
2664
+ FfiConverterOptionalString.read(buf),
2665
+ FfiConverterOptionalString.read(buf),
2666
+ FfiConverterString.read(buf),
2667
+ FfiConverterOptionalUInt.read(buf),
2668
+ FfiConverterOptionalString.read(buf),
2669
+ )
2670
+ }
2671
+
2672
+ override fun allocationSize(value: SendMessageParams) = (
2673
+ FfiConverterString.allocationSize(value.`prompt`) +
2674
+ FfiConverterString.allocationSize(value.`sessionKey`) +
2675
+ FfiConverterOptionalString.allocationSize(value.`model`) +
2676
+ FfiConverterOptionalString.allocationSize(value.`provider`) +
2677
+ FfiConverterString.allocationSize(value.`systemPrompt`) +
2678
+ FfiConverterOptionalUInt.allocationSize(value.`maxTurns`) +
2679
+ FfiConverterOptionalString.allocationSize(value.`allowedToolsJson`)
2680
+ )
2681
+
2682
+ override fun write(value: SendMessageParams, buf: ByteBuffer) {
2683
+ FfiConverterString.write(value.`prompt`, buf)
2684
+ FfiConverterString.write(value.`sessionKey`, buf)
2685
+ FfiConverterOptionalString.write(value.`model`, buf)
2686
+ FfiConverterOptionalString.write(value.`provider`, buf)
2687
+ FfiConverterString.write(value.`systemPrompt`, buf)
2688
+ FfiConverterOptionalUInt.write(value.`maxTurns`, buf)
2689
+ FfiConverterOptionalString.write(value.`allowedToolsJson`, buf)
2690
+ }
2691
+ }
2692
+
2693
+
2694
+
2695
+ /**
2696
+ * Token usage from an agent turn.
2697
+ */
2698
+ data class TokenUsage (
2699
+ var `inputTokens`: kotlin.UInt,
2700
+ var `outputTokens`: kotlin.UInt,
2701
+ var `totalTokens`: kotlin.UInt
2702
+ ) {
2703
+
2704
+ companion object
2705
+ }
2706
+
2707
+ /**
2708
+ * @suppress
2709
+ */
2710
+ public object FfiConverterTypeTokenUsage: FfiConverterRustBuffer<TokenUsage> {
2711
+ override fun read(buf: ByteBuffer): TokenUsage {
2712
+ return TokenUsage(
2713
+ FfiConverterUInt.read(buf),
2714
+ FfiConverterUInt.read(buf),
2715
+ FfiConverterUInt.read(buf),
2716
+ )
2717
+ }
2718
+
2719
+ override fun allocationSize(value: TokenUsage) = (
2720
+ FfiConverterUInt.allocationSize(value.`inputTokens`) +
2721
+ FfiConverterUInt.allocationSize(value.`outputTokens`) +
2722
+ FfiConverterUInt.allocationSize(value.`totalTokens`)
2723
+ )
2724
+
2725
+ override fun write(value: TokenUsage, buf: ByteBuffer) {
2726
+ FfiConverterUInt.write(value.`inputTokens`, buf)
2727
+ FfiConverterUInt.write(value.`outputTokens`, buf)
2728
+ FfiConverterUInt.write(value.`totalTokens`, buf)
2729
+ }
2730
+ }
2731
+
2732
+
2733
+
2734
+
2735
+
2736
+ /**
2737
+ * Top-level error type exposed via UniFFI.
2738
+ */
2739
+ sealed class NativeAgentException: kotlin.Exception() {
2740
+
2741
+ class Agent(
2742
+
2743
+ val `msg`: kotlin.String
2744
+ ) : NativeAgentException() {
2745
+ override val message
2746
+ get() = "msg=${ `msg` }"
2747
+ }
2748
+
2749
+ class Auth(
2750
+
2751
+ val `msg`: kotlin.String
2752
+ ) : NativeAgentException() {
2753
+ override val message
2754
+ get() = "msg=${ `msg` }"
2755
+ }
2756
+
2757
+ class Database(
2758
+
2759
+ val `msg`: kotlin.String
2760
+ ) : NativeAgentException() {
2761
+ override val message
2762
+ get() = "msg=${ `msg` }"
2763
+ }
2764
+
2765
+ class Llm(
2766
+
2767
+ val `msg`: kotlin.String
2768
+ ) : NativeAgentException() {
2769
+ override val message
2770
+ get() = "msg=${ `msg` }"
2771
+ }
2772
+
2773
+ class Tool(
2774
+
2775
+ val `msg`: kotlin.String
2776
+ ) : NativeAgentException() {
2777
+ override val message
2778
+ get() = "msg=${ `msg` }"
2779
+ }
2780
+
2781
+ class Io(
2782
+
2783
+ val `msg`: kotlin.String
2784
+ ) : NativeAgentException() {
2785
+ override val message
2786
+ get() = "msg=${ `msg` }"
2787
+ }
2788
+
2789
+ class Cancelled(
2790
+ ) : NativeAgentException() {
2791
+ override val message
2792
+ get() = ""
2793
+ }
2794
+
2795
+
2796
+ companion object ErrorHandler : UniffiRustCallStatusErrorHandler<NativeAgentException> {
2797
+ override fun lift(error_buf: RustBuffer.ByValue): NativeAgentException = FfiConverterTypeNativeAgentError.lift(error_buf)
2798
+ }
2799
+
2800
+
2801
+ }
2802
+
2803
+ /**
2804
+ * @suppress
2805
+ */
2806
+ public object FfiConverterTypeNativeAgentError : FfiConverterRustBuffer<NativeAgentException> {
2807
+ override fun read(buf: ByteBuffer): NativeAgentException {
2808
+
2809
+
2810
+ return when(buf.getInt()) {
2811
+ 1 -> NativeAgentException.Agent(
2812
+ FfiConverterString.read(buf),
2813
+ )
2814
+ 2 -> NativeAgentException.Auth(
2815
+ FfiConverterString.read(buf),
2816
+ )
2817
+ 3 -> NativeAgentException.Database(
2818
+ FfiConverterString.read(buf),
2819
+ )
2820
+ 4 -> NativeAgentException.Llm(
2821
+ FfiConverterString.read(buf),
2822
+ )
2823
+ 5 -> NativeAgentException.Tool(
2824
+ FfiConverterString.read(buf),
2825
+ )
2826
+ 6 -> NativeAgentException.Io(
2827
+ FfiConverterString.read(buf),
2828
+ )
2829
+ 7 -> NativeAgentException.Cancelled()
2830
+ else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
2831
+ }
2832
+ }
2833
+
2834
+ override fun allocationSize(value: NativeAgentException): ULong {
2835
+ return when(value) {
2836
+ is NativeAgentException.Agent -> (
2837
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2838
+ 4UL
2839
+ + FfiConverterString.allocationSize(value.`msg`)
2840
+ )
2841
+ is NativeAgentException.Auth -> (
2842
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2843
+ 4UL
2844
+ + FfiConverterString.allocationSize(value.`msg`)
2845
+ )
2846
+ is NativeAgentException.Database -> (
2847
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2848
+ 4UL
2849
+ + FfiConverterString.allocationSize(value.`msg`)
2850
+ )
2851
+ is NativeAgentException.Llm -> (
2852
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2853
+ 4UL
2854
+ + FfiConverterString.allocationSize(value.`msg`)
2855
+ )
2856
+ is NativeAgentException.Tool -> (
2857
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2858
+ 4UL
2859
+ + FfiConverterString.allocationSize(value.`msg`)
2860
+ )
2861
+ is NativeAgentException.Io -> (
2862
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2863
+ 4UL
2864
+ + FfiConverterString.allocationSize(value.`msg`)
2865
+ )
2866
+ is NativeAgentException.Cancelled -> (
2867
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
2868
+ 4UL
2869
+ )
2870
+ }
2871
+ }
2872
+
2873
+ override fun write(value: NativeAgentException, buf: ByteBuffer) {
2874
+ when(value) {
2875
+ is NativeAgentException.Agent -> {
2876
+ buf.putInt(1)
2877
+ FfiConverterString.write(value.`msg`, buf)
2878
+ Unit
2879
+ }
2880
+ is NativeAgentException.Auth -> {
2881
+ buf.putInt(2)
2882
+ FfiConverterString.write(value.`msg`, buf)
2883
+ Unit
2884
+ }
2885
+ is NativeAgentException.Database -> {
2886
+ buf.putInt(3)
2887
+ FfiConverterString.write(value.`msg`, buf)
2888
+ Unit
2889
+ }
2890
+ is NativeAgentException.Llm -> {
2891
+ buf.putInt(4)
2892
+ FfiConverterString.write(value.`msg`, buf)
2893
+ Unit
2894
+ }
2895
+ is NativeAgentException.Tool -> {
2896
+ buf.putInt(5)
2897
+ FfiConverterString.write(value.`msg`, buf)
2898
+ Unit
2899
+ }
2900
+ is NativeAgentException.Io -> {
2901
+ buf.putInt(6)
2902
+ FfiConverterString.write(value.`msg`, buf)
2903
+ Unit
2904
+ }
2905
+ is NativeAgentException.Cancelled -> {
2906
+ buf.putInt(7)
2907
+ Unit
2908
+ }
2909
+ }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
2910
+ }
2911
+
2912
+ }
2913
+
2914
+
2915
+
2916
+
2917
+
2918
+ /**
2919
+ * Callback interface for events from the native agent.
2920
+ */
2921
+ public interface NativeEventCallback {
2922
+
2923
+ /**
2924
+ * Called when the agent emits an event.
2925
+ * `event_type`: text_delta, tool_use, tool_result, agent.completed, agent.error, etc.
2926
+ * `payload_json`: JSON-encoded event data.
2927
+ */
2928
+ fun `onEvent`(`eventType`: kotlin.String, `payloadJson`: kotlin.String)
2929
+
2930
+ companion object
2931
+ }
2932
+
2933
+ // Magic number for the Rust proxy to call using the same mechanism as every other method,
2934
+ // to free the callback once it's dropped by Rust.
2935
+ internal const val IDX_CALLBACK_FREE = 0
2936
+ // Callback return codes
2937
+ internal const val UNIFFI_CALLBACK_SUCCESS = 0
2938
+ internal const val UNIFFI_CALLBACK_ERROR = 1
2939
+ internal const val UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2
2940
+
2941
+ /**
2942
+ * @suppress
2943
+ */
2944
+ public abstract class FfiConverterCallbackInterface<CallbackInterface: Any>: FfiConverter<CallbackInterface, Long> {
2945
+ internal val handleMap = UniffiHandleMap<CallbackInterface>()
2946
+
2947
+ internal fun drop(handle: Long) {
2948
+ handleMap.remove(handle)
2949
+ }
2950
+
2951
+ override fun lift(value: Long): CallbackInterface {
2952
+ return handleMap.get(value)
2953
+ }
2954
+
2955
+ override fun read(buf: ByteBuffer) = lift(buf.getLong())
2956
+
2957
+ override fun lower(value: CallbackInterface) = handleMap.insert(value)
2958
+
2959
+ override fun allocationSize(value: CallbackInterface) = 8UL
2960
+
2961
+ override fun write(value: CallbackInterface, buf: ByteBuffer) {
2962
+ buf.putLong(lower(value))
2963
+ }
2964
+ }
2965
+
2966
+ // Put the implementation in an object so we don't pollute the top-level namespace
2967
+ internal object uniffiCallbackInterfaceNativeEventCallback {
2968
+ internal object `onEvent`: UniffiCallbackInterfaceNativeEventCallbackMethod0 {
2969
+ override fun callback(`uniffiHandle`: Long,`eventType`: RustBuffer.ByValue,`payloadJson`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) {
2970
+ val uniffiObj = FfiConverterTypeNativeEventCallback.handleMap.get(uniffiHandle)
2971
+ val makeCall = { ->
2972
+ uniffiObj.`onEvent`(
2973
+ FfiConverterString.lift(`eventType`),
2974
+ FfiConverterString.lift(`payloadJson`),
2975
+ )
2976
+ }
2977
+ val writeReturn = { _: Unit -> Unit }
2978
+ uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn)
2979
+ }
2980
+ }
2981
+
2982
+ internal object uniffiFree: UniffiCallbackInterfaceFree {
2983
+ override fun callback(handle: Long) {
2984
+ FfiConverterTypeNativeEventCallback.handleMap.remove(handle)
2985
+ }
2986
+ }
2987
+
2988
+ internal var vtable = UniffiVTableCallbackInterfaceNativeEventCallback.UniffiByValue(
2989
+ `onEvent`,
2990
+ uniffiFree,
2991
+ )
2992
+
2993
+ // Registers the foreign callback with the Rust side.
2994
+ // This method is generated for each callback interface.
2995
+ internal fun register(lib: UniffiLib) {
2996
+ lib.uniffi_native_agent_ffi_fn_init_callback_vtable_nativeeventcallback(vtable)
2997
+ }
2998
+ }
2999
+
3000
+ /**
3001
+ * The ffiConverter which transforms the Callbacks in to handles to pass to Rust.
3002
+ *
3003
+ * @suppress
3004
+ */
3005
+ public object FfiConverterTypeNativeEventCallback: FfiConverterCallbackInterface<NativeEventCallback>()
3006
+
3007
+
3008
+
3009
+
3010
+ /**
3011
+ * @suppress
3012
+ */
3013
+ public object FfiConverterOptionalUInt: FfiConverterRustBuffer<kotlin.UInt?> {
3014
+ override fun read(buf: ByteBuffer): kotlin.UInt? {
3015
+ if (buf.get().toInt() == 0) {
3016
+ return null
3017
+ }
3018
+ return FfiConverterUInt.read(buf)
3019
+ }
3020
+
3021
+ override fun allocationSize(value: kotlin.UInt?): ULong {
3022
+ if (value == null) {
3023
+ return 1UL
3024
+ } else {
3025
+ return 1UL + FfiConverterUInt.allocationSize(value)
3026
+ }
3027
+ }
3028
+
3029
+ override fun write(value: kotlin.UInt?, buf: ByteBuffer) {
3030
+ if (value == null) {
3031
+ buf.put(0)
3032
+ } else {
3033
+ buf.put(1)
3034
+ FfiConverterUInt.write(value, buf)
3035
+ }
3036
+ }
3037
+ }
3038
+
3039
+
3040
+
3041
+
3042
+ /**
3043
+ * @suppress
3044
+ */
3045
+ public object FfiConverterOptionalString: FfiConverterRustBuffer<kotlin.String?> {
3046
+ override fun read(buf: ByteBuffer): kotlin.String? {
3047
+ if (buf.get().toInt() == 0) {
3048
+ return null
3049
+ }
3050
+ return FfiConverterString.read(buf)
3051
+ }
3052
+
3053
+ override fun allocationSize(value: kotlin.String?): ULong {
3054
+ if (value == null) {
3055
+ return 1UL
3056
+ } else {
3057
+ return 1UL + FfiConverterString.allocationSize(value)
3058
+ }
3059
+ }
3060
+
3061
+ override fun write(value: kotlin.String?, buf: ByteBuffer) {
3062
+ if (value == null) {
3063
+ buf.put(0)
3064
+ } else {
3065
+ buf.put(1)
3066
+ FfiConverterString.write(value, buf)
3067
+ }
3068
+ }
3069
+ }
3070
+ /**
3071
+ * Standalone workspace initialization for cold-start paths.
3072
+ */
3073
+ @Throws(NativeAgentException::class) fun `initWorkspace`(`config`: InitConfig)
3074
+ =
3075
+ uniffiRustCallWithError(NativeAgentException) { _status ->
3076
+ UniffiLib.INSTANCE.uniffi_native_agent_ffi_fn_func_init_workspace(
3077
+ FfiConverterTypeInitConfig.lower(`config`),_status)
3078
+ }
3079
+
3080
+
3081
+
3082
+