iterate 0.3.0 → 0.4.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 (241) hide show
  1. package/README.md +164 -82
  2. package/dist/{next/api.d.ts → api.d.ts} +197 -33
  3. package/dist/{next/app-server.d.ts → app-server.d.ts} +7 -0
  4. package/dist/{next/app-server.mjs → app-server.mjs} +17 -15
  5. package/dist/app-server.mjs.map +1 -0
  6. package/dist/{next/app-session.mjs → app-session.mjs} +12 -15
  7. package/dist/app-session.mjs.map +1 -0
  8. package/dist/{next/app.mjs → app.mjs} +53 -14
  9. package/dist/app.mjs.map +1 -0
  10. package/dist/{next/client → client}/live-state.d.ts +11 -11
  11. package/dist/client/oauth.d.ts +17 -0
  12. package/dist/{next/client → client}/react.d.ts +10 -42
  13. package/dist/{next/client → client}/socket.d.ts +1 -0
  14. package/dist/client.mjs +156 -4
  15. package/dist/client.mjs.map +1 -0
  16. package/dist/{next/expression.d.ts → expression.d.ts} +11 -69
  17. package/dist/{next/expression.mjs → expression.mjs} +11 -109
  18. package/dist/expression.mjs.map +1 -0
  19. package/dist/lib-BWr-5mFO.mjs +36 -0
  20. package/dist/lib-BWr-5mFO.mjs.map +1 -0
  21. package/dist/{next/lib.d.ts → lib.d.ts} +16 -2
  22. package/dist/{next/lib.mjs → lib.mjs} +32 -3
  23. package/dist/lib.mjs.map +1 -0
  24. package/dist/node.d.ts +15 -3
  25. package/dist/node.mjs +36 -174
  26. package/dist/node.mjs.map +1 -1
  27. package/dist/{next/oauth-scopes.mjs → oauth-scopes.mjs} +1 -1
  28. package/dist/oauth-scopes.mjs.map +1 -0
  29. package/dist/{next/oauth.mjs → oauth.mjs} +14 -2
  30. package/dist/oauth.mjs.map +1 -0
  31. package/dist/principal.d.ts +8 -0
  32. package/dist/principal.mjs +8 -0
  33. package/dist/principal.mjs.map +1 -0
  34. package/dist/project-ingress.d.ts +58 -0
  35. package/dist/project-ingress.mjs +104 -0
  36. package/dist/project-ingress.mjs.map +1 -0
  37. package/dist/{next/react.mjs → react.mjs} +12 -12
  38. package/dist/react.mjs.map +1 -0
  39. package/dist/sdk/auth.d.ts +25 -0
  40. package/dist/sdk/index.d.ts +155 -0
  41. package/dist/sdk/record-pipelined-steps.d.ts +19 -0
  42. package/dist/sdk.mjs +245 -2
  43. package/dist/sdk.mjs.map +1 -0
  44. package/dist/{next/stream → stream}/processor.d.ts +28 -23
  45. package/dist/{next/stream → stream}/processor.mjs +48 -25
  46. package/dist/stream/processor.mjs.map +1 -0
  47. package/dist/{next/stream → stream}/run.d.ts +9 -6
  48. package/dist/{next/stream → stream}/run.mjs +13 -8
  49. package/dist/stream/run.mjs.map +1 -0
  50. package/dist/stream/test-support.d.ts +45 -0
  51. package/dist/stream/test-support.mjs +196 -0
  52. package/dist/stream/test-support.mjs.map +1 -0
  53. package/package.json +65 -219
  54. package/THIRD_PARTY_NOTICES.md +0 -55
  55. package/bin/iterate.js +0 -94
  56. package/dist/api-url-B6404M82.mjs +0 -17
  57. package/dist/api-url-B6404M82.mjs.map +0 -1
  58. package/dist/app-ref-BipL0feU.mjs +0 -35
  59. package/dist/app-ref-BipL0feU.mjs.map +0 -1
  60. package/dist/app-ref-C1CrgXqX.mjs +0 -7
  61. package/dist/app-ref-C1CrgXqX.mjs.map +0 -1
  62. package/dist/app-ref-DYai_om1.mjs +0 -7
  63. package/dist/app-ref-DYai_om1.mjs.map +0 -1
  64. package/dist/cli-D0c-pDL_.mjs +0 -1010
  65. package/dist/cli-D0c-pDL_.mjs.map +0 -1
  66. package/dist/client.d.ts +0 -3
  67. package/dist/cloudflare-BTm90gQ4.mjs +0 -951
  68. package/dist/cloudflare-BTm90gQ4.mjs.map +0 -1
  69. package/dist/contract-s4FW4eES.mjs +0 -309
  70. package/dist/contract-s4FW4eES.mjs.map +0 -1
  71. package/dist/document-review/index.d.ts +0 -5
  72. package/dist/document-review/types.d.ts +0 -107
  73. package/dist/document-review.mjs +0 -7015
  74. package/dist/document-review.mjs.map +0 -1
  75. package/dist/durable-object-processor-durability-CNsTjAJS.mjs +0 -205
  76. package/dist/durable-object-processor-durability-CNsTjAJS.mjs.map +0 -1
  77. package/dist/idempotency-DleloJNt.mjs +0 -28
  78. package/dist/idempotency-DleloJNt.mjs.map +0 -1
  79. package/dist/index.d.mts +0 -5
  80. package/dist/index.mjs +0 -8
  81. package/dist/index.mjs.map +0 -1
  82. package/dist/itx/api-url.d.ts +0 -6
  83. package/dist/itx/itx-node-client.d.ts +0 -65
  84. package/dist/itx/itx-session.d.ts +0 -215
  85. package/dist/itx/owned-rpc-session.d.ts +0 -14
  86. package/dist/itx/query-client.d.ts +0 -10
  87. package/dist/itx-api.generated.d.ts +0 -6195
  88. package/dist/itx-session-sjud8GiT.mjs +0 -534
  89. package/dist/itx-session-sjud8GiT.mjs.map +0 -1
  90. package/dist/live-state-BJNqOwFw.mjs +0 -299
  91. package/dist/live-state-BJNqOwFw.mjs.map +0 -1
  92. package/dist/next/app-server.mjs.map +0 -1
  93. package/dist/next/app-session.mjs.map +0 -1
  94. package/dist/next/app.mjs.map +0 -1
  95. package/dist/next/client/oauth.d.ts +0 -12
  96. package/dist/next/client.mjs +0 -156
  97. package/dist/next/client.mjs.map +0 -1
  98. package/dist/next/expression.mjs.map +0 -1
  99. package/dist/next/lib.mjs.map +0 -1
  100. package/dist/next/oauth-scopes.mjs.map +0 -1
  101. package/dist/next/oauth.mjs.map +0 -1
  102. package/dist/next/principal.d.ts +0 -64
  103. package/dist/next/principal.mjs +0 -98
  104. package/dist/next/principal.mjs.map +0 -1
  105. package/dist/next/project-ingress.d.ts +0 -37
  106. package/dist/next/project-ingress.mjs +0 -75
  107. package/dist/next/project-ingress.mjs.map +0 -1
  108. package/dist/next/react.mjs.map +0 -1
  109. package/dist/next/sdk/auth.d.ts +0 -5
  110. package/dist/next/sdk/index.d.ts +0 -112
  111. package/dist/next/sdk.mjs +0 -139
  112. package/dist/next/sdk.mjs.map +0 -1
  113. package/dist/next/stream/processor.mjs.map +0 -1
  114. package/dist/next/stream/run.mjs.map +0 -1
  115. package/dist/next-node.d.ts +0 -15
  116. package/dist/next-node.mjs +0 -51
  117. package/dist/next-node.mjs.map +0 -1
  118. package/dist/processor-host-capabilities-BMFH3KTM.mjs +0 -56
  119. package/dist/processor-host-capabilities-BMFH3KTM.mjs.map +0 -1
  120. package/dist/processors/cloudflare.d.ts +0 -3
  121. package/dist/processors/durable-object-processor-durability.d.ts +0 -79
  122. package/dist/processors/event-consumption-metrics.d.ts +0 -82
  123. package/dist/processors/idempotency.d.ts +0 -13
  124. package/dist/processors/index.d.ts +0 -12
  125. package/dist/processors/processor-contracts.d.ts +0 -342
  126. package/dist/processors/processor-facet.d.ts +0 -186
  127. package/dist/processors/processor-host-capabilities.d.ts +0 -60
  128. package/dist/processors/prompt-sections.d.ts +0 -17
  129. package/dist/processors/rpc-types.d.ts +0 -515
  130. package/dist/processors/schemas.d.ts +0 -102
  131. package/dist/processors/stream-handle.d.ts +0 -45
  132. package/dist/processors/stream-processor-keepalive.d.ts +0 -95
  133. package/dist/processors/stream-processor-registry.d.ts +0 -233
  134. package/dist/processors/stream-processor-runner.d.ts +0 -289
  135. package/dist/processors/stream-processor.d.ts +0 -339
  136. package/dist/processors/stream-runtime-metrics.d.ts +0 -107
  137. package/dist/processors/testing.d.ts +0 -302
  138. package/dist/processors-BoNyeBfQ.mjs +0 -10
  139. package/dist/processors-BoNyeBfQ.mjs.map +0 -1
  140. package/dist/processors-cloudflare.mjs +0 -3
  141. package/dist/processors-testing.mjs +0 -435
  142. package/dist/processors-testing.mjs.map +0 -1
  143. package/dist/processors.mjs +0 -52
  144. package/dist/processors.mjs.map +0 -1
  145. package/dist/protocol-DnK_f2m6.mjs +0 -251
  146. package/dist/protocol-DnK_f2m6.mjs.map +0 -1
  147. package/dist/sdk/capnweb/index.d.ts +0 -2
  148. package/dist/sdk/capnweb/live-state/compact.d.ts +0 -5
  149. package/dist/sdk/capnweb/live-state/diff.d.ts +0 -41
  150. package/dist/sdk/capnweb/live-state/engine.d.ts +0 -44
  151. package/dist/sdk/capnweb/live-state/index.d.ts +0 -41
  152. package/dist/sdk/capnweb/live-state/protocol.d.ts +0 -87
  153. package/dist/sdk/capnweb/live-state/retain.d.ts +0 -23
  154. package/dist/sdk/capnweb/live-state/store.d.ts +0 -20
  155. package/dist/sdk/capnweb/live-state/types.d.ts +0 -11
  156. package/dist/sdk/capnweb/react.d.ts +0 -45
  157. package/dist/sdk/capnweb/react.mjs +0 -316
  158. package/dist/sdk/capnweb/react.mjs.map +0 -1
  159. package/dist/sdk/capnweb.mjs +0 -4
  160. package/dist/sdk/itx/react.d.ts +0 -191
  161. package/dist/sdk/itx/react.mjs +0 -383
  162. package/dist/sdk/itx/react.mjs.map +0 -1
  163. package/dist/sdk-DMB-IM11.mjs +0 -933
  164. package/dist/sdk-DMB-IM11.mjs.map +0 -1
  165. package/dist/sdk.d.ts +0 -339
  166. package/dist/serve-itx.d.ts +0 -46
  167. package/dist/starter-apps/flake-dashboard/app-ref.d.ts +0 -31
  168. package/dist/starter-apps/flake-dashboard/configured-worker.mjs +0 -1055
  169. package/dist/starter-apps/flake-dashboard/configured-worker.mjs.map +0 -1
  170. package/dist/starter-apps/flake-dashboard/contract.d.ts +0 -4839
  171. package/dist/starter-apps/flake-dashboard/contract.mjs +0 -2
  172. package/dist/starter-apps/flake-dashboard/index.d.ts +0 -17
  173. package/dist/starter-apps/flake-dashboard/index.mjs +0 -56
  174. package/dist/starter-apps/flake-dashboard/index.mjs.map +0 -1
  175. package/dist/starter-apps/flake-dashboard/worker.d.ts +0 -4607
  176. package/dist/starter-apps/github-ai-linter/ai-linter.d.ts +0 -8914
  177. package/dist/starter-apps/github-ai-linter/configured-worker.mjs +0 -17987
  178. package/dist/starter-apps/github-ai-linter/configured-worker.mjs.map +0 -1
  179. package/dist/starter-apps/github-ai-linter/contract.d.ts +0 -9193
  180. package/dist/starter-apps/github-ai-linter/index.d.ts +0 -10
  181. package/dist/starter-apps/github-ai-linter/index.mjs +0 -36
  182. package/dist/starter-apps/github-ai-linter/index.mjs.map +0 -1
  183. package/dist/starter-apps/github-ai-linter/prompt.d.ts +0 -13
  184. package/dist/starter-apps/github-ai-linter/review-bot.d.ts +0 -808
  185. package/dist/starter-apps/github-ai-linter/rules.d.ts +0 -34
  186. package/dist/starter-apps/github-ai-linter/worker-ref.d.ts +0 -19
  187. package/dist/starter-apps/github-ai-linter/worker.d.ts +0 -19
  188. package/dist/starter-apps/github-ai-linter/worker.mjs +0 -947
  189. package/dist/starter-apps/github-ai-linter/worker.mjs.map +0 -1
  190. package/dist/starter-apps/guestbook/app-ref.d.ts +0 -27
  191. package/dist/starter-apps/guestbook/client.d.ts +0 -7
  192. package/dist/starter-apps/guestbook/client.mjs +0 -59
  193. package/dist/starter-apps/guestbook/configured-worker.mjs +0 -205
  194. package/dist/starter-apps/guestbook/configured-worker.mjs.map +0 -1
  195. package/dist/starter-apps/guestbook/index.d.ts +0 -9
  196. package/dist/starter-apps/guestbook/index.mjs +0 -31
  197. package/dist/starter-apps/guestbook/index.mjs.map +0 -1
  198. package/dist/starter-apps/guestbook/processor.d.ts +0 -2267
  199. package/dist/starter-apps/guestbook/worker.d.ts +0 -26
  200. package/dist/starter-apps/guestbook/worker.mjs +0 -191
  201. package/dist/starter-apps/guestbook/worker.mjs.map +0 -1
  202. package/dist/starter-apps/media/configured-worker.mjs +0 -577
  203. package/dist/starter-apps/media/configured-worker.mjs.map +0 -1
  204. package/dist/starter-apps/media/index.mjs +0 -36
  205. package/dist/starter-apps/media/index.mjs.map +0 -1
  206. package/dist/starter-apps/media/ref.mjs +0 -20
  207. package/dist/starter-apps/media/ref.mjs.map +0 -1
  208. package/dist/starter-apps/media/worker.mjs +0 -579
  209. package/dist/starter-apps/media/worker.mjs.map +0 -1
  210. package/dist/starter-apps/notes/configured-worker.mjs +0 -6134
  211. package/dist/starter-apps/notes/configured-worker.mjs.map +0 -1
  212. package/dist/starter-apps/notes/index.mjs +0 -23
  213. package/dist/starter-apps/notes/index.mjs.map +0 -1
  214. package/dist/starter-apps/notes/ref.mjs +0 -21
  215. package/dist/starter-apps/notes/ref.mjs.map +0 -1
  216. package/dist/starter-apps/notes/worker.mjs +0 -427
  217. package/dist/starter-apps/notes/worker.mjs.map +0 -1
  218. package/dist/starter-apps/todo/client.mjs +0 -59
  219. package/dist/starter-apps/todo/configured-worker.mjs +0 -2864
  220. package/dist/starter-apps/todo/configured-worker.mjs.map +0 -1
  221. package/dist/starter-apps/todo/index.d.ts +0 -8
  222. package/dist/starter-apps/todo/index.mjs +0 -29
  223. package/dist/starter-apps/todo/index.mjs.map +0 -1
  224. package/dist/stream-processor-keepalive-DAQTP6m3.mjs +0 -2082
  225. package/dist/stream-processor-keepalive-DAQTP6m3.mjs.map +0 -1
  226. package/dist/usingCtx-mZx5nsAW.mjs +0 -11800
  227. package/dist/usingCtx-mZx5nsAW.mjs.map +0 -1
  228. package/dist/worker-ref-DZxPDmb_.mjs +0 -390
  229. package/dist/worker-ref-DZxPDmb_.mjs.map +0 -1
  230. package/dist/worker.d.mts +0 -33
  231. package/dist/worker.mjs +0 -18
  232. package/dist/worker.mjs.map +0 -1
  233. package/menubar/Iterate.entitlements +0 -12
  234. package/menubar/Iterate.swift +0 -914
  235. package/menubar/IterateIcon.swift +0 -145
  236. package/menubar/README.md +0 -28
  237. package/menubar/build-menubar-app.sh +0 -59
  238. /package/dist/{next/api.mjs → api.mjs} +0 -0
  239. /package/dist/{next/app-session.d.ts → app-session.d.ts} +0 -0
  240. /package/dist/{next/app.d.ts → app.d.ts} +0 -0
  241. /package/dist/{next/oauth-scopes.d.ts → oauth-scopes.d.ts} +0 -0
