@h1r-ai/croche-react-native 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +32 -4
  3. package/THIRD-PARTY-NOTICES +899 -6
  4. package/android/src/androidTest/java/dev/croche/reactnative/WikiFileBridgeTest.kt +4 -3
  5. package/android/src/main/AndroidManifest.xml +0 -5
  6. package/android/src/main/java/dev/croche/reactnative/CoreDispatch.kt +33 -8
  7. package/android/src/main/java/dev/croche/reactnative/CoreWire.kt +139 -5
  8. package/android/src/main/java/dev/croche/reactnative/CrocheRuntimeModule.kt +5 -2
  9. package/android/src/main/java/dev/croche/reactnative/NativePal.kt +23 -6
  10. package/android/src/test/java/dev/croche/reactnative/AgentMemoryTest.kt +28 -6
  11. package/android/src/test/java/dev/croche/reactnative/BackgroundDelegationTest.kt +4 -11
  12. package/android/src/test/java/dev/croche/reactnative/BlobFilesTest.kt +107 -0
  13. package/android/src/test/java/dev/croche/reactnative/ImageAdapterWireTest.kt +70 -0
  14. package/android/src/test/java/dev/croche/reactnative/OpenForwardingFixture.kt +19 -4
  15. package/android/src/test/java/dev/croche/reactnative/ProjectAttestationTest.kt +2 -2
  16. package/android/src/test/java/dev/croche/reactnative/StorageVersionWireTest.kt +37 -0
  17. package/android/src/test/java/dev/croche/reactnative/VerificationDispatchTest.kt +24 -0
  18. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/AndroidPlatform.kt +5 -3
  19. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BackgroundWakeWorker.kt +4 -0
  20. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapDecodedImageCodec.kt +11 -11
  21. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/BitmapImageCodec.kt +1 -0
  22. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidCoreHost.kt +11 -16
  23. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidPublicPlatform.kt +3 -3
  24. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidStateStore.kt +216 -0
  25. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/pal/AndroidStoragePal.kt +45 -10
  26. package/android/vendor/CrocheRuntimeSDK/consumer-rules.pro +0 -3
  27. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Adapters.kt +75 -0
  28. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/BindingFacts.kt +1 -1
  29. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ContextConfig.kt +9 -23
  30. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Core.kt +11 -2
  31. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Croche.kt +83 -20
  32. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheAgent.kt +54 -8
  33. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheRuntime.kt +19 -360
  34. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheTools.kt +79 -10
  35. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Decision.kt +170 -0
  36. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/DecodedImageCodec.kt +8 -5
  37. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Effects.kt +8 -1
  38. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/EncodedImageCodec.kt +51 -0
  39. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/GeneratedAppStream.kt +426 -33
  40. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Host.kt +1 -351
  41. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Images.kt +15 -29
  42. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeEvent.kt +59 -0
  43. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeHandleOwner.kt +118 -0
  44. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Platform.kt +10 -74
  45. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectTypes.kt +196 -10
  46. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/PublicResults.kt +86 -3
  47. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/RunTool.kt +33 -0
  48. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/SendEncoding.kt +1 -1
  49. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StateStore.kt +90 -0
  50. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/SubscriptionTypes.kt +68 -4
  51. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ffi/croche_ffi.kt +3403 -6894
  52. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/AppStoragePal.kt +89 -18
  53. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreFactoryCalls.kt +1 -2
  54. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreOptionsEncoding.kt +2 -2
  55. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/CoreStreamCalls.kt +3 -3
  56. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ForeignCallbacks.kt +17 -18
  57. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/ImageAdapterHost.kt +28 -0
  58. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmCoreHost.kt +12 -14
  59. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmStateStore.kt +125 -0
  60. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/JvmStoragePal.kt +36 -6
  61. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/NativeCoreInitialization.kt +21 -0
  62. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/NativePlatform.kt +21 -6
  63. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/PublicCalls.kt +16 -7
  64. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/StateStoreContract.kt +103 -0
  65. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/StorageVersionContract.kt +40 -0
  66. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/AtomicKeyFiles.kt +25 -4
  67. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/BlobFiles.kt +157 -0
  68. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/InstancePayloadPurge.kt +79 -0
  69. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/s7/pal/VersionedKeyFiles.kt +71 -0
  70. package/android/vendor/jniLibs/arm64-v8a/libcroche_ffi.so +0 -0
  71. package/android/vendor/jniLibs/armeabi-v7a/libcroche_ffi.so +0 -0
  72. package/android/vendor/jniLibs/x86_64/libcroche_ffi.so +0 -0
  73. package/croche-react-native.podspec +1 -0
  74. package/dist/react-native/src/core-native.d.ts +3 -0
  75. package/dist/react-native/src/core-native.js +148 -25
  76. package/dist/react-native/src/core-wire.d.ts +20 -3
  77. package/dist/rn-shared-build.json +8 -8
  78. package/dist/runtime/src/adapters.d.ts +8 -0
  79. package/dist/runtime/src/adapters.js +29 -0
  80. package/dist/runtime/src/agent.d.ts +53 -5
  81. package/dist/runtime/src/agent.js +69 -7
  82. package/dist/runtime/src/app-api.d.ts +307 -19
  83. package/dist/runtime/src/cancel.d.ts +2 -2
  84. package/dist/runtime/src/cancel.js +7 -4
  85. package/dist/runtime/src/core/foreground.d.ts +3 -0
  86. package/dist/runtime/src/core/foreground.js +40 -0
  87. package/dist/runtime/src/core/port.d.ts +48 -35
  88. package/dist/runtime/src/core/wasm-owner.d.ts +32 -0
  89. package/dist/runtime/src/core/wasm-owner.js +237 -0
  90. package/dist/runtime/src/croche.d.ts +64 -9
  91. package/dist/runtime/src/croche.js +78 -17
  92. package/dist/runtime/src/errors.d.ts +7 -0
  93. package/dist/runtime/src/errors.js +15 -1
  94. package/dist/runtime/src/generated/app-stream.d.ts +155 -1
  95. package/dist/runtime/src/generated/app-stream.js +7 -4
  96. package/dist/runtime/src/image-input.d.ts +5 -0
  97. package/dist/runtime/src/image-input.js +60 -0
  98. package/dist/runtime/src/index.d.ts +6 -0
  99. package/dist/runtime/src/index.js +5 -0
  100. package/dist/runtime/src/index.native.d.ts +1 -21
  101. package/dist/runtime/src/index.native.js +2 -8
  102. package/dist/runtime/src/native-adapter.d.ts +1 -1
  103. package/dist/runtime/src/native-adapter.js +10 -4
  104. package/dist/runtime/src/pal/host.d.ts +3 -3
  105. package/dist/runtime/src/pal/host.js +34 -9
  106. package/dist/runtime/src/pal/platform.d.ts +11 -6
  107. package/dist/runtime/src/pal/state-store-lock.d.ts +8 -0
  108. package/dist/runtime/src/pal/state-store-lock.js +2 -0
  109. package/dist/runtime/src/pal/state-store.d.ts +66 -0
  110. package/dist/runtime/src/pal/state-store.js +1 -0
  111. package/dist/runtime/src/pal/storage-version-contract.d.ts +19 -0
  112. package/dist/runtime/src/pal/storage-version-contract.js +68 -0
  113. package/dist/runtime/src/pal/transactional-storage.d.ts +3 -0
  114. package/dist/runtime/src/pal/transactional-storage.js +124 -0
  115. package/dist/runtime/src/tools.d.ts +20 -4
  116. package/dist/runtime/src/tools.js +31 -7
  117. package/ios/CoreAgentTransport.swift +2 -2
  118. package/ios/CoreNativePal.swift +26 -21
  119. package/ios/CorePlatformTransport.swift +4 -4
  120. package/ios/CoreWireDispatch.swift +38 -8
  121. package/ios/CoreWireSupport.swift +179 -4
  122. package/ios/CrocheRuntimeBridge.swift +1 -1
  123. package/ios/ProjectPal.swift +15 -12
  124. package/ios/vendor/CrocheRuntimeSDK/BlobFiles.swift +124 -0
  125. package/ios/vendor/CrocheRuntimeSDK/ContextConfig.swift +2 -6
  126. package/ios/vendor/CrocheRuntimeSDK/EncodedImages.swift +85 -0
  127. package/ios/vendor/CrocheRuntimeSDK/FFIStreamPort.swift +1 -174
  128. package/ios/vendor/CrocheRuntimeSDK/GeneratedAppStream.swift +233 -4
  129. package/ios/vendor/CrocheRuntimeSDK/Host.swift +1 -399
  130. package/ios/vendor/CrocheRuntimeSDK/ImagePal.swift +3 -3
  131. package/ios/vendor/CrocheRuntimeSDK/InstancePayloadPurge.swift +88 -0
  132. package/ios/vendor/CrocheRuntimeSDK/JSON.swift +26 -10
  133. package/ios/vendor/CrocheRuntimeSDK/OpenOptions.swift +0 -155
  134. package/ios/vendor/CrocheRuntimeSDK/Platform.swift +1 -27
  135. package/ios/vendor/CrocheRuntimeSDK/PlatformBackground.swift +8 -4
  136. package/ios/vendor/CrocheRuntimeSDK/PlatformPal.swift +57 -21
  137. package/ios/vendor/CrocheRuntimeSDK/PlatformStateStore.swift +253 -0
  138. package/ios/vendor/CrocheRuntimeSDK/PlatformStorage.swift +96 -10
  139. package/ios/vendor/CrocheRuntimeSDK/Project.swift +3 -382
  140. package/ios/vendor/CrocheRuntimeSDK/Runtime.swift +1 -412
  141. package/ios/vendor/CrocheRuntimeSDK/RuntimeHTTPAdapter.swift +42 -0
  142. package/ios/vendor/CrocheRuntimeSDK/S1/S1Adapters.swift +110 -0
  143. package/ios/vendor/CrocheRuntimeSDK/S1/S1Agent.swift +86 -33
  144. package/ios/vendor/CrocheRuntimeSDK/S1/S1Allowance.swift +20 -0
  145. package/ios/vendor/CrocheRuntimeSDK/S1/S1BindingFacts.swift +1 -1
  146. package/ios/vendor/CrocheRuntimeSDK/S1/S1Core.swift +12 -3
  147. package/ios/vendor/CrocheRuntimeSDK/S1/S1Croche.swift +135 -56
  148. package/ios/vendor/CrocheRuntimeSDK/S1/S1Decision.swift +146 -0
  149. package/ios/vendor/CrocheRuntimeSDK/S1/S1Events.swift +17 -8
  150. package/ios/vendor/CrocheRuntimeSDK/S1/S1HandleOwner.swift +58 -0
  151. package/ios/vendor/CrocheRuntimeSDK/S1/S1Options.swift +184 -15
  152. package/ios/vendor/CrocheRuntimeSDK/S1/S1RunTool.swift +31 -3
  153. package/ios/vendor/CrocheRuntimeSDK/S1/S1Storage.swift +131 -61
  154. package/ios/vendor/CrocheRuntimeSDK/S1/S1TestHooks.swift +10 -15
  155. package/ios/vendor/CrocheRuntimeSDK/S1/S1Tools.swift +86 -17
  156. package/ios/vendor/CrocheRuntimeSDK/S1/S1Verification.swift +27 -0
  157. package/ios/vendor/CrocheRuntimeSDK/S1/StateStoreContract.swift +189 -0
  158. package/ios/vendor/CrocheRuntimeSDK/S1/StorageVersionContract.swift +68 -0
  159. package/ios/vendor/CrocheRuntimeSDK/Storage.swift +3 -249
  160. package/ios/vendor/CrocheRuntimeSDK/SubscriptionTypes.swift +40 -8
  161. package/ios/vendor/CrocheRuntimeSDK/croche_ffi.swift +1720 -3883
  162. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64/Headers/croche_ffiFFI.h +816 -1649
  163. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64/libcroche_ffi.a +0 -0
  164. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64_x86_64-simulator/Headers/croche_ffiFFI.h +816 -1649
  165. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64_x86_64-simulator/libcroche_ffi.a +2 -2
  166. package/package.json +3 -3
  167. package/scripts/README.md +1 -1
  168. package/scripts/check-swift-vendor-modules.sh +15 -0
  169. package/scripts/vendor-native.sh +4 -3
  170. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/CrocheProjectRecordProvider.kt +0 -32
  171. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/WorkManagerScheduler.kt +0 -146
  172. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/AppStreamBranch.kt +0 -113
  173. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/NativeCoreStreamPort.kt +0 -201
  174. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectPalRouting.kt +0 -25
  175. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectRecords.kt +0 -87
  176. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Storage.kt +0 -181
  177. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StoragePal.kt +0 -18
  178. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StreamHub.kt +0 -252
  179. package/dist/runtime/src/pal/codec.d.ts +0 -15
  180. package/dist/runtime/src/pal/codec.js +0 -52
  181. package/ios/vendor/CrocheRuntimeSDK/Background.swift +0 -59
  182. package/ios/vendor/CrocheRuntimeSDK/StreamHub.swift +0 -496
  183. package/ios/vendor/CrocheRuntimeSDK/SubscriptionRuntime.swift +0 -44
