@gjermundgaraba/effect-actions 0.36.0 → 0.38.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 (41) hide show
  1. package/README.md +7 -7
  2. package/dist/Action.d.mts +2 -2
  3. package/dist/Action.mjs +1 -1
  4. package/dist/ActionEntity.mjs +1 -0
  5. package/dist/ActionHttp.d.mts +2 -2
  6. package/dist/ActionMcp.d.mts +5 -3
  7. package/dist/ActionMcp.mjs +23 -6
  8. package/dist/ActionRpc.d.mts +4 -4
  9. package/dist/ActionRpc.mjs +7 -4
  10. package/dist/Event.d.mts +2 -2
  11. package/dist/authentication/provider.d.mts +0 -22
  12. package/dist/authentication/refusal.mjs +0 -4
  13. package/dist/contract/authorizer.d.mts +0 -4
  14. package/dist/contract/call.mjs +0 -4
  15. package/dist/contract/caller.mjs +0 -1
  16. package/dist/contract/declared.d.mts +0 -1
  17. package/dist/contract/errors.d.mts +1 -1
  18. package/dist/contract/errors.mjs +1 -1
  19. package/dist/contract/feed.d.mts +0 -3
  20. package/dist/contract/feed.mjs +0 -3
  21. package/dist/contract/hub.mjs +0 -10
  22. package/dist/contract/implementation.d.mts +4 -27
  23. package/dist/contract/implementation.mjs +0 -9
  24. package/dist/contract/progress.d.mts +0 -1
  25. package/dist/contract/subscribe.mjs +0 -1
  26. package/dist/contract/webhooks.mjs +0 -13
  27. package/dist/entity/wakes.mjs +2 -5
  28. package/dist/http/client.mjs +8 -2
  29. package/dist/http/streamed.d.mts +6 -5
  30. package/dist/http/streamed.mjs +17 -3
  31. package/dist/mcp/client.d.mts +4 -3
  32. package/dist/mcp/client.mjs +11 -5
  33. package/dist/mcp/progress.mjs +1 -1
  34. package/dist/mcp/protocol.mjs +6 -3
  35. package/dist/mcp/reply.d.mts +8 -4
  36. package/dist/mcp/reply.mjs +9 -5
  37. package/dist/rpc/erased.d.mts +0 -11
  38. package/dist/rpc/erased.mjs +1 -6
  39. package/docs/ActionMcp.md +1 -0
  40. package/docs/setup.md +1 -1
  41. package/package.json +12 -12
