@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
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
export type { RunToolResult } from './run-tool.js';
|
|
2
|
+
export type { ErrorCategory } from './errors.js';
|
|
3
|
+
import type { AgentEvent } from './generated/app-stream.js';
|
|
4
|
+
export type { Attachment, AgentEvent, InputDisposition, MessageEnd, EventError, SendReceipt, RequestResult } from './generated/app-stream.js';
|
|
5
|
+
/** JSON values accepted by the SDK. Use strings for integer IDs beyond the JavaScript safe integer range. */
|
|
6
|
+
export type Json = null | boolean | number | string | Json[] | {
|
|
7
|
+
[k: string]: Json;
|
|
8
|
+
};
|
|
9
|
+
/** Tool metadata and commands supplied to defineTool. Core validates the manifest. */
|
|
10
|
+
export interface ToolManifest {
|
|
11
|
+
/** Manifest grammar version. The current version is 1. */
|
|
12
|
+
manifestVersion: 1 | (number & {});
|
|
13
|
+
/** Name by which the tool is registered and selected. */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Short explanation of what the tool does. */
|
|
16
|
+
summary: string;
|
|
17
|
+
/** Optional instructions for use of the tool. */
|
|
18
|
+
guide?: string;
|
|
19
|
+
/** Commands exposed by this tool, with their routes, arguments and optional timeouts. */
|
|
20
|
+
commands: Array<{
|
|
21
|
+
key: string;
|
|
22
|
+
summary: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
aliases?: string[];
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
positionals?: ToolArg[];
|
|
27
|
+
flags?: ToolArg[];
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
/** Argument definition in a tool manifest. Core validates it. */
|
|
31
|
+
export interface ToolArg {
|
|
32
|
+
/** Name used to bind or supply this argument. */
|
|
33
|
+
name: string;
|
|
34
|
+
/** Argument kind that determines how Core validates its value. */
|
|
35
|
+
type: 'string' | 'integer' | 'number' | 'boolean' | 'duration' | 'attachment' | (string & {});
|
|
36
|
+
/** Whether the command requires a value for this argument. */
|
|
37
|
+
required?: boolean;
|
|
38
|
+
/** When true, the app supplies the argument through a binding and it is hidden from the model. */
|
|
39
|
+
bindOnly?: boolean;
|
|
40
|
+
/** List of allowed argument values. */
|
|
41
|
+
enum?: Json[];
|
|
42
|
+
/** Value to use when no value is supplied. */
|
|
43
|
+
default?: Json;
|
|
44
|
+
/** Explanation for the argument in the tool's schema. */
|
|
45
|
+
description?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Definition for a built-in or app-defined tool that can be registered with Croche. */
|
|
48
|
+
export interface ToolDefinition {
|
|
49
|
+
/** Name used to identify this tool. */
|
|
50
|
+
readonly name: string;
|
|
51
|
+
}
|
|
52
|
+
/** Let the app apply its own permissions and use its own data for an action the agent requests. */
|
|
53
|
+
export type ToolExecute = (call: ToolCall, ctx: ToolContext) => ToolResult | Json | undefined | void | Promise<ToolResult | Json | undefined | void>;
|
|
54
|
+
/** One command and its arguments passed to an app tool handler. */
|
|
55
|
+
export interface ToolCall {
|
|
56
|
+
/** Command key selected for the call. */
|
|
57
|
+
key: string;
|
|
58
|
+
/** JSON arguments supplied to the handler. */
|
|
59
|
+
args: Record<string, Json>;
|
|
60
|
+
}
|
|
61
|
+
/** Context and attachment access for the current app tool call. */
|
|
62
|
+
export interface ToolContext {
|
|
63
|
+
/** Core-assigned call ID shared by the tool event and associated attachments. */
|
|
64
|
+
callId: string;
|
|
65
|
+
/** ID of the agent invoking this tool. */
|
|
66
|
+
agentId: string;
|
|
67
|
+
/** Named instance, or null when the call is for the main instance. */
|
|
68
|
+
instance: string | null;
|
|
69
|
+
/** User ID, or null when it is absent. */
|
|
70
|
+
user: string | null;
|
|
71
|
+
/** IDs of the inputs that contributed to this call. */
|
|
72
|
+
causedBy: string[];
|
|
73
|
+
/** Signal Core uses to request cancellation of the app tool handler. */
|
|
74
|
+
signal: AbortSignal;
|
|
75
|
+
/** Let an app tool read the file the user shared for that action. */
|
|
76
|
+
attachment(id: string): Promise<{
|
|
77
|
+
mediaType: string;
|
|
78
|
+
data: string;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
/** Result value made by toolResult, for returning content or JSON to the agent. */
|
|
82
|
+
export type ToolResult = {
|
|
83
|
+
content: ToolContent[];
|
|
84
|
+
} | {
|
|
85
|
+
json: Json;
|
|
86
|
+
};
|
|
87
|
+
/** Text or image content that a tool can return through toolResult. */
|
|
88
|
+
export type ToolContent = {
|
|
89
|
+
type: 'text';
|
|
90
|
+
text: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: 'image';
|
|
93
|
+
mediaType: string;
|
|
94
|
+
data: string;
|
|
95
|
+
alt?: string;
|
|
96
|
+
attach?: true;
|
|
97
|
+
} | {
|
|
98
|
+
type: 'image';
|
|
99
|
+
mediaType: string;
|
|
100
|
+
uri: string;
|
|
101
|
+
alt?: string;
|
|
102
|
+
attach?: true;
|
|
103
|
+
};
|
|
104
|
+
/** A wiki document supplied inline or addressed by a file. */
|
|
105
|
+
export type WikiDoc = {
|
|
106
|
+
path: string;
|
|
107
|
+
description: string;
|
|
108
|
+
markdown: string;
|
|
109
|
+
} | {
|
|
110
|
+
path: string;
|
|
111
|
+
description: string;
|
|
112
|
+
file: string;
|
|
113
|
+
};
|
|
114
|
+
/** Scoped configuration for one tool available to an agent. */
|
|
115
|
+
export interface ToolEntryOptions<T> {
|
|
116
|
+
/** Name of the registered tool. */
|
|
117
|
+
tool: T;
|
|
118
|
+
/** Optional bindings supplied for this scoped tool. */
|
|
119
|
+
bind?: Record<string, Json>;
|
|
120
|
+
/** Optional selection of command keys the agent can use. */
|
|
121
|
+
commands?: string[];
|
|
122
|
+
/** Optional guidance for using this tool in the current scope. */
|
|
123
|
+
guide?: string;
|
|
124
|
+
}
|
|
125
|
+
/** Tool definition alone or with app-supplied bindings. */
|
|
126
|
+
export type ToolRegistration = ToolDefinition | {
|
|
127
|
+
tool: ToolDefinition;
|
|
128
|
+
bind: Record<string, Json>;
|
|
129
|
+
};
|
|
130
|
+
/** List of registered tools with optional command, binding and guidance settings. */
|
|
131
|
+
export type ToolScope = Array<string | ToolEntryOptions<string>>;
|
|
132
|
+
/** List of wiki document paths with optional guidance for the agent. */
|
|
133
|
+
export type WikiScope = Array<string | {
|
|
134
|
+
doc: string;
|
|
135
|
+
guide?: string;
|
|
136
|
+
}>;
|
|
137
|
+
/** Options for opening a conversation from an agent definition. */
|
|
138
|
+
export interface AgentOptions {
|
|
139
|
+
/** Named conversation and its optional configuration patch. */
|
|
140
|
+
instance?: {
|
|
141
|
+
/** Name of the conversation within the agent. */
|
|
142
|
+
id: string;
|
|
143
|
+
/** Optional instance-specific patch passed to Core on open. */
|
|
144
|
+
config?: Json;
|
|
145
|
+
};
|
|
146
|
+
/** Tool scope for this agent handle. */
|
|
147
|
+
tools?: ToolScope | 'all' | null;
|
|
148
|
+
/** Wiki scope for this agent handle. */
|
|
149
|
+
wiki?: WikiScope | 'all' | null;
|
|
150
|
+
}
|
|
151
|
+
/** App and host configuration for opening a Croche session. */
|
|
152
|
+
export interface OpenOptions {
|
|
153
|
+
/** Optional per-instance archive budgets. */
|
|
154
|
+
archive?: {
|
|
155
|
+
/** History byte budget for each agent instance. The Core default is 8 MiB. */
|
|
156
|
+
maxBytes?: number;
|
|
157
|
+
/** Shared archive byte budget for retired summary pieces and saved memory facts per instance. The Core default is 4 MiB. */
|
|
158
|
+
notesMaxBytes?: number;
|
|
159
|
+
};
|
|
160
|
+
/** App-wide input and scheduling guards, for every agent. Code-owned: a bundle cannot set them. */
|
|
161
|
+
limits?: {
|
|
162
|
+
/** Total user and app-event text in one send, in UTF-16 units. The Core default is 32,000. */
|
|
163
|
+
userTextChars?: number;
|
|
164
|
+
/** Total app-state text in one send, in UTF-16 units. The Core default is 32,000. */
|
|
165
|
+
appStateChars?: number;
|
|
166
|
+
/** Maximum length of a tool result value as compact JSON. The Core default is 200,000. */
|
|
167
|
+
toolResultChars?: number;
|
|
168
|
+
/** Images per message or tool result, 1–16 (default 4). Image byte limits stay fixed. */
|
|
169
|
+
turnImages?: number;
|
|
170
|
+
/** Schedule notes pending at once, 1–20 (default 20). */
|
|
171
|
+
pendingSchedules?: number;
|
|
172
|
+
};
|
|
173
|
+
/** Keep enough recent stream records for users to replay after reopening. */
|
|
174
|
+
retentionBytes?: number;
|
|
175
|
+
/** Total storage budget for the user’s named instances. Core defaults to 32 MiB. */
|
|
176
|
+
instanceMaxBytes?: number;
|
|
177
|
+
/** Largest app wiki document in markdown bytes; a larger one is refused, so split it. Core defaults to 64 KiB. */
|
|
178
|
+
wikiDocumentMaxBytes?: number;
|
|
179
|
+
/** Total bytes the app wiki may hold in memory: each document's markdown, path and description. Core defaults to 8 MiB. */
|
|
180
|
+
wikiMaxBytes?: number;
|
|
181
|
+
/** Public project key identifying the Croche project. */
|
|
182
|
+
projectKey: string;
|
|
183
|
+
/** Optional user ID for the session. Core validates it for the selected access path. */
|
|
184
|
+
user?: string;
|
|
185
|
+
/** Optional language preference supplied to Core. */
|
|
186
|
+
language?: string;
|
|
187
|
+
/** Bundled project and agent configuration supplied to Core. */
|
|
188
|
+
bundledConfig: Json;
|
|
189
|
+
/** Tool definitions registered by the app. */
|
|
190
|
+
tools?: ToolRegistration[];
|
|
191
|
+
/** Wiki documents supplied with this session. */
|
|
192
|
+
wiki?: WikiDoc[];
|
|
193
|
+
/** Host adapters to supply for this session. */
|
|
194
|
+
adapters?: readonly Adapter[];
|
|
195
|
+
/** Optional platform-owned handle used by the host integration. */
|
|
196
|
+
platform?: PlatformHandle;
|
|
197
|
+
/** Optional credential for a trusted server host. */
|
|
198
|
+
serverKey?: string;
|
|
199
|
+
/** Optional development key, used while developing the app. */
|
|
200
|
+
developmentKey?: string;
|
|
201
|
+
}
|
|
202
|
+
/** Evidence and question selection for a decision call. */
|
|
203
|
+
export interface DecideInput {
|
|
204
|
+
/** Optional correlation ID for this decision call. Reusing it after completion can make another paid call. */
|
|
205
|
+
id?: string;
|
|
206
|
+
/** JSON evidence presented to the decision model. */
|
|
207
|
+
state: Json;
|
|
208
|
+
/** Question references for this call. Omit the list to use the configured questions. */
|
|
209
|
+
questions?: Array<string | DecisionQuestion>;
|
|
210
|
+
}
|
|
211
|
+
/** A decision question whose ID identifies its answer in the result. */
|
|
212
|
+
export type DecisionQuestion = {
|
|
213
|
+
id: string;
|
|
214
|
+
} & ({
|
|
215
|
+
type: 'noul';
|
|
216
|
+
instructions: string;
|
|
217
|
+
criteria?: {
|
|
218
|
+
true?: string;
|
|
219
|
+
false?: string;
|
|
220
|
+
};
|
|
221
|
+
} | {
|
|
222
|
+
type: 'choice';
|
|
223
|
+
instructions: string;
|
|
224
|
+
criteria: Array<{
|
|
225
|
+
id: string;
|
|
226
|
+
description?: string;
|
|
227
|
+
}>;
|
|
228
|
+
} | {
|
|
229
|
+
type: 'score';
|
|
230
|
+
instructions: string;
|
|
231
|
+
criteria: string[];
|
|
232
|
+
});
|
|
233
|
+
/** Confidence value with the method used to obtain it. */
|
|
234
|
+
export interface DecisionConfidence {
|
|
235
|
+
/** Numeric confidence reported with the answer. */
|
|
236
|
+
value: number;
|
|
237
|
+
/** Method label accompanying the confidence. */
|
|
238
|
+
method: 'typesafe' | 'p_max' | (string & {});
|
|
239
|
+
}
|
|
240
|
+
/** Boolean, choice or numeric answer, a refusal, or an unfamiliar answer type returned by Core. */
|
|
241
|
+
export type DecisionAnswer = {
|
|
242
|
+
type: 'noul';
|
|
243
|
+
value: boolean;
|
|
244
|
+
probability?: number;
|
|
245
|
+
confidence?: DecisionConfidence;
|
|
246
|
+
} | {
|
|
247
|
+
type: 'choice';
|
|
248
|
+
value: string;
|
|
249
|
+
probabilities?: Record<string, number>;
|
|
250
|
+
confidence?: DecisionConfidence;
|
|
251
|
+
} | {
|
|
252
|
+
type: 'score';
|
|
253
|
+
value: number;
|
|
254
|
+
probabilities?: number[];
|
|
255
|
+
confidence?: DecisionConfidence;
|
|
256
|
+
} | {
|
|
257
|
+
type: 'refusal';
|
|
258
|
+
reason?: string;
|
|
259
|
+
} | {
|
|
260
|
+
type: 'unknown';
|
|
261
|
+
originalType: string;
|
|
262
|
+
fields: Json;
|
|
263
|
+
};
|
|
264
|
+
/** Answers and usage information returned by a decision call. */
|
|
265
|
+
export interface DecisionResult {
|
|
266
|
+
/** Correlation ID for the decision call. */
|
|
267
|
+
id: string;
|
|
268
|
+
/** Model recorded for the decision. */
|
|
269
|
+
model: string;
|
|
270
|
+
/** Answers and refusals keyed by question ID. */
|
|
271
|
+
answers: Record<string, DecisionAnswer>;
|
|
272
|
+
/** Serving provider, when available. */
|
|
273
|
+
provider?: string;
|
|
274
|
+
/** Usage information recorded for this call. */
|
|
275
|
+
usage: Json;
|
|
276
|
+
/** Recorded call cost in credits, or null when unavailable. */
|
|
277
|
+
cost: number | null;
|
|
278
|
+
/** Status of the cost observation. */
|
|
279
|
+
costStatus: 'reported' | 'unknown' | 'none' | (string & {});
|
|
280
|
+
}
|
|
281
|
+
/** User text or an ordered group of text and image elements with an optional input ID. */
|
|
282
|
+
export type SendInput = string | {
|
|
283
|
+
id?: string;
|
|
284
|
+
input: Array<TextInput | ImageInput>;
|
|
285
|
+
};
|
|
286
|
+
/** Text element in an ordered send. */
|
|
287
|
+
export interface TextInput {
|
|
288
|
+
/** Discriminant for a text element. */
|
|
289
|
+
type: 'text';
|
|
290
|
+
/** Text supplied to the agent. */
|
|
291
|
+
text: string;
|
|
292
|
+
/** Input source sent to Core. Defaults to user input. */
|
|
293
|
+
kind?: 'user' | 'app_event' | 'app_state';
|
|
294
|
+
}
|
|
295
|
+
/** Image in an ordered send. Supply a URI or encoded bytes. */
|
|
296
|
+
export interface ImageInput {
|
|
297
|
+
/** Discriminant for an image in an ordered send. */
|
|
298
|
+
type: 'image';
|
|
299
|
+
/** Media type of the encoded image, when supplied. */
|
|
300
|
+
mediaType?: string;
|
|
301
|
+
/** Image bytes encoded as Base64. */
|
|
302
|
+
data?: string;
|
|
303
|
+
/** URI passed to the host to load the image. */
|
|
304
|
+
uri?: string;
|
|
305
|
+
/** Optional text description of the image. */
|
|
306
|
+
alt?: string;
|
|
307
|
+
}
|
|
308
|
+
/** Response and cancellation options for `Agent.send` and `Agent.request`. */
|
|
309
|
+
export interface SendOptions {
|
|
310
|
+
/**
|
|
311
|
+
* Aborting before acceptance prevents the input from being queued. Once `send` accepts it,
|
|
312
|
+
* the signal has no effect on the input. Once `request` accepts it, aborting rejects the wait
|
|
313
|
+
* with `aborted` while the input continues. To cancel the input itself, call `Agent.cancel(id)`.
|
|
314
|
+
*/
|
|
315
|
+
signal?: AbortSignal;
|
|
316
|
+
/** Optional format supplied to Core for structured output. */
|
|
317
|
+
responseFormat?: ResponseFormat;
|
|
318
|
+
}
|
|
319
|
+
/** Structured response format to request from the model, as a JSON object or according to a JSON schema. */
|
|
320
|
+
export type ResponseFormat = {
|
|
321
|
+
type: 'json_schema';
|
|
322
|
+
json_schema: {
|
|
323
|
+
name: string;
|
|
324
|
+
schema: Json;
|
|
325
|
+
strict?: boolean;
|
|
326
|
+
description?: string;
|
|
327
|
+
};
|
|
328
|
+
} | {
|
|
329
|
+
type: 'json_object';
|
|
330
|
+
};
|
|
331
|
+
/** Live agent subscription used to receive updates and request older transcript pages. */
|
|
332
|
+
export interface Subscription {
|
|
333
|
+
/** Load older messages into the same chat view when the user scrolls back. */
|
|
334
|
+
history(options: {
|
|
335
|
+
before?: number;
|
|
336
|
+
limit: number;
|
|
337
|
+
}): Promise<void>;
|
|
338
|
+
/** Stop routing updates to a chat view that has been dismissed. */
|
|
339
|
+
close(): void;
|
|
340
|
+
/** Whether Core has ended this subscription. */
|
|
341
|
+
readonly ended: boolean;
|
|
342
|
+
}
|
|
343
|
+
/** One saved memory item returned by the memory list. */
|
|
344
|
+
export interface MemoryItem {
|
|
345
|
+
/** Item ID used to select the fact for deletion. */
|
|
346
|
+
id: string;
|
|
347
|
+
/** Saved text for this item. */
|
|
348
|
+
text: string;
|
|
349
|
+
[k: string]: Json;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Options of every paged public list: `listAttachments`, `memory.list` and `wiki.list`.
|
|
353
|
+
* `limit` is a positive integer; a page holds at most 128 items, which is also the default.
|
|
354
|
+
* `cursor` is the opaque cursor of the previous page of the same list.
|
|
355
|
+
*/
|
|
356
|
+
export interface ListOptions {
|
|
357
|
+
/** Requested number of items, capped at 128. Omit to use 128. */
|
|
358
|
+
limit?: number;
|
|
359
|
+
/** Cursor returned by the previous page of the same list. */
|
|
360
|
+
cursor?: string;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* One page of a public list, in the list's stable order. `cursor` is present only when more
|
|
364
|
+
* items follow: pass it back with the same list to continue strictly past this page.
|
|
365
|
+
*/
|
|
366
|
+
export interface Page<T> {
|
|
367
|
+
/** Items returned in this page. */
|
|
368
|
+
items: T[];
|
|
369
|
+
/** Opaque cursor to pass back to this list when another page is available. */
|
|
370
|
+
cursor?: string;
|
|
371
|
+
}
|
|
372
|
+
/** Recorded moments use ISO 8601 strings; scheduling deadlines use epoch milliseconds. */
|
|
373
|
+
export type BackgroundEvent = {
|
|
374
|
+
type: 'delivered' | 'deadline' | 'cancelled' | 'skipped' | (string & {});
|
|
375
|
+
/** When the event happened, as an ISO 8601 string. */
|
|
376
|
+
at: string;
|
|
377
|
+
[k: string]: Json;
|
|
378
|
+
} & {
|
|
379
|
+
reason?: 'storage_unavailable' | 'os_registration_failed' | (string & {});
|
|
380
|
+
};
|
|
381
|
+
/** Settings for the host to register background delivery. */
|
|
382
|
+
export interface BackgroundOptions {
|
|
383
|
+
/** Optional receiver of Core background notifications. */
|
|
384
|
+
sink?: {
|
|
385
|
+
/** Let the app react when scheduled work was delivered or could not run. */
|
|
386
|
+
onEvent(event: BackgroundEvent): void;
|
|
387
|
+
};
|
|
388
|
+
/** Host adapters for the background run. Use the same storage as the foreground session. */
|
|
389
|
+
adapters?: readonly Adapter[];
|
|
390
|
+
}
|
|
391
|
+
/** Action reported as available to the attached debugger. The set can grow. */
|
|
392
|
+
export type DebugCapability = 'agents.list' | 'status' | 'history' | 'send' | 'cancel' | 'tools' | (string & {});
|
|
393
|
+
import type { StateStore } from './pal/state-store.js';
|
|
394
|
+
export type { StateStore, StateCommitResult, StateCondition, StateEntry, StateListOptions, StateOp, StatePage, StateValue } from './pal/state-store.js';
|
|
395
|
+
export type StorageVersion = string;
|
|
396
|
+
export interface VersionedValue {
|
|
397
|
+
value: string | null;
|
|
398
|
+
version: StorageVersion | null;
|
|
399
|
+
}
|
|
400
|
+
export type WriteOutcome = {
|
|
401
|
+
type: 'written';
|
|
402
|
+
version: StorageVersion | null;
|
|
403
|
+
} | {
|
|
404
|
+
type: 'conflict';
|
|
405
|
+
version: StorageVersion | null;
|
|
406
|
+
};
|
|
407
|
+
/** A page of raw objects in one BlobStore prefix. */
|
|
408
|
+
export interface BlobListPage {
|
|
409
|
+
/** Objects and their sizes in bytes, in ascending UTF-8 key order. */
|
|
410
|
+
entries: Array<{
|
|
411
|
+
key: string;
|
|
412
|
+
size: number;
|
|
413
|
+
}>;
|
|
414
|
+
/** Opaque continuation for the same prefix, omitted on the last page. */
|
|
415
|
+
nextCursor?: string;
|
|
416
|
+
}
|
|
417
|
+
/** Raw objects. Core defines keys, ownership, budgets and cleanup. */
|
|
418
|
+
export interface BlobStore {
|
|
419
|
+
/** Selects the blob adapter. */
|
|
420
|
+
readonly kind: 'blob';
|
|
421
|
+
/**
|
|
422
|
+
* Keep an attachment available when the user returns to the conversation.
|
|
423
|
+
*
|
|
424
|
+
* Stores raw bytes, replacing an existing object at the same key.
|
|
425
|
+
*/
|
|
426
|
+
put(key: string, bytes: Uint8Array): Promise<void>;
|
|
427
|
+
/**
|
|
428
|
+
* Load the stored bytes when the app displays a file or uses it in a request.
|
|
429
|
+
*
|
|
430
|
+
* Returns raw bytes, or null if the object is missing.
|
|
431
|
+
*/
|
|
432
|
+
get(key: string): Promise<Uint8Array | null>;
|
|
433
|
+
/**
|
|
434
|
+
* Reclaim the file when the user deletes its owning data.
|
|
435
|
+
*
|
|
436
|
+
* Removes the object and succeeds if it is already missing.
|
|
437
|
+
*/
|
|
438
|
+
delete(key: string): Promise<void>;
|
|
439
|
+
/**
|
|
440
|
+
* Walk a user’s stored files in pages when measuring storage or completing deletion.
|
|
441
|
+
*
|
|
442
|
+
* Ascending UTF-8 key order. Pass a returned cursor back with the same prefix.
|
|
443
|
+
*/
|
|
444
|
+
list(prefix: string, cursor?: string): Promise<BlobListPage>;
|
|
445
|
+
}
|
|
446
|
+
/** Opaque platform value passed to the host when opening the runtime. */
|
|
447
|
+
export type PlatformHandle = unknown;
|
|
448
|
+
/** Callback and replay options for starting an agent subscription. */
|
|
449
|
+
export interface SubscribeOptions {
|
|
450
|
+
/** Update the transcript and controls together as the agent makes progress. */
|
|
451
|
+
onEvent: (event: AgentEvent) => void;
|
|
452
|
+
/** Number of recent messages to replay on attach. Omit to use Core's default. */
|
|
453
|
+
initialMessages?: number;
|
|
454
|
+
/** Resume after this cursor in its stream log. */
|
|
455
|
+
after?: {
|
|
456
|
+
/** Identifies the stream log to resume. */
|
|
457
|
+
logId: string;
|
|
458
|
+
/** Last sequence the app has already seen in the log. */
|
|
459
|
+
seq: number;
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
/** Outcome of a background delivery pass. */
|
|
463
|
+
export interface DeliverDueResult {
|
|
464
|
+
/** Whether Core reports that the delivery pass ran. */
|
|
465
|
+
ran: boolean;
|
|
466
|
+
/** Number of usage reports the runtime delivered in this run. */
|
|
467
|
+
delivered: number;
|
|
468
|
+
/** Agents and instances whose due work was deferred, with reasons. */
|
|
469
|
+
deferred: Array<{
|
|
470
|
+
user: string | null;
|
|
471
|
+
agent: string;
|
|
472
|
+
instance: string | null;
|
|
473
|
+
code: 'deadline' | 'cancelled' | (string & {});
|
|
474
|
+
message: string;
|
|
475
|
+
}>;
|
|
476
|
+
}
|
|
477
|
+
/** Page of scheduled wakes returned by the host query. */
|
|
478
|
+
export interface WakeTimes {
|
|
479
|
+
/** Scheduled wakes included in this result. */
|
|
480
|
+
wakes: Array<{
|
|
481
|
+
user: string | null;
|
|
482
|
+
/** Delivery deadline in epoch milliseconds. */
|
|
483
|
+
at: number;
|
|
484
|
+
}>;
|
|
485
|
+
/** Inclusive pagination deadline in epoch milliseconds; pass as wakeTimes query.after. */
|
|
486
|
+
next?: number;
|
|
487
|
+
}
|
|
488
|
+
/** Select an agent or one named instance for local deletion. An empty scope selects the user. */
|
|
489
|
+
export interface DeleteScope {
|
|
490
|
+
/** Agent whose local data is selected for deletion. */
|
|
491
|
+
agent?: string;
|
|
492
|
+
/** Named instance within the selected agent. */
|
|
493
|
+
instance?: string;
|
|
494
|
+
}
|
|
495
|
+
/** Connection details for attaching a debugger. */
|
|
496
|
+
export interface DebugAttachOptions {
|
|
497
|
+
/** Endpoint for the debugger connection. */
|
|
498
|
+
url: string;
|
|
499
|
+
/** Debugger access token. */
|
|
500
|
+
token: string;
|
|
501
|
+
}
|
|
502
|
+
/** Debugger attachment and the capabilities returned by Core. */
|
|
503
|
+
export interface AttachedDebugger {
|
|
504
|
+
/** Identifier returned for the attached debugger. */
|
|
505
|
+
debuggerId: string;
|
|
506
|
+
/** Capabilities that Core reports for the attached debugger. */
|
|
507
|
+
capabilities: DebugCapability[];
|
|
508
|
+
}
|
|
509
|
+
/** Access to the runtime debugger for the current session. */
|
|
510
|
+
export interface CrocheDebugger {
|
|
511
|
+
/** Inspect a running session when a development build behaves unexpectedly. */
|
|
512
|
+
attach(options: DebugAttachOptions): Promise<AttachedDebugger>;
|
|
513
|
+
/** End diagnostic access after the developer is done or the user withdraws permission. */
|
|
514
|
+
detach(): Promise<void>;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* How Croche Cloud verified this installation (`croche.verification()`). Verification is not access: a withheld key
|
|
518
|
+
* leaves it unchanged. `unknown`: not registered yet, or Cloud did not say. `lastAttestation` is the device-side code
|
|
519
|
+
* of the last attestor attempt without a usable proof; null does not mean Cloud accepted a proof.
|
|
520
|
+
*/
|
|
521
|
+
export interface Verification {
|
|
522
|
+
/** Open-ended installation verification status reported by Core. */
|
|
523
|
+
status: 'attested' | 'server' | 'development' | 'unverified' | 'unknown' | (string & {});
|
|
524
|
+
/** Device-side code from the last attestor attempt that did not produce usable proof, if present. */
|
|
525
|
+
lastAttestation: 'attestation_unavailable' | 'attestation_unsupported' | 'attestation_failed' | 'attestation_timeout' | 'attestation_unusable' | (string & {}) | null;
|
|
526
|
+
}
|
|
527
|
+
/** App implementations replace host defaults only for their own kind. */
|
|
528
|
+
export type Adapter = BlobStore | ImageAdapter | StateStore;
|
|
529
|
+
/** Format and input capabilities supplied by an image adapter. */
|
|
530
|
+
export interface ImageSupport {
|
|
531
|
+
/** Source media types the adapter can read. */
|
|
532
|
+
inputMediaTypes: readonly string[];
|
|
533
|
+
/** Media types the adapter can produce. */
|
|
534
|
+
outputMediaTypes: readonly string[];
|
|
535
|
+
/** Upper pixel count advertised for input images, when specified. */
|
|
536
|
+
maxInputPixels?: number;
|
|
537
|
+
}
|
|
538
|
+
/** Width, height and alpha describe the orientation-applied (upright) first frame; resize uses the same geometry. mediaType describes the encoded input. */
|
|
539
|
+
export interface ImageInfo {
|
|
540
|
+
/** Detected media type of the source image. */
|
|
541
|
+
mediaType: string;
|
|
542
|
+
/** Upright first-frame width in pixels. */
|
|
543
|
+
width: number;
|
|
544
|
+
/** Upright first-frame height in pixels. */
|
|
545
|
+
height: number;
|
|
546
|
+
/** Whether the source has an alpha channel, when known. */
|
|
547
|
+
hasAlpha?: boolean;
|
|
548
|
+
}
|
|
549
|
+
/** Bounds and output formats for a resized model view. */
|
|
550
|
+
export interface ImageResizeLimits {
|
|
551
|
+
/** Maximum length of the longest side in pixels, when set. */
|
|
552
|
+
maxSide?: number;
|
|
553
|
+
/** Maximum encoded byte length of the resized image. */
|
|
554
|
+
maxBytes: number;
|
|
555
|
+
/** Accepted media types for the resized output. */
|
|
556
|
+
outputMediaTypes: readonly string[];
|
|
557
|
+
}
|
|
558
|
+
/** Host capability for inspecting and preparing encoded image bytes. */
|
|
559
|
+
export interface ImageAdapter {
|
|
560
|
+
/** Host adapter tag for image inspection and resizing. */
|
|
561
|
+
readonly kind: 'image';
|
|
562
|
+
/** Formats and input bounds advertised to Core by this adapter. */
|
|
563
|
+
readonly support: ImageSupport;
|
|
564
|
+
/** Find out whether a photo fits before preparing it for the selected model. */
|
|
565
|
+
info(bytes: Uint8Array, options: {
|
|
566
|
+
signal: AbortSignal;
|
|
567
|
+
}): Promise<ImageInfo>;
|
|
568
|
+
/** Fit a large photo within the model’s limits while keeping the user’s original. */
|
|
569
|
+
resize(bytes: Uint8Array, limits: ImageResizeLimits, options: {
|
|
570
|
+
signal: AbortSignal;
|
|
571
|
+
}): Promise<Uint8Array>;
|
|
572
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CoreCancel, CoreModule } from './core/port.js';
|
|
2
|
+
/**
|
|
3
|
+
* A fresh Core token for one call, bridged to the app's AbortSignal when there is one (S1: Core borrows a token on
|
|
4
|
+
* every call). Already aborted = cancelled before the call (Core: never queued). Token disposal removes the
|
|
5
|
+
* listener at a request's terminal settlement. A send receipt retains it: the signal is cancel(id) after acceptance too.
|
|
6
|
+
*/
|
|
7
|
+
export declare function tokenFor(core: CoreModule, signal: AbortSignal | undefined): CoreCancel;
|
|
8
|
+
/** Core's token as the AbortSignal a tool's execute sees (`ctx.signal`). */
|
|
9
|
+
export declare function signalFor(token: CoreCancel): AbortSignal;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A fresh Core token for one call, bridged to the app's AbortSignal when there is one (S1: Core borrows a token on
|
|
3
|
+
* every call). Already aborted = cancelled before the call (Core: never queued). Token disposal removes the
|
|
4
|
+
* listener at a request's terminal settlement. A send receipt retains it: the signal is cancel(id) after acceptance too.
|
|
5
|
+
*/
|
|
6
|
+
export function tokenFor(core, signal) {
|
|
7
|
+
const token = core.newCancel();
|
|
8
|
+
if (signal === undefined)
|
|
9
|
+
return token;
|
|
10
|
+
if (signal.aborted)
|
|
11
|
+
token.cancel();
|
|
12
|
+
else {
|
|
13
|
+
const abort = () => token.cancel();
|
|
14
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
15
|
+
token.onDispose?.(() => signal.removeEventListener('abort', abort));
|
|
16
|
+
}
|
|
17
|
+
return token;
|
|
18
|
+
}
|
|
19
|
+
/** Core's token as the AbortSignal a tool's execute sees (`ctx.signal`). */
|
|
20
|
+
export function signalFor(token) {
|
|
21
|
+
const controller = new AbortController();
|
|
22
|
+
if (token.isCancelled())
|
|
23
|
+
controller.abort();
|
|
24
|
+
else
|
|
25
|
+
token.onCancel(() => controller.abort());
|
|
26
|
+
return controller.signal;
|
|
27
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const sleeps = new Set();
|
|
2
|
+
let calls = 0;
|
|
3
|
+
let enabled = false;
|
|
4
|
+
export function enableNodeSleepTracking() { enabled = true; }
|
|
5
|
+
function settled() {
|
|
6
|
+
if (--calls === 0)
|
|
7
|
+
for (const timer of sleeps)
|
|
8
|
+
timer.unref?.();
|
|
9
|
+
}
|
|
10
|
+
export function foreground(invoke) {
|
|
11
|
+
if (!enabled)
|
|
12
|
+
return invoke();
|
|
13
|
+
if (calls++ === 0)
|
|
14
|
+
for (const timer of sleeps)
|
|
15
|
+
timer.ref?.();
|
|
16
|
+
let result;
|
|
17
|
+
try {
|
|
18
|
+
result = invoke();
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
settled();
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
if (result instanceof Promise)
|
|
25
|
+
return result.finally(settled);
|
|
26
|
+
settled();
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
// Only the Node PAL opts into keeping references to its pending sleeps.
|
|
30
|
+
export function nodeSleep(ms) {
|
|
31
|
+
return new Promise(resolve => {
|
|
32
|
+
const timer = setTimeout(() => {
|
|
33
|
+
sleeps.delete(timer);
|
|
34
|
+
resolve();
|
|
35
|
+
}, ms);
|
|
36
|
+
sleeps.add(timer);
|
|
37
|
+
if (calls === 0)
|
|
38
|
+
timer.unref?.();
|
|
39
|
+
});
|
|
40
|
+
}
|