@@ -8,6 +8,7 @@ import { CrocheError } from './errors.js';
8
8
  import { eventSink } from './events.js';
9
9
  import { jsonText, optionsText } from './json.js';
10
10
  import { createHost, storageFor } from './pal/host.js';
11
+ import { adaptersFor } from './adapters.js';
11
12
  import { coreDefinition } from './tools.js';
12
13
  import { runToolResult } from './run-tool.js';
13
14
  /** One `tools` entry: Core's definition handle, and the app's WHOLE wrapper object with `tool` as null (S1 #830).
@@ -30,20 +31,22 @@ const nullIfGiven = (options, key) => options[key] === undefined ? {} : { [key]:
30
31
  /** OpenOptions as Core takes it (vectors/s1-null-markers-06.json): the whole JSON with each given opaque reference as
31
32
  * a null marker in place, the registrations in order, the storage and the host. */
32
33
  function opening(options, recoveryGiven = false) {
34
+ const selected = adaptersFor(options.adapters);
33
35
  const entries = options.tools === undefined || recoveryGiven ? [] : Array.from(options.tools, registration);
34
36
  const whole = {
35
37
  ...options,
36
38
  ...(options.tools === undefined ? {} : { tools: recoveryGiven ? Array.from(options.tools, () => null) : entries.map(entry => entry.marker) }),
37
- ...nullIfGiven(options, 'storage'),
39
+ ...(options.adapters === undefined ? {} : { adapters: options.adapters.map(adapter => ({ kind: adapter.kind })) }),
38
40
  ...nullIfGiven(options, 'platform'),
39
41
  };
40
42
  return {
41
43
  json: optionsText(whole),
42
44
  registrations: entries.map(entry => entry.registration),
43
- storage: storageFor(options.storage),
44
- host: createHost(options.platform),
45
+ host: createHost(options.platform, selected.image, selected.blob),
46
+ storage: storageFor(selected.storage),
45
47
  };
46
48
  }
