@ny4n/durable 0.0.0-stage → 1.0.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 (303) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +711 -2
  3. package/dist/documents.d.ts +66 -0
  4. package/dist/documents.d.ts.map +1 -0
  5. package/dist/documents.js +98 -0
  6. package/dist/documents.js.map +1 -0
  7. package/dist/entries.d.ts +31 -0
  8. package/dist/entries.d.ts.map +1 -0
  9. package/dist/entries.js +31 -0
  10. package/dist/entries.js.map +1 -0
  11. package/dist/env/decode.d.ts +16 -0
  12. package/dist/env/decode.d.ts.map +1 -0
  13. package/dist/env/decode.js +28 -0
  14. package/dist/env/decode.js.map +1 -0
  15. package/dist/env/index.d.ts +263 -0
  16. package/dist/env/index.d.ts.map +1 -0
  17. package/dist/env/index.js +49 -0
  18. package/dist/env/index.js.map +1 -0
  19. package/dist/env/line-scan.d.ts +13 -0
  20. package/dist/env/line-scan.d.ts.map +1 -0
  21. package/dist/env/line-scan.js +147 -0
  22. package/dist/env/line-scan.js.map +1 -0
  23. package/dist/env/node-watch.d.ts +29 -0
  24. package/dist/env/node-watch.d.ts.map +1 -0
  25. package/dist/env/node-watch.js +485 -0
  26. package/dist/env/node-watch.js.map +1 -0
  27. package/dist/env/node.d.ts +56 -0
  28. package/dist/env/node.d.ts.map +1 -0
  29. package/dist/env/node.js +1166 -0
  30. package/dist/env/node.js.map +1 -0
  31. package/dist/errors.d.ts +32 -0
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/errors.js +53 -0
  34. package/dist/errors.js.map +1 -0
  35. package/dist/harness/agent.d.ts +33 -0
  36. package/dist/harness/agent.d.ts.map +1 -0
  37. package/dist/harness/agent.js +235 -0
  38. package/dist/harness/agent.js.map +1 -0
  39. package/dist/harness/assistant.d.ts +15 -0
  40. package/dist/harness/assistant.d.ts.map +1 -0
  41. package/dist/harness/assistant.js +23 -0
  42. package/dist/harness/assistant.js.map +1 -0
  43. package/dist/harness/compaction.d.ts +56 -0
  44. package/dist/harness/compaction.d.ts.map +1 -0
  45. package/dist/harness/compaction.js +384 -0
  46. package/dist/harness/compaction.js.map +1 -0
  47. package/dist/harness/context.d.ts +63 -0
  48. package/dist/harness/context.d.ts.map +1 -0
  49. package/dist/harness/context.js +221 -0
  50. package/dist/harness/context.js.map +1 -0
  51. package/dist/harness/define.d.ts +18 -0
  52. package/dist/harness/define.d.ts.map +1 -0
  53. package/dist/harness/define.js +25 -0
  54. package/dist/harness/define.js.map +1 -0
  55. package/dist/harness/events.d.ts +180 -0
  56. package/dist/harness/events.d.ts.map +1 -0
  57. package/dist/harness/events.js +370 -0
  58. package/dist/harness/events.js.map +1 -0
  59. package/dist/harness/generation.d.ts +54 -0
  60. package/dist/harness/generation.d.ts.map +1 -0
  61. package/dist/harness/generation.js +514 -0
  62. package/dist/harness/generation.js.map +1 -0
  63. package/dist/harness/harness.d.ts +17 -0
  64. package/dist/harness/harness.d.ts.map +1 -0
  65. package/dist/harness/harness.js +332 -0
  66. package/dist/harness/harness.js.map +1 -0
  67. package/dist/harness/inbox.d.ts +59 -0
  68. package/dist/harness/inbox.d.ts.map +1 -0
  69. package/dist/harness/inbox.js +97 -0
  70. package/dist/harness/inbox.js.map +1 -0
  71. package/dist/harness/json.d.ts +10 -0
  72. package/dist/harness/json.d.ts.map +1 -0
  73. package/dist/harness/json.js +33 -0
  74. package/dist/harness/json.js.map +1 -0
  75. package/dist/harness/live.d.ts +142 -0
  76. package/dist/harness/live.d.ts.map +1 -0
  77. package/dist/harness/live.js +149 -0
  78. package/dist/harness/live.js.map +1 -0
  79. package/dist/harness/output.d.ts +69 -0
  80. package/dist/harness/output.d.ts.map +1 -0
  81. package/dist/harness/output.js +318 -0
  82. package/dist/harness/output.js.map +1 -0
  83. package/dist/harness/prompt.d.ts +27 -0
  84. package/dist/harness/prompt.d.ts.map +1 -0
  85. package/dist/harness/prompt.js +131 -0
  86. package/dist/harness/prompt.js.map +1 -0
  87. package/dist/harness/provider.d.ts +14 -0
  88. package/dist/harness/provider.d.ts.map +1 -0
  89. package/dist/harness/provider.js +30 -0
  90. package/dist/harness/provider.js.map +1 -0
  91. package/dist/harness/registry.d.ts +6 -0
  92. package/dist/harness/registry.d.ts.map +1 -0
  93. package/dist/harness/registry.js +101 -0
  94. package/dist/harness/registry.js.map +1 -0
  95. package/dist/harness/run.d.ts +17 -0
  96. package/dist/harness/run.d.ts.map +1 -0
  97. package/dist/harness/run.js +26 -0
  98. package/dist/harness/run.js.map +1 -0
  99. package/dist/harness/scheduler.d.ts +106 -0
  100. package/dist/harness/scheduler.d.ts.map +1 -0
  101. package/dist/harness/scheduler.js +1743 -0
  102. package/dist/harness/scheduler.js.map +1 -0
  103. package/dist/harness/submissions.d.ts +29 -0
  104. package/dist/harness/submissions.d.ts.map +1 -0
  105. package/dist/harness/submissions.js +175 -0
  106. package/dist/harness/submissions.js.map +1 -0
  107. package/dist/harness/task-graph.d.ts +49 -0
  108. package/dist/harness/task-graph.d.ts.map +1 -0
  109. package/dist/harness/task-graph.js +168 -0
  110. package/dist/harness/task-graph.js.map +1 -0
  111. package/dist/harness/tool.d.ts +76 -0
  112. package/dist/harness/tool.d.ts.map +1 -0
  113. package/dist/harness/tool.js +736 -0
  114. package/dist/harness/tool.js.map +1 -0
  115. package/dist/harness/types.d.ts +713 -0
  116. package/dist/harness/types.d.ts.map +1 -0
  117. package/dist/harness/types.js +2 -0
  118. package/dist/harness/types.js.map +1 -0
  119. package/dist/harness/usage.d.ts +18 -0
  120. package/dist/harness/usage.d.ts.map +1 -0
  121. package/dist/harness/usage.js +57 -0
  122. package/dist/harness/usage.js.map +1 -0
  123. package/dist/harness/util.d.ts +19 -0
  124. package/dist/harness/util.d.ts.map +1 -0
  125. package/dist/harness/util.js +58 -0
  126. package/dist/harness/util.js.map +1 -0
  127. package/dist/harness/view.d.ts +47 -0
  128. package/dist/harness/view.d.ts.map +1 -0
  129. package/dist/harness/view.js +206 -0
  130. package/dist/harness/view.js.map +1 -0
  131. package/dist/ids.d.ts +6 -0
  132. package/dist/ids.d.ts.map +1 -0
  133. package/dist/ids.js +9 -0
  134. package/dist/ids.js.map +1 -0
  135. package/dist/images/cloudflare.d.ts +4 -0
  136. package/dist/images/cloudflare.d.ts.map +1 -0
  137. package/dist/images/cloudflare.js +9 -0
  138. package/dist/images/cloudflare.js.map +1 -0
  139. package/dist/images/exif.d.ts +3 -0
  140. package/dist/images/exif.d.ts.map +1 -0
  141. package/dist/images/exif.js +71 -0
  142. package/dist/images/exif.js.map +1 -0
  143. package/dist/images/index.d.ts +18 -0
  144. package/dist/images/index.d.ts.map +1 -0
  145. package/dist/images/index.js +125 -0
  146. package/dist/images/index.js.map +1 -0
  147. package/dist/images/node-worker.d.ts +17 -0
  148. package/dist/images/node-worker.d.ts.map +1 -0
  149. package/dist/images/node-worker.js +16 -0
  150. package/dist/images/node-worker.js.map +1 -0
  151. package/dist/images/node.d.ts +21 -0
  152. package/dist/images/node.d.ts.map +1 -0
  153. package/dist/images/node.js +121 -0
  154. package/dist/images/node.js.map +1 -0
  155. package/dist/index.d.ts +24 -0
  156. package/dist/index.d.ts.map +1 -0
  157. package/dist/index.js +20 -0
  158. package/dist/index.js.map +1 -0
  159. package/dist/session/forks.d.ts +10 -0
  160. package/dist/session/forks.d.ts.map +1 -0
  161. package/dist/session/forks.js +42 -0
  162. package/dist/session/forks.js.map +1 -0
  163. package/dist/session/observation.d.ts +42 -0
  164. package/dist/session/observation.d.ts.map +1 -0
  165. package/dist/session/observation.js +281 -0
  166. package/dist/session/observation.js.map +1 -0
  167. package/dist/session/session.d.ts +133 -0
  168. package/dist/session/session.d.ts.map +1 -0
  169. package/dist/session/session.js +811 -0
  170. package/dist/session/session.js.map +1 -0
  171. package/dist/session/transaction.d.ts +119 -0
  172. package/dist/session/transaction.d.ts.map +1 -0
  173. package/dist/session/transaction.js +795 -0
  174. package/dist/session/transaction.js.map +1 -0
  175. package/dist/storage/jsonl/index.d.ts +2 -0
  176. package/dist/storage/jsonl/index.d.ts.map +1 -0
  177. package/dist/storage/jsonl/index.js +2 -0
  178. package/dist/storage/jsonl/index.js.map +1 -0
  179. package/dist/storage/jsonl/node.d.ts +6 -0
  180. package/dist/storage/jsonl/node.d.ts.map +1 -0
  181. package/dist/storage/jsonl/node.js +8 -0
  182. package/dist/storage/jsonl/node.js.map +1 -0
  183. package/dist/storage/jsonl/storage.d.ts +143 -0
  184. package/dist/storage/jsonl/storage.d.ts.map +1 -0
  185. package/dist/storage/jsonl/storage.js +682 -0
  186. package/dist/storage/jsonl/storage.js.map +1 -0
  187. package/dist/storage/memory.d.ts +62 -0
  188. package/dist/storage/memory.d.ts.map +1 -0
  189. package/dist/storage/memory.js +733 -0
  190. package/dist/storage/memory.js.map +1 -0
  191. package/dist/storage/scan.d.ts +18 -0
  192. package/dist/storage/scan.d.ts.map +1 -0
  193. package/dist/storage/scan.js +29 -0
  194. package/dist/storage/scan.js.map +1 -0
  195. package/dist/storage/sqlite/cloudflare.d.ts +46 -0
  196. package/dist/storage/sqlite/cloudflare.d.ts.map +1 -0
  197. package/dist/storage/sqlite/cloudflare.js +106 -0
  198. package/dist/storage/sqlite/cloudflare.js.map +1 -0
  199. package/dist/storage/sqlite/database.d.ts +37 -0
  200. package/dist/storage/sqlite/database.d.ts.map +1 -0
  201. package/dist/storage/sqlite/database.js +2 -0
  202. package/dist/storage/sqlite/database.js.map +1 -0
  203. package/dist/storage/sqlite/index.d.ts +4 -0
  204. package/dist/storage/sqlite/index.d.ts.map +1 -0
  205. package/dist/storage/sqlite/index.js +3 -0
  206. package/dist/storage/sqlite/index.js.map +1 -0
  207. package/dist/storage/sqlite/migrations.d.ts +11 -0
  208. package/dist/storage/sqlite/migrations.d.ts.map +1 -0
  209. package/dist/storage/sqlite/migrations.js +111 -0
  210. package/dist/storage/sqlite/migrations.js.map +1 -0
  211. package/dist/storage/sqlite/node.d.ts +41 -0
  212. package/dist/storage/sqlite/node.d.ts.map +1 -0
  213. package/dist/storage/sqlite/node.js +179 -0
  214. package/dist/storage/sqlite/node.js.map +1 -0
  215. package/dist/storage/sqlite/storage.d.ts +65 -0
  216. package/dist/storage/sqlite/storage.d.ts.map +1 -0
  217. package/dist/storage/sqlite/storage.js +670 -0
  218. package/dist/storage/sqlite/storage.js.map +1 -0
  219. package/dist/tasks.d.ts +6 -0
  220. package/dist/tasks.d.ts.map +1 -0
  221. package/dist/tasks.js +5 -0
  222. package/dist/tasks.js.map +1 -0
  223. package/dist/testing/assertions.d.ts +5 -0
  224. package/dist/testing/assertions.d.ts.map +1 -0
  225. package/dist/testing/assertions.js +25 -0
  226. package/dist/testing/assertions.js.map +1 -0
  227. package/dist/testing/env-conformance.d.ts +7 -0
  228. package/dist/testing/env-conformance.d.ts.map +1 -0
  229. package/dist/testing/env-conformance.js +431 -0
  230. package/dist/testing/env-conformance.js.map +1 -0
  231. package/dist/testing/index.d.ts +7 -0
  232. package/dist/testing/index.d.ts.map +1 -0
  233. package/dist/testing/index.js +6 -0
  234. package/dist/testing/index.js.map +1 -0
  235. package/dist/testing/runner.d.ts +12 -0
  236. package/dist/testing/runner.d.ts.map +1 -0
  237. package/dist/testing/runner.js +23 -0
  238. package/dist/testing/runner.js.map +1 -0
  239. package/dist/testing/storage-benchmark.d.ts +41 -0
  240. package/dist/testing/storage-benchmark.d.ts.map +1 -0
  241. package/dist/testing/storage-benchmark.js +350 -0
  242. package/dist/testing/storage-benchmark.js.map +1 -0
  243. package/dist/testing/storage-conformance.d.ts +4 -0
  244. package/dist/testing/storage-conformance.d.ts.map +1 -0
  245. package/dist/testing/storage-conformance.js +1213 -0
  246. package/dist/testing/storage-conformance.js.map +1 -0
  247. package/dist/testing/types.d.ts +37 -0
  248. package/dist/testing/types.d.ts.map +1 -0
  249. package/dist/testing/types.js +2 -0
  250. package/dist/testing/types.js.map +1 -0
  251. package/dist/tools/bash.d.ts +55 -0
  252. package/dist/tools/bash.d.ts.map +1 -0
  253. package/dist/tools/bash.js +138 -0
  254. package/dist/tools/bash.js.map +1 -0
  255. package/dist/tools/edit-diff.d.ts +89 -0
  256. package/dist/tools/edit-diff.d.ts.map +1 -0
  257. package/dist/tools/edit-diff.js +386 -0
  258. package/dist/tools/edit-diff.js.map +1 -0
  259. package/dist/tools/edit.d.ts +18 -0
  260. package/dist/tools/edit.d.ts.map +1 -0
  261. package/dist/tools/edit.js +117 -0
  262. package/dist/tools/edit.js.map +1 -0
  263. package/dist/tools/env.d.ts +5 -0
  264. package/dist/tools/env.d.ts.map +1 -0
  265. package/dist/tools/env.js +7 -0
  266. package/dist/tools/env.js.map +1 -0
  267. package/dist/tools/file-mutation-queue.d.ts +9 -0
  268. package/dist/tools/file-mutation-queue.d.ts.map +1 -0
  269. package/dist/tools/file-mutation-queue.js +52 -0
  270. package/dist/tools/file-mutation-queue.js.map +1 -0
  271. package/dist/tools/image-processor.d.ts +47 -0
  272. package/dist/tools/image-processor.d.ts.map +1 -0
  273. package/dist/tools/image-processor.js +30 -0
  274. package/dist/tools/image-processor.js.map +1 -0
  275. package/dist/tools/image.d.ts +20 -0
  276. package/dist/tools/image.d.ts.map +1 -0
  277. package/dist/tools/image.js +178 -0
  278. package/dist/tools/image.js.map +1 -0
  279. package/dist/tools/index.d.ts +46 -0
  280. package/dist/tools/index.d.ts.map +1 -0
  281. package/dist/tools/index.js +23 -0
  282. package/dist/tools/index.js.map +1 -0
  283. package/dist/tools/path-utils.d.ts +5 -0
  284. package/dist/tools/path-utils.d.ts.map +1 -0
  285. package/dist/tools/path-utils.js +26 -0
  286. package/dist/tools/path-utils.js.map +1 -0
  287. package/dist/tools/read.d.ts +25 -0
  288. package/dist/tools/read.d.ts.map +1 -0
  289. package/dist/tools/read.js +235 -0
  290. package/dist/tools/read.js.map +1 -0
  291. package/dist/tools/write.d.ts +10 -0
  292. package/dist/tools/write.d.ts.map +1 -0
  293. package/dist/tools/write.js +31 -0
  294. package/dist/tools/write.js.map +1 -0
  295. package/dist/truncate.d.ts +64 -0
  296. package/dist/truncate.d.ts.map +1 -0
  297. package/dist/truncate.js +154 -0
  298. package/dist/truncate.js.map +1 -0
  299. package/dist/types.d.ts +932 -0
  300. package/dist/types.d.ts.map +1 -0
  301. package/dist/types.js +3 -0
  302. package/dist/types.js.map +1 -0
  303. package/package.json +140 -5
