@gjermundgaraba/effect-actions 0.41.0 → 0.42.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 (100) hide show
  1. package/dist/Action.d.mts +1 -1
  2. package/dist/Action.mjs +1 -1
  3. package/dist/ActionCli.d.mts +3 -3
  4. package/dist/ActionCli.mjs +2 -2
  5. package/dist/ActionEntity.d.mts +4 -4
  6. package/dist/ActionEntity.mjs +4 -4
  7. package/dist/ActionHttp.d.mts +3 -3
  8. package/dist/ActionHttp.mjs +3 -3
  9. package/dist/ActionMcp.d.mts +3 -3
  10. package/dist/ActionMcp.mjs +21 -15
  11. package/dist/ActionRpc.d.mts +4 -4
  12. package/dist/ActionRpc.mjs +3 -3
  13. package/dist/ActionToolkit.d.mts +2 -2
  14. package/dist/ActionToolkit.mjs +19 -17
  15. package/dist/Authentication.d.mts +3 -3
  16. package/dist/Authentication.mjs +3 -3
  17. package/dist/Event.d.mts +1 -1
  18. package/dist/Event.mjs +1 -1
  19. package/dist/Stored.d.mts +2 -2
  20. package/dist/Stored.mjs +3 -3
  21. package/dist/Testing.d.mts +1 -1
  22. package/dist/Testing.mjs +1 -1
  23. package/dist/Webhook.d.mts +3 -3
  24. package/dist/Webhook.mjs +5 -5
  25. package/dist/authentication/provider.d.mts +6 -6
  26. package/dist/authentication/provider.mjs +1 -1
  27. package/dist/authentication/refusal.mjs +2 -2
  28. package/dist/cli/commands.d.mts +2 -2
  29. package/dist/cli/commands.mjs +2 -2
  30. package/dist/contract/authorizer.d.mts +2 -3
  31. package/dist/contract/authorizer.mjs +1 -1
  32. package/dist/contract/call.d.mts +1 -1
  33. package/dist/contract/call.mjs +1 -1
  34. package/dist/contract/caller.d.mts +1 -1
  35. package/dist/contract/codes.mjs +1 -1
  36. package/dist/contract/declared.d.mts +1 -1
  37. package/dist/contract/declared.mjs +1 -1
  38. package/dist/contract/feed.d.mts +1 -1
  39. package/dist/contract/feed.mjs +1 -1
  40. package/dist/contract/hub.d.mts +1 -1
  41. package/dist/contract/hub.mjs +1 -1
  42. package/dist/contract/idempotency.d.mts +1 -1
  43. package/dist/contract/idempotency.mjs +1 -1
  44. package/dist/contract/implementation.d.mts +1 -1
  45. package/dist/contract/implementation.mjs +22 -3
  46. package/dist/contract/lift.mjs +17 -14
  47. package/dist/contract/log.d.mts +1 -1
  48. package/dist/contract/log.mjs +1 -1
  49. package/dist/contract/media.d.mts +1 -1
  50. package/dist/contract/occurrence.d.mts +1 -1
  51. package/dist/contract/pages.d.mts +1 -1
  52. package/dist/contract/pages.mjs +1 -1
  53. package/dist/contract/progress.d.mts +1 -1
  54. package/dist/contract/push.d.mts +1 -1
  55. package/dist/contract/push.mjs +1 -1
  56. package/dist/contract/receiving.d.mts +1 -1
  57. package/dist/contract/receiving.mjs +1 -1
  58. package/dist/contract/stream.d.mts +5 -5
  59. package/dist/contract/stream.mjs +4 -4
  60. package/dist/contract/subscribe.d.mts +1 -1
  61. package/dist/contract/subscribe.mjs +1 -1
  62. package/dist/contract/transient.mjs +2 -2
  63. package/dist/contract/wake.d.mts +1 -1
  64. package/dist/contract/watch.d.mts +1 -1
  65. package/dist/contract/watch.mjs +1 -1
  66. package/dist/contract/webhooks.d.mts +1 -1
  67. package/dist/contract/webhooks.mjs +1 -1
  68. package/dist/entity/forwarded.d.mts +1 -1
  69. package/dist/entity/wakes.mjs +3 -3
  70. package/dist/http/client.d.mts +3 -3
  71. package/dist/http/client.mjs +3 -3
  72. package/dist/http/events.d.mts +2 -2
  73. package/dist/http/events.mjs +3 -3
  74. package/dist/http/schema-errors.mjs +1 -1
  75. package/dist/http/streamed.d.mts +3 -3
  76. package/dist/http/streamed.mjs +3 -3
  77. package/dist/http/unavailable.mjs +1 -1
  78. package/dist/http/watch.mjs +2 -2
  79. package/dist/mcp/bridge.mjs +3 -3
  80. package/dist/mcp/client.d.mts +2 -2
  81. package/dist/mcp/client.mjs +6 -6
  82. package/dist/mcp/events.mjs +2 -2
  83. package/dist/mcp/progress.mjs +1 -1
  84. package/dist/mcp/protocol.mjs +21 -12
  85. package/dist/mcp/reply.d.mts +2 -2
  86. package/dist/mcp/reply.mjs +1 -1
  87. package/dist/mcp/request.mjs +1 -1
  88. package/dist/mcp/watch.mjs +1 -1
  89. package/dist/rpc/erased.d.mts +2 -2
  90. package/dist/rpc/erased.mjs +4 -4
  91. package/dist/rpc/watch.mjs +3 -3
  92. package/dist/testing/memory.d.mts +1 -1
  93. package/dist/webhook/attempt.mjs +1 -1
  94. package/dist/webhook/receiver.mjs +3 -3
  95. package/dist/webhook/signing.mjs +2 -2
  96. package/dist/webhook/stored.mjs +2 -2
  97. package/dist/webhook/subscriptions.mjs +2 -2
  98. package/docs/Action.md +1 -1
  99. package/docs/setup.md +1 -1
  100. package/package.json +7 -7
