stitchkit 0.100.2 → 0.101.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 (242) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/README.md +2 -1
  3. package/dist/entrypoints/agent-runtime/browser.js +119 -119
  4. package/dist/entrypoints/agent-runtime/coding-tools.js +15 -20
  5. package/dist/entrypoints/agent-runtime/harness.js +55 -63
  6. package/dist/entrypoints/agent-runtime/openrouter.js +6 -6
  7. package/dist/entrypoints/agent-runtime/sandbox.js +20 -25
  8. package/dist/entrypoints/agent-runtime/sqlite/bun.js +11 -13
  9. package/dist/entrypoints/agent-runtime/sqlite/node.js +11 -13
  10. package/dist/entrypoints/agent-runtime/testing.js +32 -34
  11. package/dist/entrypoints/agent-runtime.js +395 -402
  12. package/dist/entrypoints/application/diagnostic-journal.js +26 -27
  13. package/dist/entrypoints/application/directory-inbox.js +16 -17
  14. package/dist/entrypoints/application/grammy.js +13 -13
  15. package/dist/entrypoints/application/opentelemetry.js +13 -13
  16. package/dist/entrypoints/application/schemas.js +24 -24
  17. package/dist/entrypoints/application.js +209 -210
  18. package/dist/entrypoints/bin/upgrade-cli.js +2 -2
  19. package/dist/entrypoints/cli.js +81 -84
  20. package/dist/entrypoints/contract.js +54 -57
  21. package/dist/entrypoints/declaration.js +22 -22
  22. package/dist/entrypoints/files.js +18 -21
  23. package/dist/entrypoints/geo.js +7 -8
  24. package/dist/entrypoints/google.js +2 -2
  25. package/dist/entrypoints/index.js +150 -154
  26. package/dist/entrypoints/live.js +45 -47
  27. package/dist/entrypoints/node.js +68 -74
  28. package/dist/entrypoints/oauth.js +6 -6
  29. package/dist/entrypoints/observability.d.ts +1 -0
  30. package/dist/entrypoints/observability.d.ts.map +1 -1
  31. package/dist/entrypoints/observability.js +116 -87
  32. package/dist/entrypoints/primitives.js +35 -35
  33. package/dist/entrypoints/react/keyboard.d.ts +4 -0
  34. package/dist/entrypoints/react/keyboard.d.ts.map +1 -0
  35. package/dist/entrypoints/react/keyboard.js +397 -0
  36. package/dist/entrypoints/react.js +10 -10
  37. package/dist/entrypoints/release.js +7 -7
  38. package/dist/entrypoints/remote.js +15 -17
  39. package/dist/entrypoints/server.js +198 -200
  40. package/dist/entrypoints/telegram/html.d.ts +5 -0
  41. package/dist/entrypoints/telegram/html.d.ts.map +1 -0
  42. package/dist/entrypoints/telegram/html.js +26 -0
  43. package/dist/entrypoints/telegram/screens.d.ts +14 -0
  44. package/dist/entrypoints/telegram/screens.d.ts.map +1 -0
  45. package/dist/entrypoints/telegram/screens.js +2028 -0
  46. package/dist/entrypoints/telegram.d.ts +11 -3
  47. package/dist/entrypoints/telegram.d.ts.map +1 -1
  48. package/dist/entrypoints/telegram.js +779 -159
  49. package/dist/entrypoints/testing.js +75 -79
  50. package/dist/entrypoints/tools/connections.js +30 -32
  51. package/dist/entrypoints/tools/contract.js +18 -20
  52. package/dist/entrypoints/tools/invoker.js +12 -17
  53. package/dist/entrypoints/tools.js +224 -229
  54. package/dist/entrypoints/tracking/server.js +6 -6
  55. package/dist/entrypoints/tracking.js +40 -42
  56. package/dist/entrypoints/voice.js +3 -3
  57. package/dist/{index-eaysmdtq.js → index-0ndk4555.js} +56 -56
  58. package/dist/{index-2bxbyab0.js → index-1bx1xv1k.js} +1 -1
  59. package/dist/{index-p5r7qpdd.js → index-1eeqpadm.js} +4 -4
  60. package/dist/{index-hadmp193.js → index-3ct7hhq6.js} +210 -210
  61. package/dist/{index-e01r054k.js → index-45tdvqa3.js} +26 -26
  62. package/dist/{index-dce5wxcq.js → index-4s0fep5q.js} +8 -8
  63. package/dist/index-50ejfz75.js +9 -0
  64. package/dist/{index-m9zn6cpq.js → index-5107q189.js} +12 -12
  65. package/dist/{index-sbdmyz75.js → index-5cc6r990.js} +3 -3
  66. package/dist/{index-c6bxbsnc.js → index-7kxw1awn.js} +2 -2
  67. package/dist/{index-0r0fbk7z.js → index-7z9ym7t8.js} +28 -28
  68. package/dist/{index-p7hgdyhb.js → index-814xpr6d.js} +2 -2
  69. package/dist/{index-gtj3zc53.js → index-8kzct1d6.js} +99 -99
  70. package/dist/{index-1zbbzgfh.js → index-9pw0a51a.js} +4 -4
  71. package/dist/{index-79z7m7dt.js → index-a9pd417t.js} +35 -35
  72. package/dist/{index-ham5sz8m.js → index-aaj97r4y.js} +45 -45
  73. package/dist/{index-s812ycat.js → index-aan6hqb9.js} +3 -3
  74. package/dist/{index-10x2hbx0.js → index-adhgd4pe.js} +44 -44
  75. package/dist/{index-2gxzjvyr.js → index-afjvjyck.js} +23 -23
  76. package/dist/{index-qmy6zq75.js → index-ahvsksw5.js} +16 -16
  77. package/dist/{index-hr4tzbwq.js → index-ap3gqe56.js} +3 -3
  78. package/dist/{index-znfs20ss.js → index-b2bz0kdm.js} +16 -16
  79. package/dist/{index-r066jx76.js → index-c6aagrbd.js} +148 -120
  80. package/dist/{index-k30h66yd.js → index-ck71tbcf.js} +9 -9
  81. package/dist/{index-eqqvgdb3.js → index-ct75c3at.js} +2 -2
  82. package/dist/{index-gw8bmyaj.js → index-djjhhgjk.js} +41 -41
  83. package/dist/{index-8qt2m66q.js → index-dvwj1f43.js} +43 -43
  84. package/dist/index-e05cjgtf.js +144 -0
  85. package/dist/{index-yw4fzmdz.js → index-e6c2spsd.js} +79 -30
  86. package/dist/{index-fhwqwxe0.js → index-ej331hah.js} +1 -1
  87. package/dist/{index-9t3dffv2.js → index-ewbaywk5.js} +5 -5
  88. package/dist/{index-7p1f0vp2.js → index-fyphpknh.js} +25 -25
  89. package/dist/{index-83bdg97s.js → index-g149e9pk.js} +1 -1
  90. package/dist/{index-ngfhvfpd.js → index-g6a3na27.js} +4 -4
  91. package/dist/{index-qwhynv6x.js → index-h124epcf.js} +20 -20
  92. package/dist/{index-h6eeys1v.js → index-h97tqqp1.js} +9 -9
  93. package/dist/{index-zcgf3gqf.js → index-hby4qhax.js} +10 -10
  94. package/dist/{index-5jrd0yng.js → index-j8aw2c0e.js} +4 -4
  95. package/dist/{index-d8m8zpd8.js → index-jzczzcsb.js} +14 -14
  96. package/dist/index-kqnd6a85.js +26 -0
  97. package/dist/{index-35mh5bhj.js → index-kw1ws0cs.js} +12 -12
  98. package/dist/{index-4gcnakhx.js → index-m38ej7e5.js} +2 -2
  99. package/dist/{index-ndddxtyx.js → index-m79yr938.js} +19 -19
  100. package/dist/{index-5p2m7we1.js → index-m9fndta6.js} +11 -11
  101. package/dist/index-mnkk1ffz.js +150 -0
  102. package/dist/index-n15jny5b.js +4 -0
  103. package/dist/{index-2vtcmrj9.js → index-n53mswt3.js} +20 -20
  104. package/dist/{index-bt14acb5.js → index-n5yqxd3d.js} +21 -21
  105. package/dist/{index-bm5rx7n6.js → index-n9tyz8z3.js} +12 -12
  106. package/dist/index-nmaqxdx7.js +463 -0
  107. package/dist/{index-mqv3b5rh.js → index-nx6eazt0.js} +30 -30
  108. package/dist/{index-3z73fh2c.js → index-q0th8q0z.js} +9 -9
  109. package/dist/{index-v260df89.js → index-qjeggp8w.js} +20 -20
  110. package/dist/{index-zfrhfn82.js → index-r1z0rd9c.js} +20 -20
  111. package/dist/{index-wqgjfstn.js → index-r5c4fedv.js} +3 -3
  112. package/dist/{index-cyktc4bp.js → index-r5hsgkz5.js} +118 -118
  113. package/dist/{index-0b1ess5e.js → index-r7a7r7ha.js} +1 -1
  114. package/dist/{index-1j8pm5t0.js → index-rfkh44ss.js} +15 -15
  115. package/dist/index-rz3z13e9.js +47 -0
  116. package/dist/{index-k6gpggb9.js → index-s80awwsw.js} +35 -35
  117. package/dist/{index-vqr7f7v8.js → index-ssmd41kh.js} +124 -124
  118. package/dist/index-sznqf8fx.js +20 -0
  119. package/dist/{index-ensd0r74.js → index-v14qqmys.js} +41 -41
  120. package/dist/{index-paz6sgdp.js → index-v4a2fjtk.js} +36 -36
  121. package/dist/{index-d9pk3td4.js → index-w0eqdhyd.js} +14 -14
  122. package/dist/{index-5qn1kx34.js → index-w575evhq.js} +29 -29
  123. package/dist/{index-3gye9wzb.js → index-w5s3xftz.js} +26 -26
  124. package/dist/{index-tm88avnj.js → index-wykebpn9.js} +3 -3
  125. package/dist/{index-sh3s86na.js → index-xkhk5d6g.js} +17 -17
  126. package/dist/{index-6k1937bx.js → index-xqhede6x.js} +4 -4
  127. package/dist/{index-f4fx2tza.js → index-zs4ms3th.js} +181 -181
  128. package/dist/{index-k5hsfc3j.js → index-zsvzhjtk.js} +1 -1
  129. package/dist/internal/secret-shapes.d.ts +21 -0
  130. package/dist/internal/secret-shapes.d.ts.map +1 -0
  131. package/dist/observability/bounded-logger.d.ts +2 -0
  132. package/dist/observability/bounded-logger.d.ts.map +1 -1
  133. package/dist/observability/sanitize.d.ts +6 -0
  134. package/dist/observability/sanitize.d.ts.map +1 -1
  135. package/dist/observability/secret-values.d.ts +25 -0
  136. package/dist/observability/secret-values.d.ts.map +1 -0
  137. package/dist/react/keyboard/hooks.d.ts +71 -0
  138. package/dist/react/keyboard/hooks.d.ts.map +1 -0
  139. package/dist/react/keyboard/layers.d.ts +98 -0
  140. package/dist/react/keyboard/layers.d.ts.map +1 -0
  141. package/dist/react/keyboard/zone.d.ts +139 -0
  142. package/dist/react/keyboard/zone.d.ts.map +1 -0
  143. package/dist/telegram/bot-api.d.ts +7 -4
  144. package/dist/telegram/bot-api.d.ts.map +1 -1
  145. package/dist/telegram/crypto.d.ts +16 -0
  146. package/dist/telegram/crypto.d.ts.map +1 -0
  147. package/dist/telegram/html/check.d.ts +26 -0
  148. package/dist/telegram/html/check.d.ts.map +1 -0
  149. package/dist/telegram/html/nodes.d.ts +70 -0
  150. package/dist/telegram/html/nodes.d.ts.map +1 -0
  151. package/dist/telegram/html/parse.d.ts +35 -0
  152. package/dist/telegram/html/parse.d.ts.map +1 -0
  153. package/dist/telegram/html/render.d.ts +39 -0
  154. package/dist/telegram/html/render.d.ts.map +1 -0
  155. package/dist/telegram/init-data.d.ts +3 -44
  156. package/dist/telegram/init-data.d.ts.map +1 -1
  157. package/dist/telegram/operator-channel.d.ts +19 -3
  158. package/dist/telegram/operator-channel.d.ts.map +1 -1
  159. package/dist/telegram/operator-dedupe.d.ts +44 -0
  160. package/dist/telegram/operator-dedupe.d.ts.map +1 -0
  161. package/dist/telegram/screens/callback-codec.d.ts +34 -0
  162. package/dist/telegram/screens/callback-codec.d.ts.map +1 -0
  163. package/dist/telegram/screens/dispatch.d.ts +22 -0
  164. package/dist/telegram/screens/dispatch.d.ts.map +1 -0
  165. package/dist/telegram/screens/display.d.ts +70 -0
  166. package/dist/telegram/screens/display.d.ts.map +1 -0
  167. package/dist/telegram/screens/execute.d.ts +57 -0
  168. package/dist/telegram/screens/execute.d.ts.map +1 -0
  169. package/dist/telegram/screens/html.d.ts +36 -0
  170. package/dist/telegram/screens/html.d.ts.map +1 -0
  171. package/dist/telegram/screens/outcome.d.ts +74 -0
  172. package/dist/telegram/screens/outcome.d.ts.map +1 -0
  173. package/dist/telegram/screens/path.d.ts +29 -0
  174. package/dist/telegram/screens/path.d.ts.map +1 -0
  175. package/dist/telegram/screens/reconcile.d.ts +67 -0
  176. package/dist/telegram/screens/reconcile.d.ts.map +1 -0
  177. package/dist/telegram/screens/registry.d.ts +23 -0
  178. package/dist/telegram/screens/registry.d.ts.map +1 -0
  179. package/dist/telegram/screens/render.d.ts +70 -0
  180. package/dist/telegram/screens/render.d.ts.map +1 -0
  181. package/dist/telegram/screens/runtime.d.ts +133 -0
  182. package/dist/telegram/screens/runtime.d.ts.map +1 -0
  183. package/dist/telegram/screens/screen-types.d.ts +130 -0
  184. package/dist/telegram/screens/screen-types.d.ts.map +1 -0
  185. package/dist/telegram/screens/screen.d.ts +138 -0
  186. package/dist/telegram/screens/screen.d.ts.map +1 -0
  187. package/dist/telegram/screens/state.d.ts +115 -0
  188. package/dist/telegram/screens/state.d.ts.map +1 -0
  189. package/dist/telegram/screens/telegram-screens.d.ts +18 -0
  190. package/dist/telegram/screens/telegram-screens.d.ts.map +1 -0
  191. package/dist/telegram/screens/test-chat-telegram.d.ts +47 -0
  192. package/dist/telegram/screens/test-chat-telegram.d.ts.map +1 -0
  193. package/dist/telegram/screens/test-chat.d.ts +66 -0
  194. package/dist/telegram/screens/test-chat.d.ts.map +1 -0
  195. package/dist/telegram/screens/view.d.ts +89 -0
  196. package/dist/telegram/screens/view.d.ts.map +1 -0
  197. package/dist/telegram/send-failure.d.ts +25 -0
  198. package/dist/telegram/send-failure.d.ts.map +1 -1
  199. package/dist/telegram/update-intake.d.ts +82 -0
  200. package/dist/telegram/update-intake.d.ts.map +1 -0
  201. package/dist/telegram/update-store-check.d.ts +22 -0
  202. package/dist/telegram/update-store-check.d.ts.map +1 -0
  203. package/dist/telegram/update-store-postgres.d.ts +33 -0
  204. package/dist/telegram/update-store-postgres.d.ts.map +1 -0
  205. package/dist/telegram/update-store-sqlite.d.ts +26 -0
  206. package/dist/telegram/update-store-sqlite.d.ts.map +1 -0
  207. package/dist/telegram/update-store.d.ts +67 -0
  208. package/dist/telegram/update-store.d.ts.map +1 -0
  209. package/dist/telegram/user.d.ts +51 -0
  210. package/dist/telegram/user.d.ts.map +1 -0
  211. package/dist/telegram/webhook.d.ts +105 -0
  212. package/dist/telegram/webhook.d.ts.map +1 -0
  213. package/dist/tools/cli/args-fields.d.ts +8 -0
  214. package/dist/tools/cli/args-fields.d.ts.map +1 -1
  215. package/dist/tools/cli/args-route.d.ts.map +1 -1
  216. package/dist/tools/cli/args.d.ts.map +1 -1
  217. package/dist/tools/cli/help.d.ts.map +1 -1
  218. package/llms/cli.txt +8 -2
  219. package/llms/observability.txt +15 -2
  220. package/llms/react-keyboard.txt +193 -0
  221. package/llms/server.4.txt +16 -0
  222. package/llms/stitchkit.txt +10 -4
  223. package/llms/telegram-html.txt +35 -0
  224. package/llms/telegram-screens.txt +365 -0
  225. package/llms/telegram.txt +245 -11
  226. package/llms/{upgrading-0.74.0-0.100.0.txt → upgrading-0.74.0-0.101.0.txt} +39 -3
  227. package/llms/upgrading.txt +1 -1
  228. package/llms-full.txt +889 -19
  229. package/llms.txt +12 -7
  230. package/package.json +17 -2
  231. package/dist/index-2k4yrqkc.js +0 -9
  232. package/dist/index-crykmqkr.js +0 -26
  233. package/dist/index-y64k3s0h.js +0 -150
  234. package/dist/index-y91ry9h2.js +0 -4
  235. /package/dist/{index-hffjpmq9.js → index-9jfdm5tg.js} +0 -0
  236. /package/dist/{index-zjjyynm3.js → index-d4pa2bgs.js} +0 -0
  237. /package/dist/{index-rxfy4cq7.js → index-dwfv9a85.js} +0 -0
  238. /package/dist/{index-5jm36zv1.js → index-gfk7nrht.js} +0 -0
  239. /package/dist/{index-b9aefrqd.js → index-n1dqr7gf.js} +0 -0
  240. /package/dist/{index-q3pyb9n0.js → index-sykb5ag7.js} +0 -0
  241. /package/dist/{index-48ffdxgk.js → index-xhzq2qvj.js} +0 -0
  242. /package/dist/{index-kzfs85xp.js → index-zsarb5xp.js} +0 -0
