@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.
- package/LICENSE +1 -1
- package/README.md +32 -4
- package/THIRD-PARTY-NOTICES +899 -6
- package/android/src/androidTest/java/dev/croche/reactnative/WikiFileBridgeTest.kt +4 -3
- package/android/src/main/AndroidManifest.xml +0 -5
- package/android/src/main/java/dev/croche/reactnative/CoreDispatch.kt +33 -8
- package/android/src/main/java/dev/croche/reactnative/CoreWire.kt +139 -5
- package/android/src/main/java/dev/croche/reactnative/CrocheRuntimeModule.kt +5 -2
- package/android/src/main/java/dev/croche/reactnative/NativePal.kt +23 -6
- package/android/src/test/java/dev/croche/reactnative/AgentMemoryTest.kt +28 -6
- package/android/src/test/java/dev/croche/reactnative/BackgroundDelegationTest.kt +4 -11
- package/android/src/test/java/dev/croche/reactnative/BlobFilesTest.kt +107 -0
- package/android/src/test/java/dev/croche/reactnative/ImageAdapterWireTest.kt +70 -0
- package/android/src/test/java/dev/croche/reactnative/OpenForwardingFixture.kt +19 -4
- package/android/src/test/java/dev/croche/reactnative/ProjectAttestationTest.kt +2 -2
- package/android/src/test/java/dev/croche/reactnative/StorageVersionWireTest.kt +37 -0
- package/android/src/test/java/dev/croche/reactnative/VerificationDispatchTest.kt +24 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/AndroidPlatform.kt +5 -3
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BackgroundWakeWorker.kt +4 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapDecodedImageCodec.kt +11 -11
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapImageCodec.kt +1 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidCoreHost.kt +11 -16
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidPublicPlatform.kt +3 -3
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidStateStore.kt +216 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidStoragePal.kt +45 -10
- package/android/vendor/CrocheRuntimeSDK/consumer-rules.pro +0 -3
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Adapters.kt +75 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/BindingFacts.kt +1 -1
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ContextConfig.kt +9 -23
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Core.kt +11 -2
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Croche.kt +83 -20
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheAgent.kt +54 -8
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheRuntime.kt +19 -360
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheTools.kt +79 -10
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Decision.kt +170 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/DecodedImageCodec.kt +8 -5
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Effects.kt +8 -1
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/EncodedImageCodec.kt +51 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/GeneratedAppStream.kt +426 -33
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Host.kt +1 -351
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Images.kt +15 -29
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeEvent.kt +59 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeHandleOwner.kt +118 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Platform.kt +10 -74
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectTypes.kt +196 -10
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/PublicResults.kt +86 -3
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/RunTool.kt +33 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/SendEncoding.kt +1 -1
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StateStore.kt +90 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/SubscriptionTypes.kt +68 -4
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ffi/croche_ffi.kt +3403 -6894
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/AppStoragePal.kt +89 -18
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreFactoryCalls.kt +1 -2
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreOptionsEncoding.kt +2 -2
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreStreamCalls.kt +3 -3
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ForeignCallbacks.kt +17 -18
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ImageAdapterHost.kt +28 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmCoreHost.kt +12 -14
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmStateStore.kt +125 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmStoragePal.kt +36 -6
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/NativeCoreInitialization.kt +21 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/NativePlatform.kt +21 -6
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/PublicCalls.kt +16 -7
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/StateStoreContract.kt +103 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/StorageVersionContract.kt +40 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/AtomicKeyFiles.kt +25 -4
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/BlobFiles.kt +157 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/InstancePayloadPurge.kt +79 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/VersionedKeyFiles.kt +71 -0
- package/android/vendor/jniLibs/arm64-v8a/libcroche_ffi.so +0 -0
- package/android/vendor/jniLibs/armeabi-v7a/libcroche_ffi.so +0 -0
- package/android/vendor/jniLibs/x86_64/libcroche_ffi.so +0 -0
- package/croche-react-native.podspec +1 -0
- package/dist/react-native/src/core-native.d.ts +3 -0
- package/dist/react-native/src/core-native.js +148 -25
- package/dist/react-native/src/core-wire.d.ts +20 -3
- package/dist/rn-shared-build.json +8 -8
- package/dist/runtime/src/adapters.d.ts +8 -0
- package/dist/runtime/src/adapters.js +29 -0
- package/dist/runtime/src/agent.d.ts +53 -5
- package/dist/runtime/src/agent.js +69 -7
- package/dist/runtime/src/app-api.d.ts +307 -19
- package/dist/runtime/src/cancel.d.ts +2 -2
- package/dist/runtime/src/cancel.js +7 -4
- package/dist/runtime/src/core/foreground.d.ts +3 -0
- package/dist/runtime/src/core/foreground.js +40 -0
- package/dist/runtime/src/core/port.d.ts +48 -35
- package/dist/runtime/src/core/wasm-owner.d.ts +32 -0
- package/dist/runtime/src/core/wasm-owner.js +237 -0
- package/dist/runtime/src/croche.d.ts +64 -9
- package/dist/runtime/src/croche.js +78 -17
- package/dist/runtime/src/errors.d.ts +7 -0
- package/dist/runtime/src/errors.js +15 -1
- package/dist/runtime/src/generated/app-stream.d.ts +155 -1
- package/dist/runtime/src/generated/app-stream.js +7 -4
- package/dist/runtime/src/image-input.d.ts +5 -0
- package/dist/runtime/src/image-input.js +60 -0
- package/dist/runtime/src/index.d.ts +6 -0
- package/dist/runtime/src/index.js +5 -0
- package/dist/runtime/src/index.native.d.ts +1 -21
- package/dist/runtime/src/index.native.js +2 -8
- package/dist/runtime/src/native-adapter.d.ts +1 -1
- package/dist/runtime/src/native-adapter.js +10 -4
- package/dist/runtime/src/pal/host.d.ts +3 -3
- package/dist/runtime/src/pal/host.js +34 -9
- package/dist/runtime/src/pal/platform.d.ts +11 -6
- package/dist/runtime/src/pal/state-store-lock.d.ts +8 -0
- package/dist/runtime/src/pal/state-store-lock.js +2 -0
- package/dist/runtime/src/pal/state-store.d.ts +66 -0
- package/dist/runtime/src/pal/state-store.js +1 -0
- package/dist/runtime/src/pal/storage-version-contract.d.ts +19 -0
- package/dist/runtime/src/pal/storage-version-contract.js +68 -0
- package/dist/runtime/src/pal/transactional-storage.d.ts +3 -0
- package/dist/runtime/src/pal/transactional-storage.js +124 -0
- package/dist/runtime/src/tools.d.ts +20 -4
- package/dist/runtime/src/tools.js +31 -7
- package/ios/CoreAgentTransport.swift +2 -2
- package/ios/CoreNativePal.swift +26 -21
- package/ios/CorePlatformTransport.swift +4 -4
- package/ios/CoreWireDispatch.swift +38 -8
- package/ios/CoreWireSupport.swift +179 -4
- package/ios/CrocheRuntimeBridge.swift +1 -1
- package/ios/ProjectPal.swift +15 -12
- package/ios/vendor/CrocheRuntimeSDK/BlobFiles.swift +124 -0
- package/ios/vendor/CrocheRuntimeSDK/ContextConfig.swift +2 -6
- package/ios/vendor/CrocheRuntimeSDK/EncodedImages.swift +85 -0
- package/ios/vendor/CrocheRuntimeSDK/FFIStreamPort.swift +1 -174
- package/ios/vendor/CrocheRuntimeSDK/GeneratedAppStream.swift +233 -4
- package/ios/vendor/CrocheRuntimeSDK/Host.swift +1 -399
- package/ios/vendor/CrocheRuntimeSDK/ImagePal.swift +3 -3
- package/ios/vendor/CrocheRuntimeSDK/InstancePayloadPurge.swift +88 -0
- package/ios/vendor/CrocheRuntimeSDK/JSON.swift +26 -10
- package/ios/vendor/CrocheRuntimeSDK/OpenOptions.swift +0 -155
- package/ios/vendor/CrocheRuntimeSDK/Platform.swift +1 -27
- package/ios/vendor/CrocheRuntimeSDK/PlatformBackground.swift +8 -4
- package/ios/vendor/CrocheRuntimeSDK/PlatformPal.swift +57 -21
- package/ios/vendor/CrocheRuntimeSDK/PlatformStateStore.swift +253 -0
- package/ios/vendor/CrocheRuntimeSDK/PlatformStorage.swift +96 -10
- package/ios/vendor/CrocheRuntimeSDK/Project.swift +3 -382
- package/ios/vendor/CrocheRuntimeSDK/Runtime.swift +1 -412
- package/ios/vendor/CrocheRuntimeSDK/RuntimeHTTPAdapter.swift +42 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Adapters.swift +110 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Agent.swift +86 -33
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Allowance.swift +20 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1BindingFacts.swift +1 -1
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Core.swift +12 -3
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Croche.swift +135 -56
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Decision.swift +146 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Events.swift +17 -8
- package/ios/vendor/CrocheRuntimeSDK/S1/S1HandleOwner.swift +58 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Options.swift +184 -15
- package/ios/vendor/CrocheRuntimeSDK/S1/S1RunTool.swift +31 -3
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Storage.swift +131 -61
- package/ios/vendor/CrocheRuntimeSDK/S1/S1TestHooks.swift +10 -15
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Tools.swift +86 -17
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Verification.swift +27 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/StateStoreContract.swift +189 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/StorageVersionContract.swift +68 -0
- package/ios/vendor/CrocheRuntimeSDK/Storage.swift +3 -249
- package/ios/vendor/CrocheRuntimeSDK/SubscriptionTypes.swift +40 -8
- package/ios/vendor/CrocheRuntimeSDK/croche_ffi.swift +1720 -3883
- package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64/Headers/croche_ffiFFI.h +816 -1649
- package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64/libcroche_ffi.a +0 -0
- package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64_x86_64-simulator/Headers/croche_ffiFFI.h +816 -1649
- package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64_x86_64-simulator/libcroche_ffi.a +2 -2
- package/package.json +3 -3
- package/scripts/README.md +1 -1
- package/scripts/check-swift-vendor-modules.sh +15 -0
- package/scripts/vendor-native.sh +4 -3
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/CrocheProjectRecordProvider.kt +0 -32
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/WorkManagerScheduler.kt +0 -146
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/AppStreamBranch.kt +0 -113
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeCoreStreamPort.kt +0 -201
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectPalRouting.kt +0 -25
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectRecords.kt +0 -87
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Storage.kt +0 -181
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StoragePal.kt +0 -18
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StreamHub.kt +0 -252
- package/dist/runtime/src/pal/codec.d.ts +0 -15
- package/dist/runtime/src/pal/codec.js +0 -52
- package/ios/vendor/CrocheRuntimeSDK/Background.swift +0 -59
- package/ios/vendor/CrocheRuntimeSDK/StreamHub.swift +0 -496
- package/ios/vendor/CrocheRuntimeSDK/SubscriptionRuntime.swift +0 -44
|
@@ -5,207 +5,583 @@ import com.google.gson.*
|
|
|
5
5
|
import com.google.gson.annotations.JsonAdapter
|
|
6
6
|
import com.google.gson.stream.*
|
|
7
7
|
|
|
8
|
+
/** The app-stream reader types, generated from Core's Rust contract, and their decoder. */
|
|
8
9
|
object AppStreamContract {
|
|
10
|
+
/** Status of an accepted input: `queued` or `seen`, then one terminal status. */
|
|
9
11
|
sealed interface InputDisposition {
|
|
12
|
+
/** The wire string for this value. */
|
|
10
13
|
val rawValue: String
|
|
11
|
-
|
|
12
|
-
object
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
/** Accepted and waiting for a turn. */
|
|
15
|
+
object QUEUED: InputDisposition {
|
|
16
|
+
/** The wire string for this value. */
|
|
17
|
+
override val rawValue = "queued"
|
|
18
|
+
}
|
|
19
|
+
/** Taken up by a turn for the agent to work on. */
|
|
20
|
+
object SEEN: InputDisposition {
|
|
21
|
+
/** The wire string for this value. */
|
|
22
|
+
override val rawValue = "seen"
|
|
23
|
+
}
|
|
24
|
+
/** A completed reply answered the input. */
|
|
25
|
+
object ANSWERED: InputDisposition {
|
|
26
|
+
/** The wire string for this value. */
|
|
27
|
+
override val rawValue = "answered"
|
|
28
|
+
}
|
|
29
|
+
/** The work finished without a reply answering the input. */
|
|
30
|
+
object NO_REPLY: InputDisposition {
|
|
31
|
+
/** The wire string for this value. */
|
|
32
|
+
override val rawValue = "no_reply"
|
|
33
|
+
}
|
|
34
|
+
/** The input failed; its error says why. */
|
|
35
|
+
object FAILED: InputDisposition {
|
|
36
|
+
/** The wire string for this value. */
|
|
37
|
+
override val rawValue = "failed"
|
|
38
|
+
}
|
|
39
|
+
/** The input was cancelled. */
|
|
40
|
+
object CANCELLED: InputDisposition {
|
|
41
|
+
/** The wire string for this value. */
|
|
42
|
+
override val rawValue = "cancelled"
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A wire value this SDK does not recognize.
|
|
46
|
+
*
|
|
47
|
+
* @property type The original wire string.
|
|
48
|
+
* @property fields The original wire value as JSON.
|
|
49
|
+
*/
|
|
50
|
+
data class Unknown(val type: String, val fields: JsonElement): InputDisposition {
|
|
51
|
+
/** The wire string for this value. */
|
|
52
|
+
override val rawValue = type
|
|
53
|
+
}
|
|
18
54
|
}
|
|
55
|
+
/** Kind of an input's parts. */
|
|
19
56
|
sealed interface InputKind {
|
|
57
|
+
/** The wire string for this value. */
|
|
20
58
|
val rawValue: String
|
|
21
|
-
|
|
22
|
-
object
|
|
23
|
-
|
|
24
|
-
|
|
59
|
+
/** Text from the person using the app. */
|
|
60
|
+
object USER: InputKind {
|
|
61
|
+
/** The wire string for this value. */
|
|
62
|
+
override val rawValue = "user"
|
|
63
|
+
}
|
|
64
|
+
/** An event the app reported. */
|
|
65
|
+
object APP_EVENT: InputKind {
|
|
66
|
+
/** The wire string for this value. */
|
|
67
|
+
override val rawValue = "app_event"
|
|
68
|
+
}
|
|
69
|
+
/** Opaque app state text. */
|
|
70
|
+
object APP_STATE: InputKind {
|
|
71
|
+
/** The wire string for this value. */
|
|
72
|
+
override val rawValue = "app_state"
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A wire value this SDK does not recognize.
|
|
76
|
+
*
|
|
77
|
+
* @property type The original wire string.
|
|
78
|
+
* @property fields The original wire value as JSON.
|
|
79
|
+
*/
|
|
80
|
+
data class Unknown(val type: String, val fields: JsonElement): InputKind {
|
|
81
|
+
/** The wire string for this value. */
|
|
82
|
+
override val rawValue = type
|
|
83
|
+
}
|
|
25
84
|
}
|
|
85
|
+
/** How an agent reply ended. */
|
|
26
86
|
sealed interface MessageStatus {
|
|
87
|
+
/** The wire string for this value. */
|
|
27
88
|
val rawValue: String
|
|
28
|
-
|
|
29
|
-
object
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
89
|
+
/** The reply finished and answers its open inputs. */
|
|
90
|
+
object COMPLETED: MessageStatus {
|
|
91
|
+
/** The wire string for this value. */
|
|
92
|
+
override val rawValue = "completed"
|
|
93
|
+
}
|
|
94
|
+
/** The reply ended because its call or turn failed. */
|
|
95
|
+
object FAILED: MessageStatus {
|
|
96
|
+
/** The wire string for this value. */
|
|
97
|
+
override val rawValue = "failed"
|
|
98
|
+
}
|
|
99
|
+
/** The reply ended because its work was cancelled. */
|
|
100
|
+
object CANCELLED: MessageStatus {
|
|
101
|
+
/** The wire string for this value. */
|
|
102
|
+
override val rawValue = "cancelled"
|
|
103
|
+
}
|
|
104
|
+
/** The process stopped during the reply. */
|
|
105
|
+
object INTERRUPTED: MessageStatus {
|
|
106
|
+
/** The wire string for this value. */
|
|
107
|
+
override val rawValue = "interrupted"
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A wire value this SDK does not recognize.
|
|
111
|
+
*
|
|
112
|
+
* @property type The original wire string.
|
|
113
|
+
* @property fields The original wire value as JSON.
|
|
114
|
+
*/
|
|
115
|
+
data class Unknown(val type: String, val fields: JsonElement): MessageStatus {
|
|
116
|
+
/** The wire string for this value. */
|
|
117
|
+
override val rawValue = type
|
|
118
|
+
}
|
|
33
119
|
}
|
|
120
|
+
/** Whether the agent has work. */
|
|
34
121
|
sealed interface AgentStatus {
|
|
122
|
+
/** The wire string for this value. */
|
|
35
123
|
val rawValue: String
|
|
36
|
-
|
|
37
|
-
object
|
|
38
|
-
|
|
39
|
-
|
|
124
|
+
/** Nothing to do and nothing to receive. */
|
|
125
|
+
object IDLE: AgentStatus {
|
|
126
|
+
/** The wire string for this value. */
|
|
127
|
+
override val rawValue = "idle"
|
|
128
|
+
}
|
|
129
|
+
/** A turn runs, an accepted input is queued, or a tool result waits to continue the turn. */
|
|
130
|
+
object RUNNING: AgentStatus {
|
|
131
|
+
/** The wire string for this value. */
|
|
132
|
+
override val rawValue = "running"
|
|
133
|
+
}
|
|
134
|
+
/** Nothing to do, but a late tool result is still to arrive. */
|
|
135
|
+
object WAITING: AgentStatus {
|
|
136
|
+
/** The wire string for this value. */
|
|
137
|
+
override val rawValue = "waiting"
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A wire value this SDK does not recognize.
|
|
141
|
+
*
|
|
142
|
+
* @property type The original wire string.
|
|
143
|
+
* @property fields The original wire value as JSON.
|
|
144
|
+
*/
|
|
145
|
+
data class Unknown(val type: String, val fields: JsonElement): AgentStatus {
|
|
146
|
+
/** The wire string for this value. */
|
|
147
|
+
override val rawValue = type
|
|
148
|
+
}
|
|
40
149
|
}
|
|
150
|
+
/** Why a model call other than an ordinary reply call was made. */
|
|
41
151
|
sealed interface TurnPurpose {
|
|
152
|
+
/** The wire string for this value. */
|
|
42
153
|
val rawValue: String
|
|
43
|
-
|
|
44
|
-
|
|
154
|
+
/** The call made a context summary. */
|
|
155
|
+
object SUMMARY: TurnPurpose {
|
|
156
|
+
/** The wire string for this value. */
|
|
157
|
+
override val rawValue = "summary"
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* A wire value this SDK does not recognize.
|
|
161
|
+
*
|
|
162
|
+
* @property type The original wire string.
|
|
163
|
+
* @property fields The original wire value as JSON.
|
|
164
|
+
*/
|
|
165
|
+
data class Unknown(val type: String, val fields: JsonElement): TurnPurpose {
|
|
166
|
+
/** The wire string for this value. */
|
|
167
|
+
override val rawValue = type
|
|
168
|
+
}
|
|
45
169
|
}
|
|
170
|
+
/** A memory operation the app can make. */
|
|
46
171
|
sealed interface MemoryOp {
|
|
172
|
+
/** The wire string for this value. */
|
|
47
173
|
val rawValue: String
|
|
48
|
-
|
|
49
|
-
object
|
|
50
|
-
|
|
51
|
-
|
|
174
|
+
/** One memory fact was deleted. */
|
|
175
|
+
object DELETE: MemoryOp {
|
|
176
|
+
/** The wire string for this value. */
|
|
177
|
+
override val rawValue = "delete"
|
|
178
|
+
}
|
|
179
|
+
/** All memory facts were deleted. */
|
|
180
|
+
object CLEAR: MemoryOp {
|
|
181
|
+
/** The wire string for this value. */
|
|
182
|
+
override val rawValue = "clear"
|
|
183
|
+
}
|
|
184
|
+
/** Memory was turned on or off. */
|
|
185
|
+
object ENABLED: MemoryOp {
|
|
186
|
+
/** The wire string for this value. */
|
|
187
|
+
override val rawValue = "enabled"
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* A wire value this SDK does not recognize.
|
|
191
|
+
*
|
|
192
|
+
* @property type The original wire string.
|
|
193
|
+
* @property fields The original wire value as JSON.
|
|
194
|
+
*/
|
|
195
|
+
data class Unknown(val type: String, val fields: JsonElement): MemoryOp {
|
|
196
|
+
/** The wire string for this value. */
|
|
197
|
+
override val rawValue = type
|
|
198
|
+
}
|
|
52
199
|
}
|
|
200
|
+
/** Metadata of a stored image original that Core keeps for the app, a message or a tool call. */
|
|
53
201
|
data class Attachment(
|
|
202
|
+
/** Core-assigned attachment id, used to read, copy, release or delete the original. */
|
|
54
203
|
val id: String,
|
|
204
|
+
/** What the attachment is; Core currently stores only `image` (open string). */
|
|
55
205
|
val kind: String,
|
|
206
|
+
/** Where the stored original came from, for example `tool` (produced by a tool call) or `app` (copied in by the app). */
|
|
56
207
|
val origin: String,
|
|
208
|
+
/** Image media type of the stored original, for example `image/png`. */
|
|
57
209
|
val mediaType: String,
|
|
210
|
+
/** Size of the stored original in bytes. */
|
|
58
211
|
val bytes: Long,
|
|
212
|
+
/** Lowercase hex SHA-256 of the stored original's bytes. */
|
|
59
213
|
val sha256: String,
|
|
214
|
+
/** The original's pixel width, when Core reports it; absent otherwise. */
|
|
60
215
|
val width: Long? = null,
|
|
216
|
+
/** The original's pixel height, when Core reports it; absent otherwise. */
|
|
61
217
|
val height: Long? = null,
|
|
218
|
+
/** Description text supplied with the image; absent when none was given. */
|
|
62
219
|
val alt: String? = null,
|
|
220
|
+
/** Id of the agent tool call that produced the original (the same id as `ToolEvent.id`); absent for originals not produced by a call. */
|
|
63
221
|
val callId: String? = null,
|
|
222
|
+
/** Present only as `true` when the original is no longer stored at read time; the logged row itself is not changed. */
|
|
64
223
|
val deleted: Boolean? = null,
|
|
224
|
+
/** Why the original is gone: `deleted` (explicitly deleted or missing), `evicted` (removed to make room or past retention) or `cleared` (released by a history clear); present only with `deleted`. */
|
|
65
225
|
val deletedReason: String? = null
|
|
66
226
|
)
|
|
227
|
+
/** An error carried by an event or result, with the category that tells the app how to react. */
|
|
67
228
|
data class EventError(
|
|
229
|
+
/** Error code, for example `store_full` or `interrupted`; a code outside the known table has category `internal`. */
|
|
68
230
|
val code: String,
|
|
231
|
+
/** What the app does about the error. */
|
|
69
232
|
val category: ErrorCategory,
|
|
233
|
+
/** Human-readable explanation of the error. */
|
|
70
234
|
val message: String,
|
|
71
235
|
/** Integer seconds, present only on the hourly app-paid rate_limited refusal. */
|
|
72
236
|
val retryAfter: Long? = null
|
|
73
237
|
)
|
|
238
|
+
/** An image that could not be viewed for one model call; the call continues with the image's id and description. */
|
|
239
|
+
data class ViewError(
|
|
240
|
+
/** Id of the attachment whose view failed. */
|
|
241
|
+
val attachmentId: String,
|
|
242
|
+
/** Error code for the failed view, for example `image_unsupported`. */
|
|
243
|
+
val code: String,
|
|
244
|
+
/** What the app does about the error. */
|
|
245
|
+
val category: ErrorCategory,
|
|
246
|
+
/** Human-readable explanation of why the view failed. */
|
|
247
|
+
val message: String
|
|
248
|
+
)
|
|
249
|
+
/** Returned when Core accepts a send: the input's id, its status at acceptance and where its events start in the stream. */
|
|
74
250
|
@ConsistentCopyVisibility
|
|
75
251
|
data class SendReceipt internal constructor(
|
|
252
|
+
/** Id of the accepted input. */
|
|
76
253
|
val requestId: String,
|
|
254
|
+
/** The input's status when the receipt was made; `queued` for a newly accepted input, or the recorded status when the same id was sent again. */
|
|
77
255
|
val status: InputDisposition,
|
|
256
|
+
/** Stream sequence of the input's first event, or for a just-accepted input the position its events start from. */
|
|
78
257
|
val seq: Long,
|
|
258
|
+
/** Why the input failed; present when `status` is `failed`. */
|
|
79
259
|
val error: EventError? = null
|
|
80
260
|
)
|
|
261
|
+
/** The terminal result of an accepted `request`: the input's final status and the replies it caused. */
|
|
81
262
|
@ConsistentCopyVisibility
|
|
82
263
|
data class RequestResult internal constructor(
|
|
264
|
+
/** Id of the input this result is for. */
|
|
83
265
|
val id: String,
|
|
266
|
+
/** The input's terminal status. */
|
|
84
267
|
val status: InputDisposition,
|
|
268
|
+
/** The retained `message.end` events whose `causedBy` includes this input. */
|
|
85
269
|
val messages: List<MessageEnd>,
|
|
270
|
+
/** Present only as `true` when some of this input's events were already pruned, so `messages` can be incomplete or empty. */
|
|
86
271
|
val gap: Boolean? = null,
|
|
272
|
+
/** Why the input failed; always present when `status` is `failed`. */
|
|
87
273
|
val error: EventError? = null
|
|
88
274
|
)
|
|
275
|
+
/** An input was accepted or its status changed; each change re-emits the input's full current state. */
|
|
89
276
|
data class InputEvent(
|
|
277
|
+
/** Id of the input. */
|
|
90
278
|
val id: String,
|
|
279
|
+
/** Stream sequence of this event. */
|
|
91
280
|
val seq: Long,
|
|
281
|
+
/** Stream sequence of this input's first event; the same on every update of the input. */
|
|
92
282
|
val firstSeq: Long,
|
|
283
|
+
/** Which kind of input parts this row shows. */
|
|
93
284
|
val kind: InputKind,
|
|
285
|
+
/** The input's status after this change. */
|
|
94
286
|
val status: InputDisposition,
|
|
287
|
+
/** ISO 8601 time of this change. */
|
|
95
288
|
val at: String,
|
|
289
|
+
/** Text of the input's parts of this `kind`, joined with blank lines; absent when Core holds no summary for the input. */
|
|
96
290
|
val text: String? = null,
|
|
291
|
+
/** Why the input failed; always present when `status` is `failed` and absent otherwise. */
|
|
97
292
|
val error: EventError? = null
|
|
98
293
|
)
|
|
294
|
+
/** A held send left without running; Core emits it after reopen for a send that was held when the app stopped. */
|
|
295
|
+
data class InputDropped(
|
|
296
|
+
/** Id of the dropped input. */
|
|
297
|
+
val inputId: String,
|
|
298
|
+
/** Why the input was dropped; Core's stream emits `reopened` (open string). */
|
|
299
|
+
val reason: String,
|
|
300
|
+
/** Stream sequence of this event. */
|
|
301
|
+
val seq: Long,
|
|
302
|
+
/** Stream sequence of the input's first event when it had one, otherwise this event's own sequence. */
|
|
303
|
+
val firstSeq: Long
|
|
304
|
+
)
|
|
305
|
+
/** An agent reply began; Core emits it when the reply has its first visible text, before any of its deltas. */
|
|
99
306
|
data class MessageStart(
|
|
307
|
+
/** Id of the reply message, shared by its start, deltas and end. */
|
|
100
308
|
val id: String,
|
|
309
|
+
/** Stream sequence of this event. */
|
|
101
310
|
val seq: Long,
|
|
311
|
+
/** Stream sequence of the message's first event, which is this start. */
|
|
102
312
|
val firstSeq: Long,
|
|
313
|
+
/** ISO 8601 time the reply started. */
|
|
103
314
|
val at: String
|
|
104
315
|
)
|
|
316
|
+
/** New text of the open reply as it is written; a preview only, since `message.end` carries the stored text. */
|
|
105
317
|
data class MessageDelta(
|
|
318
|
+
/** Id of the open reply message. */
|
|
106
319
|
val id: String,
|
|
320
|
+
/** Text added to the reply since the previous delta. */
|
|
107
321
|
val text: String
|
|
108
322
|
)
|
|
323
|
+
/** The end of an agent reply with its stored text and final status; never rewritten. */
|
|
109
324
|
data class MessageEnd(
|
|
325
|
+
/** Id of the reply message. */
|
|
110
326
|
val id: String,
|
|
327
|
+
/** Stream sequence of this event. */
|
|
111
328
|
val seq: Long,
|
|
329
|
+
/** Stream sequence of the message's first event (its `message.start`). */
|
|
112
330
|
val firstSeq: Long,
|
|
331
|
+
/** ISO 8601 time the reply ended. */
|
|
113
332
|
val at: String,
|
|
333
|
+
/** How the reply ended. */
|
|
114
334
|
val status: MessageStatus,
|
|
335
|
+
/** The stored reply text with markers removed; empty after an interruption or when the reply was too large to store. */
|
|
115
336
|
val text: String,
|
|
337
|
+
/** Names of the registered markers found in the reply, in reply order. */
|
|
116
338
|
val markers: List<String>,
|
|
339
|
+
/** Ids of the inputs the turn producing this reply worked for. */
|
|
117
340
|
val causedBy: List<String>,
|
|
341
|
+
/** Ids of the inputs this reply answered; only a `completed` reply answers inputs, so it is empty otherwise. */
|
|
118
342
|
val inReplyTo: List<String>,
|
|
343
|
+
/** The reply before marker removal; equal to `text` when markers did not change it. */
|
|
344
|
+
val raw: String,
|
|
345
|
+
/** The checked structured-output value of a reply made with a response format; absent otherwise. */
|
|
119
346
|
val output: JsonElement? = null,
|
|
120
|
-
|
|
347
|
+
/** Why the reply did not complete; always present when `status` is `failed`. */
|
|
348
|
+
val error: EventError? = null,
|
|
349
|
+
/** Originals attached to this reply; absent when there are none. */
|
|
350
|
+
val attachments: List<Attachment>? = null
|
|
121
351
|
)
|
|
352
|
+
/** One model call was recorded, with its usage, cost and model; Core writes it when it records the call's cost. */
|
|
122
353
|
data class TurnEvent(
|
|
354
|
+
/** Opaque id of the model call; do not parse it. */
|
|
123
355
|
val id: String,
|
|
356
|
+
/** Ids of the inputs first seen by this call. */
|
|
124
357
|
val inputs: List<String>,
|
|
358
|
+
/** Ids of every input this call worked for. */
|
|
125
359
|
val causedBy: List<String>,
|
|
360
|
+
/** Token counts reported for the call (`prompt`, `completion`, `total`, `cached`, `cacheWrite`, `reasoning` when reported), or null when none were reported. */
|
|
126
361
|
val usage: JsonElement,
|
|
362
|
+
/** Cost of the call in credits; null when unknown. */
|
|
127
363
|
val cost: Double?,
|
|
364
|
+
/** How final `cost` is, for example `reported` (final), `unknown` (null cost), `estimated` (provisional) or `none` (zero cost). */
|
|
128
365
|
val costStatus: String,
|
|
366
|
+
/** The model recorded for the call; the requested model when no response named one. */
|
|
129
367
|
val model: String,
|
|
368
|
+
/** ISO 8601 time the call was recorded. */
|
|
130
369
|
val at: String,
|
|
370
|
+
/** `summary` when the call made a context summary; absent for an ordinary model call. */
|
|
131
371
|
val purpose: TurnPurpose? = null,
|
|
132
372
|
/** Reported serving-provider label; absent when unavailable. Diagnostic only; never changes pricing or settlement. */
|
|
133
|
-
val provider: String? = null
|
|
373
|
+
val provider: String? = null,
|
|
374
|
+
/** Images whose view failed; the call continues with their id and description. */
|
|
375
|
+
val viewErrors: List<ViewError>? = null
|
|
134
376
|
)
|
|
377
|
+
/** An agent tool call started or changed status; updates keep the same id and `firstSeq`. */
|
|
135
378
|
data class ToolEvent(
|
|
379
|
+
/** Opaque Core-assigned call id, the same as `ToolContext.callId` and an attachment's `callId`; do not parse it. */
|
|
136
380
|
val id: String,
|
|
381
|
+
/** Stream sequence of this event. */
|
|
137
382
|
val seq: Long,
|
|
383
|
+
/** Stream sequence of the call's first event; the same on every update of the call. */
|
|
138
384
|
val firstSeq: Long,
|
|
385
|
+
/** Who made the call; Core emits `agent` for these events (open string). */
|
|
139
386
|
val origin: String,
|
|
387
|
+
/** Ids of the inputs the call works for. */
|
|
140
388
|
val causedBy: List<String>,
|
|
389
|
+
/** Name of the called tool. */
|
|
141
390
|
val tool: String,
|
|
391
|
+
/** Stable command key of the called command. */
|
|
142
392
|
val key: String,
|
|
393
|
+
/** Arguments of the call, without app-bound arguments; `{}` when there are none. */
|
|
143
394
|
val args: JsonElement,
|
|
395
|
+
/** Status of the call: `running`, `waiting` (its result arrives later), `completed`, `failed`, `cancelled` or `unused` (a late result whose cause was cancelled) (open string). */
|
|
144
396
|
val status: String,
|
|
397
|
+
/** Cost of the call in credits; null while running or when unknown, 0 for an unpaid call. */
|
|
145
398
|
val cost: Double?,
|
|
399
|
+
/** How final `cost` is, for example `unknown` while running, `reported`, or `none` for an unpaid call. */
|
|
146
400
|
val costStatus: String,
|
|
401
|
+
/** ISO 8601 time the call started. */
|
|
147
402
|
val startedAt: String,
|
|
403
|
+
/** ISO 8601 time of this update. */
|
|
148
404
|
val at: String,
|
|
405
|
+
/** Id of the `turn` event for the model call that requested this tool call; absent when not recorded. */
|
|
149
406
|
val requestedBy: String? = null,
|
|
407
|
+
/** What the model was given as the result: `{text}`, plus `images` metadata (`mediaType`, `bytes`, `attachment`) for result images; absent while running, and removed when Core closes an unsettled call as failed or cancelled. */
|
|
150
408
|
val delivered: JsonElement? = null,
|
|
409
|
+
/** Originals the call kept as attachments, as `{attachments: [{id, mediaType, bytes}]}`; absent when none. */
|
|
151
410
|
val outputs: JsonElement? = null
|
|
152
411
|
)
|
|
412
|
+
/** The agent's current state: status, queue length, typing, and what running work is doing. */
|
|
153
413
|
data class StateEvent(
|
|
414
|
+
/** Whether the agent is idle, running or waiting. */
|
|
154
415
|
val status: AgentStatus,
|
|
416
|
+
/** Number of accepted sends waiting in the queue. */
|
|
155
417
|
val queued: Long,
|
|
418
|
+
/** True while a reply's `message.start` is written and its `message.end` is not. */
|
|
156
419
|
val typing: Boolean,
|
|
420
|
+
/** What running work is doing, for example `model`, `summary` or `tool`; null unless `status` is `running`. */
|
|
157
421
|
val activity: String?,
|
|
422
|
+
/** Names of the tools in the current round, in call order (built-in or app command key, else `unknown`); present only when `activity` is `tool`. */
|
|
158
423
|
val tools: List<String>? = null
|
|
159
424
|
)
|
|
425
|
+
/** The subscription's starting point: the current log, state and the reply being streamed; delivered first on attach. */
|
|
160
426
|
data class SnapshotEvent(
|
|
427
|
+
/** Id of the log the subscription reads; pass it back with a `seq` to resume. */
|
|
161
428
|
val logId: String,
|
|
429
|
+
/** The current `state` event. */
|
|
162
430
|
val state: JsonElement,
|
|
431
|
+
/** The reply being streamed now as `{messageId, firstSeq, text}`, or null when none. */
|
|
163
432
|
val streaming: JsonElement
|
|
164
433
|
)
|
|
434
|
+
/** An older page of the conversation, delivered after `subscription.history()`. */
|
|
165
435
|
data class PageEvent(
|
|
436
|
+
/** The page's rows oldest first, each as its latest event. */
|
|
166
437
|
val messages: List<AgentEvent>,
|
|
438
|
+
/** True when no older retained row was left out of this page. */
|
|
167
439
|
val reachedFloor: Boolean,
|
|
440
|
+
/** Id of the log the page was read from. */
|
|
168
441
|
val logId: String,
|
|
442
|
+
/** Stream sequence of the latest history clear, or 0 when there was none. */
|
|
169
443
|
val clearedSeq: Long
|
|
170
444
|
)
|
|
445
|
+
/** A full `clearHistory()` took effect; empty the displayed conversation. */
|
|
171
446
|
data class ClearedEvent(
|
|
447
|
+
/** Core-assigned id of this clear. */
|
|
172
448
|
val id: String,
|
|
449
|
+
/** ISO 8601 time the clear took effect. */
|
|
173
450
|
val at: String
|
|
174
451
|
)
|
|
452
|
+
/** A memory delete, clear or enable change took effect. */
|
|
175
453
|
data class MemoryEvent(
|
|
454
|
+
/** Core-assigned id of the memory operation. */
|
|
176
455
|
val id: String,
|
|
456
|
+
/** Which memory operation took effect. */
|
|
177
457
|
val op: MemoryOp,
|
|
458
|
+
/** ISO 8601 time the operation took effect. */
|
|
178
459
|
val at: String,
|
|
460
|
+
/** Id of the deleted memory fact; present only for `delete`. */
|
|
179
461
|
val item: String? = null,
|
|
462
|
+
/** The new memory setting; present only for `enabled`. */
|
|
180
463
|
val enabled: Boolean? = null,
|
|
464
|
+
/** Number of memory facts removed; present for `delete` and `clear`. */
|
|
181
465
|
val removed: Long? = null
|
|
182
466
|
)
|
|
467
|
+
/** Events were missed; redraw from a `page`. */
|
|
183
468
|
data class GapEvent(
|
|
469
|
+
/** Last stream sequence before the missed range. */
|
|
184
470
|
val afterSeq: Long,
|
|
471
|
+
/** Last missed stream sequence (inclusive). */
|
|
185
472
|
val throughSeq: Long,
|
|
473
|
+
/** Why the events are missing: `limit` (retention pruned them) or `cleared` (a history clear removed them). */
|
|
186
474
|
val reason: String
|
|
187
475
|
)
|
|
476
|
+
/** The subscription ended with an error; it receives no further events. */
|
|
188
477
|
data class SubscriptionError(
|
|
478
|
+
/** Error code, for example `storage_error`. */
|
|
189
479
|
val code: String,
|
|
480
|
+
/** Human-readable explanation of the error. */
|
|
190
481
|
val message: String,
|
|
482
|
+
/** Present only as `true` when a storage failure stopped the agent from writing; reopen to continue. */
|
|
191
483
|
val poisoned: Boolean? = null
|
|
192
484
|
)
|
|
485
|
+
/** The subscription ended because a newer subscription replaced it. */
|
|
193
486
|
class ReplacedEvent
|
|
487
|
+
/** One subscription event, by its wire `type`. Ignore or log `Unknown`. */
|
|
194
488
|
sealed interface AgentEvent {
|
|
489
|
+
/**
|
|
490
|
+
* The `input` event: see [InputEvent].
|
|
491
|
+
*
|
|
492
|
+
* @property value The event payload.
|
|
493
|
+
*/
|
|
195
494
|
data class InputEventEvent(val value: AppStreamContract.InputEvent): AgentEvent
|
|
495
|
+
/**
|
|
496
|
+
* The `input.dropped` event: see [InputDropped].
|
|
497
|
+
*
|
|
498
|
+
* @property value The event payload.
|
|
499
|
+
*/
|
|
500
|
+
data class InputDroppedEvent(val value: AppStreamContract.InputDropped): AgentEvent
|
|
501
|
+
/**
|
|
502
|
+
* The `message.start` event: see [MessageStart].
|
|
503
|
+
*
|
|
504
|
+
* @property value The event payload.
|
|
505
|
+
*/
|
|
196
506
|
data class MessageStartEvent(val value: AppStreamContract.MessageStart): AgentEvent
|
|
507
|
+
/**
|
|
508
|
+
* The `message.delta` event: see [MessageDelta].
|
|
509
|
+
*
|
|
510
|
+
* @property value The event payload.
|
|
511
|
+
*/
|
|
197
512
|
data class MessageDeltaEvent(val value: AppStreamContract.MessageDelta): AgentEvent
|
|
513
|
+
/**
|
|
514
|
+
* The `message.end` event: see [MessageEnd].
|
|
515
|
+
*
|
|
516
|
+
* @property value The event payload.
|
|
517
|
+
*/
|
|
198
518
|
data class MessageEndEvent(val value: AppStreamContract.MessageEnd): AgentEvent
|
|
519
|
+
/**
|
|
520
|
+
* The `turn` event: see [TurnEvent].
|
|
521
|
+
*
|
|
522
|
+
* @property value The event payload.
|
|
523
|
+
*/
|
|
199
524
|
data class TurnEventEvent(val value: AppStreamContract.TurnEvent): AgentEvent
|
|
525
|
+
/**
|
|
526
|
+
* The `tool` event: see [ToolEvent].
|
|
527
|
+
*
|
|
528
|
+
* @property value The event payload.
|
|
529
|
+
*/
|
|
200
530
|
data class ToolEventEvent(val value: AppStreamContract.ToolEvent): AgentEvent
|
|
531
|
+
/**
|
|
532
|
+
* The `state` event: see [StateEvent].
|
|
533
|
+
*
|
|
534
|
+
* @property value The event payload.
|
|
535
|
+
*/
|
|
201
536
|
data class StateEventEvent(val value: AppStreamContract.StateEvent): AgentEvent
|
|
537
|
+
/**
|
|
538
|
+
* The `snapshot` event: see [SnapshotEvent].
|
|
539
|
+
*
|
|
540
|
+
* @property value The event payload.
|
|
541
|
+
*/
|
|
202
542
|
data class SnapshotEventEvent(val value: AppStreamContract.SnapshotEvent): AgentEvent
|
|
543
|
+
/**
|
|
544
|
+
* The `page` event: see [PageEvent].
|
|
545
|
+
*
|
|
546
|
+
* @property value The event payload.
|
|
547
|
+
*/
|
|
203
548
|
data class PageEventEvent(val value: AppStreamContract.PageEvent): AgentEvent
|
|
549
|
+
/**
|
|
550
|
+
* The `cleared` event: see [ClearedEvent].
|
|
551
|
+
*
|
|
552
|
+
* @property value The event payload.
|
|
553
|
+
*/
|
|
204
554
|
data class ClearedEventEvent(val value: AppStreamContract.ClearedEvent): AgentEvent
|
|
555
|
+
/**
|
|
556
|
+
* The `memory` event: see [MemoryEvent].
|
|
557
|
+
*
|
|
558
|
+
* @property value The event payload.
|
|
559
|
+
*/
|
|
205
560
|
data class MemoryEventEvent(val value: AppStreamContract.MemoryEvent): AgentEvent
|
|
561
|
+
/**
|
|
562
|
+
* The `gap` event: see [GapEvent].
|
|
563
|
+
*
|
|
564
|
+
* @property value The event payload.
|
|
565
|
+
*/
|
|
206
566
|
data class GapEventEvent(val value: AppStreamContract.GapEvent): AgentEvent
|
|
567
|
+
/**
|
|
568
|
+
* The `error` event: see [SubscriptionError].
|
|
569
|
+
*
|
|
570
|
+
* @property value The event payload.
|
|
571
|
+
*/
|
|
207
572
|
data class SubscriptionErrorEvent(val value: AppStreamContract.SubscriptionError): AgentEvent
|
|
573
|
+
/**
|
|
574
|
+
* The `replaced` event: see [ReplacedEvent].
|
|
575
|
+
*
|
|
576
|
+
* @property value The event payload.
|
|
577
|
+
*/
|
|
208
578
|
data class ReplacedEventEvent(val value: AppStreamContract.ReplacedEvent): AgentEvent
|
|
579
|
+
/**
|
|
580
|
+
* An event type this SDK does not know, with every field kept.
|
|
581
|
+
*
|
|
582
|
+
* @property type The original event type.
|
|
583
|
+
* @property fields A copy of the original JSON object.
|
|
584
|
+
*/
|
|
209
585
|
data class Unknown(val type: String, val fields: JsonObject): AgentEvent
|
|
210
586
|
}
|
|
211
587
|
private class StringReaderAdapter<T>(val read: (String) -> T, val write: (T) -> String): JsonDeserializer<T>, JsonSerializer<T> {
|
|
@@ -252,8 +628,10 @@ object AppStreamContract {
|
|
|
252
628
|
else -> MemoryOp.Unknown(value, JsonPrimitive(value))
|
|
253
629
|
} }, { it.rawValue }))
|
|
254
630
|
.registerTypeAdapter(AgentEvent::class.java, JsonDeserializer<AgentEvent> { json, _, _ -> decode(json.asJsonObject) }).create()
|
|
631
|
+
/** Decodes one event by its `type`. An unrecognized type becomes [AgentEvent.Unknown]. */
|
|
255
632
|
fun decode(value: JsonObject): AgentEvent = when (value.get("type").asString) {
|
|
256
633
|
"input" -> AgentEvent.InputEventEvent(gson.fromJson(value, InputEvent::class.java))
|
|
634
|
+
"input.dropped" -> AgentEvent.InputDroppedEvent(gson.fromJson(value, InputDropped::class.java))
|
|
257
635
|
"message.start" -> AgentEvent.MessageStartEvent(gson.fromJson(value, MessageStart::class.java))
|
|
258
636
|
"message.delta" -> AgentEvent.MessageDeltaEvent(gson.fromJson(value, MessageDelta::class.java))
|
|
259
637
|
"message.end" -> AgentEvent.MessageEndEvent(gson.fromJson(value, MessageEnd::class.java))
|
|
@@ -273,7 +651,22 @@ object AppStreamContract {
|
|
|
273
651
|
internal fun decodeRequestResult(value: JsonObject): RequestResult = gson.fromJson(value, RequestResult::class.java)
|
|
274
652
|
/** The ONE closed set (APP-API): Core attaches it to every code, and a value outside it does not decode. */
|
|
275
653
|
@JsonAdapter(ErrorCategoryAdapter::class, nullSafe = false)
|
|
276
|
-
enum class ErrorCategory {
|
|
654
|
+
enum class ErrorCategory {
|
|
655
|
+
/** A network or Croche Cloud failure. Retry later; the input is kept. */
|
|
656
|
+
OFFLINE,
|
|
657
|
+
/** Credit or allowance ran out. Tell the user; retrying after a top-up works. */
|
|
658
|
+
ALLOWANCE,
|
|
659
|
+
/** Usage is stopped by the project, an account or a rate limit. Wait, or contact the operator. */
|
|
660
|
+
PAUSED,
|
|
661
|
+
/** A developer fix is needed: key, config, model or device identity. */
|
|
662
|
+
SETUP,
|
|
663
|
+
/** The work or the wait stopped; nothing to fix. An aborted wait can leave the input running. */
|
|
664
|
+
CLOSED,
|
|
665
|
+
/** The app's request cannot run as given. */
|
|
666
|
+
INVALID,
|
|
667
|
+
/** The work failed for a reason outside the app. Report it. A code outside Core's table is also `internal`. */
|
|
668
|
+
INTERNAL
|
|
669
|
+
}
|
|
277
670
|
private class ErrorCategoryAdapter: TypeAdapter<ErrorCategory>() {
|
|
278
671
|
override fun read(input: JsonReader): ErrorCategory {
|
|
279
672
|
if (input.peek() != JsonToken.STRING) throw JsonParseException("ErrorCategory must be a string.")
|
|
@@ -305,10 +698,10 @@ object AppStreamContract {
|
|
|
305
698
|
return when (code) {
|
|
306
699
|
"offline", "network_error", "request_timeout", "gateway_unavailable", "invalid_cloud_response", "stale_control", "http_<status>" -> ErrorCategory.OFFLINE
|
|
307
700
|
"account_credit_exhausted", "project_budget_exhausted", "user_allowance_exhausted", "development_allowance_exhausted", "unverified_allowance_exhausted", "gateway_key_exhausted", "provider_credit_unavailable" -> ErrorCategory.ALLOWANCE
|
|
308
|
-
"usage_paused", "runtime_blocked", "project_access_disabled", "account_disabled", "server_key_revoked", "
|
|
309
|
-
"
|
|
310
|
-
"outcome_unknown", "closed", "target_closed", "runtime_detached", "cancelled", "interrupted", "preempted", "aborted", "observation_lost", "store_busy", "instance_busy" -> ErrorCategory.CLOSED
|
|
311
|
-
"invalid_input", "input_too_large", "invalid_memory", "invalid_response_format", "invalid_request", "tool_unauthorized", "agent_conflict", "unknown_id", "idempotency_conflict", "identity_conflict", "busy", "queue_full", "cursor_reset", "context_limit", "output_limit", "iteration_limit", "structured_output_unsupported" -> ErrorCategory.INVALID
|
|
701
|
+
"usage_paused", "runtime_blocked", "project_access_disabled", "account_disabled", "server_key_revoked", "development_key_revoked", "development_device_limit", "rate_limited", "provider_rate_limited" -> ErrorCategory.PAUSED
|
|
702
|
+
"user_allowance_disabled", "invalid_configuration", "model_missing", "model_withdrawn", "model_unavailable", "project_key_unknown", "server_key_invalid", "development_key_invalid", "user_required", "gateway_key_rejected", "gateway_unsupported", "schema_unsupported", "capability_unsupported", "invalid_snapshot", "snapshot_mismatch", "invalid_tool", "invalid_wiki", "installation_unverified", "attestation_required", "attestation_rejected", "attestation_unverifiable", "attestation_failed", "attestation_unavailable", "attestation_unsupported", "attestation_timeout", "recovery_required", "host_unavailable", "core_unavailable" -> ErrorCategory.SETUP
|
|
703
|
+
"state_conflict", "outcome_unknown", "closed", "target_closed", "runtime_detached", "cancelled", "interrupted", "preempted", "aborted", "observation_lost", "store_busy", "instance_busy" -> ErrorCategory.CLOSED
|
|
704
|
+
"invalid_input", "input_too_large", "invalid_memory", "invalid_response_format", "invalid_request", "tool_unauthorized", "agent_conflict", "unknown_id", "attachment_storage_full", "idempotency_conflict", "identity_conflict", "busy", "queue_full", "cursor_reset", "context_limit", "output_limit", "iteration_limit", "structured_output_unsupported" -> ErrorCategory.INVALID
|
|
312
705
|
"failure_unrecorded", "internal", "asset_read_failed", "stream_incomplete", "provider_error", "provider_rejected", "invalid_provider_response", "invalid_response", "output_too_large", "output_invalid", "empty_response", "unexpected_tool_call", "storage_error", "store_refused", "store_full", "corrupt_store", "store_too_new", "fresh_reservation_lost", "archive_unavailable", "archive_error", "host_error", "host_unresponsive", "thread_unavailable", "core_error", "invalid_abi", "no_lock", "handler_failed", "subscriber_overflow" -> ErrorCategory.INTERNAL
|
|
313
706
|
else -> ErrorCategory.INTERNAL
|
|
314
707
|
}
|