@@ -1,342 +0,0 @@
1
- import { z } from "zod";
2
- import type { StreamEvent, StreamEventInput } from "./schemas.ts";
3
- /**
4
- * Merge one processor configuration patch into its current configuration.
5
- *
6
- * Configuration patches recurse only through plain JSON objects. Arrays,
7
- * scalars, and `null` replace the previous value wholesale; omitted keys are
8
- * retained. Processors validate the merged result with their own complete
9
- * configuration schema before storing it in reduced state.
10
- */
11
- export declare function mergeProcessorConfig(base: unknown, patch: unknown): unknown;
12
- /**
13
- * One documented example payload for an owned event, rendered on the public
14
- * event docs site (events.iterate.com). The payload must parse against the
15
- * event's `payloadSchema` — enforced by the event-docs unit tests rather than
16
- * at module load, so a bad example fails CI instead of bricking a worker boot.
17
- */
18
- export type EventExample = {
19
- /** What this example shows, e.g. "Durable delivery to another stream". */
20
- description: string;
21
- /** The example payload, in the payload schema's input shape. */
22
- payload: unknown;
23
- };
24
- /** One owned event: its payload schema plus optional human description and examples. */
25
- export type EventDefinition<PayloadOutput = unknown, PayloadInput = PayloadOutput> = {
26
- description?: string;
27
- payloadSchema: z.ZodType<PayloadOutput, PayloadInput>;
28
- /**
29
- * FORCIBLY ephemeral: every append and parse built from this definition
30
- * defaults the envelope's `ephemeral` flag to `true` and REJECTS an explicit
31
- * `ephemeral: false`. For events that must never become durable stream
32
- * facts (streaming chunks) — declaring it here makes forgetting the flag at
33
- * an append site impossible instead of a silent storage leak.
34
- */
35
- ephemeral?: true;
36
- examples?: readonly EventExample[];
37
- };
38
- /** A contract's owned events, keyed by the durable event type string. */
39
- export type EventCatalog = Record<string, EventDefinition<unknown, unknown>>;
40
- /** The string-keyed event definitions of a catalog object (index signatures excluded). */
41
- type EventCatalogFromObject<Value> = {
42
- [Key in keyof Value as string extends Key ? never : number extends Key ? never : Value[Key] extends EventDefinition ? Key : never]: Value[Key];
43
- };
44
- /**
45
- * A `processorDeps` entry may be a full contract (`{ events: ... }`) or a
46
- * standalone event catalog, so a processor can depend on another processor's
47
- * contract or on a small shared catalog.
48
- */
49
- type ContractEventCatalog<ContractOrCatalog> = ContractOrCatalog extends {
50
- events: infer Events;
51
- } ? EventCatalogFromObject<Events> : EventCatalogFromObject<ContractOrCatalog>;
52
- /** All event type strings resolvable from local `events` plus `processorDeps`. */
53
- type ResolvedEventType<Events extends EventCatalog, ProcessorDeps extends readonly unknown[]> = Extract<keyof EventCatalogFromObject<Events> | EventTypeFromProcessorDeps<ProcessorDeps>, string>;
54
- /** Union of every event type string owned by any `processorDeps` entry. */
55
- type EventTypeFromProcessorDeps<ProcessorDeps extends readonly unknown[]> = ProcessorDeps[number] extends infer ProcessorDep ? ProcessorDep extends unknown ? keyof ContractEventCatalog<ProcessorDep> : never : never;
56
- /**
57
- * Resolve a string event type to the definition that owns it. Local events win
58
- * in the type-level lookup; runtime validation rejects duplicate ownership.
59
- */
60
- type EventDefinitionForType<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Type extends string> = Type extends keyof Events ? Events[Type] : ProcessorDeps[number] extends infer ProcessorDep ? ProcessorDep extends unknown ? Type extends keyof ContractEventCatalog<ProcessorDep> ? ContractEventCatalog<ProcessorDep>[Type] : never : never : never;
61
- /** `StreamEventInput` with `type`/`payload` narrowed to one event definition. */
62
- type TypedStreamEventInput<Type extends string = string, Payload = Record<string, unknown>> = Omit<StreamEventInput, "payload" | "type"> & {
63
- type: Type;
64
- payload: Payload;
65
- };
66
- /**
67
- * A durable processor input. Wake processors never receive ephemeral events, so
68
- * a domain object's processor-typed append door must not claim that they do.
69
- */
70
- type TypedConsumedEventInput<Type extends string = string, Payload = Record<string, unknown>> = Omit<TypedStreamEventInput<Type, Payload>, "ephemeral"> & {
71
- ephemeral?: never;
72
- };
73
- /** `StreamEvent` with `type`/`payload` narrowed to one event definition. */
74
- type TypedStreamEvent<Type extends string = string, Payload = Record<string, unknown>> = Omit<StreamEvent, "payload" | "type"> & TypedStreamEventInput<Type, Payload>;
75
- /** Committed event for one resolved type (payload parsed, so required). */
76
- type EventFromType<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Type extends string> = Type extends unknown ? EventDefinitionForType<Events, ProcessorDeps, Type> extends EventDefinition<infer PayloadOutput, unknown> ? TypedStreamEvent<Type, PayloadOutput> & {
77
- payload: PayloadOutput;
78
- } & ParsedEphemeralEnvelope<EventDefinitionForType<Events, ProcessorDeps, Type>> : never : never;
79
- /** A committed event resolved from a contract's owned events or processor dependencies.
80
- * Unknown event-type strings retain the untyped {@link StreamEvent} shape. */
81
- export type ResolvedEvent<Contract, Type extends string> = Contract extends {
82
- events: EventCatalog;
83
- } ? Type extends ResolvedEventType<ContractEventCatalog<Contract>, ProcessorDepsOf<Contract>> ? EventFromType<ContractEventCatalog<Contract>, ProcessorDepsOf<Contract>, Type> : StreamEvent : StreamEvent;
84
- /** Union of committed-event shapes for a `consumes` tuple; `"*"` alone means any `StreamEvent`. */
85
- type EventFromTypes<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Types extends readonly string[]> = "*" extends Types[number] ? [Exclude<Types[number], "*">] extends [never] ? StreamEvent : EventFromType<Events, ProcessorDeps, Exclude<Types[number], "*">> : EventFromType<Events, ProcessorDeps, Types[number]>;
86
- /** Append input for one resolved type (payload accepts the schema's input shape). */
87
- type InputFromType<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Type extends string> = Type extends unknown ? EventDefinitionForType<Events, ProcessorDeps, Type> extends EventDefinition<unknown, infer PayloadInput> ? TypedStreamEventInput<Type, PayloadInput> : never : never;
88
- /** Durable append input for one event delivered to a wake processor. */
89
- type ConsumedInputFromType<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Type extends string> = Type extends unknown ? EventDefinitionForType<Events, ProcessorDeps, Type> extends EventDefinition<unknown, infer PayloadInput> ? TypedConsumedEventInput<Type, PayloadInput> : never : never;
90
- /** Durable append-input shapes for a processor's `consumes` tuple. */
91
- type ConsumedInputFromTypes<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Types extends readonly string[]> = "*" extends Types[number] ? Omit<StreamEventInput, "ephemeral"> & {
92
- ephemeral?: never;
93
- } : ConsumedInputFromType<Events, ProcessorDeps, Types[number]>;
94
- /** Parsed append input for one resolved type (payload validated, so required). */
95
- type ParsedInputFromType<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Type extends string> = Type extends unknown ? EventDefinitionForType<Events, ProcessorDeps, Type> extends EventDefinition<infer PayloadOutput, unknown> ? TypedStreamEventInput<Type, PayloadOutput> & {
96
- payload: PayloadOutput;
97
- } & ParsedEphemeralEnvelope<EventDefinitionForType<Events, ProcessorDeps, Type>> : never : never;
98
- /** Contract-forced ephemeral inputs default to `true` during parsing. */
99
- type ParsedEphemeralEnvelope<Definition> = Definition extends {
100
- ephemeral: true;
101
- } ? {
102
- ephemeral: true;
103
- } : unknown;
104
- /** A typed builder preserves the supplied envelope while returning parsed payload/default output. */
105
- type BuiltInputFromEvent<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Event extends {
106
- type: string;
107
- }> = Event extends unknown ? Omit<Event, "payload"> & Pick<ParsedInputFromType<Events, ProcessorDeps, Event["type"]>, "payload"> & ParsedEphemeralEnvelope<EventDefinitionForType<Events, ProcessorDeps, Event["type"]>> : never;
108
- /** Parsed durable inputs for a processor's `consumes` tuple. */
109
- type ParsedConsumedInputFromTypes<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Types extends readonly string[]> = "*" extends Types[number] ? Omit<StreamEventInput, "ephemeral"> & {
110
- ephemeral?: never;
111
- } : Types[number] extends infer Type extends string ? EventDefinitionForType<Events, ProcessorDeps, Type> extends EventDefinition<infer PayloadOutput, unknown> ? TypedConsumedEventInput<Type, PayloadOutput> : never : never;
112
- /** Union of committed-event shapes a contract's `consumes` list can deliver to `reduce`. */
113
- export type ConsumedEvent<Contract> = Contract extends {
114
- events: EventCatalog;
115
- consumes: infer Consumes extends readonly string[];
116
- } ? EventFromTypes<ContractEventCatalog<Contract>, ProcessorDepsOf<Contract>, Consumes> : never;
117
- /**
118
- * Union of durable append-input shapes accepted by a contract's `consumes`
119
- * list. Ephemeral events are excluded because hosted processors cannot consume
120
- * them; append those intentionally through the raw Stream door. This is a
121
- * schema/vocabulary union, not proof that an event is valid in the processor's
122
- * current state or came from a particular provenance.
123
- */
124
- export type ConsumedInput<Contract> = Contract extends {
125
- events: EventCatalog;
126
- consumes: infer Consumes extends readonly string[];
127
- } ? ConsumedInputFromTypes<ContractEventCatalog<Contract>, ProcessorDepsOf<Contract>, Consumes> : never;
128
- /** Union of append-input shapes a contract's `emits` list allows a processor to append. */
129
- export type EmittedInput<Contract> = Contract extends {
130
- events: EventCatalog;
131
- emits: infer Emits extends readonly string[];
132
- } ? InputFromType<ContractEventCatalog<Contract>, ProcessorDepsOf<Contract>, Emits[number]> : never;
133
- /** A contract's `processorDeps` tuple, defaulting to empty when absent. */
134
- type ProcessorDepsOf<Contract> = Contract extends {
135
- processorDeps?: infer ProcessorDeps;
136
- } ? ProcessorDeps extends readonly unknown[] ? ProcessorDeps : readonly [] : readonly [];
137
- /** A contract's reduced-state type, inferred from its `stateSchema`. */
138
- export type ProcessorState<Contract> = Contract extends {
139
- stateSchema: infer State extends z.ZodType;
140
- } ? z.output<State> : never;
141
- /** Reduced state must be object-shaped and must accept `{}` (the empty initial state). */
142
- type DefaultableObjectStateSchema<StateSchema extends z.ZodType> = z.output<StateSchema> extends Record<string, unknown> ? {} extends z.input<StateSchema> ? StateSchema : never : never;
143
- /**
144
- * Compile-time typo guard for `consumes` / `emits`: resolves to `unknown` when
145
- * every string in `Types` is resolvable (leaving the contract argument
146
- * unchanged), `never` when one is not — failing the call where the bad string
147
- * is written. `AllowStar` admits the `"*"` wildcard (consumes only).
148
- */
149
- type ResolvedEventTypesOnly<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Types extends readonly string[], AllowStar extends string = never> = [Exclude<Exclude<Types[number], AllowStar>, ResolvedEventType<Events, ProcessorDeps>>] extends [
150
- never
151
- ] ? unknown : never;
152
- /** `contract.buildEvent(...)`: validate an append input against the resolved payload schema. */
153
- type ProcessorContractBuildEvent<Events extends EventCatalog, ProcessorDeps extends readonly unknown[]> = <const Event extends InputFromType<Events, ProcessorDeps, ResolvedEventType<Events, ProcessorDeps>> & {
154
- type: string;
155
- }>(event: Event) => BuiltInputFromEvent<Events, ProcessorDeps, Event>;
156
- /** Resolved contract types compatible with an event's current discriminator type. */
157
- type ResolvedTypeFromEvent<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Event extends {
158
- type: string;
159
- }> = Extract<ResolvedEventType<Events, ProcessorDeps>, Event["type"]>;
160
- /** `contract.parseEvent(...)`: validate a committed event and infer its output from `event.type`. */
161
- type ProcessorContractParseEvent<Events extends EventCatalog, ProcessorDeps extends readonly unknown[]> = <const Event extends StreamEvent>(event: Event) => EventFromType<Events, ProcessorDeps, ResolvedTypeFromEvent<Events, ProcessorDeps, Event>>;
162
- /**
163
- * Same as `parseEvent`, but for append inputs that do not yet have an offset or
164
- * createdAt. This exists for stream-owned pre-commit policy: the Stream Durable
165
- * Object must reject some contract-owned events BEFORE they become durable
166
- * facts (see the core processor's `validate`) — validating them
167
- * later, in the wake side effect, would leave the invalid event committed and
168
- * reduced into durable state. The lifecycle e2e tests assert both the rejection
169
- * and that nothing was committed.
170
- */
171
- type ProcessorContractParseEventInput<Events extends EventCatalog, ProcessorDeps extends readonly unknown[]> = <const Event extends StreamEventInput>(event: Event) => ParsedInputFromType<Events, ProcessorDeps, ResolvedTypeFromEvent<Events, ProcessorDeps, Event>>;
172
- /**
173
- * `contract.parseConsumedInput(...)`: validate one domain-object append
174
- * against the exact event vocabulary delivered to the processor.
175
- */
176
- type ProcessorContractParseConsumedInput<Events extends EventCatalog, ProcessorDeps extends readonly unknown[], Consumes extends readonly string[]> = <const Event extends ConsumedInputFromTypes<Events, ProcessorDeps, Consumes>>(event: Event) => "*" extends Consumes[number] ? ParsedConsumedInputFromTypes<Events, ProcessorDeps, Consumes> : ParsedConsumedInputFromTypes<Events, ProcessorDeps, readonly Extract<Consumes[number], Event["type"]>[]>;
177
- /**
178
- * `getEventSchema` without offset/createdAt (and strict, so an accidental
179
- * `offset` key on an append input fails loudly). Gives pre-append policy code
180
- * the same payload validation as reducers, without fabricating a committed
181
- * event just to get at the typed payload.
182
- */
183
- export declare function getEventInputSchema<const Type extends string, const PayloadSchema extends z.ZodType>(args: {
184
- type: Type;
185
- payloadSchema: PayloadSchema;
186
- ephemeral?: boolean;
187
- }): z.ZodType<TypedStreamEventInput<Type, z.output<PayloadSchema>>, TypedStreamEventInput<Type, z.input<PayloadSchema>>>;
188
- /** Memoized {@link getEventSchema} (see {@link eventSchemaCache}). */
189
- export declare function cachedEventSchema(args: {
190
- type: string;
191
- payloadSchema: z.ZodType;
192
- ephemeral?: boolean;
193
- }): z.ZodType;
194
- /** Union of append-input shapes for every event a contract can resolve (own + deps). */
195
- type ResolvedEventInput<Contract> = Contract extends {
196
- events: EventCatalog;
197
- } ? InputFromType<ContractEventCatalog<Contract>, ProcessorDepsOf<Contract>, ResolvedEventType<ContractEventCatalog<Contract>, ProcessorDepsOf<Contract>>> : never;
198
- /**
199
- * Validate an append input with the payload schema resolved from a processor
200
- * contract. Prefer the contract-bound `contract.buildEvent(event)` API, which
201
- * carries the same types without repeating the contract in the argument.
202
- *
203
- * @deprecated Use `contract.buildEvent(event)`.
204
- */
205
- export declare function buildEvent<const Contract extends {
206
- slug?: string;
207
- events: EventCatalog;
208
- processorDeps?: readonly unknown[];
209
- }, const Event extends ResolvedEventInput<NoInfer<Contract>> & {
210
- type: string;
211
- }>(args: {
212
- contract: Contract;
213
- event: Event;
214
- }): BuiltInputFromEvent<ContractEventCatalog<Contract>, ProcessorDepsOf<Contract>, Event>;
215
- /**
216
- * Typed identity for processor contracts: validation plus the pre-bound
217
- * `buildEvent` / `parseEvent` / `parseEventInput` / `parseConsumedInput`
218
- * helpers.
219
- *
220
- * The signature enforces the important invariants at authoring time:
221
- *
222
- * - `stateSchema` must parse `{}` to an object-shaped reduced state;
223
- * - every string in `consumes` and `emits` must resolve against local `events`
224
- * plus `processorDeps` (and both are contextually typed for autocomplete);
225
- * - local `events` must not redefine an event already owned by a
226
- * `processorDeps` contract. Event ownership is intentionally one processor
227
- * deep: a processor can depend on another owner, but it cannot shadow that
228
- * owner's public event type with a second payload schema.
229
- */
230
- export declare function defineProcessorContract<const StateSchema extends z.ZodType, const Events extends EventCatalog, const Consumes extends readonly (ResolvedEventType<Events, ProcessorDeps> | "*")[], const Emits extends readonly ResolvedEventType<Events, ProcessorDeps>[], const ProcessorDeps extends readonly unknown[] = readonly []>(contract: {
231
- slug: string;
232
- version: string;
233
- description: string;
234
- stateSchema: DefaultableObjectStateSchema<StateSchema>;
235
- processorDeps?: ProcessorDeps;
236
- events: Events;
237
- consumes: Consumes & ResolvedEventTypesOnly<Events, ProcessorDeps, Consumes, "*">;
238
- emits: Emits & ResolvedEventTypesOnly<Events, ProcessorDeps, Emits>;
239
- }): {
240
- slug: string;
241
- version: string;
242
- description: string;
243
- stateSchema: StateSchema;
244
- processorDeps?: ProcessorDeps;
245
- events: Events;
246
- consumes: Consumes;
247
- emits: Emits;
248
- buildEvent: ProcessorContractBuildEvent<Events, ProcessorDeps>;
249
- parseEvent: ProcessorContractParseEvent<Events, ProcessorDeps>;
250
- parseEventInput: ProcessorContractParseEventInput<Events, ProcessorDeps>;
251
- parseConsumedInput: ProcessorContractParseConsumedInput<Events, ProcessorDeps, Consumes>;
252
- };
253
- /**
254
- * Enforces the invariant that reduced processor state is object-shaped (so
255
- * state slices can evolve safely and hooks never branch on primitive state).
256
- */
257
- export declare function assertObjectProcessorState(args: {
258
- processorSlug: string;
259
- value: unknown;
260
- }): void;
261
- /**
262
- * Resolve the payload schema a processor should use for an incoming event:
263
- * the named definition when the type is listed in `consumes`, a permissive
264
- * `z.unknown()` definition when the contract consumes `"*"`, and `undefined`
265
- * when the event is not consumed at all. Runtime counterpart of
266
- * `ConsumedEvent<Contract>`.
267
- *
268
- * `"*"` NEVER MATCHES AN EPHEMERAL EVENT, and that one rule is what lets
269
- * ephemeral types live in `consumes` beside durable ones instead of in a
270
- * parallel list. Naming a type explicitly is the opt-in: you cannot be handed
271
- * a microphone firehose by a wildcard you wrote for durable facts, and a
272
- * processor that wants live events says so by type. Ephemeral bodies live
273
- * only in the Stream DO's bounded buffer, so a processor receiving one must
274
- * have decided it can cope with never seeing it again — a decision nobody
275
- * makes by writing `"*"`.
276
- */
277
- export declare function getConsumedEventDefinition(args: {
278
- contract: {
279
- events: EventCatalog;
280
- processorDeps?: readonly unknown[];
281
- consumes: readonly string[];
282
- };
283
- eventType: string;
284
- /** Whether the event being resolved is ephemeral; gates the `"*"` fallback. */
285
- ephemeral?: boolean;
286
- }): EventDefinition | undefined;
287
- export declare function getResolvedEventDefinition(args: {
288
- contract: {
289
- events: EventCatalog;
290
- processorDeps?: readonly unknown[];
291
- };
292
- eventType: string;
293
- }): EventDefinition | undefined;
294
- /**
295
- * The ONE platform revival fact for every recovery-wired stream processor.
296
- * Appended by the platform keepalive (`durableObjectRecovery` in
297
- * durable-object-processor-durability.ts) when a processor is revived after
298
- * its incarnation died owing background work — never emitted by a processor.
299
- * Per-processor identity rides the payload's `processorSlug` and the
300
- * `processor-revived:<slug>@...` idempotency key, not the type string.
301
- * Consuming it is OPTIONAL: a processor should do so only when it reacts to
302
- * the fact itself. Its append still wakes delivery when it is unconsumed, and
303
- * a head-reaching frame receives the runner's eventless
304
- * `processEvent(event: null, caughtUp: true)` pass so open obligations are not
305
- * stranded. The event DEFINITION (payload schema) lives with the platform's
306
- * core stream contract; this constant is here so contracts and the recovery
307
- * adapter agree on the type string without importing that contract.
308
- */
309
- export declare const STREAM_PROCESSOR_REVIVED_EVENT_TYPE = "events.iterate.com/stream/processor-revived";
310
- /**
311
- * A processor contract announcement carried on `connection-opened` when the
312
- * callback owner is a hosted stream processor. UIs and tooling read it from
313
- * that event and from `runtime.connections[..].openedBy`.
314
- */
315
- export declare const ProcessorContractAnnouncement: z.ZodObject<{
316
- slug: z.ZodString;
317
- version: z.ZodString;
318
- description: z.ZodString;
319
- consumes: z.ZodArray<z.ZodString>;
320
- emits: z.ZodArray<z.ZodString>;
321
- ownedEvents: z.ZodArray<z.ZodObject<{
322
- type: z.ZodString;
323
- description: z.ZodOptional<z.ZodString>;
324
- }, z.core.$strip>>;
325
- }, z.core.$strip>;
326
- export type ProcessorContractAnnouncement = z.infer<typeof ProcessorContractAnnouncement>;
327
- /**
328
- * Platform stream events a processor contract may CONSUME without owning —
329
- * pass as a `processorDeps` entry. Currently just the keepalive revival fact.
330
- * Consumption is optional and belongs only in processors that react to the
331
- * fact itself; an unconsumed revival tail receives the runner's eventless
332
- * at-head turn. The event's authoritative definition lives with the
333
- * platform's core stream contract, and this catalog is deliberately
334
- * payload-loose.
335
- */
336
- export declare const PLATFORM_STREAM_EVENTS: {
337
- "events.iterate.com/stream/processor-revived": {
338
- description: string;
339
- payloadSchema: z.ZodObject<{}, z.core.$loose>;
340
- };
341
- };
342
- export {};
@@ -1,186 +0,0 @@
1
- import { DurableObject } from "cloudflare:workers";
2
- import type { LiveStateCursor } from "../sdk/capnweb/live-state/protocol.ts";
3
- import type { LiveStateRpc } from "../sdk/capnweb/live-state/types.ts";
4
- import type { ProcessorStream } from "./stream-handle.ts";
5
- import type { MaybePromise } from "./stream-processor.ts";
6
- import type { ProcessorRuntimeState, ProcessorSnapshot, StreamProcessorWakeRequest, StreamProcessorWakeResponse } from "./rpc-types.ts";
7
- import { type StreamProcessorRegistry } from "./stream-processor-registry.ts";
8
- /**
9
- * Where the configured identity lives in the facet's own kv. Exported so a
10
- * subclass's own doors can self-heal a fresh incarnation (re-run the
11
- * idempotent `configure` from the stash) before the base's boot microtask has
12
- * run — see apps/os `ProcessorFacet.#requireRegistry`.
13
- */
14
- export declare const FACET_IDENTITY_KEY = "iterate:processor-facet:identity";
15
- /**
16
- * The identity a {@link ProcessorFacet} is configured with on first contact —
17
- * stashed durably in the facet's own kv, never passed again. `path` +
18
- * `projectId` are the registry's wake coordinate fence; `parentName` is how
19
- * the facet dials BACK to the Durable Object hosting it (the Stream DO) for
20
- * the alarm proxy.
21
- */
22
- export type ProcessorFacetIdentity = {
23
- /** Durable Object name of the hosting parent (the Stream DO). */
24
- parentName: string;
25
- /** Owning project of the hosted stream, or null on a deployment-global stream. */
26
- projectId: string | null;
27
- /** Path of the hosted stream. */
28
- path: string;
29
- };
30
- /**
31
- * The three parent-side alarm doors a facet dials in place of its own
32
- * (unimplemented) `ctx.storage` alarm verbs. The parent implements them over
33
- * its REAL platform alarm and replays each fire into the facet's
34
- * {@link ProcessorFacet.handleAlarm}. The parent's implementations MUST
35
- * tolerate being called reentrantly while the parent itself is still awaiting
36
- * `handleAlarm` — the keepalive re-arms from inside its own alarm turn.
37
- */
38
- export type ProcessorFacetAlarmProxy = {
39
- proxySetAlarm(scheduledTimeMs: number): MaybePromise<unknown>;
40
- proxyDeleteAlarm(): MaybePromise<unknown>;
41
- proxyGetAlarm(): MaybePromise<number | null>;
42
- };
43
- /**
44
- * Everything app-specific about one facet host, derived from the stashed
45
- * identity by {@link ProcessorFacet.createHost}: the stream handle processors
46
- * append through, the worker deploy version (keepalive crash-loop budget
47
- * reset), and the per-host processor composition — the subclass constructs its
48
- * processors here and registers each under its subscription name.
49
- */
50
- export type ProcessorFacetHost = {
51
- /** The hosted stream — how processors append/read (colocated: a dial back
52
- * to the parent Stream DO's stream surface). */
53
- stream: ProcessorStream;
54
- /** Worker deploy version — pass this worker's build identity. A change
55
- * resets each keepalive's crash-loop budget (the antidote deploy). */
56
- version: string;
57
- /** Injected clock for tests; production omits it (Date.now). */
58
- now?: () => number;
59
- /** Assemble this node's live state; omit for the primary runner's fold. */
60
- getLiveState?: () => Record<string, unknown>;
61
- /** Construct and register this host's processors (`registry.register(new
62
- * XProcessor({...}), { recovery, name })`) — called once, right after the
63
- * registry is built. Per-processor recovery stays the author's explicit
64
- * choice, exactly as on a hosting DO. */
65
- registerProcessors(registry: StreamProcessorRegistry): void;
66
- };
67
- /**
68
- * A facet's `DurableObjectState` facade for `createStreamProcessorRegistry`:
69
- * ONLY `storage.setAlarm` / `storage.deleteAlarm` / `storage.getAlarm` are
70
- * overridden to dial the parent's {@link ProcessorFacetAlarmProxy}; kv,
71
- * waitUntil, and everything else pass through untouched. `parentAlarms` is
72
- * invoked PER CALL — the parent stub must be resolved lazily from the stashed
73
- * identity, because the recovery adapter's boot reconcile issues alarm calls
74
- * at construction and a stub captured once would outlive its RPC session.
75
- */
76
- export declare function facetProcessorDurableObjectState(ctx: DurableObjectState, parentAlarms: () => ProcessorFacetAlarmProxy): DurableObjectState;
77
- /**
78
- * Plain-copy an `AlarmInvocationInfo` before a facet hop. The platform hands
79
- * the parent's `alarm()` a host object that does not serialize across RPC;
80
- * a parent replaying a fire into {@link ProcessorFacet.handleAlarm} must send
81
- * this copy instead.
82
- */
83
- export declare function plainAlarmInvocationInfo(info: AlarmInvocationInfo | undefined): AlarmInvocationInfo | undefined;
84
- /**
85
- * Generic base for hosting stream processors in a Durable Object facet.
86
- * Subclasses are the per-host composition (the facets task's target shape) and
87
- * supply exactly two things: how to dial the parent's alarm proxy and what
88
- * this host runs —
89
- *
90
- * ```ts
91
- * export class AgentProcessors extends ProcessorFacet<Env> {
92
- * protected parentAlarms({ parentName }: ProcessorFacetIdentity) {
93
- * return this.env.STREAM.getByName(parentName);
94
- * }
95
- * protected createHost({ path, projectId }: ProcessorFacetIdentity): ProcessorFacetHost {
96
- * const stream = ...; // dial the parent stream
97
- * return {
98
- * stream,
99
- * version: workerVersion(this.env),
100
- * registerProcessors: (registry) => {
101
- * registry.register(
102
- * new AgentProcessor({ stream, path, projectId, ... }),
103
- * { recovery: true, name: "agent" },
104
- * );
105
- * },
106
- * };
107
- * }
108
- * }
109
- * ```
110
- *
111
- * The parent creates it with `ctx.facets.get(name, () => ({ class:
112
- * ctx.exports.AgentProcessors }))`, calls `configure()` once (idempotent), and
113
- * routes wakes/alarms/doors to the RPC surface below.
114
- *
115
- * THIS CLASS MUST NEVER DEFINE `alarm()` — and neither may a subclass. The
116
- * fire arrives as `handleAlarm` (an ordinary RPC verb) instead: workerd
117
- * reserves `alarm` for its native handler, and with one present a failed
118
- * native `setAlarm` poisons the facet's output gate (workerd#6810). The
119
- * constructor enforces this.
120
- */
121
- export declare abstract class ProcessorFacet<Env = unknown> extends DurableObject<Env> {
122
- #private;
123
- constructor(ctx: DurableObjectState, env: Env);
124
- /**
125
- * Resolve the parent's alarm-proxy stub for the stashed identity — e.g.
126
- * `this.env.STREAM.getByName(identity.parentName)`. Called once per alarm
127
- * verb invocation (stubs must not outlive their call turn).
128
- */
129
- protected abstract parentAlarms(identity: ProcessorFacetIdentity): ProcessorFacetAlarmProxy;
130
- /** Build this host's app-specific wiring from the stashed identity — called
131
- * once per incarnation, lazily on first use. */
132
- protected abstract createHost(identity: ProcessorFacetIdentity): ProcessorFacetHost;
133
- /**
134
- * First-contact identity stash, idempotent: re-configuring with the same
135
- * identity is a no-op (and ensures the host is built); a DIFFERENT identity
136
- * throws — a facet's coordinate never changes, so a mismatch is a miswire,
137
- * not a migration.
138
- */
139
- configure(identity: ProcessorFacetIdentity): void;
140
- /** The wake door — the parent's colocated delivery dial. Routes to the
141
- * registry: name-first resolution, coordinate fence, per-batch settlement
142
- * through each batch's independent `reportDeliveryResult`. */
143
- wakeStreamProcessor(request: StreamProcessorWakeRequest): Promise<StreamProcessorWakeResponse>;
144
- /**
145
- * The parent's alarm replay door — deliberately NOT named `alarm` (see the
146
- * class doc). The parent plain-copies its `AlarmInvocationInfo`
147
- * ({@link plainAlarmInvocationInfo}) and awaits this; a rejection propagates
148
- * so the parent can rethrow and get the platform's alarm retry.
149
- */
150
- handleAlarm(info?: AlarmInvocationInfo): Promise<void>;
151
- /** One consistent read of a hosted processor's committed fold. `name` may be
152
- * omitted on a single-processor host. */
153
- snapshot(args?: {
154
- name?: string;
155
- }): Promise<ProcessorSnapshot<unknown>>;
156
- /** The hosted processor's runtime state (runner snapshot + contributed
157
- * runtime bag). `name` may be omitted on a single-processor host. */
158
- getRuntimeState(args?: {
159
- name?: string;
160
- }): Promise<ProcessorRuntimeState>;
161
- /** Resolve once the named processor's acknowledged cursor reaches `offset` —
162
- * the read-your-writes barrier. The subscription catalog's uniform
163
- * `waitUntilProcessed` delegates its facet-placed processor rows here. */
164
- waitUntilProcessed(args: {
165
- offset: number;
166
- timeoutMs?: number;
167
- name?: string;
168
- }): Promise<void>;
169
- /** Pull the named processor through the durable stream tail — the parent
170
- * facade's catch-up-before-snapshot leg, dialed before every facet read.
171
- * `name` may be omitted on a single-processor host. */
172
- catchUp(args?: {
173
- name?: string;
174
- }): Promise<void>;
175
- /** Read a transient snapshot or delta for the parent's current stream lifetime.
176
- * Cold or replaced processors hydrate from durable progress. Warm reads use
177
- * committed local state: polling must not call back into the parent stream
178
- * for every processor while it is delivering events to this facet. */
179
- readLiveState(args: {
180
- streamId: string;
181
- cursor?: LiveStateCursor;
182
- patchVersion?: 2 | 3;
183
- }): Promise<import("../sdk/capnweb/index.ts").LiveStateRead<Record<string, unknown>>>;
184
- /** Direct subscriptions retain their callbacks across the Workers RPC hop. */
185
- liveState(): LiveStateRpc<Record<string, unknown>>;
186
- }
@@ -1,60 +0,0 @@
1
- import type { z } from "zod";
2
- import type { GetProcessorRuntimeState, ProcessorSnapshot, StreamConnectionPing } from "./rpc-types.ts";
3
- import type { ProcessorContractAnnouncement } from "./processor-contracts.ts";
4
- import type { EventConsumptionMetrics } from "./event-consumption-metrics.ts";
5
- import type { ProcessorRuntimeContribution } from "./stream-processor.ts";
6
- /**
7
- * The processor surface shared by the Durable Object registry
8
- * (stream-processor-registry.ts) and the browser host (stream-browser-store.ts):
9
- * the contract description returned by `wakeStreamProcessor`, the
10
- * processor-contributed runtime bag, and self-measured event-consumption metrics.
11
- * Deliberately NOT the drive surface — cursors, snapshots, and delivery live
12
- * in the StreamProcessorRunner, which reaches the protected hooks through
13
- * `StreamProcessor.runnerHooks`.
14
- */
15
- export type AnyHostedProcessor = {
16
- contract: {
17
- slug: string;
18
- version: string;
19
- description: string;
20
- stateSchema: z.ZodType;
21
- consumes: readonly string[];
22
- emits: readonly string[];
23
- events: Record<string, {
24
- description?: string;
25
- payloadSchema?: unknown;
26
- }>;
27
- };
28
- /** The processor-contributed runtime bag; the snapshot half comes from the runner. */
29
- getRuntimeState(): Promise<ProcessorRuntimeContribution>;
30
- readonly eventConsumptionMetrics: Pick<EventConsumptionMetrics, "report" | "notePingObserved" | "noteAppendCommitted" | "clearPendingAppends">;
31
- };
32
- /**
33
- * The two live capabilities every processor host hands the stream alongside
34
- * its event-batch callback, shared by the DO registry and browser runtime so they cannot
35
- * drift. `getRuntimeState` assembles the published shape from its two honest
36
- * sources: the SNAPSHOT from the runner (`opts.snapshot` — the cursor owner),
37
- * the `runtime` bag from the processor, with the self-measured metrics merged
38
- * in host-side so a subclass override cannot accidentally drop them.
39
- */
40
- export declare function hostRuntimeCapabilities(processor: AnyHostedProcessor, opts: {
41
- now: () => number;
42
- /** The driving runner's committed snapshot (`() => runner.snapshot()`). */
43
- snapshot: () => Promise<ProcessorSnapshot<unknown>>;
44
- oneWayEstimateMs?: () => number | undefined;
45
- }): {
46
- getRuntimeState: GetProcessorRuntimeState;
47
- ping: StreamConnectionPing;
48
- };
49
- /** Serializable processor contract carried by server and browser hosts. */
50
- export declare function announceContract(contract: {
51
- slug: string;
52
- version: string;
53
- description: string;
54
- consumes: readonly string[];
55
- emits: readonly string[];
56
- events: Record<string, {
57
- description?: string;
58
- payloadSchema?: unknown;
59
- }>;
60
- }): ProcessorContractAnnouncement;
@@ -1,17 +0,0 @@
1
- export type PromptSection = {
2
- key: string;
3
- content: string;
4
- };
5
- /**
6
- * Parse a prompt file's authoring syntax into sections, in file order.
7
- * Content inside `<section key="x">...</section>` becomes a section with
8
- * that key; content outside any tag (including a whole untagged file)
9
- * becomes a section with `fallbackKey` — so an untagged prompt file parses
10
- * to one section and keeps working unchanged. Throws on malformed authoring
11
- * (unclosed or nested tags): this runs at append time, where a loud failure
12
- * beats silently shipping tag soup to a model.
13
- */
14
- export declare function parsePromptSections(input: {
15
- content: string;
16
- fallbackKey: string;
17
- }): PromptSection[];