49
+ /** A user's Croche session for opening agents, running tools and accessing shared resources. */
47
50
  export class Croche {
48
51
  #module;
49
52
  #core;
@@ -51,6 +54,7 @@ export class Croche {
51
54
  this.#module = module;
52
55
  this.#core = core;
53
56
  }
57
+ /** Open the app’s user session before letting that user talk to an agent or run a tool. */
54
58
  static async open(options, recovery) {
55
59
  const module = coreModule();
56
60
  const recoveryJson = optionsText(recovery);
@@ -59,46 +63,99 @@ export class Croche {
59
63
  const { json, registrations, storage, host } = opening(options, recoveryJson !== undefined);
60
64
  return new Croche(module, await module.open(json, registrations, storage, host, recoveryJson));
61
65
  }
62
- /** Deletes this user's local data in the scope. Core closes selected agents first. */
66
+ /**
67
+ * Honor a user’s request to erase one workspace or all their local Croche data.
68
+ *
69
+ * Deletes this user's local data in the scope. Core closes selected agents first.
70
+ */
63
71
  async deleteData(scope) {
64
72
  await this.#core.deleteData(optionsText(scope));
65
73
  }
66
74
  /**
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).
75
+ * Let the app keep up with due work when its UI is no longer in the foreground.
76
+ *
77
+ * Once at app start. Core keeps BackgroundEvents durably and delivers each at least once to the sink. Use the same
78
+ * adapters as open() (the platform defaults when omitted).
69
79
  */
70
80
  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));
