@gjermundgaraba/effect-actions 0.21.0 → 0.23.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 (271) hide show
  1. package/README.md +7 -1
  2. package/dist/Action.d.mts +2 -2
  3. package/dist/Action.mjs +1 -0
  4. package/dist/ActionCli.mjs +0 -1
  5. package/dist/ActionHttp.d.mts +1 -1
  6. package/dist/ActionMcp.d.mts +0 -3
  7. package/dist/ActionMcp.mjs +0 -5
  8. package/dist/ActionRpc.d.mts +8 -15
  9. package/dist/ActionRpc.mjs +29 -54
  10. package/dist/ActionToolkit.d.mts +0 -2
  11. package/dist/ActionToolkit.mjs +0 -2
  12. package/dist/Event.d.mts +0 -23
  13. package/dist/Testing.mjs +3 -2
  14. package/dist/Webhook.mjs +2 -2
  15. package/dist/authentication/refusal.mjs +0 -1
  16. package/dist/cli/commands.mjs +0 -5
  17. package/dist/contract/authorizer.mjs +0 -5
  18. package/dist/contract/call.mjs +0 -23
  19. package/dist/contract/callback.mjs +0 -1
  20. package/dist/contract/caller.mjs +0 -11
  21. package/dist/contract/canonical.mjs +0 -5
  22. package/dist/contract/codec.d.mts +0 -1
  23. package/dist/contract/codec.mjs +0 -1
  24. package/dist/contract/codes.mjs +1 -15
  25. package/dist/contract/declared.mjs +0 -15
  26. package/dist/contract/digest.mjs +0 -1
  27. package/dist/contract/errors.d.mts +0 -4
  28. package/dist/contract/errors.mjs +0 -4
  29. package/dist/contract/feed.d.mts +0 -1
  30. package/dist/contract/feed.mjs +0 -20
  31. package/dist/contract/hints.mjs +0 -6
  32. package/dist/contract/hub.mjs +0 -3
  33. package/dist/contract/idempotency.mjs +0 -4
  34. package/dist/contract/implementation.d.mts +0 -1
  35. package/dist/contract/implementation.mjs +0 -27
  36. package/dist/contract/input-check.mjs +0 -1
  37. package/dist/contract/lease.mjs +0 -1
  38. package/dist/contract/listed.mjs +0 -6
  39. package/dist/contract/log.mjs +0 -8
  40. package/dist/contract/names.mjs +0 -1
  41. package/dist/contract/occurrence.mjs +0 -8
  42. package/dist/contract/pages.mjs +5 -12
  43. package/dist/contract/progress.mjs +2 -25
  44. package/dist/contract/push.d.mts +0 -5
  45. package/dist/contract/push.mjs +1 -24
  46. package/dist/contract/receiving.mjs +0 -7
  47. package/dist/contract/reported.mjs +0 -5
  48. package/dist/contract/serving.mjs +0 -18
  49. package/dist/contract/status.mjs +0 -3
  50. package/dist/contract/stream.mjs +0 -2
  51. package/dist/contract/subscribe.d.mts +0 -2
  52. package/dist/contract/subscribe.mjs +0 -8
  53. package/dist/contract/transient.mjs +0 -12
  54. package/dist/contract/watch.mjs +5 -17
  55. package/dist/contract/webhooks.mjs +0 -11
  56. package/dist/http/client.mjs +0 -1
  57. package/dist/http/events.d.mts +0 -10
  58. package/dist/http/events.mjs +2 -31
  59. package/dist/http/placed.d.mts +0 -2
  60. package/dist/http/streamed.d.mts +0 -1
  61. package/dist/http/streamed.mjs +4 -32
  62. package/dist/http/watch.mjs +0 -6
  63. package/dist/mcp/bridge.mjs +0 -25
  64. package/dist/mcp/client.d.mts +0 -1
  65. package/dist/mcp/client.mjs +0 -1
  66. package/dist/mcp/events.mjs +0 -6
  67. package/dist/mcp/progress.mjs +0 -7
  68. package/dist/mcp/protocol.mjs +0 -6
  69. package/dist/mcp/reply.mjs +0 -11
  70. package/dist/mcp/request.mjs +0 -1
  71. package/dist/mcp/watch.mjs +0 -6
  72. package/dist/rpc/watch.mjs +0 -6
  73. package/dist/stdio/console.mjs +2 -2
  74. package/dist/webhook/address.mjs +4 -9
  75. package/dist/webhook/attempt.mjs +2 -15
  76. package/dist/webhook/receiver.mjs +2 -8
  77. package/dist/webhook/signing.mjs +0 -3
  78. package/dist/webhook/stored.mjs +8 -17
  79. package/dist/webhook/subscriptions.mjs +19 -23
  80. package/docs/Action-streams.md +0 -12
  81. package/docs/Action.md +0 -10
  82. package/docs/ActionCli.md +2 -26
  83. package/docs/ActionHttp.md +0 -28
  84. package/docs/ActionMcp.md +2 -37
  85. package/docs/ActionRpc-events.md +0 -16
  86. package/docs/ActionRpc.md +0 -63
  87. package/docs/ActionToolkit.md +0 -11
  88. package/docs/Authentication-advanced.md +0 -31
  89. package/docs/Authentication.md +4 -13
  90. package/docs/Event.md +0 -37
  91. package/docs/README.md +1 -1
  92. package/docs/Testing.md +3 -13
  93. package/docs/Webhook.md +0 -46
  94. package/docs/setup.md +0 -5
  95. package/examples/README.md +7 -1
  96. package/examples/assistant/src/agent.ts +8 -31
  97. package/examples/assistant/src/cli.ts +2 -9
  98. package/examples/assistant/src/commands.ts +0 -8
  99. package/examples/assistant/src/identity/Identity.ts +0 -10
  100. package/examples/assistant/src/identity/authorize.ts +0 -4
  101. package/examples/assistant/src/identity/members.ts +1 -3
  102. package/examples/assistant/src/identity/permissions.ts +0 -5
  103. package/examples/assistant/src/platform/tasks-file.ts +1 -6
  104. package/examples/assistant/src/scripted.ts +0 -4
  105. package/examples/assistant/src/tasks/Tasks.ts +0 -2
  106. package/examples/assistant/src/tasks/handlers.ts +0 -3
  107. package/examples/assistant/src/tasks/store.ts +0 -7
  108. package/examples/assistant/src/toolkit.ts +0 -11
  109. package/examples/assistant/test/commands.test.ts +0 -5
  110. package/examples/assistant/test/identity/identity.test.ts +6 -6
  111. package/examples/assistant/test/platform/tasks-file.test.ts +2 -6
  112. package/examples/assistant/test/tasks/tasks.test.ts +13 -14
  113. package/examples/assistant/test/toolkit.test.ts +7 -18
  114. package/examples/build-events/README.md +2 -0
  115. package/examples/build-events/src/Api.ts +0 -3
  116. package/examples/build-events/src/Rpc.ts +0 -2
  117. package/examples/build-events/src/builds/Builds.ts +0 -15
  118. package/examples/build-events/src/builds/events.ts +0 -10
  119. package/examples/build-events/src/builds/handlers.ts +0 -6
  120. package/examples/build-events/src/builds/log.ts +0 -6
  121. package/examples/build-events/src/builds/status.ts +0 -4
  122. package/examples/build-events/src/builds/store.ts +0 -21
  123. package/examples/build-events/src/cli.ts +0 -2
  124. package/examples/build-events/src/commands.ts +0 -9
  125. package/examples/build-events/src/deploys/approvers.ts +0 -3
  126. package/examples/build-events/src/deploys/events.ts +0 -8
  127. package/examples/build-events/src/deploys/handlers.ts +0 -2
  128. package/examples/build-events/src/identity/Identity.ts +0 -11
  129. package/examples/build-events/src/identity/members.ts +1 -2
  130. package/examples/build-events/src/identity/verifier.ts +8 -9
  131. package/examples/build-events/src/notifier/Notices.ts +0 -3
  132. package/examples/build-events/src/notifier/routes.ts +0 -10
  133. package/examples/build-events/src/notifier.ts +0 -8
  134. package/examples/build-events/src/routes.ts +0 -24
  135. package/examples/build-events/src/server.ts +0 -14
  136. package/examples/build-events/test/builds/events.test.ts +0 -6
  137. package/examples/build-events/test/builds/log.test.ts +0 -1
  138. package/examples/build-events/test/builds/progress.test.ts +0 -1
  139. package/examples/build-events/test/commands.test.ts +0 -5
  140. package/examples/build-events/test/deploys/events.test.ts +0 -1
  141. package/examples/build-events/test/http.test.ts +0 -4
  142. package/examples/build-events/test/notifier.test.ts +0 -9
  143. package/examples/build-events/test/routes.test.ts +0 -9
  144. package/examples/build-events/test/rpc.test.ts +0 -4
  145. package/examples/build-events/test/support/as.ts +3 -4
  146. package/examples/build-events/test/support/memory.ts +0 -5
  147. package/examples/build-events/test/webhooks.test.ts +0 -12
  148. package/examples/kitchen-sink/README.md +1 -1
  149. package/examples/kitchen-sink/src/Actions.ts +0 -10
  150. package/examples/kitchen-sink/src/Api.ts +0 -8
  151. package/examples/kitchen-sink/src/Rpc.ts +0 -4
  152. package/examples/kitchen-sink/src/admin/Admin.ts +0 -9
  153. package/examples/kitchen-sink/src/admin/authenticate.ts +2 -6
  154. package/examples/kitchen-sink/src/admin/authorize.ts +0 -5
  155. package/examples/kitchen-sink/src/admin/grants.ts +0 -5
  156. package/examples/kitchen-sink/src/admin/handlers.ts +0 -2
  157. package/examples/kitchen-sink/src/admin/keys.ts +1 -3
  158. package/examples/kitchen-sink/src/agent.ts +2 -13
  159. package/examples/kitchen-sink/src/assistant/Assistant.ts +7 -24
  160. package/examples/kitchen-sink/src/assistant/conversations.ts +3 -21
  161. package/examples/kitchen-sink/src/assistant/demo-model.ts +0 -5
  162. package/examples/kitchen-sink/src/assistant/handlers.ts +1 -30
  163. package/examples/kitchen-sink/src/attachments/Attachments.ts +0 -4
  164. package/examples/kitchen-sink/src/attachments/download.ts +0 -10
  165. package/examples/kitchen-sink/src/attachments/handlers.ts +0 -3
  166. package/examples/kitchen-sink/src/attachments/store.ts +0 -3
  167. package/examples/kitchen-sink/src/browser.ts +0 -9
  168. package/examples/kitchen-sink/src/cli.ts +0 -19
  169. package/examples/kitchen-sink/src/config.ts +3 -11
  170. package/examples/kitchen-sink/src/identity/Identity.ts +0 -18
  171. package/examples/kitchen-sink/src/identity/authenticate.ts +3 -14
  172. package/examples/kitchen-sink/src/identity/authorize.ts +0 -6
  173. package/examples/kitchen-sink/src/identity/directory.ts +8 -18
  174. package/examples/kitchen-sink/src/identity/handlers.ts +0 -3
  175. package/examples/kitchen-sink/src/identity/members.ts +1 -5
  176. package/examples/kitchen-sink/src/identity/quota.ts +0 -11
  177. package/examples/kitchen-sink/src/issues/Issues.ts +0 -24
  178. package/examples/kitchen-sink/src/issues/assistant.ts +0 -10
  179. package/examples/kitchen-sink/src/issues/events.ts +2 -16
  180. package/examples/kitchen-sink/src/issues/export.ts +0 -5
  181. package/examples/kitchen-sink/src/issues/guide.ts +0 -5
  182. package/examples/kitchen-sink/src/issues/handlers.ts +0 -5
  183. package/examples/kitchen-sink/src/issues/store.ts +19 -23
  184. package/examples/kitchen-sink/src/issues/write-limit.ts +0 -12
  185. package/examples/kitchen-sink/src/memory.ts +0 -9
  186. package/examples/kitchen-sink/src/ops.ts +0 -6
  187. package/examples/kitchen-sink/src/request-policy.ts +0 -17
  188. package/examples/kitchen-sink/src/routes.ts +0 -48
  189. package/examples/kitchen-sink/src/sdk.ts +0 -12
  190. package/examples/kitchen-sink/src/seed.ts +0 -10
  191. package/examples/kitchen-sink/src/server.ts +0 -22
  192. package/examples/kitchen-sink/src/stdio.ts +2 -12
  193. package/examples/kitchen-sink/src/workspaces/Workspaces.ts +0 -4
  194. package/examples/kitchen-sink/src/workspaces/handlers.ts +0 -4
  195. package/examples/kitchen-sink/src/workspaces/registry.ts +0 -5
  196. package/examples/kitchen-sink/src/workspaces/tenant.ts +0 -4
  197. package/examples/kitchen-sink/test/admin/admin.test.ts +0 -1
  198. package/examples/kitchen-sink/test/assistant/assistant.test.ts +0 -18
  199. package/examples/kitchen-sink/test/attachments/attachments.test.ts +0 -9
  200. package/examples/kitchen-sink/test/identity/identity.test.ts +0 -10
  201. package/examples/kitchen-sink/test/identity/session.test.ts +0 -10
  202. package/examples/kitchen-sink/test/issues/assistant.test.ts +3 -7
  203. package/examples/kitchen-sink/test/issues/events.test.ts +2 -9
  204. package/examples/kitchen-sink/test/issues/export.test.ts +0 -3
  205. package/examples/kitchen-sink/test/issues/issues.test.ts +6 -12
  206. package/examples/kitchen-sink/test/request-policy.test.ts +0 -6
  207. package/examples/kitchen-sink/test/routes.test.ts +0 -6
  208. package/examples/kitchen-sink/test/support/as.ts +3 -5
  209. package/examples/kitchen-sink/test/support/scripted.ts +0 -3
  210. package/examples/kitchen-sink/test/support/services.ts +0 -3
  211. package/examples/live-rpc/src/Rpc.ts +0 -4
  212. package/examples/live-rpc/src/browser.ts +0 -24
  213. package/examples/live-rpc/src/chat/Chat.ts +0 -22
  214. package/examples/live-rpc/src/chat/authorize.ts +0 -3
  215. package/examples/live-rpc/src/chat/events.ts +0 -14
  216. package/examples/live-rpc/src/chat/handlers.ts +0 -5
  217. package/examples/live-rpc/src/chat/room.ts +0 -6
  218. package/examples/live-rpc/src/chat/store.ts +0 -9
  219. package/examples/live-rpc/src/client.ts +0 -6
  220. package/examples/live-rpc/src/identity/Identity.ts +0 -6
  221. package/examples/live-rpc/src/identity/members.ts +1 -3
  222. package/examples/live-rpc/src/identity/verifier.ts +6 -12
  223. package/examples/live-rpc/src/page.ts +0 -10
  224. package/examples/live-rpc/src/routes.ts +0 -13
  225. package/examples/live-rpc/src/server.ts +0 -16
  226. package/examples/live-rpc/test/browser.test.ts +0 -9
  227. package/examples/live-rpc/test/chat/chat.test.ts +3 -11
  228. package/examples/live-rpc/test/routes.test.ts +0 -8
  229. package/examples/live-rpc/test/server.test.ts +0 -13
  230. package/examples/mcp-tools/src/instructions.ts +0 -4
  231. package/examples/mcp-tools/src/platform/fake-farm.ts +0 -6
  232. package/examples/mcp-tools/src/platform/print-farm.ts +0 -16
  233. package/examples/mcp-tools/src/printers/Printers.ts +0 -21
  234. package/examples/mcp-tools/src/printers/farm.ts +0 -5
  235. package/examples/mcp-tools/src/printers/handlers.ts +0 -6
  236. package/examples/mcp-tools/src/routes.ts +0 -11
  237. package/examples/mcp-tools/src/server.ts +0 -9
  238. package/examples/mcp-tools/src/stdio.ts +1 -13
  239. package/examples/mcp-tools/test/printers/printers.test.ts +0 -10
  240. package/examples/mcp-tools/test/routes.test.ts +0 -14
  241. package/examples/notes-service/src/Api.ts +0 -4
  242. package/examples/notes-service/src/browser.ts +0 -12
  243. package/examples/notes-service/src/cli.ts +0 -2
  244. package/examples/notes-service/src/commands.ts +0 -30
  245. package/examples/notes-service/src/identity/Identity.ts +0 -2
  246. package/examples/notes-service/src/identity/authorize.ts +0 -4
  247. package/examples/notes-service/src/identity/users.ts +1 -3
  248. package/examples/notes-service/src/identity/verifier.ts +4 -11
  249. package/examples/notes-service/src/notes/Notes.ts +0 -12
  250. package/examples/notes-service/src/notes/handlers.ts +0 -4
  251. package/examples/notes-service/src/notes/store.ts +62 -48
  252. package/examples/notes-service/src/routes.ts +0 -12
  253. package/examples/notes-service/src/server.ts +0 -6
  254. package/examples/notes-service/src/status/Status.ts +0 -1
  255. package/examples/notes-service/src/status/handlers.ts +0 -1
  256. package/examples/notes-service/src/stdio.ts +2 -12
  257. package/examples/notes-service/src/worker.ts +0 -7
  258. package/examples/notes-service/test/commands.test.ts +0 -20
  259. package/examples/notes-service/test/notes/as.ts +3 -4
  260. package/examples/notes-service/test/notes/in-process.test.ts +3 -6
  261. package/examples/notes-service/test/notes/notes.test.ts +0 -6
  262. package/examples/notes-service/test/routes.test.ts +0 -5
  263. package/examples/notes-service/test/worker.test.ts +0 -1
  264. package/examples/quickstart/src/Api.ts +0 -1
  265. package/examples/quickstart/src/client.ts +0 -3
  266. package/examples/quickstart/src/greeting/Greeting.ts +0 -2
  267. package/examples/quickstart/src/greeting/handlers.ts +0 -1
  268. package/examples/quickstart/src/routes.ts +0 -1
  269. package/examples/quickstart/src/server.ts +3 -6
  270. package/examples/quickstart/test/routes.test.ts +0 -1
  271. package/package.json +2 -1
