@h1r-ai/croche-react-native 0.6.0 → 0.7.0

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.
Files changed (183) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +32 -4
  3. package/THIRD-PARTY-NOTICES +899 -6
  4. package/android/src/androidTest/java/dev/croche/reactnative/WikiFileBridgeTest.kt +4 -3
  5. package/android/src/main/AndroidManifest.xml +0 -5
  6. package/android/src/main/java/dev/croche/reactnative/CoreDispatch.kt +33 -8
  7. package/android/src/main/java/dev/croche/reactnative/CoreWire.kt +139 -5
  8. package/android/src/main/java/dev/croche/reactnative/CrocheRuntimeModule.kt +5 -2
  9. package/android/src/main/java/dev/croche/reactnative/NativePal.kt +23 -6
  10. package/android/src/test/java/dev/croche/reactnative/AgentMemoryTest.kt +28 -6
  11. package/android/src/test/java/dev/croche/reactnative/BackgroundDelegationTest.kt +4 -11
  12. package/android/src/test/java/dev/croche/reactnative/BlobFilesTest.kt +107 -0
  13. package/android/src/test/java/dev/croche/reactnative/ImageAdapterWireTest.kt +70 -0
  14. package/android/src/test/java/dev/croche/reactnative/OpenForwardingFixture.kt +19 -4
  15. package/android/src/test/java/dev/croche/reactnative/ProjectAttestationTest.kt +2 -2
  16. package/android/src/test/java/dev/croche/reactnative/StorageVersionWireTest.kt +37 -0
  17. package/android/src/test/java/dev/croche/reactnative/VerificationDispatchTest.kt +24 -0
  18. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/AndroidPlatform.kt +5 -3
  19. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BackgroundWakeWorker.kt +4 -0
  20. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapDecodedImageCodec.kt +11 -11
  21. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapImageCodec.kt +1 -0
  22. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidCoreHost.kt +11 -16
  23. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidPublicPlatform.kt +3 -3
  24. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidStateStore.kt +216 -0
  25. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidStoragePal.kt +45 -10
  26. package/android/vendor/CrocheRuntimeSDK/consumer-rules.pro +0 -3
  27. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Adapters.kt +75 -0
  28. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/BindingFacts.kt +1 -1
  29. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ContextConfig.kt +9 -23
  30. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Core.kt +11 -2
  31. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Croche.kt +83 -20
  32. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheAgent.kt +54 -8
  33. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheRuntime.kt +19 -360
  34. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheTools.kt +79 -10
  35. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Decision.kt +170 -0
  36. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/DecodedImageCodec.kt +8 -5
  37. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Effects.kt +8 -1
  38. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/EncodedImageCodec.kt +51 -0
  39. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/GeneratedAppStream.kt +426 -33
  40. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Host.kt +1 -351
  41. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Images.kt +15 -29
  42. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeEvent.kt +59 -0
  43. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeHandleOwner.kt +118 -0
  44. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Platform.kt +10 -74
  45. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectTypes.kt +196 -10
  46. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/PublicResults.kt +86 -3
  47. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/RunTool.kt +33 -0
  48. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/SendEncoding.kt +1 -1
  49. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StateStore.kt +90 -0
  50. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/SubscriptionTypes.kt +68 -4
  51. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ffi/croche_ffi.kt +3403 -6894
  52. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/AppStoragePal.kt +89 -18
  53. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreFactoryCalls.kt +1 -2
  54. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreOptionsEncoding.kt +2 -2
  55. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreStreamCalls.kt +3 -3
  56. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ForeignCallbacks.kt +17 -18
  57. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ImageAdapterHost.kt +28 -0
  58. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmCoreHost.kt +12 -14
  59. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmStateStore.kt +125 -0
  60. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmStoragePal.kt +36 -6
  61. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/NativeCoreInitialization.kt +21 -0
  62. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/NativePlatform.kt +21 -6
  63. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/PublicCalls.kt +16 -7
  64. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/StateStoreContract.kt +103 -0
  65. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/StorageVersionContract.kt +40 -0
  66. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/AtomicKeyFiles.kt +25 -4
  67. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/BlobFiles.kt +157 -0
  68. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/InstancePayloadPurge.kt +79 -0
  69. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/VersionedKeyFiles.kt +71 -0
  70. package/android/vendor/jniLibs/arm64-v8a/libcroche_ffi.so +0 -0
  71. package/android/vendor/jniLibs/armeabi-v7a/libcroche_ffi.so +0 -0
  72. package/android/vendor/jniLibs/x86_64/libcroche_ffi.so +0 -0
  73. package/croche-react-native.podspec +1 -0
  74. package/dist/react-native/src/core-native.d.ts +3 -0
  75. package/dist/react-native/src/core-native.js +148 -25
  76. package/dist/react-native/src/core-wire.d.ts +20 -3
  77. package/dist/rn-shared-build.json +8 -8
  78. package/dist/runtime/src/adapters.d.ts +8 -0
  79. package/dist/runtime/src/adapters.js +29 -0
  80. package/dist/runtime/src/agent.d.ts +53 -5
  81. package/dist/runtime/src/agent.js +69 -7
  82. package/dist/runtime/src/app-api.d.ts +307 -19
  83. package/dist/runtime/src/cancel.d.ts +2 -2
  84. package/dist/runtime/src/cancel.js +7 -4
  85. package/dist/runtime/src/core/foreground.d.ts +3 -0
  86. package/dist/runtime/src/core/foreground.js +40 -0
  87. package/dist/runtime/src/core/port.d.ts +48 -35
  88. package/dist/runtime/src/core/wasm-owner.d.ts +32 -0
  89. package/dist/runtime/src/core/wasm-owner.js +237 -0
  90. package/dist/runtime/src/croche.d.ts +64 -9
  91. package/dist/runtime/src/croche.js +78 -17
  92. package/dist/runtime/src/errors.d.ts +7 -0
  93. package/dist/runtime/src/errors.js +15 -1
  94. package/dist/runtime/src/generated/app-stream.d.ts +155 -1
  95. package/dist/runtime/src/generated/app-stream.js +7 -4
  96. package/dist/runtime/src/image-input.d.ts +5 -0
  97. package/dist/runtime/src/image-input.js +60 -0
  98. package/dist/runtime/src/index.d.ts +6 -0
  99. package/dist/runtime/src/index.js +5 -0
  100. package/dist/runtime/src/index.native.d.ts +1 -21
  101. package/dist/runtime/src/index.native.js +2 -8
  102. package/dist/runtime/src/native-adapter.d.ts +1 -1
  103. package/dist/runtime/src/native-adapter.js +10 -4
  104. package/dist/runtime/src/pal/host.d.ts +3 -3
  105. package/dist/runtime/src/pal/host.js +34 -9
  106. package/dist/runtime/src/pal/platform.d.ts +11 -6
  107. package/dist/runtime/src/pal/state-store-lock.d.ts +8 -0
  108. package/dist/runtime/src/pal/state-store-lock.js +2 -0
  109. package/dist/runtime/src/pal/state-store.d.ts +66 -0
  110. package/dist/runtime/src/pal/state-store.js +1 -0
  111. package/dist/runtime/src/pal/storage-version-contract.d.ts +19 -0
  112. package/dist/runtime/src/pal/storage-version-contract.js +68 -0
  113. package/dist/runtime/src/pal/transactional-storage.d.ts +3 -0
  114. package/dist/runtime/src/pal/transactional-storage.js +124 -0
  115. package/dist/runtime/src/tools.d.ts +20 -4
  116. package/dist/runtime/src/tools.js +31 -7
  117. package/ios/CoreAgentTransport.swift +2 -2
  118. package/ios/CoreNativePal.swift +26 -21
  119. package/ios/CorePlatformTransport.swift +4 -4
  120. package/ios/CoreWireDispatch.swift +38 -8
  121. package/ios/CoreWireSupport.swift +179 -4
  122. package/ios/CrocheRuntimeBridge.swift +1 -1
  123. package/ios/ProjectPal.swift +15 -12
  124. package/ios/vendor/CrocheRuntimeSDK/BlobFiles.swift +124 -0
  125. package/ios/vendor/CrocheRuntimeSDK/ContextConfig.swift +2 -6
  126. package/ios/vendor/CrocheRuntimeSDK/EncodedImages.swift +85 -0
  127. package/ios/vendor/CrocheRuntimeSDK/FFIStreamPort.swift +1 -174
  128. package/ios/vendor/CrocheRuntimeSDK/GeneratedAppStream.swift +233 -4
  129. package/ios/vendor/CrocheRuntimeSDK/Host.swift +1 -399
  130. package/ios/vendor/CrocheRuntimeSDK/ImagePal.swift +3 -3
  131. package/ios/vendor/CrocheRuntimeSDK/InstancePayloadPurge.swift +88 -0
  132. package/ios/vendor/CrocheRuntimeSDK/JSON.swift +26 -10
  133. package/ios/vendor/CrocheRuntimeSDK/OpenOptions.swift +0 -155
  134. package/ios/vendor/CrocheRuntimeSDK/Platform.swift +1 -27
  135. package/ios/vendor/CrocheRuntimeSDK/PlatformBackground.swift +8 -4
  136. package/ios/vendor/CrocheRuntimeSDK/PlatformPal.swift +57 -21
  137. package/ios/vendor/CrocheRuntimeSDK/PlatformStateStore.swift +253 -0
  138. package/ios/vendor/CrocheRuntimeSDK/PlatformStorage.swift +96 -10
  139. package/ios/vendor/CrocheRuntimeSDK/Project.swift +3 -382
  140. package/ios/vendor/CrocheRuntimeSDK/Runtime.swift +1 -412
  141. package/ios/vendor/CrocheRuntimeSDK/RuntimeHTTPAdapter.swift +42 -0
  142. package/ios/vendor/CrocheRuntimeSDK/S1/S1Adapters.swift +110 -0
  143. package/ios/vendor/CrocheRuntimeSDK/S1/S1Agent.swift +86 -33
  144. package/ios/vendor/CrocheRuntimeSDK/S1/S1Allowance.swift +20 -0
  145. package/ios/vendor/CrocheRuntimeSDK/S1/S1BindingFacts.swift +1 -1
  146. package/ios/vendor/CrocheRuntimeSDK/S1/S1Core.swift +12 -3
  147. package/ios/vendor/CrocheRuntimeSDK/S1/S1Croche.swift +135 -56
  148. package/ios/vendor/CrocheRuntimeSDK/S1/S1Decision.swift +146 -0
  149. package/ios/vendor/CrocheRuntimeSDK/S1/S1Events.swift +17 -8
  150. package/ios/vendor/CrocheRuntimeSDK/S1/S1HandleOwner.swift +58 -0
  151. package/ios/vendor/CrocheRuntimeSDK/S1/S1Options.swift +184 -15
  152. package/ios/vendor/CrocheRuntimeSDK/S1/S1RunTool.swift +31 -3
  153. package/ios/vendor/CrocheRuntimeSDK/S1/S1Storage.swift +131 -61
  154. package/ios/vendor/CrocheRuntimeSDK/S1/S1TestHooks.swift +10 -15
  155. package/ios/vendor/CrocheRuntimeSDK/S1/S1Tools.swift +86 -17
  156. package/ios/vendor/CrocheRuntimeSDK/S1/S1Verification.swift +27 -0
  157. package/ios/vendor/CrocheRuntimeSDK/S1/StateStoreContract.swift +189 -0
  158. package/ios/vendor/CrocheRuntimeSDK/S1/StorageVersionContract.swift +68 -0
  159. package/ios/vendor/CrocheRuntimeSDK/Storage.swift +3 -249
  160. package/ios/vendor/CrocheRuntimeSDK/SubscriptionTypes.swift +40 -8
  161. package/ios/vendor/CrocheRuntimeSDK/croche_ffi.swift +1720 -3883
  162. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64/Headers/croche_ffiFFI.h +816 -1649
  163. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64/libcroche_ffi.a +0 -0
  164. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64_x86_64-simulator/Headers/croche_ffiFFI.h +816 -1649
  165. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64_x86_64-simulator/libcroche_ffi.a +2 -2
  166. package/package.json +3 -3
  167. package/scripts/README.md +1 -1
  168. package/scripts/check-swift-vendor-modules.sh +15 -0
  169. package/scripts/vendor-native.sh +4 -3
  170. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/CrocheProjectRecordProvider.kt +0 -32
  171. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/WorkManagerScheduler.kt +0 -146
  172. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/AppStreamBranch.kt +0 -113
  173. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeCoreStreamPort.kt +0 -201
  174. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectPalRouting.kt +0 -25
  175. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectRecords.kt +0 -87
  176. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Storage.kt +0 -181
  177. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StoragePal.kt +0 -18
  178. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StreamHub.kt +0 -252
  179. package/dist/runtime/src/pal/codec.d.ts +0 -15
  180. package/dist/runtime/src/pal/codec.js +0 -52
  181. package/ios/vendor/CrocheRuntimeSDK/Background.swift +0 -59
  182. package/ios/vendor/CrocheRuntimeSDK/StreamHub.swift +0 -496
  183. package/ios/vendor/CrocheRuntimeSDK/SubscriptionRuntime.swift +0 -44