81
+ const { adapters, ...given } = options ?? {};
82
+ if (Object.hasOwn(given, 'storage')) {
83
+ throw new CrocheError('invalid_configuration', 'Pass the StateStore in adapters.', 'setup');
84
+ }
85
+ const { sink } = given;
86
+ const { storage: state, image, blob } = adaptersFor(adapters);
87
+ const host = createHost(undefined, image, blob);
88
+ // The SDK selects adapters. Core still validates other options and the opaque storage and sink markers.
89
+ const json = optionsText({ ...given, ...nullIfGiven(given, 'sink'), ...(state === undefined ? {} : { storage: null }) });
90
+ coreModule().registerBackground(json, sink && eventSink(event => sink.onEvent(event)), storageFor(state), undefined, // INTERNAL platform_storage: Node and web have no separate OS default store
91
+ host);
77
92
  }
93
+ /**
94
+ * Let a server schedule just the users whose background work is due.
95
+ *
96
+ * Read delivery deadlines without opening a project. before/after are epoch milliseconds; after is inclusive.
97
+ */
78
98
  static async wakeTimes(options, query) {
79
99
  const { json, storage, host } = opening(options);
80
100
  return JSON.parse(await coreModule().wakeTimes(json, optionsText(query), storage, host));
81
101
  }
