@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.
- package/dist/Action.d.mts +1 -1
- package/dist/Action.mjs +1 -1
- package/dist/ActionCli.d.mts +3 -3
- package/dist/ActionCli.mjs +2 -2
- package/dist/ActionEntity.d.mts +4 -4
- package/dist/ActionEntity.mjs +4 -4
- package/dist/ActionHttp.d.mts +3 -3
- package/dist/ActionHttp.mjs +3 -3
- package/dist/ActionMcp.d.mts +3 -3
- package/dist/ActionMcp.mjs +21 -15
- package/dist/ActionRpc.d.mts +4 -4
- package/dist/ActionRpc.mjs +3 -3
- package/dist/ActionToolkit.d.mts +2 -2
- package/dist/ActionToolkit.mjs +19 -17
- package/dist/Authentication.d.mts +3 -3
- package/dist/Authentication.mjs +3 -3
- package/dist/Event.d.mts +1 -1
- package/dist/Event.mjs +1 -1
- package/dist/Stored.d.mts +2 -2
- package/dist/Stored.mjs +3 -3
- package/dist/Testing.d.mts +1 -1
- package/dist/Testing.mjs +1 -1
- package/dist/Webhook.d.mts +3 -3
- package/dist/Webhook.mjs +5 -5
- package/dist/authentication/provider.d.mts +6 -6
- package/dist/authentication/provider.mjs +1 -1
- package/dist/authentication/refusal.mjs +2 -2
- package/dist/cli/commands.d.mts +2 -2
- package/dist/cli/commands.mjs +2 -2
- package/dist/contract/authorizer.d.mts +2 -3
- package/dist/contract/authorizer.mjs +1 -1
- package/dist/contract/call.d.mts +1 -1
- package/dist/contract/call.mjs +1 -1
- package/dist/contract/caller.d.mts +1 -1
- package/dist/contract/codes.mjs +1 -1
- package/dist/contract/declared.d.mts +1 -1
- package/dist/contract/declared.mjs +1 -1
- package/dist/contract/feed.d.mts +1 -1
- package/dist/contract/feed.mjs +1 -1
- package/dist/contract/hub.d.mts +1 -1
- package/dist/contract/hub.mjs +1 -1
- package/dist/contract/idempotency.d.mts +1 -1
- package/dist/contract/idempotency.mjs +1 -1
- package/dist/contract/implementation.d.mts +1 -1
- package/dist/contract/implementation.mjs +22 -3
- package/dist/contract/lift.mjs +17 -14
- package/dist/contract/log.d.mts +1 -1
- package/dist/contract/log.mjs +1 -1
- package/dist/contract/media.d.mts +1 -1
- package/dist/contract/occurrence.d.mts +1 -1
- package/dist/contract/pages.d.mts +1 -1
- package/dist/contract/pages.mjs +1 -1
- package/dist/contract/progress.d.mts +1 -1
- package/dist/contract/push.d.mts +1 -1
- package/dist/contract/push.mjs +1 -1
- package/dist/contract/receiving.d.mts +1 -1
- package/dist/contract/receiving.mjs +1 -1
- package/dist/contract/stream.d.mts +5 -5
- package/dist/contract/stream.mjs +4 -4
- package/dist/contract/subscribe.d.mts +1 -1
- package/dist/contract/subscribe.mjs +1 -1
- package/dist/contract/transient.mjs +2 -2
- package/dist/contract/wake.d.mts +1 -1
- package/dist/contract/watch.d.mts +1 -1
- package/dist/contract/watch.mjs +1 -1
- package/dist/contract/webhooks.d.mts +1 -1
- package/dist/contract/webhooks.mjs +1 -1
- package/dist/entity/forwarded.d.mts +1 -1
- package/dist/entity/wakes.mjs +3 -3
- package/dist/http/client.d.mts +3 -3
- package/dist/http/client.mjs +3 -3
- package/dist/http/events.d.mts +2 -2
- package/dist/http/events.mjs +3 -3
- package/dist/http/schema-errors.mjs +1 -1
- package/dist/http/streamed.d.mts +3 -3
- package/dist/http/streamed.mjs +3 -3
- package/dist/http/unavailable.mjs +1 -1
- package/dist/http/watch.mjs +2 -2
- package/dist/mcp/bridge.mjs +3 -3
- package/dist/mcp/client.d.mts +2 -2
- package/dist/mcp/client.mjs +6 -6
- package/dist/mcp/events.mjs +2 -2
- package/dist/mcp/progress.mjs +1 -1
- package/dist/mcp/protocol.mjs +21 -12
- package/dist/mcp/reply.d.mts +2 -2
- package/dist/mcp/reply.mjs +1 -1
- package/dist/mcp/request.mjs +1 -1
- package/dist/mcp/watch.mjs +1 -1
- package/dist/rpc/erased.d.mts +2 -2
- package/dist/rpc/erased.mjs +4 -4
- package/dist/rpc/watch.mjs +3 -3
- package/dist/testing/memory.d.mts +1 -1
- package/dist/webhook/attempt.mjs +1 -1
- package/dist/webhook/receiver.mjs +3 -3
- package/dist/webhook/signing.mjs +2 -2
- package/dist/webhook/stored.mjs +2 -2
- package/dist/webhook/subscriptions.mjs +2 -2
- package/docs/Action.md +1 -1
- package/docs/setup.md +1 -1
- package/package.json +7 -7
package/dist/Action.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Schema, Scope, Stream as Stream$1 } from "effect";
|
|
1
2
|
import { Deferred as Deferred$1 } from "./contract/authorizer.mjs";
|
|
2
3
|
import { Call } from "./contract/call.mjs";
|
|
3
4
|
import { Anyone } from "./contract/caller.mjs";
|
|
@@ -11,7 +12,6 @@ import { ReportingOf } from "./contract/progress.mjs";
|
|
|
11
12
|
import { Answer, Stream, StreamOf } from "./contract/stream.mjs";
|
|
12
13
|
import { WatchArgs } from "./contract/watch.mjs";
|
|
13
14
|
import { Image } from "./contract/media.mjs";
|
|
14
|
-
import { Context, Effect, Layer, Schema, Scope, Stream as Stream$1 } from "effect";
|
|
15
15
|
/**
|
|
16
16
|
* How the action's tool presents itself over MCP, in MCP's own names; every field is optional
|
|
17
17
|
* and none enforces anything. A hint left out is MCP's default, but `destructiveHint`, which is
|
package/dist/Action.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Array as Array$1, Cause, Effect, Function, Layer, Predicate, Schema, Stream as Stream$1 } from "effect";
|
|
1
2
|
import { authorizerOf } from "./contract/authorizer.mjs";
|
|
2
3
|
import { checked, checkedStream, jsonRoundTrip, sentInput } from "./contract/call.mjs";
|
|
3
4
|
import { Anyone, assertCaller } from "./contract/caller.mjs";
|
|
@@ -15,7 +16,6 @@ import { Stream, elementOf } from "./contract/stream.mjs";
|
|
|
15
16
|
import { watching } from "./contract/watch.mjs";
|
|
16
17
|
import { BuiltIn, Forbidden, InvalidInput, Refusal, Unauthenticated, Unavailable, isUnavailable } from "./contract/errors.mjs";
|
|
17
18
|
import { Image } from "./contract/media.mjs";
|
|
18
|
-
import { Array as Array$1, Cause, Effect, Function, Layer, Predicate, Schema, Stream as Stream$1 } from "effect";
|
|
19
19
|
// src/contract/Action.ts
|
|
20
20
|
function make(name, options) {
|
|
21
21
|
assertName(name);
|
package/dist/ActionCli.d.mts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { BuiltIn } from "./contract/errors.mjs";
|
|
2
|
+
import { Effect, Stream } from "effect";
|
|
3
|
+
import { CliError, Command } from "effect/cli";
|
|
4
|
+
import { HttpClient } from "effect/http";
|
|
2
5
|
import { Any } from "./Action.mjs";
|
|
3
6
|
import { Declaring } from "./contract/declared.mjs";
|
|
4
7
|
import { Any as Any$1, SubscriptionError } from "./Event.mjs";
|
|
@@ -9,9 +12,6 @@ import { WatchArgs } from "./contract/watch.mjs";
|
|
|
9
12
|
import { AnyHttp, Client, WatchError } from "./http/client.mjs";
|
|
10
13
|
import "./ActionHttp.mjs";
|
|
11
14
|
import { Options, UserError } from "./cli/commands.mjs";
|
|
12
|
-
import { Effect, Stream } from "effect";
|
|
13
|
-
import { HttpClient } from "effect/http";
|
|
14
|
-
import { CliError, Command } from "effect/cli";
|
|
15
15
|
interface AnyBinding extends Declaring {
|
|
16
16
|
readonly actions: readonly Any[];
|
|
17
17
|
}
|
package/dist/ActionCli.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Cause, Effect, Logger, Runtime, Stream } from "effect";
|
|
2
|
+
import { Command } from "effect/cli";
|
|
1
3
|
import { client } from "./Action.mjs";
|
|
2
4
|
import { bindingErrors, eventErrors, projectedErrors } from "./contract/declared.mjs";
|
|
3
5
|
import { Implementation, acquire, assertHeld, elementsOf, notHeld, toList } from "./contract/implementation.mjs";
|
|
@@ -8,8 +10,6 @@ import { selectFrom } from "./contract/serving.mjs";
|
|
|
8
10
|
import { elementOf } from "./contract/stream.mjs";
|
|
9
11
|
import { client as client$1 } from "./ActionHttp.mjs";
|
|
10
12
|
import { command as command$1, failingAsDerived, watchCommand } from "./cli/commands.mjs";
|
|
11
|
-
import { Cause, Effect, Logger, Runtime, Stream } from "effect";
|
|
12
|
-
import { Command } from "effect/cli";
|
|
13
13
|
// src/cli/ActionCli.ts
|
|
14
14
|
/**
|
|
15
15
|
* Make a command of your own fail as a derived command does. Give it what the command calls, the
|
package/dist/ActionEntity.d.mts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Anyone } from "./contract/caller.mjs";
|
|
2
|
+
import { Context, DateTime, Duration, Effect, Layer, Scope, Stream } from "effect";
|
|
3
|
+
import { ClusterError, Entity as Entity$1, Sharding } from "effect/cluster";
|
|
4
|
+
import { HttpServerRequest } from "effect/http";
|
|
5
|
+
import { Rpc, RpcClient, RpcGroup } from "effect/rpc";
|
|
2
6
|
import { Any as Any$1, Matching, RemoteRequest, Required, ServedProvider, ServerBuildServices, VerifierError } from "./authentication/provider.mjs";
|
|
3
7
|
import { Any as Any$2, Errors } from "./Action.mjs";
|
|
4
8
|
import { Call } from "./contract/call.mjs";
|
|
@@ -13,10 +17,6 @@ import { WatchArgs } from "./contract/watch.mjs";
|
|
|
13
17
|
import { Any as Any$4, Binding } from "./ActionRpc.mjs";
|
|
14
18
|
import { erasedOf } from "./rpc/erased.mjs";
|
|
15
19
|
import { forwardedHeaders } from "./entity/forwarded.mjs";
|
|
16
|
-
import { Context, DateTime, Duration, Effect, Layer, Scope, Stream } from "effect";
|
|
17
|
-
import { ClusterError, Entity as Entity$1, Sharding } from "effect/cluster";
|
|
18
|
-
import { HttpServerRequest } from "effect/http";
|
|
19
|
-
import { Rpc, RpcClient, RpcGroup } from "effect/rpc";
|
|
20
20
|
type Contract<B extends Any$4> = B["actions"][number] | B["events"][number];
|
|
21
21
|
/**
|
|
22
22
|
* The key of the binding `B`'s actions and event types, the id of the entity that serves a call
|
package/dist/ActionEntity.mjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Forbidden, Unavailable } from "./contract/errors.mjs";
|
|
2
|
+
import { Cause, Context, DateTime, Duration, Effect, Function, Layer, Option, Predicate, Schema, Stream } from "effect";
|
|
3
|
+
import { ClusterError, Entity } from "effect/cluster";
|
|
4
|
+
import { Rpc, RpcGroup, RpcMessage } from "effect/rpc";
|
|
5
|
+
import { SqlClient } from "effect/sql";
|
|
2
6
|
import { allowAll } from "./Action.mjs";
|
|
3
7
|
import { allowAll as allowAll$1 } from "./Event.mjs";
|
|
4
8
|
import { EventImplementation } from "./contract/feed.mjs";
|
|
@@ -12,10 +16,6 @@ import { make as make$1 } from "./ActionRpc.mjs";
|
|
|
12
16
|
import { actionMethodOf, erasedCallOf, erasedOf, handlersOf, methodsOf, nativeOf, pollOf, polledTransport, watchedOf, webhookCallsOf, webhookRpcsOf } from "./rpc/erased.mjs";
|
|
13
17
|
import { forwarded, forwardedHeaders } from "./entity/forwarded.mjs";
|
|
14
18
|
import { WakeRpc, makeWake, wakeTag } from "./entity/wakes.mjs";
|
|
15
|
-
import { Cause, Context, DateTime, Duration, Effect, Function, Layer, Option, Predicate, Schema, Stream } from "effect";
|
|
16
|
-
import { ClusterError, Entity } from "effect/cluster";
|
|
17
|
-
import { Rpc, RpcGroup, RpcMessage } from "effect/rpc";
|
|
18
|
-
import { SqlClient } from "effect/sql";
|
|
19
19
|
// src/entity/ActionEntity.ts
|
|
20
20
|
const namedBy = (key) => (input) => {
|
|
21
21
|
const named = key(input);
|
package/dist/ActionHttp.d.mts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Context, Effect, FileSystem, Layer, Path, Schema, Types } from "effect";
|
|
2
|
+
import { Etag, HttpClient, HttpClientError, HttpPlatform, HttpRouter } from "effect/http";
|
|
3
|
+
import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware } from "effect/http-api";
|
|
1
4
|
import { Any, DescriptorOf, LayerIdentity, Matching, PublicOnly, RemoteRequest, Required, ServedProvider, ServerBuildServices, VerifierError } from "./authentication/provider.mjs";
|
|
2
5
|
import { Any as Any$1, Errors } from "./Action.mjs";
|
|
3
6
|
import { Anyone } from "./contract/caller.mjs";
|
|
@@ -12,9 +15,6 @@ import { SubscriptionOf } from "./contract/push.mjs";
|
|
|
12
15
|
import { AnyHttp, Client, MethodError, Options, WatchError } from "./http/client.mjs";
|
|
13
16
|
import { sentOf } from "./http/events.mjs";
|
|
14
17
|
import { SuccessOf } from "./http/streamed.mjs";
|
|
15
|
-
import { Context, Effect, FileSystem, Layer, Path, Schema, Types } from "effect";
|
|
16
|
-
import { Etag, HttpClient, HttpClientError, HttpPlatform, HttpRouter } from "effect/http";
|
|
17
|
-
import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware } from "effect/http-api";
|
|
18
18
|
/** What `fetchClient` takes: `client`'s options, and the `fetch` its calls send with. */
|
|
19
19
|
export interface FetchClientOptions<E = HttpClientError.HttpClientError, R = never> extends Options<E, R> {
|
|
20
20
|
/**
|
package/dist/ActionHttp.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Scope } from "effect";
|
|
2
|
+
import { FetchHttpClient, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
|
+
import { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
1
4
|
import { providerOf } from "./authentication/provider.mjs";
|
|
2
5
|
import { inputParseOptions } from "./contract/call.mjs";
|
|
3
6
|
import { Anyone } from "./contract/caller.mjs";
|
|
@@ -14,9 +17,6 @@ import { credentialNames } from "./http/redacted.mjs";
|
|
|
14
17
|
import { SchemaErrors, schemaErrors } from "./http/schema-errors.mjs";
|
|
15
18
|
import { answeredWithProgress, answeringElements, answeringWithProgress, elementStreamOf, progressStreamOf } from "./http/streamed.mjs";
|
|
16
19
|
import { RetryAfter, retryAfter } from "./http/unavailable.mjs";
|
|
17
|
-
import { Context, Effect, Layer, Scope } from "effect";
|
|
18
|
-
import { FetchHttpClient, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
19
|
-
import { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
20
20
|
// src/http/ActionHttp.ts
|
|
21
21
|
const mountSegments = (prefix) => (prefix ?? "/api").split("/").filter((segment) => segment !== "");
|
|
22
22
|
const absolutePath = (segments) => `/${segments.join("/")}`;
|
package/dist/ActionMcp.d.mts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Cause, Effect, Layer, Scope, Stdio } from "effect";
|
|
2
|
+
import { McpSchema, McpServer } from "effect/ai";
|
|
3
|
+
import { HttpRouter } from "effect/http";
|
|
1
4
|
import { Any, Matching, ProviderOf, RemoteRequest, Required, ServerBuildServices } from "./authentication/provider.mjs";
|
|
2
5
|
import { Any as Any$1 } from "./Action.mjs";
|
|
3
6
|
import { Any as Any$2 } from "./Event.mjs";
|
|
@@ -6,9 +9,6 @@ import { ActionOf, BuildError, BuildServices, Holding, Known, Member, Protected,
|
|
|
6
9
|
import { Client, ClientOptions, client } from "./mcp/client.mjs";
|
|
7
10
|
import { McpCallError } from "./mcp/reply.mjs";
|
|
8
11
|
import { Params, RequestOptions, request } from "./mcp/request.mjs";
|
|
9
|
-
import { Cause, Effect, Layer, Scope, Stdio } from "effect";
|
|
10
|
-
import { HttpRouter } from "effect/http";
|
|
11
|
-
import { McpSchema, McpServer } from "effect/ai";
|
|
12
12
|
type NativeStdioOptions = Parameters<typeof McpServer.layerStdio>[0];
|
|
13
13
|
type NativeHttpOptions = Parameters<typeof McpServer.layerHttp>[0];
|
|
14
14
|
/**
|
package/dist/ActionMcp.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Cause, Context, Effect, ErrorReporter, Exit, Fiber, Layer, Predicate, Schema } from "effect";
|
|
2
|
+
import { AiError, McpSchema, McpServer } from "effect/ai";
|
|
3
|
+
import { HttpRouter, HttpServerRequest } from "effect/http";
|
|
1
4
|
import { providerOf } from "./authentication/provider.mjs";
|
|
2
5
|
import { asCaller } from "./authentication/refusal.mjs";
|
|
3
6
|
import { inputParseOptions } from "./contract/call.mjs";
|
|
@@ -17,9 +20,6 @@ import { defaultPath, errorKey, fieldKey, httpProtocol, isMisplaced, isObjectSch
|
|
|
17
20
|
import { client } from "./mcp/client.mjs";
|
|
18
21
|
import { McpCallError } from "./mcp/reply.mjs";
|
|
19
22
|
import { request } from "./mcp/request.mjs";
|
|
20
|
-
import { Cause, Context, Effect, ErrorReporter, Exit, Fiber, Layer, Predicate, Schema } from "effect";
|
|
21
|
-
import { HttpRouter, HttpServerRequest } from "effect/http";
|
|
22
|
-
import { AiError, McpSchema, McpServer } from "effect/ai";
|
|
23
23
|
// src/mcp/ActionMcp.ts
|
|
24
24
|
const assertToolsServable = (lifted) => {
|
|
25
25
|
const inputs = lifted.map(([action]) => action).flatMap(({ input, name }) => isObjectSchema(toolJsonSchema(Schema.toCodecJson(input), true)) ? [] : [name]);
|
|
@@ -27,6 +27,13 @@ const assertToolsServable = (lifted) => {
|
|
|
27
27
|
const misplaced = lifted.flatMap(([action, lift]) => isMisplaced(action, lift) ? [action.name] : []);
|
|
28
28
|
if (misplaced.length > 0) throw new Error(`MCP media must be the success or an array of it, a member of a union success whose other members encode to a string, or a top-level field of a struct success, one, optional or a required array: ${misplaced.join(", ")} (make the image such a field, or give an optional array as a required one, empty when absent; an image in input or an error is not served over MCP, so leave that action out of actions)`);
|
|
29
29
|
};
|
|
30
|
+
const structuredOf = (lift) => {
|
|
31
|
+
switch (lift._tag) {
|
|
32
|
+
case "Plain": return lift.success;
|
|
33
|
+
case "Fields": return lift.rest;
|
|
34
|
+
case "Either": return;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
30
37
|
const internalErrorResult = new McpSchema.CallToolResult({
|
|
31
38
|
isError: true,
|
|
32
39
|
content: [{
|
|
@@ -35,10 +42,10 @@ const internalErrorResult = new McpSchema.CallToolResult({
|
|
|
35
42
|
}],
|
|
36
43
|
_meta: { [McpSchema.TOOL_ERROR_META_KEY]: { kind: "internal" } }
|
|
37
44
|
});
|
|
38
|
-
const nativeJsonTextOf = (encoded) => encoded === void 0 ? [] : [{
|
|
45
|
+
const nativeJsonTextOf = (encoded) => encoded === void 0 ? [] : [McpSchema.TextContent.make({
|
|
39
46
|
type: "text",
|
|
40
47
|
text: JSON.stringify(encoded)
|
|
41
|
-
}];
|
|
48
|
+
})];
|
|
42
49
|
const errorTextOf = (encoded) => {
|
|
43
50
|
if (Predicate.isString(encoded)) return encoded;
|
|
44
51
|
return Predicate.hasProperty(encoded, "message") && Predicate.isString(encoded.message) && encoded.message !== "" ? encoded.message : JSON.stringify(encoded);
|
|
@@ -58,7 +65,7 @@ const declaredErrorResult = (encoded) => new McpSchema.CallToolResult({
|
|
|
58
65
|
[McpSchema.TOOL_ERROR_META_KEY]: failureInfoOf(encoded)
|
|
59
66
|
}
|
|
60
67
|
});
|
|
61
|
-
const contentBlockOf = ({ kind, field, value }) => ({
|
|
68
|
+
const contentBlockOf = ({ kind, field, value }) => McpSchema.ImageContent.make({
|
|
62
69
|
type: kind,
|
|
63
70
|
data: value.data,
|
|
64
71
|
mimeType: value.mimeType,
|
|
@@ -89,9 +96,9 @@ const registerTools = Effect.fnUntraced(function* (apps, authentication) {
|
|
|
89
96
|
const toolSuccess = toolSuccessOf(action.success);
|
|
90
97
|
const run = answeringWhole(action, handler);
|
|
91
98
|
const lift = liftOf(toolSuccess);
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
const
|
|
99
|
+
const structuredSuccess = structuredOf(lift);
|
|
100
|
+
const text = lift._tag === "Plain" && isText(toolSuccess);
|
|
101
|
+
const isOtherwise = lift._tag === "Either" ? Schema.is(lift.otherwise) : () => false;
|
|
95
102
|
const structured = structuredSuccess === void 0 || text ? void 0 : Schema.toCodecJson(structuredSuccess);
|
|
96
103
|
const outputSchema = structured === void 0 ? void 0 : yield* Schema.decodeUnknownEffect(McpSchema.ToolOutputJson)(toolJsonSchema(structured, false)).pipe(Effect.orDie);
|
|
97
104
|
const tool = yield* toolOf(action, outputSchema).pipe(Effect.orDie);
|
|
@@ -100,22 +107,21 @@ const registerTools = Effect.fnUntraced(function* (apps, authentication) {
|
|
|
100
107
|
const encodeFailure = encoder(Schema.Union(projectedErrors(action)));
|
|
101
108
|
const reported = (input) => action.progress === void 0 ? run(input) : Effect.flatMap(progressNotifier(registry.notifications, action.progress), (sink) => run(input, sink));
|
|
102
109
|
const call = (input) => asCaller(authentication, action, reported(input));
|
|
103
|
-
const liftedFieldNames = new Set(
|
|
110
|
+
const liftedFieldNames = new Set(lift._tag === "Plain" ? [] : lift.fields.map(({ name }) => name));
|
|
104
111
|
const resultOf = (encoded, success) => {
|
|
105
|
-
|
|
106
|
-
if (Predicate.isString(answer)) return new McpSchema.CallToolResult({
|
|
112
|
+
if ((text || isOtherwise(success)) && Predicate.isString(encoded)) return new McpSchema.CallToolResult({
|
|
107
113
|
isError: false,
|
|
108
114
|
content: [{
|
|
109
115
|
type: "text",
|
|
110
|
-
text:
|
|
116
|
+
text: encoded
|
|
111
117
|
}]
|
|
112
118
|
});
|
|
113
|
-
if (
|
|
119
|
+
if (lift._tag === "Plain") return new McpSchema.CallToolResult({
|
|
114
120
|
isError: false,
|
|
115
121
|
structuredContent: encoded,
|
|
116
122
|
content: nativeJsonTextOf(encoded)
|
|
117
123
|
});
|
|
118
|
-
const blocks = liftedFrom(
|
|
124
|
+
const blocks = liftedFrom(lift.fields, success).map(contentBlockOf);
|
|
119
125
|
if (structured === void 0) return new McpSchema.CallToolResult({
|
|
120
126
|
isError: false,
|
|
121
127
|
content: blocks
|
package/dist/ActionRpc.d.mts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { Context, Duration, Effect, Layer, Schedule, Schema, Scope, Stream, Types } from "effect";
|
|
2
|
+
import { HttpRouter, HttpServerRequest } from "effect/http";
|
|
3
|
+
import { Rpc, RpcClient, RpcClientError, RpcGroup, RpcMiddleware, RpcSchema, RpcSerialization, RpcServer } from "effect/rpc";
|
|
4
|
+
import { Socket } from "effect/socket";
|
|
1
5
|
import { Any as Any$1, Descriptor, DescriptorOf, LayerIdentity, Matching, ProviderOf, PublicOnly, RemoteRequest, Required, Security, ServedProvider, ServerBuildServices, VerifierError } from "./authentication/provider.mjs";
|
|
2
6
|
import { Any as Any$2, Errors } from "./Action.mjs";
|
|
3
7
|
import { Call } from "./contract/call.mjs";
|
|
@@ -14,10 +18,6 @@ import { Answer, StreamOf } from "./contract/stream.mjs";
|
|
|
14
18
|
import { WatchArgs } from "./contract/watch.mjs";
|
|
15
19
|
import { Poll, ProgressedOf, pollTag } from "./rpc/erased.mjs";
|
|
16
20
|
import { AnyPage } from "./contract/pages.mjs";
|
|
17
|
-
import { Context, Duration, Effect, Layer, Schedule, Schema, Scope, Stream, Types } from "effect";
|
|
18
|
-
import { HttpRouter, HttpServerRequest } from "effect/http";
|
|
19
|
-
import { Rpc, RpcClient, RpcClientError, RpcGroup, RpcMiddleware, RpcSchema, RpcSerialization, RpcServer } from "effect/rpc";
|
|
20
|
-
import { Socket } from "effect/socket";
|
|
21
21
|
type BindingError = Errors[number];
|
|
22
22
|
type ErrorOf<A extends Any$2, E extends Errors, D> = Schema.Union<ReadonlyArray<A["error"][number] | E[number] | VerifierError<A, D> | BuiltIns>>;
|
|
23
23
|
type ElementedOf<Element extends Schema.Constraint, P> = Schema.Union<readonly [Schema.TaggedStruct<"Element", {
|
package/dist/ActionRpc.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Duration, Effect, Function, Layer, Predicate, Schedule, Schema } from "effect";
|
|
2
|
+
import { Rpc, RpcClient, RpcGroup, RpcMiddleware, RpcSerialization, RpcServer } from "effect/rpc";
|
|
3
|
+
import { Socket } from "effect/socket";
|
|
1
4
|
import { bindingErrors, bindingOf, eventErrors } from "./contract/declared.mjs";
|
|
2
5
|
import { Forbidden, Unauthenticated } from "./contract/errors.mjs";
|
|
3
6
|
import { listed } from "./contract/listed.mjs";
|
|
@@ -7,9 +10,6 @@ import { provideServed, servingOf } from "./contract/serving.mjs";
|
|
|
7
10
|
import { Poll, erasedCallOf, erasedOf, handlersOf, methodsOf, nativeOf, pollTag, polledTransport, streamedOf, streamedTransport, verifyingNative } from "./rpc/erased.mjs";
|
|
8
11
|
import { isApplicationCode, isRpcTransient } from "./rpc/watch.mjs";
|
|
9
12
|
import { AnyPage } from "./contract/pages.mjs";
|
|
10
|
-
import { Duration, Effect, Function, Layer, Predicate, Schedule, Schema } from "effect";
|
|
11
|
-
import { Rpc, RpcClient, RpcGroup, RpcMiddleware, RpcSerialization, RpcServer } from "effect/rpc";
|
|
12
|
-
import { Socket } from "effect/socket";
|
|
13
13
|
// src/rpc/ActionRpc.ts
|
|
14
14
|
const authenticatedKey = "effect-actions/ActionRpc/Authenticated";
|
|
15
15
|
const authenticatedOf = (authentication) => RpcMiddleware.Service()(authenticatedKey, { error: Schema.Union([
|
package/dist/ActionToolkit.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { Effect, Layer, Schema } from "effect";
|
|
2
|
+
import { Prompt, Tool, Toolkit } from "effect/ai";
|
|
1
3
|
import { Any } from "./Action.mjs";
|
|
2
4
|
import { Codec } from "./contract/codec.mjs";
|
|
3
5
|
import { BuiltIns } from "./contract/errors.mjs";
|
|
4
6
|
import { ActionOf, BuildError, BuildServices, Holding, Known, Member, Offered, OptionalUnless, RequestOf, SelectedOf, ServedActions, Serving } from "./contract/implementation.mjs";
|
|
5
7
|
import { ToolSuccess } from "./contract/stream.mjs";
|
|
6
|
-
import { Effect, Layer, Schema } from "effect";
|
|
7
|
-
import { Prompt, Tool, Toolkit } from "effect/ai";
|
|
8
8
|
type NativeTool<A extends Any, R> = Tool.Tool<A["name"], {
|
|
9
9
|
readonly parameters: Schema.toCodecJson<A["input"]>;
|
|
10
10
|
readonly success: A["progress"] extends Codec ? Schema.toCodecJson<Schema.Union<readonly [ProgressOf<A["progress"]>, ToolSuccess<A["success"]>]>> : Schema.toCodecJson<ToolSuccess<A["success"]>>;
|
package/dist/ActionToolkit.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Effect, Predicate, Schema, SchemaGetter } from "effect";
|
|
2
|
+
import { Prompt, Tool, Toolkit } from "effect/ai";
|
|
1
3
|
import { projectedErrors } from "./contract/declared.mjs";
|
|
2
4
|
import { hintsOf } from "./contract/hints.mjs";
|
|
3
5
|
import { Implementation, acquire, actionKind, answeringWhole, select, toList } from "./contract/implementation.mjs";
|
|
@@ -6,8 +8,6 @@ import { assertOnce, heldOnce } from "./contract/names.mjs";
|
|
|
6
8
|
import { progressSink } from "./contract/progress.mjs";
|
|
7
9
|
import { provideServed } from "./contract/serving.mjs";
|
|
8
10
|
import { toolSuccessOf } from "./contract/stream.mjs";
|
|
9
|
-
import { Effect, Predicate, Schema, SchemaGetter } from "effect";
|
|
10
|
-
import { Prompt, Tool, Toolkit } from "effect/ai";
|
|
11
11
|
// src/toolkit/ActionToolkit.ts
|
|
12
12
|
const annotateIfGiven = (tool, key, value) => value === void 0 ? tool : tool.annotate(key, value);
|
|
13
13
|
const annotateFromContract = (tool, action) => {
|
|
@@ -30,23 +30,25 @@ const ProgressOf = (progress) => Schema.TaggedStruct("Progress", { value: progre
|
|
|
30
30
|
value: reported.value
|
|
31
31
|
}))
|
|
32
32
|
}));
|
|
33
|
+
const jsonTextPartOf = (encoded) => Prompt.textPart({ text: Predicate.isString(encoded) ? encoded : JSON.stringify(encoded) });
|
|
34
|
+
const filePartsOf = (lifted) => lifted.map(({ value }) => Prompt.filePart({
|
|
35
|
+
mediaType: value.mimeType,
|
|
36
|
+
data: value.data
|
|
37
|
+
}));
|
|
33
38
|
const modelOutputOf = (success) => {
|
|
34
39
|
const lift = liftOf(success);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
data: value.data
|
|
48
|
-
}))
|
|
49
|
-
];
|
|
40
|
+
switch (lift._tag) {
|
|
41
|
+
case "Plain": return;
|
|
42
|
+
case "Either": {
|
|
43
|
+
const isOtherwise = Schema.is(lift.otherwise);
|
|
44
|
+
const encodeOtherwise = Schema.encodeUnknownSync(Schema.toCodecJson(lift.otherwise));
|
|
45
|
+
return (result) => isOtherwise(result) ? [jsonTextPartOf(encodeOtherwise(result))] : filePartsOf(liftedFrom(lift.fields, result));
|
|
46
|
+
}
|
|
47
|
+
case "Fields": {
|
|
48
|
+
const encodeRest = lift.rest === void 0 ? void 0 : Schema.encodeUnknownSync(Schema.toCodecJson(lift.rest));
|
|
49
|
+
return (result) => [...encodeRest === void 0 ? [] : [Prompt.textPart({ text: JSON.stringify(encodeRest(result)) })], ...filePartsOf(liftedFrom(lift.fields, result))];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
50
52
|
};
|
|
51
53
|
const jsonToolOf = (action) => {
|
|
52
54
|
const success = toolSuccessOf(action.success);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { Array, Context, Effect, Layer, Option, Redacted, Schema, Scope } from "effect";
|
|
2
|
+
import { HttpRouter, HttpServerResponse } from "effect/http";
|
|
3
|
+
import { HttpApiSecurity } from "effect/http-api";
|
|
1
4
|
import { Errors } from "./Action.mjs";
|
|
2
5
|
import { Codec } from "./contract/codec.mjs";
|
|
3
6
|
import { ErrorsOf } from "./contract/declared.mjs";
|
|
4
7
|
import { Refusal } from "./contract/errors.mjs";
|
|
5
8
|
import { Known } from "./contract/implementation.mjs";
|
|
6
9
|
import { Any, Descriptor, Provider, Security } from "./authentication/provider.mjs";
|
|
7
|
-
import { Array, Context, Effect, Layer, Option, Redacted, Schema, Scope } from "effect";
|
|
8
|
-
import { HttpRouter, HttpServerResponse } from "effect/http";
|
|
9
|
-
import { HttpApiSecurity } from "effect/http-api";
|
|
10
10
|
/**
|
|
11
11
|
* The bearer token of an `Authorization` header, `authorization`, or none, read as Effect's
|
|
12
12
|
* `HttpApiSecurity.bearer` reads it for routes and MCP: the scheme matched case-insensitively,
|
package/dist/Authentication.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { Context, Effect, Function, Layer, Match, Option, Predicate, Redacted } from "effect";
|
|
2
|
+
import { HttpEffect, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
|
+
import { HttpApiBuilder, HttpApiMiddleware, HttpApiSecurity } from "effect/http-api";
|
|
1
4
|
import { assertDistinctTags, errorList } from "./contract/declared.mjs";
|
|
2
5
|
import { Unauthenticated, builtIns, scopeToken } from "./contract/errors.mjs";
|
|
3
6
|
import { providerOf } from "./authentication/provider.mjs";
|
|
4
7
|
import { answer, answerStepUp, bearer, challenge, declaredResponse, isRefusal, isStepUp, plain } from "./authentication/refusal.mjs";
|
|
5
|
-
import { Context, Effect, Function, Layer, Match, Option, Predicate, Redacted } from "effect";
|
|
6
|
-
import { HttpEffect, HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
7
|
-
import { HttpApiBuilder, HttpApiMiddleware, HttpApiSecurity } from "effect/http-api";
|
|
8
8
|
// src/authentication/Authentication.ts
|
|
9
9
|
const bearerAuthorizationHeader = /^[ \t]*Bearer +(?<token>.*[^ \t])[ \t]*$/iu;
|
|
10
10
|
/**
|
package/dist/Event.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DateTime, Duration, Effect, Schedule, Schema, Scope, Stream } from "effect";
|
|
1
2
|
import { Options as Options$1 } from "./Action.mjs";
|
|
2
3
|
import { Deferred as Deferred$1 } from "./contract/authorizer.mjs";
|
|
3
4
|
import { Codec, CodecOf, Fields, NoInput } from "./contract/codec.mjs";
|
|
@@ -7,7 +8,6 @@ import { Events, KeyOptions, layerMemory } from "./contract/hub.mjs";
|
|
|
7
8
|
import { Protected } from "./contract/implementation.mjs";
|
|
8
9
|
import { Gap, OccurrenceSchema } from "./contract/occurrence.mjs";
|
|
9
10
|
import { Listed } from "./contract/log.mjs";
|
|
10
|
-
import { DateTime, Duration, Effect, Schedule, Schema, Scope, Stream } from "effect";
|
|
11
11
|
declare const TypeId = "~@gjermundgaraba/effect-actions/Event";
|
|
12
12
|
/** What `make` needs to define an event type. */
|
|
13
13
|
export interface Options {
|
package/dist/Event.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Array as Array$1, Data, Effect, Match, Option, Predicate, Schema } from "effect";
|
|
1
2
|
import { authorizerOf } from "./contract/authorizer.mjs";
|
|
2
3
|
import { Anyone, assertCaller } from "./contract/caller.mjs";
|
|
3
4
|
import { codecOf } from "./contract/codec.mjs";
|
|
@@ -5,7 +6,6 @@ import { EventImplementation, sourcesOf } from "./contract/feed.mjs";
|
|
|
5
6
|
import { assertEventName, assertOnce } from "./contract/names.mjs";
|
|
6
7
|
import { Events, layerMemory } from "./contract/hub.mjs";
|
|
7
8
|
import { Gap } from "./contract/occurrence.mjs";
|
|
8
|
-
import { Array as Array$1, Data, Effect, Match, Option, Predicate, Schema } from "effect";
|
|
9
9
|
// src/contract/Event.ts
|
|
10
10
|
const TypeId = "~@gjermundgaraba/effect-actions/Event";
|
|
11
11
|
/** Whether `u` is an event type `make` defined: a binding's list tells events from actions by it. */
|
package/dist/Stored.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Events } from "./contract/hub.mjs";
|
|
2
|
-
import { Idempotency } from "./contract/idempotency.mjs";
|
|
3
1
|
import { Context, Layer } from "effect";
|
|
4
2
|
import { SqlClient } from "effect/sql";
|
|
3
|
+
import { Events } from "./contract/hub.mjs";
|
|
4
|
+
import { Idempotency } from "./contract/idempotency.mjs";
|
|
5
5
|
/**
|
|
6
6
|
* What `layerEvents` calls in the fiber that made each change its change signal counts, each
|
|
7
7
|
* append to a log, published or emitted, and each `notify`, once the change is written: a host
|
package/dist/Stored.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { changeSignalQuery, createLogTables, sqlRevisions, sqlStorage } from "./contract/event-tables.mjs";
|
|
2
|
-
import { Events, makeEvents } from "./contract/hub.mjs";
|
|
3
|
-
import { Idempotency, Kept, keptFor } from "./contract/idempotency.mjs";
|
|
4
1
|
import { Context, Duration, Effect, Layer, Option, Schema } from "effect";
|
|
5
2
|
import { Persistence } from "effect/persistence";
|
|
6
3
|
import { SqlClient } from "effect/sql";
|
|
4
|
+
import { changeSignalQuery, createLogTables, sqlRevisions, sqlStorage } from "./contract/event-tables.mjs";
|
|
5
|
+
import { Events, makeEvents } from "./contract/hub.mjs";
|
|
6
|
+
import { Idempotency, Kept, keptFor } from "./contract/idempotency.mjs";
|
|
7
7
|
// src/contract/Stored.ts
|
|
8
8
|
/**
|
|
9
9
|
* What `layerEvents` calls in the fiber that made each change its change signal counts, each
|
package/dist/Testing.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Served } from "./testing/memory.mjs";
|
|
2
1
|
import { Layer } from "effect";
|
|
3
2
|
import { HttpClient, HttpRouter } from "effect/http";
|
|
3
|
+
import { Served } from "./testing/memory.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* The native `HttpClient`, answered by `handler` instead of the network: a web handler the test
|
|
6
6
|
* serves and disposes of, which other tests and raw web `Request`s may share, such as
|
package/dist/Testing.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { clientOf } from "./testing/memory.mjs";
|
|
2
1
|
import { Cause, Console, Context, Effect, ErrorReporter, FileSystem, Layer, Option, Path, Schema } from "effect";
|
|
3
2
|
import { Etag, HttpEffect, HttpPlatform, HttpRouter, HttpServerRespondable } from "effect/http";
|
|
3
|
+
import { clientOf } from "./testing/memory.mjs";
|
|
4
4
|
// src/testing/Testing.ts
|
|
5
5
|
const isClientError = (error) => !HttpServerRespondable.isRespondable(error) && (Schema.isSchemaError(error) || Cause.isNoSuchElementError(error));
|
|
6
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));
|
package/dist/Webhook.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { WebhookDelivery } from "./Event.mjs";
|
|
2
|
-
import { Receiving } from "./contract/receiving.mjs";
|
|
3
|
-
import { Webhooks } from "./contract/webhooks.mjs";
|
|
4
1
|
import { Duration, Layer } from "effect";
|
|
5
2
|
import { HttpClient, HttpRouter } from "effect/http";
|
|
6
3
|
import { Dns } from "effect/net";
|
|
7
4
|
import { KeyValueStore } from "effect/persistence";
|
|
5
|
+
import { WebhookDelivery } from "./Event.mjs";
|
|
6
|
+
import { Receiving } from "./contract/receiving.mjs";
|
|
7
|
+
import { Webhooks } from "./contract/webhooks.mjs";
|
|
8
8
|
/** How `layer` grants, verifies and retries webhook subscriptions. */
|
|
9
9
|
export interface Options {
|
|
10
10
|
/**
|
package/dist/Webhook.mjs
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { Duration, Effect, Layer, Option } from "effect";
|
|
2
|
+
import { Entity } from "effect/cluster";
|
|
3
|
+
import { HttpRouter } from "effect/http";
|
|
4
|
+
import { Dns } from "effect/net";
|
|
5
|
+
import { KeyValueStore } from "effect/persistence";
|
|
1
6
|
import { WebhookDelivery } from "./Event.mjs";
|
|
2
7
|
import { Receiving } from "./contract/receiving.mjs";
|
|
3
8
|
import { Wake } from "./contract/wake.mjs";
|
|
@@ -5,11 +10,6 @@ import { Webhooks } from "./contract/webhooks.mjs";
|
|
|
5
10
|
import { makeReceiver } from "./webhook/receiver.mjs";
|
|
6
11
|
import { entityStorePrefix, makeWriteBehindStorage, storePrefix } from "./webhook/stored.mjs";
|
|
7
12
|
import { makeWebhooks } from "./webhook/subscriptions.mjs";
|
|
8
|
-
import { Duration, Effect, Layer, Option } from "effect";
|
|
9
|
-
import { Entity } from "effect/cluster";
|
|
10
|
-
import { HttpRouter } from "effect/http";
|
|
11
|
-
import { Dns } from "effect/net";
|
|
12
|
-
import { KeyValueStore } from "effect/persistence";
|
|
13
13
|
// src/webhook/Webhook.ts
|
|
14
14
|
const trustedOf = (prefix) => {
|
|
15
15
|
const url = URL.parse(prefix);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
|
+
import { HttpRouter, HttpServerResponse } from "effect/http";
|
|
3
|
+
import { HttpApiMiddleware, HttpApiSecurity } from "effect/http-api";
|
|
1
4
|
import { Any as Any$1, Errors } from "../Action.mjs";
|
|
2
5
|
import { Anyone } from "../contract/caller.mjs";
|
|
3
6
|
import { Codec } from "../contract/codec.mjs";
|
|
@@ -5,9 +8,6 @@ import { Refusal } from "../contract/errors.mjs";
|
|
|
5
8
|
import { Any as Any$2 } from "../Event.mjs";
|
|
6
9
|
import { EventOf, ServingEvents } from "../contract/feed.mjs";
|
|
7
10
|
import { BuildServices, Protected, ServedRequest, Serving } from "../contract/implementation.mjs";
|
|
8
|
-
import { Context, Effect } from "effect";
|
|
9
|
-
import { HttpRouter, HttpServerResponse } from "effect/http";
|
|
10
|
-
import { HttpApiMiddleware, HttpApiSecurity } from "effect/http-api";
|
|
11
11
|
/** One native security scheme: Bearer unless a descriptor names another. */
|
|
12
12
|
export type Security = HttpApiSecurity.HttpApiSecurity;
|
|
13
13
|
/** What a native scheme decodes: a `Redacted` token or key, or Basic credentials. */
|
|
@@ -33,7 +33,7 @@ export interface SecurityMiddleware<I, Name extends string = string> {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
type Response = Effect.Effect<HttpServerResponse.HttpServerResponse, unknown, unknown>;
|
|
36
|
-
interface Runtime
|
|
36
|
+
export interface Runtime {
|
|
37
37
|
readonly descriptor: unknown;
|
|
38
38
|
readonly authenticate: (credential: Credential) => Effect.Effect<unknown, unknown, unknown>;
|
|
39
39
|
readonly middleware: Readonly<Record<string, (route: Response, options: {
|
|
@@ -58,7 +58,7 @@ export interface Descriptor<I, A, S extends Security, Name extends string = stri
|
|
|
58
58
|
principal(identity: A): string;
|
|
59
59
|
/** `Options.schema` of `make`, how an identity is kept, where given. */
|
|
60
60
|
readonly schema?: Codec | undefined;
|
|
61
|
-
readonly "~provider": Context.Key<Provider<I, Name>, Runtime
|
|
61
|
+
readonly "~provider": Context.Key<Provider<I, Name>, Runtime>;
|
|
62
62
|
readonly "~middleware": Context.Key<SecurityMiddleware<I, Name>, unknown>;
|
|
63
63
|
readonly "~verified": Context.Key<never, unknown>;
|
|
64
64
|
}
|
|
@@ -130,4 +130,4 @@ export type VerifierError<A extends Pick<Any$1, "caller">, D> = A["caller"] exte
|
|
|
130
130
|
* `App` serve a protected action of `A` or a protected event type of `E`.
|
|
131
131
|
*/
|
|
132
132
|
export type ServedProvider<App, A extends Any$1, D, E extends Any$2 = EventOf<App>> = [Protected<Serving<App, A>> | Protected<E>] extends [never] ? never : ProviderOf<D>;
|
|
133
|
-
export {
|
|
133
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Unauthenticated } from "../contract/errors.mjs";
|
|
2
1
|
import { Effect, Option } from "effect";
|
|
2
|
+
import { Unauthenticated } from "../contract/errors.mjs";
|
|
3
3
|
// src/authentication/provider.ts
|
|
4
4
|
const providerOf = (auth) => Effect.filterOrElse(Effect.service(auth["~provider"]), (provider) => provider.descriptor === auth, () => Effect.die(/* @__PURE__ */ new Error(`Authentication "${auth.name}": the descriptor named here is not the one its provider was built from (build both from one descriptor)`)));
|
|
5
5
|
const promote = (auth, run) => Effect.flatMap(Effect.serviceOption(auth["~verified"]), (actor) => Option.isSome(actor) ? Effect.provideService(run, auth.identity, actor.value) : Effect.fail(new Unauthenticated()));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { Cause, Context, Effect, Exit, Option, Predicate, Ref, Schema } from "effect";
|
|
2
|
+
import { HttpServerResponse } from "effect/http";
|
|
1
3
|
import { Anyone } from "../contract/caller.mjs";
|
|
2
4
|
import { errorSchemas } from "../contract/declared.mjs";
|
|
3
5
|
import { Forbidden, Refusal, Unauthenticated } from "../contract/errors.mjs";
|
|
4
6
|
import { declaredStatus } from "../contract/status.mjs";
|
|
5
7
|
import { promote } from "./provider.mjs";
|
|
6
|
-
import { Cause, Context, Effect, Exit, Option, Predicate, Ref, Schema } from "effect";
|
|
7
|
-
import { HttpServerResponse } from "effect/http";
|
|
8
8
|
// src/authentication/refusal.ts
|
|
9
9
|
const responseOf = (schema, error) => HttpServerResponse.jsonUnsafe(Schema.encodeUnknownSync(Schema.toCodecJson(schema))(error), { status: declaredStatus(schema) });
|
|
10
10
|
const declaredResponse = (errors, error) => {
|
package/dist/cli/commands.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { Runtime, Types } from "effect";
|
|
2
|
+
import { CliError } from "effect/cli";
|
|
1
3
|
import { Any } from "../Action.mjs";
|
|
2
4
|
import "../contract/errors.mjs";
|
|
3
5
|
import "../Event.mjs";
|
|
4
6
|
import "../contract/implementation.mjs";
|
|
5
7
|
import "../contract/progress.mjs";
|
|
6
8
|
import { Each } from "../contract/stream.mjs";
|
|
7
|
-
import { Effect, Option, Runtime, Stream, Types } from "effect";
|
|
8
|
-
import { CliError, Command } from "effect/cli";
|
|
9
9
|
type Field<A extends Any> = A["input"]["Encoded"] extends (infer E) ? true extends Types.IsUnion<E> ? never : E extends readonly unknown[] ? never : E extends object ? string extends keyof E ? never : Extract<keyof E, string> : never : never;
|
|
10
10
|
type StdinField<A extends Any> = A["input"]["Encoded"] extends (infer E) ? Exclude<Field<A>, { [K in keyof E]-?: {} extends Pick<E, K> ? K : never; }[keyof E]> : never;
|
|
11
11
|
/** How one command of `A` is named, takes its input and prints its result. */
|
package/dist/cli/commands.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Console, Effect, Option, Predicate, Record, Runtime, Schema, SchemaAST, Stdio, Stream } from "effect";
|
|
2
|
+
import { CliError, Command, Flag, Param } from "effect/cli";
|
|
1
3
|
import { literalValues, members, unsuspended } from "../contract/ast.mjs";
|
|
2
4
|
import { decodeInput } from "../contract/call.mjs";
|
|
3
5
|
import { errorSchemas } from "../contract/declared.mjs";
|
|
@@ -8,8 +10,6 @@ import { assertDistinct } from "../contract/names.mjs";
|
|
|
8
10
|
import { ReceivedOf } from "../contract/occurrence.mjs";
|
|
9
11
|
import { elementOf } from "../contract/stream.mjs";
|
|
10
12
|
import { withStderrConsole } from "../stdio/console.mjs";
|
|
11
|
-
import { Console, Effect, Option, Predicate, Record, Runtime, Schema, SchemaAST, Stdio, Stream } from "effect";
|
|
12
|
-
import { CliError, Command, Flag, Param } from "effect/cli";
|
|
13
13
|
// src/cli/commands.ts
|
|
14
14
|
const kebab = (name) => {
|
|
15
15
|
const kebabbed = name.replaceAll(/(?<upper>[A-Z]+)(?<word>[A-Z][a-z])/gu, "$<upper>-$<word>").replaceAll(/(?<lower>[a-z0-9])(?<upper>[A-Z])/gu, "$<lower>-$<upper>").replaceAll("_", "-").replaceAll(/^-+|-+$/gu, "").toLowerCase();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { memoized } from "./implementation.mjs";
|
|
2
1
|
import { Effect, Predicate } from "effect";
|
|
2
|
+
import { memoized } from "./implementation.mjs";
|
|
3
3
|
// src/contract/authorizer.ts
|
|
4
4
|
const authorizerOf = (holding, holdsProtected, authorize) => {
|
|
5
5
|
const { singular, module } = holding;
|