@h1r-ai/croche-react-native 0.5.5 → 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 +90 -451
- package/THIRD-PARTY-NOTICES +906 -14
- package/android/build.gradle +6 -1
- package/android/src/androidTest/java/dev/croche/reactnative/WikiFileBridgeTest.kt +126 -0
- package/android/src/main/AndroidManifest.xml +0 -5
- package/android/src/main/java/dev/croche/reactnative/CoreDispatch.kt +106 -0
- package/android/src/main/java/dev/croche/reactnative/CoreWire.kt +217 -0
- package/android/src/main/java/dev/croche/reactnative/CrocheRuntimeModule.kt +48 -824
- package/android/src/main/java/dev/croche/reactnative/NativePal.kt +68 -0
- package/android/src/main/java/dev/croche/reactnative/RNHostPal.kt +9 -0
- package/android/src/test/java/dev/croche/reactnative/AgentMemoryTest.kt +64 -41
- package/android/src/test/java/dev/croche/reactnative/BackgroundDelegationTest.kt +64 -0
- 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 +44 -0
- package/android/src/test/java/dev/croche/reactnative/ProjectAttestationTest.kt +19 -32
- package/android/src/test/java/dev/croche/reactnative/ProjectHandlerStagesTest.kt +32 -0
- package/android/src/test/java/dev/croche/reactnative/ProjectRecoveryTest.kt +12 -0
- package/android/src/test/java/dev/croche/reactnative/ProjectTimeZoneTest.kt +11 -15
- 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/AndroidEventSink.kt +27 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/AndroidPlatform.kt +10 -8
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BackgroundRegistration.kt +16 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BackgroundWakeWorker.kt +55 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapDecodedImageCodec.kt +162 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapImageCodec.kt +1 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapImageInput.kt +15 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapOrientation.kt +40 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapPalCodec.kt +66 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidAssetPal.kt +30 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidCoreFactory.kt +35 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidCoreHost.kt +116 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidMainDispatcher.kt +17 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidPublicPlatform.kt +17 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidS2Pal.kt +14 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidStateStore.kt +216 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidStoragePal.kt +108 -0
- package/android/vendor/CrocheRuntimeSDK/consumer-rules.pro +8 -2
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Adapters.kt +75 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/BindingFacts.kt +29 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ContextConfig.kt +31 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Core.kt +25 -1
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Croche.kt +121 -103
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheAgent.kt +89 -103
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheRuntime.kt +20 -360
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheTools.kt +136 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Decision.kt +170 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/DecodedImageCodec.kt +23 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Effects.kt +26 -21
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/EncodedImageCodec.kt +51 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/GeneratedAppStream.kt +715 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Host.kt +9 -322
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ImagePal.kt +183 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Images.kt +16 -28
- 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 +294 -37
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/PublicResults.kt +127 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ReaderValues.kt +73 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/RunTool.kt +73 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/SendEncoding.kt +23 -21
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StateStore.kt +90 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/SubscriptionTypes.kt +88 -24
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ffi/croche_ffi.kt +5723 -3088
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/AppEventSink.kt +34 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/AppStoragePal.kt +96 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/BackgroundOsRegistration.kt +35 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/BackgroundSink.kt +37 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreDefinitionCalls.kt +35 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreFactoryCalls.kt +30 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreOptionsEncoding.kt +41 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreStreamCalls.kt +35 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ForeignCallbacks.kt +127 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ImageAdapterHost.kt +28 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmCoreHost.kt +70 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmStateStore.kt +125 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmStoragePal.kt +64 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/LifecycleBinding.kt +18 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/NativeCoreInitialization.kt +21 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/NativePlatform.kt +60 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/PalCallbacks.kt +27 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/PlainToolJson.kt +56 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/PublicCalls.kt +43 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ScopeJson.kt +29 -0
- 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/ToolCompletionEncoding.kt +29 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/AtomicKeyFiles.kt +100 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/BlobFiles.kt +157 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/DirectHttpPal.kt +223 -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/package.json +1 -0
- package/dist/react-native/src/NativeCrocheRuntime.d.ts +16 -0
- package/dist/react-native/src/NativeCrocheRuntime.js +2 -0
- package/dist/react-native/src/core-native.d.ts +6 -0
- package/dist/react-native/src/core-native.js +316 -0
- package/dist/react-native/src/core-wire.d.ts +55 -0
- package/dist/react-native/src/core-wire.js +1 -0
- package/dist/react-native/src/native-module.d.ts +8 -0
- package/dist/react-native/src/native-module.js +53 -0
- package/dist/rn-shared-build.json +16 -0
- package/dist/runtime/src/adapters.d.ts +8 -0
- package/dist/runtime/src/adapters.js +29 -0
- package/dist/runtime/src/agent.d.ts +91 -0
- package/dist/runtime/src/agent.js +137 -0
- package/dist/runtime/src/app-api.d.ts +572 -0
- package/dist/runtime/src/app-api.js +1 -0
- package/dist/runtime/src/cancel.d.ts +9 -0
- package/dist/runtime/src/cancel.js +27 -0
- 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 +247 -0
- package/dist/runtime/src/core/port.js +1 -0
- 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/core/wasm.d.ts +1 -0
- package/dist/runtime/src/core/wasm.js +2 -0
- package/dist/runtime/src/croche.d.ts +97 -0
- package/dist/runtime/src/croche.js +172 -0
- package/dist/runtime/src/errors.d.ts +33 -0
- package/dist/runtime/src/errors.js +63 -0
- package/dist/runtime/src/events.d.ts +5 -0
- package/dist/runtime/src/events.js +31 -0
- package/dist/runtime/src/generated/app-stream.d.ts +328 -0
- package/dist/runtime/src/generated/app-stream.js +127 -0
- 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 -0
- package/dist/runtime/src/index.native.js +2 -0
- package/dist/runtime/src/json.d.ts +13 -0
- package/dist/runtime/src/json.js +120 -0
- package/dist/runtime/src/native-adapter.d.ts +3 -0
- package/dist/runtime/src/native-adapter.js +30 -0
- package/dist/runtime/src/pal/host.d.ts +5 -0
- package/dist/runtime/src/pal/host.js +60 -0
- package/dist/runtime/src/pal/platform.d.ts +21 -0
- package/dist/runtime/src/pal/platform.js +7 -0
- 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/rn-entry.d.ts +1 -0
- package/dist/runtime/src/rn-entry.js +4 -0
- package/dist/runtime/src/run-tool.d.ts +33 -0
- package/dist/runtime/src/run-tool.js +7 -0
- package/dist/runtime/src/tools.d.ts +35 -0
- package/dist/runtime/src/tools.js +94 -0
- package/ios/CoreAgentTransport.swift +14 -0
- package/ios/CoreDeliveryTransport.swift +58 -0
- package/ios/CoreNativePal.swift +98 -0
- package/ios/CorePlatformTransport.swift +44 -0
- package/ios/CoreWireDispatch.swift +122 -0
- package/ios/CoreWireSupport.swift +286 -0
- package/ios/CrocheRuntimeBridge.swift +34 -994
- package/ios/ProjectPal.swift +49 -0
- package/ios/RNCrocheRuntime.mm +18 -201
- package/ios/vendor/CrocheRuntimeSDK/AppBuildFacts.swift +112 -0
- package/ios/vendor/CrocheRuntimeSDK/BlobFiles.swift +124 -0
- package/ios/vendor/CrocheRuntimeSDK/ContextConfig.swift +60 -0
- package/ios/vendor/CrocheRuntimeSDK/DirectHTTP.swift +258 -0
- package/ios/vendor/CrocheRuntimeSDK/Effects.swift +17 -17
- package/ios/vendor/CrocheRuntimeSDK/EncodedImages.swift +85 -0
- package/ios/vendor/CrocheRuntimeSDK/FFIStreamPort.swift +26 -157
- package/ios/vendor/CrocheRuntimeSDK/GeneratedAppStream.swift +672 -0
- package/ios/vendor/CrocheRuntimeSDK/Host.swift +34 -371
- package/ios/vendor/CrocheRuntimeSDK/ImagePal.swift +410 -0
- package/ios/vendor/CrocheRuntimeSDK/Images.swift +10 -9
- package/ios/vendor/CrocheRuntimeSDK/InstancePayloadPurge.swift +88 -0
- package/ios/vendor/CrocheRuntimeSDK/JSON.swift +30 -14
- package/ios/vendor/CrocheRuntimeSDK/Offload.swift +24 -0
- package/ios/vendor/CrocheRuntimeSDK/OpenOptions.swift +1 -155
- package/ios/vendor/CrocheRuntimeSDK/Platform.swift +33 -59
- package/ios/vendor/CrocheRuntimeSDK/PlatformBackground.swift +289 -0
- package/ios/vendor/CrocheRuntimeSDK/PlatformPal.swift +302 -0
- package/ios/vendor/CrocheRuntimeSDK/PlatformStateStore.swift +253 -0
- package/ios/vendor/CrocheRuntimeSDK/PlatformStorage.swift +281 -0
- package/ios/vendor/CrocheRuntimeSDK/Project.swift +4 -269
- package/ios/vendor/CrocheRuntimeSDK/Runtime.swift +24 -461
- package/ios/vendor/CrocheRuntimeSDK/RuntimeHTTPAdapter.swift +42 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Adapters.swift +110 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Agent.swift +248 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Allowance.swift +20 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1BindingFacts.swift +33 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Core.swift +170 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Croche.swift +313 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Decision.swift +146 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Events.swift +37 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1HandleOwner.swift +58 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Options.swift +346 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1RunTool.swift +89 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Storage.swift +165 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1TestHooks.swift +100 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Tools.swift +278 -0
- 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 +23 -269
- package/ios/vendor/CrocheRuntimeSDK/SubscriptionTypes.swift +163 -116
- package/ios/vendor/CrocheRuntimeSDK/Truncate.swift +12 -0
- package/ios/vendor/CrocheRuntimeSDK/croche_ffi.swift +4712 -2469
- package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64/Headers/croche_ffiFFI.h +899 -608
- 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 +899 -608
- package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64_x86_64-simulator/libcroche_ffi.a +0 -0
- package/package.json +18 -8
- package/scripts/README.md +11 -0
- package/scripts/build-shared.mjs +46 -0
- package/scripts/build.mjs +11 -0
- package/scripts/check-swift-vendor-modules.sh +15 -0
- package/scripts/vendor-native.sh +8 -6
- package/src/NativeCrocheRuntime.ts +12 -159
- package/android/src/main/java/dev/croche/reactnative/AgentMemory.kt +0 -25
- package/android/src/main/java/dev/croche/reactnative/ProjectAttestation.kt +0 -17
- package/android/src/main/java/dev/croche/reactnative/ProjectTimeZone.kt +0 -14
- 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 -110
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Control.kt +0 -178
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeCoreStreamPort.kt +0 -173
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectBinding.kt +0 -79
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectPalRouting.kt +0 -25
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectPlatform.kt +0 -46
- 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/StreamHub.kt +0 -227
- package/ios/vendor/CrocheRuntimeSDK/Background.swift +0 -59
- package/ios/vendor/CrocheRuntimeSDK/Control.swift +0 -192
- package/ios/vendor/CrocheRuntimeSDK/StreamHub.swift +0 -453
- package/ios/vendor/CrocheRuntimeSDK/SubscriptionRuntime.swift +0 -38
- package/src/index.ts +0 -664
- package/src/project-types.ts +0 -35
- package/src/project.ts +0 -434
- package/src/protocol.ts +0 -28
- package/src/types.ts +0 -9
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h1r-ai/croche-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"license": "SEE LICENSE IN LICENSE",
|
|
8
8
|
"description": "Croche Runtime for React Native: the shared Rust Core through the native iOS and Android SDKs, with app attestation and Keychain/Keystore credentials.",
|
|
9
|
-
"main": "src/
|
|
10
|
-
"types": "src/
|
|
11
|
-
"react-native": "src/
|
|
9
|
+
"main": "dist/runtime/src/rn-entry.js",
|
|
10
|
+
"types": "dist/runtime/src/rn-entry.d.ts",
|
|
11
|
+
"react-native": "dist/runtime/src/rn-entry.js",
|
|
12
12
|
"files": [
|
|
13
|
-
"
|
|
13
|
+
"dist",
|
|
14
|
+
"src/NativeCrocheRuntime.ts",
|
|
14
15
|
"ios",
|
|
15
16
|
"android",
|
|
16
17
|
"scripts",
|
|
@@ -20,11 +21,11 @@
|
|
|
20
21
|
"THIRD-PARTY-NOTICES"
|
|
21
22
|
],
|
|
22
23
|
"peerDependencies": {
|
|
23
|
-
"@h1r-ai/croche": "0.
|
|
24
|
+
"@h1r-ai/croche": "0.7.0",
|
|
24
25
|
"react-native": ">=0.76"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@h1r-ai/croche": "0.
|
|
28
|
+
"@h1r-ai/croche": "0.7.0"
|
|
28
29
|
},
|
|
29
30
|
"codegenConfig": {
|
|
30
31
|
"name": "CrocheRuntimeSpec",
|
|
@@ -37,6 +38,15 @@
|
|
|
37
38
|
"scripts": {
|
|
38
39
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
39
40
|
"vendor:native": "scripts/vendor-native.sh",
|
|
40
|
-
"test": "vitest run --root ../.. packages/react-native/tests"
|
|
41
|
+
"test": "vitest run --root ../.. packages/react-native/tests",
|
|
42
|
+
"build": "node scripts/build.mjs",
|
|
43
|
+
"prepack": "npm run build"
|
|
44
|
+
},
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./dist/runtime/src/rn-entry.d.ts",
|
|
48
|
+
"react-native": "./dist/runtime/src/rn-entry.js",
|
|
49
|
+
"default": "./dist/runtime/src/rn-entry.js"
|
|
50
|
+
}
|
|
41
51
|
}
|
|
42
52
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# RN shared-facade build
|
|
2
|
+
|
|
3
|
+
`build-shared.mjs` compiles the canonical TypeScript facade from `packages/runtime/src` into the RN artifact. It does not keep an RN copy of those source files. Only `core/wasm.ts` is replaced. The native entry exports the same decision method and types; the optional Core capability forwards only through explicit native decide dispatch backed by host bridge acceptance. The RN entry selects the native platform and shared declarations; the public facade and tool brand use the same source.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
node packages/react-native/scripts/build-shared.mjs --adapter <native-adapter.ts> --out <empty-artifact-directory>
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The adapter is compiled at the shared source root and supplies `coreModule()` and `nativePlatform`, typed against `core/port.ts` and `pal/platform.ts`. It may import the RN native adapter through a relative path. The build records canonical source hashes, refuses a nonempty output, and refuses a dependency graph containing WASM. No additional `@h1r-ai/croche` package export is used.
|
|
10
|
+
|
|
11
|
+
The focused `app-five-scenarios.test.ts` build supplies an explicitly test-only adapter. Its fake Core is not the production adapter, and that fixture artifact must not ship. Native adapter registration and the public package entrypoint switch land together in the RN unit.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Compile the ONE TS facade into the RN artifact. Only the platform/core-loader
|
|
3
|
+
// modules differ. No new @h1r-ai/croche export and no WASM in the RN build.
|
|
4
|
+
import ts from 'typescript';
|
|
5
|
+
import {readFile,mkdir,writeFile,readdir} from 'node:fs/promises';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import {createHash} from 'node:crypto';
|
|
9
|
+
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'../../..');
|
|
10
|
+
const args=process.argv.slice(2),option=name=>{const i=args.indexOf(name);return i<0?undefined:args[i+1];};
|
|
11
|
+
const adapter=option('--adapter'),output=option('--out');
|
|
12
|
+
if(!adapter||!output)throw Error('Usage: build-shared.mjs --adapter <native adapter source> --out <RN artifact directory>');
|
|
13
|
+
const out=path.resolve(output),source=path.join(root,'packages/runtime/src');
|
|
14
|
+
try { if((await readdir(out)).length)throw Error('RN build output must be empty: '+out); }
|
|
15
|
+
catch(error){if(error.code!=='ENOENT')throw error;}
|
|
16
|
+
const adapterFile=path.resolve(adapter),adapterSource=await readFile(adapterFile,'utf8');
|
|
17
|
+
// The public facade is compiled unchanged. This RN entry selects the native PAL
|
|
18
|
+
// using the explicit native surface; only core/wasm.ts is replaced.
|
|
19
|
+
const nativeEntry="export * from './index.native.js';\nimport {usePlatform} from './pal/platform.js';\nimport {nativePlatform} from './native-adapter.js';\nusePlatform(nativePlatform);\n";
|
|
20
|
+
const virtual=new Map([
|
|
21
|
+
[path.join(source,'rn-entry.ts'),nativeEntry],
|
|
22
|
+
[path.join(source,'native-adapter.ts'),adapterSource],
|
|
23
|
+
[path.join(source,'core/wasm.ts'),"// Native Core transport selected at RN build time.\nexport {coreModule} from '../native-adapter.js'\n"],
|
|
24
|
+
]);
|
|
25
|
+
const options={target:ts.ScriptTarget.ES2022,module:ts.ModuleKind.ESNext,moduleResolution:ts.ModuleResolutionKind.Bundler,
|
|
26
|
+
strict:true,skipLibCheck:true,declaration:true,noEmitOnError:true,rootDir:path.join(root,'packages'),outDir:out,
|
|
27
|
+
baseUrl:root,paths:{'react-native':['packages/react-native/types/react-native.d.ts']}};
|
|
28
|
+
const host=ts.createCompilerHost(options),read=host.readFile.bind(host),exists=host.fileExists.bind(host),get=host.getSourceFile.bind(host);
|
|
29
|
+
host.fileExists=file=>virtual.has(path.resolve(file))||exists(file);
|
|
30
|
+
host.readFile=file=>virtual.get(path.resolve(file))??read(file);
|
|
31
|
+
host.getSourceFile=(file,languageVersion,onError,create)=>virtual.has(path.resolve(file))
|
|
32
|
+
?ts.createSourceFile(file,virtual.get(path.resolve(file)),languageVersion,true):get(file,languageVersion,onError,create);
|
|
33
|
+
const program=ts.createProgram([path.join(source,'rn-entry.ts')],options,host);
|
|
34
|
+
const diagnostics=ts.getPreEmitDiagnostics(program);
|
|
35
|
+
if(diagnostics.length){process.stderr.write(ts.formatDiagnosticsWithColorAndContext(diagnostics,{getCurrentDirectory:()=>root,getCanonicalFileName:x=>x,getNewLine:()=> '\n'}));process.exit(1);}
|
|
36
|
+
const result=program.emit();if(result.emitSkipped)throw Error('Shared RN emit skipped');
|
|
37
|
+
const forbidden=program.getSourceFiles().filter(file=>/[/\\](core-wasm|core-wasm-bytes|core-bindgen)\.ts$/.test(file.fileName));
|
|
38
|
+
if(forbidden.length)throw Error('RN facade imported WASM: '+forbidden.map(file=>file.fileName).join(', '));
|
|
39
|
+
const hashes={};
|
|
40
|
+
for(const file of ['index.native.ts','croche.ts','agent.ts','tools.ts','app-api.ts','json.ts','errors.ts','cancel.ts','core/port.ts']){
|
|
41
|
+
const bytes=await readFile(path.join(source,file));hashes[file]=createHash('sha256').update(bytes).digest('hex');
|
|
42
|
+
}
|
|
43
|
+
await mkdir(out,{recursive:true});await writeFile(path.join(out,'package.json'),JSON.stringify({type:'module'})+'\n');
|
|
44
|
+
const metadata={entry:'runtime/src/rn-entry.js',adapter:path.relative(root,adapterFile),sharedSources:hashes,wasm:false};
|
|
45
|
+
await writeFile(path.join(out,'rn-shared-build.json'),JSON.stringify(metadata,null,2)+'\n');
|
|
46
|
+
console.log(JSON.stringify({status:'PASS',entry:path.join(out,metadata.entry),wasm:false}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Only this package's generated dist is replaced. build-shared itself keeps its
|
|
3
|
+
// nonempty-output guard, so stale/foreign artifact directories are never reused.
|
|
4
|
+
import {rmSync} from 'node:fs';
|
|
5
|
+
import {execFileSync} from 'node:child_process';
|
|
6
|
+
import {fileURLToPath} from 'node:url';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
const directory=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
|
9
|
+
const out=path.join(directory,'dist');
|
|
10
|
+
rmSync(out,{recursive:true,force:true});
|
|
11
|
+
execFileSync(process.execPath,[path.join(directory,'scripts/build-shared.mjs'),'--adapter',path.join(directory,'src/shared-adapter.ts'),'--out',out],{stdio:'inherit'});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# CocoaPods compiles these SPM sources and bindings into a single RN module.
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
root=$(cd "$(dirname "$0")/../../.." && pwd)
|
|
5
|
+
sources=("$root/sdk/swift/Sources/CrocheRuntime")
|
|
6
|
+
bindings="$root/sdk/swift/Sources/CrocheFFI"
|
|
7
|
+
if [[ -d "$bindings" ]]; then sources+=("$bindings"); fi
|
|
8
|
+
if grep -rnE --include='*.swift' '(^|[^[:alnum:]_])(CrocheRuntime|CrocheFFI)[[:space:]]*\.' \
|
|
9
|
+
"${sources[@]}"; then
|
|
10
|
+
echo 'RN vendors these Swift sources into its own module. Call the SDK or binding helper unqualified.' >&2
|
|
11
|
+
exit 1
|
|
12
|
+
else
|
|
13
|
+
status=$?
|
|
14
|
+
if [[ $status != 1 ]]; then exit "$status"; fi
|
|
15
|
+
fi
|
package/scripts/vendor-native.sh
CHANGED
|
@@ -13,16 +13,15 @@ what=${1:-all}
|
|
|
13
13
|
if [[ $what == ios || $what == all ]]; then
|
|
14
14
|
work=$(mktemp -d)
|
|
15
15
|
CROCHE_SWIFT_OUTPUT="$work/out" "$root/sdk/swift/build-xcframework.sh"
|
|
16
|
+
bash "$package/scripts/check-swift-vendor-modules.sh"
|
|
16
17
|
rm -rf "$package/ios/vendor"; mkdir -p "$package/ios/vendor"
|
|
17
18
|
cp -R "$work/out/CrocheRuntime/croche_ffiFFI.xcframework" "$package/ios/vendor/"
|
|
18
19
|
cp -R "$root/sdk/swift/Sources/CrocheRuntime" "$package/ios/vendor/CrocheRuntimeSDK"
|
|
19
20
|
cp "$root/sdk/swift/Sources/CrocheFFI/croche_ffi.swift" "$package/ios/vendor/CrocheRuntimeSDK/"
|
|
20
21
|
# The pod compiles the SDK and its bindings into one module: no CrocheFFI module to import.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
echo 'The SDK names the CrocheFFI module; the pod has none. Call the binding unqualified.' >&2; exit 1
|
|
25
|
-
fi
|
|
22
|
+
# Recursive: the App API sources live in a subfolder (S1/).
|
|
23
|
+
find "$package/ios/vendor/CrocheRuntimeSDK" -name '*.swift' -exec sed -i.bak '/^import CrocheFFI$/d' {} +
|
|
24
|
+
find "$package/ios/vendor/CrocheRuntimeSDK" -name '*.bak' -delete
|
|
26
25
|
rm -rf "$work"
|
|
27
26
|
echo "iOS: ios/vendor/croche_ffiFFI.xcframework and ios/vendor/CrocheRuntimeSDK ready; run pod install."
|
|
28
27
|
fi
|
|
@@ -33,6 +32,9 @@ if [[ $what == android || $what == all ]]; then
|
|
|
33
32
|
for target in aarch64-linux-android armv7-linux-androideabi x86_64-linux-android; do
|
|
34
33
|
rustup target list --installed | grep -Fxq "$target" || { echo "rustup target add $target" >&2; exit 1; }
|
|
35
34
|
done
|
|
35
|
+
"$root/sdk/kotlin/generate-bindings.sh"
|
|
36
|
+
bindings="$root/sdk/kotlin/src/main/kotlin/dev/croche/ffi/croche_ffi.kt"
|
|
37
|
+
[[ -s "$bindings" ]] || { echo "Missing Android Kotlin bindings: $bindings" >&2; exit 1; }
|
|
36
38
|
rm -rf "$package/android/vendor"; mkdir -p "$package/android/vendor/CrocheRuntimeSDK"
|
|
37
39
|
# The Android SDK sources (sdk/kotlin, with its UniFFI bindings) are compiled into the bridge
|
|
38
40
|
# module; Gradle cannot reach sdk/ from node_modules, so they ship inside the package.
|
|
@@ -47,7 +49,7 @@ if [[ $what == android || $what == all ]]; then
|
|
|
47
49
|
# extracts for crash symbolication before it strips the APK's copy (Atlas, #213). Keep it so.
|
|
48
50
|
nm=$(ls "$ANDROID_NDK_HOME"/toolchains/llvm/prebuilt/*/bin/llvm-nm | head -1)
|
|
49
51
|
for so in "$package/android/vendor/jniLibs/"*/libcroche_ffi.so; do
|
|
50
|
-
"$nm" "$so" | grep -
|
|
52
|
+
"$nm" "$so" | grep -cE '11croche_core.*4Core5admit' >/dev/null || { echo "$so lost its symbol table (Core::admit)" >&2; exit 1; }
|
|
51
53
|
done
|
|
52
54
|
for abi in arm64-v8a armeabi-v7a x86_64; do
|
|
53
55
|
[[ -f "$package/android/vendor/jniLibs/$abi/libcroche_ffi.so" ]] || { echo "Missing libcroche_ffi.so for $abi" >&2; exit 1; }
|
|
@@ -1,162 +1,15 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { TurboModuleRegistry } from 'react-native';
|
|
7
|
-
|
|
1
|
+
// Private S1 transport. Core owns all handles, validation, scheduling and events.
|
|
2
|
+
// React Native codegen reads this file; JSON is opaque at this boundary.
|
|
3
|
+
import type {TurboModule} from 'react-native';
|
|
4
|
+
import {TurboModuleRegistry} from 'react-native';
|
|
5
|
+
export type OwnedImage = {element:number; bytes:ReadonlyArray<number>};
|
|
8
6
|
export interface Spec extends TurboModule {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
open(handle: string, configJson: string, optionsJson: string): Promise<string>;
|
|
17
|
-
/**
|
|
18
|
-
* Resolves the TurnResult JSON. Several sends may be in flight per handle. `responseFormatJson`:
|
|
19
|
-
* the structured-output format, or "null" for none. `callId` names this call, unique per handle:
|
|
20
|
-
* a retry of the same input id is another call, with its own cancellation.
|
|
21
|
-
*/
|
|
22
|
-
send(handle: string, inputJson: string, responseFormatJson: string, callId: string): Promise<string>;
|
|
23
|
-
/**
|
|
24
|
-
* Stops the handle's running turn only; sends held behind it still run, together, as the next
|
|
25
|
-
* turn. The running send's promise still resolves with the outcome.
|
|
26
|
-
*/
|
|
27
|
-
cancel(handle: string): void;
|
|
28
|
-
/**
|
|
29
|
-
* Cancels one send call: held, it is dropped; running, its turn stops (a turn several sends
|
|
30
|
-
* share stops for all of them). A call not yet registered natively is remembered and starts
|
|
31
|
-
* cancelled, so an abort right after `send` is never lost.
|
|
32
|
-
*/
|
|
33
|
-
cancelSend(handle: string, callId: string): void;
|
|
34
|
-
/** Drops the sends held behind the running turn (each ends `cancelled`); resolves how many. */
|
|
35
|
-
clearQueued(handle: string): Promise<number>;
|
|
36
|
-
inspect(handle: string): Promise<string>;
|
|
37
|
-
/**
|
|
38
|
-
* One round of background upkeep (deliver call reports, then sync). The native SDK also
|
|
39
|
-
* runs it by itself after each turn and on a timer; call it when the app returns to the
|
|
40
|
-
* foreground. Resolves the MaintenanceResult JSON. Never delays a send.
|
|
41
|
-
*/
|
|
42
|
-
maintain(handle: string, force: boolean): Promise<string>;
|
|
43
|
-
/**
|
|
44
|
-
* The platform SDK's `deliverDue()`: the agent's scheduled notes that are due, as one turn.
|
|
45
|
-
* Resolves `{ran: false}` (none due, or one being delivered: `inFlight`) or
|
|
46
|
-
* `{ran, ids, delivered, turn}` JSON.
|
|
47
|
-
*/
|
|
48
|
-
deliverDue(handle: string): Promise<string>;
|
|
49
|
-
/** The platform SDK's `schedules()`: `{pending: [{id, at, note}], due}` JSON. */
|
|
50
|
-
schedules(handle: string): Promise<string>;
|
|
51
|
-
/**
|
|
52
|
-
* Asks Cloud to raise (`absolute` false) or set (`absolute` true) this user's allowance
|
|
53
|
-
* within the project's ceilings. `id` ("" for none) makes a retry safe: Cloud applies an
|
|
54
|
-
* id once. Resolves the BudgetAdjustment JSON.
|
|
55
|
-
*/
|
|
56
|
-
adjustBudget(handle: string, amount: number, absolute: boolean, id: string): Promise<string>;
|
|
57
|
-
/**
|
|
58
|
-
* Replaces the tool list: `toolsJson` is tool metadata as in `open`'s config (no callbacks;
|
|
59
|
-
* JavaScript keeps the handlers). Rejects, changing nothing, when the Core refuses the list.
|
|
60
|
-
*/
|
|
61
|
-
setTools(handle: string, toolsJson: string): Promise<void>;
|
|
62
|
-
/** Starts a new session: forgets history and memory, keeps money and identity. */
|
|
63
|
-
clearHistory(handle: string): Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* One wiki operation on the platform SDK's `runtime.wiki`, as JSON both ways:
|
|
66
|
-
* `set` {docs} → digest; `put` {docs} → null; `remove` {path} → boolean; `list` {folder?}
|
|
67
|
-
* → entries; `read` {path, part} → page or null; `search` {query, limit} → hits;
|
|
68
|
-
* `putUser` {docs} → {documents, bytes}; `removeUser` {path} → boolean; `clearUser` {} →
|
|
69
|
-
* count; `bundled` {folder} → the documents shipped in the app (iOS bundle folder, Android
|
|
70
|
-
* assets), with `handle` unused. Docs are [{path, markdown, agents?}].
|
|
71
|
-
*/
|
|
72
|
-
wiki(handle: string, op: string, argsJson: string): Promise<string>;
|
|
73
|
-
/**
|
|
74
|
-
* One operation on the platform SDK's `runtime.memory`, as JSON both ways: `list` {} → items;
|
|
75
|
-
* `delete` {id} → {deleted}; `clear` {} → {cleared};
|
|
76
|
-
* `enabled` {on} → null; `export` {} → {enabled, items}; `observe` {on} → null,
|
|
77
|
-
* attaching (or removing) the SDK's onChanged so each change arrives as a `memoryChanged`
|
|
78
|
-
* message.
|
|
79
|
-
*/
|
|
80
|
-
memory(handle: string, op: string, argsJson: string): Promise<string>;
|
|
81
|
-
close(handle: string): Promise<void>;
|
|
82
|
-
/** Answers a `tool` event. When `ok`, `resultJson` is `{value, images?, imageResolution?}`:
|
|
83
|
-
* the images beside the value (H3). Otherwise `{code}`, set by this bridge alone:
|
|
84
|
-
* `tool_not_dispatched` (no handler ran), `invalid_tool_result` (it ran and returned something
|
|
85
|
-
* unreadable: that call fails alone) or `effect_failed` (the handler threw). */
|
|
86
|
-
resolveTool(callId: string, ok: boolean, resultJson: string): void;
|
|
87
|
-
// The project API (Keel #339 6093822222: RN mirrors TS `Croche` / `CrocheAgent`). A thin
|
|
88
|
-
// binding of the FFI's `CoreProject` (#377): `project` names one open project, and each
|
|
89
|
-
// agent it opens is an FFI `CoreRuntime` under its own `handle`, which every per-agent method
|
|
90
|
-
// below (and `clearHistory`, `close`, `resolveTool`) takes. The native side builds the
|
|
91
|
-
// `HostPalFactory` from its platform SDK's PAL pieces (storage, HTTP, tools, attestation).
|
|
92
|
-
// JavaScript runs the TypeScript SDK's StreamHub over the stream port, so subscriptions
|
|
93
|
-
// behave as in TypeScript. Every callback arrives as a `CrocheRuntimeEvent` NativeMessage
|
|
94
|
-
// (protocol.ts: {handle, type, json}) emitted from ONE serial queue per handle, in the order
|
|
95
|
-
// the Core called it: observe events, projection events and readOutcome's capture share that
|
|
96
|
-
// order (the hub relies on it). Tool calls use the existing `tool`/`toolCancel` messages and
|
|
97
|
-
// `resolveTool`, with the Core's tool context passed through unchanged.
|
|
98
|
-
/**
|
|
99
|
-
* `Croche.open`. `optionsJson`: `{host, user?, config, handlers, language?, streaming,
|
|
100
|
-
* backgroundSync, maintenanceIntervalMs}` as the FFI's `ProjectOpenOptions` (host and config
|
|
101
|
-
* as JSON values, not text), plus RN host choices `attestation` ("platform" | "off"),
|
|
102
|
-
* `android.cloudProjectNumber`. Usage arrives as `{handle: project, type: "usage", json}`.
|
|
103
|
-
* Resolves `projectInfo`'s JSON. Rejects with the Core's code; nothing stays open.
|
|
104
|
-
*/
|
|
105
|
-
projectOpen(project: string, optionsJson: string): Promise<string>;
|
|
106
|
-
/** Synchronous (in-memory getters): `{user, installationId, crocheUserId, agentIds, applied}`. */
|
|
107
|
-
// Sync getters (projectInfo, agentState) either throw a coded error or return {"error":{"code","message"}}.
|
|
108
|
-
projectInfo(project: string): string;
|
|
109
|
-
/** `Croche.deleteStore` (R8): `optionsJson` is `{host, user?, config, agent?}`, as TypeScript's wire. */
|
|
110
|
-
projectDeleteStore(optionsJson: string): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* `croche.agent(id?, {instance?, fresh?, config?})` (#406): opens (or returns again) that agent
|
|
113
|
-
* as `handle`; `id` "" is the default agent, `optionsJson` `{instance?, fresh?, config?}`.
|
|
114
|
-
* Resolves `{id, name, mode, visibleTools, logId, instance, created}`. Rejects with the Core's
|
|
115
|
-
* code (override mismatch, closed).
|
|
116
|
-
*/
|
|
117
|
-
projectAgent(project: string, handle: string, id: string, optionsJson: string): Promise<string>;
|
|
118
|
-
/** Closes every agent of the project, then the project. */
|
|
119
|
-
projectClose(project: string): Promise<void>;
|
|
120
|
-
/**
|
|
121
|
-
* One agent control, JSON both ways: `setTools` {visible: string[] | null} → null; `setMode`
|
|
122
|
-
* {mode: string | null} → null; `sync` {} → null.
|
|
123
|
-
*/
|
|
124
|
-
agentControl(handle: string, op: string, argsJson: string): Promise<string>;
|
|
125
|
-
/** Synchronous (in-memory getters): `{id, name, mode, visibleTools, closed}`. */
|
|
126
|
-
agentState(handle: string): string;
|
|
127
|
-
/**
|
|
128
|
-
* Starts the agent's one observation: type `observe` (json: the Core event) per event, then one
|
|
129
|
-
* `observeEnd` (json: the Core error, or "null"). Rejects with the
|
|
130
|
-
* Core's code (for example `invalid_configuration` when observed already), observing nothing.
|
|
131
|
-
*/
|
|
132
|
-
observe(handle: string): Promise<void>;
|
|
133
|
-
unobserve(handle: string): void;
|
|
134
|
-
/**
|
|
135
|
-
* Opens a projection, `selectionJson` `{"initialMessages": n}` or `{"after": {logId, seq}}`.
|
|
136
|
-
* Resolves its id; each event arrives as type `projection`, json `{"projection": id, "event": …}`.
|
|
137
|
-
*/
|
|
138
|
-
select(handle: string, selectionJson: string): Promise<number>;
|
|
139
|
-
closeProjection(handle: string, projection: number): void;
|
|
140
|
-
/** Places one history page (`before` -1: from the loaded edge); the page arrives on the projection. */
|
|
141
|
-
history(handle: string, projection: number, before: number, limit: number): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* The retained ends of input `id` from `fromSeq`. The capture is emitted, in order, as type
|
|
144
|
-
* `captured`, json `{"readId": …, "state": …}`, before this resolves `{messages, gap?}` JSON;
|
|
145
|
-
* JavaScript waits for both.
|
|
146
|
-
*/
|
|
147
|
-
readOutcome(handle: string, id: string, fromSeq: number, readId: string): Promise<string>;
|
|
148
|
-
/**
|
|
149
|
-
* The receipt send: resolves `{id, status, seq}` JSON once the input is accepted. `cancelSend`
|
|
150
|
-
* with this `callId` applies before acceptance only.
|
|
151
|
-
*/
|
|
152
|
-
sendReceipt(handle: string, inputJson: string, responseFormatJson: string, callId: string): Promise<string>;
|
|
153
|
-
/** Core `cancel(id)`: resolves once durable; rejects `unknown_id` or `closed`. */
|
|
154
|
-
cancelInput(handle: string, id: string): Promise<void>;
|
|
155
|
-
/** Core `cancel_turn`: stops the running turn at the call (FFI #397 returns at once). */
|
|
156
|
-
cancelTurn(handle: string): Promise<void>;
|
|
157
|
-
/** Emitter bookkeeping for the `CrocheRuntimeEvent` stream. */
|
|
158
|
-
addListener(eventName: string): void;
|
|
159
|
-
removeListeners(count: number): void;
|
|
7
|
+
coreCall(handle:string, method:string, argsJson:string, images:ReadonlyArray<OwnedImage>):Promise<string>;
|
|
8
|
+
coreCallSync(handle:string, method:string, argsJson:string):string;
|
|
9
|
+
coreReply(call:string, completionJson:string):void;
|
|
10
|
+
platformCall(method:string, argsJson:string):Promise<string>;
|
|
11
|
+
platformCallSync(method:string, argsJson:string):string;
|
|
12
|
+
addListener(eventName:string):void;
|
|
13
|
+
removeListeners(count:number):void;
|
|
160
14
|
}
|
|
161
|
-
|
|
162
15
|
export default TurboModuleRegistry.getEnforcing<Spec>('CrocheRuntime');
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package dev.croche.reactnative
|
|
2
|
-
|
|
3
|
-
import com.google.gson.JsonObject
|
|
4
|
-
import dev.croche.CrocheException
|
|
5
|
-
import dev.croche.ffi.CoreRuntimeInterface
|
|
6
|
-
import dev.croche.ffi.EventListener
|
|
7
|
-
import dev.croche.keepAttached
|
|
8
|
-
|
|
9
|
-
/** Agent entries own an FFI CoreRuntime, rather than the legacy SDK Runtime wrapper. */
|
|
10
|
-
internal fun agentMemory(core: CoreRuntimeInterface, op: String, args: JsonObject, changed: (String) -> Unit): String = when (op) {
|
|
11
|
-
"list" -> core.memoryList()
|
|
12
|
-
"set" -> throw CrocheException("invalid_memory", "memory.set was removed: only the AI writes memories.")
|
|
13
|
-
"delete" -> core.memoryDelete(args.get("id")?.takeIf { it.isJsonPrimitive }?.asString ?: "")
|
|
14
|
-
"clear" -> core.memoryClear()
|
|
15
|
-
"enabled" -> core.memorySetEnabled(args.get("on")?.takeIf { it.isJsonPrimitive && it.asJsonPrimitive.isBoolean }?.asBoolean == true)
|
|
16
|
-
"export" -> core.memoryExport()
|
|
17
|
-
"observe" -> {
|
|
18
|
-
val on = args.get("on")?.takeIf { it.isJsonPrimitive && it.asJsonPrimitive.isBoolean }?.asBoolean == true
|
|
19
|
-
core.setMemoryObserver(if (on) object : EventListener {
|
|
20
|
-
override fun onEvent(event: String) { keepAttached(); changed(event) }
|
|
21
|
-
} else null)
|
|
22
|
-
"null"
|
|
23
|
-
}
|
|
24
|
-
else -> throw CrocheException("invalid_memory", "Unknown memory operation $op")
|
|
25
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
package dev.croche.reactnative
|
|
2
|
-
|
|
3
|
-
import com.google.gson.JsonObject
|
|
4
|
-
import dev.croche.RuntimeAttestor
|
|
5
|
-
|
|
6
|
-
/** The project's attestor, shared by its agents: Play Integrity when the app gave its Cloud
|
|
7
|
-
* project number and did not turn attestation off; otherwise none (unverified). */
|
|
8
|
-
internal fun projectAttestor(options: JsonObject, playIntegrity: (Long) -> RuntimeAttestor): RuntimeAttestor? {
|
|
9
|
-
val number = options.getAsJsonObject("android")?.get("cloudProjectNumber")?.asLong
|
|
10
|
-
return if (options.get("attestation")?.asString != "off" && number != null) playIntegrity(number) else null
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** The host fields Core receives. They name the platform only when there is an attestor, as
|
|
14
|
-
* CrocheRuntime.create does: otherwise no agent asks to attest and every install registers
|
|
15
|
-
* unverified (sdk-internal #24). */
|
|
16
|
-
internal fun projectHost(options: JsonObject, attestor: RuntimeAttestor?): JsonObject =
|
|
17
|
-
options.getAsJsonObject("host").deepCopy().apply { attestor?.let { addProperty("attestationPlatform", it.platform) } }
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
package dev.croche.reactnative
|
|
2
|
-
|
|
3
|
-
import com.google.gson.JsonObject
|
|
4
|
-
import dev.croche.CrocheException
|
|
5
|
-
import dev.croche.projectTimeZone
|
|
6
|
-
import java.util.TimeZone
|
|
7
|
-
|
|
8
|
-
/** Parse before CoreProject.open; never silently fall back to GMT for an unknown zone. */
|
|
9
|
-
internal fun projectZone(options: JsonObject): TimeZone? =
|
|
10
|
-
projectTimeZone(options.get("timeZone")?.takeUnless { it.isJsonNull }?.let {
|
|
11
|
-
if (!it.isJsonPrimitive || !it.asJsonPrimitive.isString)
|
|
12
|
-
throw CrocheException("invalid_configuration", "timeZone must be an IANA time zone")
|
|
13
|
-
it.asString
|
|
14
|
-
})
|
package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/CrocheProjectRecordProvider.kt
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
package dev.croche.android
|
|
2
|
-
|
|
3
|
-
import android.content.ContentProvider
|
|
4
|
-
import android.content.ContentValues
|
|
5
|
-
import android.database.Cursor
|
|
6
|
-
import android.net.Uri
|
|
7
|
-
import java.io.File
|
|
8
|
-
|
|
9
|
-
/** Internal Android startup hook: the install's records use filesDir, regardless of its stores. */
|
|
10
|
-
internal class CrocheProjectRecordProvider : ContentProvider() {
|
|
11
|
-
override fun onCreate(): Boolean {
|
|
12
|
-
app = context?.applicationContext
|
|
13
|
-
location = app?.filesDir
|
|
14
|
-
return true
|
|
15
|
-
}
|
|
16
|
-
override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? = null
|
|
17
|
-
override fun getType(uri: Uri): String? = null
|
|
18
|
-
override fun insert(uri: Uri, values: ContentValues?): Uri? = null
|
|
19
|
-
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int = 0
|
|
20
|
-
override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?): Int = 0
|
|
21
|
-
|
|
22
|
-
companion object {
|
|
23
|
-
@Volatile private var app: android.content.Context? = null
|
|
24
|
-
@Volatile private var location: File? = null
|
|
25
|
-
@JvmStatic fun directory(): File? = location
|
|
26
|
-
@JvmStatic fun language(): String = android.os.LocaleList.getDefault()[0].toLanguageTag()
|
|
27
|
-
@JvmStatic fun secretStorage(name: String): dev.croche.RuntimeSecretStore =
|
|
28
|
-
KeystoreSecretStore(checkNotNull(app) { "Croche startup provider is not initialized" }, name)
|
|
29
|
-
@JvmStatic fun attestor(number: Long): dev.croche.RuntimeAttestor =
|
|
30
|
-
PlayIntegrityAttestor(checkNotNull(app) { "Croche startup provider is not initialized" }, number)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
package dev.croche.android
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.app.Application
|
|
5
|
-
import android.content.Context
|
|
6
|
-
import android.os.Bundle
|
|
7
|
-
import androidx.work.Constraints
|
|
8
|
-
import androidx.work.Data
|
|
9
|
-
import androidx.work.NetworkType
|
|
10
|
-
import androidx.work.OneTimeWorkRequestBuilder
|
|
11
|
-
import androidx.work.WorkInfo
|
|
12
|
-
import androidx.work.WorkManager
|
|
13
|
-
import androidx.work.Worker
|
|
14
|
-
import androidx.work.WorkerParameters
|
|
15
|
-
import dev.croche.CrocheException
|
|
16
|
-
import dev.croche.CrocheRuntime
|
|
17
|
-
import dev.croche.RuntimeCancellation
|
|
18
|
-
import dev.croche.RuntimeScheduler
|
|
19
|
-
import java.util.concurrent.TimeUnit
|
|
20
|
-
|
|
21
|
-
// The agent's scheduled notes on Android while the app is not running (founder 17:14Z): one
|
|
22
|
-
// waiting WorkManager request per Runtime, at the earliest note. Inexact: WorkManager runs it at
|
|
23
|
-
// or after its delay, when the device allows (Doze, App Standby buckets), with network. No exact
|
|
24
|
-
// alarms, no notifications, no permissions, no manifest entries.
|
|
25
|
-
// CI compiles it in the AAR job, and runs the scheduler against the real WorkManager on an
|
|
26
|
-
// emulator (examples/android-aar-sample, WorkManagerSchedulerTest); a delivery run needs a device.
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Registers the earliest pending note as one `OneTimeWorkRequest`, tagged with `name`, whose
|
|
30
|
-
* worker runs `deliverDue()`. Pass it to `CrocheRuntime.create(..., scheduler = ...)`, and call
|
|
31
|
-
* `WorkManagerScheduler.install(application, name)` once in `Application.onCreate` so a run can
|
|
32
|
-
* reach that Runtime.
|
|
33
|
-
*
|
|
34
|
-
* A registration replaces only requests that are still waiting: it never cancels a run in
|
|
35
|
-
* progress, so a run that re-registers what is left (or whose delivery changes the pending set)
|
|
36
|
-
* never stops itself (rook, #323 A). Each Runtime uses its own `name`, and its runs deliver
|
|
37
|
-
* through the Runtime installed for that name; a second open Runtime with the same name is
|
|
38
|
-
* refused (`scheduler_conflict`), including a second Runtime given this same object.
|
|
39
|
-
*/
|
|
40
|
-
class WorkManagerScheduler(context: Context, val name: String = DEFAULT_NAME) : RuntimeScheduler {
|
|
41
|
-
private val context = context.applicationContext
|
|
42
|
-
|
|
43
|
-
override fun schedule(earliestAtMs: Long) = synchronized(lockFor(name)) {
|
|
44
|
-
val manager = manager()
|
|
45
|
-
val request = OneTimeWorkRequestBuilder<CrocheDeliveryWorker>()
|
|
46
|
-
.setInitialDelay((earliestAtMs - System.currentTimeMillis()).coerceAtLeast(0), TimeUnit.MILLISECONDS)
|
|
47
|
-
.setConstraints(Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build())
|
|
48
|
-
.setInputData(Data.Builder().putString(KEY_NAME, name).build())
|
|
49
|
-
.addTag(tag(name))
|
|
50
|
-
.build()
|
|
51
|
-
withdrawWaiting(manager)
|
|
52
|
-
manager.enqueue(request)
|
|
53
|
-
Unit
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
override fun cancel() = synchronized(lockFor(name)) { withdrawWaiting(manager()) }
|
|
57
|
-
|
|
58
|
-
/** One open Runtime per name, this scheduler object included: `create` attaches once per
|
|
59
|
-
* Runtime, so a second attach while the name is held (by another object, or by this one for
|
|
60
|
-
* another open Runtime) is refused (Atlas, #323 at dc38bf0). Close-and-reuse stays valid. */
|
|
61
|
-
override fun attach() = claims.claim(name, this)
|
|
62
|
-
|
|
63
|
-
override fun detach() = claims.release(name, this)
|
|
64
|
-
|
|
65
|
-
/** Cancels this name's requests that are waiting (enqueued, or blocked), never one that runs. */
|
|
66
|
-
private fun withdrawWaiting(manager: WorkManager) {
|
|
67
|
-
val infos = try { manager.getWorkInfosByTag(tag(name)).get() } catch (_: Exception) { emptyList() }
|
|
68
|
-
for (id in waiting(infos.map { it.id to it.state })) manager.cancelWorkById(id)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private fun manager(): WorkManager = try { WorkManager.getInstance(context) }
|
|
72
|
-
// The app turned WorkManager's initializer off without providing a Configuration.
|
|
73
|
-
catch (_: IllegalStateException) { throw CrocheException("not_configured", "WorkManager is not initialized in this app") }
|
|
74
|
-
|
|
75
|
-
companion object {
|
|
76
|
-
const val DEFAULT_NAME = "croche.schedule"
|
|
77
|
-
internal const val KEY_NAME = "dev.croche.schedule.name"
|
|
78
|
-
private val claims = dev.croche.SchedulerClaims("WorkManager name")
|
|
79
|
-
private val locks = java.util.concurrent.ConcurrentHashMap<String, Any>()
|
|
80
|
-
private fun lockFor(name: String) = locks.getOrPut(name) { Any() }
|
|
81
|
-
internal val providers = java.util.concurrent.ConcurrentHashMap<String, (Context) -> CrocheRuntime?>()
|
|
82
|
-
|
|
83
|
-
/** The tag that marks `name`'s requests. */
|
|
84
|
-
fun tag(name: String) = "dev.croche.schedule:$name"
|
|
85
|
-
|
|
86
|
-
/** Of these requests, the ones a registration may cancel: those still waiting. Never a
|
|
87
|
-
* running one, which may be the very run registering. */
|
|
88
|
-
fun <T> waiting(requests: List<Pair<T, WorkInfo.State>>): List<T> =
|
|
89
|
-
requests.filter { (_, state) -> state == WorkInfo.State.ENQUEUED || state == WorkInfo.State.BLOCKED }.map { it.first }
|
|
90
|
-
|
|
91
|
-
/** What `name`'s WorkManager runs deliver through: the app's Runtime, opened if need be,
|
|
92
|
-
* or null when there is none to reach (the run ends; the next open delivers). A run never
|
|
93
|
-
* closes it. */
|
|
94
|
-
fun deliverThrough(name: String = DEFAULT_NAME, runtime: (Context) -> CrocheRuntime?) { providers[name] = runtime }
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* `deliverThrough(name, runtime)`, and a delivery at each return to the foreground (the
|
|
98
|
-
* first activity started), off the main thread. Call once per name in
|
|
99
|
-
* `Application.onCreate`.
|
|
100
|
-
*/
|
|
101
|
-
fun install(application: Application, name: String = DEFAULT_NAME, runtime: (Context) -> CrocheRuntime) {
|
|
102
|
-
deliverThrough(name, runtime)
|
|
103
|
-
application.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks {
|
|
104
|
-
private var started = 0
|
|
105
|
-
override fun onActivityStarted(activity: Activity) {
|
|
106
|
-
if (started++ == 0) Thread({ try { runtime(application).deliverDue() } catch (_: Exception) {} }, "croche-foreground").start()
|
|
107
|
-
}
|
|
108
|
-
override fun onActivityStopped(activity: Activity) { started = (started - 1).coerceAtLeast(0) }
|
|
109
|
-
override fun onActivityCreated(activity: Activity, state: Bundle?) {}
|
|
110
|
-
override fun onActivityResumed(activity: Activity) {}
|
|
111
|
-
override fun onActivityPaused(activity: Activity) {}
|
|
112
|
-
override fun onActivitySaveInstanceState(activity: Activity, state: Bundle) {}
|
|
113
|
-
override fun onActivityDestroyed(activity: Activity) {}
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* One WorkManager run: `deliverDue()` through the Runtime installed for its name.
|
|
121
|
-
*
|
|
122
|
-
* It always ends `success`: the Runtime has already registered what is still pending (a request
|
|
123
|
-
* of its own, never this one), so a WorkManager retry would only add a second request. A
|
|
124
|
-
* delivery already in flight (`inFlight`) ends it at once, with nothing registered: the
|
|
125
|
-
* delivery in flight registers what is left when it ends (rook, #323 B). Only a Runtime that
|
|
126
|
-
* could not be opened asks WorkManager to retry.
|
|
127
|
-
*
|
|
128
|
-
* When WorkManager stops the run (its time is up, or the constraints are lost), this run's own
|
|
129
|
-
* delivery is cancelled, whether it is waiting behind another turn or running: never another
|
|
130
|
-
* turn of the Runtime. Its notes stay pending, and registered.
|
|
131
|
-
*/
|
|
132
|
-
class CrocheDeliveryWorker(context: Context, params: WorkerParameters) : Worker(context, params) {
|
|
133
|
-
private val cancellation = RuntimeCancellation()
|
|
134
|
-
|
|
135
|
-
override fun doWork(): Result {
|
|
136
|
-
val name = inputData.getString(WorkManagerScheduler.KEY_NAME) ?: WorkManagerScheduler.DEFAULT_NAME
|
|
137
|
-
// Not installed for this name: the next open delivers.
|
|
138
|
-
val open = WorkManagerScheduler.providers[name] ?: return Result.success()
|
|
139
|
-
val runtime = try { open(applicationContext) } catch (_: Exception) { return Result.retry() } ?: return Result.success()
|
|
140
|
-
if (isStopped) return Result.success()
|
|
141
|
-
try { runtime.deliverDue(cancellation) } catch (_: Exception) { /* registered again by the Runtime */ }
|
|
142
|
-
return Result.success()
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
override fun onStopped() { cancellation.cancel() }
|
|
146
|
-
}
|