@@ -0,0 +1,90 @@
1
+ package dev.croche
2
+
3
+ /** Atomic state for an app. The condition and every write share one transaction. */
4
+ interface StateStore : Adapter {
5
+ /** Host adapter tag for state storage. */
6
+ override val kind: String get() = "state"
7
+ /** Read saved state so a user can continue where they left off. */
8
+ suspend fun get(key: String): StateValue?
9
+ /** Load just the relevant records so a long conversation still opens promptly. */
10
+ suspend fun list(prefix: String, options: StateListOptions = StateListOptions()): StatePage
11
+ /** Keep a saved reply and its related progress consistent if the app stops mid-write. */
12
+ suspend fun commit(ops: List<StateOp>, condition: StateCondition): StateCommitResult
13
+ }
14
+
15
+ /**
16
+ * Stored value together with the version used for a conditional commit.
17
+ *
18
+ * @property value String value returned for the key.
19
+ * @property version Opaque version for the observed value.
20
+ */
21
+ data class StateValue(val value: String, val version: String)
22
+
23
+ internal data class VersionedValue(val value: String?, val version: String?)
24
+ internal sealed interface WriteOutcome {
25
+ data class Written(val version: String?) : WriteOutcome
26
+ data class Conflict(val version: String?) : WriteOutcome
27
+ }
28
+
29
+
30
+ /** One put or delete in a conditional state batch. */
31
+ sealed interface StateOp {
32
+ /** Full key addressed by this operation. */
33
+ val key: String
34
+ /**
35
+ * Write a value at a key in the store.
36
+ *
37
+ * @property key Full key to write.
38
+ * @property value String value to save.
39
+ */
40
+ data class Put(override val key: String, val value: String) : StateOp
41
+ /**
42
+ * Remove a key from the store.
43
+ *
44
+ * @property key Full key to remove.
45
+ */
46
+ data class Delete(override val key: String) : StateOp
47
+ }
48
+ /**
49
+ * Version check that guards an atomic state commit.
50
+ *
51
+ * @property key Key checked before committing the batch.
52
+ * @property version Expected version, or null to require the key to be absent.
53
+ */
54
+ data class StateCondition(val key: String, val version: String?)
55
+ /** Outcome of comparing a state version and applying a write batch. */
56
+ sealed interface StateCommitResult {
57
+ /**
58
+ * The condition matched and the batch was applied.
59
+ *
60
+ * @property version Version of the condition key after the batch, or null if it is absent.
61
+ */
62
+ data class Committed(val version: String?) : StateCommitResult
63
+ /** The condition did not match. The batch made no writes. */
64
+ data object Conflict : StateCommitResult
65
+ }
66
+ /** Bounds and continuation for a StateStore prefix read. */
67
+ data class StateListOptions(
68
+ /** Inclusive lower bound on full keys within the prefix. */
69
+ val start: String? = null,
70
+ /** Use descending UTF-8 key order. The start bound is still a lower bound. */
71
+ val reverse: Boolean = false,
72
+ /** Positive page limit up to 128. Null uses the default of 128. */
73
+ val limit: UInt? = null,
74
+ /** Opaque continuation from a page for the same prefix, start and direction. */
75
+ val cursor: String? = null,
76
+ )
77
+ /**
78
+ * Key and value returned by a state range read.
79
+ *
80
+ * @property key Full stored key.
81
+ * @property value String value associated with this key.
82
+ */
83
+ data class StateEntry(val key: String, val value: String)
84
+ /**
85
+ * One bounded page of stored entries.
86
+ *
87
+ * @property entries Entries in the order requested for the range.
88
+ * @property nextCursor Opaque continuation if another page is available. A short page may still have a cursor.
89
+ */
90
+ data class StatePage(val entries: List<StateEntry>, val nextCursor: String? = null)
@@ -6,33 +6,96 @@ import java.time.Instant
6
6
 
