@gjermundgaraba/effect-actions 0.39.0 → 0.39.1

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.
@@ -124,7 +124,7 @@ type Inferring<D, A extends Pick<Any$1, "caller">> = [D] extends [undefined] ? [
124
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.
125
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.
126
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.
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.
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 a JSON-RPC error `-32600` in a 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.
128
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.
129
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.
130
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.
@@ -24,7 +24,7 @@ export declare function layer(handler: (request: Request) => Promise<Response>):
24
24
  * - The client is the layer's own: the program's other HTTP clients get none of its requests, so a fake upstream is another `HttpClient`, provided to the service that calls out.
25
25
  * - A service the test reads too is provided around it once, with `Layer.provideMerge`: provided to the routes and again to the test, it is two instances, and the test reads one the handlers never changed.
26
26
  * - Requests run in the context it is built in: a `ConfigProvider` or the test clock provided around the test reaches middleware and handlers.
27
- * - No request is logged: only the cause of a defect, of a result that does not encode or of a failure a route leaves unhandled, as an error on the process console, even under `it.effect`'s `TestConsole`; a client reads it as an empty 500.
27
+ * - No request is logged: only the cause of a defect, of a result that does not encode or of a failure a route leaves unhandled, as an error on the process console, even under `it.effect`'s `TestConsole`; a client reads it as an empty 500. A `SchemaError` or `NoSuchElementError` a route fails with is not logged: the server answers it 400 or 404 and reports it to no `ErrorReporter`.
28
28
  * - It never requires `FileSystem`, `Path`, `HttpPlatform` or `Etag.Generator`: one provided around it is the routes', and `HttpServer.layerServices`' defaults stand in for the rest, whose `FileSystem` is a no-op, so a file the routes read is `NotFound` until `NodeFileSystem.layer` is provided around it.
29
29
  * - It answers HTTP requests and cannot upgrade a WebSocket: give an rpc layer `RpcServer.layerProtocolHttp` in the test, and its client `RpcClient.layerProtocolHttp` over this layer.
30
30
  */
package/dist/Testing.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { clientOf } from "./testing/memory.mjs";
2
- import { Cause, Console, Context, Effect, ErrorReporter, FileSystem, Layer, Option, Path } from "effect";
3
- import { Etag, HttpEffect, HttpPlatform, HttpRouter } from "effect/http";
2
+ import { Cause, Console, Context, Effect, ErrorReporter, FileSystem, Layer, Option, Path, Schema } from "effect";
3
+ import { Etag, HttpEffect, HttpPlatform, HttpRouter, HttpServerRespondable } from "effect/http";
4
4
  // src/testing/Testing.ts
5
- const reachedRouterUnhandled = (cause) => cause.reasons.some((reason) => Cause.isFailReason(reason) && !ErrorReporter.isIgnored(reason.error) || Cause.isDieReason(reason) && !ErrorReporter.isIgnored(reason.defect));
5
+ const isClientError = (error) => !HttpServerRespondable.isRespondable(error) && (Schema.isSchemaError(error) || Cause.isNoSuchElementError(error));
6
+ const reachedRouterUnhandled = (cause) => cause.reasons.some((reason) => Cause.isFailReason(reason) && !ErrorReporter.isIgnored(reason.error) && !isClientError(reason.error) || Cause.isDieReason(reason) && !ErrorReporter.isIgnored(reason.defect));
6
7
  const logUnhandledToProcessConsole = (cause) => reachedRouterUnhandled(cause) ? Effect.logError(cause).pipe(Effect.provideService(Console.Console, globalThis.console)) : Effect.void;
7
8
  function layer(routes) {
8
9
  if (!Layer.isLayer(routes)) return clientOf(routes);
@@ -12,7 +12,7 @@ What you see when something is wrong, and the fix. Search for a fragment of the
12
12
  - A hand-written HTTP request answers 400 with JSON-RPC error `-32602`, `Required request metadata is missing` or `io.modelcontextprotocol/clientCapabilities request metadata is required`: it names 2026-07-28 in `MCP-Protocol-Version` and its `params._meta` lacks `io.modelcontextprotocol/protocolVersion`, for the first message, or `io.modelcontextprotocol/clientCapabilities`, for the second. Build it with `ActionMcp.request`, or copy the `curl` of [mcp-tools](../examples/mcp-tools/README.md#connect-a-client).
13
13
  - A hand-written HTTP request answers 400 with JSON-RPC error `-32020`, `MCP-Protocol-Version header is required`, `Mcp-Method header does not match request method` or `Mcp-Name header does not match request parameters`: those headers repeat a 2026-07-28 request's revision, method and `tools/call`, `events/poll`, `events/stream`, `events/subscribe` or `events/unsubscribe` name, and one is absent or differs from its body. Build it with `ActionMcp.request`.
14
14
  - `events/list`, `events/poll` or `events/stream` answered with JSON-RPC error `-32601`, Method not found: the client opened a 2025 session with `initialize`, and events are served to 2026-07-28 requests alone. Send those, as `ActionMcp.client` does.
15
- - A hand-written HTTP request answers an empty 406: its `Accept` header does not list both `application/json` and `text/event-stream`, as `*/*` does not. Send both.
15
+ - A hand-written HTTP request answers 406 with JSON-RPC error `-32600`, `Accept header must include both application/json and text/event-stream`: its `Accept` header does not list both `application/json` and `text/event-stream`, as `*/*` does not. Send both.
16
16
  - A request written by hand to a stdio server answers JSON-RPC error `-32602`, `Invalid request metadata`: it is neither preceded by `initialize` nor carries the 2026-07-28 metadata. Open with `initialize` and `notifications/initialized`, or give the request's `_meta` its `io.modelcontextprotocol/protocolVersion` and `io.modelcontextprotocol/clientCapabilities`.
17
17
  - `Tool <name> has an output schema but did not return structured content` raised by a Python MCP client for an action that returns nothing: its success is sent as `null`, which a Python SDK release before the fix of python-sdk#3345 reads as missing. Update the SDK.
18
18
  - `UrlError` from `HttpClientRequest.toWebResult` or `toWeb` of an `ActionMcp.request`, or an `HttpClientError` whose reason is `InvalidUrlError` from a client method or a sent `ActionMcp.request`: the `url` is relative, such as the default `/mcp`, which only the `HttpClient` of `Testing.layer` resolves. Pass an absolute one.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjermundgaraba/effect-actions",
3
- "version": "0.39.0",
3
+ "version": "0.39.1",
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",
@@ -55,19 +55,19 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@clanker-stuff/oxlint-config": "0.5.1",
58
- "@effect/platform-node": "4.1.6",
59
- "@effect/sql-sqlite-node": "4.1.6",
60
- "@effect/tsgo": "0.73.2",
61
- "@effect/vitest": "4.1.6",
58
+ "@effect/platform-node": "4.1.7",
59
+ "@effect/sql-sqlite-node": "4.1.7",
60
+ "@effect/tsgo": "0.73.7",
61
+ "@effect/vitest": "4.1.7",
62
62
  "@modelcontextprotocol/client": "2.4.0",
63
63
  "@types/node": "26.6.6",
64
- "effect": "4.1.6",
64
+ "effect": "4.1.7",
65
65
  "tsx": "4.23.15",
66
66
  "typescript": "7.0.2",
67
67
  "ultracite": "8.3.1",
68
- "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8000",
69
- "vite-plus": "1.7.0",
70
- "vitest": "5.1.0"
68
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
69
+ "vite-plus": "1.8.0",
70
+ "vitest": "5.1.1"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "effect": "~4.1.4"