@@ -1,11 +1,11 @@
1
+ import { Schema } from "effect";
2
+ import "effect/http";
3
+ import { HttpApiSchema } from "effect/http-api";
1
4
  import { Any } from "../Action.mjs";
2
5
  import { Codec } from "../contract/codec.mjs";
3
6
  import "../contract/implementation.mjs";
4
7
  import "../contract/progress.mjs";
5
8
  import { StreamOf } from "../contract/stream.mjs";
6
- import { Effect, Schema, Stream } from "effect";
7
- import { HttpServerRequest } from "effect/http";
8
- import { HttpApiSchema } from "effect/http-api";
9
9
  declare const Sent: Schema.Struct<{
10
10
  readonly event: Schema.Literals<readonly ["progress", "element", "final"]>;
11
11
  readonly data: Schema.Unknown;
@@ -1,9 +1,9 @@
1
- import { elementsOf } from "../contract/implementation.mjs";
2
- import { Progressed, answerFrom, elementsFrom } from "../contract/progress.mjs";
3
- import { concealed } from "../contract/reported.mjs";
4
1
  import { Cause, Duration, Effect, ErrorReporter, Queue, Schema, Stream } from "effect";
5
2
  import { HttpServerRequest } from "effect/http";
6
3
  import { HttpApiSchema } from "effect/http-api";
4
+ import { elementsOf } from "../contract/implementation.mjs";
5
+ import { Progressed, answerFrom, elementsFrom } from "../contract/progress.mjs";
6
+ import { concealed } from "../contract/reported.mjs";
7
7
  // src/http/streamed.ts
8
8
  const Sent = Schema.Struct({
9
9
  event: Schema.Literals([
@@ -1,7 +1,7 @@
1
- import { Unavailable, isUnavailable } from "../contract/errors.mjs";
2
1
  import { Cause, Effect, ErrorReporter, Layer, Schema } from "effect";
3
2
  import { HttpServerResponse } from "effect/http";
4
3
  import { HttpApiMiddleware } from "effect/http-api";
4
+ import { Unavailable, isUnavailable } from "../contract/errors.mjs";
5
5
  // src/http/unavailable.ts
6
6
  const encode = Schema.encodeUnknownSync(Schema.toCodecJson(Unavailable));
7
7
  var RetryAfter = class extends HttpApiMiddleware.Service()("effect-actions/http/RetryAfter") {};
@@ -1,9 +1,9 @@
1
+ import { Effect, Predicate, Stream } from "effect";
2
+ import { HttpClientError } from "effect/http";
1
3
  import { NotServed, SubscriptionError } from "../Event.mjs";
2
4
  import { fedOf } from "../contract/pages.mjs";
3
5
  import { Receiving, webhookFed } from "../contract/receiving.mjs";
4
6
  import { answeredStatus, failingWhenUnanswered, isTransient, receivedFrom } from "../contract/transient.mjs";
5
- import { Effect, Predicate, Stream } from "effect";
6
- import { HttpClientError } from "effect/http";
7
7
  // src/http/watch.ts
8
8
  const isNotFound = Predicate.compose(HttpClientError.isHttpClientError, (error) => answeredStatus(error) === 404);
9
9
  const transportOf = (event, poll, stream, webhook, input) => {
@@ -1,3 +1,6 @@
1
+ import { Cause, Context, Duration, Effect, Exit, Match, Option, Predicate, Result, Schema } from "effect";
2
+ import { McpSchema, McpServer } from "effect/ai";
3
+ import { HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/http";
1
4
  import { asCaller } from "../authentication/refusal.mjs";
2
5
  import { inputParseOptions } from "../contract/call.mjs";
3
6
  import { principalOf } from "../contract/caller.mjs";
@@ -11,9 +14,6 @@ import { deliveryUnsupported } from "../contract/subscribe.mjs";
11
14
  import { Webhooks, subscriberOf, webhookSubscriber } from "../contract/webhooks.mjs";
12
15
  import { Active, EventsError, Failed, Heartbeat, Notifications, Occurred, Requests, Terminated, codes, extension, subscriptionIdKey } from "./events.mjs";
13
16
  import { isObjectSchema, toolJsonSchema } from "./protocol.mjs";
14
- import { Cause, Context, Duration, Effect, Exit, Match, Option, Predicate, Result, Schema } from "effect";
15
- import { HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/http";
16
- import { McpSchema, McpServer } from "effect/ai";
17
17
  // src/mcp/bridge.ts
18
18
  const isGroup = (u) => Predicate.isObjectKeyword(u) && "merge" in u && Predicate.isFunction(u.merge) && "requests" in u && u.requests instanceof Map;
19
19
  const groupOf = (adapter, key) => {
@@ -1,3 +1,5 @@
1
+ import { Effect, Schema, Stream } from "effect";
2
+ import { HttpClient, HttpClientError } from "effect/http";
1
3
  import { Any, VerifierError } from "../authentication/provider.mjs";
2
4
  import { Any as Any$1 } from "../Action.mjs";
3
5
  import { Call } from "../contract/call.mjs";
@@ -6,8 +8,6 @@ import { Any as Any$2, Received, SubscriptionError, WatchOptions } from "../Even
6
8
  import { Answer } from "../contract/stream.mjs";
7
9
  import { WatchArgs, WatchRequirement } from "../contract/watch.mjs";
8
10
  import { McpCallError } from "./reply.mjs";
9
- import { Effect, Schema, Stream } from "effect";
10
- import { HttpClient, HttpClientError } from "effect/http";
11
11
  /**
12
12
  * Where `client` sends, through what client, and what the endpoint's authentication declares: the
13
13
  * client `transformClient` returns may fail with `E` and require `R`.
@@ -1,3 +1,6 @@
1
+ import { Effect, Option, Schema, Stream } from "effect";
2
+ import { McpSchema } from "effect/ai";
3
+ import { HttpClient } from "effect/http";
1
4
  import { checked, checkedStream, sendingJson, sentInput } from "../contract/call.mjs";
2
5
  import { Anyone } from "../contract/caller.mjs";
3
6
  import { projectedErrors } from "../contract/declared.mjs";
@@ -12,9 +15,6 @@ import { defaultPath, errorKey, isText, unliftedFrom } from "./protocol.mjs";
12
15
  import { NoReply, ProtocolError, StatusError, UndeclaredError, UnexpectedContent, bodyOf, callError, failWith } from "./reply.mjs";
13
16
  import { request } from "./request.mjs";
14
17
  import { transportOf } from "./watch.mjs";
15
- import { Effect, Option, Schema, Stream } from "effect";
16
- import { HttpClient } from "effect/http";
17
- import { McpSchema } from "effect/ai";
18
18
  // src/mcp/client.ts
19
19
  const textOf = (block) => block?.type === "text" ? block.text : void 0;
20
20
  const ToolCallReply = Schema.Union([Schema.Struct({ result: McpSchema.CallToolResult }), Schema.Struct({ error: Schema.Struct({
@@ -48,12 +48,12 @@ const callTool = (client, url, action, success, refusedWith, input, sink) => {
48
48
  const declared = result._meta?.[errorKey];
49
49
  return yield* declared === void 0 ? Effect.fail(undeclared) : failWith(projectedErrors(action), JSON.stringify(declared), undeclared);
50
50
  }
51
- if (lift.fields.length === 0 ? isText(success) : lift.otherwise !== void 0 && result.content.every((block) => block.type === "text")) {
51
+ if (lift._tag === "Plain" ? isText(success) : lift._tag === "Either" && result.content.every((block) => block.type === "text")) {
52
52
  if (firstText === void 0 || result.structuredContent !== void 0) return yield* callError(method, name, new UnexpectedContent({ body: text }));
53
53
  return yield* Schema.decodeEffect(Schema.toCodecJson(success))(firstText);
54
54
  }
55
- if (result.structuredContent === void 0 && lift.rest !== void 0) return yield* callError(method, name, new UnexpectedContent({ body: text }));
56
- return yield* Schema.decodeUnknownEffect(Schema.toCodecJson(success))(unliftedFrom(lift, result));
55
+ if ((lift._tag === "Plain" || lift._tag === "Fields" && lift.rest !== void 0) && result.structuredContent === void 0) return yield* callError(method, name, new UnexpectedContent({ body: text }));
56
+ return yield* Schema.decodeUnknownEffect(Schema.toCodecJson(success))(unliftedFrom(lift._tag === "Plain" ? [] : lift.fields, result));
57
57
  });
58
58
  };
59
59
  function client(contracts, { url = defaultPath, transformClient, authentication } = {}) {
@@ -1,8 +1,8 @@
1
- import { eventCodes } from "../contract/codes.mjs";
2
- import { Subscribed, WebhookCallback, WebhookTarget, webhookFields } from "../contract/subscribe.mjs";
3
1
  import { ErrorReporter, Schema, Struct } from "effect";
4
2
  import { McpSchema } from "effect/ai";
5
3
  import { Rpc, RpcGroup } from "effect/rpc";
4
+ import { eventCodes } from "../contract/codes.mjs";
5
+ import { Subscribed, WebhookCallback, WebhookTarget, webhookFields } from "../contract/subscribe.mjs";
6
6
  // src/mcp/events.ts
7
7
  const extension = "io.modelcontextprotocol/events";
8
8
  const subscriptionIdKey = "io.modelcontextprotocol/subscriptionId";
@@ -1,6 +1,6 @@
1
- import { progressSink } from "../contract/progress.mjs";
2
1
  import { Effect, Option, Schema } from "effect";
3
2
  import { McpSchema } from "effect/ai";
3
+ import { progressSink } from "../contract/progress.mjs";
4
4
  // src/mcp/progress.ts
5
5
  const progressKey = "io.github.gjermundgaraba.effect-actions/progress";
6
6
  const tokenOf = Schema.decodeUnknownOption(McpSchema.ProgressToken);
@@ -1,7 +1,7 @@
1
- import { isMarked } from "../contract/media.mjs";
2
1
  import { JsonPointer, Predicate, Schema, SchemaAST } from "effect";
3
- import { Base64 } from "effect/encoding";
4
2
  import { McpProtocol, McpSchema } from "effect/ai";
3
+ import { Base64 } from "effect/encoding";
4
+ import { isMarked } from "../contract/media.mjs";
5
5
  // src/mcp/protocol.ts
6
6
  const httpProtocol = McpProtocol.v2026_07_28;
7
7
  const protocols = [
@@ -68,12 +68,21 @@ const holdsMediaAnywhere = (ast) => {
68
68
  }
69
69
  return false;
70
70
  };
71
- const isMisplaced = (action, { rest, otherwise }) => [
72
- action.input,
73
- ...action.error,
74
- ...rest === void 0 ? [] : [rest],
75
- ...otherwise === void 0 ? [] : [otherwise]
76
- ].some(({ ast }) => holdsMediaAnywhere(ast)) || otherwise !== void 0 && !isText(otherwise);
71
+ const servedBeside = (lift) => {
72
+ switch (lift._tag) {
73
+ case "Plain": return lift.success;
74
+ case "Fields": return lift.rest;
75
+ case "Either": return lift.otherwise;
76
+ }
77
+ };
78
+ const isMisplaced = (action, lift) => {
79
+ const served = servedBeside(lift);
80
+ return [
81
+ action.input,
82
+ ...action.error,
83
+ ...served === void 0 ? [] : [served]
84
+ ].some(({ ast }) => holdsMediaAnywhere(ast)) || lift._tag === "Either" && !isText(lift.otherwise);
85
+ };
77
86
  const mediaOf = ({ name, kind, many }, result) => {
78
87
  const values = result.content.flatMap((block) => block.type === kind && block._meta?.["io.github.gjermundgaraba.effect-actions/field"] === name ? [{
79
88
  data: Base64.encode(block.data),
@@ -81,13 +90,13 @@ const mediaOf = ({ name, kind, many }, result) => {
81
90
  }] : []);
82
91
  return many || values.length > 1 ? values : values[0];
83
92
  };
84
- const unliftedFrom = (lift, result) => {
85
- const [whole] = lift.fields;
93
+ const unliftedFrom = (fields, result) => {
94
+ const [whole] = fields;
86
95
  if (whole !== void 0 && whole.name === void 0) return mediaOf(whole, result);
87
96
  const { structuredContent = {} } = result;
88
97
  if (!Predicate.isObject(structuredContent)) return structuredContent;
89
- const lifted = new Set(lift.fields.map(({ name }) => name));
90
- return Object.fromEntries([...Object.entries(structuredContent).filter(([key]) => !lifted.has(key)), ...lift.fields.flatMap((field) => {
98
+ const lifted = new Set(fields.map(({ name }) => name));
99
+ return Object.fromEntries([...Object.entries(structuredContent).filter(([key]) => !lifted.has(key)), ...fields.flatMap((field) => {
91
100
  const value = mediaOf(field, result);
92
101
  return field.name === void 0 || value === void 0 ? [] : [[field.name, value]];
93
102
  })]);
@@ -1,7 +1,7 @@
1
+ import { Schema } from "effect";
2
+ import "effect/http";
1
3
  import "../Action.mjs";
2
4
  import "../contract/progress.mjs";
3
- import { Effect, Schema, Stream } from "effect";
4
- import { HttpClientError } from "effect/http";
5
5
  declare const StatusError_base: Schema.Class<StatusError, Schema.TaggedStruct<"StatusError", {
6
6
  readonly status: Schema.Int;
7
7
  readonly body: Schema.String;
@@ -1,6 +1,6 @@
1
- import { progressOf } from "./progress.mjs";
2
1
  import { Effect, Match, Option, Predicate, Schema, Stream } from "effect";
3
2
  import { Sse } from "effect/encoding";
3
+ import { progressOf } from "./progress.mjs";
4
4
  // src/mcp/reply.ts
5
5
  /** The endpoint answered with an HTTP status other than 200, and a body no declared error decodes. */
6
6
  var StatusError = class extends Schema.TaggedError()("StatusError", {
@@ -1,6 +1,6 @@
1
- import { defaultPath, httpProtocol } from "./protocol.mjs";
2
1
  import { Predicate } from "effect";
3
2
  import { HttpClientRequest } from "effect/http";
3
+ import { defaultPath, httpProtocol } from "./protocol.mjs";
4
4
  // src/mcp/request.ts
5
5
  const statelessRequest = (method, params) => {
6
6
  const { protocolVersion } = httpProtocol;
@@ -1,3 +1,4 @@
1
+ import { Duration, Effect, Match, Option, Predicate, Schema, Stream } from "effect";
1
2
  import { reasonOf } from "../contract/codes.mjs";
2
3
  import { InvalidInput } from "../contract/errors.mjs";
3
4
  import { defaultNextPoll } from "../contract/feed.mjs";
@@ -10,7 +11,6 @@ import { failingWhenSilent, failingWhenUnanswered, isTransient } from "../contra
10
11
  import { Active, Failed as Failed$1, Heartbeat, Occurred, PollEvents, SubscribeEvents, Terminated, UnsubscribeEvents, WireError, codes } from "./events.mjs";
11
12
  import { McpCallError, NoReply, ProtocolError, StatusError, bodyOf, callError, failWith, framesOf, isEventStream } from "./reply.mjs";
12
13
  import { request } from "./request.mjs";
13
- import { Duration, Effect, Match, Option, Predicate, Schema, Stream } from "effect";
14
14
  // src/mcp/watch.ts
15
15
  const replyOf = (success) => Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Union([Schema.Struct({ result: success }), Schema.Struct({ error: WireError })])));
16
16
  const pollReplyOf = replyOf(PollEvents.successSchema);
@@ -1,3 +1,5 @@
1
+ import { Effect, ErrorReporter, Schema } from "effect";
2
+ import { Rpc, RpcGroup, RpcMiddleware } from "effect/rpc";
1
3
  import "../authentication/provider.mjs";
2
4
  import { Forbidden } from "../contract/errors.mjs";
3
5
  import { Any } from "../Action.mjs";
@@ -10,8 +12,6 @@ import { ErasedValue } from "../contract/implementation.mjs";
10
12
  import "../contract/progress.mjs";
11
13
  import "../contract/watch.mjs";
12
14
  import "../contract/webhooks.mjs";
13
- import { Cause, Duration, Effect, ErrorReporter, Queue, Schema, Stream } from "effect";
14
- import { Rpc, RpcGroup, RpcMiddleware } from "effect/rpc";
15
15
  export declare class DeclaredFailure {
16
16
  readonly [ErrorReporter.ignore] = true;
17
17
  readonly json: Schema.Json;
@@ -1,3 +1,7 @@
1
+ import { Cause, Effect, ErrorReporter, Option, Predicate, Queue, Result, Schema, SchemaTransformation, Stream } from "effect";
2
+ import { HttpClientRequest, HttpServerRequest } from "effect/http";
3
+ import { HttpApiBuilder } from "effect/http-api";
4
+ import { Rpc, RpcGroup } from "effect/rpc";
1
5
  import { providerOf } from "../authentication/provider.mjs";
2
6
  import { checked, checkedStream, decodeInput, sendingJson, sentInput } from "../contract/call.mjs";
3
7
  import { Anyone, principalOf } from "../contract/caller.mjs";
@@ -15,10 +19,6 @@ import { Subscribed, WebhookCancellationOf, WebhookSubscriptionOf, deliveryUnsup
15
19
  import { watching } from "../contract/watch.mjs";
16
20
  import { offersWebhook, servingFeeds, webhookAnswers } from "../contract/webhooks.mjs";
17
21
  import { isUnknownTag, polledTransportOf, streamingOf } from "./watch.mjs";
18
- import { Cause, Effect, ErrorReporter, Option, Predicate, Queue, Result, Schema, SchemaTransformation, Stream } from "effect";
19
- import { HttpClientRequest, HttpServerRequest } from "effect/http";
20
- import { Rpc, RpcGroup } from "effect/rpc";
21
- import { HttpApiBuilder } from "effect/http-api";
22
22
  // src/rpc/erased.ts
23
23
  const streams = (action) => !Answering.$is("Value")(answeringOf(action));
24
24
  const withSyntheticRequestFromHeaders = (headers) => (effect) => effect.pipe(Effect.provideService(HttpServerRequest.HttpServerRequest, HttpServerRequest.fromClientRequest(HttpClientRequest.get("/", { headers }))), Effect.provideService(HttpServerRequest.ParsedSearchParams, {}));
@@ -1,10 +1,10 @@
1
+ import { Cause, Effect, Match, Predicate, Schema, Stream } from "effect";
2
+ import { HttpClientError } from "effect/http";
3
+ import { RpcClientError } from "effect/rpc";
1
4
  import { NotServed, SubscriptionError } from "../Event.mjs";
2
5
  import { readOn } from "../contract/push.mjs";
3
6
  import { deliveryUnsupported } from "../contract/subscribe.mjs";
4
7
  import { isTransientReason, receivedFrom } from "../contract/transient.mjs";
5
- import { Cause, Effect, Match, Predicate, Schema, Stream } from "effect";
6
- import { HttpClientError } from "effect/http";
7
- import { RpcClientError } from "effect/rpc";
8
8
  // src/rpc/watch.ts
9
9
  const isRpcClientError = Schema.is(RpcClientError.RpcClientError);
10
10
  const isAnsweredReason = Schema.is(Schema.Union([
@@ -1,4 +1,4 @@
1
1
  import { Layer } from "effect";
2
- import { HttpClient, HttpRouter, HttpServer } from "effect/http";
2
+ import { HttpRouter, HttpServer } from "effect/http";
3
3
  /** What in-memory routes may leave to the host: the router, the platform, nothing per request. */
4
4
  export type Served = HttpRouter.HttpRouter | HttpRouter.Request<"Requires", never> | HttpRouter.Request<"GlobalRequires", never> | HttpRouter.Request<"Error", unknown> | HttpRouter.Request<"GlobalError", unknown> | Layer.Success<typeof HttpServer.layerServices>;
@@ -1,6 +1,6 @@
1
- import { standardWebhooksSignature } from "./signing.mjs";
2
1
  import { Clock, Data, Duration, Effect, Option, Schema, Stream } from "effect";
3
2
  import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
3
+ import { standardWebhooksSignature } from "./signing.mjs";
4
4
  // src/webhook/attempt.ts
5
5
  var AttemptFailed = class extends Data.TaggedError("AttemptFailed") {};
6
6
  const timeout = Duration.seconds(5);
@@ -1,10 +1,10 @@
1
+ import { Clock, Effect, Option, Predicate, Schema } from "effect";
2
+ import { Base64Url } from "effect/encoding";
3
+ import { HttpServerRequest, HttpServerResponse } from "effect/http";
1
4
  import { signingSecretOf } from "../contract/callback.mjs";
2
5
  import { watchParameter } from "../contract/receiving.mjs";
3
6
  import { makeRecent } from "../contract/recent.mjs";
4
7
  import { constantTimeEqual, standardWebhooksSignature } from "./signing.mjs";
5
- import { Clock, Effect, Option, Predicate, Schema } from "effect";
6
- import { HttpServerRequest, HttpServerResponse } from "effect/http";
7
- import { Base64Url } from "effect/encoding";
8
8
  // src/webhook/receiver.ts
9
9
  const timestampToleranceSeconds = 300;
10
10
  const Body = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Json));
@@ -1,7 +1,7 @@
1
- import { sha256Hex } from "../contract/digest.mjs";
2
1
  import { Effect } from "effect";
3
- import { Base64, Hex } from "effect/encoding";
4
2
  import { Mac } from "effect/crypto";
3
+ import { Base64, Hex } from "effect/encoding";
4
+ import { sha256Hex } from "../contract/digest.mjs";
5
5
  // src/webhook/signing.ts
6
6
  const encoder = new TextEncoder();
7
7
  const hmac = (key, content) => Effect.promise(async () => {
@@ -1,8 +1,8 @@
1
+ import { Cause, Duration, Effect, Option, Queue, Schema, Semaphore } from "effect";
2
+ import { KeyValueStore } from "effect/persistence";
1
3
  import { CallbackUrl, WebhookSecret } from "../contract/callback.mjs";
2
4
  import { reported } from "../contract/reported.mjs";
3
5
  import { DeliveryStatus } from "../contract/subscribe.mjs";
4
- import { Cause, Duration, Effect, Option, Queue, Schema, Semaphore } from "effect";
5
- import { KeyValueStore } from "effect/persistence";
6
6
  // src/webhook/stored.ts
7
7
  const Stored = Schema.Struct({
8
8
  url: CallbackUrl,
@@ -1,3 +1,5 @@
1
+ import { Cause, Clock, Context, Deferred, Duration, Effect, Exit, Fiber, FiberMap, Match, Option, RcMap, Schedule, Schema, Scope, Semaphore, Stream } from "effect";
2
+ import { HttpRouter, HttpServerRequest } from "effect/http";
1
3
  import { canonicalInput } from "../contract/canonical.mjs";
2
4
  import { sentError } from "../contract/codes.mjs";
3
5
  import { CallbackFailed, NotSubscribed, SubscriptionError } from "../Event.mjs";
@@ -8,8 +10,6 @@ import { checkedHost } from "./address.mjs";
8
10
  import { attempt, challenged } from "./attempt.mjs";
9
11
  import { delivering, failingForMs, healthOf, healthTransition, iso, statusOf } from "./health.mjs";
10
12
  import { randomToken, subscriptionId } from "./signing.mjs";
11
- import { Cause, Clock, Context, Deferred, Duration, Effect, Exit, Fiber, FiberMap, Match, Option, RcMap, Schedule, Schema, Scope, Semaphore, Stream } from "effect";
12
- import { HttpRouter, HttpServerRequest } from "effect/http";
13
13
  // src/webhook/subscriptions.ts
14
14
  const minTtl = Duration.minutes(1);
15
15
  const rotationGrace = Duration.minutes(5);
package/docs/Action.md CHANGED
@@ -87,7 +87,7 @@ export const notes = Action.implement(
87
87
  A plain handler, no builder, is [quickstart/src/greeting/handlers.ts](../examples/quickstart/src/greeting/handlers.ts). The builder's rules, once per layer graph, a scope per call, passing the builder to `implement` itself, calling through `Action.client` and never the function you passed, are on `Action.implement`.
88
88
 
89
89
  - **One implementation may hold public and protected actions**, and actions only some surfaces serve: group by domain.
90
- - **Leave a handler's `Effect.fn` unnamed** unless you need handler-only timing. The span named after the action covers authorization, the handler and call cleanup, carrying `action.name` and `action.read_only` on it and its logs. Credential verification and input decoding run before it, so a request they reject has no action span; response encoding runs after it, so it can fail after a successful one.
90
+ - **Leave a handler's `Effect.fn` unnamed** unless you need handler-only timing. The span named after the action covers authorization, the handler and call cleanup, carrying `action.name` and `action.read_only` on it and its logs. A declared error, `Action.Unauthenticated` and `Action.Forbidden` included, is an answer, not a fault: the action span ends without failing and names the error's `_tag` in `error.type` (`_OTHER` for an error without one), so a backend can still find declared answers, while the caller still receives the error; a defect or an interruption fails it. A span the error passes through on its way out, such as a named `Effect.fn` or an `ActionRpc` server span, still fails. Credential verification and input decoding run before it, so a request they reject has no action span; response encoding runs after it, so it can fail after a successful one.
91
91
 
92
92
  ## Authorize calls
93
93
 
package/docs/setup.md CHANGED
@@ -23,7 +23,7 @@ The `effect` peer admits the 4.2.x patches from the oldest whose APIs and behavi
23
23
 
24
24
  Keep the tilde in `package.json`: `^4.2.0`, which npm writes for `effect@4.2.0`, admits a minor release outside the peer range. `npm install effect@~4.2.0` keeps it.
25
25
 
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:
26
+ Node `>=26.13.1` per the package's `engines`; the repository's `.node-version` selects the Node release used in CI. 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.41.0",
3
+ "version": "0.42.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",
@@ -57,17 +57,17 @@
57
57
  "@clanker-stuff/oxlint-config": "0.6.1",
58
58
  "@effect/platform-node": "4.2.0",
59
59
  "@effect/sql-sqlite-node": "4.2.0",
60
- "@effect/tsgo": "0.74.4",
60
+ "@effect/tsgo": "0.74.3",
61
61
  "@effect/vitest": "4.2.0",
62
62
  "@modelcontextprotocol/client": "2.4.0",
63
63
  "@types/node": "26.6.11",
64
64
  "effect": "4.2.0",
65
65
  "tsx": "4.23.15",
66
66
  "typescript": "7.0.2",
67
- "ultracite": "8.3.1",
68
- "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
69
- "vite-plus": "1.8.0",
70
- "vitest": "5.1.1"
67
+ "ultracite": "8.3.2",
68
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.4.0",
69
+ "vite-plus": "1.9.0",
70
+ "vitest": "5.1.2"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "effect": "~4.2.0"
@@ -75,7 +75,7 @@
75
75
  "devEngines": {
76
76
  "packageManager": {
77
77
  "name": "pnpm",
78
- "version": "12.23.0",
78
+ "version": "12.26.0",
79
79
  "onFail": "download"
80
80
  }
81
81
  },