7
7
  /** Ordered request elements; normalization and admission belong to Core. */
8
8
  sealed interface SendElement
9
- /** [kind] is the generated reader value Core also reports on `input` events; null = Core's default (user). */
9
+ /**
10
+ * Text supplied to the agent. Null [kind] means user input.
11
+ *
12
+ * @property kind Input source sent to Core. Null uses user input.
13
+ * @property text Text supplied to the agent.
14
+ */
10
15
  data class TextInput(val text: String, val kind: AppStreamContract.InputKind? = null) : SendElement
11
- /** One image element, supplied by URI or encoded bytes. */
16
+ /**
17
+ * One image element, supplied by URI or encoded bytes.
18
+ *
19
+ * @property alt Optional description supplied with the image.
20
+ */
12
21
  class ImageInput private constructor(internal val uri: String?, internal val image: ByteArray?,
13
22
  val alt: String?) : SendElement {
23
+ /** Create an image element from a URI and optional description. */
14
24
  constructor(uri: String, alt: String? = null) : this(uri, null, alt)
25
+ /** Create an image element from a private copy of encoded bytes and an optional description. */
15
26
  constructor(image: ByteArray, alt: String? = null) : this(null, image.copyOf(), alt)
16
27
  internal fun owned(): ImageInput = uri?.let { ImageInput(it, alt) } ?: ImageInput(image!!, alt)
17
28
  }