@@ -0,0 +1,66 @@
1
+ import { type JsonValue } from "@ny4n/chord";
2
+ import type { Op } from "@ny4n/chord/delta";
3
+ import type { CheckpointInfo, CommonDocDefinition, ConversationDocFamilyToken, ConversationDocToken, DocumentAddress, DocumentCreate, DocumentId, DocumentRecord, DocumentSemantics, JsonObject, LatestConversationSemantics, RewindableConversationDocFamilyToken, RewindableConversationDocToken, RewindableConversationSemantics, SessionDocFamilyToken, SessionDocToken, StoredDocument, TaskDocFamilyToken, TaskDocToken } from "./types.ts";
4
+ type FamilyInput<T extends JsonObject, I extends JsonValue> = Omit<CommonDocDefinition<T>, "initial"> & {
5
+ readonly family: true;
6
+ initial(seed: I): T;
7
+ };
8
+ /** Define a Session-scoped singleton document. */
9
+ export declare function defineDoc<T extends JsonObject>(definition: CommonDocDefinition<T> & {
10
+ readonly scope: "session";
11
+ }): SessionDocToken<T>;
12
+ /** Define a latest-only conversation singleton document. */
13
+ export declare function defineDoc<T extends JsonObject>(definition: CommonDocDefinition<T> & LatestConversationSemantics): ConversationDocToken<T>;
14
+ /** Define a rewindable conversation singleton document. */
15
+ export declare function defineDoc<T extends JsonObject>(definition: CommonDocDefinition<T> & RewindableConversationSemantics): RewindableConversationDocToken<T>;
16
+ /** Define a task-scoped singleton document. */
17
+ export declare function defineDoc<T extends JsonObject>(definition: CommonDocDefinition<T> & {
18
+ readonly scope: "task";
19
+ }): TaskDocToken<T>;
20
+ /** Define a Session-scoped document family. */
21
+ export declare function defineDocFamily<T extends JsonObject, I extends JsonValue>(definition: FamilyInput<T, I> & {
22
+ readonly scope: "session";
23
+ }): SessionDocFamilyToken<T, I>;
24
+ /** Define a latest-only conversation document family. */
25
+ export declare function defineDocFamily<T extends JsonObject, I extends JsonValue>(definition: FamilyInput<T, I> & LatestConversationSemantics): ConversationDocFamilyToken<T, I>;
26
+ /** Define a rewindable conversation document family. */
27
+ export declare function defineDocFamily<T extends JsonObject, I extends JsonValue>(definition: FamilyInput<T, I> & RewindableConversationSemantics): RewindableConversationDocFamilyToken<T, I>;
28
+ /** Define a task-scoped document family. */
29
+ export declare function defineDocFamily<T extends JsonObject, I extends JsonValue>(definition: FamilyInput<T, I> & {
30
+ readonly scope: "task";
31
+ }): TaskDocFamilyToken<T, I>;
32
+ /** Erased definition shape used by the Session after overload resolution. */
33
+ export type AnyDocDefinition = DocumentSemantics & {
34
+ readonly kind: string;
35
+ readonly version: number;
36
+ readonly family?: true;
37
+ initial(seed?: JsonValue): JsonObject;
38
+ migrate?(value: JsonObject, fromVersion: number): JsonObject;
39
+ checkpointWhen?(value: Readonly<JsonObject>, ops: readonly Op[], info: CheckpointInfo): boolean;
40
+ };
41
+ /** Erased singleton or family token. */
42
+ export type AnyDocToken = {
43
+ readonly definition: AnyDocDefinition;
44
+ };
45
+ /** Logical address plus its string identity for maps. */
46
+ export type ResolvedAddress = {
47
+ readonly address: DocumentAddress;
48
+ readonly id: string;
49
+ readonly nextArgument: number;
50
+ };
51
+ /** Resolve an overloaded argument list and return the index after the owner and family key. */
52
+ export declare function resolveAddress(definition: AnyDocDefinition, args: readonly unknown[]): ResolvedAddress;
53
+ /** Stable string identity of one logical address. */
54
+ export declare function addressId(address: DocumentAddress): string;
55
+ /** Build the storage create record for a new incarnation at an address. */
56
+ export declare function documentCreate(definition: AnyDocDefinition, address: DocumentAddress, id: DocumentId): DocumentCreate;
57
+ /** Reject typed access whose token disagrees with the persisted scope, history, or fork semantics. */
58
+ export declare function checkRecordScope(definition: AnyDocDefinition, record: DocumentCreate | DocumentRecord): void;
59
+ /** Reject typed access to a stored version the supplied definition cannot use. */
60
+ export declare function checkRecordVersion(definition: AnyDocDefinition, record: DocumentCreate | DocumentRecord, version: number): void;
61
+ /** Validate and materialize a detached stored value for typed access. */
62
+ export declare function materializeDocument(definition: AnyDocDefinition, stored: StoredDocument): JsonObject;
63
+ /** Validate and materialize one detached value before its first persisted incarnation. */
64
+ export declare function materializeDocumentValue(definition: AnyDocDefinition, record: DocumentCreate | DocumentRecord, version: number, value: JsonObject): JsonObject;
65
+ export {};
66
+ //# sourceMappingURL=documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,KAAK,EACX,cAAc,EACd,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,EAMpB,eAAe,EACf,cAAc,EACd,UAAU,EACV,cAAc,EACd,iBAAiB,EAEjB,UAAU,EACV,2BAA2B,EAC3B,oCAAoC,EACpC,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,YAAY,EAEZ,MAAM,YAAY,CAAC;AAEpB,KAAK,WAAW,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,SAAS,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG;IACvG,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;CACpB,CAAC;AAEF,kDAAkD;AAClD,wBAAgB,SAAS,CAAC,CAAC,SAAS,UAAU,EAC7C,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAChE,eAAe,CAAC,CAAC,CAAC,CAAC;AACtB,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,CAAC,SAAS,UAAU,EAC7C,UAAU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AED,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,GAAG,cAAc,GAAG,IAAI,CAQ5G;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CACjC,UAAU,EAAE,gBAAgB,EAC5B,MAAM,EAAE,cAAc,GAAG,cAAc,EACvC,OAAO,EAAE,MAAM,GACb,IAAI,CAON;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,GAAG,UAAU,CAEpG;AAED,0FAA0F;AAC1F,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,gBAAgB,EAC5B,MAAM,EAAE,cAAc,GAAG,cAAc,EACvC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,UAAU,GACf,UAAU,CAKZ"}
@@ -0,0 +1,98 @@
1
+ import { copyJson } from "@ny4n/chord";
2
+ import { idFromNumber } from "./ids.js";
3
+ export function defineDoc(definition) {
4
+ validateDefinition(definition);
5
+ return { definition };
6
+ }
7
+ export function defineDocFamily(definition) {
8
+ validateDefinition(definition);
9
+ return { definition };
10
+ }
11
+ function validateDefinition(definition) {
12
+ if (!Number.isSafeInteger(definition.version) || definition.version < 1) {
13
+ throw new TypeError(`Document ${definition.kind} version must be a positive integer`);
14
+ }
15
+ }
16
+ /** Resolve an overloaded argument list and return the index after the owner and family key. */
17
+ export function resolveAddress(definition, args) {
18
+ let index = 0;
19
+ let scope;
20
+ switch (definition.scope) {
21
+ case "session":
22
+ scope = { kind: "session" };
23
+ break;
24
+ case "conversation":
25
+ scope = { kind: "conversation", conversationId: ownerId(args[index++], definition) };
26
+ break;
27
+ case "task":
28
+ scope = { kind: "task", taskId: ownerId(args[index++], definition) };
29
+ break;
30
+ }
31
+ const key = definition.family === true ? args[index++] : undefined;
32
+ const address = key === undefined ? { kind: definition.kind, scope } : { kind: definition.kind, scope, key };
33
+ return { address, id: addressId(address), nextArgument: index };
34
+ }
35
+ function ownerId(value, definition) {
36
+ if (typeof value !== "number" || !Number.isSafeInteger(value)) {
37
+ throw new TypeError(`Document ${definition.kind} requires a ${definition.scope} ID`);
38
+ }
39
+ return idFromNumber(value);
40
+ }
41
+ /** Stable string identity of one logical address. */
42
+ export function addressId(address) {
43
+ const owner = address.scope.kind === "session"
44
+ ? null
45
+ : address.scope.kind === "conversation"
46
+ ? address.scope.conversationId
47
+ : address.scope.taskId;
48
+ return JSON.stringify([address.kind, address.scope.kind, owner, address.key ?? null]);
49
+ }
50
+ /** Build the storage create record for a new incarnation at an address. */
51
+ export function documentCreate(definition, address, id) {
52
+ const key = address.key === undefined ? {} : { key: address.key };
53
+ switch (address.scope.kind) {
54
+ case "session":
55
+ return { id, kind: address.kind, ...key, scope: address.scope };
56
+ case "task":
57
+ return { id, kind: address.kind, ...key, scope: address.scope };
58
+ case "conversation":
59
+ return {
60
+ id,
61
+ kind: address.kind,
62
+ ...key,
63
+ scope: address.scope,
64
+ history: definition.history,
65
+ fork: definition.fork,
66
+ };
67
+ }
68
+ }
69
+ /** Reject typed access whose token disagrees with the persisted scope, history, or fork semantics. */
70
+ export function checkRecordScope(definition, record) {
71
+ if (record.scope.kind !== definition.scope ||
72
+ (record.scope.kind === "conversation" &&
73
+ (record.history !== definition.history || record.fork !== definition.fork))) {
74
+ throw new TypeError(`Document ${record.id} (${record.kind}) does not match the supplied definition semantics`);
75
+ }
76
+ }
77
+ /** Reject typed access to a stored version the supplied definition cannot use. */
78
+ export function checkRecordVersion(definition, record, version) {
79
+ if (version > definition.version) {
80
+ throw new Error(`Document ${record.id} (${record.kind}) has newer version ${version} than ${definition.version}`);
81
+ }
82
+ if (version < definition.version && definition.migrate === undefined) {
83
+ throw new Error(`Document ${record.id} (${record.kind}) requires migration from version ${version}`);
84
+ }
85
+ }
86
+ /** Validate and materialize a detached stored value for typed access. */
87
+ export function materializeDocument(definition, stored) {
88
+ return materializeDocumentValue(definition, stored.record, stored.version, stored.value);
89
+ }
90
+ /** Validate and materialize one detached value before its first persisted incarnation. */
91
+ export function materializeDocumentValue(definition, record, version, value) {
92
+ checkRecordScope(definition, record);
93
+ checkRecordVersion(definition, record, version);
94
+ if (version === definition.version)
95
+ return value;
96
+ return copyJson(definition.migrate(value, version));
97
+ }
98
+ //# sourceMappingURL=documents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.js","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAmDxC,MAAM,UAAU,SAAS,CAAuB,UAA4B;IAC3E,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC/B,OAAO,EAAE,UAAU,EAAE,CAAC;AACvB,CAAC;AAkBD,MAAM,UAAU,eAAe,CAC9B,UAAqC;IAErC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC/B,OAAO,EAAE,UAAU,EAAE,CAAC;AACvB,CAAC;AAeD,SAAS,kBAAkB,CAAC,UAA4B;IACvD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,SAAS,CAAC,YAAY,UAAU,CAAC,IAAI,qCAAqC,CAAC,CAAC;IACvF,CAAC;AACF,CAAC;AASD,+FAA+F;AAC/F,MAAM,UAAU,cAAc,CAAC,UAA4B,EAAE,IAAwB;IACpF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAA+B,CAAC;IACpC,QAAQ,UAAU,CAAC,KAAK,EAAE,CAAC;QAC1B,KAAK,SAAS;YACb,KAAK,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;YAC5B,MAAM;QACP,KAAK,cAAc;YAClB,KAAK,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,CAAiB,IAAI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OAAO,QAAQ,CAAC,UAAU,CAAC,OAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAe,CAAC;AACpE,CAAC","sourcesContent":["import { copyJson, type JsonValue } from \"@ny4n/chord\";\nimport type { Op } from \"@ny4n/chord/delta\";\nimport { idFromNumber } from \"./ids.ts\";\nimport type {\n\tCheckpointInfo,\n\tCommonDocDefinition,\n\tConversationDocFamilyToken,\n\tConversationDocToken,\n\tConversationId,\n\tDocDefinition,\n\tDocFamilyDefinition,\n\tDocFamilyToken,\n\tDocToken,\n\tDocumentAddress,\n\tDocumentCreate,\n\tDocumentId,\n\tDocumentRecord,\n\tDocumentSemantics,\n\tId,\n\tJsonObject,\n\tLatestConversationSemantics,\n\tRewindableConversationDocFamilyToken,\n\tRewindableConversationDocToken,\n\tRewindableConversationSemantics,\n\tSessionDocFamilyToken,\n\tSessionDocToken,\n\tStoredDocument,\n\tTaskDocFamilyToken,\n\tTaskDocToken,\n\tTaskId,\n} from \"./types.ts\";\n\ntype FamilyInput<T extends JsonObject, I extends JsonValue> = Omit<CommonDocDefinition<T>, \"initial\"> & {\n\treadonly family: true;\n\tinitial(seed: I): T;\n};\n\n/** Define a Session-scoped singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & { readonly scope: \"session\" },\n): SessionDocToken<T>;\n/** Define a latest-only conversation singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & LatestConversationSemantics,\n): ConversationDocToken<T>;\n/** Define a rewindable conversation singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & RewindableConversationSemantics,\n): RewindableConversationDocToken<T>;\n/** Define a task-scoped singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & { readonly scope: \"task\" },\n): TaskDocToken<T>;\nexport function defineDoc<T extends JsonObject>(definition: DocDefinition<T>): DocToken<T, DocDefinition<T>> {\n\tvalidateDefinition(definition);\n\treturn { definition };\n}\n\n/** Define a Session-scoped document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & { readonly scope: \"session\" },\n): SessionDocFamilyToken<T, I>;\n/** Define a latest-only conversation document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & LatestConversationSemantics,\n): ConversationDocFamilyToken<T, I>;\n/** Define a rewindable conversation document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & RewindableConversationSemantics,\n): RewindableConversationDocFamilyToken<T, I>;\n/** Define a task-scoped document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & { readonly scope: \"task\" },\n): TaskDocFamilyToken<T, I>;\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: DocFamilyDefinition<T, I>,\n): DocFamilyToken<T, I, DocFamilyDefinition<T, I>> {\n\tvalidateDefinition(definition);\n\treturn { definition };\n}\n\n/** Erased definition shape used by the Session after overload resolution. */\nexport type AnyDocDefinition = DocumentSemantics & {\n\treadonly kind: string;\n\treadonly version: number;\n\treadonly family?: true;\n\tinitial(seed?: JsonValue): JsonObject;\n\tmigrate?(value: JsonObject, fromVersion: number): JsonObject;\n\tcheckpointWhen?(value: Readonly<JsonObject>, ops: readonly Op[], info: CheckpointInfo): boolean;\n};\n\n/** Erased singleton or family token. */\nexport type AnyDocToken = { readonly definition: AnyDocDefinition };\n\nfunction validateDefinition(definition: AnyDocDefinition): void {\n\tif (!Number.isSafeInteger(definition.version) || definition.version < 1) {\n\t\tthrow new TypeError(`Document ${definition.kind} version must be a positive integer`);\n\t}\n}\n\n/** Logical address plus its string identity for maps. */\nexport type ResolvedAddress = {\n\treadonly address: DocumentAddress;\n\treadonly id: string;\n\treadonly nextArgument: number;\n};\n\n/** Resolve an overloaded argument list and return the index after the owner and family key. */\nexport function resolveAddress(definition: AnyDocDefinition, args: readonly unknown[]): ResolvedAddress {\n\tlet index = 0;\n\tlet scope: DocumentAddress[\"scope\"];\n\tswitch (definition.scope) {\n\t\tcase \"session\":\n\t\t\tscope = { kind: \"session\" };\n\t\t\tbreak;\n\t\tcase \"conversation\":\n\t\t\tscope = { kind: \"conversation\", conversationId: ownerId<ConversationId>(args[index++], definition) };\n\t\t\tbreak;\n\t\tcase \"task\":\n\t\t\tscope = { kind: \"task\", taskId: ownerId<TaskId>(args[index++], definition) };\n\t\t\tbreak;\n\t}\n\tconst key = definition.family === true ? (args[index++] as string) : undefined;\n\tconst address: DocumentAddress =\n\t\tkey === undefined ? { kind: definition.kind, scope } : { kind: definition.kind, scope, key };\n\treturn { address, id: addressId(address), nextArgument: index };\n}\n\nfunction ownerId<I extends Id<string>>(value: unknown, definition: AnyDocDefinition): I {\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value)) {\n\t\tthrow new TypeError(`Document ${definition.kind} requires a ${definition.scope} ID`);\n\t}\n\treturn idFromNumber<I>(value);\n}\n\n/** Stable string identity of one logical address. */\nexport function addressId(address: DocumentAddress): string {\n\tconst owner =\n\t\taddress.scope.kind === \"session\"\n\t\t\t? null\n\t\t\t: address.scope.kind === \"conversation\"\n\t\t\t\t? address.scope.conversationId\n\t\t\t\t: address.scope.taskId;\n\treturn JSON.stringify([address.kind, address.scope.kind, owner, address.key ?? null]);\n}\n\n/** Build the storage create record for a new incarnation at an address. */\nexport function documentCreate(definition: AnyDocDefinition, address: DocumentAddress, id: DocumentId): DocumentCreate {\n\tconst key = address.key === undefined ? {} : { key: address.key };\n\tswitch (address.scope.kind) {\n\t\tcase \"session\":\n\t\t\treturn { id, kind: address.kind, ...key, scope: address.scope };\n\t\tcase \"task\":\n\t\t\treturn { id, kind: address.kind, ...key, scope: address.scope };\n\t\tcase \"conversation\":\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\tkind: address.kind,\n\t\t\t\t...key,\n\t\t\t\tscope: address.scope,\n\t\t\t\thistory: definition.history!,\n\t\t\t\tfork: definition.fork!,\n\t\t\t} as DocumentCreate;\n\t}\n}\n\n/** Reject typed access whose token disagrees with the persisted scope, history, or fork semantics. */\nexport function checkRecordScope(definition: AnyDocDefinition, record: DocumentCreate | DocumentRecord): void {\n\tif (\n\t\trecord.scope.kind !== definition.scope ||\n\t\t(record.scope.kind === \"conversation\" &&\n\t\t\t(record.history !== definition.history || record.fork !== definition.fork))\n\t) {\n\t\tthrow new TypeError(`Document ${record.id} (${record.kind}) does not match the supplied definition semantics`);\n\t}\n}\n\n/** Reject typed access to a stored version the supplied definition cannot use. */\nexport function checkRecordVersion(\n\tdefinition: AnyDocDefinition,\n\trecord: DocumentCreate | DocumentRecord,\n\tversion: number,\n): void {\n\tif (version > definition.version) {\n\t\tthrow new Error(`Document ${record.id} (${record.kind}) has newer version ${version} than ${definition.version}`);\n\t}\n\tif (version < definition.version && definition.migrate === undefined) {\n\t\tthrow new Error(`Document ${record.id} (${record.kind}) requires migration from version ${version}`);\n\t}\n}\n\n/** Validate and materialize a detached stored value for typed access. */\nexport function materializeDocument(definition: AnyDocDefinition, stored: StoredDocument): JsonObject {\n\treturn materializeDocumentValue(definition, stored.record, stored.version, stored.value);\n}\n\n/** Validate and materialize one detached value before its first persisted incarnation. */\nexport function materializeDocumentValue(\n\tdefinition: AnyDocDefinition,\n\trecord: DocumentCreate | DocumentRecord,\n\tversion: number,\n\tvalue: JsonObject,\n): JsonObject {\n\tcheckRecordScope(definition, record);\n\tcheckRecordVersion(definition, record, version);\n\tif (version === definition.version) return value;\n\treturn copyJson(definition.migrate!(value, version)) as JsonObject;\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import type { JsonValue } from "@ny4n/chord";
2
+ import type { CompactionReason, ToolDiagnostic } from "./harness/types.ts";
3
+ import type { Entry } from "./types.ts";
4
+ /** Define a typed entry kind whose `is()` guard narrows by `EntryRecord.kind`. */
5
+ export declare function defineEntry<D extends JsonValue = never>(kind: string): Entry<D>;
6
+ /** User input: `model` is `[UserMessage]`. Written by submissions. */
7
+ export declare const UserEntry: Entry<never>;
8
+ /** Provider result with any stop reason: `model` is `[AssistantMessage]`. Written by generation. */
9
+ export declare const AssistantEntry: Entry<never>;
10
+ /** Positional prompt and tool change: `model` is `[SystemMessage]` with empty `content`. */
11
+ export declare const SystemEntry: Entry<never>;
12
+ /**
13
+ * Tool result: `model` is `[ToolResultMessage]`, whose content ends with the rendered diagnostics block; `data` holds
14
+ * the structured diagnostics, possibly none. Written by tool tasks, and by generation for calls it did not offer.
15
+ */
16
+ export declare const ToolResultEntry: Entry<{
17
+ diagnostics: ToolDiagnostic[];
18
+ }>;
19
+ /**
20
+ * Start of a new context: always `head: "self"`, with `model` absent for a plain reset or `[UserMessage]` carrying the
21
+ * handoff text. Written by `Conversation.reset()` and the `handoff` tool control.
22
+ */
23
+ export declare const ResetEntry: Entry<never>;
24
+ /**
25
+ * Compaction summary: `model` is `[UserMessage]` with the wrapped summary, `head` the first kept entry. Written by
26
+ * compaction tasks, directly or through a write submission.
27
+ */
28
+ export declare const CompactionEntry: Entry<{
29
+ reason: CompactionReason;
30
+ }>;
31
+ //# sourceMappingURL=entries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../src/entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,KAAK,EAAE,KAAK,EAA2B,MAAM,YAAY,CAAC;AAEjE,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAM/E;AAED,sEAAsE;AACtE,eAAO,MAAM,SAAS,cAA2B,CAAC;AAClD,oGAAoG;AACpG,eAAO,MAAM,cAAc,cAAgC,CAAC;AAC5D,4FAA4F;AAC5F,eAAO,MAAM,WAAW,cAA6B,CAAC;AACtD;;;GAGG;AACH,eAAO,MAAM,eAAe;iBAA8B,cAAc,EAAE;EAAuB,CAAC;AAClG;;;GAGG;AACH,eAAO,MAAM,UAAU,cAA4B,CAAC;AACpD;;;GAGG;AACH,eAAO,MAAM,eAAe;YAAyB,gBAAgB;EAAsB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /** Define a typed entry kind whose `is()` guard narrows by `EntryRecord.kind`. */
2
+ export function defineEntry(kind) {
3
+ if (typeof kind !== "string" || kind.length === 0)
4
+ throw new TypeError("Entry kind must be a non-empty string");
5
+ return {
6
+ kind,
7
+ is: (entry) => entry !== undefined && entry.kind === kind,
8
+ };
9
+ }
10
+ /** User input: `model` is `[UserMessage]`. Written by submissions. */
11
+ export const UserEntry = defineEntry("nyan.user");
12
+ /** Provider result with any stop reason: `model` is `[AssistantMessage]`. Written by generation. */
13
+ export const AssistantEntry = defineEntry("nyan.assistant");
14
+ /** Positional prompt and tool change: `model` is `[SystemMessage]` with empty `content`. */
15
+ export const SystemEntry = defineEntry("nyan.system");
16
+ /**
17
+ * Tool result: `model` is `[ToolResultMessage]`, whose content ends with the rendered diagnostics block; `data` holds
18
+ * the structured diagnostics, possibly none. Written by tool tasks, and by generation for calls it did not offer.
19
+ */
20
+ export const ToolResultEntry = defineEntry("nyan.tool-result");
21
+ /**
22
+ * Start of a new context: always `head: "self"`, with `model` absent for a plain reset or `[UserMessage]` carrying the
23
+ * handoff text. Written by `Conversation.reset()` and the `handoff` tool control.
24
+ */
25
+ export const ResetEntry = defineEntry("nyan.reset");
26
+ /**
27
+ * Compaction summary: `model` is `[UserMessage]` with the wrapped summary, `head` the first kept entry. Written by
28
+ * compaction tasks, directly or through a write submission.
29
+ */
30
+ export const CompactionEntry = defineEntry("nyan.compaction");
31
+ //# sourceMappingURL=entries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.js","sourceRoot":"","sources":["../src/entries.ts"],"names":[],"mappings":"AAIA,kFAAkF;AAClF,MAAM,UAAU,WAAW,CAA8B,IAAY;IACpE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAC;IAChH,OAAO;QACN,IAAI;QACJ,EAAE,EAAE,CAAC,KAA8B,EAA0B,EAAE,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI;KAC1G,CAAC;AACH,CAAC;AAED,sEAAsE;AACtE,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;AAClD,oGAAoG;AACpG,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC,gBAAgB,CAAC,CAAC;AAC5D,4FAA4F;AAC5F,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;AACtD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAoC,kBAAkB,CAAC,CAAC;AAClG;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;AACpD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAA+B,iBAAiB,CAAC,CAAC","sourcesContent":["import type { JsonValue } from \"@ny4n/chord\";\nimport type { CompactionReason, ToolDiagnostic } from \"./harness/types.ts\";\nimport type { Entry, EntryRecord, TypedEntry } from \"./types.ts\";\n\n/** Define a typed entry kind whose `is()` guard narrows by `EntryRecord.kind`. */\nexport function defineEntry<D extends JsonValue = never>(kind: string): Entry<D> {\n\tif (typeof kind !== \"string\" || kind.length === 0) throw new TypeError(\"Entry kind must be a non-empty string\");\n\treturn {\n\t\tkind,\n\t\tis: (entry: EntryRecord | undefined): entry is TypedEntry<D> => entry !== undefined && entry.kind === kind,\n\t};\n}\n\n/** User input: `model` is `[UserMessage]`. Written by submissions. */\nexport const UserEntry = defineEntry(\"nyan.user\");\n/** Provider result with any stop reason: `model` is `[AssistantMessage]`. Written by generation. */\nexport const AssistantEntry = defineEntry(\"nyan.assistant\");\n/** Positional prompt and tool change: `model` is `[SystemMessage]` with empty `content`. */\nexport const SystemEntry = defineEntry(\"nyan.system\");\n/**\n * Tool result: `model` is `[ToolResultMessage]`, whose content ends with the rendered diagnostics block; `data` holds\n * the structured diagnostics, possibly none. Written by tool tasks, and by generation for calls it did not offer.\n */\nexport const ToolResultEntry = defineEntry<{ diagnostics: ToolDiagnostic[] }>(\"nyan.tool-result\");\n/**\n * Start of a new context: always `head: \"self\"`, with `model` absent for a plain reset or `[UserMessage]` carrying the\n * handoff text. Written by `Conversation.reset()` and the `handoff` tool control.\n */\nexport const ResetEntry = defineEntry(\"nyan.reset\");\n/**\n * Compaction summary: `model` is `[UserMessage]` with the wrapped summary, `head` the first kept entry. Written by\n * compaction tasks, directly or through a write submission.\n */\nexport const CompactionEntry = defineEntry<{ reason: CompactionReason }>(\"nyan.compaction\");\n"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Decoding that matches `new TextDecoder().decode(bytes)` of the whole input when the input arrives in pieces. Node's
3
+ * streaming decoder with BOM handling can drop a U+FEFF that follows a chunk boundary, not only a leading byte-order
4
+ * mark, so these decoders turn BOM handling off and drop a leading mark themselves.
5
+ */
6
+ /** A streaming decoder for a byte range; callers that start at the beginning of a file skip a leading mark themselves. */
7
+ export declare function rangeDecoder(): InstanceType<typeof TextDecoder>;
8
+ /** Whether decoding the whole input drops its first three bytes as a byte-order mark. */
9
+ export declare function startsWithBom(firstBytes: Uint8Array): boolean;
10
+ /** Decodes one stream chunk by chunk exactly like decoding all of it at once. */
11
+ export declare class StreamDecoder {
12
+ #private;
13
+ /** Text for `bytes`, holding back an incomplete character; without `bytes`, the end of the stream. */
14
+ decode(bytes?: Uint8Array): string;
15
+ }
16
+ //# sourceMappingURL=decode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/env/decode.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0HAA0H;AAC1H,wBAAgB,YAAY,IAAI,YAAY,CAAC,OAAO,WAAW,CAAC,CAE/D;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAE7D;AAED,iFAAiF;AACjF,qBAAa,aAAa;;IAIzB,sGAAsG;IACtG,MAAM,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,MAAM,CAMjC;CACD"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Decoding that matches `new TextDecoder().decode(bytes)` of the whole input when the input arrives in pieces. Node's
3
+ * streaming decoder with BOM handling can drop a U+FEFF that follows a chunk boundary, not only a leading byte-order
4
+ * mark, so these decoders turn BOM handling off and drop a leading mark themselves.
5
+ */
6
+ /** A streaming decoder for a byte range; callers that start at the beginning of a file skip a leading mark themselves. */
7
+ export function rangeDecoder() {
8
+ return new TextDecoder("utf-8", { ignoreBOM: true });
9
+ }
10
+ /** Whether decoding the whole input drops its first three bytes as a byte-order mark. */
11
+ export function startsWithBom(firstBytes) {
12
+ return firstBytes[0] === 0xef && firstBytes[1] === 0xbb && firstBytes[2] === 0xbf;
13
+ }
14
+ /** Decodes one stream chunk by chunk exactly like decoding all of it at once. */
15
+ export class StreamDecoder {
16
+ #decoder = rangeDecoder();
17
+ #started = false;
18
+ /** Text for `bytes`, holding back an incomplete character; without `bytes`, the end of the stream. */
19
+ decode(bytes) {
20
+ const text = bytes === undefined ? this.#decoder.decode() : this.#decoder.decode(bytes, { stream: true });
21
+ if (this.#started || text === "")
22
+ return text;
23
+ this.#started = true;
24
+ // U+FEFF encodes only as EF BB BF, so a leading U+FEFF is exactly a byte-order mark at the stream's start.
25
+ return text.startsWith("\ufeff") ? text.slice(1) : text;
26
+ }
27
+ }
28
+ //# sourceMappingURL=decode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/env/decode.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0HAA0H;AAC1H,MAAM,UAAU,YAAY;IAC3B,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,aAAa,CAAC,UAAsB;IACnD,OAAO,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AACnF,CAAC;AAED,iFAAiF;AACjF,MAAM,OAAO,aAAa;IAChB,QAAQ,GAAG,YAAY,EAAE,CAAC;IACnC,QAAQ,GAAG,KAAK,CAAC;IAEjB,sGAAsG;IACtG,MAAM,CAAC,KAAkB;QACxB,MAAM,IAAI,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1G,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,2GAA2G;QAC3G,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,CAAC;CACD","sourcesContent":["/**\n * Decoding that matches `new TextDecoder().decode(bytes)` of the whole input when the input arrives in pieces. Node's\n * streaming decoder with BOM handling can drop a U+FEFF that follows a chunk boundary, not only a leading byte-order\n * mark, so these decoders turn BOM handling off and drop a leading mark themselves.\n */\n\n/** A streaming decoder for a byte range; callers that start at the beginning of a file skip a leading mark themselves. */\nexport function rangeDecoder(): InstanceType<typeof TextDecoder> {\n\treturn new TextDecoder(\"utf-8\", { ignoreBOM: true });\n}\n\n/** Whether decoding the whole input drops its first three bytes as a byte-order mark. */\nexport function startsWithBom(firstBytes: Uint8Array): boolean {\n\treturn firstBytes[0] === 0xef && firstBytes[1] === 0xbb && firstBytes[2] === 0xbf;\n}\n\n/** Decodes one stream chunk by chunk exactly like decoding all of it at once. */\nexport class StreamDecoder {\n\treadonly #decoder = rangeDecoder();\n\t#started = false;\n\n\t/** Text for `bytes`, holding back an incomplete character; without `bytes`, the end of the stream. */\n\tdecode(bytes?: Uint8Array): string {\n\t\tconst text = bytes === undefined ? this.#decoder.decode() : this.#decoder.decode(bytes, { stream: true });\n\t\tif (this.#started || text === \"\") return text;\n\t\tthis.#started = true;\n\t\t// U+FEFF encodes only as EF BB BF, so a leading U+FEFF is exactly a byte-order mark at the stream's start.\n\t\treturn text.startsWith(\"\\ufeff\") ? text.slice(1) : text;\n\t}\n}\n"]}
@@ -0,0 +1,263 @@
1
+ import type { Context } from "@ny4n/chord";
2
+ /** Result of a fallible operation. Expected failures are returned instead of thrown. */
3
+ export type Result<TValue, TError> = {
4
+ ok: true;
5
+ value: TValue;
6
+ } | {
7
+ ok: false;
8
+ error: TError;
9
+ };
10
+ export declare function ok<TValue, TError>(value: TValue): Result<TValue, TError>;
11
+ export declare function err<TValue, TError>(error: TError): Result<TValue, TError>;
12
+ export declare function getOrThrow<TValue, TError>(result: Result<TValue, TError>): TValue;
13
+ export declare function getOrUndefined<TValue extends object, TError>(result: Result<TValue, TError>): TValue | undefined;
14
+ export declare function toError(error: unknown): Error;
15
+ export type FileKind = "file" | "directory" | "symlink";
16
+ export type FileErrorCode = "aborted" | "not_found" | "permission_denied" | "not_directory" | "is_directory" | "invalid" | "not_supported" | "unknown";
17
+ export declare class FileError extends Error {
18
+ code: FileErrorCode;
19
+ path?: string;
20
+ constructor(code: FileErrorCode, message: string, path?: string, cause?: Error);
21
+ }
22
+ export type ExecutionErrorCode = "aborted" | "timeout" | "shell_unavailable" | "spawn_error" | "callback_error" | "unknown";
23
+ export declare class ExecutionError extends Error {
24
+ code: ExecutionErrorCode;
25
+ /** Spill file of a command that timed out or was aborted after its output crossed the spill thresholds. */
26
+ spillPath?: string;
27
+ constructor(code: ExecutionErrorCode, message: string, cause?: Error);
28
+ }
29
+ export interface FileInfo {
30
+ name: string;
31
+ path: string;
32
+ kind: FileKind;
33
+ size: number;
34
+ mtimeMs: number;
35
+ }
36
+ export interface TextLine {
37
+ text: string;
38
+ terminated: boolean;
39
+ }
40
+ export interface TextLineReader {
41
+ readLine(context: Context): Promise<Result<TextLine | undefined, FileError>>;
42
+ close(context: Context): Promise<void>;
43
+ }
44
+ /** Positional reads from one opened regular file; all calls see the same file even if its path is renamed. */
45
+ export interface BinaryReader {
46
+ /** Metadata of the opened file, not of whatever its path names now. */
47
+ info(context: Context): Promise<Result<FileInfo, FileError>>;
48
+ /** Up to `length` bytes at `offset`; fewer only at end of file. */
49
+ read(offset: number, length: number, context: Context): Promise<Result<Uint8Array, FileError>>;
50
+ /**
51
+ * One pass over the file that locates lines `[startLine, endLine)` (`endLine` absent: to the end), 0-based, where line
52
+ * `k` starts after the `k`-th newline byte. Decoded sizes are those of the text `new TextDecoder().decode(file)` would
53
+ * produce for that range, so a byte-order mark at the start of the file is not counted.
54
+ */
55
+ scanLines(options: {
56
+ startLine: number;
57
+ endLine?: number;
58
+ }, context: Context): Promise<Result<LineScan, FileError>>;
59
+ close(context: Context): Promise<void>;
60
+ }
61
+ /** A file or directory to watch. It may be missing; creating it is a change. */
62
+ export interface WatchTarget {
63
+ path: string;
64
+ /** Watch everything below a directory, not only its entries. Symbolic links below it are not followed. */
65
+ recursive?: boolean;
66
+ /** Entries below `path` that are neither watched nor reported: names starting with `.`, or these names. */
67
+ exclude?: {
68
+ hidden?: boolean;
69
+ names?: readonly string[];
70
+ };
71
+ }
72
+ /**
73
+ * What changed:
74
+ * - `paths`: something at or below each path may have changed (a directory path covers its whole subtree). Calls may be
75
+ * spurious; a change is never missed while the watcher is healthy.
76
+ * - `overflow`: coverage was uncertain for a while (lost events, reconnect); rescan everything that is watched.
77
+ * - `error`: the watcher stopped, for example because the watched tree grew past the environment's limit; no calls
78
+ * follow.
79
+ */
80
+ export type WatchChange = {
81
+ paths: string[];
82
+ } | {
83
+ overflow: true;
84
+ } | {
85
+ error: FileError;
86
+ };
87
+ export interface FileWatcher {
88
+ /**
89
+ * `native`: changes are reported within about two seconds. `polling`: the environment compares snapshots, because
90
+ * the file system does not report changes reliably (network and FUSE file systems); a change undone between two
91
+ * snapshots can be missed.
92
+ */
93
+ readonly mode: "native" | "polling";
94
+ /** Stop watching; no `onChange` call starts after this resolves. Idempotent. */
95
+ close(context: Context): Promise<void>;
96
+ }
97
+ /** Where lines of a file are, as `BinaryReader.scanLines` found them. */
98
+ export interface LineScan {
99
+ /** Newline bytes in the whole file; it has `newlines + 1` lines. */
100
+ newlines: number;
101
+ /**
102
+ * Byte range of the selected lines: from the start of the first to the end of the last, without the newline that
103
+ * ends it. A selection past the last line is empty at the end of the file.
104
+ */
105
+ start: number;
106
+ end: number;
107
+ /** Where the first selected line ends: its newline, or the end of the file. */
108
+ firstLineEnd: number;
109
+ /** Where the last selected line starts. */
110
+ lastLineStart: number;
111
+ /** UTF-8 byte length of the decoded selection and of its first line. */
112
+ selectedBytes: number;
113
+ firstLineBytes: number;
114
+ }
115
+ /** Pages of one directory's entries. */
116
+ export interface DirReader {
117
+ /**
118
+ * Up to `maxEntries` entries in the order the file system returns them, continuing where the previous call stopped.
119
+ * `done` marks the end; it may come with the last entries or with an empty page. An entry that disappears before its
120
+ * metadata is read is skipped, as are entries of unsupported kinds. After a failed or aborted call, close the reader.
121
+ */
122
+ next(maxEntries: number, context: Context): Promise<Result<{
123
+ entries: FileInfo[];
124
+ done: boolean;
125
+ }, FileError>>;
126
+ close(context: Context): Promise<void>;
127
+ }
128
+ /** Portable filesystem capability. Operations return failures rather than throwing. */
129
+ export interface FileSystem {
130
+ /**
131
+ * The file namespace: equal ids see the same files at the same paths, whatever their `cwd`. Every local Node
132
+ * environment shares one id; each container or remote host has its own.
133
+ */
134
+ readonly id: string;
135
+ cwd: string;
136
+ absolutePath(path: string, context: Context): Promise<Result<string, FileError>>;
137
+ joinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;
138
+ readTextFile(path: string, context: Context): Promise<Result<string, FileError>>;
139
+ openTextLineReader(path: string, context: Context): Promise<Result<TextLineReader, FileError>>;
140
+ readTextLines(path: string, options: {
141
+ maxLines?: number;
142
+ } | undefined, context: Context): Promise<Result<string[], FileError>>;
143
+ readBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;
144
+ /**
145
+ * Open a regular file for bounded positional reads. A directory fails with `is_directory`, other non-regular files
146
+ * with `invalid`. With `noFollow`, a symbolic link as the final path component fails with `invalid` instead of being
147
+ * followed; earlier components are still resolved.
148
+ */
149
+ openBinaryReader(path: string, options: {
150
+ noFollow?: boolean;
151
+ } | undefined, context: Context): Promise<Result<BinaryReader, FileError>>;
152
+ writeFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;
153
+ appendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;
154
+ /** Truncate or extend a file to exactly `size` bytes. */
155
+ truncateFile(path: string, size: number, context: Context): Promise<Result<void, FileError>>;
156
+ /** Flush file contents and metadata needed to retrieve them from an open file handle. */
157
+ flushFile(path: string, context: Context): Promise<Result<void, FileError>>;
158
+ renameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;
159
+ fileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;
160
+ listDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;
161
+ openDirReader(path: string, context: Context): Promise<Result<DirReader, FileError>>;
162
+ /**
163
+ * Report changes to files and directories, for hosts that load resources from the environment. When the returned
164
+ * watcher exists, coverage is established: a host that watches before it loads cannot miss a change made during the
165
+ * load. See `WatchChange` for what is reported and `FileWatcher.mode` for how reliably.
166
+ */
167
+ watch(targets: readonly WatchTarget[], onChange: (change: WatchChange) => void, context: Context): Promise<Result<FileWatcher, FileError>>;
168
+ canonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;
169
+ exists(path: string, context: Context): Promise<Result<boolean, FileError>>;
170
+ createDir(path: string, options: {
171
+ recursive?: boolean;
172
+ } | undefined, context: Context): Promise<Result<void, FileError>>;
173
+ remove(path: string, options: {
174
+ recursive?: boolean;
175
+ force?: boolean;
176
+ } | undefined, context: Context): Promise<Result<void, FileError>>;
177
+ createTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;
178
+ createTempFile(options: {
179
+ prefix?: string;
180
+ suffix?: string;
181
+ } | undefined, context: Context): Promise<Result<string, FileError>>;
182
+ cleanup(context: Context): Promise<void>;
183
+ }
184
+ /** Spill the complete output to a temporary file once it exceeds either threshold. */
185
+ export interface ShellSpillOptions {
186
+ afterBytes: number;
187
+ /** Complete or partial lines. */
188
+ afterLines: number;
189
+ }
190
+ export interface ShellExecResult {
191
+ exitCode: number;
192
+ /** Temporary file holding the complete raw output, when the spill thresholds were exceeded. */
193
+ spillPath?: string;
194
+ }
195
+ export interface ShellExecOptions {
196
+ cwd?: string;
197
+ env?: Record<string, string>;
198
+ inheritEnv?: boolean;
199
+ timeout?: number;
200
+ /**
201
+ * Every decoded chunk of stdout and stderr as it arrives, in arrival order, with the stream it came from: raw,
202
+ * unbounded, and unthrottled. Each stream is decoded separately, so a character split across chunks survives.
203
+ */
204
+ onOutput?: (text: string, context: Context, info: ShellOutputInfo) => void;
205
+ spill?: ShellSpillOptions;
206
+ /**
207
+ * The caller keeps only this tail of the output, so the environment may omit output outside it and report the omission
208
+ * as `info.skipped`. Without it, every chunk is delivered.
209
+ */
210
+ window?: ShellOutputWindow;
211
+ }
212
+ /**
213
+ * The tail of the combined output a caller keeps, and how often it samples it. An environment that transfers output
214
+ * over a slow link uses it to omit what the caller would drop anyway and to send no faster than the caller commits.
215
+ */
216
+ export interface ShellOutputWindow {
217
+ /** UTF-8 bytes of decoded text kept at the end of the output. */
218
+ maxBytes: number;
219
+ /** Lines kept at the end of the output. */
220
+ maxLines: number;
221
+ /** Minimum pause between the caller's samples of the output. */
222
+ minIntervalMs: number;
223
+ /** Each sample also pauses the caller in proportion to its size at this rate. */
224
+ bytesPerSecond: number;
225
+ }
226
+ /**
227
+ * Output an environment omitted, measured on the decoded text `onOutput` would have received: every U+FFFD counts as
228
+ * three bytes, and no sanitizing is applied.
229
+ */
230
+ export interface ShellOutputSkip {
231
+ /** UTF-8 byte length of the omitted text. */
232
+ bytes: number;
233
+ /** Newlines (U+000A) in the omitted text. */
234
+ newlines: number;
235
+ /** Whether the omitted text ends with a newline. */
236
+ endsWithNewline: boolean;
237
+ }
238
+ export interface ShellOutputInfo {
239
+ stream: "stdout" | "stderr";
240
+ /**
241
+ * Output omitted immediately before this chunk, only with `window`. The chunk then holds all output after the
242
+ * omission up to its end, and that is more than the window by at least one byte or one line: more than
243
+ * `window.maxBytes` bytes or more than `window.maxLines` newlines. So the omitted text can never be in the kept tail.
244
+ * The omission and such a chunk may span both streams in arrival order; `stream` then names the chunk's last stream.
245
+ * Callers that need the streams apart do not pass `window`.
246
+ */
247
+ skipped?: ShellOutputSkip;
248
+ }
249
+ export interface Shell {
250
+ /**
251
+ * Run a command. A string runs through the environment's shell. An array runs `command[0]` directly with the rest
252
+ * as its arguments, without a shell, so they reach the program unparsed. Aborting the context or a timeout kills
253
+ * only this command's processes.
254
+ */
255
+ exec(command: string | readonly string[], options: ShellExecOptions | undefined, context: Context): Promise<Result<ShellExecResult, ExecutionError>>;
256
+ /** Kill every command this environment still runs; for its owner's shutdown, never for one request. */
257
+ cleanup(context: Context): Promise<void>;
258
+ }
259
+ export interface ExecutionEnv extends FileSystem, Shell {
260
+ }
261
+ export { rangeDecoder, StreamDecoder, startsWithBom } from "./decode.ts";
262
+ export { LineScanner } from "./line-scan.ts";
263
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,wFAAwF;AACxF,MAAM,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG,wBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExE;AAED,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEzE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAGjF;AAED,wBAAgB,cAAc,CAAC,MAAM,SAAS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAEhH;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAQ7C;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;AAExD,MAAM,MAAM,aAAa,GACtB,SAAS,GACT,WAAW,GACX,mBAAmB,GACnB,eAAe,GACf,cAAc,GACd,SAAS,GACT,eAAe,GACf,SAAS,CAAC;AAEb,qBAAa,SAAU,SAAQ,KAAK;IAC5B,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,C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