package/README.md CHANGED
@@ -29,7 +29,7 @@ const greeting = Action.implement(Greet, ({ name }) =>
29
29
  A binding gives it a route, for the server to serve and a client to call:
30
30
 
31
31
  ```ts
32
- const Http = ActionHttp.make([Greet]); // POST /api/greet
32
+ const Http = ActionHttp.make([Greet]);
33
33
  ```
34
34
 
35
35
  And the same implementation is served on every surface the host wants:
@@ -44,13 +44,13 @@ const routes = Layer.mergeAll(
44
44
  Serve `routes` with Effect's `HttpRouter.serve` and a platform server, as [examples/quickstart](examples/quickstart) does, file by file, and you have `POST /api/greet` and an MCP tool named `greet` at `/mcp`. The same `greeting` implementation is also:
45
45
 
46
46
  ```ts
47
- const { toolkit, layer } = ActionToolkit.make(greeting); // native Effect AI Toolkit and its handler layer
48
- const cli = ActionCli.make(greeting, { name: "greetings" }); // greetings greet --name Ada
47
+ const { toolkit, layer } = ActionToolkit.make(greeting);
48
+ const cli = ActionCli.make(greeting, { name: "greetings" });
49
49
  const remote = ActionCli.remoteCommand(Http, Greet, {
50
50
  client: ActionHttp.client(Http, { baseUrl }),
51
- }); // greet --name Ada, over HTTP
52
- const local = Action.client(greeting); // the HTTP client's methods, in process
53
- const rpc = ActionRpc.layer(ActionRpc.make([Greet]), greeting); // Effect RPC, on the protocol the host provides
51
+ });
52
+ const local = Action.client(greeting);
53
+ const rpc = ActionRpc.layer(ActionRpc.make([Greet]), greeting);
54
54
  ```
55
55
 
56
56
  And the client is Effect's own `HttpApiClient`, typed from the same contract, one method per action:
@@ -59,7 +59,7 @@ And the client is Effect's own `HttpApiClient`, typed from the same contract, on
59
59
  Effect.gen(function* () {
60
60
  const client = yield* ActionHttp.client(Http, { baseUrl });
61
61
 
62
- return yield* client.greet({ name: "Ada" }); // "Hello, Ada!"
62
+ return yield* client.greet({ name: "Ada" });
63
63
  });
64
64
  ```
65
65
 
package/dist/Action.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Authorizer, Deferred as Deferred$1 } from "./contract/authorizer.mjs";
1
+ import { Deferred as Deferred$1 } from "./contract/authorizer.mjs";
2
2
  import { Call } from "./contract/call.mjs";
3
3
  import { Anyone } from "./contract/caller.mjs";
4
4
  import { Codec, CodecOf, Fields, NoInput } from "./contract/codec.mjs";
@@ -284,7 +284,7 @@ export declare const allowAll: Authorize<Any>;
284
284
  export declare function implement<const T extends Target, RequestServices extends (T extends readonly Any[] ? { readonly [K in NamesOf<T>]: unknown; } : never), R = never, EX = never, RX = never, RA = never, EAX = never, RAX = never>(actions: T, handlers: HandlersOf<T, R, RequestServices> | Effect.Effect<HandlersOf<T, R, RequestServices>, EX, RX>, options: [Protected<ActionsOf<T>>] extends [never] ? {
285
285
  readonly authorize?: "A public-only target takes no authorize";
286
286
  } | undefined : {
287
- readonly authorize: Authorizer<Protected<ActionsOf<T>>, RA, EAX, RAX>;
287
+ readonly authorize: ((contract: Protected<ActionsOf<T>>) => Effect.Effect<void, Refusal, RA>) | Effect.Effect<(contract: Protected<ActionsOf<T>>) => Effect.Effect<void, Refusal, RA>, EAX, RAX>;
288
288
  }): Implemented<T, RequestServices, R, EX, RX, RA, EAX, RAX>;
289
289
  export declare function implement<const T extends Target, RequestServices extends (T extends readonly Any[] ? { readonly [K in NamesOf<T>]: unknown; } : never), R = never, EX = never, RX = never>(actions: T & TakesNoAuthorize<T>, handlers: HandlersOf<T, R, RequestServices> | Effect.Effect<HandlersOf<T, R, RequestServices>, EX, RX>): Implemented<T, RequestServices, R, EX, RX, never, never, never>;
290
290
  /**
package/dist/Action.mjs CHANGED
@@ -86,7 +86,7 @@ function implement(actions, handlers, options) {
86
86
  return bound;
87
87
  };
88
88
  const paired = Effect.isEffect(handlers) ? Effect.map(handlers, pairWithActions) : Effect.succeed(pairWithActions(handlers));
89
- const recorded = listed.some((action) => action.idempotencyKey !== void 0) ? Effect.flatMap(paired, (written) => Effect.map(Effect.service(Idempotency), (store) => written.map(([action, handle]) => [action, keyed(action, store, handle)]))) : paired;
89
+ const recorded = listed.some((action) => action.idempotencyKey !== void 0) ? Effect.zipWith(paired, Effect.service(Idempotency), (written, store) => written.map(([action, handle]) => [action, keyed(action, store, handle)])) : paired;
90
90
  return new Implementation(listed, memoized(recorded), authorizer);
91
91
  }
92
92
  function layer(implementations) {
@@ -72,6 +72,7 @@ const wakeAt = (at) => Effect.flatMap(Wake, (wake) => wake.wakeAt(Math.ceil(Date
72
72
  const callOf = (request, rpc) => ({
73
73
  client: new Rpc.ServerClient(0),
74
74
  requestId: RpcMessage.RequestId(String(request.requestId)),
75
+ remoteParentSpan: void 0,
75
76
  headers: request.headers,
76
77
  rpc
77
78
  });
@@ -162,7 +162,7 @@ export declare function make<const Contracts extends ReadonlyArray<Any$1 | Any$2
162
162
  * **Gotchas**
163
163
  *
164
164
  * - A success is its JSON as the body; an action without `success` answers an empty 200, no body and no content type, so a hand-written client must not parse it, or an empty 204 where it declares `progress`. One without `input` still takes the body `{}` typed as JSON: no body is a 400.
165
- * - An action declaring `progress` answers a request whose `Accept` names `text/event-stream`, whatever else it names, with an SSE stream, listed in OpenAPI: a `progress` event for each value, its data the value's JSON, then one `final` event holding the answer's JSON, `null` for none; without that `Accept` it answers as any action, its progress dropped.
165
+ * - An action declaring `progress` answers a request whose `Accept` explicitly allows `text/event-stream` at nonzero quality with an SSE stream, listed in OpenAPI: a `progress` event for each value, its data the value's JSON, then one `final` event holding the answer's JSON, `null` for none; without that `Accept` it answers as any action, its progress dropped.
166
166
  * - An action answering a stream, `Action.Stream`, answers an SSE stream alone, whatever `Accept` says: an `element` event for each element, its data the element's JSON, and a `progress` event for each value where it declares `progress`; a stream of none answers a 200 with no event. A failure before the first event answers its status; one after ends the stream as Effect's stream failure event, a defect as `Internal server error`.
167
167
  * - The stream starts with the call's first event, so a failure before it, a refusal included, answers as it would without the stream; a declared failure after it ends the stream with Effect's `effect/http-api/stream/failure` event, reported as `Info` as without the stream, and a defect or an answer that does not encode with one saying `Internal server error`, its cause logged and reported.
168
168
  * - An action's SSE stream writes a `: keepalive` comment every 15 seconds from its first event until it ends, events or not, which SSE clients skip, so a proxy closing a silent response keeps it open through a slow step; before the first event no response has started, so a proxy timing out a response's start still ends a call silent that long.
@@ -197,7 +197,7 @@ export declare function layer<const H extends AnyHttp, const Apps extends Served
197
197
  * - `watch(event, input, options)` holds the event's SSE stream open, or polls its pages with `mode: "poll"`, as `Action.client`'s; a watch of an event the server does not serve, its route a 404, fails with `Event.SubscriptionError`, reason `NotServed`.
198
198
  * - A watch reconnects after the transport fails, a status such as 502, `Action.Unavailable`, or 60 seconds without an answer or a frame, a second later and doubling to 30 seconds, each reconnect logged as a warning; another declared error, a refusal included, ends it.
199
199
  * - A watch's stream ends at an SSE `retry:` field, which `ActionHttp.layer` never sends, as Effect's client decodes it, and the watch connects again: a server or proxy sending one as each stream starts delivers nothing.
200
- * - A call of an action declaring `progress` reads the route's event stream, as every request accepts it, and its answer from the `final` event; the server sends the values whether or not the call gave `onProgress`, and without one they are dropped.
200
+ * - A call of an action declaring `progress` reads the route's `text/event-stream` response and its answer from the `final` event; the server sends the values whether or not the call gave `onProgress`, and without one they are dropped.
201
201
  * - A call of an action answering a stream returns a `Stream` of its elements, failing as the route's stream fails, with `Sse.SseError` or `Sse.Retry` too; its `onProgress` gets each `progress` event, which the server sends whether or not the call gave one.
202
202
  */
203
203
  export declare function client<const H extends AnyHttp>(binding: H, options?: Options): Effect.Effect<Client<H>, never, HttpClient.HttpClient>;
@@ -117,13 +117,15 @@ type Inferring<D, A extends Pick<Any$1, "caller">> = [D] extends [undefined] ? [
117
117
  * **Gotchas**
118
118
  *
119
119
  * - A success is `isError: false` with `structuredContent` its JSON and the same JSON as one text block, both `null` for an action without `success`; an `Action.Image` field is left out of `structuredContent` and its text, its block following them, and a success of images alone has no `structuredContent`.
120
- * - A declared error is an `isError: true` tool result in a 200 holding its JSON as one text block, with no `structuredContent`; a refusal is answered as `Action.Unauthenticated` and `Action.Forbidden` say.
120
+ * - A success whose schema encodes only to a string, such as `Schema.String`, a string literal or `Schema.DateTimeUtc`, is its raw text as one text block on every revision, with no `structuredContent` and no `outputSchema`, since Claude Code shows a model serialized `structuredContent` in place of every text block: return file contents or command output as such a string, never as a field of an object, which reaches a model JSON-escaped.
121
+ * - A union holding a string, such as `Schema.NullOr(Schema.String)` or an optional string, is sent as any other success, so a 2026-07-28 client gets the string as `structuredContent` and JSON-quoted text, which reaches a Claude Code model escaped: return `""` for nothing, not `null`.
122
+ * - A declared error is an `isError: true` tool result in a 200 whose one text block is its `message`, or the error itself when it is a string, or its JSON when it has no `message` or an empty one, with its JSON in `_meta["io.github.gjermundgaraba.effect-actions/error"]`, from which `client` decodes it, and no `structuredContent`: write each `message` for the model, since its other fields reach a model only through it; a refusal is answered as `Action.Unauthenticated` and `Action.Forbidden` say.
121
123
  * - An action answering a stream, `Action.Stream`, answers its elements collected into one array once the stream ends, a success of that array.
122
- * - An action declaring `progress` sends each value as `notifications/progress` on the `progressToken` its call's `_meta` carries, before the result: `progress` counts from 1, `message` is the value's JSON and `_meta["effect-actions/progress"]` the value; a call without a token gets none.
124
+ * - An action declaring `progress` sends each value as `notifications/progress` on the `progressToken` its call's `_meta` carries, before the result: `progress` counts from 1, `message` is the value's JSON and `_meta["io.github.gjermundgaraba.effect-actions/progress"]` the value; a call without a token gets none.
123
125
  * - Arguments that do not decode never reach the handler: an `isError: true` result in a 200, text `Invalid parameters for tool '<name>': …`, or for a 2025-06-18 client a JSON-RPC error.
124
126
  * - A defect, an undeclared failure, or a success or an error that does not encode is `isError: true`, text `Tool execution failed due to an internal server error.`: the cause goes to the log and to the call's `ErrorReporter`s, never to the client.
125
127
  * - An unknown tool is a JSON-RPC error `-32602` in a 200; a body that is not JSON a JSON-RPC error `-32700` in a 200; a `Content-Type` missing or not JSON an empty 415; another HTTP method an empty 405 with `Allow: POST, DELETE`, `Allow: POST` where `requestScoped`, or the 401 of an endpoint with authentication when signed out.
126
- * - A 2025-11-25 or 2025-06-18 client gets `structuredContent` only for a success that is an object: any other success arrives as its text block alone, a string unquoted.
128
+ * - A 2025-11-25 or 2025-06-18 client gets `structuredContent` only for a success that is an object: a number, an array or `null` arrives as its JSON text block alone, and a string a union success returns as its text unquoted.
127
129
  * - A client asking for an earlier revision, such as 2025-03-26, is offered 2025-11-25, so a client speaking only that earlier one cannot connect.
128
130
  * - A request body is read whole, however large, and a 2025 session holds what its `initialize` sent until it ends, so an oversized `initialize` costs memory for that long: limit bodies as `ActionHttp.layer` says.
129
131
  * - An event type named starting with `mcp.`, a prefix MCP keeps for its own events, is refused as the endpoint is made, with `MCP event name starts with "mcp."`.
@@ -13,7 +13,7 @@ import { servingFeeds } from "./contract/webhooks.mjs";
13
13
  import { withStderrConsole } from "./stdio/console.mjs";
14
14
  import { eventSchemasOf, withEvents } from "./mcp/bridge.mjs";
15
15
  import { progressNotifier } from "./mcp/progress.mjs";
16
- import { defaultPath, fieldKey, httpProtocol, isMisplaced, isObjectSchema, protocols, toolJsonSchema } from "./mcp/protocol.mjs";
16
+ import { defaultPath, errorKey, fieldKey, httpProtocol, isMisplaced, isObjectSchema, isText, protocols, toolJsonSchema } from "./mcp/protocol.mjs";
17
17
  import { client } from "./mcp/client.mjs";
18
18
  import { McpCallError } from "./mcp/reply.mjs";
19
19
  import { request } from "./mcp/request.mjs";
@@ -39,6 +39,18 @@ const nativeJsonTextOf = (encoded) => encoded === void 0 ? [] : [{
39
39
  type: "text",
40
40
  text: JSON.stringify(encoded)
41
41
  }];
42
+ const errorTextOf = (encoded) => {
43
+ if (Predicate.isString(encoded)) return encoded;
44
+ return Predicate.hasProperty(encoded, "message") && Predicate.isString(encoded.message) && encoded.message !== "" ? encoded.message : JSON.stringify(encoded);
45
+ };
46
+ const declaredErrorResult = (encoded) => new McpSchema.CallToolResult({
47
+ isError: true,
48
+ content: [{
49
+ type: "text",
50
+ text: errorTextOf(encoded)
51
+ }],
52
+ _meta: { [errorKey]: encoded }
53
+ });
42
54
  const contentBlockOf = ({ kind, field, value }) => ({
43
55
  type: kind,
44
56
  data: value.data,
@@ -72,7 +84,8 @@ const registerTools = Effect.fnUntraced(function* (apps, authentication) {
72
84
  const lift = liftOf(toolSuccess);
73
85
  const media = lift.fields.length === 0 ? void 0 : lift;
74
86
  const structuredSuccess = media === void 0 ? toolSuccess : media.rest;
75
- const structured = structuredSuccess === void 0 ? void 0 : Schema.toCodecJson(structuredSuccess);
87
+ const text = media === void 0 && isText(toolSuccess);
88
+ const structured = structuredSuccess === void 0 || text ? void 0 : Schema.toCodecJson(structuredSuccess);
76
89
  const outputSchema = structured === void 0 ? void 0 : yield* Schema.decodeUnknownEffect(McpSchema.ToolOutputJson)(toolJsonSchema(structured, false)).pipe(Effect.orDie);
77
90
  const tool = yield* toolOf(action, outputSchema).pipe(Effect.orDie);
78
91
  const decode = Schema.decodeUnknownEffect(Schema.toCodecJson(action.input), inputParseOptions);
@@ -82,6 +95,13 @@ const registerTools = Effect.fnUntraced(function* (apps, authentication) {
82
95
  const call = (input) => asCaller(authentication, action, reported(input));
83
96
  const liftedFieldNames = new Set(media?.fields.map(({ name }) => name));
84
97
  const resultOf = (encoded, success) => {
98
+ if (text) return new McpSchema.CallToolResult({
99
+ isError: false,
100
+ content: [{
101
+ type: "text",
102
+ text: encoded
103
+ }]
104
+ });
85
105
  if (media === void 0) return new McpSchema.CallToolResult({
86
106
  isError: false,
87
107
  structuredContent: encoded,
@@ -107,10 +127,7 @@ const registerTools = Effect.fnUntraced(function* (apps, authentication) {
107
127
  toolName: action.name,
108
128
  description: message
109
129
  }).message })), Effect.flatMap((input) => call(input).pipe(Effect.matchEffect({
110
- onFailure: (error) => Effect.map(encodeFailure(error), (encoded) => new McpSchema.CallToolResult({
111
- isError: true,
112
- content: nativeJsonTextOf(encoded)
113
- })),
130
+ onFailure: (error) => Effect.map(encodeFailure(error), declaredErrorResult),
114
131
  onSuccess: (success) => Effect.map(encodeSuccess(success), (encoded) => resultOf(encoded, success))
115
132
  }))), Effect.catchCause(internalErrorOnDefect))
116
133
  });
@@ -4,7 +4,7 @@ import { Call } from "./contract/call.mjs";
4
4
  import { Anyone } from "./contract/caller.mjs";
5
5
  import { Codec } from "./contract/codec.mjs";
6
6
  import { Certain, ErrorsOf } from "./contract/declared.mjs";
7
- import { BuiltIn, BuiltIns, Unauthenticated } from "./contract/errors.mjs";
7
+ import { BuiltIn, BuiltIns, Forbidden, Unauthenticated } from "./contract/errors.mjs";
8
8
  import { Any as Any$3, Received, SubscriptionError } from "./Event.mjs";
9
9
  import { EventBuildError, EventBuildServices, EventServedRequest, HoldingEvents, ServingEvents } from "./contract/feed.mjs";
10
10
  import { BuildError, Holding, Known, Member, MiddlewareOf, Selected, SelectedEvents, Served } from "./contract/implementation.mjs";
@@ -28,7 +28,7 @@ type ElementedOf<Element extends Schema.Constraint, P> = Schema.Union<readonly [
28
28
  type RpcOf<A extends Any$2, E extends Errors, D> = A extends Any$2 ? A["success"] extends StreamOf<infer Element> ? Rpc.Rpc<A["name"], A["input"], RpcSchema.Stream<ElementedOf<Element, A["progress"]>, ErrorOf<A, E, D>>> : A["progress"] extends Codec ? Rpc.Rpc<A["name"], A["input"], RpcSchema.Stream<ReturnType<typeof ProgressedOf<A["progress"], A["success"]>>, ErrorOf<A, E, D>>> : Rpc.Rpc<A["name"], A["input"], A["success"], ErrorOf<A, E, D>> : never;
29
29
  type EventRpcOf<V extends Any$3, E extends Errors, D> = V extends Any$3 ? Rpc.Rpc<V["name"], ReturnType<typeof SubscriptionOf<V>>, RpcSchema.Stream<ReturnType<typeof PushedOf<V>>, Schema.Union<ReadonlyArray<E[number] | VerifierError<V, D> | BuiltIns>>>> : never;
30
30
  declare const authenticatedKey = "effect-actions/ActionRpc/Authenticated";
31
- type RefusalOf<E extends Errors> = Schema.Union<ReadonlyArray<typeof Unauthenticated | E[number]>>;
31
+ type RefusalOf<E extends Errors> = Schema.Union<ReadonlyArray<typeof Unauthenticated | typeof Forbidden | E[number]>>;
32
32
  declare const authenticatedBrand: unique symbol;
33
33
  interface Authenticated<I, E extends Errors = Errors> {
34
34
  readonly [authenticatedBrand]: typeof authenticatedBrand;
@@ -101,8 +101,8 @@ export interface Options<E extends Errors = Errors> {
101
101
  /**
102
102
  * Native rpcs the binding serves beside its actions and event types, with their own schemas
103
103
  * and handlers: `RpcGroup.make(Upload)`. Under an `authentication`, each of their messages
104
- * authenticates as a protected action's does: its handler reads the identity, and a refusal
105
- * fails the call with `Unauthenticated`.
104
+ * authenticates as a protected action's does: its handler reads the identity, and the client
105
+ * receives the verifier's `Unauthenticated`, `Forbidden` (including any `scopes`), or declared error.
106
106
  *
107
107
  * **Gotchas**
108
108
  *
@@ -1,5 +1,5 @@
1
1
  import { bindingErrors, bindingOf, eventErrors } from "./contract/declared.mjs";
2
- import { Unauthenticated } from "./contract/errors.mjs";
2
+ import { Forbidden, Unauthenticated } from "./contract/errors.mjs";
3
3
  import { listed } from "./contract/listed.mjs";
4
4
  import { reservedList, reservedNames } from "./contract/names.mjs";
5
5
  import { PushedOf, SubscriptionOf } from "./contract/push.mjs";
@@ -12,7 +12,11 @@ import { Rpc, RpcClient, RpcGroup, RpcMiddleware, RpcSerialization, RpcServer }
12
12
  import { Socket } from "effect/socket";
13
13
  // src/rpc/ActionRpc.ts
14
14
  const authenticatedKey = "effect-actions/ActionRpc/Authenticated";
15
- const authenticatedOf = (authentication) => RpcMiddleware.Service()(authenticatedKey, { error: Schema.Union([Unauthenticated, ...authentication.error]) });
15
+ const authenticatedOf = (authentication) => RpcMiddleware.Service()(authenticatedKey, { error: Schema.Union([
16
+ Unauthenticated,
17
+ Forbidden,
18
+ ...authentication.error
19
+ ]) });
16
20
  const authenticatedIn = (rpc) => [...rpc.middlewares].find(({ key }) => key === authenticatedKey);
17
21
  function make(contracts, options = {}) {
18
22
  const { actions, events } = listed(contracts);
@@ -68,8 +72,7 @@ function layer(binding, served, options = {}) {
68
72
  const servedActions = jsonGroup.toLayer(byName);
69
73
  const authenticated = natives.map(authenticatedIn).find(Predicate.isNotUndefined);
70
74
  if (authenticated === void 0 || authenticating === void 0) return servedActions;
71
- const authenticate = authenticating(verifyingNative);
72
- return Layer.merge(servedActions, Layer.succeed(authenticated)(authenticate));
75
+ return Layer.merge(servedActions, Layer.succeed(authenticated)(authenticating(verifyingNative)));
73
76
  })).pipe(provideServed(selected.apps, selected.events));
74
77
  return RpcServer.layer(jsonGroup.merge(binding.rpcs), { disableFatalDefects: true }).pipe(Layer.provide(handlers));
75
78
  }
package/dist/Event.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Options as Options$1 } from "./Action.mjs";
2
- import { Authorizer, Deferred as Deferred$1 } from "./contract/authorizer.mjs";
2
+ import { Deferred as Deferred$1 } from "./contract/authorizer.mjs";
3
3
  import { Codec, CodecOf, Fields, NoInput } from "./contract/codec.mjs";
4
4
  import { Refusal } from "./contract/errors.mjs";
5
5
  import { AnyEventImplementation, EventImplementation } from "./contract/feed.mjs";
@@ -415,7 +415,7 @@ type Implemented<T extends Target, RequestServices, R, EX, RX, RA, EAX, RAX> = E
415
415
  export declare function implement<const T extends Target, RequestServices extends (T extends readonly Any[] ? { readonly [K in NamesOf<T>]: unknown; } : never), R = never, EX = never, RX = never, RA = never, EAX = never, RAX = never>(events: T, sources: SourcesOf<T, R, RequestServices> | Effect.Effect<SourcesOf<T, R, RequestServices>, EX, RX>, options: [Protected<EventsOf<T>>] extends [never] ? {
416
416
  readonly authorize?: "A public-only target takes no authorize";
417
417
  } | undefined : {
418
- readonly authorize: Authorizer<Protected<EventsOf<T>>, RA, EAX, RAX>;
418
+ readonly authorize: ((contract: Protected<EventsOf<T>>) => Effect.Effect<void, Refusal, RA>) | Effect.Effect<(contract: Protected<EventsOf<T>>) => Effect.Effect<void, Refusal, RA>, EAX, RAX>;
419
419
  }): Implemented<T, RequestServices, R, EX, RX, RA, EAX, RAX>;
420
420
  export declare function implement<const T extends Target, RequestServices extends (T extends readonly Any[] ? { readonly [K in NamesOf<T>]: unknown; } : never), R = never, EX = never, RX = never>(events: T & TakesNoAuthorize<T>, sources: SourcesOf<T, R, RequestServices> | Effect.Effect<SourcesOf<T, R, RequestServices>, EX, RX>): Implemented<T, RequestServices, R, EX, RX, never, never, never>;
421
421
  export { type AnyEventImplementation as AnyImplementation, Events, Gap, type EventImplementation as Implementation, type KeyOptions, type Listed, layerMemory };
@@ -33,35 +33,14 @@ export interface SecurityMiddleware<I, Name extends string = string> {
33
33
  };
34
34
  }
35
35
  type Response = Effect.Effect<HttpServerResponse.HttpServerResponse, unknown, unknown>;
36
- /** What a provider holds for the surfaces serving its descriptor, beside its identity. */
37
36
  interface Runtime$1 {
38
- /** The descriptor the provider was built from, the one a binding naming it must hold. */
39
37
  readonly descriptor: unknown;
40
- /**
41
- * The verifier itself, for a surface answering refusals its own way, such as RPC: the
42
- * credential to the identity, or a refusal, or an error the descriptor declares. An empty
43
- * credential, as the native decoder gives an absent one, is refused without reaching it.
44
- */
45
38
  readonly authenticate: (credential: Credential) => Effect.Effect<unknown, unknown, unknown>;
46
- /** The native security middleware's implementation, keyed by its scheme. */
47
39
  readonly middleware: Readonly<Record<string, (route: Response, options: {
48
40
  readonly credential: Credential;
49
41
  }) => Response>>;
50
- /**
51
- * A protected HTTP route as it leaves the layer's middleware, a step-up refusal it fails with
52
- * answered with its challenge under Bearer; as it is under another scheme.
53
- */
54
42
  readonly stepUp: HttpApiMiddleware.HttpApiMiddleware<never, never, never>;
55
- /**
56
- * An MCP endpoint's request: decoded here, and a protected tool's call promotes what it
57
- * verified. Where `optional`, a request presenting no credential, which the scheme decodes as
58
- * empty, passes signed out.
59
- */
60
43
  readonly http: <E, R>(route: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>, optional: boolean) => Effect.Effect<HttpServerResponse.HttpServerResponse, E, R | HttpRouter.Provided>;
61
- /**
62
- * A route of the host's own: the request is decoded here, the route gets the identity
63
- * itself, and a refusal it fails with is answered as an action route's.
64
- */
65
44
  readonly route: <E, R>(route: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>) => Effect.Effect<HttpServerResponse.HttpServerResponse, Exclude<E, Refusal>, HttpRouter.Provided>;
66
45
  }
67
46
  /**
@@ -81,7 +60,6 @@ export interface Descriptor<I, A, S extends Security, Name extends string = stri
81
60
  readonly schema?: Codec | undefined;
82
61
  readonly "~provider": Context.Key<Provider<I, Name>, Runtime$1>;
83
62
  readonly "~middleware": Context.Key<SecurityMiddleware<I, Name>, unknown>;
84
- /** An MCP request's verified identity, which a protected tool's call promotes. */
85
63
  readonly "~verified": Context.Key<never, unknown>;
86
64
  }
87
65
  /**
@@ -37,10 +37,6 @@ const answer = (error, metadataUrl) => {
37
37
  var SteppedUpRefusal = class extends Context.Service()("effect-actions/SteppedUp") {};
38
38
  const isStepUp = (error) => isRefusal(error) && (!Predicate.isTagged(error, "Forbidden") || error.scopes !== void 0);
39
39
  const recordStepUp = (call) => Effect.tapError(call, (error) => isStepUp(error) ? Effect.flatMap(Effect.serviceOption(SteppedUpRefusal), (slot) => Option.isSome(slot) ? Ref.set(slot.value, Option.some(error)) : Effect.void) : Effect.void);
40
- /**
41
- * `run` as the caller of `called`: unchanged where it is public or nothing authenticates, and
42
- * otherwise with the identity its request verified, a step-up it fails with recorded.
43
- */
44
40
  const asCaller = (authentication, called, run) => authentication === void 0 || called.caller === Anyone ? run : recordStepUp(promote(authentication, run));
45
41
  const answerStepUp = (route, metadataUrl) => Effect.gen(function* () {
46
42
  const slot = yield* Ref.make(Option.none());
@@ -1,8 +1,4 @@
1
1
  import "./implementation.mjs";
2
- import { Refusal } from "./errors.mjs";
3
2
  import { Effect } from "effect";
4
- /** `T`, read only once it is inferred: an implementation's build channels. */
5
3
  type Deferred$1<T> = [T][T extends unknown ? 0 : never];
6
- /** What `implement` takes as `authorize` for contracts `C`: the rule, or an Effect building it. */
7
- export type Authorizer<C, RA, EAX, RAX> = ((contract: C) => Effect.Effect<void, Refusal, RA>) | Effect.Effect<(contract: C) => Effect.Effect<void, Refusal, RA>, EAX, RAX>;
8
4
  export { Deferred$1 as Deferred };
@@ -24,10 +24,6 @@ const jsonRoundTrip = (schema) => {
24
24
  value: received
25
25
  })));
26
26
  };
27
- /**
28
- * A call's or a watch's input as it is sent, `{}` decoded where it is left out: its JSON, and the
29
- * value the server decodes from it.
30
- */
31
27
  const sentInput = (event, input) => inputOf(event, input === void 0 ? [] : [input]).pipe(Effect.flatMap(jsonRoundTrip(event.input)), Effect.mapError(InvalidInput.fromSchemaError));
32
28
  const sendingJson = (action) => Schema.encodeUnknownEffect(Schema.toCodecJson(action.input), { errors: "all" });
33
29
  const sendingValue = (action) => {
@@ -7,7 +7,6 @@ import { Context, Effect, Function } from "effect";
7
7
  */
8
8
  const Anyone = Symbol.for("@gjermundgaraba/effect-actions/Anyone");
9
9
  const CallerKeyed = Context.Reference("effect-actions/CallerKeyed", { defaultValue: Function.constUndefined });
10
- /** The caller's principal: none for a public one, or on a surface with no authentication. */
11
10
  const principalOf = (called, keyed) => keyed === void 0 || called.caller === Anyone ? Effect.undefined : Effect.map(Effect.service(called.caller), keyed.principal);
12
11
  const assertAuthentication = (contracts, authentication, noun = "action") => {
13
12
  for (const contract of contracts) if (contract.caller !== Anyone && (authentication === void 0 || contract.caller.key !== authentication.identity.key)) throw new Error(`Protected ${noun} '${contract.name}' requires its matching authentication descriptor (give it the authentication whose identity the ${noun}'s caller names)`);
@@ -16,7 +16,6 @@ type Single<T> = true extends Types.IsUnion<T> ? never : T;
16
16
  * `E` may be one of several.
17
17
  */
18
18
  export type Certain<E extends Errors> = true extends Types.IsUnion<E> ? never : number extends E["length"] ? never : { readonly [K in keyof E]: Single<E[K]>; }[number];
19
- /** The errors a binding declares for every call, and its protected actions' authentication's. */
20
19
  export interface Declaring {
21
20
  readonly error: Errors;
22
21
  readonly authentication?: {
@@ -80,7 +80,7 @@ declare const Forbidden_base: Schema.Class<Forbidden, Schema.TaggedStruct<"Forbi
80
80
  * **Gotchas**
81
81
  *
82
82
  * - Over HTTP its JSON with a 403: from authentication before the body is read, from `authorize` or a handler after the input is decoded; on a protected route under Bearer, one naming `scopes` also carries the challenge.
83
- * - Over MCP, from authentication the HTTP 403 before the arguments are decoded; from `authorize` or a handler an `isError: true` tool result holding its JSON as text, in a **200**, not a 403; only on an endpoint under Bearer is a protected tool's refusal naming `scopes` the HTTP 403 with the challenge instead.
83
+ * - Over MCP, from authentication the HTTP 403 before the arguments are decoded; from `authorize` or a handler an `isError: true` tool result, in a **200**, not a 403, whose text is its `message` alone, so a model reads no `scopes` unless the message names them; only on an endpoint under Bearer is a protected tool's refusal naming `scopes` the HTTP 403 with the challenge instead.
84
84
  * - Over RPC the typed failure, never a status or a challenge; on a Toolkit and in a CLI as a declared error.
85
85
  * - From another service's client, such as `ActionHttp.client`, one passed on becomes this server's own refusal: map it to an error the action declares, or to a defect.
86
86
  */
@@ -68,7 +68,7 @@ const ScopeToken = Schema.String.check(Schema.isPattern(scopeToken));
68
68
  * **Gotchas**
69
69
  *
70
70
  * - Over HTTP its JSON with a 403: from authentication before the body is read, from `authorize` or a handler after the input is decoded; on a protected route under Bearer, one naming `scopes` also carries the challenge.
71
- * - Over MCP, from authentication the HTTP 403 before the arguments are decoded; from `authorize` or a handler an `isError: true` tool result holding its JSON as text, in a **200**, not a 403; only on an endpoint under Bearer is a protected tool's refusal naming `scopes` the HTTP 403 with the challenge instead.
71
+ * - Over MCP, from authentication the HTTP 403 before the arguments are decoded; from `authorize` or a handler an `isError: true` tool result, in a **200**, not a 403, whose text is its `message` alone, so a model reads no `scopes` unless the message names them; only on an endpoint under Bearer is a protected tool's refusal naming `scopes` the HTTP 403 with the challenge instead.
72
72
  * - Over RPC the typed failure, never a status or a challenge; on a Toolkit and in a CLI as a declared error.
73
73
  * - From another service's client, such as `ActionHttp.client`, one passed on becomes this server's own refusal: map it to an error the action declares, or to a defect.
74
74
  */
@@ -80,11 +80,8 @@ export declare class EventImplementation<E extends Any, R, EX, RX, RA = never, E
80
80
  /** The event types this implementation answers. */
81
81
  readonly events: readonly E[];
82
82
  constructor(events: readonly E[], running: Running<EX, RX>, authorizer: Memoized<ErasedAuthorize<Any>, EAX, RAX>);
83
- /** Select event types while retaining their sources, authorization and shared builder. */
84
83
  static share(events: readonly Any[], app: AnyEventImplementation): AnyEventImplementation;
85
- /** The builders of `app`, its sources' and its authorizer's, as one layer. */
86
84
  static layerOf(app: AnyEventImplementation): Layer.Layer<never, unknown, unknown>;
87
- /** The event types of `app` with what runs them, behind its authorizer. */
88
85
  static feedsOf(app: AnyEventImplementation): Effect.Effect<readonly Feed[], never, unknown>;
89
86
  private static held;
90
87
  private static own;
@@ -223,18 +223,15 @@ var EventImplementation = class EventImplementation {
223
223
  this.#running = running;
224
224
  this.#authorizer = authorizer;
225
225
  }
226
- /** Select event types while retaining their sources, authorization and shared builder. */
227
226
  static share(events, app) {
228
227
  const source = EventImplementation.own(app);
229
228
  return new EventImplementation(events, source.#running, source.#authorizer);
230
229
  }
231
- /** The builders of `app`, its sources' and its authorizer's, as one layer. */
232
230
  static layerOf(app) {
233
231
  const source = EventImplementation.own(app);
234
232
  const runs = Layer.mergeAll(Layer.empty, ...EventImplementation.held(app).map(([, run]) => run.layer));
235
233
  return builderLayer(app.events, { layer: runs }, source.#authorizer);
236
234
  }
237
- /** The event types of `app` with what runs them, behind its authorizer. */
238
235
  static feedsOf(app) {
239
236
  const source = EventImplementation.own(app);
240
237
  return Effect.gen(function* () {
@@ -40,16 +40,6 @@ const holding = (set, value) => Effect.acquireRelease(Effect.sync(() => {
40
40
  set.add(value);
41
41
  return value;
42
42
  }), () => Effect.sync(() => set.delete(value)));
43
- /**
44
- * An `Events` for as long as the scope lasts, over the log storage `log` makes: what
45
- * `Stored.layerEvents` provides over SQL, its subscribers' wakes in memory and its logs where
46
- * `log` keeps them.
47
- *
48
- * **Gotchas**
49
- *
50
- * - Make it once per database, around the handlers that announce and the surfaces that serve, as `layerMemory` is built.
51
- * - A log's storage is made once per event for the life of the scope, its position read on every append and read: a storage emptied behind its back starts a new epoch, and a cursor from before reads a gap.
52
- */
53
43
  const makeEvents = (options) => Effect.gen(function* () {
54
44
  const revisions = options.revisions ?? memoryRevisions();
55
45
  const scope = yield* Effect.scope;
@@ -5,30 +5,19 @@ import { Any as Any$1 } from "../Event.mjs";
5
5
  import { AnyEventImplementation, EventOf } from "./feed.mjs";
6
6
  import { Reporting } from "./progress.mjs";
7
7
  import { Context, Effect, Layer, Scope, Stream } from "effect";
8
- /** Decoded values at the dispatch boundary every surface shares. */
9
8
  export type ErasedValue = Any["input"]["Type"];
10
9
  export type WrittenHandler<R> = {
11
10
  bivarianceHack(input: ErasedValue, reporting?: Reporting): Effect.Effect<ErasedValue, ErasedValue, R> | Stream.Stream<ErasedValue, ErasedValue, R>;
12
11
  }["bivarianceHack"];
13
- /**
14
- * A handler behind its action's authentication, authorization and declared errors, as a surface
15
- * calls it. For an action answering a stream it succeeds at once with the call's stream, which
16
- * `elementsOf` reads, the refusals included. `reporting` is where its progress goes, ignored for
17
- * an action declaring no `progress`, so a surface may hand one to every call.
18
- */
19
12
  export type ErasedHandler<R> = (input: ErasedValue, reporting?: Reporting) => Effect.Effect<ErasedValue, ErasedValue, R>;
20
13
  /**
21
14
  * Authorization for protected contracts: it refuses, and fails with nothing else. It runs only for
22
15
  * protected actions, after authentication and before the handler.
23
16
  */
24
17
  export type Authorize<A extends Any, R = never> = (action: A) => Effect.Effect<void, Refusal, R>;
25
- /** An authorization rule over contracts `C`, erased: it refuses, or lets the call run. */
26
18
  export type ErasedAuthorize<C = Any> = (contract: C) => Effect.Effect<void, unknown, unknown>;
27
- /** Each action of an implementation with its handler, as `dispatch` makes it. */
28
19
  export type Bound = ReadonlyArray<readonly [Any, ErasedHandler<unknown>]>;
29
- /** Each action of an implementation with its handler as written, as its builder made them. */
30
20
  export type Written = ReadonlyArray<readonly [Any, WrittenHandler<unknown>]>;
31
- /** A build shared by every layer an implementation reaches, through the one key it is provided under. */
32
21
  export interface Memoized<S, E, R> {
33
22
  readonly key: Context.Key<S, S>;
34
23
  readonly layer: Layer.Layer<S, E, R>;
@@ -58,17 +47,8 @@ export declare class Implementation<A extends Any, RequestServices, EX, RX, RA =
58
47
  readonly "~authorizeBuildServices": RAX;
59
48
  /** The contracts this implementation answers. */
60
49
  readonly actions: readonly A[];
61
- constructor(actions: readonly A[],
62
- /** Builds each action paired with its handler: its own builder, or the one it shares. */
63
- handlers: Memoized<Written, EX, RX>,
64
- /** Builds its authorizer. */
65
- authorizer: Memoized<ErasedAuthorize, EAX, RAX>);
66
- /** Select contracts while retaining their handlers, authorization and shared builder. */
50
+ constructor(actions: readonly A[], handlers: Memoized<Written, EX, RX>, authorizer: Memoized<ErasedAuthorize, EAX, RAX>);
67
51
  static share(actions: readonly Any[], app: AnyImplementation): AnyImplementation;
68
- /**
69
- * The key of what runs a call of `app`'s actions: its handlers' memoized layer's, which each
70
- * `implement` makes, so it is unique to the implementation. Every selection retains it.
71
- */
72
52
  static runKey(app: AnyImplementation): string;
73
53
  /**
74
54
  * The builders of `app`, its handlers' and its authorizer's, as a layer. Effect memoizes each
@@ -76,10 +56,6 @@ export declare class Implementation<A extends Any, RequestServices, EX, RX, RA =
76
56
  * implementation sharing its builder, shares one run.
77
57
  */
78
58
  static layerOf(app: AnyImplementation): Layer.Layer<never, unknown, unknown>;
79
- /**
80
- * The actions of `app` with their handlers, behind its authorizer, from the context
81
- * `layerOf(app)` provides.
82
- */
83
59
  static boundOf(app: AnyImplementation, keyed: Keyed | undefined): Effect.Effect<Bound, never, unknown>;
84
60
  private static own;
85
61
  }
@@ -141,9 +117,10 @@ type Listing<O> = O extends unknown ? NonNullable<O["actions" & keyof O]> : neve
141
117
  /**
142
118
  * No key of any member of `O` beyond those of `Keys`, so a misspelled option is refused
143
119
  * rather than ignored: options inferred whole, as a type parameter, skip TypeScript's own
144
- * check, and `keyof` a union holds only the keys every member has.
120
+ * check, and `keyof` a union holds only the keys every member has. An index signature of `O`,
121
+ * a record built at runtime, names no key, so it is left to the runtime check.
145
122
  */
146
- export type Known<O, Keys> = { readonly [K in Exclude<O extends unknown ? keyof O : never, keyof Keys>]?: never; };
123
+ export type Known<O, Keys> = { readonly [K in Exclude<O extends unknown ? keyof O : never, keyof Keys> as string extends K ? never : number extends K ? never : K]?: never; };
147
124
  /**
148
125
  * The parameters of an optional options argument of type `O`: required where `O` names what
149
126
  * only a given argument holds, such as listed actions, so explicit type arguments cannot
@@ -73,15 +73,10 @@ var Implementation = class Implementation {
73
73
  this.#handlers = handlers;
74
74
  this.#authorizer = authorizer;
75
75
  }
76
- /** Select contracts while retaining their handlers, authorization and shared builder. */
77
76
  static share(actions, app) {
78
77
  const source = Implementation.own(app);
79
78
  return new Implementation(actions, source.#handlers, source.#authorizer);
80
79
  }
81
- /**
82
- * The key of what runs a call of `app`'s actions: its handlers' memoized layer's, which each
83
- * `implement` makes, so it is unique to the implementation. Every selection retains it.
84
- */
85
80
  static runKey(app) {
86
81
  return Implementation.own(app).#handlers.key.key;
87
82
  }
@@ -94,10 +89,6 @@ var Implementation = class Implementation {
94
89
  const source = Implementation.own(app);
95
90
  return builderLayer(app.actions, source.#handlers, source.#authorizer);
96
91
  }
97
- /**
98
- * The actions of `app` with their handlers, behind its authorizer, from the context
99
- * `layerOf(app)` provides.
100
- */
101
92
  static boundOf(app, keyed) {
102
93
  const { actions } = app;
103
94
  const source = Implementation.own(app);
@@ -1,7 +1,6 @@
1
1
  import { Codec } from "./codec.mjs";
2
2
  import { ErasedValue } from "./implementation.mjs";
3
3
  import { Data, Effect, Scope, Stream } from "effect";
4
- /** Where a call's progress goes: each value reported, checked by its schema, is given to `progress`. */
5
4
  export interface Reporting {
6
5
  readonly progress: (value: ErasedValue) => Effect.Effect<void>;
7
6
  }
@@ -3,7 +3,6 @@ import { CallbackCategory, SubscriptionError, Unsupported } from "../Event.mjs";
3
3
  import { SubscriptionOf } from "./push.mjs";
4
4
  import { Schema, Struct } from "effect";
5
5
  // src/contract/subscribe.ts
6
- /** The error for `event` that is not delivered by `mode` where it is asked for. */
7
6
  const deliveryUnsupported = (event, mode) => SubscriptionError.of(event, new Unsupported({
8
7
  feature: "deliveryMode",
9
8
  value: mode
@@ -14,24 +14,16 @@ import { Context, Effect, Option } from "effect";
14
14
  * `Event.SubscriptionError`.
15
15
  */
16
16
  var Webhooks = class extends Context.Service()("effect-actions/Webhooks") {};
17
- /** Whether a surface offers `event` by webhook: a protected one, its caller an identity. */
18
17
  const offersWebhook = (event) => event.caller !== Anyone;
19
18
  const offeredByWebhook = (feed) => offersWebhook(feed.event);
20
19
  const deliversByWebhook = (feed) => feed.webhook === void 0 && offeredByWebhook(feed);
21
- /**
22
- * Who subscribes to `feed`'s webhooks, and where they are held: the holder the feed names, a
23
- * reached entity, or else the surface's own `Webhooks`; none where the event is not offered by
24
- * webhook. Its principal is read from the caller each time it runs.
25
- */
26
20
  const webhookSubscriber = (feed, keyed, webhooks) => keyed !== void 0 && offeredByWebhook(feed) ? Option.map(feed.webhook === void 0 ? webhooks : Option.some(feed.webhook), (holder) => Effect.map(Effect.service(feed.event.caller), (identity) => ({
27
21
  webhooks: holder,
28
22
  feed,
29
23
  keyed,
30
24
  principal: keyed.principal(identity)
31
25
  }))) : Option.none();
32
- /** As `webhookSubscriber`, failing as `Unsupported` where the event is not offered by webhook. */
33
26
  const subscriberOf = (feed, keyed, webhooks) => Option.getOrElse(webhookSubscriber(feed, keyed, webhooks), () => Effect.fail(deliveryUnsupported(feed.event.name, "webhook")));
34
- /** A surface's answers to a webhook subscribe and unsubscribe of `feed`, run as its subscriber. */
35
27
  const webhookAnswers = (feed, keyed, webhooks) => {
36
28
  const served = subscriberOf(feed, keyed, webhooks);
37
29
  return {
@@ -46,11 +38,6 @@ const webhookAnswers = (feed, keyed, webhooks) => {
46
38
  }))
47
39
  };
48
40
  };
49
- /**
50
- * The feeds of `events` a surface's layer serves, and the `Webhooks` it offers them by: run as
51
- * the layer builds, which serves the webhooks it delivers itself, those of the feeds `holds`
52
- * admits, and restores their kept subscriptions.
53
- */
54
41
  const servingFeeds = Effect.fnUntraced(function* (events, keyed, holds = () => true) {
55
42
  const feeds = yield* acquireFeeds(events);
56
43
  const webhooks = yield* Effect.serviceOption(Webhooks);
@@ -12,11 +12,8 @@ var WakeAt = class extends Schema.Class("effect-actions/ActionEntity/WakeAt")({
12
12
  };
13
13
  const WakeRpc = Rpc.make(wakeTag, { payload: WakeAt }).annotate(ClusterSchema.Persisted, true);
14
14
  /**
15
- * The entity's wake. `wakeAt` sends the persisted tell unless one this activation stored, due no
16
- * later, has not fired; `until` stores its own deadline, unless one at that time is pending, then
17
- * waits for a wake due no earlier, so no earlier wake hands it over; `woke` takes a delivery,
18
- * which may be stale or replayed. A send and its record hold the lock, uninterruptibly, and so
19
- * does a delivery's bookkeeping, so a delivery racing its own send cannot leave a fired time pending.
15
+ * An entity's wake scheduler. Sending and recording a wake hold the same lock as delivery
16
+ * bookkeeping, so a delivery racing its own send cannot leave a fired time pending.
20
17
  */
21
18
  const makeWake = (send) => Effect.gen(function* () {
22
19
  const clock = yield* Clock.Clock;
@@ -21,8 +21,14 @@ const actionMethodOf = (action, native) => {
21
21
  const method = methodOf(native, action.name, "action");
22
22
  return Answering.$match(answeringOf(action), {
23
23
  Value: () => checked(action, sendingValue, (payload) => method({ payload })),
24
- Progressed: () => checked(action, sendingValue, (payload, onProgress) => Effect.flatMap(method({ payload }), (answer) => readWithProgress(answer, onProgress))),
25
- Elements: () => checkedStream(action, sendingValue, (payload, onProgress) => Stream.unwrap(Effect.map(method({ payload }), (answer) => readElements(answer, onProgress))))
24
+ Progressed: () => checked(action, sendingValue, (payload, onProgress) => Effect.flatMap(method({
25
+ payload,
26
+ responseMode: "decoded-and-response"
27
+ }), (answer) => readWithProgress(answer, onProgress))),
28
+ Elements: () => checkedStream(action, sendingValue, (payload, onProgress) => Stream.unwrap(Effect.map(method({
29
+ payload,
30
+ responseMode: "decoded-and-response"
31
+ }), (answer) => readElements(answer, onProgress))))
26
32
  });
27
33
  };
28
34
  const sendersWith = (http, httpClient, baseUrl) => Effect.gen(function* () {
@@ -1,15 +1,16 @@
1
1
  import { Any } from "../Action.mjs";
2
2
  import { Codec } from "../contract/codec.mjs";
3
- import { ErasedValue } from "../contract/implementation.mjs";
3
+ import "../contract/implementation.mjs";
4
4
  import "../contract/progress.mjs";
5
5
  import { StreamOf } from "../contract/stream.mjs";
6
6
  import { Effect, Schema, Stream } from "effect";
7
7
  import { HttpServerRequest } from "effect/http";
8
8
  import { HttpApiSchema } from "effect/http-api";
9
- interface Sent {
10
- readonly event: "progress" | "element" | "final";
11
- readonly data: ErasedValue;
12
- }
9
+ declare const Sent: Schema.Struct<{
10
+ readonly event: Schema.Literals<readonly ["progress", "element", "final"]>;
11
+ readonly data: Schema.Unknown;
12
+ }>;
13
+ type Sent = typeof Sent.Type;
13
14
  declare const eventOf: <const N extends Sent["event"], D extends Codec>(event: N, data: D) => Schema.Struct<{
14
15
  readonly id: Schema.optional<Schema.String>;
15
16
  readonly event: Schema.Literal<N>;
@@ -5,6 +5,15 @@ import { Cause, Duration, Effect, ErrorReporter, Queue, Schema, Stream } from "e
5
5
  import { HttpServerRequest } from "effect/http";
6
6
  import { HttpApiSchema } from "effect/http-api";
7
7
  // src/http/streamed.ts
8
+ const Sent = Schema.Struct({
9
+ event: Schema.Literals([
10
+ "progress",
11
+ "element",
12
+ "final"
13
+ ]),
14
+ data: Schema.Unknown
15
+ });
16
+ const isSent = Schema.is(Sent);
8
17
  const eventOf = (event, data) => Schema.Struct({
9
18
  id: Schema.optional(Schema.String),
10
19
  event: Schema.Literal(event),
@@ -44,8 +53,13 @@ const checkedBy = (schema) => {
44
53
  const encode = Schema.encodeUnknownEffect(Schema.toCodecJson(schema));
45
54
  return (data) => Effect.orDie(encode(data));
46
55
  };
47
- /** Whether `request` asks for an SSE stream, `text/event-stream` among whatever else it accepts. */
48
- const acceptsEventStream = (request) => (request.headers["accept"] ?? "").includes("text/event-stream");
56
+ const acceptsEventStream = (request) => ((request.headers["accept"] ?? "").match(/(?:[^",]|"(?:[^"\\]|\\.)*")+/gu) ?? []).some((range) => {
57
+ const [media, ...parameters] = range.match(/(?:[^";]|"(?:[^"\\]|\\.)*")+/gu) ?? [];
58
+ if (media?.trim().toLowerCase() !== "text/event-stream") return false;
59
+ const quality = parameters.find((parameter) => /^\s*q\s*=/iu.test(parameter));
60
+ const weight = quality === void 0 ? 1 : Number(quality.split("=")[1]);
61
+ return weight > 0 && weight <= 1;
62
+ });
49
63
  const answeringWithProgress = (success, run) => {
50
64
  const check = checkedBy(success);
51
65
  return (payload) => Effect.flatMap(HttpServerRequest.HttpServerRequest, (request) => acceptsEventStream(request) ? streamed((reporting, send) => run(payload, reporting).pipe(Effect.tap(check), Effect.flatMap((data) => send({
@@ -65,7 +79,7 @@ const progressedOf = ({ event, data }) => {
65
79
  return event === "final" ? Progressed.Final({ value: data }) : Progressed.Element({ value: data });
66
80
  };
67
81
  const answeredWithout = /* @__PURE__ */ new Error("A route of an action declaring progress or answering a stream answered without its event stream");
68
- const sentFrom = (answer) => Stream.isStream(answer) ? Stream.map(answer, progressedOf) : Stream.die(answeredWithout);
82
+ const sentFrom = ([answer, response]) => response.headers["content-type"]?.split(";")[0]?.trim().toLowerCase() === "text/event-stream" && Stream.isStream(answer) ? Stream.mapEffect(answer, (event) => isSent(event) ? Effect.succeed(progressedOf(event)) : Effect.die(answeredWithout)) : Stream.die(answeredWithout);
69
83
  const readWithProgress = (answer, onProgress) => answerFrom(sentFrom(answer), onProgress);
70
84
  const readElements = (answer, onProgress) => elementsFrom(sentFrom(answer), onProgress);
71
85
  export { acceptsEventStream, answeredWithProgress, answeringElements, answeringWithProgress, elementStreamOf, progressStreamOf, readElements, readWithProgress };
@@ -48,9 +48,10 @@ type Watching<Listed extends Any$2, D, E, R> = [Listed] extends [never] ? unknow
48
48
  * A client of an MCP endpoint served by `layerHttp`, one method per action calling
49
49
  * its tool with one stateless request, as `ActionHttp.client` calls routes: the input is
50
50
  * encoded with the action's schema, and the success decoded from its structured content, each
51
- * media field from the blocks whose `_meta` names it, and a success that is media, or whose
52
- * every field is, from its blocks alone. A declared error the tool returns, the action's own
53
- * or a refusal, is its decoded value, and so is a refusal the endpoint's authentication answers
51
+ * media field from the blocks whose `_meta` names it, a success that is media, or whose
52
+ * every field is, from its blocks alone, and a success whose schema encodes only to a string
53
+ * from its text block. A declared error the tool returns, the action's own or a refusal, is its
54
+ * decoded value, read from the result's `_meta`, and so is a refusal the endpoint's authentication answers
54
55
  * with: a test telling a 401 or 403 from a tool result asserts the status of a request `request`
55
56
  * builds. The argument may be omitted when `{}` is a valid input. Where `contracts` lists event
56
57
  * types, `watch` subscribes to one as `Action.client`'s does, holding `events/stream` open, or
@@ -8,8 +8,8 @@ import { assertOnce } from "../contract/names.mjs";
8
8
  import { elementOf } from "../contract/stream.mjs";
9
9
  import { watching } from "../contract/watch.mjs";
10
10
  import { decodedSink } from "./progress.mjs";
11
- import { defaultPath, unliftedFrom } from "./protocol.mjs";
12
- import { NoReply, NoStructuredContent, ProtocolError, StatusError, UndeclaredError, bodyOf, callError, failWith } from "./reply.mjs";
11
+ import { defaultPath, errorKey, isText, unliftedFrom } from "./protocol.mjs";
12
+ import { NoReply, ProtocolError, StatusError, UndeclaredError, UnexpectedContent, bodyOf, callError, failWith } from "./reply.mjs";
13
13
  import { request } from "./request.mjs";
14
14
  import { transportOf } from "./watch.mjs";
15
15
  import { Effect, Option, Schema, Stream } from "effect";
@@ -42,11 +42,17 @@ const callTool = (client, url, action, success, refusedWith, input, sink) => {
42
42
  if (Option.isNone(reply)) return yield* callError(method, name, new NoReply({ body: text }));
43
43
  if ("error" in reply.value) return yield* callError(method, name, new ProtocolError(reply.value.error));
44
44
  const { result } = reply.value;
45
+ const firstText = textOf(result.content.find((block) => block.type === "text"));
45
46
  if (result.isError === true) {
46
- const error = textOf(result.content.find((block) => block.type === "text")) ?? "";
47
- return yield* failWith(projectedErrors(action), error, callError(method, name, new UndeclaredError({ text: error })));
47
+ const undeclared = callError(method, name, new UndeclaredError({ text: firstText ?? "" }));
48
+ const declared = result._meta?.[errorKey];
49
+ return yield* declared === void 0 ? Effect.fail(undeclared) : failWith(projectedErrors(action), JSON.stringify(declared), undeclared);
48
50
  }
49
- if (result.structuredContent === void 0 && lift.rest !== void 0) return yield* callError(method, name, new NoStructuredContent({ body: text }));
51
+ if (lift.fields.length === 0 && isText(success)) {
52
+ if (firstText === void 0 || result.structuredContent !== void 0) return yield* callError(method, name, new UnexpectedContent({ body: text }));
53
+ return yield* Schema.decodeEffect(Schema.toCodecJson(success))(firstText);
54
+ }
55
+ if (result.structuredContent === void 0 && lift.rest !== void 0) return yield* callError(method, name, new UnexpectedContent({ body: text }));
50
56
  return yield* Schema.decodeUnknownEffect(Schema.toCodecJson(success))(unliftedFrom(lift, result));
51
57
  });
52
58
  };
@@ -2,7 +2,7 @@ import { progressSink } from "../contract/progress.mjs";
2
2
  import { Effect, Option, Schema } from "effect";
3
3
  import { McpSchema } from "effect/ai";
4
4
  // src/mcp/progress.ts
5
- const progressKey = "effect-actions/progress";
5
+ const progressKey = "io.github.gjermundgaraba.effect-actions/progress";
6
6
  const tokenOf = Schema.decodeUnknownOption(McpSchema.ProgressToken);
7
7
  const progressNotifier = (notifications, progress) => Effect.map(Effect.service(McpSchema.McpRequestContext), ({ requestMetadata }) => {
8
8
  const token = tokenOf(requestMetadata?.progressToken);
@@ -45,7 +45,10 @@ const toolJsonSchema = (schema, strict) => {
45
45
  $defs: definitions
46
46
  };
47
47
  };
48
- const fieldKey = "effect-actions/field";
48
+ const fieldKey = "io.github.gjermundgaraba.effect-actions/field";
49
+ const errorKey = "io.github.gjermundgaraba.effect-actions/error";
50
+ /** Whether a success's schema encodes only to a string, which a tool sends as its raw text alone. */
51
+ const isText = (success) => toolJsonSchema(Schema.toCodecJson(success), false)?.["type"] === "string";
49
52
  const partsAndEncodedSideOf = (ast) => [
50
53
  ...SchemaAST.isDeclaration(ast) ? ast.typeParameters : [],
51
54
  ...SchemaAST.isArrays(ast) ? [...ast.elements, ...ast.rest] : [],
@@ -71,7 +74,7 @@ const isMisplaced = (action, { rest }) => [
71
74
  ...rest === void 0 ? [] : [rest]
72
75
  ].some(({ ast }) => holdsMediaAnywhere(ast));
73
76
  const mediaOf = ({ name, kind, many }, result) => {
74
- const values = result.content.flatMap((block) => block.type === kind && block._meta?.["effect-actions/field"] === name ? [{
77
+ const values = result.content.flatMap((block) => block.type === kind && block._meta?.["io.github.gjermundgaraba.effect-actions/field"] === name ? [{
75
78
  data: Base64.encode(block.data),
76
79
  mimeType: block.mimeType
77
80
  }] : []);
@@ -88,4 +91,4 @@ const unliftedFrom = (lift, result) => {
88
91
  return field.name === void 0 || value === void 0 ? [] : [[field.name, value]];
89
92
  })]);
90
93
  };
91
- export { defaultPath, fieldKey, httpProtocol, isMisplaced, isObjectSchema, protocols, toolJsonSchema, unliftedFrom };
94
+ export { defaultPath, errorKey, fieldKey, httpProtocol, isMisplaced, isObjectSchema, isText, protocols, toolJsonSchema, unliftedFrom };
@@ -34,13 +34,17 @@ declare const UndeclaredError_base: Schema.Class<UndeclaredError, Schema.TaggedS
34
34
  }>;
35
35
  /** The tool returned an error whose text decodes as none of the action's declared errors. */
36
36
  export declare class UndeclaredError extends UndeclaredError_base {}
37
- declare const NoStructuredContent_base: Schema.Class<NoStructuredContent, Schema.TaggedStruct<"NoStructuredContent", {
37
+ declare const UnexpectedContent_base: Schema.Class<UnexpectedContent, Schema.TaggedStruct<"UnexpectedContent", {
38
38
  readonly body: Schema.String;
39
39
  }>, import("effect/Cause").YieldableError & {
40
40
  readonly brand: unique symbol;
41
41
  }>;
42
- /** The tool returned a result without the structured content its action's success needs. */
43
- export declare class NoStructuredContent extends NoStructuredContent_base {}
42
+ /**
43
+ * The tool returned a result whose content does not fit its action's success: no structured
44
+ * content where the success needs it, or, for a success whose schema encodes only to a string,
45
+ * no text block, or structured content beside it.
46
+ */
47
+ export declare class UnexpectedContent extends UnexpectedContent_base {}
44
48
  declare const FrameTooLarge_base: Schema.Class<FrameTooLarge, Schema.TaggedStruct<"FrameTooLarge", {
45
49
  readonly maxEventSize: Schema.Int;
46
50
  }>, import("effect/Cause").YieldableError & {
@@ -58,7 +62,7 @@ export declare class FrameTooLarge extends FrameTooLarge_base {}
58
62
  declare const McpCallError_base: Schema.Class<McpCallError, Schema.TaggedStruct<"McpCallError", {
59
63
  readonly method: Schema.String;
60
64
  readonly target: Schema.String;
61
- readonly reason: Schema.Union<readonly [typeof StatusError, typeof ProtocolError, typeof NoReply, typeof UndeclaredError, typeof NoStructuredContent, typeof FrameTooLarge]>;
65
+ readonly reason: Schema.Union<readonly [typeof StatusError, typeof ProtocolError, typeof NoReply, typeof UndeclaredError, typeof UnexpectedContent, typeof FrameTooLarge]>;
62
66
  readonly message: Schema.String;
63
67
  }>, import("effect/Cause").YieldableError & {
64
68
  readonly brand: unique symbol;
@@ -18,8 +18,12 @@ var ProtocolError = class extends Schema.TaggedError()("ProtocolError", {
18
18
  var NoReply = class extends Schema.TaggedError()("NoReply", { body: Schema.String }) {};
19
19
  /** The tool returned an error whose text decodes as none of the action's declared errors. */
20
20
  var UndeclaredError = class extends Schema.TaggedError()("UndeclaredError", { text: Schema.String }) {};
21
- /** The tool returned a result without the structured content its action's success needs. */
22
- var NoStructuredContent = class extends Schema.TaggedError()("NoStructuredContent", { body: Schema.String }) {};
21
+ /**
22
+ * The tool returned a result whose content does not fit its action's success: no structured
23
+ * content where the success needs it, or, for a success whose schema encodes only to a string,
24
+ * no text block, or structured content beside it.
25
+ */
26
+ var UnexpectedContent = class extends Schema.TaggedError()("UnexpectedContent", { body: Schema.String }) {};
23
27
  /**
24
28
  * The endpoint's event stream held more than `maxEventSize` characters with no frame ending, the
25
29
  * most a client holds while it waits for one.
@@ -34,7 +38,7 @@ const Reason = Schema.Union([
34
38
  ProtocolError,
35
39
  NoReply,
36
40
  UndeclaredError,
37
- NoStructuredContent,
41
+ UnexpectedContent,
38
42
  FrameTooLarge
39
43
  ]);
40
44
  const sentenceOf = Match.typeTags()({
@@ -42,7 +46,7 @@ const sentenceOf = Match.typeTags()({
42
46
  ProtocolError: ({ code, message }) => `failed with ${code}: ${message}`,
43
47
  NoReply: ({ body }) => `had no reply: ${body}`,
44
48
  UndeclaredError: ({ text }) => `returned an error: ${text}`,
45
- NoStructuredContent: ({ body }) => `returned no structured content: ${body}`,
49
+ UnexpectedContent: ({ body }) => `returned content that does not fit its success: ${body}`,
46
50
  FrameTooLarge: ({ maxEventSize }) => `sent more than ${maxEventSize} characters of an event stream with no frame ending`
47
51
  });
48
52
  /**
@@ -85,4 +89,4 @@ const bodyOf = (method, name, response, sink) => isEventStream(response) ? Strea
85
89
  onSome: (value) => sink === void 0 ? Effect.succeed(false) : Effect.as(sink.progress(value), false)
86
90
  }))) : Effect.map(response.text, (text) => [text]);
87
91
  const failWith = (errors, text, otherwise) => Schema.decodeEffect(Schema.fromJsonString(Schema.toCodecJson(Schema.Union(errors))))(text).pipe(Effect.mapError(() => otherwise), Effect.flatMap(Effect.fail));
88
- export { FrameTooLarge, McpCallError, NoReply, NoStructuredContent, ProtocolError, StatusError, UndeclaredError, bodyOf, callError, failWith, framesOf, isEventStream };
92
+ export { FrameTooLarge, McpCallError, NoReply, ProtocolError, StatusError, UndeclaredError, UnexpectedContent, bodyOf, callError, failWith, framesOf, isEventStream };
@@ -18,11 +18,6 @@ export declare class DeclaredFailure {
18
18
  constructor(json: Schema.Json);
19
19
  toString(): string;
20
20
  }
21
- /**
22
- * What serves a binding's erased rpcs: `ActionRpc.layer`, which streams each event type beside
23
- * polling it, through its `middleware`, or an entity, which only polls them, holds their webhooks
24
- * and runs `check` on each input.
25
- */
26
21
  export type Server = {
27
22
  readonly _tag: "ActionRpc.layer";
28
23
  readonly middleware: readonly RpcMiddleware.AnyService[];
@@ -36,7 +31,6 @@ export type Server = {
36
31
  * `ActionRpc.client`'s polling watch calls.
37
32
  */
38
33
  export declare const pollTag: (name: string) => string;
39
- /** The rpcs `server` serves for `actions` and `events`, and its clients call. */
40
34
  export declare const erasedOf: (actions: readonly Any[], events: readonly Any$1[], server: Server["_tag"]) => RpcGroup.RpcGroup<Rpc.Rpc<string, Schema.Codec<Schema.Json, Schema.Json, never, never>, Schema.Codec<Schema.Json, Schema.Json, never, never>, Schema.instanceOf<DeclaredFailure, DeclaredFailure>, never, never> | Rpc.Rpc<string, Schema.Codec<Schema.Json, Schema.Json, never, never>, import("effect/rpc/RpcSchema").Stream<Schema.Codec<Schema.Json, Schema.Json, never, never>, Schema.instanceOf<DeclaredFailure, DeclaredFailure>>, Schema.Never, never, never>>;
41
35
  /**
42
36
  * The payload of an event type's poll rpc, `<event>/poll`, past its `input`, as a client sends
@@ -54,9 +48,4 @@ export declare const ProgressedOf: <P extends Codec, S extends Codec>(progress:
54
48
  }>, Schema.TaggedStruct<"Final", {
55
49
  readonly value: S;
56
50
  }>]>;
57
- /**
58
- * What a server checks of each call's and subscription's decoded input, once it has verified its
59
- * caller and before the implementation's authorizer: an entity refuses an input whose key names
60
- * another entity.
61
- */
62
51
  export type InputCheck = (contract: Any | Any$1, input: ErasedValue) => Effect.Effect<void, Forbidden>;
@@ -31,7 +31,7 @@ const throughSteps = (steps, call, options) => {
31
31
  };
32
32
  const authenticatingOf = (authentication) => Effect.map(providerOf(authentication), (provider) => {
33
33
  const verify = Effect.flatMap(HttpApiBuilder.securityDecode(authentication.security), provider.authenticate);
34
- return (verifying) => (effect, options) => Effect.flatMap(verifying(verify, options), (actor) => Effect.provideService(effect, authentication.identity, actor));
34
+ return (verifying) => (effect, options) => Effect.provideServiceEffect(effect, authentication.identity, verifying(verify, options));
35
35
  });
36
36
  var DeclaredFailure = class {
37
37
  [ErrorReporter.ignore] = true;
@@ -73,7 +73,6 @@ const subscribeTag = (name) => `${name}/subscribe`;
73
73
  const unsubscribeTag = (name) => `${name}/unsubscribe`;
74
74
  const webhookRpcsOf = (events) => RpcGroup.make(...events.filter(offersWebhook).flatMap((event) => [unaryOf(subscribeTag(event.name)), unaryOf(unsubscribeTag(event.name))]));
75
75
  const webhookErrors = (event, binding) => Schema.Union([...eventErrors(event, binding), SubscriptionError]);
76
- /** The rpcs `server` serves for `actions` and `events`, and its clients call. */
77
76
  const erasedOf = (actions, events, server) => RpcGroup.make(...actions.map((action) => streams(action) ? streamOf(action.name) : unaryOf(action.name)), ...events.flatMap((event) => [...streamsEvents(server) ? [streamOf(event.name)] : [], unaryOf(pollTag(event.name))]));
78
77
  const Watch = Schema.String.check(Schema.isUUID());
79
78
  /**
@@ -191,10 +190,6 @@ const polledTransport = (transient, resendAfter) => (event, binding) => {
191
190
  };
192
191
  };
193
192
  };
194
- /**
195
- * An action's client method over `reach`: its call goes where its input, decoded as the server
196
- * will decode it, a decoding default included, says.
197
- */
198
193
  const actionMethodOf = (action, binding) => {
199
194
  const method = calledMethodOf(action, binding);
200
195
  const answer = (reach, [input, ...rest]) => Effect.flatMap(sentInput(action, input), ({ value }) => Effect.map(reach(action, value), (call) => method(call)(value, ...rest)));
package/docs/ActionMcp.md CHANGED
@@ -67,6 +67,7 @@ A tool is its contract ([Action.md](Action.md#define-a-contract)): a model knows
67
67
 
68
68
  - Constrain in the schema what a model may send: `PrinterId` in [mcp-tools/src/printers/Printers.ts](../examples/mcp-tools/src/printers/Printers.ts). Which checks reach the listed schema is on `Action.Options.input`.
69
69
  - A model acts on a declared error's `message`, so write it for the model: [mcp-tools/src/platform/print-farm.ts](../examples/mcp-tools/src/platform/print-farm.ts).
70
+ - A model reads a success whose schema is a string as it is, and an object or a `NullOr` of a string as escaped JSON, so return text it reads or copies, such as a file's lines or a command's output, as a string success: `greet` in [quickstart/src/greeting/Greeting.ts](../examples/quickstart/src/greeting/Greeting.ts). What each shape sends is on `layerHttp`.
70
71
  - `ActionMcp.Options`'s `actions` lists the tools, and only listed actions must suit MCP: [kitchen-sink/src/Actions.ts](../examples/kitchen-sink/src/Actions.ts). Leave out an action a model should not call, or one that takes a secret ([Action.md](Action.md#define-a-contract)).
71
72
 
72
73
  ## Return images and other media
package/docs/setup.md CHANGED
@@ -23,7 +23,7 @@ The `effect` peer admits the 4.1.x patches from the oldest whose APIs and behavi
23
23
 
24
24
  Keep the tilde in `package.json`: `^4.1.4`, which npm writes for `effect@4.1.4`, admits a minor release outside the peer range. `npm install effect@~4.1.4` keeps it.
25
25
 
26
- Node `>=26.13.0`: the package's `engines`, the Node the library is developed and tested on. TypeScript 7 or newer. ESM only. The repository checks the examples with a stricter `tsconfig.json`; this is the minimum a project needs. The package's modules resolve only through its `exports`, which `"module": "nodenext"` reads, as a bundler project's `"moduleResolution": "bundler"` does. `"strict": true` is required, by Effect:
26
+ Node `>=26.13.1`: the package's `engines`, the Node the library is developed and tested on. TypeScript 7 or newer. ESM only. The repository checks the examples with a stricter `tsconfig.json`; this is the minimum a project needs. The package's modules resolve only through its `exports`, which `"module": "nodenext"` reads, as a bundler project's `"moduleResolution": "bundler"` does. `"strict": true` is required, by Effect:
27
27
 
28
28
  ```json
29
29
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjermundgaraba/effect-actions",
3
- "version": "0.36.0",
3
+ "version": "0.38.0",
4
4
  "description": "Define Effect action contracts once and project them onto HTTP, MCP, Effect RPC, native Toolkits, and CLIs.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -54,19 +54,19 @@
54
54
  "access": "public"
55
55
  },
56
56
  "devDependencies": {
57
- "@clanker-stuff/oxlint-config": "0.5.0",
58
- "@effect/platform-node": "4.1.4",
59
- "@effect/sql-sqlite-node": "4.1.4",
60
- "@effect/tsgo": "0.67.7",
61
- "@effect/vitest": "4.1.4",
57
+ "@clanker-stuff/oxlint-config": "0.5.1",
58
+ "@effect/platform-node": "4.1.5",
59
+ "@effect/sql-sqlite-node": "4.1.5",
60
+ "@effect/tsgo": "0.73.2",
61
+ "@effect/vitest": "4.1.5",
62
62
  "@modelcontextprotocol/client": "2.4.0",
63
63
  "@types/node": "26.6.6",
64
- "effect": "4.1.4",
64
+ "effect": "4.1.5",
65
65
  "tsx": "4.23.15",
66
66
  "typescript": "7.0.2",
67
- "ultracite": "8.1.1",
68
- "vite": "npm:@voidzero-dev/vite-plus-core@1.5.1",
69
- "vite-plus": "1.5.1",
67
+ "ultracite": "8.3.1",
68
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8000",
69
+ "vite-plus": "1.7.0",
70
70
  "vitest": "5.1.0"
71
71
  },
72
72
  "peerDependencies": {
@@ -75,12 +75,12 @@
75
75
  "devEngines": {
76
76
  "packageManager": {
77
77
  "name": "pnpm",
78
- "version": "12.18.0",
78
+ "version": "12.21.0",
79
79
  "onFail": "download"
80
80
  }
81
81
  },
82
82
  "engines": {
83
- "node": ">=26.13.0"
83
+ "node": ">=26.13.1"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "vp pack",