29
+ /**
30
+ * An ordered group of elements submitted together to the agent.
31
+ *
32
+ * @property id Optional app-supplied input identifier used to correlate stream events.
33
+ * @property input Text and image elements in input order.
34
+ */
18
35
  data class SendInput(val id: String? = null, val input: List<SendElement>)
36
+ /**
37
+ * Response options that accompany an accepted send.
38
+ *
39
+ * @property responseFormat Optional format supplied to Core for structured output.
40
+ */
19
41
  data class SendOptions(val responseFormat: JsonObject? = null)
20
42
  internal data class Receipt(val requestId: String, val status: InputStatus, val seq: Long?)
21
43
  // OPEN(§18.24.D): No pending field until Atlas approves the consuming-unit contract.
22
- enum class RequestWait { IDLE }
44
+ /** Extra condition the request waits for after input completion. */
45
+ enum class RequestWait {
46
+ /** Wait until the agent is idle as well as the input being terminal. */
47
+ IDLE
48
+ }
23
49
  internal data class LegacyRequestResult(val id: String, val status: InputStatus, val messages: List<RuntimeEvent.MessageEnd>,
24
50
  val gap: Boolean, val legacy: Boolean)
51
+ /**
52
+ * Resume coordinate for an agent subscription.
53
+ *
54
+ * @property logId Identifies the stream log the sequence belongs to.
55
+ * @property seq Last stream sequence the app has seen.
56
+ */
25
57
  data class Cursor(val logId: String, val seq: Long)