102
+ /** Let a host deliver scheduled work when its timer or alarm fires. */
82
103
  async deliverDue(options) {
83
104
  const { signal, ...rest } = options ?? {};
84
105
  const json = options === undefined ? undefined : optionsText(rest);
85
106
  return JSON.parse(await this.#core.deliverDue(json, tokenFor(this.#module, signal)));
86
107
  }
108
+ /** Give each chat, case, or workspace its own conversation while reusing the app’s agent definition. */
87
109
  async agent(id, options) {
88
110
  return wrapAgent(this.#module, await this.#core.agent(id, optionsText(options)));
89
111
  }
90
- /** App tools run outside every conversation. Recovery uses the same required id. */
112
+ /**
113
+ * Let an app button run a tool outside chat, such as generating an image for a form.
114
+ *
115
+ * App tools run outside every conversation. Recovery uses the same required id.
116
+ */
91
117
  async runTool(name, args, options) {
92
118
  const { signal, ...rest } = options;
93
119
  return runToolResult(await this.#core.runTool(name, jsonText(args), optionsText(rest), tokenFor(this.#module, signal)));
94
120
  }
95
- /** Read from Core at every access. */
96
- get agentIds() { return this.#core.agentIds(); }
121
+ /**
122
+ * Load a shared attachment when the user opens its preview.
123
+ *
124
+ * Read from Core at every access.
125
+ */
126
+ attachment(id) { return this.#core.attachment(id).then(JSON.parse); }
127
+ /** Let the user remove a shared attachment they no longer want to keep. */
128
+ deleteAttachment(id) { return this.#core.deleteAttachment(id); }
129
+ /** Populate a picker of attachments shared by this user’s agents, newest first, one page at a time. */
130
+ listAttachments(options) {
131
+ return this.#core.listAttachments(optionsText(options)).then(JSON.parse);
132
+ }
133
+ /**
134
+ * Set this user's allowance: the most credits the runtime lets this user spend per UTC day.
135
+ * Absolute, it replaces the earlier value; `null` returns the user to Studio's default. The runtime
136
+ * counts and enforces it from its own storage; Croche Cloud keeps no per-user ledger
137
+ * (founder 2026-11-21: «사용자 한도 안에서는 런타임이 보호하고.. (클라우드x»).
138
+ */
139
+ allowance = {
140
+ /** Set the user's absolute UTC-day limit in credits. Pass null to use Studio's default. */
141
+ set: async (limit) => { await this.#core.allowanceSet(jsonText(limit)); },
142
+ };
143
+ /**
144
+ * Let the app show how Croche Cloud verified this installation, or explain a withheld key.
145
+ *
146
+ * Read-only, from stored registration state; it never calls Cloud.
147
+ */
148
+ async verification() { return JSON.parse(await this.#core.verification()); }
149
+ /** Access the project's wiki documents available to this user. */
97
150
  wiki = {
151
+ /** Make an updated help article available to agents in the current app session. */
98
152
  put: (doc) => this.#core.wikiPut(jsonText(doc)),
153
+ /** Stop agents from using a help article the app has withdrawn. */
99
154
  remove: (path) => this.#core.wikiRemove(path),
100
- list: async () => JSON.parse(await this.#core.wikiList()),
155
+ /** Show which help articles the app has made available to its agents. */
156
+ list: async (options) => JSON.parse(await this.#core.wikiList(optionsText(options))),
101
157
  };
158
+ /** Access debugger controls for this session. */
102
159
  debugger = {
103
160
  attach: async (options) => {
104
161
  const answer = await this.#core.debugAttach(jsonText(options));
@@ -106,6 +163,10 @@ export class Croche {
106
163
  },
107
164
  detach: () => this.#core.debugDetach(),
108
165
  };
109
- /** Resolves once new work has stopped; Core continues the bounded final delivery. */
166
+ /**
167
+ * Release the user’s session when they sign out or the app switches accounts.
168
+ *
169
+ * Resolves once new work has stopped; Core continues the bounded final delivery.
170
+ */
110
171
  close() { return this.#core.shutdown(); }
111
172
  }
@@ -1,9 +1,14 @@
1
1
  import type { ErrorCategory } from './generated/app-stream.js';
2
2
  export type { ErrorCategory } from './generated/app-stream.js';
3
+ /** A structured failure reported by Core or the SDK. */
3
4
  export declare class CrocheError extends Error {
5
+ /** Machine-readable error code. */
4
6
  readonly code: string;
7
+ /** Group used to decide how the app should handle the error. */
5
8
  readonly category: ErrorCategory;
9
+ /** Suggested retry delay in seconds, when supplied. */
6
10
  readonly retryAfter?: number;
11
+ /** Create an error with a code, human-readable message, category and optional retry delay. */
7
12
  constructor(code: string, message: string, category: ErrorCategory, retryAfter?: number);
8
13
  }
9
14
  /** A PAL effect's failure, as a fact for Core: a code and a message, no category, no policy. */
@@ -24,3 +29,5 @@ export declare function thrownError(error: unknown): {
24
29
  type: string;
25
30
  message: string;
26
31
  } | undefined;
32
+ /** Core's error (code, message, category, path?) as the app's CrocheError; anything else passes unchanged. */
33
+ export declare function coreFailure(error: unknown): unknown;
@@ -1,12 +1,17 @@
1
1
  // 0.6 App API error (docs/APP-API.md). Core supplies `code` and `category` for its own errors and the port rejects
2
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).
3
+ // (json.ts), a Core that cannot load (core/wasm.ts), a registration that is not a tool definition (croche.ts),
4
+ // or an unsupported JS host (index.unsupported.ts).
4
5
  // An SDK-shipped effect (HTTP, codec, assets) that fails throws a HostError with a code from that effect's closed list;
5
6
  // Core validates it and picks the category. A storage primitive that fails throws a plain Error: Core reports
6
7
  // storage_error (ARCHITECTURE #837).
8
+ /** A structured failure reported by Core or the SDK. */
7
9
  export class CrocheError extends Error {
10
+ /** Machine-readable error code. */
8
11
  code;
12
+ /** Group used to decide how the app should handle the error. */
9
13
  category;
14
+ /** Create an error with a code, human-readable message, category and optional retry delay. */
10
15
  constructor(code, message, category, retryAfter) {
11
16
  super(message);
12
17
  this.name = 'CrocheError';
@@ -47,3 +52,12 @@ export function thrownError(error) {
47
52
  return undefined;
48
53
  return { type: name, message };
49
54
  }
55
+ /** Core's error (code, message, category, path?) as the app's CrocheError; anything else passes unchanged. */
56
+ export function coreFailure(error) {
57
+ if (error instanceof CrocheError || typeof error !== 'object' || error === null)
58
+ return error;
59
+ const { code, message, category, retryAfter } = error;
60
+ if (typeof code !== 'string' || typeof category !== 'string')
61
+ return error;
62
+ return new CrocheError(code, typeof message === 'string' ? message : code, category, retryAfter);
63
+ }
@@ -1,171 +1,325 @@
1
1
  export type Json = null | boolean | number | string | Json[] | {
2
2
  [key: string]: Json;
3
3
  };
4
+ /** Status of an accepted input: `queued` or `seen`, then one terminal status. */
4
5
  export type InputDisposition = "queued" | "seen" | "answered" | "no_reply" | "failed" | "cancelled" | (string & {});
6
+ /** Kind of an input's parts. */
5
7
  export type InputKind = "user" | "app_event" | "app_state" | (string & {});
8
+ /** How an agent reply ended. */
6
9
  export type MessageStatus = "completed" | "failed" | "cancelled" | "interrupted" | (string & {});
10
+ /** Whether the agent has work. */
7
11
  export type AgentStatus = "idle" | "running" | "waiting" | (string & {});
12
+ /** Why a model call other than an ordinary reply call was made. */
8
13
  export type TurnPurpose = "summary" | (string & {});
14
+ /** A memory operation the app can make. */
9
15
  export type MemoryOp = "delete" | "clear" | "enabled" | (string & {});
16
+ /** Metadata of a stored image original that Core keeps for the app, a message or a tool call. */
10
17
  export interface Attachment {
18
+ /** Core-assigned attachment id, used to read, copy, release or delete the original. */
11
19
  id: string;
20
+ /** What the attachment is; Core currently stores only `image` (open string). */
12
21
  kind: string;
22
+ /** Where the stored original came from, for example `tool` (produced by a tool call) or `app` (copied in by the app). */
13
23
  origin: string;
24
+ /** Image media type of the stored original, for example `image/png`. */
14
25
  mediaType: string;
26
+ /** Size of the stored original in bytes. */
15
27
  bytes: number;
28
+ /** Lowercase hex SHA-256 of the stored original's bytes. */
16
29
  sha256: string;
30
+ /** The original's pixel width, when Core reports it; absent otherwise. */
17
31
  width?: number;
32
+ /** The original's pixel height, when Core reports it; absent otherwise. */
18
33
  height?: number;
34
+ /** Description text supplied with the image; absent when none was given. */
19
35
  alt?: string;
36
+ /** Id of the agent tool call that produced the original (the same id as `ToolEvent.id`); absent for originals not produced by a call. */
20
37
  callId?: string;
38
+ /** Present only as `true` when the original is no longer stored at read time; the logged row itself is not changed. */
21
39
  deleted?: true;
40
+ /** Why the original is gone: `deleted` (explicitly deleted or missing), `evicted` (removed to make room or past retention) or `cleared` (released by a history clear); present only with `deleted`. */
22
41
  deletedReason?: string;
23
42
  }
43
+ /** An error carried by an event or result, with the category that tells the app how to react. */
24
44
  export interface EventError {
45
+ /** Error code, for example `store_full` or `interrupted`; a code outside the known table has category `internal`. */
25
46
  code: string;
47
+ /** What the app does about the error. */
26
48
  category: ErrorCategory;
49
+ /** Human-readable explanation of the error. */
27
50
  message: string;
28
51
  /** Integer seconds, present only on the hourly app-paid rate_limited refusal. */
29
52
  retryAfter?: number;
30
53
  }
54
+ /** An image that could not be viewed for one model call; the call continues with the image's id and description. */
55
+ export interface ViewError {
56
+ /** Id of the attachment whose view failed. */
57
+ attachmentId: string;
58
+ /** Error code for the failed view, for example `image_unsupported`. */
59
+ code: string;
60
+ /** What the app does about the error. */
61
+ category: ErrorCategory;
62
+ /** Human-readable explanation of why the view failed. */
63
+ message: string;
64
+ }
65
+ /** Returned when Core accepts a send: the input's id, its status at acceptance and where its events start in the stream. */
31
66
  export interface SendReceipt {
67
+ /** Id of the accepted input. */
32
68
  requestId: string;
69
+ /** The input's status when the receipt was made; `queued` for a newly accepted input, or the recorded status when the same id was sent again. */
33
70
  status: InputDisposition;
71
+ /** Stream sequence of the input's first event, or for a just-accepted input the position its events start from. */
34
72
  seq: number;
73
+ /** Why the input failed; present when `status` is `failed`. */
35
74
  error?: EventError;
36
75
  }
76
+ /** The terminal result of an accepted `request`: the input's final status and the replies it caused. */
37
77
  export interface RequestResult {
78
+ /** Id of the input this result is for. */
38
79
  id: string;
80
+ /** The input's terminal status. */
39
81
  status: InputDisposition;
82
+ /** The retained `message.end` events whose `causedBy` includes this input. */
40
83
  messages: Array<MessageEnd>;
84
+ /** Present only as `true` when some of this input's events were already pruned, so `messages` can be incomplete or empty. */
41
85
  gap?: true;
86
+ /** Why the input failed; always present when `status` is `failed`. */
42
87
  error?: EventError;
43
88
  }
89
+ /** An input was accepted or its status changed; each change re-emits the input's full current state. */
44
90
  export interface InputEvent {
45
91
  type: 'input';
92
+ /** Id of the input. */
46
93
  id: string;
94
+ /** Stream sequence of this event. */
47
95
  seq: number;
96
+ /** Stream sequence of this input's first event; the same on every update of the input. */
48
97
  firstSeq: number;
98
+ /** Which kind of input parts this row shows. */
49
99
  kind: InputKind;
100
+ /** The input's status after this change. */
50
101
  status: InputDisposition;
102
+ /** ISO 8601 time of this change. */
51
103
  at: string;
104
+ /** Text of the input's parts of this `kind`, joined with blank lines; absent when Core holds no summary for the input. */
52
105
  text?: string;
106
+ /** Why the input failed; always present when `status` is `failed` and absent otherwise. */
53
107
  error?: EventError;
54
108
  }
109
+ /** A held send left without running; Core emits it after reopen for a send that was held when the app stopped. */
110
+ export interface InputDropped {
111
+ type: 'input.dropped';
112
+ /** Id of the dropped input. */
113
+ inputId: string;
114
+ /** Why the input was dropped; Core's stream emits `reopened` (open string). */
115
+ reason: string;
116
+ /** Stream sequence of this event. */
117
+ seq: number;
118
+ /** Stream sequence of the input's first event when it had one, otherwise this event's own sequence. */
119
+ firstSeq: number;
120
+ }
121
+ /** An agent reply began; Core emits it when the reply has its first visible text, before any of its deltas. */
55
122
  export interface MessageStart {
56
123
  type: 'message.start';
124
+ /** Id of the reply message, shared by its start, deltas and end. */
57
125
  id: string;
126
+ /** Stream sequence of this event. */
58
127
  seq: number;
128
+ /** Stream sequence of the message's first event, which is this start. */
59
129
  firstSeq: number;
130
+ /** ISO 8601 time the reply started. */
60
131
  at: string;
61
132
  }
133
+ /** New text of the open reply as it is written; a preview only, since `message.end` carries the stored text. */
62
134
  export interface MessageDelta {
63
135
  type: 'message.delta';
136
+ /** Id of the open reply message. */
64
137
  id: string;
138
+ /** Text added to the reply since the previous delta. */
65
139
  text: string;
66
140
  }
141
+ /** The end of an agent reply with its stored text and final status; never rewritten. */
67
142
  export interface MessageEnd {
68
143
  type: 'message.end';
144
+ /** Id of the reply message. */
69
145
  id: string;
146
+ /** Stream sequence of this event. */
70
147
  seq: number;
148
+ /** Stream sequence of the message's first event (its `message.start`). */
71
149
  firstSeq: number;
150
+ /** ISO 8601 time the reply ended. */
72
151
  at: string;
152
+ /** How the reply ended. */
73
153
  status: MessageStatus;
154
+ /** The stored reply text with markers removed; empty after an interruption or when the reply was too large to store. */
74
155
  text: string;
156
+ /** Names of the registered markers found in the reply, in reply order. */
75
157
  markers: Array<string>;
158
+ /** Ids of the inputs the turn producing this reply worked for. */
76
159
  causedBy: Array<string>;
160
+ /** Ids of the inputs this reply answered; only a `completed` reply answers inputs, so it is empty otherwise. */
77
161
  inReplyTo: Array<string>;
162
+ /** The reply before marker removal; equal to `text` when markers did not change it. */
163
+ raw: string;
164
+ /** The checked structured-output value of a reply made with a response format; absent otherwise. */
78
165
  output?: Json;
166
+ /** Why the reply did not complete; always present when `status` is `failed`. */
79
167
  error?: EventError;
168
+ /** Originals attached to this reply; absent when there are none. */
169
+ attachments?: Array<Attachment>;
80
170
  }
171
+ /** One model call was recorded, with its usage, cost and model; Core writes it when it records the call's cost. */
81
172
  export interface TurnEvent {
82
173
  type: 'turn';
174
+ /** Opaque id of the model call; do not parse it. */
83
175
  id: string;
176
+ /** Ids of the inputs first seen by this call. */
84
177
  inputs: Array<string>;
178
+ /** Ids of every input this call worked for. */
85
179
  causedBy: Array<string>;
180
+ /** Token counts reported for the call (`prompt`, `completion`, `total`, `cached`, `cacheWrite`, `reasoning` when reported), or null when none were reported. */
86
181
  usage: Json;
182
+ /** Cost of the call in credits; null when unknown. */
87
183
  cost: number | null;
184
+ /** How final `cost` is, for example `reported` (final), `unknown` (null cost), `estimated` (provisional) or `none` (zero cost). */
88
185
  costStatus: string;
186
+ /** The model recorded for the call; the requested model when no response named one. */
89
187
  model: string;
188
+ /** ISO 8601 time the call was recorded. */
90
189
  at: string;
190
+ /** `summary` when the call made a context summary; absent for an ordinary model call. */
91
191
  purpose?: TurnPurpose;
92
192
  /** Reported serving-provider label; absent when unavailable. Diagnostic only; never changes pricing or settlement. */
93
193
  provider?: string;
194
+ /** Images whose view failed; the call continues with their id and description. */
195
+ viewErrors?: Array<ViewError>;
94
196
  }
197
+ /** An agent tool call started or changed status; updates keep the same id and `firstSeq`. */
95
198
  export interface ToolEvent {
96
199
  type: 'tool';
200
+ /** Opaque Core-assigned call id, the same as `ToolContext.callId` and an attachment's `callId`; do not parse it. */
97
201
  id: string;
202
+ /** Stream sequence of this event. */
98
203
  seq: number;
204
+ /** Stream sequence of the call's first event; the same on every update of the call. */
99
205
  firstSeq: number;
206
+ /** Who made the call; Core emits `agent` for these events (open string). */
100
207
  origin: string;
208
+ /** Ids of the inputs the call works for. */
101
209
  causedBy: Array<string>;
210
+ /** Name of the called tool. */
102
211
  tool: string;
212
+ /** Stable command key of the called command. */
103
213
  key: string;
214
+ /** Arguments of the call, without app-bound arguments; `{}` when there are none. */
104
215
  args: Json;
216
+ /** Status of the call: `running`, `waiting` (its result arrives later), `completed`, `failed`, `cancelled` or `unused` (a late result whose cause was cancelled) (open string). */
105
217
  status: string;
218
+ /** Cost of the call in credits; null while running or when unknown, 0 for an unpaid call. */
106
219
  cost: number | null;
220
+ /** How final `cost` is, for example `unknown` while running, `reported`, or `none` for an unpaid call. */
107
221
  costStatus: string;
222
+ /** ISO 8601 time the call started. */
108
223
  startedAt: string;
224
+ /** ISO 8601 time of this update. */
109
225
  at: string;
226
+ /** Id of the `turn` event for the model call that requested this tool call; absent when not recorded. */
110
227
  requestedBy?: string;
228
+ /** What the model was given as the result: `{text}`, plus `images` metadata (`mediaType`, `bytes`, `attachment`) for result images; absent while running, and removed when Core closes an unsettled call as failed or cancelled. */
111
229
  delivered?: Json;
230
+ /** Originals the call kept as attachments, as `{attachments: [{id, mediaType, bytes}]}`; absent when none. */
112
231
  outputs?: Json;
113
232
  }
233
+ /** The agent's current state: status, queue length, typing, and what running work is doing. */
114
234
  export interface StateEvent {
115
235
  type: 'state';
236
+ /** Whether the agent is idle, running or waiting. */
116
237
  status: AgentStatus;
238
+ /** Number of accepted sends waiting in the queue. */
117
239
  queued: number;
240
+ /** True while a reply's `message.start` is written and its `message.end` is not. */
118
241
  typing: boolean;
242
+ /** What running work is doing, for example `model`, `summary` or `tool`; null unless `status` is `running`. */
119
243
  activity: string | null;
244
+ /** Names of the tools in the current round, in call order (built-in or app command key, else `unknown`); present only when `activity` is `tool`. */
120
245
  tools?: Array<string>;
121
246
  }
247
+ /** The subscription's starting point: the current log, state and the reply being streamed; delivered first on attach. */
122
248
  export interface SnapshotEvent {
123
249
  type: 'snapshot';
250
+ /** Id of the log the subscription reads; pass it back with a `seq` to resume. */
124
251
  logId: string;
252
+ /** The current `state` event. */
125
253
  state: Json;
254
+ /** The reply being streamed now as `{messageId, firstSeq, text}`, or null when none. */
126
255
  streaming: Json;
127
256
  }
257
+ /** An older page of the conversation, delivered after `subscription.history()`. */
128
258
  export interface PageEvent {
129
259
  type: 'page';
260
+ /** The page's rows oldest first, each as its latest event. */
130
261
  messages: Array<AgentEvent>;
262
+ /** True when no older retained row was left out of this page. */
131
263
  reachedFloor: boolean;
264
+ /** Id of the log the page was read from. */
132
265
  logId: string;
266
+ /** Stream sequence of the latest history clear, or 0 when there was none. */
133
267
  clearedSeq: number;
134
268
  }
269
+ /** A full `clearHistory()` took effect; empty the displayed conversation. */
135
270
  export interface ClearedEvent {
136
271
  type: 'cleared';
272
+ /** Core-assigned id of this clear. */
137
273
  id: string;
274
+ /** ISO 8601 time the clear took effect. */
138
275
  at: string;
139
276
  }
277
+ /** A memory delete, clear or enable change took effect. */
140
278
  export interface MemoryEvent {
141
279
  type: 'memory';
280
+ /** Core-assigned id of the memory operation. */
142
281
  id: string;
282
+ /** Which memory operation took effect. */
143
283
  op: MemoryOp;
284
+ /** ISO 8601 time the operation took effect. */
144
285
  at: string;
286
+ /** Id of the deleted memory fact; present only for `delete`. */
145
287
  item?: string;
288
+ /** The new memory setting; present only for `enabled`. */
146
289
  enabled?: boolean;
290
+ /** Number of memory facts removed; present for `delete` and `clear`. */
147
291
  removed?: number;
148
292
  }
293
+ /** Events were missed; redraw from a `page`. */
149
294
  export interface GapEvent {
150
295
  type: 'gap';
296
+ /** Last stream sequence before the missed range. */
151
297
  afterSeq: number;
298
+ /** Last missed stream sequence (inclusive). */
152
299
  throughSeq: number;
300
+ /** Why the events are missing: `limit` (retention pruned them) or `cleared` (a history clear removed them). */
153
301
  reason: string;
154
302
  }
303
+ /** The subscription ended with an error; it receives no further events. */
155
304
  export interface SubscriptionError {
156
305
  type: 'error';
306
+ /** Error code, for example `storage_error`. */
157
307
  code: string;
308
+ /** Human-readable explanation of the error. */
158
309
  message: string;
310
+ /** Present only as `true` when a storage failure stopped the agent from writing; reopen to continue. */
159
311
  poisoned?: boolean;
160
312
  }
313
+ /** The subscription ended because a newer subscription replaced it. */
161
314
  export interface ReplacedEvent {
162
315
  type: 'replaced';
163
316
  }
164
- export type AgentEvent = InputEvent | MessageStart | MessageDelta | MessageEnd | TurnEvent | ToolEvent | StateEvent | SnapshotEvent | PageEvent | ClearedEvent | MemoryEvent | GapEvent | SubscriptionError | ReplacedEvent | {
317
+ export type AgentEvent = InputEvent | InputDropped | MessageStart | MessageDelta | MessageEnd | TurnEvent | ToolEvent | StateEvent | SnapshotEvent | PageEvent | ClearedEvent | MemoryEvent | GapEvent | SubscriptionError | ReplacedEvent | {
165
318
  type: 'unknown';
166
319
  originalType: string;
167
320
  fields: Json;
168
321
  };
322
+ /** What the app does about an error. A code outside Core's table has category `internal`. */
169
323
  export type ErrorCategory = 'offline' | 'allowance' | 'paused' | 'setup' | 'closed' | 'invalid' | 'internal';
170
324
  export type JsonRepresentationErrorCode = "invalid_configuration" | "invalid_input" | "invalid_tool_result";
171
325
  export declare const jsonRepresentationErrorCategories: Readonly<Record<JsonRepresentationErrorCode, ErrorCategory>>;
@@ -23,17 +23,18 @@ export const errorCategories = {
23
23
  "project_access_disabled": "paused",
24
24
  "account_disabled": "paused",
25
25
  "server_key_revoked": "paused",
26
- "debug_token_revoked": "paused",
26
+ "development_key_revoked": "paused",
27
+ "development_device_limit": "paused",
27
28
  "rate_limited": "paused",
28
29
  "provider_rate_limited": "paused",
29
- "allowance_grants_disabled": "setup",
30
+ "user_allowance_disabled": "setup",
30
31
  "invalid_configuration": "setup",
31
32
  "model_missing": "setup",
32
33
  "model_withdrawn": "setup",
33
34
  "model_unavailable": "setup",
34
35
  "project_key_unknown": "setup",
35
36
  "server_key_invalid": "setup",
36
- "debug_token_invalid": "setup",
37
+ "development_key_invalid": "setup",
37
38
  "user_required": "setup",
38
39
  "gateway_key_rejected": "setup",
39
40
  "gateway_unsupported": "setup",
@@ -54,6 +55,7 @@ export const errorCategories = {
54
55
  "recovery_required": "setup",
55
56
  "host_unavailable": "setup",
56
57
  "core_unavailable": "setup",
58
+ "state_conflict": "closed",
57
59
  "outcome_unknown": "closed",
58
60
  "closed": "closed",
59
61
  "target_closed": "closed",
@@ -73,6 +75,7 @@ export const errorCategories = {
73
75
  "tool_unauthorized": "invalid",
74
76
  "agent_conflict": "invalid",
75
77
  "unknown_id": "invalid",
78
+ "attachment_storage_full": "invalid",
76
79
  "idempotency_conflict": "invalid",
77
80
  "identity_conflict": "invalid",
78
81
  "busy": "invalid",
@@ -112,7 +115,7 @@ export const errorCategories = {
112
115
  "subscriber_overflow": "internal"
113
116
  };
114
117
  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"]);
118
+ const knownEventTypes = new Set(["input", "input.dropped", "message.start", "message.delta", "message.end", "turn", "tool", "state", "snapshot", "page", "cleared", "memory", "gap", "error", "replaced"]);
116
119
  export function decodeAgentEvent(value) {
117
120
  if (value === null || Array.isArray(value) || typeof value !== 'object' || typeof value.type !== 'string')
118
121
  throw new TypeError('An app event must have a string type.');
@@ -0,0 +1,5 @@
1
+ import type { CoreAttachmentInput } from './core/port.js';
2
+ /** Preserve the strict serializer's refusal for non-JSON values. For JSON image
3
+ * elements, move only valid base64 bytes beside the JSON, indexed by position.
4
+ * The caller's objects and every other member are left unchanged. */
5
+ export declare function imageInput(input: unknown): [string, CoreAttachmentInput[]];