apps 0.0.1-beta.5 → 0.0.1-beta.55
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/README.md +68 -44
- package/framework-reference.json +1 -1
- package/js/chunk-47F7VXST.js +221 -0
- package/js/chunk-5FHWNLCI.js +88 -0
- package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
- package/js/chunk-7UUHJR2Q.js +49 -0
- package/js/{chunk-CYYBFC2K.js → chunk-AQU56EPI.js} +9 -5
- package/js/chunk-BTSIG4NQ.js +1885 -0
- package/js/chunk-CDXQDN7W.js +92 -0
- package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
- package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
- package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
- package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
- package/js/{chunk-UDDE5KOR.js → chunk-JK5S2N2S.js} +148 -34
- package/js/{chunk-RJDDBDSN.js → chunk-JM7LOD2W.js} +628 -85
- package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
- package/js/{chunk-FWQC6I3C.js → chunk-KGCTYL2S.js} +523 -63
- package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
- package/js/chunk-L4K2K22P.js +42 -0
- package/js/chunk-LTDHQJ2Z.js +171 -0
- package/js/chunk-MWKHKOTL.js +240 -0
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
- package/js/chunk-PXXZ6ABC.js +266 -0
- package/js/chunk-QEBRH5AP.js +729 -0
- package/js/chunk-TLWLJ7PD.js +4342 -0
- package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
- package/js/{chunk-XHO2ZX6W.js → chunk-UM62MBJQ.js} +96 -41
- package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
- package/js/chunk-XCSG7FT7.js +340 -0
- package/js/client.js +142 -94
- package/js/contracts.js +123 -33
- package/js/effect.js +19 -21
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +63 -60
- package/js/host.js +83 -60
- package/js/index.js +262 -222
- package/js/mcp/effect.js +23 -23
- package/js/mcp/stdio.js +48 -40
- package/js/mcp.js +109 -72
- package/js/openapi.js +4129 -1419
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +208 -82
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +5 -4
- package/js/ui/serving.js +8517 -214
- package/package.json +2 -3
- package/runtime.json +1 -1
- package/types/app-cache/src/index.d.ts +10 -1
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +9 -8
- package/types/apps/src/contracts/cache.d.ts +20 -0
- package/types/apps/src/contracts/context.d.ts +19 -11
- package/types/apps/src/contracts/elicitation.d.ts +6 -6
- package/types/apps/src/contracts/events.d.ts +93 -0
- package/types/apps/src/contracts/failure.d.ts +30 -1
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +57 -18
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +96 -10
- package/types/apps/src/contracts/network.d.ts +84 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +32 -3
- package/types/apps/src/contracts/openapi.d.ts +45 -9
- package/types/apps/src/contracts/operations.d.ts +8 -9
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +733 -81
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/2.d.ts +69 -26
- package/types/apps/src/contracts/protocols/3.d.ts +133 -33
- package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
- package/types/apps/src/contracts/protocols/current.d.ts +2476 -0
- package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +115 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +50 -13
- package/types/apps/src/contracts/sql.d.ts +58 -0
- package/types/apps/src/contracts/ui.d.ts +19 -1
- package/types/apps/src/contracts/workflows.d.ts +6 -0
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +13 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/authoring.d.ts +25 -5
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/cache.d.ts +4 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
- package/types/apps/src/implementation/elicitation.d.ts +18 -15
- package/types/apps/src/implementation/events.d.ts +59 -0
- package/types/apps/src/implementation/failure-detail.d.ts +25 -3
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/input-problems.d.ts +6 -2
- package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +49 -25
- package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +52 -25
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
- package/types/apps/src/implementation/openapi-document.d.ts +46 -19
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +10 -2
- package/types/apps/src/implementation/openapi-source.d.ts +8 -6
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +43 -5
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +19 -5
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +223 -0
- package/types/apps/src/implementation/router.d.ts +70 -0
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schema.d.ts +95 -11
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +71 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +1 -1
- package/types/apps/src/implementation/ui-client.d.ts +2 -2
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +11 -5
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/upstream-error.d.ts +7 -0
- package/types/apps/src/implementation/webhooks.d.ts +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +1 -1
- package/types/apps/src/implementation/workflows.d.ts +1 -1
- package/types/apps/src/index.d.ts +32 -13
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +25 -5
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +7 -4
- package/types/telemetry/src/browser.d.ts +8 -3
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/index.d.ts +1 -0
- package/types/telemetry/src/layer.d.ts +2 -2
- package/types/telemetry/src/ownership.d.ts +56 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -0
- package/types/telemetry/src/relay.d.ts +2 -2
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +55 -0
- package/types/utils/src/connection-failure.d.ts +33 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-3XKZDQLM.js +0 -93
- package/js/chunk-4M277YTM.js +0 -136
- package/js/chunk-67EVWIGJ.js +0 -224
- package/js/chunk-C3VAOK5B.js +0 -215
- package/js/chunk-DQAZTA4I.js +0 -2375
- package/js/chunk-G7T27IWB.js +0 -63
- package/js/chunk-LUVSFETN.js +0 -1347
- package/js/chunk-N7YDVXYJ.js +0 -186
- package/js/chunk-PJJ24GU7.js +0 -877
- package/js/chunk-PZB6T6KU.js +0 -19
- package/js/chunk-SB3V4YVR.js +0 -18
- package/js/chunk-TDNYXSIX.js +0 -29
- package/js/chunk-W4DMKWAB.js +0 -35
- package/js/chunk-YEPYT6SD.js +0 -85
- package/js/chunk-ZQINWV4W.js +0 -630
- package/types/app-data/src/implementation/cursor.d.ts +0 -10
- package/types/app-data/src/implementation/index-key.d.ts +0 -7
- package/types/app-data/src/implementation/promise.d.ts +0 -68
- package/types/app-data/src/implementation/range.d.ts +0 -8
- package/types/app-data/src/implementation/schema.d.ts +0 -18
- package/types/app-data/src/implementation/sqlite.d.ts +0 -11
- package/types/app-data/src/index.d.ts +0 -4
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
- package/types/apps/src/implementation/storage.d.ts +0 -15
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Pure operation declarations. Only the author callback crosses the Promise boundary. */
|
|
2
|
-
import {
|
|
2
|
+
import { Schema as EffectSchema } from "effect";
|
|
3
3
|
import type { AppOperation } from "../contracts/operations.js";
|
|
4
4
|
import type { AppContext, QueryContext, MutationContext } from "../contracts/context.js";
|
|
5
5
|
import type { Approval } from "../approval.js";
|
|
@@ -7,16 +7,44 @@ import type { ToolAnnotations } from "../contracts/tools.js";
|
|
|
7
7
|
import type { JsonObject } from "../contracts/schema.js";
|
|
8
8
|
import { type Schema } from "./schema.js";
|
|
9
9
|
declare const NativeOperation: unique symbol;
|
|
10
|
-
declare const
|
|
11
|
-
|
|
10
|
+
declare const QueryHandlerContext: unique symbol;
|
|
11
|
+
declare const MutationHandlerContext: unique symbol;
|
|
12
|
+
/**
|
|
13
|
+
* A server-only declaration with its category preserved for catalog validation. Queries and
|
|
14
|
+
* mutations carry their handler context under different phantom keys, so a router can type a
|
|
15
|
+
* query's handler from its query context alone.
|
|
16
|
+
*/
|
|
12
17
|
export interface OperationDeclaration<Kind extends "query" | "mutation", Context = never> {
|
|
13
|
-
readonly [
|
|
18
|
+
readonly [QueryHandlerContext]?: "query" extends Kind ? (context: Context) => void : never;
|
|
19
|
+
readonly [MutationHandlerContext]?: "mutation" extends Kind ? (context: Context) => void : never;
|
|
14
20
|
readonly kind: Kind;
|
|
15
21
|
readonly [NativeOperation]: Omit<AppOperation<never>, "kind" | "input"> & {
|
|
16
22
|
readonly kind: Kind;
|
|
17
23
|
readonly input: EffectSchema.Decoder<unknown>;
|
|
18
24
|
};
|
|
19
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* A router declaration. The phantom contexts let `defineApp` type inline handlers; protocol
|
|
28
|
+
* routers accept any context because their operations only use the framework's own capabilities.
|
|
29
|
+
* The native router is held under a private key in implementation/router.ts.
|
|
30
|
+
*/
|
|
31
|
+
export interface RouterDeclaration<Query = unknown, Mutation = unknown> {
|
|
32
|
+
readonly [QueryHandlerContext]?: (context: Query) => void;
|
|
33
|
+
readonly [MutationHandlerContext]?: (context: Mutation) => void;
|
|
34
|
+
readonly [NativeRouterKey]: unknown;
|
|
35
|
+
}
|
|
36
|
+
/** An operation or nested router under one key. Each child is typed only by its own kind's context. */
|
|
37
|
+
export interface RouterChild<Query, Mutation> {
|
|
38
|
+
readonly [QueryHandlerContext]?: (context: Query) => void;
|
|
39
|
+
readonly [MutationHandlerContext]?: (context: Mutation) => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A query or mutation whose handler context is checked by its kind, as a dynamic router resolves
|
|
43
|
+
* one. `query()` and `mutation()` results fit with their inferred contexts.
|
|
44
|
+
*/
|
|
45
|
+
export type OperationChild<Query, Mutation> = RouterChild<Query, Mutation> & Pick<OperationDeclaration<"query" | "mutation">, "kind" | typeof NativeOperation>;
|
|
46
|
+
/** Private key for a router's native definition. */
|
|
47
|
+
export declare const NativeRouterKey: unique symbol;
|
|
20
48
|
/** Typed operation handles drive browser reference inference without bundling handlers. */
|
|
21
49
|
export interface Operation<Input, Output, Kind extends "query" | "mutation", Context = AppContext> extends OperationDeclaration<Kind, Context> {
|
|
22
50
|
readonly [NativeOperation]: AppOperation<Input, Output> & {
|
|
@@ -41,7 +69,7 @@ export interface OperationOptions<Input, Output> {
|
|
|
41
69
|
}
|
|
42
70
|
/** Adapt metadata and approval without running user code. */
|
|
43
71
|
export declare const operationOptions: <Input, Output>(options: OperationOptions<Input, Output>) => {
|
|
44
|
-
approval?: (context: Parameters<Approval<Input>>[0]) => Effect.Effect<"approved" | "denied" | "user-approval", unknown, never>;
|
|
72
|
+
approval?: (context: Parameters<Approval<Input>>[0]) => import("effect/Effect").Effect<"approved" | "denied" | "user-approval", unknown, never>;
|
|
45
73
|
input: EffectSchema.Decoder<Input, never>;
|
|
46
74
|
_meta?: {
|
|
47
75
|
readonly [x: string]: EffectSchema.Json;
|
|
@@ -56,8 +84,18 @@ export declare const operationOptions: <Input, Output>(options: OperationOptions
|
|
|
56
84
|
title?: string;
|
|
57
85
|
description?: string;
|
|
58
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Replace a native operation's approval. Property descriptors are copied so an output schema that
|
|
89
|
+
* a protocol adapter builds only when read stays lazy.
|
|
90
|
+
*/
|
|
91
|
+
export declare const approvedOperation: <Input, Native extends AppOperation<Input, unknown>>(operation: Native, approval: Approval<Input>) => Native;
|
|
59
92
|
/** Attach the same approval function to a generated or shared operation. */
|
|
60
93
|
export declare const withApproval: <Input, Output, Kind extends "query" | "mutation", Context>(operation: Operation<Input, Output, Kind, Context>, approval: Approval<Input>) => Operation<Input, Output, Kind, Context>;
|
|
94
|
+
/**
|
|
95
|
+
* The advisory hints an operation carries, such as an MCP server's `destructiveHint`. App code
|
|
96
|
+
* reads them to choose an approval; the framework never infers one from them.
|
|
97
|
+
*/
|
|
98
|
+
export declare const toolAnnotations: (operation: OperationDeclaration<"query" | "mutation", never>) => ToolAnnotations | undefined;
|
|
61
99
|
/** Read operation. External reads are allowed; only database writes are mechanically prohibited. */
|
|
62
100
|
export declare const query: <Input, Output, Context extends AppContext = QueryContext>(options: OperationOptions<Input, Output>, run: (context: Context, input: Input) => Promise<Output>) => Operation<Input, Output, "query", Context>;
|
|
63
101
|
/** Explicit write operation. Database writes roll back on failure; external effects cannot be undone. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** One client's mounted queries and ordered optimistic write/read handoffs. */
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
-
import { Atom, AsyncResult } from "effect/
|
|
3
|
+
import { Atom, AsyncResult } from "effect/reactivity";
|
|
4
4
|
import type { AppMutation } from "../contracts/optimistic.js";
|
|
5
5
|
import type { OperationReference } from "../contracts/live.js";
|
|
6
6
|
import { JsonValue } from "../contracts/schema.js";
|
|
@@ -13,12 +13,14 @@ interface ProtocolOperation {
|
|
|
13
13
|
readonly annotations?: ToolAnnotations | undefined;
|
|
14
14
|
readonly _meta?: JsonObject | undefined;
|
|
15
15
|
readonly input: Schema.Decoder<JsonValue>;
|
|
16
|
+
/** Checks and describes every returned value. */
|
|
17
|
+
readonly output?: Schema.Decoder<JsonValue> | undefined;
|
|
18
|
+
/** Describes the returned value without checking it; ignored when `output` is declared. */
|
|
16
19
|
readonly outputSchema?: JsonObject | undefined;
|
|
17
20
|
readonly run: (context: OperationContext, input: JsonValue) => Effect.Effect<unknown, unknown>;
|
|
18
21
|
}
|
|
19
22
|
/** Unknown behavior defaults to mutation. Classification never enforces an external service's behavior. */
|
|
20
|
-
export declare const protocolOperations: (operations: Readonly<Record<string, ProtocolOperation>>, kinds?: OperationKinds) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
23
|
+
export declare const protocolOperations: (operations: Readonly<Record<string, ProtocolOperation>>, kinds?: OperationKinds) => Record<string, Operation<Schema.Json, unknown, "query" | "mutation", OperationContext>>;
|
|
24
|
+
/** Operations already discovered, as a router keyed by upstream name. */
|
|
25
|
+
export declare const protocolRouter: (operations: Readonly<Record<string, ProtocolOperation>>, kinds?: OperationKinds) => import("./operations.js").RouterDeclaration<unknown, unknown>;
|
|
24
26
|
export {};
|
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
import { Option } from "effect";
|
|
2
|
+
import type { FailurePhase, UpstreamError } from "../contracts/failure.js";
|
|
2
3
|
import { ProviderError } from "../contracts/provider-error.js";
|
|
4
|
+
import { AccountId } from "../contracts/schema.js";
|
|
5
|
+
/** A provider failure's fields, each optional one possibly absent. */
|
|
6
|
+
interface ProviderErrorFields {
|
|
7
|
+
readonly reason: ProviderError["reason"];
|
|
8
|
+
readonly status?: number | undefined;
|
|
9
|
+
readonly accountId?: AccountId | undefined;
|
|
10
|
+
readonly phase?: FailurePhase | undefined;
|
|
11
|
+
readonly upstream?: UpstreamError | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Construct a provider failure without keys for absent fields. Failures inside a catalog cross the
|
|
15
|
+
* boundary as JSON values, which have no `undefined`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const providerError: ({ reason, status, accountId, phase, upstream, }: ProviderErrorFields) => ProviderError;
|
|
3
18
|
/** Parse and rebuild the allowlisted fields, including when the input is already an Error instance. */
|
|
4
19
|
export declare function parseProviderError(error: unknown): Option.Option<ProviderError>;
|
|
5
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* The same failure with detail its raiser could not know: the phase it happened in, and the
|
|
22
|
+
* error the service stated. Detail the failure already carries is kept.
|
|
23
|
+
*/
|
|
24
|
+
export declare function providerErrorDetail(error: ProviderError, detail: {
|
|
25
|
+
readonly phase?: FailurePhase;
|
|
26
|
+
readonly upstream?: UpstreamError | undefined;
|
|
27
|
+
}): ProviderError;
|
|
28
|
+
/**
|
|
29
|
+
* Classify only explicit HTTP evidence. Raw provider content never enters the error; a Bearer
|
|
30
|
+
* challenge's documented error code and description do.
|
|
31
|
+
*/
|
|
6
32
|
export declare function httpProviderError(status: number, headers?: Readonly<Record<string, string>>): ProviderError | undefined;
|
|
7
33
|
/** Attach the account used by the enclosing operation, without preserving arbitrary thrown fields. */
|
|
8
34
|
export declare function accountProviderError<E>(error: E, accountId: string): E | ProviderError;
|
|
9
35
|
/** GraphQL has no standard auth code; recognize these documented codes without guessing from prose. */
|
|
10
36
|
export declare function graphqlProviderError(errors: readonly unknown[], status: number): ProviderError | undefined;
|
|
37
|
+
export {};
|
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
/** Pure constructors over the native provider contracts. */
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
|
-
import { type
|
|
3
|
+
import { type PromiseMethod } from "./authoring.js";
|
|
4
|
+
import { type AccountCheck, type AuthMethods, type FieldExposure, OAuth2Config, OAuth2Method, Provider, SecretsMethod } from "../contracts/provider.js";
|
|
4
5
|
import type { ValidationError } from "../contracts/schema.js";
|
|
5
6
|
/** Declare a secrets method with an Effect decoder. */
|
|
6
7
|
export declare const secrets: <Fields extends Schema.Decoder<unknown>>(options: {
|
|
7
8
|
readonly label: string;
|
|
8
9
|
readonly fields: Fields;
|
|
10
|
+
readonly exposure?: Readonly<Record<string, FieldExposure>>;
|
|
9
11
|
}) => SecretsMethod<Fields>;
|
|
10
12
|
/** Validate OAuth endpoints while declaring their app-visible response projection. */
|
|
11
|
-
export declare const oauth2: <Response extends Schema.Decoder<unknown>>(config: OAuth2Config, response: Response) => Effect.Effect<OAuth2Method<Response>, ValidationError>;
|
|
12
|
-
/**
|
|
13
|
-
export
|
|
13
|
+
export declare const oauth2: <Response extends Schema.Decoder<unknown>>(config: OAuth2Config, response: Response, exposure?: Readonly<Record<string, FieldExposure>>) => Effect.Effect<OAuth2Method<Response>, ValidationError>;
|
|
14
|
+
/** Author options: the account check is an ordinary async function. */
|
|
15
|
+
export interface ProviderOptions<Auth extends AuthMethods> {
|
|
14
16
|
readonly name: string;
|
|
15
17
|
readonly auth: Auth;
|
|
16
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Hosts the credentials may be sent to: `api.example.com`, `api.example.com:8443`, or
|
|
20
|
+
* `*.example.com` for one level of subdomain. Secret fields then reach app code as handles
|
|
21
|
+
* that the outbound network replaces only on requests to these hosts. An account records the
|
|
22
|
+
* hosts it was connected for; changing them does not change the provider, but an existing
|
|
23
|
+
* account sends only to hosts it was connected for until it is connected again.
|
|
24
|
+
*/
|
|
25
|
+
readonly hosts?: readonly string[];
|
|
26
|
+
/** Verify a connected account with a safe read, optionally reporting its upstream identity. */
|
|
27
|
+
readonly health?: PromiseMethod<AccountCheck<Auth>["run"]>;
|
|
28
|
+
}
|
|
29
|
+
/** Retain the provider and literal method names without registering or authenticating it. */
|
|
30
|
+
export declare const defineProvider: <const Auth extends AuthMethods>({ health, ...options }: ProviderOptions<Auth>) => Provider<Auth>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AsyncResult } from "effect/
|
|
1
|
+
import { AsyncResult } from "effect/reactivity";
|
|
2
2
|
/** Per-result metadata follows the exact Atom registry snapshot, including concurrent mounts. */
|
|
3
3
|
export interface ObservedQueryValue<A> {
|
|
4
4
|
readonly value: A;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a live router tree into tools, routers and router skills. A nested dynamic router that fails
|
|
3
|
+
* is reported on its own entry; the root failing fails the read, as a single-source app would.
|
|
4
|
+
*/
|
|
5
|
+
import { Effect, Schema } from "effect";
|
|
6
|
+
import { HostDeclarationInvalid, HostEvaluationFailed, type HostRouterError } from "../contracts/host.js";
|
|
7
|
+
import type { AppOperation } from "../contracts/operations.js";
|
|
8
|
+
import type { AppRouter, DynamicRouter, RouterMeta } from "../contracts/router.js";
|
|
9
|
+
import type { OperationSchedule } from "../contracts/schedules.js";
|
|
10
|
+
/**
|
|
11
|
+
* Keep only a failure's safe fields. Anything unrecognized becomes an evaluation failure with the
|
|
12
|
+
* error's name and bounded message, with the given account secrets replaced.
|
|
13
|
+
*/
|
|
14
|
+
export declare const safeFailure: (error: unknown, secrets: readonly string[]) => HostRouterError;
|
|
15
|
+
/**
|
|
16
|
+
* Router skills are named `tools` for the root and `tools-<path>` below it, so a router's
|
|
17
|
+
* instructions never take an authored skill's name by accident.
|
|
18
|
+
*/
|
|
19
|
+
export declare const routerSkillPrefix = "tools";
|
|
20
|
+
/**
|
|
21
|
+
* The skill name for a router path. A path of lowercase letters and digits is spelled out:
|
|
22
|
+
* `issues.open` is `tools-issues-open`. Any other path, or one too long, is a readable slug
|
|
23
|
+
* followed by a hash of the exact path, such as `tools-issues-list-0123456789`. Plain segments
|
|
24
|
+
* start with a letter and a hash is all digits, so the two forms never meet, and paths that slug
|
|
25
|
+
* alike, such as `issues_list` and `issues.list`, get different names.
|
|
26
|
+
*/
|
|
27
|
+
export declare const routerSkillName: (path: string) => string;
|
|
28
|
+
/** A declared operation's catalog entry without schemas. `router` is its owning router's path. */
|
|
29
|
+
export declare const operationSummary: (name: string, router: string, operation: AppOperation, schedules?: readonly OperationSchedule[]) => Effect.Effect<{
|
|
30
|
+
readonly description: string;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly router?: string;
|
|
33
|
+
readonly title?: string;
|
|
34
|
+
readonly annotations?: {
|
|
35
|
+
readonly title?: string;
|
|
36
|
+
readonly readOnlyHint?: boolean;
|
|
37
|
+
readonly destructiveHint?: boolean;
|
|
38
|
+
readonly idempotentHint?: boolean;
|
|
39
|
+
readonly openWorldHint?: boolean;
|
|
40
|
+
};
|
|
41
|
+
readonly schedules?: readonly {
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly timing: {
|
|
44
|
+
readonly kind: "interval";
|
|
45
|
+
readonly milliseconds: number;
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: "cron";
|
|
48
|
+
readonly calendar: {
|
|
49
|
+
readonly expression: string;
|
|
50
|
+
readonly timezone: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly input: Schema.Json;
|
|
54
|
+
}[];
|
|
55
|
+
readonly readOnly?: boolean;
|
|
56
|
+
readonly tags?: readonly string[];
|
|
57
|
+
}, HostDeclarationInvalid, never>;
|
|
58
|
+
/** A declared operation's full description, including rendered schemas. */
|
|
59
|
+
export declare const operationDescription: (name: string, router: string, operation: AppOperation, schedules?: readonly OperationSchedule[]) => Effect.Effect<{
|
|
60
|
+
readonly description: string;
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly inputSchema: {
|
|
63
|
+
readonly [x: string]: Schema.Json;
|
|
64
|
+
};
|
|
65
|
+
readonly _meta?: {
|
|
66
|
+
readonly [x: string]: Schema.Json;
|
|
67
|
+
};
|
|
68
|
+
readonly router?: string;
|
|
69
|
+
readonly title?: string;
|
|
70
|
+
readonly annotations?: {
|
|
71
|
+
readonly title?: string;
|
|
72
|
+
readonly readOnlyHint?: boolean;
|
|
73
|
+
readonly destructiveHint?: boolean;
|
|
74
|
+
readonly idempotentHint?: boolean;
|
|
75
|
+
readonly openWorldHint?: boolean;
|
|
76
|
+
};
|
|
77
|
+
readonly outputSchema?: {
|
|
78
|
+
readonly [x: string]: Schema.Json;
|
|
79
|
+
};
|
|
80
|
+
readonly schedules?: readonly {
|
|
81
|
+
readonly name: string;
|
|
82
|
+
readonly timing: {
|
|
83
|
+
readonly kind: "interval";
|
|
84
|
+
readonly milliseconds: number;
|
|
85
|
+
} | {
|
|
86
|
+
readonly kind: "cron";
|
|
87
|
+
readonly calendar: {
|
|
88
|
+
readonly expression: string;
|
|
89
|
+
readonly timezone: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
readonly input: Schema.Json;
|
|
93
|
+
}[];
|
|
94
|
+
readonly readOnly?: boolean;
|
|
95
|
+
readonly tags?: readonly string[];
|
|
96
|
+
}, HostDeclarationInvalid, never>;
|
|
97
|
+
/**
|
|
98
|
+
* A dynamic router over operations already discovered, such as an eager OpenAPI document or a
|
|
99
|
+
* stdio server. Upstream names can contain dots, which static router keys cannot.
|
|
100
|
+
*/
|
|
101
|
+
export declare const fixedRouter: (operations: Readonly<Record<string, AppOperation>>, meta?: RouterMeta) => DynamicRouter;
|
|
102
|
+
export interface CatalogOptions {
|
|
103
|
+
/** Omit schemas. */
|
|
104
|
+
readonly summary: boolean;
|
|
105
|
+
/** Account secrets that a failure's message must not reveal. */
|
|
106
|
+
readonly secrets: readonly string[];
|
|
107
|
+
/** Only these full tool names. Routers with none of them are not read. */
|
|
108
|
+
readonly wanted?: ReadonlySet<string>;
|
|
109
|
+
/** Schedules that target a declared operation, by full name. */
|
|
110
|
+
readonly schedules: (name: string) => readonly OperationSchedule[];
|
|
111
|
+
/**
|
|
112
|
+
* Only declared operations that have schedules. Schedules never target dynamic routers, and
|
|
113
|
+
* their catalogs can be expensive to discover, so none is read.
|
|
114
|
+
*/
|
|
115
|
+
readonly scheduled?: true;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Read a router tree. Every nested router is listed, for grouping; the root only when it has
|
|
119
|
+
* metadata. A nested dynamic source that fails is reported on its router's entry.
|
|
120
|
+
*/
|
|
121
|
+
export declare const readCatalog: (root: AppRouter | DynamicRouter | undefined, options: CatalogOptions) => Effect.Effect<{
|
|
122
|
+
tools: ({
|
|
123
|
+
readonly description: string;
|
|
124
|
+
readonly name: string;
|
|
125
|
+
readonly inputSchema: {
|
|
126
|
+
readonly [x: string]: Schema.Json;
|
|
127
|
+
};
|
|
128
|
+
readonly _meta?: {
|
|
129
|
+
readonly [x: string]: Schema.Json;
|
|
130
|
+
};
|
|
131
|
+
readonly router?: string;
|
|
132
|
+
readonly title?: string;
|
|
133
|
+
readonly annotations?: {
|
|
134
|
+
readonly title?: string;
|
|
135
|
+
readonly readOnlyHint?: boolean;
|
|
136
|
+
readonly destructiveHint?: boolean;
|
|
137
|
+
readonly idempotentHint?: boolean;
|
|
138
|
+
readonly openWorldHint?: boolean;
|
|
139
|
+
};
|
|
140
|
+
readonly outputSchema?: {
|
|
141
|
+
readonly [x: string]: Schema.Json;
|
|
142
|
+
};
|
|
143
|
+
readonly schedules?: readonly {
|
|
144
|
+
readonly name: string;
|
|
145
|
+
readonly timing: {
|
|
146
|
+
readonly kind: "interval";
|
|
147
|
+
readonly milliseconds: number;
|
|
148
|
+
} | {
|
|
149
|
+
readonly kind: "cron";
|
|
150
|
+
readonly calendar: {
|
|
151
|
+
readonly expression: string;
|
|
152
|
+
readonly timezone: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
readonly input: Schema.Json;
|
|
156
|
+
}[];
|
|
157
|
+
readonly readOnly?: boolean;
|
|
158
|
+
readonly tags?: readonly string[];
|
|
159
|
+
} | {
|
|
160
|
+
readonly description: string;
|
|
161
|
+
readonly name: string;
|
|
162
|
+
readonly router?: string;
|
|
163
|
+
readonly title?: string;
|
|
164
|
+
readonly annotations?: {
|
|
165
|
+
readonly title?: string;
|
|
166
|
+
readonly readOnlyHint?: boolean;
|
|
167
|
+
readonly destructiveHint?: boolean;
|
|
168
|
+
readonly idempotentHint?: boolean;
|
|
169
|
+
readonly openWorldHint?: boolean;
|
|
170
|
+
};
|
|
171
|
+
readonly schedules?: readonly {
|
|
172
|
+
readonly name: string;
|
|
173
|
+
readonly timing: {
|
|
174
|
+
readonly kind: "interval";
|
|
175
|
+
readonly milliseconds: number;
|
|
176
|
+
} | {
|
|
177
|
+
readonly kind: "cron";
|
|
178
|
+
readonly calendar: {
|
|
179
|
+
readonly expression: string;
|
|
180
|
+
readonly timezone: string;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
readonly input: Schema.Json;
|
|
184
|
+
}[];
|
|
185
|
+
readonly readOnly?: boolean;
|
|
186
|
+
readonly tags?: readonly string[];
|
|
187
|
+
})[];
|
|
188
|
+
routers: {
|
|
189
|
+
readonly path: string;
|
|
190
|
+
readonly description?: string;
|
|
191
|
+
readonly error?: import("../index.js").ProviderError | import("../contracts/host.js").McpError | import("../contracts/host.js").SkillLoadFailed | HostDeclarationInvalid | HostEvaluationFailed;
|
|
192
|
+
readonly title?: string;
|
|
193
|
+
readonly tags?: {
|
|
194
|
+
readonly [x: string]: string;
|
|
195
|
+
};
|
|
196
|
+
readonly icons?: readonly {
|
|
197
|
+
readonly src: string;
|
|
198
|
+
readonly mimeType?: string;
|
|
199
|
+
readonly sizes?: readonly string[];
|
|
200
|
+
readonly theme?: "light" | "dark";
|
|
201
|
+
}[];
|
|
202
|
+
readonly skill?: string;
|
|
203
|
+
}[];
|
|
204
|
+
}, import("../index.js").ProviderError | import("../contracts/host.js").McpError | import("../contracts/host.js").SkillLoadFailed | HostDeclarationInvalid | HostEvaluationFailed, never>;
|
|
205
|
+
/**
|
|
206
|
+
* One skill for each router with instructions. Skills and tools fail independently: a dynamic
|
|
207
|
+
* router whose metadata cannot be read, including the root, contributes no skill and does not
|
|
208
|
+
* fail the others. Metadata comes through each source's catalog cache, like a tool listing.
|
|
209
|
+
*/
|
|
210
|
+
export declare const routerSkills: (root: AppRouter | DynamicRouter | undefined) => Effect.Effect<{
|
|
211
|
+
readonly description: string;
|
|
212
|
+
readonly name: string;
|
|
213
|
+
readonly files: readonly {
|
|
214
|
+
readonly path: string;
|
|
215
|
+
readonly content: string;
|
|
216
|
+
}[];
|
|
217
|
+
readonly license?: string;
|
|
218
|
+
readonly compatibility?: string;
|
|
219
|
+
readonly metadata?: {
|
|
220
|
+
readonly [x: string]: string;
|
|
221
|
+
};
|
|
222
|
+
readonly "allowed-tools"?: string;
|
|
223
|
+
}[], never, never>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { HostedTool } from "../contracts/host.js";
|
|
2
|
+
import type { AppOperation } from "../contracts/operations.js";
|
|
3
|
+
import { RouterMeta, type AppRouter, type DynamicRouter, type RouterIcon } from "../contracts/router.js";
|
|
4
|
+
import type { Approval } from "../approval.js";
|
|
5
|
+
import { type OperationChild, type OperationDeclaration, type RouterChild, type RouterDeclaration } from "./operations.js";
|
|
6
|
+
export type { OperationChild, OperationDeclaration, RouterChild, RouterDeclaration, } from "./operations.js";
|
|
7
|
+
/** Author metadata for a router. Instructions become a skill named after the router's path. */
|
|
8
|
+
export interface RouterOptions {
|
|
9
|
+
readonly title?: string;
|
|
10
|
+
readonly description?: string;
|
|
11
|
+
readonly instructions?: string;
|
|
12
|
+
readonly icons?: readonly RouterIcon[];
|
|
13
|
+
readonly tags?: Readonly<Record<string, string>>;
|
|
14
|
+
}
|
|
15
|
+
/** Wrap a native router. Protocol helpers use this for the routers they build. */
|
|
16
|
+
export declare const routerDeclaration: (node: AppRouter | DynamicRouter) => RouterDeclaration;
|
|
17
|
+
/** Accept only framework-created routers. */
|
|
18
|
+
export declare const nativeRouter: (value: unknown) => AppRouter | DynamicRouter | undefined;
|
|
19
|
+
/** Author fields win; a field the author omits keeps the source's value. */
|
|
20
|
+
export declare const mergeMeta: (base: RouterMeta | undefined, override: RouterMeta | undefined) => RouterMeta | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Group operations and routers under path keys, like tRPC's nested routers, with metadata an
|
|
23
|
+
* agent can read. Passing an existing router instead of children overrides its metadata:
|
|
24
|
+
* `router(mcpRouter(options), { description: "..." })`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function router<Query = unknown, Mutation = unknown>(children: Readonly<Record<string, RouterChild<Query, Mutation>>>, options?: RouterOptions): RouterDeclaration<Query, Mutation>;
|
|
27
|
+
export declare function router<Query, Mutation>(source: RouterDeclaration<Query, Mutation>, options: RouterOptions): RouterDeclaration<Query, Mutation>;
|
|
28
|
+
/**
|
|
29
|
+
* Declare a router whose tools are discovered when read. `list` returns tools with names relative
|
|
30
|
+
* to this router; mark queries with `readOnly: true`. `resolve` receives one of those names.
|
|
31
|
+
* The router carries the handler contexts of the operations `resolve` returns, so `defineApp`
|
|
32
|
+
* checks them like a static router's.
|
|
33
|
+
*/
|
|
34
|
+
export declare const dynamicRouter: <Query = unknown, Mutation = unknown>(source: {
|
|
35
|
+
readonly meta?: () => RouterOptions | Promise<RouterOptions>;
|
|
36
|
+
readonly list: () => readonly HostedTool[] | Promise<readonly HostedTool[]>;
|
|
37
|
+
readonly resolve: (name: string) => OperationChild<Query, Mutation> | undefined | Promise<OperationChild<Query, Mutation> | undefined>;
|
|
38
|
+
}) => RouterDeclaration<Query, Mutation>;
|
|
39
|
+
/** Join a router path and a relative name. The root router's path is "". */
|
|
40
|
+
export declare const joinPath: (path: string, name: string) => string;
|
|
41
|
+
/** Where a full tool name points: a declared operation, or a name inside a dynamic router. */
|
|
42
|
+
export type Location = {
|
|
43
|
+
readonly kind: "operation";
|
|
44
|
+
readonly operation: AppOperation;
|
|
45
|
+
readonly router: string;
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: "dynamic";
|
|
48
|
+
readonly source: DynamicRouter;
|
|
49
|
+
readonly router: string;
|
|
50
|
+
readonly name: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Walk static keys until the name ends at an operation or enters a dynamic router, which receives
|
|
54
|
+
* the rest of the name. Static keys contain no dots, so every name has at most one location.
|
|
55
|
+
*/
|
|
56
|
+
export declare const locate: (root: AppRouter | DynamicRouter | undefined, name: string) => Location | undefined;
|
|
57
|
+
/** Every declared operation with its full name and owning router. Dynamic routers are not listed. */
|
|
58
|
+
export declare const declaredOperations: (root: AppRouter | undefined, path?: string) => Array<{
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly router: string;
|
|
61
|
+
readonly operation: AppOperation;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Choose an approval for each operation a router contains, including tools a dynamic router
|
|
65
|
+
* resolves later. `policy` receives the operation and its name relative to this router; returning
|
|
66
|
+
* undefined keeps the operation's own approval. Read hints with `toolAnnotations(operation)`.
|
|
67
|
+
* Apply it to each account's router before `accountRouter` combines them, so every account keeps
|
|
68
|
+
* its own tools' hints.
|
|
69
|
+
*/
|
|
70
|
+
export declare const withApprovals: <Query, Mutation>(source: RouterDeclaration<Query, Mutation>, policy: (operation: OperationDeclaration<"query" | "mutation", never>, name: string) => Approval | undefined) => RouterDeclaration<Query, Mutation>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Let the runtime run its own tasks between long synchronous steps. In a Worker, a large OpenAPI
|
|
3
|
+
* compilation that never yields leaves the garbage collector only long, full pauses; yielding
|
|
4
|
+
* between steps measurably shortens it. A timer is used because a resolved promise would continue
|
|
5
|
+
* without leaving the current task.
|
|
6
|
+
*/
|
|
7
|
+
export declare const yieldToRuntime: () => Promise<void>;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/** Author schema facade. Internals use the native decoder retained by each value. */
|
|
2
2
|
import { Effect, Schema as EffectSchema } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
declare const StorageField: unique symbol;
|
|
3
|
+
import { JsonObject, ValidationError } from "../contracts/schema.js";
|
|
4
|
+
import type { FieldExposure } from "../contracts/provider.js";
|
|
6
5
|
declare const Decoder: unique symbol;
|
|
7
6
|
/** An author-facing value schema. Effect is never required in author code. */
|
|
8
7
|
export interface Schema<T, Optional extends boolean = false> {
|
|
9
|
-
readonly [StorageField]?: Field;
|
|
10
8
|
readonly [Decoder]: EffectSchema.Decoder<T>;
|
|
11
9
|
readonly optionalValue: Optional;
|
|
12
10
|
/** Parse an unknown value; invalid input throws a safe ValidationError. */
|
|
@@ -37,10 +35,15 @@ export interface ObjectSchema<F extends Fields> extends Schema<ObjectValue<F>> {
|
|
|
37
35
|
export declare const decoderOf: <T>(schema: Schema<T, boolean>) => EffectSchema.Decoder<T>;
|
|
38
36
|
/** Recognize schemas made by this author facade when adapting a definition. */
|
|
39
37
|
export declare const isSchema: (value: unknown) => value is Schema<unknown, boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Source that skipped type checking can pass any value where a schema belongs, such as `string`
|
|
40
|
+
* for `string()`. Name the argument and the mistake before a native constructor reads it.
|
|
41
|
+
*/
|
|
42
|
+
export declare const schemaArgument: <S extends Schema<unknown, boolean>>(value: S, role: string) => S;
|
|
40
43
|
/** Decode within an Effect program. Invalid input is omitted from the failure. */
|
|
41
44
|
export declare const parse: <T>(decoder: EffectSchema.Decoder<T>, input: unknown) => Effect.Effect<T, ValidationError>;
|
|
42
45
|
/** Present a native decoder through the synchronous author API. */
|
|
43
|
-
export declare function wrap<T, Optional extends boolean>(decoder: EffectSchema.Decoder<T>, optionalValue: Optional
|
|
46
|
+
export declare function wrap<T, Optional extends boolean>(decoder: EffectSchema.Decoder<T>, optionalValue: Optional): Schema<T, Optional>;
|
|
44
47
|
/** A string, optionally with a minimum length. No coercion. */
|
|
45
48
|
export declare function string(options?: {
|
|
46
49
|
readonly minLength?: number;
|
|
@@ -59,6 +62,44 @@ export declare function literal<const T extends string | number | boolean | null
|
|
|
59
62
|
export declare const array: <T>(item: Schema<T, boolean>) => Schema<readonly T[]>;
|
|
60
63
|
/** Parse declared fields and omit undeclared fields. */
|
|
61
64
|
export declare function object<const F extends Fields>(fields: F): ObjectSchema<F>;
|
|
65
|
+
declare const Exposure: unique symbol;
|
|
66
|
+
/** A schema marked with how app code sees the field in a provider that declares hosts. */
|
|
67
|
+
export type Exposed<S, E extends FieldExposure = FieldExposure> = S & {
|
|
68
|
+
readonly [Exposure]: E;
|
|
69
|
+
};
|
|
70
|
+
/** The marking of one account field, if any. */
|
|
71
|
+
export declare const exposureOf: (schema: Schema<unknown, boolean>) => FieldExposure | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* A field that is not secret, such as a subdomain or region. App code reads its real value and
|
|
74
|
+
* the connect form shows it.
|
|
75
|
+
*/
|
|
76
|
+
export declare const plain: <S extends Schema<unknown, boolean>>(schema: S) => Exposed<S, "plain">;
|
|
77
|
+
/**
|
|
78
|
+
* A secret field that app code reads as its real value, for request signing and similar uses.
|
|
79
|
+
* The connect form warns that the app can read it. Prefer an unmarked field, which app code
|
|
80
|
+
* receives as a handle that only reaches the provider's declared hosts.
|
|
81
|
+
*/
|
|
82
|
+
export declare const raw: <S extends Schema<unknown, boolean>>(schema: S) => Exposed<S, "raw">;
|
|
83
|
+
/** Marked fields of an account object, by name. */
|
|
84
|
+
export declare const fieldExposure: (fields: Fields) => Readonly<Record<string, FieldExposure>>;
|
|
85
|
+
declare const Secret: unique symbol;
|
|
86
|
+
/**
|
|
87
|
+
* A secret account value. In a provider that declares hosts it is a handle, which the host's
|
|
88
|
+
* outbound network replaces with the real value only on requests to those hosts. Pass it to
|
|
89
|
+
* clients and headers as an ordinary string; do not decode or transform it.
|
|
90
|
+
*/
|
|
91
|
+
export type SecretString = string & {
|
|
92
|
+
readonly [Secret]: true;
|
|
93
|
+
};
|
|
94
|
+
type Sealed<T> = T extends string ? SecretString : T;
|
|
95
|
+
/** Account fields as app code receives them: unmarked string fields are secret. */
|
|
96
|
+
export type SecretFields<F extends Fields> = {
|
|
97
|
+
readonly [Key in keyof ObjectValue<F>]: Key extends keyof F ? F[Key] extends Exposed<unknown> ? ObjectValue<F>[Key] : Sealed<ObjectValue<F>[Key]> : ObjectValue<F>[Key];
|
|
98
|
+
};
|
|
99
|
+
/** An account object without declared fields, such as a default OAuth projection. */
|
|
100
|
+
export type SecretObject<T> = {
|
|
101
|
+
readonly [Key in keyof T]: Sealed<T[Key]>;
|
|
102
|
+
};
|
|
62
103
|
declare const ImportedJsonSchema: unique symbol;
|
|
63
104
|
/** Read the original document for an imported decoder without a lossy schema round trip. */
|
|
64
105
|
export declare const importedJsonSchema: (decoder: EffectSchema.Decoder<unknown>) => unknown | undefined;
|
|
@@ -72,8 +113,45 @@ export declare const withLazyJsonSchemaDocument: <S extends EffectSchema.Decoder
|
|
|
72
113
|
* Relocate a self-contained JSON Schema under a document pointer. Resolve references
|
|
73
114
|
* before nesting so account schemas can reuse definition names, IDs and anchors.
|
|
74
115
|
* Only schema nodes are rewritten; examples and ordinary property values stay intact.
|
|
116
|
+
* A `$recursiveRef` becomes the pointer to its static target, such as the relocated root. The
|
|
117
|
+
* patched validator applies it like `"#"` was: the recursive anchor in scope, else that target.
|
|
75
118
|
*/
|
|
76
119
|
export declare const nestJsonSchema: (input: JsonObject, pointer: string) => JsonObject;
|
|
120
|
+
/**
|
|
121
|
+
* Whether an input key may be named in a validation problem. Other keys can carry supplied data,
|
|
122
|
+
* so problems locate them without echoing them.
|
|
123
|
+
*/
|
|
124
|
+
export declare const echoableKey: (key: string) => boolean;
|
|
125
|
+
/**
|
|
126
|
+
* The keys an object accepts, as `object {name, optional?}`. `...` marks an object that also
|
|
127
|
+
* accepts other keys. Names come from the schema, never from supplied input.
|
|
128
|
+
*/
|
|
129
|
+
export declare const objectShape: (keys: readonly {
|
|
130
|
+
readonly name: string;
|
|
131
|
+
readonly optional: boolean;
|
|
132
|
+
}[], open: boolean, limit?: number) => string;
|
|
133
|
+
/**
|
|
134
|
+
* The values a schema fixes, as `"v1"` or `one of "a", "b" and 3 more`. Agents already read
|
|
135
|
+
* these values in the tool's signature, so problems list them, up to {@link maxListedValues}
|
|
136
|
+
* values and {@link maxValuesText} characters. They come from the schema, never from input.
|
|
137
|
+
*/
|
|
138
|
+
export declare const allowedValues: (values: readonly unknown[]) => string;
|
|
139
|
+
/** Keys listed for each union alternative, so several alternatives fit in one problem. */
|
|
140
|
+
export declare const maxAlternativeKeys = 8;
|
|
141
|
+
/**
|
|
142
|
+
* The alternatives a union accepts, as `string or object {id}`, and the key whose value tells
|
|
143
|
+
* them apart. Shapes, values and the key come from the schema, never from supplied input.
|
|
144
|
+
*/
|
|
145
|
+
export declare const unionShape: (alternatives: readonly string[], selector: string | undefined) => string;
|
|
146
|
+
/** The problem for a required key the input omits, with what its schema expects when stated. */
|
|
147
|
+
export declare const missingKey: (expected: string | undefined) => string;
|
|
148
|
+
/** The text every missing-key problem starts with, so the caller can add where the input has it. */
|
|
149
|
+
export declare const missingKeyText = "Missing key";
|
|
150
|
+
/**
|
|
151
|
+
* Whether the imported schema whose check failed may accept a key as an object's own key, for a
|
|
152
|
+
* failure's check; undefined when the check is not an imported schema's.
|
|
153
|
+
*/
|
|
154
|
+
export declare const importedSchemaKeys: (check: object) => ((key: string) => boolean) | undefined;
|
|
77
155
|
/** Prepare an interpreted validator. No eval or generated JavaScript runs in any host. */
|
|
78
156
|
export declare const compileJsonSchemaDecoder: (document: JsonObject) => Effect.Effect<EffectSchema.Codec<EffectSchema.Json, EffectSchema.Json, never, never> & {
|
|
79
157
|
[ImportedJsonSchema]: {
|
|
@@ -81,14 +159,20 @@ export declare const compileJsonSchemaDecoder: (document: JsonObject) => Effect.
|
|
|
81
159
|
};
|
|
82
160
|
}, ValidationError, never>;
|
|
83
161
|
export declare const lazyJsonSchemaDecoder: (document: () => JsonObject) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, never, never>;
|
|
162
|
+
/**
|
|
163
|
+
* A lazy decoder and the compilation it decodes with. Running `compile` first lets a caller
|
|
164
|
+
* reject an unsupported schema before a side effect whose result the decoder will check.
|
|
165
|
+
*/
|
|
166
|
+
export declare const preparedJsonSchemaDecoder: (document: JsonObject) => {
|
|
167
|
+
decoder: EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>;
|
|
168
|
+
compile: Effect.Effect<EffectSchema.Decoder<EffectSchema.Json, never>, ValidationError, never>;
|
|
169
|
+
};
|
|
84
170
|
/** Preserve the JSON document; compile its validator only when a value is first decoded. */
|
|
85
171
|
export declare const jsonSchemaDecoder: (input: unknown) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, ValidationError, never>;
|
|
86
172
|
/** Import JSON metadata now; unsupported schemas and invalid values fail when parsed. */
|
|
87
173
|
export declare const jsonSchema: (input: unknown) => Schema<EffectSchema.Json>;
|
|
88
|
-
/**
|
|
89
|
-
export declare const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/** A host user identifier, stored as a string without imposing a product auth model. */
|
|
93
|
-
export declare const userId: () => Schema<string>;
|
|
174
|
+
/** Render a decoder as a JSON Schema document, keeping an imported upstream document as-is. */
|
|
175
|
+
export declare const jsonSchemaDocument: (decoder: EffectSchema.Decoder<unknown>) => Effect.Effect<{
|
|
176
|
+
readonly [x: string]: EffectSchema.Json;
|
|
177
|
+
}, EffectSchema.SchemaError, never>;
|
|
94
178
|
export {};
|