package/docs/ActionMcp.md CHANGED
@@ -16,7 +16,6 @@ import { Layer } from "effect";
16
16
  import { Http } from "./Api.js";
17
17
  import { greeting } from "./greeting/handlers.js";
18
18
 
19
- // One implementation, two surfaces: a JSON route and an MCP tool at `/mcp`.
20
19
  export const routes = Layer.mergeAll(
21
20
  ActionHttp.layer(Http, greeting),
22
21
  ActionMcp.layerHttp(greeting, { name: "greetings", version: "1.0.0" })
@@ -42,27 +41,17 @@ import { Effect } from "effect";
42
41
 
43
42
  import { identity } from "./identity/handlers.js";
44
43
  import { CurrentUser } from "./identity/Identity.js";
45
- import { users } from "./identity/users.js";
44
+ import { demoUsers } from "./identity/users.js";
46
45
  import { notes } from "./notes/handlers.js";
47
46
  import { NoteStore } from "./notes/store.js";
48
47
  import { status } from "./status/handlers.js";
49
48
 
50
- // Entrypoint: an MCP server a local agent starts as a subprocess, such as
51
- // `claude mcp add notes -- "$PWD/node_modules/.bin/tsx" "$PWD/examples/notes-service/src/stdio.ts"`
52
- // from the repository root. The host starts the process in a directory it chooses, so `tsx`
53
- // and the file are named by full path.
54
- // The same implementations as the HTTP server, and the same `authorize`. No token arrives
55
- // over stdio, so this host names the caller itself. It is a process of its own with services
56
- // of its own. DEMO ONLY: this in-memory store holds its notes, not the running server's. To
57
- // share them, both provide a store they both reach, such as a database.
58
49
  ActionMcp.runStdio([status, notes, identity], {
59
50
  name: "notes-service",
60
51
  version: "1.0.0",
61
52
  }).pipe(
62
- // DEMO ONLY: a real host reads who started it, from its own login or configuration.
63
- Effect.provideService(CurrentUser, users.ada),
53
+ Effect.provideService(CurrentUser, demoUsers.ada),
64
54
  Effect.provide([NodeStdio.layer, NoteStore.layerMemory]),
65
- // stdout carries the protocol alone, so logs and failures go to stderr.
66
55
  ActionCli.logToStderr,
67
56
  NodeRuntime.runMain()
68
57
  );
@@ -114,7 +103,6 @@ import { Login } from "./identity/Identity.js";
114
103
  import { authenticate } from "./identity/verifier.js";
115
104
  import { Rpc } from "./Rpc.js";
116
105
 
117
- // Every domain's implementation, once: the events beside the actions, in one list.
118
106
  const implementations = [
119
107
  builds,
120
108
  logs,
@@ -124,17 +112,6 @@ const implementations = [
124
112
  deployEvents,
125
113
  ];
126
114
 
127
- // The actions as MCP tools and the events as MCP events, at `/mcp`. A client polls with
128
- // `events/poll`, or holds `events/stream` open and is pushed each occurrence. Both events are
129
- // protected, so each request needs a member's token, and each subscriber sees what its token
130
- // lets it. This long-lived process holds the deploy event's `subscription` hook between polls and
131
- // its log in memory, and pushes each occurrence: a `requestScoped` endpoint would serve the events
132
- // by poll and webhook alone, and a serverless host, where no process lasts, check sources alone,
133
- // without `Webhook.layer`.
134
- //
135
- // A tool answers one result, so `tailLog` would collect a whole log before answering, all of it
136
- // in a model's context: its implementation, `logs`, is left out, and the endpoint serves every
137
- // other action and every event.
138
115
  const mcp = ActionMcp.layerHttp(
139
116
  [builds, buildEvents, statusEvents, deploys, deployEvents],
140
117
  {
@@ -144,25 +121,13 @@ const mcp = ActionMcp.layerHttp(
144
121
  }
145
122
  );
146
123
 
147
- // The same implementations as routes under `/api`, for a client that speaks HTTP rather than
148
- // MCP: one implementation of each event serves every surface.
149
124
  const api = ActionHttp.layer(Http, implementations);
150
125
 
151
- // And as Effect RPC at `/rpc`, over HTTP. A watch is a stream rpc that never ends, so the
152
- // serialization frames each element as it is sent: `layerNdjson` does, where `layerJson` would
153
- // answer once every stream of the request ended, which a watch never does.
154
126
  const rpc = ActionRpc.layer(Rpc, implementations).pipe(
155
127
  Layer.provide(RpcServer.layerProtocolHttp({ path: "/rpc" })),
156
128
  Layer.provide(RpcSerialization.layerNdjson)
157
129
  );
158
130
 
159
- // Webhook delivery for MCP and HTTP alike: a member names a callback URL and a secret, with
160
- // MCP's `events/subscribe` or `POST /api/events/<name>/subscribe`, and each occurrence it may see
161
- // is POSTed there, signed. One layer holds the subscriptions of both, so either surface refreshes
162
- // one made over the other. `persist` keeps each in a `KeyValueStore`, so a restart goes on
163
- // delivering from where it reached, as the subscriber `Login`'s `schema` keeps. It needs an
164
- // `HttpClient` to POST, `Dns` to check where each callback resolves, and the store, which
165
- // `server.ts` provides.
166
131
  export const routes = Layer.mergeAll(mcp, api, rpc).pipe(
167
132
  Layer.provide(authenticate),
168
133
  Layer.provide(Webhook.layer({ persist: true }))
@@ -21,8 +21,6 @@ import {
21
21
  import { DeployRequested, RequestDeploy } from "./deploys/Deploys.js";
22
22
  import { Login } from "./identity/Identity.js";
23
23
 
24
- // The RPC binding: each action an rpc named after it, and each event a stream rpc named after
25
- // it, which pushes each occurrence as the server reads it. Plain data, as the HTTP binding is.
26
24
  export const Rpc = ActionRpc.make(
27
25
  [
28
26
  FinishBuild,
@@ -56,9 +54,6 @@ const idOf = Schema.decodeUnknownOption(
56
54
  Schema.NumberFromString.pipe(Schema.check(Schema.isInt()))
57
55
  );
58
56
 
59
- // A cursor this source gives is `<epoch>:<id>`, the store's epoch and the id of the last message
60
- // a page holds, so one from before a restart of the memory store is told apart. A page starting
61
- // a watch gives the id alone, as `readMessages`' `after` is, which is the store's now.
62
57
  const positionOf = (epoch: string, cursor: string | null) => {
63
58
  const parts =
64
59
  cursor?.includes(":") === true ? cursor.split(":") : [epoch, cursor];
@@ -68,9 +63,6 @@ const positionOf = (epoch: string, cursor: string | null) => {
68
63
  : Option.none();
69
64
  };
70
65
 
71
- // The room's messages as an event, read from the store that keeps them: a check source.
72
- // `postMessage` notifies after each post, so a page receives it at once, not at its next read
73
- // every 5 seconds.
74
66
  export const messageEvents = Event.implement(
75
67
  MessagePosted,
76
68
  Effect.gen(function* () {
@@ -87,9 +79,6 @@ export const messageEvents = Event.implement(
87
79
  (id) => id >= 0 && id <= last
88
80
  );
89
81
 
90
- // No cursor starts after the room's last message. One this room never gave, such as
91
- // one from before a restart, is answered `truncated` from there: the page learns its
92
- // messages may be another run's, and reads the room again with `readMessages`.
93
82
  if (Option.isNone(after)) {
94
83
  return {
95
84
  cursor: `${store.epoch}:${last}`,
@@ -102,17 +91,12 @@ export const messageEvents = Event.implement(
102
91
 
103
92
  return {
104
93
  cursor: `${store.epoch}:${messages.at(-1)?.id ?? after.value}`,
105
- // A message's id counts within its room and the store's epoch, so the event's id
106
- // names all three: a watch drops an id it has seen, and after a restart of the memory
107
- // store `lobby:1` is another message.
108
94
  events: messages.map((data) => ({
109
95
  eventId: `${store.epoch}:${room}:${data.id}`,
110
96
  data,
111
97
  })),
112
98
  };
113
99
  }),
114
- // A notify for one room wakes that room's pages alone: the key is the room the watch's
115
- // header names, read as `check` reads it.
116
100
  key: () => CurrentRoom,
117
101
  };
118
102
  }),
package/docs/ActionRpc.md CHANGED
@@ -14,10 +14,6 @@ import * as ActionRpc from "@gjermundgaraba/effect-actions/ActionRpc";
14
14
  import { ListRooms, MessagePosted, Messages } from "./chat/Chat.js";
15
15
  import { Login } from "./identity/Identity.js";
16
16
 
17
- // The RPC binding: one native rpc per action, named after it, and a stream rpc for
18
- // `MessagePosted`, the protected ones requiring `Login`. It is plain data and imports no server
19
- // code, so the server and a browser page both import this one value. `Rpc.group` is the native
20
- // `RpcGroup`, for Effect's own `RpcClient.make`.
21
17
  export const Rpc = ActionRpc.make([ListRooms, ...Messages, MessagePosted], {
22
18
  authentication: Login,
23
19
  });
@@ -39,19 +35,6 @@ import { ResolveRoom, resolveRoom } from "./chat/room.js";
39
35
  import { authenticate } from "./identity/verifier.js";
40
36
  import { Rpc } from "./Rpc.js";
41
37
 
42
- // The binding's rpcs on Effect's own RpcServer, the protected ones behind `Login`'s verifier;
43
- // `listRooms` needs no token.
44
- //
45
- // `ResolveRoom`, listed in `middleware`, provides `CurrentRoom`, which the handlers, the event's
46
- // source and `authorize` read; on a watch it runs as the watch starts, and each time it connects
47
- // again. Only something that runs per message can, since each message names its own room:
48
- // `Layer.succeed(CurrentRoom, "lobby")` provided here would leave the layer still requiring it,
49
- // in its type.
50
- //
51
- // It still requires four things, each chosen by whoever serves it. The protocol and its
52
- // serialization: server.ts gives it a WebSocket, and a test Effect's HTTP protocol, which
53
- // answers in memory. `MessageStore`, and `Event.Events`, which `postMessage` notifies and the
54
- // watches wait on: one of each, provided around the whole server.
55
38
  export const rpc = ActionRpc.layer(Rpc, [rooms, messages, messageEvents], {
56
39
  middleware: [ResolveRoom],
57
40
  }).pipe(Layer.provide([resolveRoom, authenticate]));
@@ -71,13 +54,6 @@ import { RpcSerialization, RpcServer } from "effect/rpc";
71
54
  import { MessageStore } from "./chat/store.js";
72
55
  import { rpc } from "./routes.js";
73
56
 
74
- // Entrypoint: `node --import tsx examples/live-rpc/src/server.ts`.
75
- // It chooses the protocol, the store and the port, and starts Node's HTTP server. It provides
76
- // no caller and no room: those arrive with each message.
77
-
78
- // The rpcs over a WebSocket at `/rpc`, the router's one route: Node's HTTP server answers the
79
- // upgrade. JSON, because a page's client speaks it: browser.ts gives its socket the same
80
- // serialization.
81
57
  const socket = rpc.pipe(
82
58
  Layer.provide(RpcServer.layerProtocolWebsocket({ path: "/rpc" })),
83
59
  Layer.provide(RpcSerialization.layerJson)
@@ -85,7 +61,6 @@ const socket = rpc.pipe(
85
61
 
86
62
  const server = Layer.unwrap(
87
63
  Effect.gen(function* () {
88
- // The loopback default serves this machine alone; HOST=0.0.0.0 lets others reach it.
89
64
  const host = yield* Config.String("HOST").pipe(
90
65
  Config.withDefault("127.0.0.1")
91
66
  );
@@ -97,18 +72,10 @@ const server = Layer.unwrap(
97
72
  NodeHttpServer.layer(createServer, {
98
73
  host,
99
74
  port,
100
- // A message on a WebSocket is no request body, so `HttpServerRequest.MaxBodySize`
101
- // does not bound it: Node's WebSocket server reads one of up to 100 MiB whole unless
102
- // told otherwise. A chat message is short, and a larger one closes the socket (1009).
103
75
  websocket: { maxPayload: 64 * 1024 },
104
76
  })
105
77
  ),
106
- // DEMO ONLY: messages live in this process's memory; a deployment provides a store that
107
- // lasts.
108
78
  Layer.provide(MessageStore.layerMemory),
109
- // The pages watching a room are this process's sockets, so what wakes them lives in its
110
- // memory too: one for the whole server. Several processes behind a balancer would each
111
- // wake only their own pages, the others reading a post at their next read, 5 seconds on.
112
79
  Layer.provide(Event.layerMemory)
113
80
  );
114
81
  })
@@ -138,37 +105,23 @@ import { Socket } from "effect/socket";
138
105
  import { MessagePosted, roomHeader } from "./chat/Chat.js";
139
106
  import { Rpc } from "./Rpc.js";
140
107
 
141
- // Client module: what a web page imports. It holds the binding and nothing of the server, so a
142
- // bundler gets the contracts and Effect's RPC client, no handler and nothing of Node.
143
-
144
- // Effect's own client protocol: one WebSocket, speaking the server's JSON. This layer owns
145
- // the socket, so a page provides it once, around its whole program, and every call shares
146
- // that one socket. Which WebSocket is left to the host: a page provides
147
- // `Socket.layerWebSocketConstructorGlobal`, the browser's own, and client.ts provides Node's.
148
108
  export const connection = (url: string) =>
149
109
  RpcClient.layerProtocolSocket().pipe(
150
110
  Layer.provide(Socket.layerWebSocket(url)),
151
111
  Layer.provide(RpcSerialization.layerJson)
152
112
  );
153
113
 
154
- // The chat as a page uses it, on the connection provided around it.
155
114
  export const openChat = Effect.gen(function* () {
156
- // One typed method per action of the binding, all on the one connection.
157
115
  const client = yield* ActionRpc.client(Rpc);
158
116
 
159
117
  return {
160
- // The public rpc: no token.
161
118
  rooms: Effect.map(client.listRooms(), ({ rooms }) => rooms),
162
119
 
163
120
  room: (name: string, token: string) => {
164
- // A browser WebSocket cannot set an `Authorization` header on its upgrade, so the token
165
- // travels on each message, and the room beside it. A refreshed token needs no new socket.
166
121
  const headers = { authorization: `Bearer ${token}`, [roomHeader]: name };
167
122
  const here = RpcClient.withHeaders(headers);
168
123
 
169
124
  return {
170
- // What the room holds after the last id the page has. A token may expire while the
171
- // page stays open, so each refusal becomes what the page shows.
172
125
  read: (after: number) =>
173
126
  client.readMessages({ after }).pipe(
174
127
  here,
@@ -189,14 +142,6 @@ export const openChat = Effect.gen(function* () {
189
142
 
190
143
  post: (text: string) => client.postMessage({ text }).pipe(here),
191
144
 
192
- // Each message posted to the room after the last id the page holds: a page opening a
193
- // room reads it, then watches from the last id it read, so a post between the two is
194
- // not lost; 0 sends the room's history first. `watch` connects again after a drop and
195
- // resumes from the last message it delivered, so the page never subscribes by hand; a
196
- // `Gap` says some were missed, or are another run's, so the page reads the room again
197
- // with `read(0)`. The headers go with the
198
- // stream, as `here` puts them on a call, and so with every request it sends again. A
199
- // refusal ends it, as when it connects again with a token that has expired.
200
145
  messages: (after: number) =>
201
146
  client
202
147
  .watch(MessagePosted, {}, { cursor: String(after) })
@@ -207,8 +152,6 @@ export const openChat = Effect.gen(function* () {
207
152
  )
208
153
  ),
209
154
 
210
- // A declared error arrives as the contract's class. A message someone else already
211
- // removed is gone, which is what the page asked for.
212
155
  remove: (id: number) =>
213
156
  client.deleteMessage({ id }).pipe(
214
157
  here,
@@ -250,17 +193,11 @@ export class CurrentRoom extends Context.Service<CurrentRoom, string>()(
250
193
  "live-rpc/CurrentRoom"
251
194
  ) {}
252
195
 
253
- // Native Effect RPC middleware, declared as providing `CurrentRoom`. Listed in
254
- // `ActionRpc.layer`'s `middleware`, it runs once per message.
255
196
  export class ResolveRoom extends RpcMiddleware.Service<
256
197
  ResolveRoom,
257
198
  { provides: CurrentRoom }
258
199
  >()("live-rpc/ResolveRoom") {}
259
200
 
260
- // The middleware's implementation. It gets the message's headers, which over a WebSocket are
261
- // the upgrade request's merged with the message's own, and runs the rest of the call with the
262
- // room they name, or the default room when they name none. It refuses nothing: whether the
263
- // caller may be in that room is `authorize`'s rule.
264
201
  export const resolveRoom = Layer.succeed(ResolveRoom, (call, { headers }) =>
265
202
  Effect.provideService(call, CurrentRoom, headers[roomHeader] ?? defaultRoom)
266
203
  );
@@ -18,12 +18,7 @@ import { CurrentCaller } from "./identity/Identity.js";
18
18
  import type { Member } from "./identity/Identity.js";
19
19
  import { tasks } from "./tasks/handlers.js";
20
20
 
21
- // `actions.layer` holds the handlers, and requires the startup services their builders read;
22
- // neither it nor `actions.toolkit` holds a caller.
23
21
  const actions = ActionToolkit.make([tasks, identity], {
24
- // One rule over every call a model makes, asked before the call runs. A read runs at once. A
25
- // write waits for a person to approve it, except a task the caller adds to their own list:
26
- // `call.name` narrows `call.input` to that action's. Without a caller, it asks.
27
22
  needsApproval: (call) =>
28
23
  !call.action.readOnly &&
29
24
  Effect.map(
@@ -36,8 +31,6 @@ const actions = ActionToolkit.make([tasks, identity], {
36
31
  ),
37
32
  });
38
33
 
39
- // A title for this assistant's approval display. The model still calls the tool `addTask`.
40
- // The later definition wins; annotating the generated tool keeps its handler and approval rule.
41
34
  export const toolkit = Toolkit.merge(
42
35
  actions.toolkit,
43
36
  Toolkit.make(actions.toolkit.tools.addTask.annotate(Tool.Title, "Add a task"))
@@ -45,10 +38,6 @@ export const toolkit = Toolkit.merge(
45
38
 
46
39
  export const { layer } = actions;
47
40
 
48
- // One toolkit serves every member, so who a turn runs as is provided around that turn. This is
49
- // how this example names a model's caller, and it takes a `Member`. The tools themselves accept
50
- // any `CurrentCaller`, so keeping the operator away from a model is this function's doing, and
51
- // that of every host using it.
52
41
  export const actingFor = (member: Member) =>
53
42
  Effect.provideService(CurrentCaller, member);
54
43
  ```
@@ -21,10 +21,6 @@ export class Tenant extends Context.Service<Tenant, Option.Option<string>>()(
21
21
  "tracker/Tenant"
22
22
  ) {}
23
23
 
24
- // Native router middleware. It provides `Tenant` to whatever it is provided to, per request:
25
- // to the verifier too, when it is provided after the authentication, in a `Layer.provide` of
26
- // its own: in one array with the authentication it would leave `Tenant` owed, since an array's
27
- // layers provide to the routes, not to one another.
28
24
  export const resolveTenant = HttpRouter.middleware<{ provides: Tenant }>()(
29
25
  (route) =>
30
26
  Effect.flatMap(HttpServerRequest.HttpServerRequest, (request) =>
@@ -59,32 +55,22 @@ import { CurrentMember, Session } from "../identity/Identity.js";
59
55
  import { GetAttachment } from "./Attachments.js";
60
56
  import { AttachmentStore } from "./store.js";
61
57
 
62
- // A route of the host's own: `GET /attachments/<id>` answers the image's bytes, for an `<img>`
63
- // of the web app, which no action can (an action answers JSON), behind
64
- // `Authentication.protect(Session)`: the page's cookie, which the web app's rpcs use. A token
65
- // holder has no use for it: `getAttachment` gives an API client the same image.
66
58
  export const download = Layer.unwrap(
67
59
  Effect.map(AttachmentStore, (store) =>
68
60
  HttpRouter.add(
69
61
  "GET",
70
62
  "/attachments/:id",
71
63
  Effect.gen(function* () {
72
- // The rule of the action it mirrors.
73
64
  yield* authorize(GetAttachment);
74
65
 
75
66
  const member = yield* CurrentMember;
76
67
  const { id = "" } = yield* HttpRouter.params;
77
68
  const { image } = yield* store.get(member.workspace, id);
78
69
 
79
- // An attachment never changes, but it is one workspace's: `private`.
80
70
  return HttpServerResponse.uint8Array(image.data, {
81
71
  contentType: image.mimeType,
82
72
  headers: {
83
73
  "cache-control": "private, max-age=31536000, immutable",
84
- // What a member uploaded is served from the application's own origin, and an image
85
- // can be a document: an SVG opened by its URL, not in an `<img>`, runs its scripts
86
- // as the member reading it. `sandbox` gives it no origin and no scripts, and
87
- // `nosniff` keeps the browser to the type stated.
88
74
  "content-security-policy": "sandbox",
89
75
  "x-content-type-options": "nosniff",
90
76
  },
@@ -113,13 +99,6 @@ import { allowedOrigins, publicUrl } from "./config.js";
113
99
 
114
100
  const loopback = ["localhost", "127.0.0.1"];
115
101
 
116
- // Which Host and Origin a request may carry: not the library's concern, but every request of
117
- // both ports passes it first. A Host that is neither loopback nor the public URL's is refused,
118
- // against DNS rebinding. The web app signs in with a cookie, which a browser attaches to
119
- // any page's request, so a foreign Origin must be refused before authentication reads it.
120
- // That is why this is global router middleware (`global: true`): it runs before routing, so
121
- // before every route's authentication. As a layer's own `middleware` it would run inside the
122
- // authentication, too late.
123
102
  export const requestPolicy = HttpRouter.middleware(
124
103
  Effect.gen(function* () {
125
104
  const hosts = new Set([...loopback, new URL(yield* publicUrl).hostname]);
@@ -139,10 +118,6 @@ export const requestPolicy = HttpRouter.middleware(
139
118
 
140
119
  const { origin } = request.headers;
141
120
 
142
- // The request's own origin is that of a page served from this port directly. Behind a
143
- // proxy ending TLS it is an `http:` one from Effect 4.0.6, whose `originalUrl` takes the
144
- // scheme of the connection, whatever `X-Forwarded-Proto` says, so the public URL's
145
- // origin is among `origins`.
146
121
  if (
147
122
  origin !== undefined &&
148
123
  origin !== url.value.origin &&
@@ -157,12 +132,6 @@ export const requestPolicy = HttpRouter.middleware(
157
132
  { global: true }
158
133
  );
159
134
 
160
- // CORS for the one cross-origin caller, a browser MCP client. `HttpRouter.cors` is global to
161
- // the router too: it answers the preflight before any route's authentication, and adds its
162
- // headers to refusals as well. An MCP endpoint's `allowedOrigins` is no CORS: it only refuses
163
- // origins. The headers are those an MCP client sends and must be able to read. A client of an
164
- // MCP revision with sessions sends its session's id on each request, reads it from the answer
165
- // that opened the session, and ends the session with a `DELETE`.
166
135
  export const cors = Layer.unwrap(
167
136
  Effect.map(allowedOrigins, (origins) =>
168
137
  HttpRouter.cors({
@@ -30,8 +30,6 @@ export class CurrentUser extends Context.Service<CurrentUser, User>()(
30
30
  "notes-service/CurrentUser"
31
31
  ) {}
32
32
 
33
- // How a remote caller proves it is CurrentUser: a bearer token, the default scheme. Clients
34
- // import this descriptor with the binding; its verifier, in verifier.ts, stays on the server.
35
33
  export const Login = Authentication.make("notes-service.Login", CurrentUser);
36
34
 
37
35
  export const WhoAmI = Action.make("whoAmI", {
@@ -56,27 +54,21 @@ import * as Authentication from "@gjermundgaraba/effect-actions/Authentication";
56
54
  import { Config, Effect, Redacted } from "effect";
57
55
 
58
56
  import { Login, scopes } from "./Identity.js";
59
- import { users } from "./users.js";
57
+ import { demoUsers } from "./users.js";
60
58
 
61
- const isToken = (token: string): token is keyof typeof users =>
62
- Object.hasOwn(users, token);
59
+ const isToken = (token: string): token is keyof typeof demoUsers =>
60
+ Object.hasOwn(demoUsers, token);
63
61
 
64
- // DEMO ONLY: a token is a user's name. A real verifier checks a signed token with your
65
- // authorization server's library, its audience included. An unknown token is the built-in
66
- // `Unauthenticated`: a 401 every client decodes.
67
62
  const verify = (token: Redacted.Redacted) => {
68
63
  const name = Redacted.value(token);
69
64
 
70
65
  return isToken(name)
71
- ? Effect.succeed(users[name])
66
+ ? Effect.succeed(demoUsers[name])
72
67
  : Effect.fail(
73
68
  new Action.Unauthenticated({ message: "Unknown demo token." })
74
69
  );
75
70
  };
76
71
 
77
- // Server only: `Login`'s provider. As an OAuth protected resource it also publishes discovery,
78
- // so an MCP client that gets a 401 finds where to sign in, asking for read first. The resource
79
- // is the server's public URL, known only at startup, so it is read from config.
80
72
  export const authenticate = Authentication.layer(Login, verify, {
81
73
  protectedResource: Effect.map(
82
74
  Config.String("PUBLIC_URL").pipe(
@@ -85,7 +77,6 @@ export const authenticate = Authentication.layer(Login, verify, {
85
77
  (url) =>
86
78
  ({
87
79
  resource: `${url}/mcp`,
88
- // DEMO ONLY: no server is there. Yours is your authorization server's issuer.
89
80
  authorizationServers: ["https://auth.example.com"],
90
81
  scopesSupported: [scopes.read, scopes.write],
91
82
  scopesRequired: [scopes.read],
package/docs/Event.md CHANGED
@@ -31,8 +31,6 @@ export const Build = Schema.Struct({
31
31
 
32
32
  export type Build = typeof Build.Type;
33
33
 
34
- // DEMO ONLY: a CI runner reports finished builds; here a member does, so the example can
35
- // cause the event it watches.
36
34
  export const FinishBuild = Action.make("finishBuild", {
37
35
  description: "Record that a build of a pipeline finished.",
38
36
  input: { pipeline: Pipeline, status: Status },
@@ -41,10 +39,6 @@ export const FinishBuild = Action.make("finishBuild", {
41
39
  caller: CurrentMember,
42
40
  });
43
41
 
44
- // A build run here, which reports each step as it starts, before it answers how the build ended.
45
- // A caller reads the steps only if it asks, with `onProgress`; each surface carries them its
46
- // own way. They are a snapshot to show: a caller falling behind misses some, never the answer.
47
- // What a caller must see every time is the answer, or `build.finished`, which this build causes.
48
42
  export const StartBuild = Action.make("startBuild", {
49
43
  description:
50
44
  "Run a build of a pipeline, reporting each step, and record how it ended.",
@@ -65,16 +59,11 @@ export const StartBuild = Action.make("startBuild", {
65
59
  caller: CurrentMember,
66
60
  });
67
61
 
68
- // A build this member may not see is not found, as one that never ran: its id tells nothing.
69
62
  export class BuildNotFound extends Schema.TaggedError<
70
63
  BuildNotFound,
71
64
  { readonly brand: unique symbol }
72
65
  >()("BuildNotFound", { buildId: Schema.String }, { httpApiStatus: 404 }) {}
73
66
 
74
- // An action answering a stream: its handler returns a `Stream` of lines, and every client's
75
- // call returns one, each line arriving as the server sends it. HTTP, RPC and a command carry a
76
- // stream; an MCP tool answers one result, the lines collected once the stream ends, so the MCP
77
- // endpoint in `routes.ts` leaves it out rather than put a whole log in a model's context.
78
67
  export const TailLog = Action.make("tailLog", {
79
68
  description: "Stream a build's log, line by line.",
80
69
  input: {
@@ -88,8 +77,6 @@ export const TailLog = Action.make("tailLog", {
88
77
  caller: CurrentMember,
89
78
  });
90
79
 
91
- // An event type: what a subscription takes, what each occurrence carries, and who may
92
- // subscribe. Like an action's contract, it imports no server code.
93
80
  export const BuildFinished = Event.make("build.finished", {
94
81
  description: "A build of a pipeline you may see finished.",
95
82
  input: {
@@ -104,8 +91,6 @@ export const BuildFinished = Event.make("build.finished", {
104
91
  caller: CurrentMember,
105
92
  });
106
93
 
107
- // An event whose occurrence is the whole value: how a pipeline's last build ended, `null` before
108
- // its first. A subscriber is sent it as it is, then again each time a build of it finishes.
109
94
  export const PipelineStatus = Event.make("pipeline.status", {
110
95
  description:
111
96
  "How a pipeline's last build ended: first as it is, then each time one finishes.",
@@ -133,9 +118,6 @@ import { CurrentMember } from "../identity/Identity.js";
133
118
  import { BuildFinished } from "./Builds.js";
134
119
  import { BuildStore } from "./store.js";
135
120
 
136
- // A check source: one function answers "what finished since this cursor?" for every
137
- // subscriber, whether it polls or holds a stream open, on every surface. The builder runs once,
138
- // at startup; the check runs per subscriber, as that subscriber.
139
121
  export const buildEvents = Event.implement(
140
122
  BuildFinished,
141
123
  Effect.gen(function* () {
@@ -146,8 +128,6 @@ export const buildEvents = Event.implement(
146
128
  Effect.gen(function* () {
147
129
  const member = yield* CurrentMember;
148
130
 
149
- // A first subscription asks with `null`: the store answers the current position, so
150
- // the subscriber starts from now.
151
131
  const page = yield* store.finishedSince(
152
132
  member.pipelines,
153
133
  cursor,
@@ -157,7 +137,6 @@ export const buildEvents = Event.implement(
157
137
  return {
158
138
  cursor: page.cursor,
159
139
  hasMore: page.hasMore,
160
- // A cursor the store cannot resume from: the subscriber is sent a gap first.
161
140
  truncated: page.truncated,
162
141
  events: page.builds
163
142
  .filter(
@@ -166,9 +145,6 @@ export const buildEvents = Event.implement(
166
145
  .filter(
167
146
  (build) => status === undefined || build.status === status
168
147
  )
169
- // The store's own id, within its epoch: a subscriber that sees a build twice,
170
- // after a reconnect, drops the second, and never drops a build of a restarted store
171
- // as one it saw before.
172
148
  .map((build) => ({
173
149
  eventId: `${page.epoch}/${build.id}`,
174
150
  data: build,
@@ -177,7 +153,6 @@ export const buildEvents = Event.implement(
177
153
  }),
178
154
  };
179
155
  }),
180
- // Every member may watch; which builds each sees is the store's check, by pipeline.
181
156
  { authorize: Event.allowAll }
182
157
  );
183
158
  ```
@@ -200,9 +175,6 @@ import { CurrentMember } from "../identity/Identity.js";
200
175
  import { PipelineStatus } from "./Builds.js";
201
176
  import { BuildStore } from "./store.js";
202
177
 
203
- // A current source: the value as it is, which the library sends first and again after each
204
- // notify reaching the subscriber's key, keeping the revision that tells them apart, so the store
205
- // keeps no cursor for it. The key is the pipeline: a build of another wakes no one here.
206
178
  export const statusEvents = Event.implement(
207
179
  PipelineStatus,
208
180
  Effect.gen(function* () {
@@ -218,7 +190,6 @@ export const statusEvents = Event.implement(
218
190
  key: ({ pipeline }) => pipeline,
219
191
  };
220
192
  }),
221
- // Every member may watch; which pipelines each sees is the store's check.
222
193
  { authorize: Event.allowAll }
223
194
  );
224
195
  ```
@@ -237,11 +208,6 @@ import { CurrentMember } from "../identity/Identity.js";
237
208
  import { Approvers } from "./approvers.js";
238
209
  import { DeployRequested } from "./Deploys.js";
239
210
 
240
- // A log source, for occurrences nothing else keeps: the library keeps each one `requestDeploy`
241
- // publishes, for 10 minutes and at most 10,000 of them by default, and gives each subscriber
242
- // what its `match` accepts. A subscriber resuming from a cursor gets what the log still holds:
243
- // after a restart, or once its occurrences are dropped, a gap first. An upstream you can ask
244
- // "what since?", such as a table, is a check source.
245
211
  export const deployEvents = Event.implement(
246
212
  DeployRequested,
247
213
  Effect.gen(function* () {
@@ -251,9 +217,6 @@ export const deployEvents = Event.implement(
251
217
  log: {},
252
218
  match: ({ environment }, deploy) =>
253
219
  environment === undefined || deploy.environment === environment,
254
- // Set up while each subscription lasts, as the subscriber: a stream's as long as it is
255
- // read, a poll's until 5 minutes after its last poll. It may run again for one
256
- // subscription, after a restart, so standing by twice must be harmless.
257
220
  subscription: ({ environment }) =>
258
221
  Effect.flatMap(CurrentMember, (member) =>
259
222
  approvers.standBy(environment, member.id)
package/docs/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  **Arriving with an error?** A message the library throws says its fix; for any other, step 5.
8
8
 
9
9
  1. **Open one page per tool call, with your file-reading tool.** Pages are kept small to reduce truncation. Several in one call, however many commands it runs, can be cut by its output limit, with no mark or with one that understates what is lost. If an output says it was truncated, read that page again alone.
10
- 2. **Start from the example closest to what you are building** ([Examples](#examples)). Its README has a layout tree, and all but quickstart's a "Where to look" table naming the file for each thing. Copy its layout and idioms: the examples are the reference for how code is written, and its comments carry the traps it shows. An example shows one way, not the rules or the alternatives: read steps 3 and 4 even when it fits.
10
+ 2. **Start from the example closest to what you are building** ([Examples](#examples)). Its README has a layout tree, and all but quickstart's a "Where to look" table naming the file for each thing. Copy its layout and idioms: the examples are the reference for how code is written, and its code carries the traps it shows. An example shows one way, not the rules or the alternatives: read steps 3 and 4 even when it fits.
11
11
  3. **Read [Action.md](Action.md) completely.** Every surface builds on it.
12
12
  4. **Read the page of each surface you serve** ([Pages](#pages)), and the example files its task sections link.
13
13
  5. **For a compiler diagnostic or Effect's own error, search the `*-failures.md` pages** for a fragment of the message without quotes, your own code's first compile error included: `grep -rnF "<fragment>" node_modules/@gjermundgaraba/effect-actions/docs/*-failures.md`. Each module page has one beside it, such as [Action-failures.md](Action-failures.md).