26
58
  internal data class RuntimeError(val code: String, val message: String)
59
+ /**
60
+ * Streaming reply preview used in the runtime event view.
61
+ *
62
+ * @property firstSeq First stream sequence assigned to the reply.
63
+ * @property messageId Identifier of the reply in progress.
64
+ * @property text Text accumulated so far for this reply.
65
+ */
27
66
  data class Streaming(val messageId: String, val firstSeq: Long, val text: String)
67
+ /**
68
+ * Metadata about an input image, without the image contents.
69
+ *
70
+ * @property alt Alternative text, when supplied.
71
+ * @property bytes Encoded size in bytes, when available.
72
+ * @property mime Media type, when available.
73
+ */
28
74
  data class ImageSummary(val alt: String?, val mime: String?, val bytes: Long?)
75
+ /**
76
+ * Tool command and call identity associated with an app event.
77
+ *
78
+ * @property callId Tool call ID recorded for the event.
79
+ * @property command Command recorded as the event source.
80
+ */
29
81
  data class ToolSource(val command: String, val callId: String)
30
82
 
31
- enum class ImageMime { PNG, JPEG, WEBP, GIF }
83
+ /** Supported MIME choices for encoded tool-result image bytes. */
84
+ enum class ImageMime {
85
+ /** Encodes the media type image/png. */
86
+ PNG,
87
+ /** Encodes the media type image/jpeg. */
88
+ JPEG,
89
+ /** Encodes the media type image/webp. */
90
+ WEBP,
91
+ /** Encodes the media type image/gif. */
92
+ GIF
93
+ }
32
94
 
33
95
  /** Tool-result image attachment. Send requests use ImageInput. */
34
96
  class InputImage {
35
97
  internal val json: JsonObject
98
+ /** Create a tool-result image from encoded bytes and the given media type. */
36
99
  constructor(data: ByteArray, mime: ImageMime, alt: String? = null, resolution: ImageResolution? = null) {
37
100
  json = JsonObject().apply {
38
101
  addProperty("data", java.util.Base64.getEncoder().encodeToString(data))
@@ -41,6 +104,7 @@ class InputImage {
41
104
  resolution?.let { addProperty("resolution", it.name.lowercase()) }
42
105
  }
43
106
  }
107
+ /** Create a tool-result image that refers to a URL. */
44
108
  constructor(url: String, alt: String? = null) {
45
109
  json = JsonObject().apply { addProperty("url", url); alt?.let { addProperty("alt", it) } }
46
110
  }