@@ -1,18 +1,18 @@
1
1
  import {
2
- ApplicationIdSchema
3
- } from "./index-3gye9wzb.js";
2
+ createBoundedChannel2
3
+ } from "./index-w0eqdhyd.js";
4
4
  import {
5
5
  assertDrainBound,
6
6
  withinBound
7
- } from "./index-h6eeys1v.js";
7
+ } from "./index-h97tqqp1.js";
8
8
  import {
9
- createBoundedChannel
10
- } from "./index-d9pk3td4.js";
9
+ ApplicationIdSchema2
10
+ } from "./index-w5s3xftz.js";
11
11
 
12
12
  // src/application/latest-sink.ts
13
13
  import { z } from "zod";
14
14
  var SnapshotRevisionSchema = z.number().int().nonnegative();
15
- var ApplicationSnapshotSinkStatusSchema = z.object({
15
+ var ApplicationSnapshotSinkStatusSchema2 = z.object({
16
16
  accepting: z.boolean(),
17
17
  received: z.number().int().nonnegative(),
18
18
  accepted: z.number().int().nonnegative(),
@@ -25,7 +25,7 @@ var ApplicationSnapshotSinkStatusSchema = z.object({
25
25
  lastAcceptedRevision: SnapshotRevisionSchema.optional(),
26
26
  lastDeliveredRevision: SnapshotRevisionSchema.optional()
27
27
  }).strict().readonly();
28
- function createApplicationSnapshotSink(config) {
28
+ function createApplicationSnapshotSink2(config) {
29
29
  let accepting = true;
30
30
  let received = 0;
31
31
  let accepted = 0;
@@ -38,13 +38,13 @@ function createApplicationSnapshotSink(config) {
38
38
  let inFlight;
39
39
  let closePromise;
40
40
  let resolveClose;
41
- const pending = createBoundedChannel({
41
+ const pending = createBoundedChannel2({
42
42
  policy: "latest",
43
43
  maxItems: 1,
44
44
  maxBytes: 1,
45
45
  sizeOf: () => 1
46
46
  });
47
- const getStatus = () => ApplicationSnapshotSinkStatusSchema.parse({
47
+ const getStatus = () => ApplicationSnapshotSinkStatusSchema2.parse({
48
48
  accepting,
49
49
  received,
50
50
  accepted,
@@ -134,10 +134,10 @@ function createApplicationSnapshotSink(config) {
134
134
  import { z as z2 } from "zod";
135
135
  var BoundedOperationalIdSchema = z2.string().min(1).max(64).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/);
136
136
  var NonNegativeIntegerSchema = z2.number().int().nonnegative();
137
- var ActivityIdSchema = BoundedOperationalIdSchema;
138
- var ActivityStageIdSchema = BoundedOperationalIdSchema;
139
- var ActivityStageSnapshotSchema = z2.object({
140
- id: ActivityStageIdSchema,
137
+ var ActivityIdSchema2 = BoundedOperationalIdSchema;
138
+ var ActivityStageIdSchema2 = BoundedOperationalIdSchema;
139
+ var ActivityStageSnapshotSchema2 = z2.object({
140
+ id: ActivityStageIdSchema2,
141
141
  active: NonNegativeIntegerSchema,
142
142
  queued: NonNegativeIntegerSchema,
143
143
  completed: NonNegativeIntegerSchema,
@@ -149,17 +149,17 @@ var ActivityTotalsSchema = z2.object({
149
149
  completed: NonNegativeIntegerSchema,
150
150
  failed: NonNegativeIntegerSchema
151
151
  }).strict().readonly();
152
- var ActivitySnapshotSchema = z2.object({
153
- id: ActivityIdSchema,
152
+ var ActivitySnapshotSchema2 = z2.object({
153
+ id: ActivityIdSchema2,
154
154
  epoch: z2.string().uuid(),
155
155
  revision: NonNegativeIntegerSchema,
156
156
  capturedAt: z2.string().datetime({ offset: true }),
157
157
  changedAt: z2.string().datetime({ offset: true }),
158
- stages: z2.array(ActivityStageSnapshotSchema).min(1).max(64).readonly(),
158
+ stages: z2.array(ActivityStageSnapshotSchema2).min(1).max(64).readonly(),
159
159
  totals: ActivityTotalsSchema
160
160
  }).strict().readonly();
161
- var ActivityLiveStateSchema = z2.enum(["active", "queued"]);
162
- var ActivityTokenBrand = Symbol("stitchkit.application.activity");
161
+ var ActivityLiveStateSchema2 = z2.enum(["active", "queued"]);
162
+ var ActivityTokenBrand2 = Symbol("stitchkit.application.activity");
163
163
  function emptyCounters() {
164
164
  return { active: 0, queued: 0, completed: 0, failed: 0 };
165
165
  }
@@ -171,9 +171,9 @@ function totalsOf(stages) {
171
171
  failed: totals.failed + stage.failed
172
172
  }), emptyCounters());
173
173
  }
174
- function createActivityProjection(config) {
175
- const id = ActivityIdSchema.parse(config.id);
176
- const declaredStages = z2.array(ActivityStageIdSchema).min(1).max(64).parse(config.stages);
174
+ function createActivityProjection2(config) {
175
+ const id = ActivityIdSchema2.parse(config.id);
176
+ const declaredStages = z2.array(ActivityStageIdSchema2).min(1).max(64).parse(config.stages);
177
177
  const uniqueStages = new Set(declaredStages);
178
178
  if (uniqueStages.size !== declaredStages.length) {
179
179
  throw new Error("[stitchkit] createActivityProjection: stage ids must be unique");
@@ -194,7 +194,7 @@ function createActivityProjection(config) {
194
194
  };
195
195
  const getSnapshot = () => {
196
196
  const stages = declaredStages.map((stage) => ({ id: stage, ...countersFor(stage) }));
197
- return ActivitySnapshotSchema.parse({
197
+ return ActivitySnapshotSchema2.parse({
198
198
  id,
199
199
  epoch,
200
200
  revision,
@@ -235,11 +235,11 @@ function createActivityProjection(config) {
235
235
  };
236
236
  return {
237
237
  open(stage, rawState = "active") {
238
- const parsedStage = ActivityStageIdSchema.parse(stage);
239
- const state = ActivityLiveStateSchema.parse(rawState);
238
+ const parsedStage = ActivityStageIdSchema2.parse(stage);
239
+ const state = ActivityLiveStateSchema2.parse(rawState);
240
240
  countersFor(parsedStage)[state] += 1;
241
241
  const token = Object.freeze({
242
- get [ActivityTokenBrand]() {
242
+ get [ActivityTokenBrand2]() {
243
243
  return true;
244
244
  }
245
245
  });
@@ -252,8 +252,8 @@ function createActivityProjection(config) {
252
252
  if (activity.state === "completed" || activity.state === "failed") {
253
253
  throw new Error("[stitchkit] cannot transition a terminal activity");
254
254
  }
255
- const stage = ActivityStageIdSchema.parse(input.stage);
256
- const state = ActivityLiveStateSchema.parse(input.state);
255
+ const stage = ActivityStageIdSchema2.parse(input.stage);
256
+ const state = ActivityLiveStateSchema2.parse(input.state);
257
257
  countersFor(stage);
258
258
  if (activity.stage === stage && activity.state === state)
259
259
  return false;
@@ -268,7 +268,7 @@ function createActivityProjection(config) {
268
268
  fail: (token) => settle(token, "failed"),
269
269
  getSnapshot,
270
270
  subscribe(listener) {
271
- const sink = createApplicationSnapshotSink({
271
+ const sink = createApplicationSnapshotSink2({
272
272
  write: listener,
273
273
  ...config.onSubscriberError && { onSinkError: config.onSubscriberError }
274
274
  });
@@ -286,7 +286,7 @@ function createActivityProjection(config) {
286
286
  import { z as z3 } from "zod";
287
287
  var NonNegativeSafeIntegerSchema = z3.number().int().nonnegative().refine(Number.isSafeInteger, "Expected a safe integer");
288
288
  var PositiveSafeIntegerSchema = NonNegativeSafeIntegerSchema.refine((value) => value > 0, "Expected a positive integer");
289
- var ManagedScheduleOverlapSchema = z3.discriminatedUnion("mode", [
289
+ var ManagedScheduleOverlapSchema2 = z3.discriminatedUnion("mode", [
290
290
  z3.object({ mode: z3.literal("skip") }).readonly(),
291
291
  z3.object({ mode: z3.literal("queue-one") }).readonly(),
292
292
  z3.object({
@@ -294,16 +294,16 @@ var ManagedScheduleOverlapSchema = z3.discriminatedUnion("mode", [
294
294
  maxConcurrent: PositiveSafeIntegerSchema
295
295
  }).readonly()
296
296
  ]);
297
- var ManagedScheduleErrorPolicySchema = z3.enum(["continue", "stop-schedule"]);
298
- var ManagedScheduleDescriptorSchema = z3.object({
299
- id: ApplicationIdSchema,
297
+ var ManagedScheduleErrorPolicySchema2 = z3.enum(["continue", "stop-schedule"]);
298
+ var ManagedScheduleDescriptorSchema2 = z3.object({
299
+ id: ApplicationIdSchema2,
300
300
  everyMs: PositiveSafeIntegerSchema,
301
301
  startAfterMs: NonNegativeSafeIntegerSchema,
302
- overlap: ManagedScheduleOverlapSchema,
303
- errorPolicy: ManagedScheduleErrorPolicySchema
302
+ overlap: ManagedScheduleOverlapSchema2,
303
+ errorPolicy: ManagedScheduleErrorPolicySchema2
304
304
  }).readonly();
305
- var ManagedScheduleStatusSchema = z3.object({
306
- descriptor: ManagedScheduleDescriptorSchema,
305
+ var ManagedScheduleStatusSchema2 = z3.object({
306
+ descriptor: ManagedScheduleDescriptorSchema2,
307
307
  state: z3.enum(["inactive", "scheduled", "running", "draining", "stopped"]),
308
308
  revision: NonNegativeSafeIntegerSchema,
309
309
  capturedAt: z3.string().datetime({ offset: true }),
@@ -413,15 +413,15 @@ async function executeRun(deps, scheduledAt) {
413
413
  function elapsedIntervals(scheduledAt, observedAt, everyMs) {
414
414
  return Math.max(1, Math.floor((observedAt - scheduledAt) / everyMs) + 1);
415
415
  }
416
- function createManagedSchedule(config) {
417
- const descriptor = ManagedScheduleDescriptorSchema.parse({
416
+ function createManagedSchedule2(config) {
417
+ const descriptor = ManagedScheduleDescriptorSchema2.parse({
418
418
  id: config.id,
419
419
  everyMs: config.everyMs,
420
420
  startAfterMs: config.startAfterMs ?? config.everyMs,
421
421
  overlap: config.overlap ?? DEFAULT_OVERLAP,
422
422
  errorPolicy: config.errorPolicy ?? "continue"
423
423
  });
424
- const dependsOn = config.dependsOn?.map((id) => ApplicationIdSchema.parse(id));
424
+ const dependsOn = config.dependsOn?.map((id) => ApplicationIdSchema2.parse(id));
425
425
  const clock = config.clock ?? systemClock;
426
426
  let revision = 0;
427
427
  let accepting = false;
@@ -463,7 +463,7 @@ function createManagedSchedule(config) {
463
463
  const status = () => {
464
464
  const captured = clock.wallNow();
465
465
  const anchor = { monotonicNow: clock.now(), wallNow: captured.getTime() };
466
- return ManagedScheduleStatusSchema.parse({
466
+ return ManagedScheduleStatusSchema2.parse({
467
467
  descriptor,
468
468
  state: scheduleState(activated, stopped, accepting, active.size),
469
469
  revision,
@@ -592,4 +592,4 @@ function createManagedSchedule(config) {
592
592
  };
593
593
  }
594
594
 
595
- export { ApplicationSnapshotSinkStatusSchema, createApplicationSnapshotSink, ActivityIdSchema, ActivityStageIdSchema, ActivityStageSnapshotSchema, ActivitySnapshotSchema, ActivityLiveStateSchema, ActivityTokenBrand, createActivityProjection, ManagedScheduleOverlapSchema, ManagedScheduleErrorPolicySchema, ManagedScheduleDescriptorSchema, ManagedScheduleStatusSchema, createManagedSchedule };
595
+ export { ApplicationSnapshotSinkStatusSchema2, createApplicationSnapshotSink2, ActivityIdSchema2, ActivityStageIdSchema2, ActivityStageSnapshotSchema2, ActivitySnapshotSchema2, ActivityLiveStateSchema2, ActivityTokenBrand2, createActivityProjection2, ManagedScheduleOverlapSchema2, ManagedScheduleErrorPolicySchema2, ManagedScheduleDescriptorSchema2, ManagedScheduleStatusSchema2, createManagedSchedule2 };
@@ -1,10 +1,10 @@
1
1
  import {
2
- ManagedFilePathSchema,
3
- ManagedFileRefSchema
4
- } from "./index-6k1937bx.js";
2
+ ManagedFilePathSchema2,
3
+ ManagedFileRefSchema2
4
+ } from "./index-xqhede6x.js";
5
5
  import {
6
- isWithinDir
7
- } from "./index-sbdmyz75.js";
6
+ isWithinDir2
7
+ } from "./index-5cc6r990.js";
8
8
 
9
9
  // src/files/boundary.ts
10
10
  import { randomUUID } from "node:crypto";
@@ -13,7 +13,7 @@ import { link, mkdir, open, realpath, rename, stat, unlink } from "node:fs/promi
13
13
  import { basename, dirname, resolve } from "node:path";
14
14
 
15
15
  // src/files/file-io.ts
16
- var ManagedFileInspectionSchema = ManagedFileRefSchema.pick({
16
+ var ManagedFileInspectionSchema = ManagedFileRefSchema2.pick({
17
17
  mediaType: true,
18
18
  name: true
19
19
  });
@@ -50,20 +50,20 @@ async function inspectFile(inspector, input, timeoutMs, outerSignal) {
50
50
  } catch (error) {
51
51
  if (outerSignal?.aborted)
52
52
  throw abortReason(outerSignal);
53
- throw new ManagedFileError("FILE_INSPECTION_REJECTED", "managed file rejected by inspection", { cause: error });
53
+ throw new ManagedFileError2("FILE_INSPECTION_REJECTED", "managed file rejected by inspection", { cause: error });
54
54
  }
55
55
  }
56
56
  function inspectedRef(path, size, inspection, fallback = {}) {
57
57
  const mediaType = inspection.mediaType ?? fallback.mediaType;
58
58
  const name = inspection.name ?? fallback.name;
59
- const parsed = ManagedFileRefSchema.safeParse({
59
+ const parsed = ManagedFileRefSchema2.safeParse({
60
60
  path,
61
61
  size,
62
62
  ...mediaType ? { mediaType } : {},
63
63
  ...name ? { name } : {}
64
64
  });
65
65
  if (!parsed.success) {
66
- throw new ManagedFileError("FILE_INSPECTION_REJECTED", "managed file rejected by inspection", { cause: parsed.error });
66
+ throw new ManagedFileError2("FILE_INSPECTION_REJECTED", "managed file rejected by inspection", { cause: parsed.error });
67
67
  }
68
68
  return parsed.data;
69
69
  }
@@ -74,7 +74,7 @@ async function readHandle(handle, maxBytes, signal) {
74
74
  signal?.throwIfAborted();
75
75
  const capacity = Math.min(64 * 1024, maxBytes + 1 - total);
76
76
  if (capacity <= 0) {
77
- throw new ManagedFileError("FILE_TOO_LARGE", `file exceeds the ${maxBytes}-byte cap`);
77
+ throw new ManagedFileError2("FILE_TOO_LARGE", `file exceeds the ${maxBytes}-byte cap`);
78
78
  }
79
79
  const chunk = new Uint8Array(capacity);
80
80
  const { bytesRead } = await handle.read(chunk, 0, capacity);
@@ -82,7 +82,7 @@ async function readHandle(handle, maxBytes, signal) {
82
82
  break;
83
83
  total += bytesRead;
84
84
  if (total > maxBytes) {
85
- throw new ManagedFileError("FILE_TOO_LARGE", `file exceeds the ${maxBytes}-byte cap`);
85
+ throw new ManagedFileError2("FILE_TOO_LARGE", `file exceeds the ${maxBytes}-byte cap`);
86
86
  }
87
87
  chunks.push(chunk.subarray(0, bytesRead));
88
88
  }
@@ -111,7 +111,7 @@ async function writeSource(handle, source, maxBytes, inspectionBytes, signal) {
111
111
  signal?.throwIfAborted();
112
112
  size += chunk.byteLength;
113
113
  if (size > maxBytes) {
114
- throw new ManagedFileError("FILE_TOO_LARGE", `file exceeds the ${maxBytes}-byte cap`);
114
+ throw new ManagedFileError2("FILE_TOO_LARGE", `file exceeds the ${maxBytes}-byte cap`);
115
115
  }
116
116
  if (prefixSize < inspectionBytes) {
117
117
  const kept = chunk.subarray(0, inspectionBytes - prefixSize);
@@ -159,7 +159,7 @@ var noFollow = () => {
159
159
  return nofollowFlag;
160
160
  };
161
161
 
162
- class ManagedFileError extends Error {
162
+ class ManagedFileError2 extends Error {
163
163
  code;
164
164
  constructor(code, message, options) {
165
165
  super(message, options);
@@ -175,9 +175,9 @@ function positiveLimit(value, fallback, name) {
175
175
  return resolved;
176
176
  }
177
177
  function filePath(path) {
178
- const parsed = ManagedFilePathSchema.safeParse(path);
178
+ const parsed = ManagedFilePathSchema2.safeParse(path);
179
179
  if (!parsed.success) {
180
- throw new ManagedFileError("FILE_INVALID_PATH", "invalid managed-file path");
180
+ throw new ManagedFileError2("FILE_INVALID_PATH", "invalid managed-file path");
181
181
  }
182
182
  return parsed.data;
183
183
  }
@@ -187,9 +187,9 @@ function errorCode(error) {
187
187
  return typeof error.code === "string" ? error.code : undefined;
188
188
  }
189
189
  function ioError(message, error) {
190
- if (error instanceof ManagedFileError)
190
+ if (error instanceof ManagedFileError2)
191
191
  return error;
192
- return new ManagedFileError("FILE_IO_ERROR", message, { cause: error });
192
+ return new ManagedFileError2("FILE_IO_ERROR", message, { cause: error });
193
193
  }
194
194
  async function realpathOrNull(path, message) {
195
195
  try {
@@ -206,20 +206,20 @@ async function bindRoot(config) {
206
206
  if (canonical === null && config.createRoot) {
207
207
  const parent = await realpathOrNull(dirname(requested), "failed to resolve managed-file root parent");
208
208
  if (parent === null) {
209
- throw new ManagedFileError("FILE_NOT_FOUND", "managed-file root parent must exist");
209
+ throw new ManagedFileError2("FILE_NOT_FOUND", "managed-file root parent must exist");
210
210
  }
211
211
  const parentInfo = await stat(parent).catch((error) => {
212
212
  throw ioError("failed to inspect managed-file root parent", error);
213
213
  });
214
214
  if (!parentInfo.isDirectory()) {
215
- throw new ManagedFileError("FILE_NOT_REGULAR", "managed-file root parent must be a directory");
215
+ throw new ManagedFileError2("FILE_NOT_REGULAR", "managed-file root parent must be a directory");
216
216
  }
217
217
  try {
218
218
  await mkdir(requested, { mode: 448 });
219
219
  } catch (error) {
220
220
  if (errorCode(error) !== "EEXIST") {
221
221
  if (errorCode(error) === "ENOENT") {
222
- throw new ManagedFileError("FILE_NOT_FOUND", "managed-file root parent must exist");
222
+ throw new ManagedFileError2("FILE_NOT_FOUND", "managed-file root parent must exist");
223
223
  }
224
224
  throw ioError("failed to create managed-file root", error);
225
225
  }
@@ -227,33 +227,33 @@ async function bindRoot(config) {
227
227
  canonical = await realpathOrNull(requested, "failed to resolve managed-file root");
228
228
  }
229
229
  if (canonical === null) {
230
- throw new ManagedFileError("FILE_NOT_FOUND", "managed-file root must exist");
230
+ throw new ManagedFileError2("FILE_NOT_FOUND", "managed-file root must exist");
231
231
  }
232
232
  const info = await stat(canonical).catch((error) => {
233
233
  throw ioError("failed to inspect managed-file root", error);
234
234
  });
235
235
  if (!info.isDirectory()) {
236
- throw new ManagedFileError("FILE_NOT_REGULAR", "managed-file root must be a directory");
236
+ throw new ManagedFileError2("FILE_NOT_REGULAR", "managed-file root must be a directory");
237
237
  }
238
238
  return canonical;
239
239
  }
240
240
  async function existingParent(root, target) {
241
241
  const parent = await realpathOrNull(dirname(target), "failed to resolve managed-file parent directory");
242
242
  if (parent === null) {
243
- throw new ManagedFileError("FILE_NOT_FOUND", "managed-file parent directory not found");
243
+ throw new ManagedFileError2("FILE_NOT_FOUND", "managed-file parent directory not found");
244
244
  }
245
- if (!isWithinDir(root, parent)) {
246
- throw new ManagedFileError("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
245
+ if (!isWithinDir2(root, parent)) {
246
+ throw new ManagedFileError2("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
247
247
  }
248
248
  const info = await stat(parent).catch((error) => {
249
249
  throw ioError("failed to inspect managed-file parent directory", error);
250
250
  });
251
251
  if (!info.isDirectory()) {
252
- throw new ManagedFileError("FILE_NOT_REGULAR", "managed-file parent is not a directory");
252
+ throw new ManagedFileError2("FILE_NOT_REGULAR", "managed-file parent is not a directory");
253
253
  }
254
254
  return parent;
255
255
  }
256
- async function createManagedFileBoundary(config) {
256
+ async function createManagedFileBoundary2(config) {
257
257
  const root = await bindRoot(config);
258
258
  const maxReadBytes = positiveLimit(config.maxReadBytes, DEFAULT_MAX_BYTES, "maxReadBytes");
259
259
  const maxWriteBytes = positiveLimit(config.maxWriteBytes, DEFAULT_MAX_BYTES, "maxWriteBytes");
@@ -262,8 +262,8 @@ async function createManagedFileBoundary(config) {
262
262
  const targetFor = (path) => {
263
263
  const relative = filePath(path);
264
264
  const target = resolve(root, ...relative.split("/"));
265
- if (!isWithinDir(root, target)) {
266
- throw new ManagedFileError("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
265
+ if (!isWithinDir2(root, target)) {
266
+ throw new ManagedFileError2("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
267
267
  }
268
268
  return { path: relative, target };
269
269
  };
@@ -273,10 +273,10 @@ async function createManagedFileBoundary(config) {
273
273
  options.signal?.throwIfAborted();
274
274
  const realTarget = await realpathOrNull(resolved.target, "failed to resolve managed file");
275
275
  if (realTarget === null) {
276
- throw new ManagedFileError("FILE_NOT_FOUND", "managed file not found");
276
+ throw new ManagedFileError2("FILE_NOT_FOUND", "managed file not found");
277
277
  }
278
- if (!isWithinDir(root, realTarget)) {
279
- throw new ManagedFileError("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
278
+ if (!isWithinDir2(root, realTarget)) {
279
+ throw new ManagedFileError2("FILE_OUTSIDE_ROOT", "managed-file path escapes its boundary");
280
280
  }
281
281
  const maxBytes = positiveLimit(options.maxBytes, maxReadBytes, "maxBytes");
282
282
  let handle;
@@ -284,7 +284,7 @@ async function createManagedFileBoundary(config) {
284
284
  handle = await open(realTarget, constants.O_RDONLY | noFollow());
285
285
  const info = await handle.stat();
286
286
  if (!info.isFile()) {
287
- throw new ManagedFileError("FILE_NOT_REGULAR", "managed path is not a regular file");
287
+ throw new ManagedFileError2("FILE_NOT_REGULAR", "managed path is not a regular file");
288
288
  }
289
289
  const bytes = await readHandle(handle, maxBytes, options.signal);
290
290
  const inspection = await inspectFile(config.inspect, {
@@ -299,7 +299,7 @@ async function createManagedFileBoundary(config) {
299
299
  if (options.signal?.aborted && error === options.signal.reason)
300
300
  throw error;
301
301
  if (errorCode(error) === "ENOENT") {
302
- throw new ManagedFileError("FILE_NOT_FOUND", "managed file not found");
302
+ throw new ManagedFileError2("FILE_NOT_FOUND", "managed file not found");
303
303
  }
304
304
  throw ioError("failed to read managed file", error);
305
305
  } finally {
@@ -340,7 +340,7 @@ async function createManagedFileBoundary(config) {
340
340
  committed = true;
341
341
  } catch (error) {
342
342
  if (errorCode(error) === "EEXIST") {
343
- throw new ManagedFileError("FILE_EXISTS", "managed file already exists");
343
+ throw new ManagedFileError2("FILE_EXISTS", "managed file already exists");
344
344
  }
345
345
  throw error;
346
346
  }
@@ -368,4 +368,4 @@ async function createManagedFileBoundary(config) {
368
368
  };
369
369
  }
370
370
 
371
- export { ManagedFileError, createManagedFileBoundary };
371
+ export { ManagedFileError2, createManagedFileBoundary2 };
@@ -1,11 +1,11 @@
1
1
  // src/internal/channel.ts
2
2
  import { z } from "zod";
3
3
  var PositiveSafeIntegerSchema = z.number().int().positive().safe();
4
- var BoundedChannelPolicySchema = z.enum(["ordered", "latest"]);
5
- var BoundedChannelStateSchema = z.enum(["open", "draining", "closed", "failed"]);
6
- var BoundedChannelSnapshotSchema = z.object({
7
- state: BoundedChannelStateSchema,
8
- policy: BoundedChannelPolicySchema,
4
+ var BoundedChannelPolicySchema2 = z.enum(["ordered", "latest"]);
5
+ var BoundedChannelStateSchema2 = z.enum(["open", "draining", "closed", "failed"]);
6
+ var BoundedChannelSnapshotSchema2 = z.object({
7
+ state: BoundedChannelStateSchema2,
8
+ policy: BoundedChannelPolicySchema2,
9
9
  queuedItems: z.number().int().nonnegative(),
10
10
  queuedBytes: z.number().int().nonnegative(),
11
11
  waitingReader: z.boolean(),
@@ -17,14 +17,14 @@ var BoundedChannelSnapshotSchema = z.object({
17
17
  discarded: z.number().int().nonnegative()
18
18
  }).strict().readonly();
19
19
 
20
- class BoundedChannelReaderError extends Error {
20
+ class BoundedChannelReaderError2 extends Error {
21
21
  constructor() {
22
22
  super("A bounded channel permits only one pending next() call");
23
23
  this.name = "BoundedChannelReaderError";
24
24
  }
25
25
  }
26
- function createBoundedChannel(config) {
27
- const policy = BoundedChannelPolicySchema.parse(config.policy);
26
+ function createBoundedChannel2(config) {
27
+ const policy = BoundedChannelPolicySchema2.parse(config.policy);
28
28
  const maxItems = PositiveSafeIntegerSchema.parse(config.maxItems);
29
29
  const maxBytes = PositiveSafeIntegerSchema.parse(config.maxBytes);
30
30
  const queue = [];
@@ -42,7 +42,7 @@ function createBoundedChannel(config) {
42
42
  const removeAbortListener = () => {
43
43
  config.signal?.removeEventListener("abort", abortChannel);
44
44
  };
45
- const snapshot = () => BoundedChannelSnapshotSchema.parse({
45
+ const snapshot = () => BoundedChannelSnapshotSchema2.parse({
46
46
  state,
47
47
  policy,
48
48
  queuedItems: queue.length,
@@ -154,7 +154,7 @@ function createBoundedChannel(config) {
154
154
  return Promise.resolve({ done: true, value: undefined });
155
155
  }
156
156
  if (waiting)
157
- return Promise.reject(new BoundedChannelReaderError);
157
+ return Promise.reject(new BoundedChannelReaderError2);
158
158
  return new Promise((resolve, reject) => {
159
159
  waiting = { resolve, reject };
160
160
  });
@@ -189,7 +189,7 @@ function createBoundedChannel(config) {
189
189
  config.signal?.addEventListener("abort", abortChannel, { once: true });
190
190
  return channel;
191
191
  }
192
- var CreditWindowSnapshotSchema = z.object({
192
+ var CreditWindowSnapshotSchema2 = z.object({
193
193
  state: z.enum(["open", "closed"]),
194
194
  capacityBytes: PositiveSafeIntegerSchema,
195
195
  availableBytes: z.number().int().nonnegative(),
@@ -199,7 +199,7 @@ var CreditWindowSnapshotSchema = z.object({
199
199
  replenishedBytes: z.number().int().nonnegative(),
200
200
  waiting: z.number().int().nonnegative()
201
201
  }).strict().readonly();
202
- function createCreditWindow(config) {
202
+ function createCreditWindow2(config) {
203
203
  const capacityBytes = PositiveSafeIntegerSchema.parse(config.capacityBytes);
204
204
  let availableBytes = capacityBytes;
205
205
  let state = "open";
@@ -207,7 +207,7 @@ function createCreditWindow(config) {
207
207
  let refused = 0;
208
208
  let replenishedBytes = 0;
209
209
  const waiters = new Set;
210
- const snapshot = () => CreditWindowSnapshotSchema.parse({
210
+ const snapshot = () => CreditWindowSnapshotSchema2.parse({
211
211
  state,
212
212
  capacityBytes,
213
213
  availableBytes,
@@ -323,4 +323,4 @@ function createCreditWindow(config) {
323
323
  };
324
324
  }
325
325
 
326
- export { BoundedChannelPolicySchema, BoundedChannelStateSchema, BoundedChannelSnapshotSchema, BoundedChannelReaderError, createBoundedChannel, CreditWindowSnapshotSchema, createCreditWindow };
326
+ export { BoundedChannelPolicySchema2, BoundedChannelStateSchema2, BoundedChannelSnapshotSchema2, BoundedChannelReaderError2, createBoundedChannel2, CreditWindowSnapshotSchema2, createCreditWindow2 };