@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
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
// GENERATED by scripts/generate-app-stream.mjs from the Rust app contract. Do not edit.
|
|
2
2
|
import Foundation
|
|
3
3
|
|
|
4
|
+
/// The app-stream reader types, generated from Core's Rust contract. Core validates and emits them; the SDK only decodes.
|
|
4
5
|
public enum AppStreamContract {
|
|
6
|
+
/// Status of an accepted input: `queued` or `seen`, then one terminal status.
|
|
5
7
|
public enum InputDisposition: Codable, Sendable, Hashable {
|
|
8
|
+
/// Accepted and waiting for a turn.
|
|
6
9
|
case queued
|
|
10
|
+
/// Taken up by a turn for the agent to work on.
|
|
7
11
|
case seen
|
|
12
|
+
/// A completed reply answered the input.
|
|
8
13
|
case answered
|
|
14
|
+
/// The work finished without a reply answering the input.
|
|
9
15
|
case noReply
|
|
16
|
+
/// The input failed; its error says why.
|
|
10
17
|
case failed
|
|
18
|
+
/// The input was cancelled.
|
|
11
19
|
case cancelled
|
|
20
|
+
/// A value this SDK does not know, kept as `type` (`fields` holds the same string).
|
|
12
21
|
case unknown(type: String, fields: JSON)
|
|
22
|
+
/// The wire string.
|
|
13
23
|
public var rawValue: String {
|
|
14
24
|
switch self {
|
|
15
25
|
case .queued: return "queued"
|
|
@@ -21,6 +31,7 @@ public enum AppStreamContract {
|
|
|
21
31
|
case .unknown(let type, _): return type
|
|
22
32
|
}
|
|
23
33
|
}
|
|
34
|
+
/// Decodes the wire string. An unrecognized string becomes `unknown`.
|
|
24
35
|
public init(from decoder: Decoder) throws {
|
|
25
36
|
let value = try decoder.singleValueContainer().decode(String.self)
|
|
26
37
|
switch value {
|
|
@@ -33,16 +44,23 @@ public enum AppStreamContract {
|
|
|
33
44
|
default: self = .unknown(type: value, fields: .string(value))
|
|
34
45
|
}
|
|
35
46
|
}
|
|
47
|
+
/// Encodes `rawValue`.
|
|
36
48
|
public func encode(to encoder: Encoder) throws {
|
|
37
49
|
var value = encoder.singleValueContainer()
|
|
38
50
|
try value.encode(rawValue)
|
|
39
51
|
}
|
|
40
52
|
}
|
|
53
|
+
/// Kind of an input's parts.
|
|
41
54
|
public enum InputKind: Codable, Sendable, Hashable {
|
|
55
|
+
/// Text from the person using the app.
|
|
42
56
|
case user
|
|
57
|
+
/// An event the app reported.
|
|
43
58
|
case appEvent
|
|
59
|
+
/// Opaque app state text.
|
|
44
60
|
case appState
|
|
61
|
+
/// A value this SDK does not know, kept as `type` (`fields` holds the same string).
|
|
45
62
|
case unknown(type: String, fields: JSON)
|
|
63
|
+
/// The wire string.
|
|
46
64
|
public var rawValue: String {
|
|
47
65
|
switch self {
|
|
48
66
|
case .user: return "user"
|
|
@@ -51,6 +69,7 @@ public enum AppStreamContract {
|
|
|
51
69
|
case .unknown(let type, _): return type
|
|
52
70
|
}
|
|
53
71
|
}
|
|
72
|
+
/// Decodes the wire string. An unrecognized string becomes `unknown`.
|
|
54
73
|
public init(from decoder: Decoder) throws {
|
|
55
74
|
let value = try decoder.singleValueContainer().decode(String.self)
|
|
56
75
|
switch value {
|
|
@@ -60,17 +79,25 @@ public enum AppStreamContract {
|
|
|
60
79
|
default: self = .unknown(type: value, fields: .string(value))
|
|
61
80
|
}
|
|
62
81
|
}
|
|
82
|
+
/// Encodes `rawValue`.
|
|
63
83
|
public func encode(to encoder: Encoder) throws {
|
|
64
84
|
var value = encoder.singleValueContainer()
|
|
65
85
|
try value.encode(rawValue)
|
|
66
86
|
}
|
|
67
87
|
}
|
|
88
|
+
/// How an agent reply ended.
|
|
68
89
|
public enum MessageStatus: Codable, Sendable, Hashable {
|
|
90
|
+
/// The reply finished and answers its open inputs.
|
|
69
91
|
case completed
|
|
92
|
+
/// The reply ended because its call or turn failed.
|
|
70
93
|
case failed
|
|
94
|
+
/// The reply ended because its work was cancelled.
|
|
71
95
|
case cancelled
|
|
96
|
+
/// The process stopped during the reply.
|
|
72
97
|
case interrupted
|
|
98
|
+
/// A value this SDK does not know, kept as `type` (`fields` holds the same string).
|
|
73
99
|
case unknown(type: String, fields: JSON)
|
|
100
|
+
/// The wire string.
|
|
74
101
|
public var rawValue: String {
|
|
75
102
|
switch self {
|
|
76
103
|
case .completed: return "completed"
|
|
@@ -80,6 +107,7 @@ public enum AppStreamContract {
|
|
|
80
107
|
case .unknown(let type, _): return type
|
|
81
108
|
}
|
|
82
109
|
}
|
|
110
|
+
/// Decodes the wire string. An unrecognized string becomes `unknown`.
|
|
83
111
|
public init(from decoder: Decoder) throws {
|
|
84
112
|
let value = try decoder.singleValueContainer().decode(String.self)
|
|
85
113
|
switch value {
|
|
@@ -90,16 +118,23 @@ public enum AppStreamContract {
|
|
|
90
118
|
default: self = .unknown(type: value, fields: .string(value))
|
|
91
119
|
}
|
|
92
120
|
}
|
|
121
|
+
/// Encodes `rawValue`.
|
|
93
122
|
public func encode(to encoder: Encoder) throws {
|
|
94
123
|
var value = encoder.singleValueContainer()
|
|
95
124
|
try value.encode(rawValue)
|
|
96
125
|
}
|
|
97
126
|
}
|
|
127
|
+
/// Whether the agent has work.
|
|
98
128
|
public enum AgentStatus: Codable, Sendable, Hashable {
|
|
129
|
+
/// Nothing to do and nothing to receive.
|
|
99
130
|
case idle
|
|
131
|
+
/// A turn runs, an accepted input is queued, or a tool result waits to continue the turn.
|
|
100
132
|
case running
|
|
133
|
+
/// Nothing to do, but a late tool result is still to arrive.
|
|
101
134
|
case waiting
|
|
135
|
+
/// A value this SDK does not know, kept as `type` (`fields` holds the same string).
|
|
102
136
|
case unknown(type: String, fields: JSON)
|
|
137
|
+
/// The wire string.
|
|
103
138
|
public var rawValue: String {
|
|
104
139
|
switch self {
|
|
105
140
|
case .idle: return "idle"
|
|
@@ -108,6 +143,7 @@ public enum AppStreamContract {
|
|
|
108
143
|
case .unknown(let type, _): return type
|
|
109
144
|
}
|
|
110
145
|
}
|
|
146
|
+
/// Decodes the wire string. An unrecognized string becomes `unknown`.
|
|
111
147
|
public init(from decoder: Decoder) throws {
|
|
112
148
|
let value = try decoder.singleValueContainer().decode(String.self)
|
|
113
149
|
switch value {
|
|
@@ -117,20 +153,26 @@ public enum AppStreamContract {
|
|
|
117
153
|
default: self = .unknown(type: value, fields: .string(value))
|
|
118
154
|
}
|
|
119
155
|
}
|
|
156
|
+
/// Encodes `rawValue`.
|
|
120
157
|
public func encode(to encoder: Encoder) throws {
|
|
121
158
|
var value = encoder.singleValueContainer()
|
|
122
159
|
try value.encode(rawValue)
|
|
123
160
|
}
|
|
124
161
|
}
|
|
162
|
+
/// Why a model call other than an ordinary reply call was made.
|
|
125
163
|
public enum TurnPurpose: Codable, Sendable, Hashable {
|
|
164
|
+
/// The call made a context summary.
|
|
126
165
|
case summary
|
|
166
|
+
/// A value this SDK does not know, kept as `type` (`fields` holds the same string).
|
|
127
167
|
case unknown(type: String, fields: JSON)
|
|
168
|
+
/// The wire string.
|
|
128
169
|
public var rawValue: String {
|
|
129
170
|
switch self {
|
|
130
171
|
case .summary: return "summary"
|
|
131
172
|
case .unknown(let type, _): return type
|
|
132
173
|
}
|
|
133
174
|
}
|
|
175
|
+
/// Decodes the wire string. An unrecognized string becomes `unknown`.
|
|
134
176
|
public init(from decoder: Decoder) throws {
|
|
135
177
|
let value = try decoder.singleValueContainer().decode(String.self)
|
|
136
178
|
switch value {
|
|
@@ -138,16 +180,23 @@ public enum AppStreamContract {
|
|
|
138
180
|
default: self = .unknown(type: value, fields: .string(value))
|
|
139
181
|
}
|
|
140
182
|
}
|
|
183
|
+
/// Encodes `rawValue`.
|
|
141
184
|
public func encode(to encoder: Encoder) throws {
|
|
142
185
|
var value = encoder.singleValueContainer()
|
|
143
186
|
try value.encode(rawValue)
|
|
144
187
|
}
|
|
145
188
|
}
|
|
189
|
+
/// A memory operation the app can make.
|
|
146
190
|
public enum MemoryOp: Codable, Sendable, Hashable {
|
|
191
|
+
/// One memory fact was deleted.
|
|
147
192
|
case delete
|
|
193
|
+
/// All memory facts were deleted.
|
|
148
194
|
case clear
|
|
195
|
+
/// Memory was turned on or off.
|
|
149
196
|
case enabled
|
|
197
|
+
/// A value this SDK does not know, kept as `type` (`fields` holds the same string).
|
|
150
198
|
case unknown(type: String, fields: JSON)
|
|
199
|
+
/// The wire string.
|
|
151
200
|
public var rawValue: String {
|
|
152
201
|
switch self {
|
|
153
202
|
case .delete: return "delete"
|
|
@@ -156,6 +205,7 @@ public enum AppStreamContract {
|
|
|
156
205
|
case .unknown(let type, _): return type
|
|
157
206
|
}
|
|
158
207
|
}
|
|
208
|
+
/// Decodes the wire string. An unrecognized string becomes `unknown`.
|
|
159
209
|
public init(from decoder: Decoder) throws {
|
|
160
210
|
let value = try decoder.singleValueContainer().decode(String.self)
|
|
161
211
|
switch value {
|
|
@@ -165,167 +215,332 @@ public enum AppStreamContract {
|
|
|
165
215
|
default: self = .unknown(type: value, fields: .string(value))
|
|
166
216
|
}
|
|
167
217
|
}
|
|
218
|
+
/// Encodes `rawValue`.
|
|
168
219
|
public func encode(to encoder: Encoder) throws {
|
|
169
220
|
var value = encoder.singleValueContainer()
|
|
170
221
|
try value.encode(rawValue)
|
|
171
222
|
}
|
|
172
223
|
}
|
|
224
|
+
/// Metadata of a stored image original that Core keeps for the app, a message or a tool call.
|
|
173
225
|
public struct Attachment: Codable, Sendable {
|
|
226
|
+
/// Core-assigned attachment id, used to read, copy, release or delete the original.
|
|
174
227
|
public let id: String
|
|
228
|
+
/// What the attachment is; Core currently stores only `image` (open string).
|
|
175
229
|
public let kind: String
|
|
230
|
+
/// Where the stored original came from, for example `tool` (produced by a tool call) or `app` (copied in by the app).
|
|
176
231
|
public let origin: String
|
|
232
|
+
/// Image media type of the stored original, for example `image/png`.
|
|
177
233
|
public let mediaType: String
|
|
234
|
+
/// Size of the stored original in bytes.
|
|
178
235
|
public let bytes: UInt64
|
|
236
|
+
/// Lowercase hex SHA-256 of the stored original's bytes.
|
|
179
237
|
public let sha256: String
|
|
238
|
+
/// The original's pixel width, when Core reports it; absent otherwise.
|
|
180
239
|
public let width: UInt64?
|
|
240
|
+
/// The original's pixel height, when Core reports it; absent otherwise.
|
|
181
241
|
public let height: UInt64?
|
|
242
|
+
/// Description text supplied with the image; absent when none was given.
|
|
182
243
|
public let alt: String?
|
|
244
|
+
/// Id of the agent tool call that produced the original (the same id as `ToolEvent.id`); absent for originals not produced by a call.
|
|
183
245
|
public let callId: String?
|
|
246
|
+
/// Present only as `true` when the original is no longer stored at read time; the logged row itself is not changed.
|
|
184
247
|
public let deleted: Bool?
|
|
248
|
+
/// 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`.
|
|
185
249
|
public let deletedReason: String?
|
|
186
250
|
}
|
|
251
|
+
/// An error carried by an event or result, with the category that tells the app how to react.
|
|
187
252
|
public struct EventError: Codable, Sendable {
|
|
253
|
+
/// Error code, for example `store_full` or `interrupted`; a code outside the known table has category `internal`.
|
|
188
254
|
public let code: String
|
|
255
|
+
/// What the app does about the error.
|
|
189
256
|
public let category: ErrorCategory
|
|
257
|
+
/// Human-readable explanation of the error.
|
|
190
258
|
public let message: String
|
|
191
259
|
/// Integer seconds, present only on the hourly app-paid rate_limited refusal.
|
|
192
260
|
public let retryAfter: UInt64?
|
|
193
261
|
}
|
|
262
|
+
/// An image that could not be viewed for one model call; the call continues with the image's id and description.
|
|
263
|
+
public struct ViewError: Codable, Sendable {
|
|
264
|
+
/// Id of the attachment whose view failed.
|
|
265
|
+
public let attachmentId: String
|
|
266
|
+
/// Error code for the failed view, for example `image_unsupported`.
|
|
267
|
+
public let code: String
|
|
268
|
+
/// What the app does about the error.
|
|
269
|
+
public let category: ErrorCategory
|
|
270
|
+
/// Human-readable explanation of why the view failed.
|
|
271
|
+
public let message: String
|
|
272
|
+
}
|
|
273
|
+
/// Returned when Core accepts a send: the input's id, its status at acceptance and where its events start in the stream.
|
|
194
274
|
public struct SendReceipt: Codable, Sendable {
|
|
275
|
+
/// Id of the accepted input.
|
|
195
276
|
public let requestId: String
|
|
277
|
+
/// 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.
|
|
196
278
|
public let status: InputDisposition
|
|
279
|
+
/// Stream sequence of the input's first event, or for a just-accepted input the position its events start from.
|
|
197
280
|
public let seq: UInt64
|
|
281
|
+
/// Why the input failed; present when `status` is `failed`.
|
|
198
282
|
public let error: EventError?
|
|
199
283
|
}
|
|
284
|
+
/// The terminal result of an accepted `request`: the input's final status and the replies it caused.
|
|
200
285
|
public struct RequestResult: Codable, Sendable {
|
|
286
|
+
/// Id of the input this result is for.
|
|
201
287
|
public let id: String
|
|
288
|
+
/// The input's terminal status.
|
|
202
289
|
public let status: InputDisposition
|
|
290
|
+
/// The retained `message.end` events whose `causedBy` includes this input.
|
|
203
291
|
public let messages: [MessageEnd]
|
|
292
|
+
/// Present only as `true` when some of this input's events were already pruned, so `messages` can be incomplete or empty.
|
|
204
293
|
public let gap: Bool?
|
|
294
|
+
/// Why the input failed; always present when `status` is `failed`.
|
|
205
295
|
public let error: EventError?
|
|
206
296
|
}
|
|
297
|
+
/// An input was accepted or its status changed; each change re-emits the input's full current state.
|
|
207
298
|
public struct InputEvent: Codable, Sendable {
|
|
299
|
+
/// Id of the input.
|
|
208
300
|
public let id: String
|
|
301
|
+
/// Stream sequence of this event.
|
|
209
302
|
public let seq: UInt64
|
|
303
|
+
/// Stream sequence of this input's first event; the same on every update of the input.
|
|
210
304
|
public let firstSeq: UInt64
|
|
305
|
+
/// Which kind of input parts this row shows.
|
|
211
306
|
public let kind: InputKind
|
|
307
|
+
/// The input's status after this change.
|
|
212
308
|
public let status: InputDisposition
|
|
309
|
+
/// ISO 8601 time of this change.
|
|
213
310
|
public let at: String
|
|
311
|
+
/// Text of the input's parts of this `kind`, joined with blank lines; absent when Core holds no summary for the input.
|
|
214
312
|
public let text: String?
|
|
313
|
+
/// Why the input failed; always present when `status` is `failed` and absent otherwise.
|
|
215
314
|
public let error: EventError?
|
|
216
315
|
}
|
|
316
|
+
/// A held send left without running; Core emits it after reopen for a send that was held when the app stopped.
|
|
317
|
+
public struct InputDropped: Codable, Sendable {
|
|
318
|
+
/// Id of the dropped input.
|
|
319
|
+
public let inputId: String
|
|
320
|
+
/// Why the input was dropped; Core's stream emits `reopened` (open string).
|
|
321
|
+
public let reason: String
|
|
322
|
+
/// Stream sequence of this event.
|
|
323
|
+
public let seq: UInt64
|
|
324
|
+
/// Stream sequence of the input's first event when it had one, otherwise this event's own sequence.
|
|
325
|
+
public let firstSeq: UInt64
|
|
326
|
+
}
|
|
327
|
+
/// An agent reply began; Core emits it when the reply has its first visible text, before any of its deltas.
|
|
217
328
|
public struct MessageStart: Codable, Sendable {
|
|
329
|
+
/// Id of the reply message, shared by its start, deltas and end.
|
|
218
330
|
public let id: String
|
|
331
|
+
/// Stream sequence of this event.
|
|
219
332
|
public let seq: UInt64
|
|
333
|
+
/// Stream sequence of the message's first event, which is this start.
|
|
220
334
|
public let firstSeq: UInt64
|
|
335
|
+
/// ISO 8601 time the reply started.
|
|
221
336
|
public let at: String
|
|
222
337
|
}
|
|
338
|
+
/// New text of the open reply as it is written; a preview only, since `message.end` carries the stored text.
|
|
223
339
|
public struct MessageDelta: Codable, Sendable {
|
|
340
|
+
/// Id of the open reply message.
|
|
224
341
|
public let id: String
|
|
342
|
+
/// Text added to the reply since the previous delta.
|
|
225
343
|
public let text: String
|
|
226
344
|
}
|
|
345
|
+
/// The end of an agent reply with its stored text and final status; never rewritten.
|
|
227
346
|
public struct MessageEnd: Codable, Sendable {
|
|
347
|
+
/// Id of the reply message.
|
|
228
348
|
public let id: String
|
|
349
|
+
/// Stream sequence of this event.
|
|
229
350
|
public let seq: UInt64
|
|
351
|
+
/// Stream sequence of the message's first event (its `message.start`).
|
|
230
352
|
public let firstSeq: UInt64
|
|
353
|
+
/// ISO 8601 time the reply ended.
|
|
231
354
|
public let at: String
|
|
355
|
+
/// How the reply ended.
|
|
232
356
|
public let status: MessageStatus
|
|
357
|
+
/// The stored reply text with markers removed; empty after an interruption or when the reply was too large to store.
|
|
233
358
|
public let text: String
|
|
359
|
+
/// Names of the registered markers found in the reply, in reply order.
|
|
234
360
|
public let markers: [String]
|
|
361
|
+
/// Ids of the inputs the turn producing this reply worked for.
|
|
235
362
|
public let causedBy: [String]
|
|
363
|
+
/// Ids of the inputs this reply answered; only a `completed` reply answers inputs, so it is empty otherwise.
|
|
236
364
|
public let inReplyTo: [String]
|
|
365
|
+
/// The reply before marker removal; equal to `text` when markers did not change it.
|
|
366
|
+
public let raw: String
|
|
367
|
+
/// The checked structured-output value of a reply made with a response format; absent otherwise.
|
|
237
368
|
public let output: JSON?
|
|
369
|
+
/// Why the reply did not complete; always present when `status` is `failed`.
|
|
238
370
|
public let error: EventError?
|
|
371
|
+
/// Originals attached to this reply; absent when there are none.
|
|
372
|
+
public let attachments: [Attachment]?
|
|
239
373
|
}
|
|
374
|
+
/// One model call was recorded, with its usage, cost and model; Core writes it when it records the call's cost.
|
|
240
375
|
public struct TurnEvent: Codable, Sendable {
|
|
376
|
+
/// Opaque id of the model call; do not parse it.
|
|
241
377
|
public let id: String
|
|
378
|
+
/// Ids of the inputs first seen by this call.
|
|
242
379
|
public let inputs: [String]
|
|
380
|
+
/// Ids of every input this call worked for.
|
|
243
381
|
public let causedBy: [String]
|
|
382
|
+
/// Token counts reported for the call (`prompt`, `completion`, `total`, `cached`, `cacheWrite`, `reasoning` when reported), or null when none were reported.
|
|
244
383
|
public let usage: JSON
|
|
384
|
+
/// Cost of the call in credits; null when unknown.
|
|
245
385
|
public let cost: Double?
|
|
386
|
+
/// How final `cost` is, for example `reported` (final), `unknown` (null cost), `estimated` (provisional) or `none` (zero cost).
|
|
246
387
|
public let costStatus: String
|
|
388
|
+
/// The model recorded for the call; the requested model when no response named one.
|
|
247
389
|
public let model: String
|
|
390
|
+
/// ISO 8601 time the call was recorded.
|
|
248
391
|
public let at: String
|
|
392
|
+
/// `summary` when the call made a context summary; absent for an ordinary model call.
|
|
249
393
|
public let purpose: TurnPurpose?
|
|
250
394
|
/// Reported serving-provider label; absent when unavailable. Diagnostic only; never changes pricing or settlement.
|
|
251
395
|
public let provider: String?
|
|
396
|
+
/// Images whose view failed; the call continues with their id and description.
|
|
397
|
+
public let viewErrors: [ViewError]?
|
|
252
398
|
}
|
|
399
|
+
/// An agent tool call started or changed status; updates keep the same id and `firstSeq`.
|
|
253
400
|
public struct ToolEvent: Codable, Sendable {
|
|
401
|
+
/// Opaque Core-assigned call id, the same as `ToolContext.callId` and an attachment's `callId`; do not parse it.
|
|
254
402
|
public let id: String
|
|
403
|
+
/// Stream sequence of this event.
|
|
255
404
|
public let seq: UInt64
|
|
405
|
+
/// Stream sequence of the call's first event; the same on every update of the call.
|
|
256
406
|
public let firstSeq: UInt64
|
|
407
|
+
/// Who made the call; Core emits `agent` for these events (open string).
|
|
257
408
|
public let origin: String
|
|
409
|
+
/// Ids of the inputs the call works for.
|
|
258
410
|
public let causedBy: [String]
|
|
411
|
+
/// Name of the called tool.
|
|
259
412
|
public let tool: String
|
|
413
|
+
/// Stable command key of the called command.
|
|
260
414
|
public let key: String
|
|
415
|
+
/// Arguments of the call, without app-bound arguments; `{}` when there are none.
|
|
261
416
|
public let args: JSON
|
|
417
|
+
/// Status of the call: `running`, `waiting` (its result arrives later), `completed`, `failed`, `cancelled` or `unused` (a late result whose cause was cancelled) (open string).
|
|
262
418
|
public let status: String
|
|
419
|
+
/// Cost of the call in credits; null while running or when unknown, 0 for an unpaid call.
|
|
263
420
|
public let cost: Double?
|
|
421
|
+
/// How final `cost` is, for example `unknown` while running, `reported`, or `none` for an unpaid call.
|
|
264
422
|
public let costStatus: String
|
|
423
|
+
/// ISO 8601 time the call started.
|
|
265
424
|
public let startedAt: String
|
|
425
|
+
/// ISO 8601 time of this update.
|
|
266
426
|
public let at: String
|
|
427
|
+
/// Id of the `turn` event for the model call that requested this tool call; absent when not recorded.
|
|
267
428
|
public let requestedBy: String?
|
|
429
|
+
/// 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.
|
|
268
430
|
public let delivered: JSON?
|
|
431
|
+
/// Originals the call kept as attachments, as `{attachments: [{id, mediaType, bytes}]}`; absent when none.
|
|
269
432
|
public let outputs: JSON?
|
|
270
433
|
}
|
|
434
|
+
/// The agent's current state: status, queue length, typing, and what running work is doing.
|
|
271
435
|
public struct StateEvent: Codable, Sendable {
|
|
436
|
+
/// Whether the agent is idle, running or waiting.
|
|
272
437
|
public let status: AgentStatus
|
|
438
|
+
/// Number of accepted sends waiting in the queue.
|
|
273
439
|
public let queued: UInt64
|
|
440
|
+
/// True while a reply's `message.start` is written and its `message.end` is not.
|
|
274
441
|
public let typing: Bool
|
|
442
|
+
/// What running work is doing, for example `model`, `summary` or `tool`; null unless `status` is `running`.
|
|
275
443
|
public let activity: String?
|
|
444
|
+
/// 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`.
|
|
276
445
|
public let tools: [String]?
|
|
277
446
|
}
|
|
447
|
+
/// The subscription's starting point: the current log, state and the reply being streamed; delivered first on attach.
|
|
278
448
|
public struct SnapshotEvent: Codable, Sendable {
|
|
449
|
+
/// Id of the log the subscription reads; pass it back with a `seq` to resume.
|
|
279
450
|
public let logId: String
|
|
451
|
+
/// The current `state` event.
|
|
280
452
|
public let state: JSON
|
|
453
|
+
/// The reply being streamed now as `{messageId, firstSeq, text}`, or null when none.
|
|
281
454
|
public let streaming: JSON
|
|
282
455
|
}
|
|
456
|
+
/// An older page of the conversation, delivered after `subscription.history()`.
|
|
283
457
|
public struct PageEvent: Codable, Sendable {
|
|
458
|
+
/// The page's rows oldest first, each as its latest event.
|
|
284
459
|
public let messages: [AgentEvent]
|
|
460
|
+
/// True when no older retained row was left out of this page.
|
|
285
461
|
public let reachedFloor: Bool
|
|
462
|
+
/// Id of the log the page was read from.
|
|
286
463
|
public let logId: String
|
|
464
|
+
/// Stream sequence of the latest history clear, or 0 when there was none.
|
|
287
465
|
public let clearedSeq: UInt64
|
|
288
466
|
}
|
|
467
|
+
/// A full `clearHistory()` took effect; empty the displayed conversation.
|
|
289
468
|
public struct ClearedEvent: Codable, Sendable {
|
|
469
|
+
/// Core-assigned id of this clear.
|
|
290
470
|
public let id: String
|
|
471
|
+
/// ISO 8601 time the clear took effect.
|
|
291
472
|
public let at: String
|
|
292
473
|
}
|
|
474
|
+
/// A memory delete, clear or enable change took effect.
|
|
293
475
|
public struct MemoryEvent: Codable, Sendable {
|
|
476
|
+
/// Core-assigned id of the memory operation.
|
|
294
477
|
public let id: String
|
|
478
|
+
/// Which memory operation took effect.
|
|
295
479
|
public let op: MemoryOp
|
|
480
|
+
/// ISO 8601 time the operation took effect.
|
|
296
481
|
public let at: String
|
|
482
|
+
/// Id of the deleted memory fact; present only for `delete`.
|
|
297
483
|
public let item: String?
|
|
484
|
+
/// The new memory setting; present only for `enabled`.
|
|
298
485
|
public let enabled: Bool?
|
|
486
|
+
/// Number of memory facts removed; present for `delete` and `clear`.
|
|
299
487
|
public let removed: UInt64?
|
|
300
488
|
}
|
|
489
|
+
/// Events were missed; redraw from a `page`.
|
|
301
490
|
public struct GapEvent: Codable, Sendable {
|
|
491
|
+
/// Last stream sequence before the missed range.
|
|
302
492
|
public let afterSeq: UInt64
|
|
493
|
+
/// Last missed stream sequence (inclusive).
|
|
303
494
|
public let throughSeq: UInt64
|
|
495
|
+
/// Why the events are missing: `limit` (retention pruned them) or `cleared` (a history clear removed them).
|
|
304
496
|
public let reason: String
|
|
305
497
|
}
|
|
498
|
+
/// The subscription ended with an error; it receives no further events.
|
|
306
499
|
public struct SubscriptionError: Codable, Sendable {
|
|
500
|
+
/// Error code, for example `storage_error`.
|
|
307
501
|
public let code: String
|
|
502
|
+
/// Human-readable explanation of the error.
|
|
308
503
|
public let message: String
|
|
504
|
+
/// Present only as `true` when a storage failure stopped the agent from writing; reopen to continue.
|
|
309
505
|
public let poisoned: Bool?
|
|
310
506
|
}
|
|
507
|
+
/// The subscription ended because a newer subscription replaced it.
|
|
311
508
|
public struct ReplacedEvent: Codable, Sendable {
|
|
312
509
|
|
|
313
510
|
}
|
|
511
|
+
/// One subscription event, by its wire `type`. Ignore or log `unknown`.
|
|
314
512
|
public indirect enum AgentEvent: Codable, Sendable {
|
|
513
|
+
/// The `input` event: see ``InputEvent``.
|
|
315
514
|
case input(InputEvent)
|
|
515
|
+
/// The `input.dropped` event: see ``InputDropped``.
|
|
516
|
+
case inputDropped(InputDropped)
|
|
517
|
+
/// The `message.start` event: see ``MessageStart``.
|
|
316
518
|
case messageStart(MessageStart)
|
|
519
|
+
/// The `message.delta` event: see ``MessageDelta``.
|
|
317
520
|
case messageDelta(MessageDelta)
|
|
521
|
+
/// The `message.end` event: see ``MessageEnd``.
|
|
318
522
|
case messageEnd(MessageEnd)
|
|
523
|
+
/// The `turn` event: see ``TurnEvent``.
|
|
319
524
|
case turn(TurnEvent)
|
|
525
|
+
/// The `tool` event: see ``ToolEvent``.
|
|
320
526
|
case tool(ToolEvent)
|
|
527
|
+
/// The `state` event: see ``StateEvent``.
|
|
321
528
|
case state(StateEvent)
|
|
529
|
+
/// The `snapshot` event: see ``SnapshotEvent``.
|
|
322
530
|
case snapshot(SnapshotEvent)
|
|
531
|
+
/// The `page` event: see ``PageEvent``.
|
|
323
532
|
case page(PageEvent)
|
|
533
|
+
/// The `cleared` event: see ``ClearedEvent``.
|
|
324
534
|
case cleared(ClearedEvent)
|
|
535
|
+
/// The `memory` event: see ``MemoryEvent``.
|
|
325
536
|
case memory(MemoryEvent)
|
|
537
|
+
/// The `gap` event: see ``GapEvent``.
|
|
326
538
|
case gap(GapEvent)
|
|
539
|
+
/// The `error` event: see ``SubscriptionError``.
|
|
327
540
|
case error(SubscriptionError)
|
|
541
|
+
/// The `replaced` event: see ``ReplacedEvent``.
|
|
328
542
|
case replaced(ReplacedEvent)
|
|
543
|
+
/// An event type this SDK does not know, with every field kept.
|
|
329
544
|
case unknown(type: String, fields: [String: JSON])
|
|
330
545
|
private enum Tag: String, CodingKey { case type }
|
|
331
546
|
private struct FieldKey: CodingKey {
|
|
@@ -334,10 +549,12 @@ public enum AppStreamContract {
|
|
|
334
549
|
init(stringValue: String) { self.stringValue = stringValue }
|
|
335
550
|
init?(intValue: Int) { nil }
|
|
336
551
|
}
|
|
552
|
+
/// Decodes an event by its `type`. An unrecognized type becomes `unknown`.
|
|
337
553
|
public init(from decoder: Decoder) throws {
|
|
338
554
|
let tag = try decoder.container(keyedBy: Tag.self).decode(String.self, forKey: .type)
|
|
339
555
|
switch tag {
|
|
340
556
|
case "input": self = .input(try InputEvent(from: decoder))
|
|
557
|
+
case "input.dropped": self = .inputDropped(try InputDropped(from: decoder))
|
|
341
558
|
case "message.start": self = .messageStart(try MessageStart(from: decoder))
|
|
342
559
|
case "message.delta": self = .messageDelta(try MessageDelta(from: decoder))
|
|
343
560
|
case "message.end": self = .messageEnd(try MessageEnd(from: decoder))
|
|
@@ -356,12 +573,16 @@ public enum AppStreamContract {
|
|
|
356
573
|
self = .unknown(type: tag, fields: value.object ?? [:])
|
|
357
574
|
}
|
|
358
575
|
}
|
|
576
|
+
/// Encodes the event with its `type`.
|
|
359
577
|
public func encode(to encoder: Encoder) throws {
|
|
360
578
|
var container = encoder.container(keyedBy: Tag.self)
|
|
361
579
|
switch self {
|
|
362
580
|
case .input(let value):
|
|
363
581
|
try value.encode(to: encoder)
|
|
364
582
|
try container.encode("input", forKey: .type)
|
|
583
|
+
case .inputDropped(let value):
|
|
584
|
+
try value.encode(to: encoder)
|
|
585
|
+
try container.encode("input.dropped", forKey: .type)
|
|
365
586
|
case .messageStart(let value):
|
|
366
587
|
try value.encode(to: encoder)
|
|
367
588
|
try container.encode("message.start", forKey: .type)
|
|
@@ -410,13 +631,21 @@ public enum AppStreamContract {
|
|
|
410
631
|
}
|
|
411
632
|
}
|
|
412
633
|
}
|
|
634
|
+
/// What the app does about an error. A code outside Core's table has category `internal`.
|
|
413
635
|
public enum ErrorCategory: String, Codable, Sendable {
|
|
636
|
+
/// A network or Croche Cloud failure. Retry later; the input is kept.
|
|
414
637
|
case offline
|
|
638
|
+
/// Credit or allowance ran out. Tell the user; retrying after a top-up works.
|
|
415
639
|
case allowance
|
|
640
|
+
/// Usage is stopped by the project, an account or a rate limit. Wait, or contact the operator.
|
|
416
641
|
case paused
|
|
642
|
+
/// A developer fix is needed: key, config, model or device identity.
|
|
417
643
|
case setup
|
|
644
|
+
/// The work or the wait stopped; nothing to fix. An aborted wait can leave the input running.
|
|
418
645
|
case closed
|
|
646
|
+
/// The app's request cannot run as given.
|
|
419
647
|
case invalid
|
|
648
|
+
/// The work failed for a reason outside the app. Report it. A code outside Core's table is also `internal`.
|
|
420
649
|
case `internal`
|
|
421
650
|
}
|
|
422
651
|
static func errorCategory(_ code: String) -> ErrorCategory {
|
|
@@ -424,10 +653,10 @@ public enum AppStreamContract {
|
|
|
424
653
|
switch code {
|
|
425
654
|
case "offline", "network_error", "request_timeout", "gateway_unavailable", "invalid_cloud_response", "stale_control", "http_<status>": return .offline
|
|
426
655
|
case "account_credit_exhausted", "project_budget_exhausted", "user_allowance_exhausted", "development_allowance_exhausted", "unverified_allowance_exhausted", "gateway_key_exhausted", "provider_credit_unavailable": return .allowance
|
|
427
|
-
case "usage_paused", "runtime_blocked", "project_access_disabled", "account_disabled", "server_key_revoked", "
|
|
428
|
-
case "
|
|
429
|
-
case "outcome_unknown", "closed", "target_closed", "runtime_detached", "cancelled", "interrupted", "preempted", "aborted", "observation_lost", "store_busy", "instance_busy": return .closed
|
|
430
|
-
case "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": return .invalid
|
|
656
|
+
case "usage_paused", "runtime_blocked", "project_access_disabled", "account_disabled", "server_key_revoked", "development_key_revoked", "development_device_limit", "rate_limited", "provider_rate_limited": return .paused
|
|
657
|
+
case "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": return .setup
|
|
658
|
+
case "state_conflict", "outcome_unknown", "closed", "target_closed", "runtime_detached", "cancelled", "interrupted", "preempted", "aborted", "observation_lost", "store_busy", "instance_busy": return .closed
|
|
659
|
+
case "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": return .invalid
|
|
431
660
|
case "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": return .internal
|
|
432
661
|
default: return .internal
|
|
433
662
|
}
|