@ontrails/core 1.0.0-beta.4 → 1.0.0-beta.41

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 (247) hide show
  1. package/CHANGELOG.md +412 -12
  2. package/README.md +112 -28
  3. package/package.json +11 -1
  4. package/src/activation-provenance.ts +116 -0
  5. package/src/activation-source-compatibility.ts +430 -0
  6. package/src/activation-source-projection.ts +227 -0
  7. package/src/activation-source.ts +93 -0
  8. package/src/blob-ref.ts +51 -0
  9. package/src/branded.ts +1 -1
  10. package/src/compose-batch.ts +69 -0
  11. package/src/compose-schema.ts +36 -0
  12. package/src/context.ts +59 -11
  13. package/src/derive.ts +271 -19
  14. package/src/detours.ts +8 -0
  15. package/src/diagnostics.ts +21 -0
  16. package/src/draft.ts +350 -0
  17. package/src/entity.ts +346 -0
  18. package/src/error-projection.ts +51 -0
  19. package/src/errors.ts +335 -48
  20. package/src/execute.ts +1577 -0
  21. package/src/fire.ts +1172 -0
  22. package/src/glob.ts +81 -0
  23. package/src/index.ts +568 -32
  24. package/src/internal/fork-ctx.ts +69 -0
  25. package/src/layer-projection.ts +193 -0
  26. package/src/layer.ts +43 -6
  27. package/src/observe.ts +361 -0
  28. package/src/path-scope.ts +66 -0
  29. package/src/path-security.ts +11 -3
  30. package/src/permits.ts +12 -0
  31. package/src/queue.ts +163 -0
  32. package/src/redaction/patterns.ts +6 -3
  33. package/src/resilience.ts +11 -11
  34. package/src/resource-config.ts +804 -0
  35. package/src/resource.ts +194 -0
  36. package/src/result.ts +18 -0
  37. package/src/run.ts +76 -0
  38. package/src/runtime-builtins.ts +69 -0
  39. package/src/schedule-runtime.ts +689 -0
  40. package/src/schedule.ts +326 -0
  41. package/src/serialization.ts +92 -55
  42. package/src/sha256.ts +136 -0
  43. package/src/signal-diagnostics.ts +633 -0
  44. package/src/signal-ref.ts +111 -0
  45. package/src/signal.ts +104 -0
  46. package/src/store/accessor-protocol.ts +56 -0
  47. package/src/store/index.ts +4 -0
  48. package/src/structured-examples.ts +248 -0
  49. package/src/surface-derivation.ts +91 -0
  50. package/src/surface-filter.ts +101 -0
  51. package/src/surface-overlay.ts +694 -0
  52. package/src/surface-versioning.ts +42 -0
  53. package/src/topo.ts +762 -38
  54. package/src/tracing.ts +346 -0
  55. package/src/trail-id-glob.ts +15 -0
  56. package/src/trail.ts +1244 -34
  57. package/src/trails/derive-trail.ts +835 -0
  58. package/src/trails/index.ts +9 -0
  59. package/src/trails/ingest.ts +152 -0
  60. package/src/trails-db.ts +212 -0
  61. package/src/transport-error-map.ts +174 -0
  62. package/src/type-utils.ts +87 -0
  63. package/src/types.ts +254 -12
  64. package/src/validate-established-topo.ts +73 -0
  65. package/src/validate-topo.ts +569 -55
  66. package/src/validation.ts +152 -4
  67. package/src/version-marker.ts +716 -0
  68. package/src/version-resolution.ts +308 -0
  69. package/src/version-runtime.ts +120 -0
  70. package/src/webhook.ts +461 -0
  71. package/src/workspace.ts +183 -16
  72. package/src/zod-wrappers.ts +72 -0
  73. package/.turbo/turbo-build.log +0 -1
  74. package/.turbo/turbo-lint.log +0 -3
  75. package/.turbo/turbo-typecheck.log +0 -1
  76. package/dist/adapters.d.ts +0 -39
  77. package/dist/adapters.d.ts.map +0 -1
  78. package/dist/adapters.js +0 -2
  79. package/dist/adapters.js.map +0 -1
  80. package/dist/blob-ref.d.ts +0 -20
  81. package/dist/blob-ref.d.ts.map +0 -1
  82. package/dist/blob-ref.js +0 -22
  83. package/dist/blob-ref.js.map +0 -1
  84. package/dist/branded.d.ts +0 -36
  85. package/dist/branded.d.ts.map +0 -1
  86. package/dist/branded.js +0 -89
  87. package/dist/branded.js.map +0 -1
  88. package/dist/collections.d.ts +0 -31
  89. package/dist/collections.d.ts.map +0 -1
  90. package/dist/collections.js +0 -60
  91. package/dist/collections.js.map +0 -1
  92. package/dist/context.d.ts +0 -10
  93. package/dist/context.d.ts.map +0 -1
  94. package/dist/context.js +0 -15
  95. package/dist/context.js.map +0 -1
  96. package/dist/derive.d.ts +0 -33
  97. package/dist/derive.d.ts.map +0 -1
  98. package/dist/derive.js +0 -125
  99. package/dist/derive.js.map +0 -1
  100. package/dist/errors.d.ts +0 -83
  101. package/dist/errors.d.ts.map +0 -1
  102. package/dist/errors.js +0 -142
  103. package/dist/errors.js.map +0 -1
  104. package/dist/event.d.ts +0 -45
  105. package/dist/event.d.ts.map +0 -1
  106. package/dist/event.js +0 -17
  107. package/dist/event.js.map +0 -1
  108. package/dist/fetch.d.ts +0 -15
  109. package/dist/fetch.d.ts.map +0 -1
  110. package/dist/fetch.js +0 -102
  111. package/dist/fetch.js.map +0 -1
  112. package/dist/guards.d.ts +0 -17
  113. package/dist/guards.d.ts.map +0 -1
  114. package/dist/guards.js +0 -25
  115. package/dist/guards.js.map +0 -1
  116. package/dist/health.d.ts +0 -18
  117. package/dist/health.d.ts.map +0 -1
  118. package/dist/health.js +0 -5
  119. package/dist/health.js.map +0 -1
  120. package/dist/index.d.ts +0 -34
  121. package/dist/index.d.ts.map +0 -1
  122. package/dist/index.js +0 -38
  123. package/dist/index.js.map +0 -1
  124. package/dist/job.d.ts +0 -24
  125. package/dist/job.d.ts.map +0 -1
  126. package/dist/job.js +0 -17
  127. package/dist/job.js.map +0 -1
  128. package/dist/layer.d.ts +0 -17
  129. package/dist/layer.d.ts.map +0 -1
  130. package/dist/layer.js +0 -21
  131. package/dist/layer.js.map +0 -1
  132. package/dist/path-security.d.ts +0 -28
  133. package/dist/path-security.d.ts.map +0 -1
  134. package/dist/path-security.js +0 -63
  135. package/dist/path-security.js.map +0 -1
  136. package/dist/patterns/bulk.d.ts +0 -15
  137. package/dist/patterns/bulk.d.ts.map +0 -1
  138. package/dist/patterns/bulk.js +0 -14
  139. package/dist/patterns/bulk.js.map +0 -1
  140. package/dist/patterns/change.d.ts +0 -10
  141. package/dist/patterns/change.d.ts.map +0 -1
  142. package/dist/patterns/change.js +0 -10
  143. package/dist/patterns/change.js.map +0 -1
  144. package/dist/patterns/date-range.d.ts +0 -10
  145. package/dist/patterns/date-range.d.ts.map +0 -1
  146. package/dist/patterns/date-range.js +0 -10
  147. package/dist/patterns/date-range.js.map +0 -1
  148. package/dist/patterns/index.d.ts +0 -9
  149. package/dist/patterns/index.d.ts.map +0 -1
  150. package/dist/patterns/index.js +0 -9
  151. package/dist/patterns/index.js.map +0 -1
  152. package/dist/patterns/pagination.d.ts +0 -18
  153. package/dist/patterns/pagination.d.ts.map +0 -1
  154. package/dist/patterns/pagination.js +0 -18
  155. package/dist/patterns/pagination.js.map +0 -1
  156. package/dist/patterns/progress.d.ts +0 -11
  157. package/dist/patterns/progress.d.ts.map +0 -1
  158. package/dist/patterns/progress.js +0 -11
  159. package/dist/patterns/progress.js.map +0 -1
  160. package/dist/patterns/sorting.d.ts +0 -13
  161. package/dist/patterns/sorting.d.ts.map +0 -1
  162. package/dist/patterns/sorting.js +0 -10
  163. package/dist/patterns/sorting.js.map +0 -1
  164. package/dist/patterns/status.d.ts +0 -15
  165. package/dist/patterns/status.d.ts.map +0 -1
  166. package/dist/patterns/status.js +0 -9
  167. package/dist/patterns/status.js.map +0 -1
  168. package/dist/patterns/timestamps.d.ts +0 -10
  169. package/dist/patterns/timestamps.d.ts.map +0 -1
  170. package/dist/patterns/timestamps.js +0 -10
  171. package/dist/patterns/timestamps.js.map +0 -1
  172. package/dist/redaction/index.d.ts +0 -4
  173. package/dist/redaction/index.d.ts.map +0 -1
  174. package/dist/redaction/index.js +0 -3
  175. package/dist/redaction/index.js.map +0 -1
  176. package/dist/redaction/patterns.d.ts +0 -9
  177. package/dist/redaction/patterns.d.ts.map +0 -1
  178. package/dist/redaction/patterns.js +0 -39
  179. package/dist/redaction/patterns.js.map +0 -1
  180. package/dist/redaction/redactor.d.ts +0 -27
  181. package/dist/redaction/redactor.d.ts.map +0 -1
  182. package/dist/redaction/redactor.js +0 -89
  183. package/dist/redaction/redactor.js.map +0 -1
  184. package/dist/resilience.d.ts +0 -34
  185. package/dist/resilience.d.ts.map +0 -1
  186. package/dist/resilience.js +0 -164
  187. package/dist/resilience.js.map +0 -1
  188. package/dist/result.d.ts +0 -57
  189. package/dist/result.d.ts.map +0 -1
  190. package/dist/result.js +0 -156
  191. package/dist/result.js.map +0 -1
  192. package/dist/serialization.d.ts +0 -27
  193. package/dist/serialization.d.ts.map +0 -1
  194. package/dist/serialization.js +0 -153
  195. package/dist/serialization.js.map +0 -1
  196. package/dist/topo.d.ts +0 -16
  197. package/dist/topo.d.ts.map +0 -1
  198. package/dist/topo.js +0 -66
  199. package/dist/topo.js.map +0 -1
  200. package/dist/trail.d.ts +0 -89
  201. package/dist/trail.d.ts.map +0 -1
  202. package/dist/trail.js +0 -18
  203. package/dist/trail.js.map +0 -1
  204. package/dist/types.d.ts +0 -46
  205. package/dist/types.d.ts.map +0 -1
  206. package/dist/types.js +0 -2
  207. package/dist/types.js.map +0 -1
  208. package/dist/validate-topo.d.ts +0 -24
  209. package/dist/validate-topo.d.ts.map +0 -1
  210. package/dist/validate-topo.js +0 -158
  211. package/dist/validate-topo.js.map +0 -1
  212. package/dist/validation.d.ts +0 -27
  213. package/dist/validation.d.ts.map +0 -1
  214. package/dist/validation.js +0 -134
  215. package/dist/validation.js.map +0 -1
  216. package/dist/workspace.d.ts +0 -25
  217. package/dist/workspace.d.ts.map +0 -1
  218. package/dist/workspace.js +0 -57
  219. package/dist/workspace.js.map +0 -1
  220. package/src/__tests__/blob-ref.test.ts +0 -103
  221. package/src/__tests__/branded.test.ts +0 -148
  222. package/src/__tests__/collections.test.ts +0 -126
  223. package/src/__tests__/context.test.ts +0 -66
  224. package/src/__tests__/derive.test.ts +0 -203
  225. package/src/__tests__/errors.test.ts +0 -309
  226. package/src/__tests__/event.test.ts +0 -82
  227. package/src/__tests__/fetch.test.ts +0 -217
  228. package/src/__tests__/guards.test.ts +0 -102
  229. package/src/__tests__/job.test.ts +0 -98
  230. package/src/__tests__/layer.test.ts +0 -212
  231. package/src/__tests__/path-security.test.ts +0 -114
  232. package/src/__tests__/patterns.test.ts +0 -273
  233. package/src/__tests__/redaction.test.ts +0 -244
  234. package/src/__tests__/resilience.test.ts +0 -246
  235. package/src/__tests__/result.test.ts +0 -155
  236. package/src/__tests__/serialization.test.ts +0 -401
  237. package/src/__tests__/topo.test.ts +0 -181
  238. package/src/__tests__/trail.test.ts +0 -217
  239. package/src/__tests__/validate-topo.test.ts +0 -278
  240. package/src/__tests__/validation.test.ts +0 -283
  241. package/src/__tests__/workspace.test.ts +0 -183
  242. package/src/adapters.ts +0 -68
  243. package/src/event.ts +0 -77
  244. package/src/health.ts +0 -23
  245. package/src/job.ts +0 -20
  246. package/tsconfig.json +0 -9
  247. package/tsconfig.tsbuildinfo +0 -1
