iterate 0.2.7 → 0.3.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 (218) hide show
  1. package/README.md +86 -76
  2. package/THIRD_PARTY_NOTICES.md +55 -0
  3. package/bin/iterate.js +11 -3
  4. package/dist/api-url-B6404M82.mjs +17 -0
  5. package/dist/api-url-B6404M82.mjs.map +1 -0
  6. package/dist/app-ref-BipL0feU.mjs +35 -0
  7. package/dist/app-ref-BipL0feU.mjs.map +1 -0
  8. package/dist/app-ref-C1CrgXqX.mjs +7 -0
  9. package/dist/app-ref-C1CrgXqX.mjs.map +1 -0
  10. package/dist/app-ref-DYai_om1.mjs +7 -0
  11. package/dist/app-ref-DYai_om1.mjs.map +1 -0
  12. package/dist/cli-D0c-pDL_.mjs +1010 -0
  13. package/dist/cli-D0c-pDL_.mjs.map +1 -0
  14. package/dist/client.d.ts +3 -0
  15. package/dist/client.mjs +4 -0
  16. package/dist/cloudflare-BTm90gQ4.mjs +951 -0
  17. package/dist/cloudflare-BTm90gQ4.mjs.map +1 -0
  18. package/dist/contract-s4FW4eES.mjs +309 -0
  19. package/dist/contract-s4FW4eES.mjs.map +1 -0
  20. package/dist/document-review/index.d.ts +5 -0
  21. package/dist/document-review/types.d.ts +107 -0
  22. package/dist/document-review.mjs +7015 -0
  23. package/dist/document-review.mjs.map +1 -0
  24. package/dist/durable-object-processor-durability-CNsTjAJS.mjs +205 -0
  25. package/dist/durable-object-processor-durability-CNsTjAJS.mjs.map +1 -0
  26. package/dist/idempotency-DleloJNt.mjs +28 -0
  27. package/dist/idempotency-DleloJNt.mjs.map +1 -0
  28. package/dist/index.mjs +1 -1
  29. package/dist/itx/api-url.d.ts +6 -0
  30. package/dist/itx/itx-node-client.d.ts +65 -0
  31. package/dist/itx/itx-session.d.ts +215 -0
  32. package/dist/itx/owned-rpc-session.d.ts +14 -0
  33. package/dist/itx/query-client.d.ts +10 -0
  34. package/dist/itx-api.generated.d.ts +6195 -0
  35. package/dist/itx-session-sjud8GiT.mjs +534 -0
  36. package/dist/itx-session-sjud8GiT.mjs.map +1 -0
  37. package/dist/live-state-BJNqOwFw.mjs +299 -0
  38. package/dist/live-state-BJNqOwFw.mjs.map +1 -0
  39. package/dist/next/api.d.ts +479 -0
  40. package/dist/next/api.mjs +0 -0
  41. package/dist/next/app-server.d.ts +44 -0
  42. package/dist/next/app-server.mjs +479 -0
  43. package/dist/next/app-server.mjs.map +1 -0
  44. package/dist/next/app-session.d.ts +49 -0
  45. package/dist/next/app-session.mjs +238 -0
  46. package/dist/next/app-session.mjs.map +1 -0
  47. package/dist/next/app.d.ts +29 -0
  48. package/dist/next/app.mjs +141 -0
  49. package/dist/next/app.mjs.map +1 -0
  50. package/dist/next/client/live-state.d.ts +63 -0
  51. package/dist/next/client/oauth.d.ts +12 -0
  52. package/dist/next/client/react.d.ts +109 -0
  53. package/dist/next/client/socket.d.ts +6 -0
  54. package/dist/next/client.mjs +156 -0
  55. package/dist/next/client.mjs.map +1 -0
  56. package/dist/next/expression.d.ts +146 -0
  57. package/dist/next/expression.mjs +399 -0
  58. package/dist/next/expression.mjs.map +1 -0
  59. package/dist/next/lib.d.ts +56 -0
  60. package/dist/next/lib.mjs +199 -0
  61. package/dist/next/lib.mjs.map +1 -0
  62. package/dist/next/oauth-scopes.d.ts +32 -0
  63. package/dist/next/oauth-scopes.mjs +40 -0
  64. package/dist/next/oauth-scopes.mjs.map +1 -0
  65. package/dist/next/oauth.mjs +29 -0
  66. package/dist/next/oauth.mjs.map +1 -0
  67. package/dist/next/principal.d.ts +64 -0
  68. package/dist/next/principal.mjs +98 -0
  69. package/dist/next/principal.mjs.map +1 -0
  70. package/dist/next/project-ingress.d.ts +37 -0
  71. package/dist/next/project-ingress.mjs +75 -0
  72. package/dist/next/project-ingress.mjs.map +1 -0
  73. package/dist/next/react.mjs +285 -0
  74. package/dist/next/react.mjs.map +1 -0
  75. package/dist/next/sdk/auth.d.ts +5 -0
  76. package/dist/next/sdk/index.d.ts +112 -0
  77. package/dist/next/sdk.mjs +139 -0
  78. package/dist/next/sdk.mjs.map +1 -0
  79. package/dist/next/stream/processor.d.ts +378 -0
  80. package/dist/next/stream/processor.mjs +582 -0
  81. package/dist/next/stream/processor.mjs.map +1 -0
  82. package/dist/next/stream/run.d.ts +58 -0
  83. package/dist/next/stream/run.mjs +40 -0
  84. package/dist/next/stream/run.mjs.map +1 -0
  85. package/dist/next-node.d.ts +15 -0
  86. package/dist/next-node.mjs +51 -0
  87. package/dist/next-node.mjs.map +1 -0
  88. package/dist/node.d.ts +3 -0
  89. package/dist/node.mjs +185 -0
  90. package/dist/node.mjs.map +1 -0
  91. package/dist/processor-host-capabilities-BMFH3KTM.mjs +56 -0
  92. package/dist/processor-host-capabilities-BMFH3KTM.mjs.map +1 -0
  93. package/dist/processors/cloudflare.d.ts +3 -0
  94. package/dist/processors/durable-object-processor-durability.d.ts +79 -0
  95. package/dist/processors/event-consumption-metrics.d.ts +82 -0
  96. package/dist/processors/idempotency.d.ts +13 -0
  97. package/dist/processors/index.d.ts +12 -0
  98. package/dist/processors/processor-contracts.d.ts +342 -0
  99. package/dist/processors/processor-facet.d.ts +186 -0
  100. package/dist/processors/processor-host-capabilities.d.ts +60 -0
  101. package/dist/processors/prompt-sections.d.ts +17 -0
  102. package/dist/processors/rpc-types.d.ts +515 -0
  103. package/dist/processors/schemas.d.ts +102 -0
  104. package/dist/processors/stream-handle.d.ts +45 -0
  105. package/dist/processors/stream-processor-keepalive.d.ts +95 -0
  106. package/dist/processors/stream-processor-registry.d.ts +233 -0
  107. package/dist/processors/stream-processor-runner.d.ts +289 -0
  108. package/dist/processors/stream-processor.d.ts +339 -0
  109. package/dist/processors/stream-runtime-metrics.d.ts +107 -0
  110. package/dist/processors/testing.d.ts +302 -0
  111. package/dist/processors-BoNyeBfQ.mjs +10 -0
  112. package/dist/processors-BoNyeBfQ.mjs.map +1 -0
  113. package/dist/processors-cloudflare.mjs +3 -0
  114. package/dist/processors-testing.mjs +435 -0
  115. package/dist/processors-testing.mjs.map +1 -0
  116. package/dist/processors.mjs +52 -0
  117. package/dist/processors.mjs.map +1 -0
  118. package/dist/protocol-DnK_f2m6.mjs +251 -0
  119. package/dist/protocol-DnK_f2m6.mjs.map +1 -0
  120. package/dist/sdk/capnweb/index.d.ts +2 -0
  121. package/dist/sdk/capnweb/live-state/compact.d.ts +5 -0
  122. package/dist/sdk/capnweb/live-state/diff.d.ts +41 -0
  123. package/dist/sdk/capnweb/live-state/engine.d.ts +44 -0
  124. package/dist/sdk/capnweb/live-state/index.d.ts +41 -0
  125. package/dist/sdk/capnweb/live-state/protocol.d.ts +87 -0
  126. package/dist/sdk/capnweb/live-state/retain.d.ts +23 -0
  127. package/dist/sdk/capnweb/live-state/store.d.ts +20 -0
  128. package/dist/sdk/capnweb/live-state/types.d.ts +11 -0
  129. package/dist/sdk/capnweb/react.d.ts +45 -0
  130. package/dist/sdk/capnweb/react.mjs +316 -0
  131. package/dist/sdk/capnweb/react.mjs.map +1 -0
  132. package/dist/sdk/capnweb.mjs +4 -0
  133. package/dist/sdk/itx/react.d.ts +191 -0
  134. package/dist/sdk/itx/react.mjs +383 -0
  135. package/dist/sdk/itx/react.mjs.map +1 -0
  136. package/dist/sdk-DMB-IM11.mjs +933 -0
  137. package/dist/sdk-DMB-IM11.mjs.map +1 -0
  138. package/dist/sdk.d.ts +339 -0
  139. package/dist/sdk.mjs +2 -0
  140. package/dist/serve-itx.d.ts +46 -0
  141. package/dist/starter-apps/flake-dashboard/app-ref.d.ts +31 -0
  142. package/dist/starter-apps/flake-dashboard/configured-worker.mjs +1055 -0
  143. package/dist/starter-apps/flake-dashboard/configured-worker.mjs.map +1 -0
  144. package/dist/starter-apps/flake-dashboard/contract.d.ts +4839 -0
  145. package/dist/starter-apps/flake-dashboard/contract.mjs +2 -0
  146. package/dist/starter-apps/flake-dashboard/index.d.ts +17 -0
  147. package/dist/starter-apps/flake-dashboard/index.mjs +56 -0
  148. package/dist/starter-apps/flake-dashboard/index.mjs.map +1 -0
  149. package/dist/starter-apps/flake-dashboard/worker.d.ts +4607 -0
  150. package/dist/starter-apps/github-ai-linter/ai-linter.d.ts +8914 -0
  151. package/dist/starter-apps/github-ai-linter/configured-worker.mjs +17987 -0
  152. package/dist/starter-apps/github-ai-linter/configured-worker.mjs.map +1 -0
  153. package/dist/starter-apps/github-ai-linter/contract.d.ts +9193 -0
  154. package/dist/starter-apps/github-ai-linter/index.d.ts +10 -0
  155. package/dist/starter-apps/github-ai-linter/index.mjs +36 -0
  156. package/dist/starter-apps/github-ai-linter/index.mjs.map +1 -0
  157. package/dist/starter-apps/github-ai-linter/prompt.d.ts +13 -0
  158. package/dist/starter-apps/github-ai-linter/review-bot.d.ts +808 -0
  159. package/dist/starter-apps/github-ai-linter/rules.d.ts +34 -0
  160. package/dist/starter-apps/github-ai-linter/worker-ref.d.ts +19 -0
  161. package/dist/starter-apps/github-ai-linter/worker.d.ts +19 -0
  162. package/dist/starter-apps/github-ai-linter/worker.mjs +947 -0
  163. package/dist/starter-apps/github-ai-linter/worker.mjs.map +1 -0
  164. package/dist/starter-apps/guestbook/app-ref.d.ts +27 -0
  165. package/dist/starter-apps/guestbook/client.d.ts +7 -0
  166. package/dist/starter-apps/guestbook/client.mjs +59 -0
  167. package/dist/starter-apps/guestbook/configured-worker.mjs +205 -0
  168. package/dist/starter-apps/guestbook/configured-worker.mjs.map +1 -0
  169. package/dist/starter-apps/guestbook/index.d.ts +9 -0
  170. package/dist/starter-apps/guestbook/index.mjs +31 -0
  171. package/dist/starter-apps/guestbook/index.mjs.map +1 -0
  172. package/dist/starter-apps/guestbook/processor.d.ts +2267 -0
  173. package/dist/starter-apps/guestbook/worker.d.ts +26 -0
  174. package/dist/starter-apps/guestbook/worker.mjs +191 -0
  175. package/dist/starter-apps/guestbook/worker.mjs.map +1 -0
  176. package/dist/starter-apps/media/configured-worker.mjs +577 -0
  177. package/dist/starter-apps/media/configured-worker.mjs.map +1 -0
  178. package/dist/starter-apps/media/index.mjs +36 -0
  179. package/dist/starter-apps/media/index.mjs.map +1 -0
  180. package/dist/starter-apps/media/ref.mjs +20 -0
  181. package/dist/starter-apps/media/ref.mjs.map +1 -0
  182. package/dist/starter-apps/media/worker.mjs +579 -0
  183. package/dist/starter-apps/media/worker.mjs.map +1 -0
  184. package/dist/starter-apps/notes/configured-worker.mjs +6134 -0
  185. package/dist/starter-apps/notes/configured-worker.mjs.map +1 -0
  186. package/dist/starter-apps/notes/index.mjs +23 -0
  187. package/dist/starter-apps/notes/index.mjs.map +1 -0
  188. package/dist/starter-apps/notes/ref.mjs +21 -0
  189. package/dist/starter-apps/notes/ref.mjs.map +1 -0
  190. package/dist/starter-apps/notes/worker.mjs +427 -0
  191. package/dist/starter-apps/notes/worker.mjs.map +1 -0
  192. package/dist/starter-apps/todo/client.mjs +59 -0
  193. package/dist/starter-apps/todo/configured-worker.mjs +2864 -0
  194. package/dist/starter-apps/todo/configured-worker.mjs.map +1 -0
  195. package/dist/starter-apps/todo/index.d.ts +8 -0
  196. package/dist/starter-apps/todo/index.mjs +29 -0
  197. package/dist/starter-apps/todo/index.mjs.map +1 -0
  198. package/dist/stream-processor-keepalive-DAQTP6m3.mjs +2082 -0
  199. package/dist/stream-processor-keepalive-DAQTP6m3.mjs.map +1 -0
  200. package/dist/usingCtx-inzbY1Qz.mjs +57 -0
  201. package/dist/usingCtx-mZx5nsAW.mjs +11800 -0
  202. package/dist/usingCtx-mZx5nsAW.mjs.map +1 -0
  203. package/dist/worker-ref-DZxPDmb_.mjs +390 -0
  204. package/dist/worker-ref-DZxPDmb_.mjs.map +1 -0
  205. package/menubar/Iterate.entitlements +12 -0
  206. package/menubar/Iterate.swift +914 -0
  207. package/menubar/IterateIcon.swift +145 -0
  208. package/menubar/README.md +28 -0
  209. package/menubar/build-menubar-app.sh +59 -0
  210. package/package.json +235 -18
  211. package/dist/cli-DMS4kJph.mjs +0 -868
  212. package/dist/cli-DMS4kJph.mjs.map +0 -1
  213. package/dist/config-DtnR7Lv7.mjs +0 -170
  214. package/dist/config-DtnR7Lv7.mjs.map +0 -1
  215. package/dist/index.d.mts.map +0 -1
  216. package/dist/stream-tui/agent-chat-terminal.d.mts +0 -1
  217. package/dist/stream-tui/agent-chat-terminal.mjs +0 -933
  218. package/dist/stream-tui/agent-chat-terminal.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-DMB-IM11.mjs","names":["RpcTarget","#live","#beforeRead","#subscription","RpcTarget","callable","#stub","#project","#projects","#session","#itx","#registryFor","#reads","#host","#memoHost"],"sources":["../src/sdk/capnweb/live-state/store.ts","../src/sdk/capnweb/live-state/protocol.ts","../src/sdk/capnweb/live-state/index.ts","../src/sdk/capnweb/index.ts","../src/serve-itx.ts","../src/sdk.ts"],"sourcesContent":["import { applyPatch } from \"./diff.ts\";\nimport { applyCompactPatch } from \"./compact.ts\";\nimport type { LiveUpdate } from \"./protocol.ts\";\n\n/**\n * The client half of the live-state channel: a tiny external store that folds\n * wire updates (one snapshot, then patches) back into the live value. The\n * server's `LiveState` engine is the producing half; `useLiveState` renders\n * this store via `useSyncExternalStore`.\n *\n * Revision discipline: a patch only applies when its `from` matches the held\n * revision. A mismatch means a message was missed (or arrived from a stale\n * subscription's revision line) — the store calls `resync` and holds its value\n * until the fresh snapshot lands, so a gap can never silently corrupt state.\n */\nexport type LiveStateStore<State> = {\n getState: () => State | undefined;\n subscribe: (listener: () => void) => () => void;\n reset: () => void;\n /** Fold one wire update into the held value; a revision gap means a missed patch — resync. */\n apply: (update: LiveUpdate<State>, resync: () => void) => void;\n};\n\nexport function createLiveStateStore<State>(): LiveStateStore<State> {\n let held: { revision: number; state: State | undefined } = { revision: -1, state: undefined };\n const listeners = new Set<() => void>();\n const notify = () => listeners.forEach((listener) => listener());\n return {\n getState: () => held.state,\n subscribe: (listener: () => void) => {\n listeners.add(listener);\n return () => void listeners.delete(listener);\n },\n reset: () => {\n held = { revision: -1, state: undefined };\n notify();\n },\n apply: (update: LiveUpdate<State>, resync: () => void) => {\n if (\"s\" in update) {\n held = { revision: update.s[0], state: update.s[1] };\n } else if (\"p\" in update) {\n if (update.p[0] !== held.revision) {\n resync();\n return;\n }\n held = { revision: update.p[1], state: applyCompactPatch(held.state, update.p[2]) };\n } else if (update.type === \"snapshot\") {\n held = { revision: update.revision, state: update.state };\n } else if (update.from !== held.revision) {\n resync();\n return;\n } else {\n held = { revision: update.to, state: applyPatch(held.state, update.patch) };\n }\n notify();\n },\n };\n}\n","/**\n * Wire types for the live-state channel: what a server engine pushes down a\n * subscription. A subscription always delivers one `snapshot` first (the full\n * current state), then a stream of `patch`es — each the minimal structural diff\n * since the previous revision. `useLiveState` reassembles these into the live\n * value, so feature code never touches these types directly.\n *\n * See `diff.ts` for how patches are produced (`diff`) and applied (`applyPatch`).\n */\n\n/**\n * A structural patch turning a previous JSON value into the next one. Three\n * shapes, discriminated by `set`, `array`, or an object patch:\n * - `{ set }` — replace this position wholesale. Used for primitives,\n * `null`, type changes,\n * and newly-added object keys.\n * - `{ fields?, drop? }` — descend into a plain object: `fields` maps each\n * changed key to its own patch; `drop` lists keys that disappeared. At least\n * one is present (an empty descend never gets emitted).\n * - `{ array }` — patch changed positions and set the resulting length. Kept\n * elements retain their identity, including immutable text blocks inside a\n * changed step. This form is sent only to subscribers requesting version 2.\n */\nexport type LiveStatePatch =\n | { set: unknown }\n | { array: { length: number; items: [number, LiveStatePatch][] } }\n | { fields?: Record<string, LiveStatePatch>; drop?: string[] };\n\n/** Explicit codec negotiation keeps already-open clients valid across deploys. */\nexport type LiveStateSubscriptionOptions = { patchVersion?: 2 | 3 };\n\n/**\n * Version 3 addresses existing object fields by their sorted baseline position;\n * new fields use `+name`. Arrays use indices and an optional `#` length.\n * Primitives replace directly, `[value]` replaces other values, `[length, text]`\n * appends to a string, and `[]` deletes an object field. No dictionary survives\n * an update: every address refers to the acknowledged baseline of that patch.\n */\nexport type CompactLiveStatePatch =\n | string\n | number\n | boolean\n | null\n | []\n | [unknown]\n | [number, string]\n | { [address: string]: CompactLiveStatePatch };\n\n/** A transient reader's position; a new engine incarnation always has a new epoch. */\nexport type LiveStateCursor = { epoch: string; revision: number };\n\n/** A pull transports one delta, a fresh snapshot, or no change. No callback is retained. */\nexport type LiveStateRead<State> = { epoch: string; update: LiveUpdate<State> | null };\n\n/**\n * One message pushed down a live-state subscription. The first is always a\n * `snapshot` (a resync sends a fresh one); every message after carries only the\n * diff from revision `from` to `to`. Revisions are monotonic for the life of one\n * subscription, so a gap (`from` ≠ the client's revision) means a message was\n * missed and the client should resubscribe.\n *\n * `State` is asserted by the caller of `useLiveState` — the wire itself is\n * structure-agnostic.\n */\nexport type LiveUpdate<State = unknown> =\n | { type: \"snapshot\"; revision: number; state: State }\n | { type: \"patch\"; from: number; to: number; patch: LiveStatePatch }\n | { s: [revision: number, state: State] }\n | { p: [from: number, to: number, patch: CompactLiveStatePatch] };\n\nexport function isLiveStateSnapshot<State>(\n update: LiveUpdate<State>,\n): update is Extract<LiveUpdate<State>, { type: \"snapshot\" } | { s: unknown }> {\n return \"s\" in update || (\"type\" in update && update.type === \"snapshot\");\n}\n\nexport function liveStateRevision(update: LiveUpdate): number {\n if (\"s\" in update) return update.s[0];\n if (\"p\" in update) return update.p[1];\n return update.type === \"snapshot\" ? update.revision : update.to;\n}\n","// `iterate/sdk/capnweb` — live state end to end: the snapshot+patch wire\n// protocol, the structural diff that produces patches, the client store that\n// reassembles them, and the SERVER engine (`LiveState`) that holds a value\n// and pushes minimal diffs to retained RPC subscribers. No socket, no keeper\n// — a Worker or Durable Object can import it without dragging the browser\n// session machinery into its bundle.\nimport { RpcTarget } from \"@iterate-com/capnweb\";\nimport type { LiveState as LiveStateEngine, LiveStateSubscription } from \"./engine.ts\";\nimport type { LiveStateSubscriptionOptions, LiveUpdate } from \"./protocol.ts\";\nimport { isThenable } from \"./retain.ts\";\nimport type { LiveStateRpc, LiveStateSubscriptionHandle } from \"./types.ts\";\n\ntype LiveStateSource<State extends object> = Pick<LiveStateEngine<State>, \"getState\" | \"subscribe\">;\n\ntype RefreshingLiveStateSource<State extends object> = {\n readonly live: LiveStateSource<State>;\n loadAndRefreshLive(): void | PromiseLike<void>;\n};\n\nexport { createLiveStateStore, type LiveStateStore } from \"./store.ts\";\nexport { applyPatch, diff } from \"./diff.ts\";\nexport { compactPatch, applyCompactPatch } from \"./compact.ts\";\nexport { isLiveStateSnapshot, liveStateRevision } from \"./protocol.ts\";\nexport type {\n CompactLiveStatePatch,\n LiveStateCursor,\n LiveStateRead,\n LiveStatePatch,\n LiveStateSubscriptionOptions,\n LiveUpdate,\n} from \"./protocol.ts\";\nexport { LiveState, type LiveStateSubscription } from \"./engine.ts\";\nexport type { LiveStateRpc, LiveStateSubscriptionHandle } from \"./types.ts\";\nexport {\n disposeIgnoredRpcResult,\n isThenable,\n retainCallback,\n type RetainedCallback,\n} from \"./retain.ts\";\n\n/**\n * Expose mutable server state as a read-only Cap'n Web capability.\n * Pass an in-memory `LiveState`, or a stream-processor registry whose engine\n * must hydrate before its first snapshot.\n */\nexport class LiveStateRpcTarget<State extends object>\n extends RpcTarget\n implements LiveStateRpc<State>\n{\n readonly #live: LiveStateSource<State>;\n readonly #beforeRead: (() => void | PromiseLike<void>) | undefined;\n\n constructor(source: LiveStateSource<State> | RefreshingLiveStateSource<State>) {\n super();\n if (\"loadAndRefreshLive\" in source) {\n this.#live = source.live;\n this.#beforeRead = () => source.loadAndRefreshLive();\n } else {\n this.#live = source;\n this.#beforeRead = undefined;\n }\n }\n\n async get() {\n const loading = this.#beforeRead?.();\n if (isThenable(loading)) await loading;\n return this.#live.getState();\n }\n\n async subscribe(\n onUpdate: (update: LiveUpdate<State>) => unknown,\n options?: LiveStateSubscriptionOptions,\n ) {\n const loading = this.#beforeRead?.();\n if (isThenable(loading)) await loading;\n return new LiveStateSubscriptionRpcTarget(this.#live.subscribe(onUpdate, options));\n }\n}\n\n/**\n * The wire handle for one subscription — `ping`/`unsubscribe` over RPC.\n * Exported for relays that build their subscription OUTSIDE a `LiveState`\n * engine (the worker-local liveState-socket relay) but must hand back the\n * same handle shape `LiveStateRpcTarget.subscribe` does.\n */\nexport class LiveStateSubscriptionRpcTarget\n extends RpcTarget\n implements LiveStateSubscriptionHandle\n{\n readonly #subscription: LiveStateSubscription;\n\n constructor(subscription: LiveStateSubscription) {\n super();\n this.#subscription = subscription;\n }\n\n ping() {\n return this.#subscription.ping();\n }\n\n unsubscribe() {\n this.#subscription.unsubscribe();\n }\n\n [Symbol.dispose]() {\n this.#subscription.unsubscribe();\n }\n}\n","// `iterate/sdk/capnweb` — the project-independent Cap'n Web SDK surface.\n// Re-exporting the transport primitives and LiveState from one entry keeps a\n// consuming app on the exact Cap'n Web class identity used inside Iterate.\nexport * from \"@iterate-com/capnweb\";\nexport * from \"./live-state/index.ts\";\n","// `serveItx` — serve a NARROWED itx to a browser FROM a project worker or\n// Durable Object, over the app's own `/api`, speaking exactly the handshake\n// the SDK's session keeper expects (`iterate/client`, `iterate/sdk/itx/react`):\n// a Cap'n Web root whose `authenticate()` returns a Session whose\n// `projects.get(slug)` is the project. A page on the app's own origin needs\n// no configuration — the keeper dials the page's `/api` by default — and\n// `useItx()`, `useStreamConnection()`, `useLiveState()` work as on the OS\n// dashboard.\n//\n// The caller decides WHO the visitor is before calling this and WHAT they may\n// reach: `scope.surface` lists the members served, as dotted paths down to\n// each method. The platform side is `project.scope({ path, surface: roots })`\n// — a project-confined, non-admin itx exposing only those roots; this module\n// is the member-level allowlist. The credential the browser presents to\n// `authenticate()` is not authority here and is ignored.\n//\n// WHY A RELAY: a Cap'n Web session cannot serialize a Workers-RPC stub, so\n// the served project is a tree of small Cap'n Web targets built from the\n// served members: each leaf forwards its call onto the stub, browser callbacks\n// are retained and re-wrapped as plain functions, and a stub a call returns\n// (a connection handle) is wrapped so its methods stay callable. Anything not\n// listed does not exist on the served project at all.\nimport {\n RpcTarget,\n newHttpBatchRpcResponse,\n newWorkersWebSocketRpcResponse,\n} from \"./sdk/capnweb/index.ts\";\nimport type { ItxAuthCredentials, Project } from \"./itx-api.generated.ts\";\n\nexport type ServeItxOptions = {\n /** The worker's own itx (`this.itx`, `await env.ITX.get()`). Never reaches the browser. */\n project: Project;\n /**\n * What the browser gets. `surface` lists the members served as DOTTED\n * paths down to each METHOD: a leaf is called, so an object-valued member\n * is listed through to its methods — `\"agent.liveState.get\"` and\n * `\"agent.liveState.subscribe\"`, never `\"agent.liveState\"`. A bare root\n * cannot be relayed because its members are unknown here.\n */\n scope: { path: string; surface: string[] };\n};\n\n/**\n * Answer an app's `/api` request with an itx session for one narrowed scope.\n * Call it from `fetch` after deciding who the visitor is:\n *\n * if (url.pathname === \"/api\") {\n * return await serveItx(request, {\n * project: await this.env.ITX.get(),\n * scope: {\n * path: `/agents/web/${visitorIdFrom(request)}`,\n * surface: [\n * \"agent.message\",\n * \"agent.liveState.get\",\n * \"agent.liveState.subscribe\",\n * \"agent.stream.openConnection\",\n * ],\n * },\n * });\n * }\n *\n * WebSocket upgrades carry the live session (stream connections, live\n * state); `POST` answers the client's HTTP-batch transport.\n */\nexport async function serveItx(request: Request, options: ServeItxOptions): Promise<Response> {\n const { path, surface } = options.scope;\n const roots = [...new Set(surface.map((entry) => entry.split(\".\", 1)[0]!))];\n const served = relayServedProject(options.project.scope({ path, surface: roots }), surface);\n const root = new ServedItxRoot(new ServedItxSession(served));\n if (request.method === \"POST\") return await newHttpBatchRpcResponse(request, root);\n if (request.headers.get(\"Upgrade\")?.toLowerCase() !== \"websocket\") {\n return new Response(\"This endpoint accepts WebSocket upgrades and POST batches.\", {\n status: 400,\n });\n }\n return newWorkersWebSocketRpcResponse(request, root);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// The relay.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * The served project: the relay tree over a scoped stub for these dotted\n * members. Exported for the relay's own tests; callers use `serveItx`.\n * @internal\n */\nexport function relayServedProject(scoped: unknown, surface: readonly string[]): RpcTarget {\n return relayNode(scoped, [], surfaceTree(surface));\n}\n\nconst LEAF = Symbol(\"served member\");\ntype SurfaceTree = { [member: string]: SurfaceTree | typeof LEAF };\n\n/** `[\"agent.message\", \"agent.stream.openConnection\"]` → nested member tree. */\nfunction surfaceTree(surface: readonly string[]): SurfaceTree {\n const tree: SurfaceTree = {};\n for (const entry of surface) {\n const segments = entry.split(\".\");\n if (segments.length < 2) {\n throw new Error(\n `serveItx cannot relay the bare root \"${entry}\": list the members to serve as dotted paths, e.g. \"${entry}.someMethod\"`,\n );\n }\n let node = tree;\n for (const [index, segment] of segments.entries()) {\n const last = index === segments.length - 1;\n const existing = node[segment];\n if (last) {\n if (existing !== undefined && existing !== LEAF) {\n throw new Error(`serveItx: \"${entry}\" is both a member and a branch of the surface`);\n }\n node[segment] = LEAF;\n } else {\n if (existing === LEAF) {\n throw new Error(`serveItx: \"${entry}\" is both a member and a branch of the surface`);\n }\n node = existing ?? (node[segment] = {});\n }\n }\n }\n return tree;\n}\n\n/**\n * One node of the served project: a real Cap'n Web target whose PROTOTYPE\n * carries exactly the served members — a method per leaf, a getter per\n * branch — plus `__describe`, which forwards so the platform's restricted\n * description comes back unchanged. A leaf IS a method call: an\n * object-valued member (`liveState`) must appear as a branch, i.e. listed\n * through to its methods.\n */\nfunction relayNode(stub: unknown, path: string[], tree: SurfaceTree): RpcTarget {\n class ServedNode extends RpcTarget {}\n for (const [member, child] of Object.entries(tree)) {\n Object.defineProperty(\n ServedNode.prototype,\n member,\n child === LEAF\n ? {\n configurable: true,\n value: (...args: unknown[]) => forward(stub, [...path, member], args),\n writable: true,\n }\n : { configurable: true, get: () => relayNode(stub, [...path, member], child) },\n );\n }\n Object.defineProperty(ServedNode.prototype, \"__describe\", {\n configurable: true,\n value: () => forward(stub, [...path, \"__describe\"], []),\n writable: true,\n });\n return new ServedNode();\n}\n\n/**\n * Walk `path` on the Workers-RPC stub (pipelined) and call the last segment\n * — as a genuine member call: extracting the method and `apply`ing it would\n * make the stub's proxy dial a remote member named \"apply\" with the stub\n * itself as an argument, which workerd refuses to serialize.\n */\nasync function forward(stub: unknown, path: string[], args: unknown[]): Promise<unknown> {\n let target = stub as Record<string, unknown>;\n for (const segment of path.slice(0, -1)) {\n target = target[segment] as Record<string, unknown>;\n }\n const callable = target as Record<string, (...callArgs: unknown[]) => unknown>;\n return relayResult(await callable[path.at(-1)!]!(...args.map((arg) => relayArgument(arg))));\n}\n\n/**\n * A browser callback arrives as a Cap'n Web stub function; the platform can\n * only call back a plain function, so wrap it. Plain data passes through,\n * recursively, because callbacks ride inside option objects.\n */\nfunction relayArgument(value: unknown): unknown {\n if (typeof value === \"function\") {\n // Cap'n Web releases a call's argument stubs when the call returns; a\n // callback the platform keeps for a connection's lifetime must be\n // retained past that — `dup()` is the stub's own way to say so. The\n // duplicate is released with the session.\n const stub = value as unknown as { dup?: () => unknown };\n const callback = (typeof stub.dup === \"function\" ? stub.dup() : value) as (\n ...callbackArgs: unknown[]\n ) => unknown;\n return (...callbackArgs: unknown[]) => callback(...callbackArgs);\n }\n if (Array.isArray(value)) return (value as unknown[]).map((entry) => relayArgument(entry));\n if (isPlainObject(value)) {\n const relayed: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) relayed[key] = relayArgument(entry);\n return relayed;\n }\n return value;\n}\n\n/** A stub a call returned (a connection handle) is wrapped so its methods stay callable. */\nfunction relayResult(value: unknown): unknown {\n return isWorkersRpcStub(value) ? new RelayedStub(value) : value;\n}\n\n/**\n * Workers-RPC stubs are callable proxies (`typeof` says \"function\") that\n * implement the dispose protocol; plain data has `Object.prototype` (or no\n * prototype), arrays are arrays, and a plain function has no disposer.\n * `cloudflare:workers` does not export the stub class to type against, so\n * the check is structural.\n */\nfunction isWorkersRpcStub(value: unknown): value is Disposable {\n return (\n (typeof value === \"function\" || (typeof value === \"object\" && value !== null)) &&\n !Array.isArray(value) &&\n !isPlainObject(value) &&\n typeof (value as Partial<Disposable>)[Symbol.dispose] === \"function\"\n );\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (value === null || typeof value !== \"object\") return false;\n const prototype = Object.getPrototypeOf(value) as unknown;\n return prototype === Object.prototype || prototype === null;\n}\n\n/** Names common protocols probe on any object; never forwarded. */\nconst NEVER_FORWARDED: ReadonlySet<string> = new Set([\n \"then\",\n \"toJSON\",\n \"asymmetricMatch\",\n \"constructor\",\n \"dup\",\n \"onRpcBroken\",\n]);\n\n/**\n * A stub a served call returned, as a Cap'n Web target: every unknown member\n * is a method forwarding onto the stub (a connection handle's `close()`,\n * `ping()`). Data properties of such a stub are not readable through the\n * relay — methods only.\n */\nclass RelayedStub extends RpcTarget {\n readonly #stub: Disposable;\n constructor(stub: Disposable) {\n super();\n this.#stub = stub;\n }\n static stubOf(relayed: RelayedStub): Disposable {\n return relayed.#stub;\n }\n}\nObject.setPrototypeOf(\n RelayedStub.prototype,\n new Proxy(Object.create(RpcTarget.prototype) as object, {\n get(hopTarget, key, receiver) {\n if (typeof key === \"symbol\" || key in hopTarget || NEVER_FORWARDED.has(key)) {\n return Reflect.get(hopTarget, key, receiver);\n }\n if (!(receiver instanceof RelayedStub)) return undefined;\n return (...args: unknown[]) => forward(RelayedStub.stubOf(receiver), [key], args);\n },\n }),\n);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// The root the stock client expects.\n// ─────────────────────────────────────────────────────────────────────────────\n\nclass ServedItxProjects extends RpcTarget {\n readonly #project: RpcTarget;\n\n constructor(project: RpcTarget) {\n super();\n this.#project = project;\n }\n\n /** The served project, whatever slug the page addresses it by. */\n get(_slug: string): RpcTarget {\n return this.#project;\n }\n}\n\nclass ServedItxSession extends RpcTarget {\n readonly #projects: ServedItxProjects;\n\n constructor(project: RpcTarget) {\n super();\n this.#projects = new ServedItxProjects(project);\n }\n\n get projects(): ServedItxProjects {\n return this.#projects;\n }\n\n /** Also the session keeper's liveness probe. */\n async __describe() {\n return {\n instructions: \"An app-served itx session: projects.get(slug) is the project.\",\n children: { projects: \"The served projects catalog.\" },\n };\n }\n}\n\nclass ServedItxRoot extends RpcTarget {\n readonly #session: ServedItxSession;\n\n constructor(session: ServedItxSession) {\n super();\n this.#session = session;\n }\n\n /** The stock client's `authenticate` call. Identity was decided by the caller of `serveItx`. */\n authenticate(_credentials: ItxAuthCredentials): ServedItxSession {\n return this.#session;\n }\n}\n","// `iterate/sdk` — what an iterate project repo imports from.\n//\n// The platform's public capability types (Project, Stream, StreamEvent,\n// ItxBinding, …) are generated from the platform's RpcTargets into\n// ./itx-api.generated.ts (regenerate from apps/os: `pnpm generate:itx-api`)\n// and re-exported here. Hand-written helpers for project code accumulate in\n// this file.\n//\n// Dynamic workers install and bundle this published package from their normal\n// package.json dependency. Preview deployments rewrite that dependency to the\n// exact pkg.pr.new artifact produced by the pull request.\nimport { DurableObject, RpcTarget, WorkerEntrypoint } from \"cloudflare:workers\";\nimport type {\n DynamicWorkerCapability,\n DynamicWorkerRef,\n ItxBinding,\n Project,\n ProjectAuthPolicy,\n StatefulDynamicWorkerRef,\n StreamEvent,\n StreamEventPager,\n} from \"./itx-api.generated.ts\";\nimport type { ProcessorStream, ProcessorStreamPager } from \"./processors/stream-handle.ts\";\nimport type {\n ProcessorRuntimeState,\n ProcessorSnapshot,\n StreamDeliveryBatch,\n StreamProcessorWakeRequest,\n StreamProcessorWakeResponse,\n} from \"./processors/rpc-types.ts\";\nimport {\n createStreamProcessorRegistry,\n ProcessorFacet,\n type ProcessorFacetAlarmProxy,\n type ProcessorFacetHost,\n type ProcessorFacetIdentity,\n type RegisterableProcessor,\n type RegisteredProcessorReads,\n type StreamProcessorRegistry,\n} from \"./processors/cloudflare.ts\";\n\n// `.ts`-suffixed like every relative import here; tsc's\n// rewriteRelativeImportExtensions keeps the declaration emit for the published\n// dist/sdk.d.ts, where it must resolve to dist/itx-api.generated.d.ts.\nexport type * from \"./itx-api.generated.ts\";\nexport { serveItx } from \"./serve-itx.ts\";\n\n/**\n * What the platform supplies to every dynamic worker: the `ITX` binding\n * (`get()` for capability method calls, `fetch()` for HTTP into sibling\n * workers) and `ITERATE_WORKER_VERSION` — the content-addressed identity of\n * what Worker Loader executes: modules and effective compatibility settings.\n * Pass the latter as the `version` of a hosted processor registry: an\n * executable change resets a crash-looping keepalive's backoff budget, while\n * an unrelated source-repository revision does not.\n */\ntype IterateEnv = { ITX: ItxBinding; ITERATE_WORKER_VERSION: string };\ntype PipelinedProject = ReturnType<ItxBinding[\"get\"]>;\n\n/**\n * Forward a request to one of the project's dynamic workers (an \"app\") —\n * pages, APIs, streaming bodies, and WebSocket upgrades all ride through.\n *\n * Why this is a real `env.ITX.fetch` hop with the ref in a header, and not a\n * method call on the app: workerd only performs protocol work — WebSocket 101\n * upgrades, streaming response bodies — through genuine `fetch` handler hops\n * between workers. Calling `fetch` (or anything else) on an app handle from\n * `project.workers.get(ref)` is ordinary RPC: arguments and results are\n * serialized copies, so a Response carrying a socket cannot cross it (workerd\n * throws a DataCloneError). And because a fetch hop's only side channel for\n * \"which worker do I mean\" is the request itself, the target ref rides the\n * x-iterate-worker-dispatch header (JSON `{ ref, buildBudgetMs? }` — the same\n * ref shape `project.workers.get` takes). Method calls on apps still go\n * through `project.workers.get(ref)` RPC dispatch; HTTP never does.\n *\n * A cold build past `buildBudgetMs` (default 15s) answers a 503 building page\n * that refreshes itself, marked with x-iterate-worker-building — intercept\n * that response here to render your own.\n */\nasync function fetchDynamicWorker(\n env: IterateEnv,\n req: Request,\n ref: DynamicWorkerRef,\n opts?: { buildBudgetMs?: number },\n): Promise<Response> {\n const headers = new Headers(req.headers);\n headers.set(\n \"x-iterate-worker-dispatch\",\n JSON.stringify({ buildBudgetMs: opts?.buildBudgetMs ?? 15_000, ref }),\n );\n return await env.ITX.fetch(new Request(req, { headers }));\n}\n\n/**\n * Walk a dotted capability path over the worker instance and invoke the final\n * segment. The platform dispatches `itx.worker.<path>` calls as ONE flattened\n * `invokeCapability({ path, args })`, and this walks it in userland: nothing\n * ever crosses RPC except the final method's arguments and result, so a\n * getter on the worker class can hand back a whole vendor SDK (installed from\n * package.json) — or any nested surface — in a single round trip.\n */\nasync function invokeCapability(\n receiver: unknown,\n { args = [], path }: { args?: unknown[]; path: string[] },\n): Promise<unknown> {\n for (const segment of path.slice(0, -1)) {\n receiver = await Reflect.get(Object(receiver), segment);\n }\n const method = path.at(-1)!;\n const handler = Reflect.get(Object(receiver), method);\n if (typeof handler !== \"function\") {\n throw new Error(`\"${path.join(\".\")}\" is not a method on this worker`);\n }\n return await Reflect.apply(handler, receiver, args);\n}\n\n/** Dispose an RPC stub, tolerating stubs without a disposer and disposers\n * that throw — cleanup must never mask the value it was cleaning up after. */\nfunction disposeStub(stub: unknown): void {\n try {\n (stub as Partial<Disposable>)[Symbol.dispose]?.();\n } catch {}\n}\n\n/** Open a project itx session, use it, dispose it. RPC stubs from\n * `env.ITX.get()` must not outlive the invocation that dialed them, so every\n * operation opens its own session. */\nasync function withProject<T>(env: IterateEnv, fn: (project: Project) => Promise<T>): Promise<T> {\n const project = await env.ITX.get();\n try {\n return await fn(project);\n } finally {\n disposeStub(project);\n }\n}\n\n/**\n * Detach plain data returned by Workers RPC before releasing the per-call\n * result capability. Disposing the project root does not release values\n * obtained through it; each stream call owns its own result reference.\n */\nfunction detachPlainRpcResult<T>(result: T): T {\n if (result === null || (typeof result !== \"object\" && typeof result !== \"function\")) {\n return result;\n }\n // ProcessorStream returns JSON-shaped data only. Workers RPC adds a hidden\n // disposer that is absent from the generated data types; a shallow spread\n // preserves that data and drops the capability, but TypeScript cannot prove\n // that the generic spread still has T's exact shape.\n const detached = Array.isArray(result) ? [...result] : { ...result };\n Reflect.deleteProperty(detached, Symbol.dispose);\n try {\n const dispose = Reflect.get(result, Symbol.dispose);\n if (typeof dispose === \"function\") Reflect.apply(dispose, result, []);\n } catch (error) {\n // The plain data is already detached and the remote operation succeeded.\n // Keep cleanup failure visible without rewriting that outcome as failure.\n console.warn(\"project stream RPC result dispose failed after detaching plain data\", { error });\n }\n return detached as T;\n}\n\n/**\n * A view of `target` with `overrides` in front and everything else passed\n * through. Proxies (not spreads or Object.create) because DurableObjectState\n * and DurableObjectStorage are host objects: their methods must be invoked\n * with the REAL receiver or workerd throws \"Illegal invocation\".\n */\nfunction overlay<T extends object>(target: T, overrides: Record<PropertyKey, unknown>): T {\n return new Proxy(target, {\n get(object, prop) {\n // Own keys only: `in` would match Object.prototype inherits\n // (toString, …) and shadow the host object's.\n if (Object.hasOwn(overrides, prop)) return overrides[prop];\n const value = Reflect.get(object, prop, object);\n return typeof value === \"function\" ? value.bind(object) : value;\n },\n });\n}\n\n/**\n * A {@link ProcessorStream} over the project stream at `path`, dialed through\n * the platform ITX binding — the stream handle a worker-hosted stream\n * processor registry needs (`iterate/processors`; see the config-repo\n * template's guestbook for the full hosting shape). RPC stubs from\n * `env.ITX.get()` must not outlive the invocation that dialed them, so every\n * operation opens, uses, and disposes its own session; `readEvents` owns one\n * session for its pager's lifetime (scope it with `using`, like any pager).\n */\nexport function itxProjectStream(env: IterateEnv, path: string): ProcessorStream {\n const withStream = <T>(fn: (streams: Project[\"streams\"]) => Promise<T>): Promise<T> =>\n withProject(env, (project) => fn(project.streams)).then(detachPlainRpcResult);\n return {\n append: (...events) => withStream((streams) => streams.get(path).append(...events)),\n appendIfStreamId: (args) => withStream((streams) => streams.get(path).appendIfStreamId(args)),\n getEvent: (args) => withStream((streams) => streams.get(path).getEvent(args)),\n getEvents: (args) => withStream((streams) => streams.get(path).getEvents(args)),\n getEventPage: (args) => withStream((streams) => streams.get(path).getEventPage(args)),\n readEvents: (args): ProcessorStreamPager => {\n let opened: Promise<{ pager: StreamEventPager; project: Disposable }> | undefined;\n let closed = false;\n return {\n next: async () => {\n if (closed) return [];\n opened ??= env.ITX.get().then((project) => ({\n pager: project.streams.get(path).readEvents(args),\n project,\n }));\n const { pager } = await opened;\n return detachPlainRpcResult(await pager.next());\n },\n [Symbol.dispose]() {\n closed = true;\n void opened\n ?.then(({ pager, project }) => {\n disposeStub(pager);\n disposeStub(project);\n })\n .catch(() => {});\n },\n };\n },\n at: (siblingPath) => itxProjectStream(env, siblingPath),\n };\n}\n\n/** Where the platform-delivered self ref lives in this worker's own storage\n * (see {@link IterateDurableObject.__stashSelfRef}). */\nconst SELF_REF_STORAGE_KEY = \"iterate:self-ref\";\n\n/**\n * Durable alarms for a stateful dynamic worker, presented as the ordinary\n * `DurableObjectState` alarm API — what `IterateDurableObject` installs as\n * `this.ctx`, so alarms on stateful workers just work.\n *\n * workerd does not implement alarms for facet-hosted Durable Objects — the\n * hosting model for stateful dynamic workers (workerd#6810; a facet\n * `setAlarm` even appears to succeed, then poisons the commit path). So the\n * platform Durable Object that hosts this worker keeps the real alarm on its\n * behalf: the trio here dials `itx.workers.get(ref).setAlarm/getAlarm` on the\n * worker's own ref — delivered by the host before any other traffic and\n * stashed durably ({@link IterateDurableObject.__stashSelfRef}) — and the\n * host's fire calls this class's `alarm(alarmInfo)` method, retried by the\n * platform if it throws, exactly like a native alarm handler.\n *\n * Everything except the three alarm methods is the worker's own `ctx`,\n * untouched (`storage.kv`, `waitUntil`, WebSocket APIs, …), so code written\n * against this state uses only standard Durable Object concepts, and if\n * workerd ships facet alarms the shim disappears without a caller changing.\n * Honest divergences: the alarm methods ignore the native `options` bag,\n * alarms armed inside `storage.transaction()` bypass the shim, and a class\n * with no `alarm()` handler fails at fire time (native `setAlarm` rejects at\n * arm time; the shim cannot check).\n */\nfunction selfAlarmState<State extends DurableObjectState>(ctx: State, env: IterateEnv): State {\n const withSelf = <T>(fn: (worker: DynamicWorkerCapability) => Promise<T>): Promise<T> => {\n const ref = ctx.storage.kv.get<StatefulDynamicWorkerRef>(SELF_REF_STORAGE_KEY);\n if (ref === undefined) {\n // Unreachable after any platform contact — every call, fetch, and\n // alarm fire delivers the ref first. Constructor bodies run before\n // that first contact, hence the carve-out in the error.\n throw new Error(\n \"this worker's own ref has not been delivered yet — alarms are unavailable in the \" +\n \"constructor; arm from a handler instead\",\n );\n }\n return withProject(env, (project) => fn(project.workers.get(ref)));\n };\n return overlay(ctx, {\n storage: overlay(ctx.storage, {\n setAlarm: (scheduledTime: number | Date) =>\n withSelf((worker) =>\n worker.setAlarm(\n typeof scheduledTime === \"number\" ? scheduledTime : scheduledTime.getTime(),\n ),\n ),\n deleteAlarm: () => withSelf((worker) => worker.setAlarm(null)),\n getAlarm: () => withSelf((worker) => worker.getAlarm()),\n }),\n });\n}\n\n/**\n * Base class for stateless dynamic workers — the project worker (a repo's\n * default export) and stateless apps. A WorkerEntrypoint whose env carries\n * the platform's itx binding, plus the platform ceremony every worker needs\n * but shouldn't have to hand-roll:\n *\n * - `processEventBatch` / `processEvent`: the platform delivers every\n * committed DURABLE event on every stream in the project as checkpointed\n * per-stream batches — in per-stream order, at-least-once. Events appended\n * with `ephemeral: true` (LLM streaming chunks and other transient\n * signals) never arrive here. Session callbacks can receive one while its\n * body remains in the Stream Durable Object's bounded memory buffer; react\n * here to the durable fact that supersedes it (e.g. an assistant-role\n * `agents/context-added` item). The base unpacks batches\n * into one `processEvent(event)` call per event; override `processEvent` to react\n * (one `if` per reaction, keyed on event.path + event.type). Throwing (or a worker that fails to build) leaves that\n * stream's checkpoint in place and the whole batch is redelivered later,\n * so return normally to advance past events you don't care about — and\n * anything a reaction appends should carry an idempotency key.\n * - `invokeCapability`: the flattened `itx.worker.<path>` dispatcher — add a\n * getter or method to your class and it becomes a capability surface.\n * - `fetchDynamicWorker`: forward HTTP (WebSockets included) to another of\n * the project's dynamic workers.\n */\nexport class IterateWorkerEntrypoint<\n Env extends IterateEnv = IterateEnv,\n> extends WorkerEntrypoint<Env> {\n #itx: PipelinedProject | undefined;\n\n constructor(ctx: ConstructorParameters<typeof WorkerEntrypoint<Env>>[0], env: Env) {\n super(ctx, env);\n this.env = env;\n }\n\n /**\n * This invocation's project-root itx. Cloudflare constructs one\n * WorkerEntrypoint per invocation and releases its RPC stubs when that\n * execution context ends. The getter returns the native Workers RPC\n * promise-proxy, so `await this.itx.agents.list()` pipelines immediately;\n * repeated access within one event batch or fetch reuses the same handle.\n *\n * Durable Objects have a longer, multi-invocation lifetime and no eviction\n * callback, so IterateDurableObject deliberately does not expose this\n * memoized getter.\n */\n protected get itx(): PipelinedProject {\n return (this.#itx ??= this.env.ITX.get());\n }\n\n /**\n * Run the project-member auth partial fetch without transferring the app's\n * request body on paths auth only inspects. The callback POST belongs to\n * auth, so that one path deliberately transfers the complete request.\n */\n protected async fetchProjectAuth(\n request: Request,\n policy: ProjectAuthPolicy,\n ): Promise<Response | null> {\n if (request.method === \"POST\" && new URL(request.url).pathname === \"/_iterate/auth/callback\") {\n return await this.itx.auth.get(policy).fetch(request);\n }\n\n const authRequest = new Request(request.url, {\n headers: request.headers,\n method: request.method,\n });\n return await this.itx.auth.get(policy).fetch(authRequest);\n }\n\n /** See `fetchDynamicWorker` at module level: a real fetch hop into a\n * sibling dynamic worker — the only lane that can carry WebSocket upgrades\n * and streaming bodies (RPC serializes; sockets can't cross it). */\n protected async fetchDynamicWorker(\n req: Request,\n ref: DynamicWorkerRef,\n opts?: { buildBudgetMs?: number },\n ): Promise<Response> {\n return await fetchDynamicWorker(this.env, req, ref, opts);\n }\n\n /** Platform entry point for event delivery (see the class docstring for\n * the delivery contract). Override `processEvent`, not this, unless you\n * need whole-batch atomicity. */\n async processEventBatch(batch: StreamDeliveryBatch): Promise<void> {\n for (const event of batch.events) await this.processEvent(event);\n }\n\n /** Called once per delivered event, in per-stream order, at-least-once.\n * Override to react; the default ignores everything. */\n protected async processEvent(_event: StreamEvent): Promise<void> {}\n\n /** Platform entry point for flattened `itx.worker.<path>` capability\n * calls (see the class docstring). */\n async invokeCapability(input: { args?: unknown[]; path: string[] }): Promise<unknown> {\n return await invokeCapability(this, input);\n }\n}\n\n/**\n * Base class for stateful dynamic workers (apps hosted as Durable Objects\n * under a `durableWorkerKey`). Same platform surface as\n * `IterateWorkerEntrypoint` — see its docstring for the event-delivery and\n * capability-dispatch contracts — on a DurableObject, so state survives\n * across requests and WebSockets can be served from `fetch`. Durable alarms\n * work natively — `this.ctx.storage.setAlarm(...)` plus an `alarm()` method\n * on the class — even though this object is hosted as a workerd facet with\n * no alarms of its own; see {@link selfAlarmState} for the mechanism.\n */\nexport class IterateDurableObject<Env extends IterateEnv = IterateEnv> extends DurableObject<Env> {\n constructor(ctx: ConstructorParameters<typeof DurableObject<Env>>[0], env: Env) {\n super(ctx, env);\n this.env = env;\n // Read back through the property so the overlay carries the exact ctx\n // type the base class declares in every typecheck context.\n this.ctx = selfAlarmState(this.ctx, this.env);\n }\n\n /**\n * Platform bootstrap door: the Durable Object hosting this worker delivers\n * the worker's OWN ref here before any other traffic in its incarnation —\n * a facet has no channel to learn its identity by itself, and the ref is\n * what the alarm shim dials (`itx.workers.get(ref)` resolves back to the\n * hosting DO). Stashed durably, so a warm facet under a fresh host needs\n * no re-delivery to keep working.\n */\n __stashSelfRef(ref: StatefulDynamicWorkerRef): void {\n this.ctx.storage.kv.put(SELF_REF_STORAGE_KEY, ref);\n }\n\n /** A real fetch hop into a sibling dynamic worker — see\n * `IterateWorkerEntrypoint.fetchDynamicWorker`. */\n protected async fetchDynamicWorker(\n req: Request,\n ref: DynamicWorkerRef,\n opts?: { buildBudgetMs?: number },\n ): Promise<Response> {\n return await fetchDynamicWorker(this.env, req, ref, opts);\n }\n\n /** Platform entry point for event delivery — see\n * `IterateWorkerEntrypoint.processEventBatch`. */\n async processEventBatch(batch: StreamDeliveryBatch): Promise<void> {\n for (const event of batch.events) await this.processEvent(event);\n }\n\n /** Called once per delivered event — see\n * `IterateWorkerEntrypoint.processEvent`. */\n protected async processEvent(_event: StreamEvent): Promise<void> {}\n\n /** Platform entry point for flattened `itx.worker.<path>` capability\n * calls — see `IterateWorkerEntrypoint.invokeCapability`. */\n async invokeCapability(input: { args?: unknown[]; path: string[] }): Promise<unknown> {\n return await invokeCapability(this, input);\n }\n}\n// =============================================================================\n// Durable Object stream-processor hosting.\n// =============================================================================\n\nconst HOST_PROJECT_ID_KEY = \"iterate:processor-host:project-id\";\nconst HOST_STREAM_PATH_KEY = \"iterate:processor-host:stream-path\";\n\ntype WakeRegistryLookup = (\n projectId: string,\n path: string,\n) => Pick<StreamProcessorRegistry<object>, \"wakeStreamProcessor\">;\n\n/**\n * The worker's `processor` node: the wake door the stream spine dials PLUS\n * the public read verbs of the standard processor contract\n * (`StreamProcessorRpc`). The reads serve the registered runner directly, so\n * `streams.get(path).subscriptions.get(name).processor` and the stream's\n * `waitUntilProcessed` barrier reach an expression-placed dynamic worker's\n * processor with no extra wiring — the stream replays those verbs onto this\n * node (the stored wake expression minus its trailing wake step). It crosses\n * Workers RPC as a property read before its method is called, so it must be\n * a real RpcTarget.\n */\nclass ProcessorWakeTarget extends RpcTarget {\n readonly #registryFor: WakeRegistryLookup;\n readonly #reads: () => Promise<RegisteredProcessorReads<object>>;\n\n constructor(\n registryFor: WakeRegistryLookup,\n reads: () => Promise<RegisteredProcessorReads<object>>,\n ) {\n super();\n this.#registryFor = registryFor;\n this.#reads = reads;\n }\n\n async wakeStreamProcessor(\n request: StreamProcessorWakeRequest,\n ): Promise<StreamProcessorWakeResponse> {\n if (request.stream.projectId === null) {\n throw new Error(\"hosted stream processors require project streams\");\n }\n // The registry fences mismatched coordinates itself, so a host with a\n // fixed home stream rejects a stray wake instead of adopting its path.\n return await this.#registryFor(\n request.stream.projectId,\n request.stream.path,\n ).wakeStreamProcessor(request);\n }\n\n /** One consistent read of the committed fold, pulled through the durable\n * stream tail first (read-your-writes, the hosting relays' catch-up leg). */\n async snapshot(): Promise<ProcessorSnapshot<object>> {\n const reads = await this.#reads();\n await reads.catchUp();\n return await reads.snapshot();\n }\n\n async getRuntimeState(): Promise<ProcessorRuntimeState<object>> {\n return await (await this.#reads()).getRuntimeState();\n }\n\n /** Offset barrier against the runner's committed fold. The runner's waiter\n * self-pulls, so its timeout bounds the whole read-your-writes operation. */\n async waitUntilProcessed(input: { offset: number; timeoutMs?: number }): Promise<void> {\n await (await this.#reads()).waitUntilEvent(input);\n }\n}\n\n/**\n * The platform deps the host derives and hands a processor factory: the home\n * stream and its coordinates. Everything else a processor needs (clocks,\n * clients, itx-backed capabilities) the factory wires off `this.env`.\n */\nexport type ProcessorHostDeps = {\n path: string;\n projectId: string;\n stream: ProcessorStream;\n};\n\nexport type ProcessorHost<State extends object> = {\n /** The lazily built registry. Outside a wake request the coordinates come\n * from the durable cache, the static `path`, or one project dial. */\n registry(): Promise<StreamProcessorRegistry<State>>;\n /** One consistent read of the hosted processor's committed fold. */\n snapshot(): Promise<ProcessorSnapshot<State>>;\n /** Assign to a `processor` getter — the wake door the stream spine dials,\n * which also serves the standard read verbs (snapshot / getRuntimeState /\n * waitUntilProcessed) so the subscriptions catalog and the stream barrier\n * reach this processor. */\n readonly wakeProcessor: ProcessorWakeTarget;\n /** Route the Durable Object's `alarm()` here. Nothing cached means no\n * registry ever armed one, so a stray fire is a no-op. */\n handleAlarm(alarmInfo?: AlarmInvocationInfo): Promise<void>;\n};\n\n/**\n * Host one stream processor in a Durable Object: the registry ceremony, the\n * RPC-safe wake door, the alarm multiplex, and the durable coordinate cache\n * in one place, so an app class is only its processor plus its own verbs.\n *\n * With `path` the host serves one fixed home stream (the guestbook shape).\n * Without it the host learns its stream from the first wake request and\n * caches the coordinates durably (one Durable Object per dynamic stream,\n * keyed by the ref that names it). One host per Durable Object — the cache\n * keys assume it.\n */\nexport function createProcessorHost<State extends object = Record<string, unknown>>(args: {\n ctx: DurableObjectState;\n env: IterateEnv;\n path?: string;\n /** Post-eviction keepalive recovery, for processors that owe registered work. */\n recovery?: boolean;\n createProcessor(deps: ProcessorHostDeps): RegisterableProcessor;\n}): ProcessorHost<State> {\n let built:\n | { reads: RegisteredProcessorReads<State>; registry: StreamProcessorRegistry<State> }\n | undefined;\n\n const ensure = (projectId: string, path: string) => {\n if (built === undefined) {\n args.ctx.storage.kv.put(HOST_PROJECT_ID_KEY, projectId);\n args.ctx.storage.kv.put(HOST_STREAM_PATH_KEY, path);\n const stream = itxProjectStream(args.env, path);\n const registry = createStreamProcessorRegistry<State>(args.ctx, {\n path,\n projectId,\n stream,\n version: args.env.ITERATE_WORKER_VERSION,\n });\n const processor = registry.register(\n args.createProcessor({ path, projectId, stream }),\n args.recovery === undefined ? undefined : { recovery: args.recovery },\n );\n built = {\n // `RegisterableProcessor` erases the contract, so `reads` comes back\n // `<unknown>`; the caller's `State` is the same assertion it already\n // makes for the registry generic above.\n reads: registry.reads(processor) as RegisteredProcessorReads<State>,\n registry,\n };\n }\n return built;\n };\n\n const buildOutsideWake = async () => {\n if (built !== undefined) return built;\n const path = args.path ?? args.ctx.storage.kv.get<string>(HOST_STREAM_PATH_KEY);\n if (path === undefined) {\n throw new Error(\"this processor host learns its stream from the first wake request\");\n }\n const projectId =\n args.ctx.storage.kv.get<string>(HOST_PROJECT_ID_KEY) ??\n (await withProject(args.env, async (project) => await project.projectId));\n return ensure(projectId, path);\n };\n\n return {\n registry: async () => (await buildOutsideWake()).registry,\n snapshot: async () => await (await buildOutsideWake()).reads.snapshot(),\n wakeProcessor: new ProcessorWakeTarget(\n (projectId, path) => ensure(projectId, args.path ?? path).registry,\n async () => (await buildOutsideWake()).reads as RegisteredProcessorReads<object>,\n ),\n async handleAlarm(alarmInfo?: AlarmInvocationInfo) {\n const projectId = args.ctx.storage.kv.get<string>(HOST_PROJECT_ID_KEY);\n const path = args.path ?? args.ctx.storage.kv.get<string>(HOST_STREAM_PATH_KEY);\n if (projectId === undefined || path === undefined) return;\n await ensure(projectId, path).registry.handleAlarm(alarmInfo);\n },\n };\n}\n\n/**\n * Ergonomic base for a Durable Object that hosts exactly one stream processor.\n *\n * It collapses the host boilerplate every processor app writes by hand today —\n * a {@link createProcessorHost} field, an `alarm()` that forwards to it, and a\n * `processor` getter exposing the wake door — down to a single\n * {@link createProcessor} factory. First-party and userspace processors are\n * authored the SAME way: all a subclass writes is how to build its processor\n * from the host-derived platform deps (`{ stream, path, projectId }`) plus\n * whatever it wires off `this.env`. That single seam is why a built-in\n * processor forks into userspace with no change to the processor itself — only\n * the dep wiring in `createProcessor` differs.\n *\n * Host-agnostic: the exact same class runs as its own Durable Object, as a\n * facet of the Stream DO, or as a facet of another DO. Only the alarm adapter\n * (native vs parent-proxied) and who dials the wake door differ per host, and\n * the host owns both.\n *\n * ```ts\n * export class GuestbookDurableObject extends StreamProcessorDurableObject<GuestbookState> {\n * protected readonly streamPath = guestbookStreamPath; // fixed home stream\n * protected createProcessor(deps: ProcessorHostDeps) {\n * return new GuestbookProcessor(deps);\n * }\n * // alarm(), the `processor` wake door, snapshot(), registry() — inherited.\n * }\n * ```\n */\nexport abstract class StreamProcessorDurableObject<\n State extends object = Record<string, unknown>,\n Env extends IterateEnv = IterateEnv,\n> extends IterateDurableObject<Env> {\n /**\n * Build the processor from the host-derived platform deps. Wire your own deps\n * (clocks, clients, itx-backed capabilities) off `this.env` here — this is\n * the one method a processor app must implement, and the seam that keeps a\n * built-in processor forkable into userspace unchanged.\n */\n protected abstract createProcessor(deps: ProcessorHostDeps): RegisterableProcessor;\n\n /**\n * A fixed home stream path (the guestbook shape). Leave undefined to learn\n * the stream from the first wake request and cache the coordinates durably\n * (one Durable Object per dynamic stream).\n */\n protected readonly streamPath?: string;\n\n /**\n * Post-eviction keepalive recovery, for processors that owe registered\n * background work (the obligation pattern). Off by default.\n */\n protected readonly recovery: boolean = false;\n\n /**\n * Built lazily on first door/alarm access — deliberately NOT a field\n * initializer. A base-class field initializer runs before the subclass's\n * `streamPath` / `recovery` field initializers, so it would capture the base\n * defaults instead of a subclass's overrides; reading them on first use\n * sidesteps that ordering trap. Memoized because the host owns the registry\n * cache, and one host per Durable Object is assumed.\n */\n #memoHost?: ProcessorHost<State>;\n get #host(): ProcessorHost<State> {\n return (this.#memoHost ??= createProcessorHost<State>({\n ctx: this.ctx,\n env: this.env,\n path: this.streamPath,\n recovery: this.recovery,\n createProcessor: (deps) => this.createProcessor(deps),\n }));\n }\n\n /**\n * The processor node the stream spine dials: the wake door plus the standard\n * read verbs (`snapshot` / `getRuntimeState` / `waitUntilProcessed`), so the\n * subscriptions catalog and the stream barrier reach this processor. It\n * crosses Workers RPC as a property read before its method is called, so it\n * must be a real RpcTarget — which the host guarantees.\n */\n get processor() {\n return this.#host.wakeProcessor;\n }\n\n /** Route the Durable Object's native `alarm()` into the host's multiplex. */\n async alarm(alarmInfo?: AlarmInvocationInfo): Promise<void> {\n await this.#host.handleAlarm(alarmInfo);\n }\n\n /**\n * One consistent read of the hosted processor's committed fold, for a\n * subclass's own read verbs (e.g. a `getState()`).\n */\n protected snapshot(): Promise<ProcessorSnapshot<State>> {\n return this.#host.snapshot();\n }\n\n /**\n * The lazily built registry, for subclasses that drive catch-up / live\n * refresh directly (the guestbook's HTTP + append flow).\n */\n protected registry(): Promise<StreamProcessorRegistry<State>> {\n return this.#host.registry();\n }\n}\n\n/**\n * Ergonomic base for a userspace stream processor hosted as a FACET of the\n * platform's Stream Durable Object — the `facet-processor` subscription with a\n * `userspace` source, whose `StatefulDynamicWorkerRef` names THIS class. The\n * Stream DO loads the class from the project's source and starts it with\n * `ctx.facets.get(name, …)`, so it runs INSIDE the stream it serves: wakes are\n * an in-process parent→facet dial (no itx wake expression), and checkpoints /\n * projections land in the facet's own private SQLite.\n *\n * Same authoring seam as {@link StreamProcessorDurableObject} — a subclass\n * writes only `createProcessor` (and sets `recovery` when it owes background\n * work) — so a processor forks between \"its own Durable Object\" and \"a facet\n * of its stream\" with no change to the processor itself. The two differences a\n * facet forces, both handled here:\n *\n * - **No native alarm.** workerd does not implement alarms for facets\n * (workerd#6810), so this base routes the registry's keepalive/recovery\n * alarm through the parent's real platform alarm over itx —\n * `streams.get(path).proxySetAlarm/proxyDeleteAlarm/proxyGetAlarm`, the\n * itx-channel twin of a stateful worker's `workers.get(ref).setAlarm`. The\n * parent fires it back as {@link ProcessorFacet.handleAlarm}. NEVER define\n * `alarm()` on a subclass (the base throws): a facet's native `setAlarm`\n * would appear to succeed, then poison its output gate.\n * - **Identity by first-contact `configure`, not the constructor.** The Stream\n * DO delivers `{ parentName, projectId, path }`; the base stashes it and\n * rebuilds the host from that stash on every incarnation (see\n * {@link ProcessorFacet}).\n *\n * ```ts\n * export class GuestbookFacet extends StreamProcessorFacet {\n * protected readonly recovery = true; // owes background work\n * protected createProcessor(deps: ProcessorHostDeps) {\n * return new GuestbookProcessor(deps);\n * }\n * }\n * ```\n */\nexport abstract class StreamProcessorFacet<\n Env extends IterateEnv = IterateEnv,\n> extends ProcessorFacet<Env> {\n /**\n * Build the processor from the host-derived platform deps, wiring your own\n * deps (clocks, clients, itx-backed capabilities) off `this.env` — the one\n * method a facet-hosted processor app implements, identical to\n * {@link StreamProcessorDurableObject.createProcessor}.\n */\n protected abstract createProcessor(deps: ProcessorHostDeps): RegisterableProcessor;\n\n /**\n * Post-eviction keepalive recovery, for processors that owe registered\n * background work (the obligation pattern). Off by default.\n */\n protected readonly recovery: boolean = false;\n\n /**\n * Dial the parent stream's alarm proxy over itx, resolved PER CALL (a stub\n * must not outlive its RPC turn), each verb opening and disposing its own\n * session like {@link itxProjectStream}. `identity.path` is the coordinate;\n * `parentName` is unused here (userspace facets have no `env.STREAM`).\n */\n protected parentAlarms(identity: ProcessorFacetIdentity): ProcessorFacetAlarmProxy {\n const env = this.env;\n const { path } = identity;\n return {\n proxySetAlarm: (scheduledTimeMs) =>\n withProject(env, (project) => project.streams.get(path).proxySetAlarm(scheduledTimeMs)),\n proxyDeleteAlarm: () =>\n withProject(env, (project) => project.streams.get(path).proxyDeleteAlarm()),\n proxyGetAlarm: () => withProject(env, (project) => project.streams.get(path).proxyGetAlarm()),\n };\n }\n\n /**\n * Build the host wiring from the stashed identity: the stream handle is the\n * same itx-backed {@link itxProjectStream} a worker-hosted processor appends\n * through, and the single processor is registered under this facet's name.\n */\n protected createHost(identity: ProcessorFacetIdentity): ProcessorFacetHost {\n if (identity.projectId === null) {\n throw new Error(\"userspace stream-processor facets require a project stream\");\n }\n const { projectId, path } = identity;\n const stream = itxProjectStream(this.env, path);\n return {\n stream,\n version: this.env.ITERATE_WORKER_VERSION,\n registerProcessors: (registry) => {\n registry.register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pB;;CAGA,MAAM,MAAM,WAAgD;EAC1D,MAAM,KAAKA,MAAM,YAAY,SAAS;CACxC;;;;;CAMA,WAAwD;EACtD,OAAO,KAAKA,MAAM,SAAS;CAC7B;;;;;CAMA,WAA8D;EAC5D,OAAO,KAAKA,MAAM,SAAS;CAC7B;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAsB,uBAAtB,cAEU,eAAoB;;;;;CAa5B,WAAuC;;;;;;;CAQvC,aAAuB,UAA4D;EACjF,MAAM,MAAM,KAAK;EACjB,MAAM,EAAE,SAAS;EACjB,OAAO;GACL,gBAAgB,oBACd,YAAY,MAAM,YAAY,QAAQ,QAAQ,IAAI,IAAI,CAAC,CAAC,cAAc,eAAe,CAAC;GACxF,wBACE,YAAY,MAAM,YAAY,QAAQ,QAAQ,IAAI,IAAI,CAAC,CAAC,iBAAiB,CAAC;GAC5E,qBAAqB,YAAY,MAAM,YAAY,QAAQ,QAAQ,IAAI,IAAI,CAAC,CAAC,cAAc,CAAC;EAC9F;CACF;;;;;;CAOA,WAAqB,UAAsD;EACzE,IAAI,SAAS,cAAc,MACzB,MAAM,IAAI,MAAM,4DAA4D;EAE9E,MAAM,EAAE,WAAW,SAAS;EAC5B,MAAM,SAAS,iBAAiB,KAAK,KAAK,IAAI;EAC9C,OAAO;GACL;GACA,SAAS,KAAK,IAAI;GAClB,qBAAqB,aAAa;IAChC,SAAS,SAAS,KAAK,gBAAgB;KAAE;KAAM;KAAW;IAAO,CAAC,GAAG,EACnE,UAAU,KAAK,SACjB,CAAC;GACH;EACF;CACF;AACF"}
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,339 @@
1
+ import { DurableObject, RpcTarget, WorkerEntrypoint } from "cloudflare:workers";
2
+ import type { DynamicWorkerRef, ItxBinding, ProjectAuthPolicy, StatefulDynamicWorkerRef, StreamEvent } from "./itx-api.generated.ts";
3
+ import type { ProcessorStream } from "./processors/stream-handle.ts";
4
+ import type { ProcessorRuntimeState, ProcessorSnapshot, StreamDeliveryBatch, StreamProcessorWakeRequest, StreamProcessorWakeResponse } from "./processors/rpc-types.ts";
5
+ import { ProcessorFacet, type ProcessorFacetAlarmProxy, type ProcessorFacetHost, type ProcessorFacetIdentity, type RegisterableProcessor, type RegisteredProcessorReads, type StreamProcessorRegistry } from "./processors/cloudflare.ts";
6
+ export type * from "./itx-api.generated.ts";
7
+ export { serveItx } from "./serve-itx.ts";
8
+ /**
9
+ * What the platform supplies to every dynamic worker: the `ITX` binding
10
+ * (`get()` for capability method calls, `fetch()` for HTTP into sibling
11
+ * workers) and `ITERATE_WORKER_VERSION` — the content-addressed identity of
12
+ * what Worker Loader executes: modules and effective compatibility settings.
13
+ * Pass the latter as the `version` of a hosted processor registry: an
14
+ * executable change resets a crash-looping keepalive's backoff budget, while
15
+ * an unrelated source-repository revision does not.
16
+ */
17
+ type IterateEnv = {
18
+ ITX: ItxBinding;
19
+ ITERATE_WORKER_VERSION: string;
20
+ };
21
+ type PipelinedProject = ReturnType<ItxBinding["get"]>;
22
+ /**
23
+ * A {@link ProcessorStream} over the project stream at `path`, dialed through
24
+ * the platform ITX binding — the stream handle a worker-hosted stream
25
+ * processor registry needs (`iterate/processors`; see the config-repo
26
+ * template's guestbook for the full hosting shape). RPC stubs from
27
+ * `env.ITX.get()` must not outlive the invocation that dialed them, so every
28
+ * operation opens, uses, and disposes its own session; `readEvents` owns one
29
+ * session for its pager's lifetime (scope it with `using`, like any pager).
30
+ */
31
+ export declare function itxProjectStream(env: IterateEnv, path: string): ProcessorStream;
32
+ /**
33
+ * Base class for stateless dynamic workers — the project worker (a repo's
34
+ * default export) and stateless apps. A WorkerEntrypoint whose env carries
35
+ * the platform's itx binding, plus the platform ceremony every worker needs
36
+ * but shouldn't have to hand-roll:
37
+ *
38
+ * - `processEventBatch` / `processEvent`: the platform delivers every
39
+ * committed DURABLE event on every stream in the project as checkpointed
40
+ * per-stream batches — in per-stream order, at-least-once. Events appended
41
+ * with `ephemeral: true` (LLM streaming chunks and other transient
42
+ * signals) never arrive here. Session callbacks can receive one while its
43
+ * body remains in the Stream Durable Object's bounded memory buffer; react
44
+ * here to the durable fact that supersedes it (e.g. an assistant-role
45
+ * `agents/context-added` item). The base unpacks batches
46
+ * into one `processEvent(event)` call per event; override `processEvent` to react
47
+ * (one `if` per reaction, keyed on event.path + event.type). Throwing (or a worker that fails to build) leaves that
48
+ * stream's checkpoint in place and the whole batch is redelivered later,
49
+ * so return normally to advance past events you don't care about — and
50
+ * anything a reaction appends should carry an idempotency key.
51
+ * - `invokeCapability`: the flattened `itx.worker.<path>` dispatcher — add a
52
+ * getter or method to your class and it becomes a capability surface.
53
+ * - `fetchDynamicWorker`: forward HTTP (WebSockets included) to another of
54
+ * the project's dynamic workers.
55
+ */
56
+ export declare class IterateWorkerEntrypoint<Env extends IterateEnv = IterateEnv> extends WorkerEntrypoint<Env> {
57
+ #private;
58
+ constructor(ctx: ConstructorParameters<typeof WorkerEntrypoint<Env>>[0], env: Env);
59
+ /**
60
+ * This invocation's project-root itx. Cloudflare constructs one
61
+ * WorkerEntrypoint per invocation and releases its RPC stubs when that
62
+ * execution context ends. The getter returns the native Workers RPC
63
+ * promise-proxy, so `await this.itx.agents.list()` pipelines immediately;
64
+ * repeated access within one event batch or fetch reuses the same handle.
65
+ *
66
+ * Durable Objects have a longer, multi-invocation lifetime and no eviction
67
+ * callback, so IterateDurableObject deliberately does not expose this
68
+ * memoized getter.
69
+ */
70
+ protected get itx(): PipelinedProject;
71
+ /**
72
+ * Run the project-member auth partial fetch without transferring the app's
73
+ * request body on paths auth only inspects. The callback POST belongs to
74
+ * auth, so that one path deliberately transfers the complete request.
75
+ */
76
+ protected fetchProjectAuth(request: Request, policy: ProjectAuthPolicy): Promise<Response | null>;
77
+ /** See `fetchDynamicWorker` at module level: a real fetch hop into a
78
+ * sibling dynamic worker — the only lane that can carry WebSocket upgrades
79
+ * and streaming bodies (RPC serializes; sockets can't cross it). */
80
+ protected fetchDynamicWorker(req: Request, ref: DynamicWorkerRef, opts?: {
81
+ buildBudgetMs?: number;
82
+ }): Promise<Response>;
83
+ /** Platform entry point for event delivery (see the class docstring for
84
+ * the delivery contract). Override `processEvent`, not this, unless you
85
+ * need whole-batch atomicity. */
86
+ processEventBatch(batch: StreamDeliveryBatch): Promise<void>;
87
+ /** Called once per delivered event, in per-stream order, at-least-once.
88
+ * Override to react; the default ignores everything. */
89
+ protected processEvent(_event: StreamEvent): Promise<void>;
90
+ /** Platform entry point for flattened `itx.worker.<path>` capability
91
+ * calls (see the class docstring). */
92
+ invokeCapability(input: {
93
+ args?: unknown[];
94
+ path: string[];
95
+ }): Promise<unknown>;
96
+ }
97
+ /**
98
+ * Base class for stateful dynamic workers (apps hosted as Durable Objects
99
+ * under a `durableWorkerKey`). Same platform surface as
100
+ * `IterateWorkerEntrypoint` — see its docstring for the event-delivery and
101
+ * capability-dispatch contracts — on a DurableObject, so state survives
102
+ * across requests and WebSockets can be served from `fetch`. Durable alarms
103
+ * work natively — `this.ctx.storage.setAlarm(...)` plus an `alarm()` method
104
+ * on the class — even though this object is hosted as a workerd facet with
105
+ * no alarms of its own; see {@link selfAlarmState} for the mechanism.
106
+ */
107
+ export declare class IterateDurableObject<Env extends IterateEnv = IterateEnv> extends DurableObject<Env> {
108
+ constructor(ctx: ConstructorParameters<typeof DurableObject<Env>>[0], env: Env);
109
+ /**
110
+ * Platform bootstrap door: the Durable Object hosting this worker delivers
111
+ * the worker's OWN ref here before any other traffic in its incarnation —
112
+ * a facet has no channel to learn its identity by itself, and the ref is
113
+ * what the alarm shim dials (`itx.workers.get(ref)` resolves back to the
114
+ * hosting DO). Stashed durably, so a warm facet under a fresh host needs
115
+ * no re-delivery to keep working.
116
+ */
117
+ __stashSelfRef(ref: StatefulDynamicWorkerRef): void;
118
+ /** A real fetch hop into a sibling dynamic worker — see
119
+ * `IterateWorkerEntrypoint.fetchDynamicWorker`. */
120
+ protected fetchDynamicWorker(req: Request, ref: DynamicWorkerRef, opts?: {
121
+ buildBudgetMs?: number;
122
+ }): Promise<Response>;
123
+ /** Platform entry point for event delivery — see
124
+ * `IterateWorkerEntrypoint.processEventBatch`. */
125
+ processEventBatch(batch: StreamDeliveryBatch): Promise<void>;
126
+ /** Called once per delivered event — see
127
+ * `IterateWorkerEntrypoint.processEvent`. */
128
+ protected processEvent(_event: StreamEvent): Promise<void>;
129
+ /** Platform entry point for flattened `itx.worker.<path>` capability
130
+ * calls — see `IterateWorkerEntrypoint.invokeCapability`. */
131
+ invokeCapability(input: {
132
+ args?: unknown[];
133
+ path: string[];
134
+ }): Promise<unknown>;
135
+ }
136
+ type WakeRegistryLookup = (projectId: string, path: string) => Pick<StreamProcessorRegistry<object>, "wakeStreamProcessor">;
137
+ /**
138
+ * The worker's `processor` node: the wake door the stream spine dials PLUS
139
+ * the public read verbs of the standard processor contract
140
+ * (`StreamProcessorRpc`). The reads serve the registered runner directly, so
141
+ * `streams.get(path).subscriptions.get(name).processor` and the stream's
142
+ * `waitUntilProcessed` barrier reach an expression-placed dynamic worker's
143
+ * processor with no extra wiring — the stream replays those verbs onto this
144
+ * node (the stored wake expression minus its trailing wake step). It crosses
145
+ * Workers RPC as a property read before its method is called, so it must be
146
+ * a real RpcTarget.
147
+ */
148
+ declare class ProcessorWakeTarget extends RpcTarget {
149
+ #private;
150
+ constructor(registryFor: WakeRegistryLookup, reads: () => Promise<RegisteredProcessorReads<object>>);
151
+ wakeStreamProcessor(request: StreamProcessorWakeRequest): Promise<StreamProcessorWakeResponse>;
152
+ /** One consistent read of the committed fold, pulled through the durable
153
+ * stream tail first (read-your-writes, the hosting relays' catch-up leg). */
154
+ snapshot(): Promise<ProcessorSnapshot<object>>;
155
+ getRuntimeState(): Promise<ProcessorRuntimeState<object>>;
156
+ /** Offset barrier against the runner's committed fold. The runner's waiter
157
+ * self-pulls, so its timeout bounds the whole read-your-writes operation. */
158
+ waitUntilProcessed(input: {
159
+ offset: number;
160
+ timeoutMs?: number;
161
+ }): Promise<void>;
162
+ }
163
+ /**
164
+ * The platform deps the host derives and hands a processor factory: the home
165
+ * stream and its coordinates. Everything else a processor needs (clocks,
166
+ * clients, itx-backed capabilities) the factory wires off `this.env`.
167
+ */
168
+ export type ProcessorHostDeps = {
169
+ path: string;
170
+ projectId: string;
171
+ stream: ProcessorStream;
172
+ };
173
+ export type ProcessorHost<State extends object> = {
174
+ /** The lazily built registry. Outside a wake request the coordinates come
175
+ * from the durable cache, the static `path`, or one project dial. */
176
+ registry(): Promise<StreamProcessorRegistry<State>>;
177
+ /** One consistent read of the hosted processor's committed fold. */
178
+ snapshot(): Promise<ProcessorSnapshot<State>>;
179
+ /** Assign to a `processor` getter — the wake door the stream spine dials,
180
+ * which also serves the standard read verbs (snapshot / getRuntimeState /
181
+ * waitUntilProcessed) so the subscriptions catalog and the stream barrier
182
+ * reach this processor. */
183
+ readonly wakeProcessor: ProcessorWakeTarget;
184
+ /** Route the Durable Object's `alarm()` here. Nothing cached means no
185
+ * registry ever armed one, so a stray fire is a no-op. */
186
+ handleAlarm(alarmInfo?: AlarmInvocationInfo): Promise<void>;
187
+ };
188
+ /**
189
+ * Host one stream processor in a Durable Object: the registry ceremony, the
190
+ * RPC-safe wake door, the alarm multiplex, and the durable coordinate cache
191
+ * in one place, so an app class is only its processor plus its own verbs.
192
+ *
193
+ * With `path` the host serves one fixed home stream (the guestbook shape).
194
+ * Without it the host learns its stream from the first wake request and
195
+ * caches the coordinates durably (one Durable Object per dynamic stream,
196
+ * keyed by the ref that names it). One host per Durable Object — the cache
197
+ * keys assume it.
198
+ */
199
+ export declare function createProcessorHost<State extends object = Record<string, unknown>>(args: {
200
+ ctx: DurableObjectState;
201
+ env: IterateEnv;
202
+ path?: string;
203
+ /** Post-eviction keepalive recovery, for processors that owe registered work. */
204
+ recovery?: boolean;
205
+ createProcessor(deps: ProcessorHostDeps): RegisterableProcessor;
206
+ }): ProcessorHost<State>;
207
+ /**
208
+ * Ergonomic base for a Durable Object that hosts exactly one stream processor.
209
+ *
210
+ * It collapses the host boilerplate every processor app writes by hand today —
211
+ * a {@link createProcessorHost} field, an `alarm()` that forwards to it, and a
212
+ * `processor` getter exposing the wake door — down to a single
213
+ * {@link createProcessor} factory. First-party and userspace processors are
214
+ * authored the SAME way: all a subclass writes is how to build its processor
215
+ * from the host-derived platform deps (`{ stream, path, projectId }`) plus
216
+ * whatever it wires off `this.env`. That single seam is why a built-in
217
+ * processor forks into userspace with no change to the processor itself — only
218
+ * the dep wiring in `createProcessor` differs.
219
+ *
220
+ * Host-agnostic: the exact same class runs as its own Durable Object, as a
221
+ * facet of the Stream DO, or as a facet of another DO. Only the alarm adapter
222
+ * (native vs parent-proxied) and who dials the wake door differ per host, and
223
+ * the host owns both.
224
+ *
225
+ * ```ts
226
+ * export class GuestbookDurableObject extends StreamProcessorDurableObject<GuestbookState> {
227
+ * protected readonly streamPath = guestbookStreamPath; // fixed home stream
228
+ * protected createProcessor(deps: ProcessorHostDeps) {
229
+ * return new GuestbookProcessor(deps);
230
+ * }
231
+ * // alarm(), the `processor` wake door, snapshot(), registry() — inherited.
232
+ * }
233
+ * ```
234
+ */
235
+ export declare abstract class StreamProcessorDurableObject<State extends object = Record<string, unknown>, Env extends IterateEnv = IterateEnv> extends IterateDurableObject<Env> {
236
+ #private;
237
+ /**
238
+ * Build the processor from the host-derived platform deps. Wire your own deps
239
+ * (clocks, clients, itx-backed capabilities) off `this.env` here — this is
240
+ * the one method a processor app must implement, and the seam that keeps a
241
+ * built-in processor forkable into userspace unchanged.
242
+ */
243
+ protected abstract createProcessor(deps: ProcessorHostDeps): RegisterableProcessor;
244
+ /**
245
+ * A fixed home stream path (the guestbook shape). Leave undefined to learn
246
+ * the stream from the first wake request and cache the coordinates durably
247
+ * (one Durable Object per dynamic stream).
248
+ */
249
+ protected readonly streamPath?: string;
250
+ /**
251
+ * Post-eviction keepalive recovery, for processors that owe registered
252
+ * background work (the obligation pattern). Off by default.
253
+ */
254
+ protected readonly recovery: boolean;
255
+ /**
256
+ * The processor node the stream spine dials: the wake door plus the standard
257
+ * read verbs (`snapshot` / `getRuntimeState` / `waitUntilProcessed`), so the
258
+ * subscriptions catalog and the stream barrier reach this processor. It
259
+ * crosses Workers RPC as a property read before its method is called, so it
260
+ * must be a real RpcTarget — which the host guarantees.
261
+ */
262
+ get processor(): ProcessorWakeTarget;
263
+ /** Route the Durable Object's native `alarm()` into the host's multiplex. */
264
+ alarm(alarmInfo?: AlarmInvocationInfo): Promise<void>;
265
+ /**
266
+ * One consistent read of the hosted processor's committed fold, for a
267
+ * subclass's own read verbs (e.g. a `getState()`).
268
+ */
269
+ protected snapshot(): Promise<ProcessorSnapshot<State>>;
270
+ /**
271
+ * The lazily built registry, for subclasses that drive catch-up / live
272
+ * refresh directly (the guestbook's HTTP + append flow).
273
+ */
274
+ protected registry(): Promise<StreamProcessorRegistry<State>>;
275
+ }
276
+ /**
277
+ * Ergonomic base for a userspace stream processor hosted as a FACET of the
278
+ * platform's Stream Durable Object — the `facet-processor` subscription with a
279
+ * `userspace` source, whose `StatefulDynamicWorkerRef` names THIS class. The
280
+ * Stream DO loads the class from the project's source and starts it with
281
+ * `ctx.facets.get(name, …)`, so it runs INSIDE the stream it serves: wakes are
282
+ * an in-process parent→facet dial (no itx wake expression), and checkpoints /
283
+ * projections land in the facet's own private SQLite.
284
+ *
285
+ * Same authoring seam as {@link StreamProcessorDurableObject} — a subclass
286
+ * writes only `createProcessor` (and sets `recovery` when it owes background
287
+ * work) — so a processor forks between "its own Durable Object" and "a facet
288
+ * of its stream" with no change to the processor itself. The two differences a
289
+ * facet forces, both handled here:
290
+ *
291
+ * - **No native alarm.** workerd does not implement alarms for facets
292
+ * (workerd#6810), so this base routes the registry's keepalive/recovery
293
+ * alarm through the parent's real platform alarm over itx —
294
+ * `streams.get(path).proxySetAlarm/proxyDeleteAlarm/proxyGetAlarm`, the
295
+ * itx-channel twin of a stateful worker's `workers.get(ref).setAlarm`. The
296
+ * parent fires it back as {@link ProcessorFacet.handleAlarm}. NEVER define
297
+ * `alarm()` on a subclass (the base throws): a facet's native `setAlarm`
298
+ * would appear to succeed, then poison its output gate.
299
+ * - **Identity by first-contact `configure`, not the constructor.** The Stream
300
+ * DO delivers `{ parentName, projectId, path }`; the base stashes it and
301
+ * rebuilds the host from that stash on every incarnation (see
302
+ * {@link ProcessorFacet}).
303
+ *
304
+ * ```ts
305
+ * export class GuestbookFacet extends StreamProcessorFacet {
306
+ * protected readonly recovery = true; // owes background work
307
+ * protected createProcessor(deps: ProcessorHostDeps) {
308
+ * return new GuestbookProcessor(deps);
309
+ * }
310
+ * }
311
+ * ```
312
+ */
313
+ export declare abstract class StreamProcessorFacet<Env extends IterateEnv = IterateEnv> extends ProcessorFacet<Env> {
314
+ /**
315
+ * Build the processor from the host-derived platform deps, wiring your own
316
+ * deps (clocks, clients, itx-backed capabilities) off `this.env` — the one
317
+ * method a facet-hosted processor app implements, identical to
318
+ * {@link StreamProcessorDurableObject.createProcessor}.
319
+ */
320
+ protected abstract createProcessor(deps: ProcessorHostDeps): RegisterableProcessor;
321
+ /**
322
+ * Post-eviction keepalive recovery, for processors that owe registered
323
+ * background work (the obligation pattern). Off by default.
324
+ */
325
+ protected readonly recovery: boolean;
326
+ /**
327
+ * Dial the parent stream's alarm proxy over itx, resolved PER CALL (a stub
328
+ * must not outlive its RPC turn), each verb opening and disposing its own
329
+ * session like {@link itxProjectStream}. `identity.path` is the coordinate;
330
+ * `parentName` is unused here (userspace facets have no `env.STREAM`).
331
+ */
332
+ protected parentAlarms(identity: ProcessorFacetIdentity): ProcessorFacetAlarmProxy;
333
+ /**
334
+ * Build the host wiring from the stashed identity: the stream handle is the
335
+ * same itx-backed {@link itxProjectStream} a worker-hosted processor appends
336
+ * through, and the single processor is registered under this facet's name.
337
+ */
338
+ protected createHost(identity: ProcessorFacetIdentity): ProcessorFacetHost;
339
+ }
package/dist/sdk.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { a as createProcessorHost, i as StreamProcessorFacet, n as IterateWorkerEntrypoint, o as itxProjectStream, r as StreamProcessorDurableObject, s as serveItx, t as IterateDurableObject } from "./sdk-DMB-IM11.mjs";
2
+ export { IterateDurableObject, IterateWorkerEntrypoint, StreamProcessorDurableObject, StreamProcessorFacet, createProcessorHost, itxProjectStream, serveItx };
@@ -0,0 +1,46 @@
1
+ import { RpcTarget } from "./sdk/capnweb/index.ts";
2
+ import type { Project } from "./itx-api.generated.ts";
3
+ export type ServeItxOptions = {
4
+ /** The worker's own itx (`this.itx`, `await env.ITX.get()`). Never reaches the browser. */
5
+ project: Project;
6
+ /**
7
+ * What the browser gets. `surface` lists the members served as DOTTED
8
+ * paths down to each METHOD: a leaf is called, so an object-valued member
9
+ * is listed through to its methods — `"agent.liveState.get"` and
10
+ * `"agent.liveState.subscribe"`, never `"agent.liveState"`. A bare root
11
+ * cannot be relayed because its members are unknown here.
12
+ */
13
+ scope: {
14
+ path: string;
15
+ surface: string[];
16
+ };
17
+ };
18
+ /**
19
+ * Answer an app's `/api` request with an itx session for one narrowed scope.
20
+ * Call it from `fetch` after deciding who the visitor is:
21
+ *
22
+ * if (url.pathname === "/api") {
23
+ * return await serveItx(request, {
24
+ * project: await this.env.ITX.get(),
25
+ * scope: {
26
+ * path: `/agents/web/${visitorIdFrom(request)}`,
27
+ * surface: [
28
+ * "agent.message",
29
+ * "agent.liveState.get",
30
+ * "agent.liveState.subscribe",
31
+ * "agent.stream.openConnection",
32
+ * ],
33
+ * },
34
+ * });
35
+ * }
36
+ *
37
+ * WebSocket upgrades carry the live session (stream connections, live
38
+ * state); `POST` answers the client's HTTP-batch transport.
39
+ */
40
+ export declare function serveItx(request: Request, options: ServeItxOptions): Promise<Response>;
41
+ /**
42
+ * The served project: the relay tree over a scoped stub for these dotted
43
+ * members. Exported for the relay's own tests; callers use `serveItx`.
44
+ * @internal
45
+ */
46
+ export declare function relayServedProject(scoped: unknown, surface: readonly string[]): RpcTarget;
@@ -0,0 +1,31 @@
1
+ import type { StreamEventInput } from "../../processors/index.ts";
2
+ export declare const flakesStreamPath = "/flakes";
3
+ export declare const flakeDashboardWorkerRef: {
4
+ className: string;
5
+ durableWorkerKey: string;
6
+ path: string;
7
+ source: {
8
+ createWorker: {
9
+ entryPoint: string;
10
+ files: {
11
+ include: string[];
12
+ repoPath: string;
13
+ type: "repo";
14
+ };
15
+ };
16
+ };
17
+ type: "stateful";
18
+ };
19
+ /**
20
+ * The dashboard's birth certificate. Idempotency-keyed so every caller — the
21
+ * worker's lazy initialization AND the CI reporter script, whichever appends
22
+ * first — may offer it; the config values are immutable birth facts.
23
+ */
24
+ export declare function flakeDashboardCreationEvents(config: {
25
+ repository: {
26
+ owner: string;
27
+ repo: string;
28
+ };
29
+ issueTitle: string;
30
+ defaultBranch: string;
31
+ }): StreamEventInput[];