@h1r-ai/croche-react-native 0.5.5 → 0.6.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/README.md +69 -458
- package/THIRD-PARTY-NOTICES +7 -8
- package/android/build.gradle +6 -1
- package/android/src/androidTest/java/dev/croche/reactnative/WikiFileBridgeTest.kt +125 -0
- package/android/src/main/java/dev/croche/reactnative/CoreDispatch.kt +81 -0
- package/android/src/main/java/dev/croche/reactnative/CoreWire.kt +83 -0
- package/android/src/main/java/dev/croche/reactnative/CrocheRuntimeModule.kt +45 -824
- package/android/src/main/java/dev/croche/reactnative/NativePal.kt +51 -0
- package/android/src/main/java/dev/croche/reactnative/RNHostPal.kt +9 -0
- package/android/src/test/java/dev/croche/reactnative/AgentMemoryTest.kt +42 -41
- package/android/src/test/java/dev/croche/reactnative/BackgroundDelegationTest.kt +71 -0
- package/android/src/test/java/dev/croche/reactnative/OpenForwardingFixture.kt +29 -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/vendor/CrocheRuntimeSDK/android/dev/croche/android/AndroidEventSink.kt +27 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/AndroidPlatform.kt +6 -6
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BackgroundRegistration.kt +16 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BackgroundWakeWorker.kt +51 -0
- package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapDecodedImageCodec.kt +162 -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/WorkManagerScheduler.kt +8 -8
- 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 +121 -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/AndroidStoragePal.kt +73 -0
- package/android/vendor/CrocheRuntimeSDK/consumer-rules.pro +9 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/AppStreamBranch.kt +5 -2
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/BindingFacts.kt +29 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ContextConfig.kt +45 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Core.kt +16 -1
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Croche.kt +60 -105
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheAgent.kt +47 -107
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheRuntime.kt +41 -40
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheTools.kt +67 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/DecodedImageCodec.kt +20 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Effects.kt +18 -20
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/GeneratedAppStream.kt +322 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Host.kt +71 -34
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ImagePal.kt +183 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Images.kt +9 -7
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeCoreStreamPort.kt +47 -19
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Platform.kt +5 -5
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectPalRouting.kt +1 -1
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectRecords.kt +9 -9
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectTypes.kt +108 -37
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/PublicResults.kt +44 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ReaderValues.kt +73 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/RunTool.kt +40 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/SendEncoding.kt +23 -21
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Storage.kt +8 -8
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StoragePal.kt +18 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StreamHub.kt +50 -25
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/SubscriptionTypes.kt +22 -22
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ffi/croche_ffi.kt +8285 -2159
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/AppEventSink.kt +34 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/AppStoragePal.kt +25 -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 +31 -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 +128 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmCoreHost.kt +72 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmStoragePal.kt +34 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/LifecycleBinding.kt +18 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/NativePlatform.kt +45 -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 +34 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ScopeJson.kt +29 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ToolCompletionEncoding.kt +29 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/AtomicKeyFiles.kt +79 -0
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/DirectHttpPal.kt +223 -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/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 +3 -0
- package/dist/react-native/src/core-native.js +193 -0
- package/dist/react-native/src/core-wire.d.ts +38 -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/agent.d.ts +43 -0
- package/dist/runtime/src/agent.js +75 -0
- package/dist/runtime/src/app-api.d.ts +284 -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 +24 -0
- package/dist/runtime/src/core/port.d.ts +234 -0
- package/dist/runtime/src/core/port.js +1 -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 +42 -0
- package/dist/runtime/src/croche.js +111 -0
- package/dist/runtime/src/errors.d.ts +26 -0
- package/dist/runtime/src/errors.js +49 -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 +174 -0
- package/dist/runtime/src/generated/app-stream.js +124 -0
- package/dist/runtime/src/index.native.d.ts +21 -0
- package/dist/runtime/src/index.native.js +8 -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 +24 -0
- package/dist/runtime/src/pal/codec.d.ts +15 -0
- package/dist/runtime/src/pal/codec.js +52 -0
- package/dist/runtime/src/pal/host.d.ts +5 -0
- package/dist/runtime/src/pal/host.js +35 -0
- package/dist/runtime/src/pal/platform.d.ts +16 -0
- package/dist/runtime/src/pal/platform.js +7 -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 +19 -0
- package/dist/runtime/src/tools.js +70 -0
- package/ios/CoreAgentTransport.swift +14 -0
- package/ios/CoreDeliveryTransport.swift +58 -0
- package/ios/CoreNativePal.swift +93 -0
- package/ios/CorePlatformTransport.swift +44 -0
- package/ios/CoreWireDispatch.swift +92 -0
- package/ios/CoreWireSupport.swift +111 -0
- package/ios/CrocheRuntimeBridge.swift +34 -994
- package/ios/ProjectPal.swift +46 -0
- package/ios/RNCrocheRuntime.mm +18 -201
- package/ios/vendor/CrocheRuntimeSDK/AppBuildFacts.swift +112 -0
- package/ios/vendor/CrocheRuntimeSDK/Background.swift +11 -11
- package/ios/vendor/CrocheRuntimeSDK/ContextConfig.swift +64 -0
- package/ios/vendor/CrocheRuntimeSDK/DirectHTTP.swift +258 -0
- package/ios/vendor/CrocheRuntimeSDK/Effects.swift +17 -17
- package/ios/vendor/CrocheRuntimeSDK/FFIStreamPort.swift +85 -43
- package/ios/vendor/CrocheRuntimeSDK/GeneratedAppStream.swift +443 -0
- package/ios/vendor/CrocheRuntimeSDK/Host.swift +122 -61
- package/ios/vendor/CrocheRuntimeSDK/ImagePal.swift +410 -0
- package/ios/vendor/CrocheRuntimeSDK/Images.swift +10 -9
- package/ios/vendor/CrocheRuntimeSDK/JSON.swift +4 -4
- package/ios/vendor/CrocheRuntimeSDK/Offload.swift +24 -0
- package/ios/vendor/CrocheRuntimeSDK/OpenOptions.swift +37 -36
- package/ios/vendor/CrocheRuntimeSDK/Platform.swift +35 -35
- package/ios/vendor/CrocheRuntimeSDK/PlatformBackground.swift +285 -0
- package/ios/vendor/CrocheRuntimeSDK/PlatformPal.swift +266 -0
- package/ios/vendor/CrocheRuntimeSDK/PlatformStorage.swift +195 -0
- package/ios/vendor/CrocheRuntimeSDK/Project.swift +209 -95
- package/ios/vendor/CrocheRuntimeSDK/Runtime.swift +97 -123
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Agent.swift +195 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1BindingFacts.swift +33 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Core.swift +161 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Croche.swift +234 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Events.swift +28 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Options.swift +177 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1RunTool.swift +61 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Storage.swift +95 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1TestHooks.swift +105 -0
- package/ios/vendor/CrocheRuntimeSDK/S1/S1Tools.swift +209 -0
- package/ios/vendor/CrocheRuntimeSDK/Storage.swift +52 -52
- package/ios/vendor/CrocheRuntimeSDK/StreamHub.swift +180 -137
- package/ios/vendor/CrocheRuntimeSDK/SubscriptionRuntime.swift +16 -10
- package/ios/vendor/CrocheRuntimeSDK/SubscriptionTypes.swift +131 -116
- package/ios/vendor/CrocheRuntimeSDK/Truncate.swift +12 -0
- package/ios/vendor/CrocheRuntimeSDK/croche_ffi.swift +7209 -2803
- package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64/Headers/croche_ffiFFI.h +1342 -218
- 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 +1342 -218
- 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/vendor-native.sh +5 -4
- 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/core/dev/croche/Control.kt +0 -178
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectBinding.kt +0 -79
- package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectPlatform.kt +0 -46
- package/ios/vendor/CrocheRuntimeSDK/Control.swift +0 -192
- 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,111 @@
|
|
|
1
|
+
// Croche: one SDK object = one Core Croche, the shared-resource factory for one user's session (ARCHITECTURE §2-3).
|
|
2
|
+
// Core decides reuse (the same (projectKey, user) twice = the same Core Croche, ref-counted), defaults, validation
|
|
3
|
+
// and delivery. The wrapper serializes, calls once, parses.
|
|
4
|
+
import { wrapAgent } from './agent.js';
|
|
5
|
+
import { tokenFor } from './cancel.js';
|
|
6
|
+
import { coreModule } from './core/wasm.js';
|
|
7
|
+
import { CrocheError } from './errors.js';
|
|
8
|
+
import { eventSink } from './events.js';
|
|
9
|
+
import { jsonText, optionsText } from './json.js';
|
|
10
|
+
import { createHost, storageFor } from './pal/host.js';
|
|
11
|
+
import { coreDefinition } from './tools.js';
|
|
12
|
+
import { runToolResult } from './run-tool.js';
|
|
13
|
+
/** One `tools` entry: Core's definition handle, and the app's WHOLE wrapper object with `tool` as null (S1 #830).
|
|
14
|
+
* The wrapper's keys are Core's to read and refuse; the SDK only lifts out the handle it cannot serialize. */
|
|
15
|
+
function registration(entry, index) {
|
|
16
|
+
const bare = coreDefinition(entry);
|
|
17
|
+
if (bare)
|
|
18
|
+
return { registration: { tool: bare }, marker: null };
|
|
19
|
+
const object = typeof entry === 'object' && entry !== null ? entry : undefined;
|
|
20
|
+
const tool = object && coreDefinition(object.tool);
|
|
21
|
+
if (!object || !tool) {
|
|
22
|
+
throw new CrocheError('invalid_configuration', `$.tools[${index}]: not a tool definition (use defineTool or tools)`, 'setup');
|
|
23
|
+
}
|
|
24
|
+
const marker = { ...object, tool: null };
|
|
25
|
+
return { registration: { tool, optionsJson: jsonText(marker, `$.tools[${index}]`) }, marker };
|
|
26
|
+
}
|
|
27
|
+
/** An opaque reference the app gave becomes a null marker in the JSON; an absent one stays absent. For `storage`,
|
|
28
|
+
* presence is how Core records custom storage (#829): the platform default never adds the key. */
|
|
29
|
+
const nullIfGiven = (options, key) => options[key] === undefined ? {} : { [key]: null };
|
|
30
|
+
/** OpenOptions as Core takes it (vectors/s1-null-markers-06.json): the whole JSON with each given opaque reference as
|
|
31
|
+
* a null marker in place, the registrations in order, the storage and the host. */
|
|
32
|
+
function opening(options, recoveryGiven = false) {
|
|
33
|
+
const entries = options.tools === undefined || recoveryGiven ? [] : Array.from(options.tools, registration);
|
|
34
|
+
const whole = {
|
|
35
|
+
...options,
|
|
36
|
+
...(options.tools === undefined ? {} : { tools: recoveryGiven ? Array.from(options.tools, () => null) : entries.map(entry => entry.marker) }),
|
|
37
|
+
...nullIfGiven(options, 'storage'),
|
|
38
|
+
...nullIfGiven(options, 'platform'),
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
json: optionsText(whole),
|
|
42
|
+
registrations: entries.map(entry => entry.registration),
|
|
43
|
+
storage: storageFor(options.storage),
|
|
44
|
+
host: createHost(options.platform),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export class Croche {
|
|
48
|
+
#module;
|
|
49
|
+
#core;
|
|
50
|
+
constructor(module, core) {
|
|
51
|
+
this.#module = module;
|
|
52
|
+
this.#core = core;
|
|
53
|
+
}
|
|
54
|
+
static async open(options, recovery) {
|
|
55
|
+
const module = coreModule();
|
|
56
|
+
const recoveryJson = optionsText(recovery);
|
|
57
|
+
// Carry the separate mode to Core unchanged. A supplied mode needs no tool
|
|
58
|
+
// references; Core validates the mode before deciding whether it can open.
|
|
59
|
+
const { json, registrations, storage, host } = opening(options, recoveryJson !== undefined);
|
|
60
|
+
return new Croche(module, await module.open(json, registrations, storage, host, recoveryJson));
|
|
61
|
+
}
|
|
62
|
+
/** Deletes this user's local data in the scope. Core closes selected agents first. */
|
|
63
|
+
async deleteData(scope) {
|
|
64
|
+
await this.#core.deleteData(optionsText(scope));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Once at app start. Core keeps BackgroundEvents durably and delivers each at least once to the sink. `storage` is
|
|
68
|
+
* the same StoragePal the app passes to open() (the platform default when omitted).
|
|
69
|
+
*/
|
|
70
|
+
static registerBackground(options) {
|
|
71
|
+
const given = options ?? {};
|
|
72
|
+
const { sink, storage } = given;
|
|
73
|
+
// The whole options object reaches Core (it refuses a key it does not take); sink and storage are null markers.
|
|
74
|
+
const json = optionsText({ ...given, ...nullIfGiven(given, 'sink'), ...nullIfGiven(given, 'storage') });
|
|
75
|
+
coreModule().registerBackground(json, sink && eventSink(event => sink.onEvent(event)), storageFor(storage), undefined, // INTERNAL platform_storage: Node and web have no separate OS default store
|
|
76
|
+
createHost(undefined));
|
|
77
|
+
}
|
|
78
|
+
static async wakeTimes(options, query) {
|
|
79
|
+
const { json, storage, host } = opening(options);
|
|
80
|
+
return JSON.parse(await coreModule().wakeTimes(json, optionsText(query), storage, host));
|
|
81
|
+
}
|
|
82
|
+
async deliverDue(options) {
|
|
83
|
+
const { signal, ...rest } = options ?? {};
|
|
84
|
+
const json = options === undefined ? undefined : optionsText(rest);
|
|
85
|
+
return JSON.parse(await this.#core.deliverDue(json, tokenFor(this.#module, signal)));
|
|
86
|
+
}
|
|
87
|
+
async agent(id, options) {
|
|
88
|
+
return wrapAgent(this.#module, await this.#core.agent(id, optionsText(options)));
|
|
89
|
+
}
|
|
90
|
+
/** App tools run outside every conversation. Recovery uses the same required id. */
|
|
91
|
+
async runTool(name, args, options) {
|
|
92
|
+
const { signal, ...rest } = options;
|
|
93
|
+
return runToolResult(await this.#core.runTool(name, jsonText(args), optionsText(rest), tokenFor(this.#module, signal)));
|
|
94
|
+
}
|
|
95
|
+
/** Read from Core at every access. */
|
|
96
|
+
get agentIds() { return this.#core.agentIds(); }
|
|
97
|
+
wiki = {
|
|
98
|
+
put: (doc) => this.#core.wikiPut(jsonText(doc)),
|
|
99
|
+
remove: (path) => this.#core.wikiRemove(path),
|
|
100
|
+
list: async () => JSON.parse(await this.#core.wikiList()),
|
|
101
|
+
};
|
|
102
|
+
debugger = {
|
|
103
|
+
attach: async (options) => {
|
|
104
|
+
const answer = await this.#core.debugAttach(jsonText(options));
|
|
105
|
+
return JSON.parse(answer);
|
|
106
|
+
},
|
|
107
|
+
detach: () => this.#core.debugDetach(),
|
|
108
|
+
};
|
|
109
|
+
/** Resolves once new work has stopped; Core continues the bounded final delivery. */
|
|
110
|
+
close() { return this.#core.shutdown(); }
|
|
111
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ErrorCategory } from './generated/app-stream.js';
|
|
2
|
+
export type { ErrorCategory } from './generated/app-stream.js';
|
|
3
|
+
export declare class CrocheError extends Error {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly category: ErrorCategory;
|
|
6
|
+
readonly retryAfter?: number;
|
|
7
|
+
constructor(code: string, message: string, category: ErrorCategory, retryAfter?: number);
|
|
8
|
+
}
|
|
9
|
+
/** A PAL effect's failure, as a fact for Core: a code and a message, no category, no policy. */
|
|
10
|
+
export declare class HostError extends Error {
|
|
11
|
+
readonly code: string;
|
|
12
|
+
constructor(code: string, message: string, options?: ErrorOptions);
|
|
13
|
+
}
|
|
14
|
+
/** A thrown value's own string fields (name, message, code), read once; a throwing getter or a non-string reads as
|
|
15
|
+
* absent, and a thrown string is its message. Facts for Core, never interpreted here. */
|
|
16
|
+
export declare function thrownFacts(error: unknown): {
|
|
17
|
+
name?: string;
|
|
18
|
+
message?: string;
|
|
19
|
+
code?: string;
|
|
20
|
+
};
|
|
21
|
+
/** A tool's thrown value as the S1 completion carries it: `{type: name, message}` when the thrown value has both as
|
|
22
|
+
* strings, otherwise undefined (omitted). No code. */
|
|
23
|
+
export declare function thrownError(error: unknown): {
|
|
24
|
+
type: string;
|
|
25
|
+
message: string;
|
|
26
|
+
} | undefined;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// 0.6 App API error (docs/APP-API.md). Core supplies `code` and `category` for its own errors and the port rejects
|
|
2
|
+
// with them unchanged. The SDK builds one itself only where nothing reached Core: a value that is not JSON
|
|
3
|
+
// (json.ts), a Core that cannot load (core/wasm.ts), a registration that is not a tool definition (croche.ts).
|
|
4
|
+
// An SDK-shipped effect (HTTP, codec, assets) that fails throws a HostError with a code from that effect's closed list;
|
|
5
|
+
// Core validates it and picks the category. A storage primitive that fails throws a plain Error: Core reports
|
|
6
|
+
// storage_error (ARCHITECTURE #837).
|
|
7
|
+
export class CrocheError extends Error {
|
|
8
|
+
code;
|
|
9
|
+
category;
|
|
10
|
+
constructor(code, message, category, retryAfter) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'CrocheError';
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.category = category;
|
|
15
|
+
if (retryAfter !== undefined)
|
|
16
|
+
this.retryAfter = retryAfter;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** A PAL effect's failure, as a fact for Core: a code and a message, no category, no policy. */
|
|
20
|
+
export class HostError extends Error {
|
|
21
|
+
code;
|
|
22
|
+
constructor(code, message, options) {
|
|
23
|
+
super(message, options);
|
|
24
|
+
this.name = 'HostError';
|
|
25
|
+
this.code = code;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** A thrown value's own string fields (name, message, code), read once; a throwing getter or a non-string reads as
|
|
29
|
+
* absent, and a thrown string is its message. Facts for Core, never interpreted here. */
|
|
30
|
+
export function thrownFacts(error) {
|
|
31
|
+
const text = (key) => {
|
|
32
|
+
try {
|
|
33
|
+
const value = (typeof error === 'object' || typeof error === 'function') && error !== null ? error[key] : undefined;
|
|
34
|
+
return typeof value === 'string' ? value : undefined;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return { name: text('name'), message: typeof error === 'string' ? error : text('message'), code: text('code') };
|
|
41
|
+
}
|
|
42
|
+
/** A tool's thrown value as the S1 completion carries it: `{type: name, message}` when the thrown value has both as
|
|
43
|
+
* strings, otherwise undefined (omitted). No code. */
|
|
44
|
+
export function thrownError(error) {
|
|
45
|
+
const { name, message } = thrownFacts(error);
|
|
46
|
+
if (typeof name !== 'string' || typeof error === 'string' || typeof message !== 'string')
|
|
47
|
+
return undefined;
|
|
48
|
+
return { type: name, message };
|
|
49
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CoreEventSink } from './core/port.js';
|
|
2
|
+
import type { Json } from './app-api.js';
|
|
3
|
+
/** `decode` is the GENERATED reader (decodeAgentEvent: a type this SDK does not know becomes the #828 `unknown`
|
|
4
|
+
* member); a sink without one passes Core's JSON through unchanged. */
|
|
5
|
+
export declare function eventSink<E>(handler: (event: E) => unknown, decode?: (value: Json) => E): CoreEventSink;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { thrownFacts } from './errors.js';
|
|
2
|
+
function threw(error) {
|
|
3
|
+
return { outcome: 'threw', error: thrownFacts(error) };
|
|
4
|
+
}
|
|
5
|
+
function complete(delivery, outcome) {
|
|
6
|
+
delivery.complete(JSON.stringify(outcome));
|
|
7
|
+
}
|
|
8
|
+
/** `decode` is the GENERATED reader (decodeAgentEvent: a type this SDK does not know becomes the #828 `unknown`
|
|
9
|
+
* member); a sink without one passes Core's JSON through unchanged. */
|
|
10
|
+
export function eventSink(handler, decode = value => value) {
|
|
11
|
+
return (_deliveryId, eventJson, delivery) => {
|
|
12
|
+
const event = decode(JSON.parse(eventJson));
|
|
13
|
+
if (!delivery.tryEnter())
|
|
14
|
+
return; // Core withdrew it (closed, replaced): never enter the handler
|
|
15
|
+
let returned;
|
|
16
|
+
try {
|
|
17
|
+
returned = handler(event);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
complete(delivery, threw(error));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (typeof returned?.then === 'function') {
|
|
24
|
+
// Finished = the thenable settled; a then() that throws is a rejection.
|
|
25
|
+
Promise.resolve(returned).then(() => complete(delivery, { outcome: 'returned' }), error => complete(delivery, threw(error)));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
complete(delivery, { outcome: 'returned' });
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export type Json = null | boolean | number | string | Json[] | {
|
|
2
|
+
[key: string]: Json;
|
|
3
|
+
};
|
|
4
|
+
export type InputDisposition = "queued" | "seen" | "answered" | "no_reply" | "failed" | "cancelled" | (string & {});
|
|
5
|
+
export type InputKind = "user" | "app_event" | "app_state" | (string & {});
|
|
6
|
+
export type MessageStatus = "completed" | "failed" | "cancelled" | "interrupted" | (string & {});
|
|
7
|
+
export type AgentStatus = "idle" | "running" | "waiting" | (string & {});
|
|
8
|
+
export type TurnPurpose = "summary" | (string & {});
|
|
9
|
+
export type MemoryOp = "delete" | "clear" | "enabled" | (string & {});
|
|
10
|
+
export interface Attachment {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: string;
|
|
13
|
+
origin: string;
|
|
14
|
+
mediaType: string;
|
|
15
|
+
bytes: number;
|
|
16
|
+
sha256: string;
|
|
17
|
+
width?: number;
|
|
18
|
+
height?: number;
|
|
19
|
+
alt?: string;
|
|
20
|
+
callId?: string;
|
|
21
|
+
deleted?: true;
|
|
22
|
+
deletedReason?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface EventError {
|
|
25
|
+
code: string;
|
|
26
|
+
category: ErrorCategory;
|
|
27
|
+
message: string;
|
|
28
|
+
/** Integer seconds, present only on the hourly app-paid rate_limited refusal. */
|
|
29
|
+
retryAfter?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface SendReceipt {
|
|
32
|
+
requestId: string;
|
|
33
|
+
status: InputDisposition;
|
|
34
|
+
seq: number;
|
|
35
|
+
error?: EventError;
|
|
36
|
+
}
|
|
37
|
+
export interface RequestResult {
|
|
38
|
+
id: string;
|
|
39
|
+
status: InputDisposition;
|
|
40
|
+
messages: Array<MessageEnd>;
|
|
41
|
+
gap?: true;
|
|
42
|
+
error?: EventError;
|
|
43
|
+
}
|
|
44
|
+
export interface InputEvent {
|
|
45
|
+
type: 'input';
|
|
46
|
+
id: string;
|
|
47
|
+
seq: number;
|
|
48
|
+
firstSeq: number;
|
|
49
|
+
kind: InputKind;
|
|
50
|
+
status: InputDisposition;
|
|
51
|
+
at: string;
|
|
52
|
+
text?: string;
|
|
53
|
+
error?: EventError;
|
|
54
|
+
}
|
|
55
|
+
export interface MessageStart {
|
|
56
|
+
type: 'message.start';
|
|
57
|
+
id: string;
|
|
58
|
+
seq: number;
|
|
59
|
+
firstSeq: number;
|
|
60
|
+
at: string;
|
|
61
|
+
}
|
|
62
|
+
export interface MessageDelta {
|
|
63
|
+
type: 'message.delta';
|
|
64
|
+
id: string;
|
|
65
|
+
text: string;
|
|
66
|
+
}
|
|
67
|
+
export interface MessageEnd {
|
|
68
|
+
type: 'message.end';
|
|
69
|
+
id: string;
|
|
70
|
+
seq: number;
|
|
71
|
+
firstSeq: number;
|
|
72
|
+
at: string;
|
|
73
|
+
status: MessageStatus;
|
|
74
|
+
text: string;
|
|
75
|
+
markers: Array<string>;
|
|
76
|
+
causedBy: Array<string>;
|
|
77
|
+
inReplyTo: Array<string>;
|
|
78
|
+
output?: Json;
|
|
79
|
+
error?: EventError;
|
|
80
|
+
}
|
|
81
|
+
export interface TurnEvent {
|
|
82
|
+
type: 'turn';
|
|
83
|
+
id: string;
|
|
84
|
+
inputs: Array<string>;
|
|
85
|
+
causedBy: Array<string>;
|
|
86
|
+
usage: Json;
|
|
87
|
+
cost: number | null;
|
|
88
|
+
costStatus: string;
|
|
89
|
+
model: string;
|
|
90
|
+
at: string;
|
|
91
|
+
purpose?: TurnPurpose;
|
|
92
|
+
/** Reported serving-provider label; absent when unavailable. Diagnostic only; never changes pricing or settlement. */
|
|
93
|
+
provider?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface ToolEvent {
|
|
96
|
+
type: 'tool';
|
|
97
|
+
id: string;
|
|
98
|
+
seq: number;
|
|
99
|
+
firstSeq: number;
|
|
100
|
+
origin: string;
|
|
101
|
+
causedBy: Array<string>;
|
|
102
|
+
tool: string;
|
|
103
|
+
key: string;
|
|
104
|
+
args: Json;
|
|
105
|
+
status: string;
|
|
106
|
+
cost: number | null;
|
|
107
|
+
costStatus: string;
|
|
108
|
+
startedAt: string;
|
|
109
|
+
at: string;
|
|
110
|
+
requestedBy?: string;
|
|
111
|
+
delivered?: Json;
|
|
112
|
+
outputs?: Json;
|
|
113
|
+
}
|
|
114
|
+
export interface StateEvent {
|
|
115
|
+
type: 'state';
|
|
116
|
+
status: AgentStatus;
|
|
117
|
+
queued: number;
|
|
118
|
+
typing: boolean;
|
|
119
|
+
activity: string | null;
|
|
120
|
+
tools?: Array<string>;
|
|
121
|
+
}
|
|
122
|
+
export interface SnapshotEvent {
|
|
123
|
+
type: 'snapshot';
|
|
124
|
+
logId: string;
|
|
125
|
+
state: Json;
|
|
126
|
+
streaming: Json;
|
|
127
|
+
}
|
|
128
|
+
export interface PageEvent {
|
|
129
|
+
type: 'page';
|
|
130
|
+
messages: Array<AgentEvent>;
|
|
131
|
+
reachedFloor: boolean;
|
|
132
|
+
logId: string;
|
|
133
|
+
clearedSeq: number;
|
|
134
|
+
}
|
|
135
|
+
export interface ClearedEvent {
|
|
136
|
+
type: 'cleared';
|
|
137
|
+
id: string;
|
|
138
|
+
at: string;
|
|
139
|
+
}
|
|
140
|
+
export interface MemoryEvent {
|
|
141
|
+
type: 'memory';
|
|
142
|
+
id: string;
|
|
143
|
+
op: MemoryOp;
|
|
144
|
+
at: string;
|
|
145
|
+
item?: string;
|
|
146
|
+
enabled?: boolean;
|
|
147
|
+
removed?: number;
|
|
148
|
+
}
|
|
149
|
+
export interface GapEvent {
|
|
150
|
+
type: 'gap';
|
|
151
|
+
afterSeq: number;
|
|
152
|
+
throughSeq: number;
|
|
153
|
+
reason: string;
|
|
154
|
+
}
|
|
155
|
+
export interface SubscriptionError {
|
|
156
|
+
type: 'error';
|
|
157
|
+
code: string;
|
|
158
|
+
message: string;
|
|
159
|
+
poisoned?: boolean;
|
|
160
|
+
}
|
|
161
|
+
export interface ReplacedEvent {
|
|
162
|
+
type: 'replaced';
|
|
163
|
+
}
|
|
164
|
+
export type AgentEvent = InputEvent | MessageStart | MessageDelta | MessageEnd | TurnEvent | ToolEvent | StateEvent | SnapshotEvent | PageEvent | ClearedEvent | MemoryEvent | GapEvent | SubscriptionError | ReplacedEvent | {
|
|
165
|
+
type: 'unknown';
|
|
166
|
+
originalType: string;
|
|
167
|
+
fields: Json;
|
|
168
|
+
};
|
|
169
|
+
export type ErrorCategory = 'offline' | 'allowance' | 'paused' | 'setup' | 'closed' | 'invalid' | 'internal';
|
|
170
|
+
export type JsonRepresentationErrorCode = "invalid_configuration" | "invalid_input" | "invalid_tool_result";
|
|
171
|
+
export declare const jsonRepresentationErrorCategories: Readonly<Record<JsonRepresentationErrorCode, ErrorCategory>>;
|
|
172
|
+
export declare const errorCategories: Readonly<Record<string, ErrorCategory>>;
|
|
173
|
+
export declare function errorCategory(code: string): ErrorCategory;
|
|
174
|
+
export declare function decodeAgentEvent(value: Json): AgentEvent;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export const jsonRepresentationErrorCategories = {
|
|
2
|
+
"invalid_configuration": "setup",
|
|
3
|
+
"invalid_input": "invalid",
|
|
4
|
+
"invalid_tool_result": "invalid"
|
|
5
|
+
};
|
|
6
|
+
export const errorCategories = {
|
|
7
|
+
"offline": "offline",
|
|
8
|
+
"network_error": "offline",
|
|
9
|
+
"request_timeout": "offline",
|
|
10
|
+
"gateway_unavailable": "offline",
|
|
11
|
+
"invalid_cloud_response": "offline",
|
|
12
|
+
"stale_control": "offline",
|
|
13
|
+
"http_<status>": "offline",
|
|
14
|
+
"account_credit_exhausted": "allowance",
|
|
15
|
+
"project_budget_exhausted": "allowance",
|
|
16
|
+
"user_allowance_exhausted": "allowance",
|
|
17
|
+
"development_allowance_exhausted": "allowance",
|
|
18
|
+
"unverified_allowance_exhausted": "allowance",
|
|
19
|
+
"gateway_key_exhausted": "allowance",
|
|
20
|
+
"provider_credit_unavailable": "allowance",
|
|
21
|
+
"usage_paused": "paused",
|
|
22
|
+
"runtime_blocked": "paused",
|
|
23
|
+
"project_access_disabled": "paused",
|
|
24
|
+
"account_disabled": "paused",
|
|
25
|
+
"server_key_revoked": "paused",
|
|
26
|
+
"debug_token_revoked": "paused",
|
|
27
|
+
"rate_limited": "paused",
|
|
28
|
+
"provider_rate_limited": "paused",
|
|
29
|
+
"allowance_grants_disabled": "setup",
|
|
30
|
+
"invalid_configuration": "setup",
|
|
31
|
+
"model_missing": "setup",
|
|
32
|
+
"model_withdrawn": "setup",
|
|
33
|
+
"model_unavailable": "setup",
|
|
34
|
+
"project_key_unknown": "setup",
|
|
35
|
+
"server_key_invalid": "setup",
|
|
36
|
+
"debug_token_invalid": "setup",
|
|
37
|
+
"user_required": "setup",
|
|
38
|
+
"gateway_key_rejected": "setup",
|
|
39
|
+
"gateway_unsupported": "setup",
|
|
40
|
+
"schema_unsupported": "setup",
|
|
41
|
+
"capability_unsupported": "setup",
|
|
42
|
+
"invalid_snapshot": "setup",
|
|
43
|
+
"snapshot_mismatch": "setup",
|
|
44
|
+
"invalid_tool": "setup",
|
|
45
|
+
"invalid_wiki": "setup",
|
|
46
|
+
"installation_unverified": "setup",
|
|
47
|
+
"attestation_required": "setup",
|
|
48
|
+
"attestation_rejected": "setup",
|
|
49
|
+
"attestation_unverifiable": "setup",
|
|
50
|
+
"attestation_failed": "setup",
|
|
51
|
+
"attestation_unavailable": "setup",
|
|
52
|
+
"attestation_unsupported": "setup",
|
|
53
|
+
"attestation_timeout": "setup",
|
|
54
|
+
"recovery_required": "setup",
|
|
55
|
+
"host_unavailable": "setup",
|
|
56
|
+
"core_unavailable": "setup",
|
|
57
|
+
"outcome_unknown": "closed",
|
|
58
|
+
"closed": "closed",
|
|
59
|
+
"target_closed": "closed",
|
|
60
|
+
"runtime_detached": "closed",
|
|
61
|
+
"cancelled": "closed",
|
|
62
|
+
"interrupted": "closed",
|
|
63
|
+
"preempted": "closed",
|
|
64
|
+
"aborted": "closed",
|
|
65
|
+
"observation_lost": "closed",
|
|
66
|
+
"store_busy": "closed",
|
|
67
|
+
"instance_busy": "closed",
|
|
68
|
+
"invalid_input": "invalid",
|
|
69
|
+
"input_too_large": "invalid",
|
|
70
|
+
"invalid_memory": "invalid",
|
|
71
|
+
"invalid_response_format": "invalid",
|
|
72
|
+
"invalid_request": "invalid",
|
|
73
|
+
"tool_unauthorized": "invalid",
|
|
74
|
+
"agent_conflict": "invalid",
|
|
75
|
+
"unknown_id": "invalid",
|
|
76
|
+
"idempotency_conflict": "invalid",
|
|
77
|
+
"identity_conflict": "invalid",
|
|
78
|
+
"busy": "invalid",
|
|
79
|
+
"queue_full": "invalid",
|
|
80
|
+
"cursor_reset": "invalid",
|
|
81
|
+
"context_limit": "invalid",
|
|
82
|
+
"output_limit": "invalid",
|
|
83
|
+
"iteration_limit": "invalid",
|
|
84
|
+
"structured_output_unsupported": "invalid",
|
|
85
|
+
"failure_unrecorded": "internal",
|
|
86
|
+
"internal": "internal",
|
|
87
|
+
"asset_read_failed": "internal",
|
|
88
|
+
"stream_incomplete": "internal",
|
|
89
|
+
"provider_error": "internal",
|
|
90
|
+
"provider_rejected": "internal",
|
|
91
|
+
"invalid_provider_response": "internal",
|
|
92
|
+
"invalid_response": "internal",
|
|
93
|
+
"output_too_large": "internal",
|
|
94
|
+
"output_invalid": "internal",
|
|
95
|
+
"empty_response": "internal",
|
|
96
|
+
"unexpected_tool_call": "internal",
|
|
97
|
+
"storage_error": "internal",
|
|
98
|
+
"store_refused": "internal",
|
|
99
|
+
"store_full": "internal",
|
|
100
|
+
"corrupt_store": "internal",
|
|
101
|
+
"store_too_new": "internal",
|
|
102
|
+
"fresh_reservation_lost": "internal",
|
|
103
|
+
"archive_unavailable": "internal",
|
|
104
|
+
"archive_error": "internal",
|
|
105
|
+
"host_error": "internal",
|
|
106
|
+
"host_unresponsive": "internal",
|
|
107
|
+
"thread_unavailable": "internal",
|
|
108
|
+
"core_error": "internal",
|
|
109
|
+
"invalid_abi": "internal",
|
|
110
|
+
"no_lock": "internal",
|
|
111
|
+
"handler_failed": "internal",
|
|
112
|
+
"subscriber_overflow": "internal"
|
|
113
|
+
};
|
|
114
|
+
export function errorCategory(code) { return /^http_[1-5][0-9]{2}$/.test(code) ? 'offline' : (Object.hasOwn(errorCategories, code) ? errorCategories[code] : 'internal'); }
|
|
115
|
+
const knownEventTypes = new Set(["input", "message.start", "message.delta", "message.end", "turn", "tool", "state", "snapshot", "page", "cleared", "memory", "gap", "error", "replaced"]);
|
|
116
|
+
export function decodeAgentEvent(value) {
|
|
117
|
+
if (value === null || Array.isArray(value) || typeof value !== 'object' || typeof value.type !== 'string')
|
|
118
|
+
throw new TypeError('An app event must have a string type.');
|
|
119
|
+
if (!knownEventTypes.has(value.type))
|
|
120
|
+
return { type: 'unknown', originalType: value.type, fields: value };
|
|
121
|
+
if (value.type === 'page' && Array.isArray(value.messages))
|
|
122
|
+
return { ...value, messages: value.messages.map(decodeAgentEvent) };
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Agent as SharedAgent } from './agent.js';
|
|
2
|
+
import { Croche as SharedCroche } from './croche.js';
|
|
3
|
+
import type { AgentOptions, OpenOptions } from './app-api.js';
|
|
4
|
+
export type Agent = Omit<SharedAgent, 'decide'>;
|
|
5
|
+
export declare const Agent: Omit<typeof SharedAgent, "prototype"> & {
|
|
6
|
+
readonly prototype: Agent;
|
|
7
|
+
[Symbol.hasInstance](value: unknown): value is Agent;
|
|
8
|
+
};
|
|
9
|
+
export type Croche = Omit<SharedCroche, 'agent'> & {
|
|
10
|
+
agent(id: string, options?: AgentOptions): Promise<Agent>;
|
|
11
|
+
};
|
|
12
|
+
export declare const Croche: Omit<typeof SharedCroche, "open" | "prototype"> & {
|
|
13
|
+
readonly prototype: Croche;
|
|
14
|
+
[Symbol.hasInstance](value: unknown): value is Croche;
|
|
15
|
+
open(options: OpenOptions, recovery?: {
|
|
16
|
+
recover: "delete";
|
|
17
|
+
}): Promise<Croche>;
|
|
18
|
+
};
|
|
19
|
+
export { defineTool, toolResult, ToolError, tools } from './tools.js';
|
|
20
|
+
export { CrocheError } from './errors.js';
|
|
21
|
+
export type { RunToolResult, Attachment, AgentEvent, AgentOptions, RequestResult, SendReceipt, EventError, BackgroundEvent, DebugAttachOptions, AttachedDebugger, DebugCapability, ErrorCategory, ImageInput, InputDisposition, Json, MemoryItem, MessageEnd, OpenOptions, PlatformHandle, ResponseFormat, SendInput, SendOptions, StoragePal, Subscription, TextInput, ToolArg, ToolCall, ToolContent, ToolContext, ToolDefinition, ToolEntryOptions, ToolExecute, ToolManifest, ToolRegistration, ToolResult, ToolScope, WikiDoc, WikiScope, } from './app-api.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Keel #1187 6883440525: RN has no decide surface until a Mac/Android bridge witness passes.
|
|
2
|
+
// Same runtime values and implementation; only the unbridged method/type surface differs.
|
|
3
|
+
import { Agent as SharedAgent } from './agent.js';
|
|
4
|
+
import { Croche as SharedCroche } from './croche.js';
|
|
5
|
+
export const Agent = SharedAgent;
|
|
6
|
+
export const Croche = SharedCroche;
|
|
7
|
+
export { defineTool, toolResult, ToolError, tools } from './tools.js';
|
|
8
|
+
export { CrocheError } from './errors.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `value` as JSON text; when it has no JSON form, a non-JSON text naming the value and its path, which Core
|
|
3
|
+
* refuses with the code of the slot it is handed in.
|
|
4
|
+
*/
|
|
5
|
+
export declare function jsonText(value: unknown, path?: string): string;
|
|
6
|
+
/** `value` as JSON text, or undefined when it has no JSON form (a tool result: the bridge hands Core the fact). */
|
|
7
|
+
export declare function encodable(value: unknown): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Serializes a method's options object. The ONE relaxation: a top-level option whose value is `undefined` is
|
|
10
|
+
* omitted (it is a TS optional). Everything below the top level goes through `jsonText`, so
|
|
11
|
+
* `{tools: [{tool: 'x', bind: undefined}]}` reaches Core as non-JSON text. `undefined` options = no options.
|
|
12
|
+
*/
|
|
13
|
+
export declare function optionsText(options: unknown): string | undefined;
|