@@ -1,153 +0,0 @@
1
- /**
2
- * Serialization utilities for @ontrails/core
3
- *
4
- * Safe JSON parsing/stringifying and error serialization/deserialization
5
- * for transport across process boundaries.
6
- */
7
- import { ValidationError, AmbiguousError, AssertionError, NotFoundError, AlreadyExistsError, ConflictError, PermissionError, TimeoutError, RateLimitError, NetworkError, InternalError, AuthError, CancelledError, isTrailsError, } from './errors.js';
8
- import { Result } from './result.js';
9
- // ---------------------------------------------------------------------------
10
- // Internal helpers (defined before usage)
11
- // ---------------------------------------------------------------------------
12
- /** Build options object without including undefined context. */
13
- const buildOpts = (context) => {
14
- if (context !== undefined) {
15
- return { context };
16
- }
17
- return {};
18
- };
19
- const errorFactories = {
20
- auth: (msg, opts) => new AuthError(msg, opts),
21
- cancelled: (msg, opts) => new CancelledError(msg, opts),
22
- conflict: (msg, opts) => new ConflictError(msg, opts),
23
- internal: (msg, opts) => new InternalError(msg, opts),
24
- network: (msg, opts) => new NetworkError(msg, opts),
25
- not_found: (msg, opts) => new NotFoundError(msg, opts),
26
- permission: (msg, opts) => new PermissionError(msg, opts),
27
- rate_limit: (msg, opts, retryAfter) => {
28
- const rlOpts = {
29
- ...opts,
30
- };
31
- if (retryAfter !== undefined) {
32
- rlOpts.retryAfter = retryAfter;
33
- }
34
- return new RateLimitError(msg, rlOpts);
35
- },
36
- timeout: (msg, opts) => new TimeoutError(msg, opts),
37
- validation: (msg, opts) => new ValidationError(msg, opts),
38
- };
39
- const createErrorByCategory = (category, message, context, retryAfter) => {
40
- const opts = buildOpts(context);
41
- const factory = errorFactories[category] ?? errorFactories.internal;
42
- return factory(message, opts, retryAfter);
43
- };
44
- /** Map error class names to their constructors for precise round-tripping. */
45
- const errorConstructorsByName = {
46
- AlreadyExistsError: (msg, opts) => new AlreadyExistsError(msg, opts),
47
- AmbiguousError: (msg, opts) => new AmbiguousError(msg, opts),
48
- AssertionError: (msg, opts) => new AssertionError(msg, opts),
49
- AuthError: (msg, opts) => new AuthError(msg, opts),
50
- CancelledError: (msg, opts) => new CancelledError(msg, opts),
51
- ConflictError: (msg, opts) => new ConflictError(msg, opts),
52
- InternalError: (msg, opts) => new InternalError(msg, opts),
53
- NetworkError: (msg, opts) => new NetworkError(msg, opts),
54
- NotFoundError: (msg, opts) => new NotFoundError(msg, opts),
55
- PermissionError: (msg, opts) => new PermissionError(msg, opts),
56
- RateLimitError: (msg, opts, retryAfter) => {
57
- const rlOpts = {
58
- ...opts,
59
- };
60
- if (retryAfter !== undefined) {
61
- rlOpts.retryAfter = retryAfter;
62
- }
63
- return new RateLimitError(msg, rlOpts);
64
- },
65
- TimeoutError: (msg, opts) => new TimeoutError(msg, opts),
66
- ValidationError: (msg, opts) => new ValidationError(msg, opts),
67
- };
68
- // ---------------------------------------------------------------------------
69
- // Error serialization
70
- // ---------------------------------------------------------------------------
71
- /** Extract structured data from an Error for transport. */
72
- export const serializeError = (error) => {
73
- const result = {
74
- message: error.message,
75
- name: error.name,
76
- stack: error.stack,
77
- };
78
- if (isTrailsError(error)) {
79
- return {
80
- ...result,
81
- category: error.category,
82
- context: error.context,
83
- retryAfter: error instanceof RateLimitError ? error.retryAfter : undefined,
84
- retryable: error.retryable,
85
- };
86
- }
87
- return result;
88
- };
89
- /** Reconstruct a TrailsError from serialized data. */
90
- export const deserializeError = (data) => {
91
- const opts = buildOpts(data.context);
92
- const nameFactory = errorConstructorsByName[data.name];
93
- const error = nameFactory
94
- ? nameFactory(data.message, opts, data.retryAfter)
95
- : createErrorByCategory(data.category ?? 'internal', data.message, data.context, data.retryAfter);
96
- if (data.stack) {
97
- error.stack = data.stack;
98
- }
99
- return error;
100
- };
101
- // ---------------------------------------------------------------------------
102
- // Safe JSON
103
- // ---------------------------------------------------------------------------
104
- /** Parse a JSON string, returning a Result instead of throwing. */
105
- export const safeParse = (json) => {
106
- try {
107
- return Result.ok(JSON.parse(json));
108
- }
109
- catch (error) {
110
- return Result.err(new ValidationError('Invalid JSON', {
111
- cause: error instanceof Error ? error : new Error(String(error)),
112
- context: { input: json.slice(0, 200) },
113
- }));
114
- }
115
- };
116
- /** Stringify a value, returning a Result. Handles circular references. */
117
- export const safeStringify = (value) => {
118
- try {
119
- // Track the current ancestor chain, not every object ever visited.
120
- // This allows shared references in a DAG while still detecting cycles.
121
- const stack = [];
122
- const keys = [];
123
- const json = JSON.stringify(value, function json(key, val) {
124
- if (stack.length > 0) {
125
- // `this` is the object that contains `key`. Trim the stack back
126
- // to `this` so we only track the current ancestor path.
127
- const thisIndex = stack.lastIndexOf(this);
128
- stack.splice(thisIndex + 1);
129
- keys.splice(thisIndex);
130
- }
131
- if (typeof val === 'object' && val !== null) {
132
- if (stack.includes(val)) {
133
- return '[Circular]';
134
- }
135
- stack.push(val);
136
- keys.push(key);
137
- }
138
- return val;
139
- });
140
- if (json === undefined) {
141
- return Result.err(new InternalError('Value is not JSON-serializable', {
142
- context: { type: typeof value },
143
- }));
144
- }
145
- return Result.ok(json);
146
- }
147
- catch (error) {
148
- return Result.err(new InternalError('Failed to stringify value', {
149
- cause: error instanceof Error ? error : new Error(String(error)),
150
- }));
151
- }
152
- };
153
- //# sourceMappingURL=serialization.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO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EAAE,CAAC;oBACxB,OAAO,YAAY,CAAC;gBACtB,CAAC;gBACD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAChB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC,CAAC,CAAC;QACH,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,GAAG,CACf,IAAI,aAAa,CAAC,gCAAgC,EAAE;gBAClD,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,KAAK,EAAE;aAChC,CAAC,CACH,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,GAAG,CACf,IAAI,aAAa,CAAC,2BAA2B,EAAE;YAC7C,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACjE,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
package/dist/topo.d.ts DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * Application entry point — scans module exports to build a topology graph.
3
- */
4
- import type { AnyEvent } from './event.js';
5
- import type { AnyTrail } from './trail.js';
6
- export interface Topo {
7
- readonly name: string;
8
- readonly trails: ReadonlyMap<string, AnyTrail>;
9
- readonly events: ReadonlyMap<string, AnyEvent>;
10
- get(id: string): AnyTrail | undefined;
11
- has(id: string): boolean;
12
- list(): AnyTrail[];
13
- listEvents(): AnyEvent[];
14
- }
15
- export declare const topo: (name: string, ...modules: Record<string, unknown>[]) => Topo;
16
- //# sourceMappingURL=topo.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"topo.d.ts","sourceRoot":"","sources":["../src/topo.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM3C,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/C,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,IAAI,IAAI,QAAQ,EAAE,CAAC;IACnB,UAAU,IAAI,QAAQ,EAAE,CAAC;CAC1B;AA0ED,eAAO,MAAM,IAAI,GACf,MAAM,MAAM,EACZ,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KACpC,IAaF,CAAC"}
package/dist/topo.js DELETED
@@ -1,66 +0,0 @@
1
- /**
2
- * Application entry point — scans module exports to build a topology graph.
3
- */
4
- import { ValidationError } from './errors.js';
5
- const isRegistrable = (value) => {
6
- if (typeof value !== 'object' || value === null) {
7
- return false;
8
- }
9
- const { kind } = value;
10
- return kind === 'trail' || kind === 'event';
11
- };
12
- // ---------------------------------------------------------------------------
13
- // Topo implementation
14
- // ---------------------------------------------------------------------------
15
- const createTopo = (name, trails, events) => ({
16
- events,
17
- get(id) {
18
- return trails.get(id);
19
- },
20
- has(id) {
21
- return trails.has(id);
22
- },
23
- list() {
24
- return [...trails.values()];
25
- },
26
- listEvents() {
27
- return [...events.values()];
28
- },
29
- name,
30
- trails,
31
- });
32
- // ---------------------------------------------------------------------------
33
- // topo()
34
- // ---------------------------------------------------------------------------
35
- /** Register a single registrable value into the appropriate map. */
36
- const register = (value, trails, events) => {
37
- const { id } = value;
38
- const registrars = {
39
- event: () => {
40
- if (events.has(id)) {
41
- throw new ValidationError(`Duplicate event ID: "${id}"`);
42
- }
43
- events.set(id, value);
44
- },
45
- trail: () => {
46
- if (trails.has(id)) {
47
- throw new ValidationError(`Duplicate trail ID: "${id}"`);
48
- }
49
- trails.set(id, value);
50
- },
51
- };
52
- registrars[value.kind]?.();
53
- };
54
- export const topo = (name, ...modules) => {
55
- const trails = new Map();
56
- const events = new Map();
57
- for (const mod of modules) {
58
- for (const value of Object.values(mod)) {
59
- if (isRegistrable(value)) {
60
- register(value, trails, events);
61
- }
62
- }
63
- }
64
- return createTopo(name, trails, events);
65
- };
66
- //# sourceMappingURL=topo.js.map
package/dist/topo.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"topo.js","sourceRoot":"","sources":["../src/topo.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAwB9C,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE;IAC7D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAgC,CAAC;IAClD,OAAO,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,OAAO,CAAC;AAC9C,CAAC,CAAC;AAEF,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,MAAM,UAAU,GAAG,CACjB,IAAY,EACZ,MAAqC,EACrC,MAAqC,EAC/B,EAAE,CAAC,CAAC;IACV,MAAM;IACN,GAAG,CAAC,EAAU;QACZ,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IACD,GAAG,CAAC,EAAU;QACZ,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,IAAI;QACF,OAAO,CAAC,GAAG,MAAM,CAAC,M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E,CAAC;YACvC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC,CAAC"}
package/dist/trail.d.ts DELETED
@@ -1,89 +0,0 @@
1
- import type { z } from 'zod';
2
- import type { FieldOverride } from './derive.js';
3
- import type { Result } from './result.js';
4
- import type { Implementation, TrailContext } from './types.js';
5
- /**
6
- * A named example for documentation and testing.
7
- *
8
- * The `input` field accepts `Partial<I>` so that fields with schema defaults
9
- * (e.g. `z.number().default(20)`) can be omitted from examples. The schema
10
- * fills in defaults at validation time.
11
- */
12
- export interface TrailExample<I, O> {
13
- /** Human-readable name */
14
- readonly name: string;
15
- /** Optional description of what this example demonstrates */
16
- readonly description?: string | undefined;
17
- /** The input value — fields with schema defaults may be omitted */
18
- readonly input: Partial<I>;
19
- /** Expected output for success-path examples */
20
- readonly expected?: O | undefined;
21
- /** Error class name for error-path examples */
22
- readonly error?: string | undefined;
23
- }
24
- /** Everything needed to define a trail (minus the id) */
25
- export interface TrailSpec<I, O> {
26
- /** Zod schema for validating input */
27
- readonly input: z.ZodType<I>;
28
- /** Zod schema for validating output (optional — some trails are fire-and-forget) */
29
- readonly output?: z.ZodType<O> | undefined;
30
- /** The pure function that does the work (sync or async authoring) */
31
- readonly run: Implementation<I, O>;
32
- /** Human-readable description */
33
- readonly description?: string | undefined;
34
- /** Named examples for docs and testing */
35
- readonly examples?: readonly TrailExample<I, O>[] | undefined;
36
- /** What this trail does to the world: read, write (default), or destroy */
37
- readonly intent?: 'read' | 'write' | 'destroy' | undefined;
38
- /** Trail is idempotent (safe to retry) */
39
- readonly idempotent?: boolean | undefined;
40
- /** Arbitrary metadata for tooling and filtering */
41
- readonly metadata?: Readonly<Record<string, unknown>> | undefined;
42
- /** Named sets of downstream trail IDs that may be invoked */
43
- readonly detours?: Readonly<Record<string, readonly string[]>> | undefined;
44
- /** Per-field overrides for deriveFields() (labels, hints, options) */
45
- readonly fields?: Readonly<Record<string, FieldOverride>> | undefined;
46
- /** IDs of downstream trails this trail may invoke via ctx.follow() */
47
- readonly follow?: readonly string[] | undefined;
48
- }
49
- /** Intent describes what a trail does to the world */
50
- export type Intent = 'read' | 'write' | 'destroy';
51
- /** A fully-defined trail — the unit of work in the Trails system */
52
- export interface Trail<I, O> extends Omit<TrailSpec<I, O>, 'run' | 'follow' | 'intent'> {
53
- readonly kind: 'trail';
54
- readonly id: string;
55
- readonly run: Implementation<I, O>;
56
- /** IDs of downstream trails this trail may invoke via ctx.follow() (always present, default []) */
57
- readonly follow: readonly string[];
58
- /** What this trail does to the world (always present, default 'write') */
59
- readonly intent: Intent;
60
- }
61
- /**
62
- * Create a trail definition.
63
- *
64
- * Returns a frozen object with `kind: "trail"` and all spec fields.
65
- * The trail is inert until handed to a runner.
66
- *
67
- * @example
68
- * ```typescript
69
- * // ID as first argument (recommended for human authoring)
70
- * const show = trail("entity.show", {
71
- * input: z.object({ name: z.string() }),
72
- * run: (input) => Result.ok(entity),
73
- * });
74
- *
75
- * // Full spec object (for programmatic generation)
76
- * const show = trail({
77
- * id: "entity.show",
78
- * input: z.object({ name: z.string() }),
79
- * run: (input) => Result.ok(entity),
80
- * });
81
- * ```
82
- */
83
- export declare function trail<I, O>(id: string, spec: TrailSpec<I, O>): Trail<I, O>;
84
- export declare function trail<I, O>(spec: TrailSpec<I, O> & {
85
- readonly id: string;
86
- }): Trail<I, O>;
87
- export type AnyTrail = Trail<any, any>;
88
- export type { Implementation, TrailContext, Result };
89
- //# sourceMappingURL=trail.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trail.d.ts","sourceRoot":"","sources":["../src/trail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO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EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5E,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC9C,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AA4Bf,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEvC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC"}
package/dist/trail.js DELETED
@@ -1,18 +0,0 @@
1
- export function trail(idOrSpec, maybeSpec) {
2
- const resolved = typeof idOrSpec === 'string'
3
- ? { id: idOrSpec, spec: maybeSpec }
4
- : { id: idOrSpec.id, spec: idOrSpec };
5
- if (!resolved.spec) {
6
- throw new TypeError('trail() requires a spec when an id is provided');
7
- }
8
- const { run, follow: rawFollow, intent: rawIntent, ...spec } = resolved.spec;
9
- return Object.freeze({
10
- ...spec,
11
- follow: Object.freeze([...(rawFollow ?? [])]),
12
- id: resolved.id,
13
- intent: rawIntent ?? 'write',
14
- kind: 'trail',
15
- run: async (input, ctx) => await run(input, ctx),
16
- });
17
- }
18
- //# sourceMappingURL=trail.js.map
package/dist/trail.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"trail.js","sourceRoot":"","sources":["../src/trail.ts"],"names":[],"mappings":"AA+GA,MAAM,UAAU,KAAK,CACnB,QAA8D,EAC9D,SAA2B;IAE3B,MAAM,QAAQ,GACZ,OAAO,QAAQ,KAAK,QAAQ;QAC1B,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;QACnC,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAE1C,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC;IAE7E,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,IAAI;QACP,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7C,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,MAAM,EAAE,SAAS,IAAI,OAAO;QAC5B,IAAI,EAAE,OAAgB;QACtB,GAAG,EAAE,KAAK,EAAE,KAAQ,EAAE,GAAiB,EAAE,EAAE,CAAC,MAAM,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC;KAClE,CAAC,CAAC;AACL,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,46 +0,0 @@
1
- import type { Result } from './result.js';
2
- /**
3
- * Trail implementation — sync or async.
4
- *
5
- * Authors can return `Result` directly or wrap it in a `Promise`. The framework
6
- * normalizes with `await` at every call site, so both forms work transparently.
7
- */
8
- export type Implementation<I, O> = (input: I, ctx: TrailContext) => Result<O, Error> | Promise<Result<O, Error>>;
9
- /** Invoke another trail by id — used for trail composition */
10
- export type FollowFn = <O>(id: string, input: unknown) => Promise<Result<O, Error>>;
11
- /** Callback for reporting progress from long-running trails */
12
- export type ProgressCallback = (event: ProgressEvent) => void;
13
- /** Structured progress event emitted during trail execution */
14
- export interface ProgressEvent {
15
- readonly type: 'start' | 'progress' | 'complete' | 'error';
16
- readonly current?: number | undefined;
17
- readonly total?: number | undefined;
18
- readonly message?: string | undefined;
19
- readonly ts: string;
20
- }
21
- /** Minimal logger interface — implementations can bridge to any logging library */
22
- export interface Logger {
23
- readonly name?: string | undefined;
24
- trace(message: string, data?: Record<string, unknown>): void;
25
- debug(message: string, data?: Record<string, unknown>): void;
26
- info(message: string, data?: Record<string, unknown>): void;
27
- warn(message: string, data?: Record<string, unknown>): void;
28
- error(message: string, data?: Record<string, unknown>): void;
29
- fatal(message: string, data?: Record<string, unknown>): void;
30
- child(context: Record<string, unknown>): Logger;
31
- }
32
- /** Runtime context threaded through every trail execution */
33
- export interface TrailContext {
34
- readonly requestId: string;
35
- readonly signal: AbortSignal;
36
- readonly follow?: FollowFn | undefined;
37
- readonly permit?: unknown | undefined;
38
- readonly workspaceRoot?: string | undefined;
39
- readonly logger?: Logger | undefined;
40
- readonly progress?: ProgressCallback | undefined;
41
- readonly cwd?: string | undefined;
42
- readonly env?: Record<string, string | undefined> | undefined;
43
- readonly [key: string]: unknown;
44
- }
45
- export type Surface = 'cli' | 'mcp' | 'http' | 'ws';
46
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI,CACjC,KAAK,EAAE,CAAC,EACR,GAAG,EAAE,YAAY,KACd,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAElD,8DAA8D;AAC9D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,EACvB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,OAAO,KACX,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAE/B,+DAA+D;AAC/D,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAE9D,+DAA+D;AAC/D,M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D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IAC9D,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC"}
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1,24 +0,0 @@
1
- /**
2
- * Structural validation for a Topo graph.
3
- *
4
- * Checks trail follow references, example input validity, event origin
5
- * references, and output schema completeness. Returns a Result with all
6
- * issues collected into a single ValidationError.
7
- */
8
- import { ValidationError } from './errors.js';
9
- import { Result } from './result.js';
10
- import type { Topo } from './topo.js';
11
- export interface TopoIssue {
12
- readonly trailId: string;
13
- readonly rule: string;
14
- readonly message: string;
15
- }
16
- /**
17
- * Validate the structural integrity of a Topo graph.
18
- *
19
- * Checks follow references, example inputs, event origins, and output
20
- * schema presence. Returns `Result.ok()` when no issues are found, or
21
- * `Result.err(ValidationError)` with all issues in the error context.
22
- */
23
- export declare const validateTopo: (topo: Topo) => Result<void, ValidationError>;
24
- //# sourceMappingURL=validate-topo.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate-topo.d.ts","sourceRoot":"","sources":["../src/validate-topo.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQtC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAiKD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,IAAI,KAAG,MAAM,CAAC,IAAI,EAAE,eAAe,CAmBrE,CAAC"}
@@ -1,158 +0,0 @@
1
- /**
2
- * Structural validation for a Topo graph.
3
- *
4
- * Checks trail follow references, example input validity, event origin
5
- * references, and output schema completeness. Returns a Result with all
6
- * issues collected into a single ValidationError.
7
- */
8
- import { ValidationError } from './errors.js';
9
- import { Result } from './result.js';
10
- import { validateInput } from './validation.js';
11
- // ---------------------------------------------------------------------------
12
- // Validators
13
- // ---------------------------------------------------------------------------
14
- const WHITE = 0;
15
- const GRAY = 1;
16
- const BLACK = 2;
17
- /** Build an adjacency list and initial color map from trails with follow. */
18
- const buildFollowGraph = (trails) => {
19
- const graph = new Map();
20
- for (const [id, t] of trails) {
21
- if (t.follow.length > 0) {
22
- graph.set(id, t.follow);
23
- }
24
- }
25
- const color = new Map();
26
- for (const id of graph.keys()) {
27
- color.set(id, WHITE);
28
- }
29
- return { color, graph };
30
- };
31
- /** Detect multi-node cycles in the trail follow graph via DFS. */
32
- const detectFollowCycles = (trails) => {
33
- const issues = [];
34
- const { color, graph } = buildFollowGraph(trails);
35
- const dfs = (node, path) => {
36
- color.set(node, GRAY);
37
- for (const next of graph.get(node) ?? []) {
38
- if (!graph.has(next)) {
39
- continue;
40
- }
41
- const c = color.get(next) ?? WHITE;
42
- if (c === GRAY) {
43
- const cycle = [...path.slice(path.indexOf(next)), next];
44
- issues.push({
45
- message: `Cycle detected: ${cycle.join(' → ')}`,
46
- rule: 'follow-cycle',
47
- trailId: next,
48
- });
49
- }
50
- else if (c === WHITE) {
51
- dfs(next, [...path, next]);
52
- }
53
- }
54
- color.set(node, BLACK);
55
- };
56
- for (const id of graph.keys()) {
57
- if (color.get(id) === WHITE) {
58
- dfs(id, [id]);
59
- }
60
- }
61
- return issues;
62
- };
63
- const checkFollows = (trails, topo) => {
64
- const issues = [];
65
- for (const [id, trail] of trails) {
66
- for (const followId of trail.follow) {
67
- if (followId === id) {
68
- issues.push({
69
- message: `Trail follows itself`,
70
- rule: 'no-self-follow',
71
- trailId: id,
72
- });
73
- }
74
- else if (!topo.has(followId)) {
75
- issues.push({
76
- message: `Follows "${followId}" which is not in the topo`,
77
- rule: 'follow-exists',
78
- trailId: id,
79
- });
80
- }
81
- }
82
- }
83
- issues.push(...detectFollowCycles(trails));
84
- return issues;
85
- };
86
- const checkOneExample = (id, example, inputSchema, hasOutput) => {
87
- const issues = [];
88
- const result = validateInput(inputSchema, example.input);
89
- if (result.isErr() && example.error !== 'ValidationError') {
90
- issues.push({
91
- message: `Example "${example.name}" input does not parse against schema`,
92
- rule: 'example-input-valid',
93
- trailId: id,
94
- });
95
- }
96
- if (example.expected !== undefined && !hasOutput) {
97
- issues.push({
98
- message: `Example "${example.name}" has expected output but trail has no output schema`,
99
- rule: 'output-schema-present',
100
- trailId: id,
101
- });
102
- }
103
- return issues;
104
- };
105
- const checkExamples = (trails) => {
106
- const issues = [];
107
- for (const [id, trail] of trails) {
108
- if (!trail.examples) {
109
- continue;
110
- }
111
- for (const example of trail.examples) {
112
- issues.push(...checkOneExample(id, example, trail.input, !!trail.output));
113
- }
114
- }
115
- return issues;
116
- };
117
- const checkEventOrigins = (events, topo) => {
118
- const issues = [];
119
- for (const [id, evt] of events) {
120
- if (!evt.from) {
121
- continue;
122
- }
123
- for (const originId of evt.from) {
124
- if (!topo.has(originId)) {
125
- issues.push({
126
- message: `Event origin "${originId}" is not in the topo`,
127
- rule: 'event-origin-exists',
128
- trailId: id,
129
- });
130
- }
131
- }
132
- }
133
- return issues;
134
- };
135
- // ---------------------------------------------------------------------------
136
- // Public API
137
- // ---------------------------------------------------------------------------
138
- /**
139
- * Validate the structural integrity of a Topo graph.
140
- *
141
- * Checks follow references, example inputs, event origins, and output
142
- * schema presence. Returns `Result.ok()` when no issues are found, or
143
- * `Result.err(ValidationError)` with all issues in the error context.
144
- */
145
- export const validateTopo = (topo) => {
146
- const issues = [
147
- ...checkFollows(topo.trails, topo),
148
- ...checkExamples(topo.trails),
149
- ...checkEventOrigins(topo.events, topo),
150
- ];
151
- if (issues.length === 0) {
152
- return Result.ok();
153
- }
154
- return Result.err(new ValidationError(`Topo validation failed with ${issues.length} issue(s)`, {
155
- context: { issues },
156
- }));
157
- };
158
- //# sourceMappingURL=validate-topo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate-topo.js","sourceRoot":"","sources":["../src/validate-topo.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAYhD,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E,MAAM,KAAK,GAAG,CAAC,CAAC;AAChB,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,MAAM,KAAK,GAAG,CAAC,CAAC;AAEhB,6EAA6E;AAC7E,MAAM,gBAAgB,GAAG,CACvB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