apps 0.0.1-beta.4 → 0.0.1-beta.41
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-QKHR7BMF.js → chunk-3MMG2H6M.js} +89 -53
- package/js/{chunk-EQB7JMAL.js → chunk-6XGB4BAL.js} +146 -31
- package/js/chunk-ADD6H64X.js +729 -0
- package/js/{chunk-6VRYO2BG.js → chunk-AHGGO2VY.js} +837 -254
- package/js/{chunk-FDNTX5QJ.js → chunk-CQD3WSYH.js} +2 -2
- package/js/{chunk-EVJUVWN2.js → chunk-DKUEYTYD.js} +463 -218
- package/js/chunk-EM4UL26F.js +118 -0
- package/js/{chunk-2VPJHFOU.js → chunk-FXWRE655.js} +128 -24
- package/js/{chunk-5MQZEB6Y.js → chunk-JI3EP2GL.js} +40 -12
- package/js/chunk-JJSLEJ6T.js +156 -0
- package/js/chunk-KAQD3DTI.js +16 -0
- package/js/chunk-KIM5HXNK.js +49 -0
- package/js/chunk-MJZYV7IO.js +255 -0
- package/js/{chunk-FW5HBOIK.js → chunk-MXDKXAY4.js} +19117 -18309
- package/js/{chunk-T2LAZCAD.js → chunk-NKWWPJYX.js} +3 -3
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-3M2MEDNL.js → chunk-OTCLXFLL.js} +1337 -188
- package/js/chunk-P7MGDPFD.js +240 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-PNVCCB4L.js} +432 -79
- package/js/{chunk-D47C7KG5.js → chunk-RIXVGVA6.js} +2 -2
- package/js/{chunk-NQ3OMCA5.js → chunk-TT6OU4UG.js} +2 -2
- package/js/{chunk-YEJOQEII.js → chunk-UOZMSUJ2.js} +61 -9
- package/js/chunk-UTJIGUSS.js +42 -0
- package/js/{chunk-G7ZIRKMK.js → chunk-VIU2XXA7.js} +228 -264
- package/js/{chunk-HDJH3RPR.js → chunk-VJQXXOQ3.js} +4 -4
- package/js/{chunk-WFSQXYUT.js → chunk-WPBR4AWB.js} +523 -63
- package/js/{chunk-SATWJKN6.js → chunk-YQ35E7KS.js} +2 -2
- package/js/chunk-ZUKBIHMK.js +92 -0
- package/js/client.js +122 -88
- package/js/contracts.js +116 -25
- package/js/effect.js +19 -20
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +57 -55
- package/js/host.js +19 -20
- package/js/index.js +245 -212
- package/js/mcp/effect.js +23 -22
- package/js/mcp/stdio.js +34 -30
- package/js/mcp.js +104 -68
- package/js/openapi.js +4087 -1503
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +147 -65
- 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-data/src/contracts/database.d.ts +33 -6
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +7 -8
- package/types/apps/src/contracts/cache.d.ts +14 -0
- package/types/apps/src/contracts/context.d.ts +12 -11
- package/types/apps/src/contracts/elicitation.d.ts +6 -6
- package/types/apps/src/contracts/failure.d.ts +54 -0
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +44 -17
- 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 +263 -74
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/2.d.ts +66 -24
- package/types/apps/src/contracts/protocols/3.d.ts +715 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1297 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1130 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1106 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +89 -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 +39 -9
- 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 +40 -3
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +32 -5
- package/types/apps/src/implementation/elicitation.d.ts +12 -12
- package/types/apps/src/implementation/failure-detail.d.ts +47 -0
- 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/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 +36 -3
- 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 +68 -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 +66 -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 +11 -3
- package/types/apps/src/index.d.ts +30 -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 +6 -3
- package/types/telemetry/src/browser.d.ts +2 -2
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/layer.d.ts +2 -2
- package/types/telemetry/src/recorded-failure.d.ts +20 -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 +53 -0
- package/types/utils/src/recorded-message.d.ts +15 -0
- package/js/chunk-BMOIAIVR.js +0 -138
- package/js/chunk-DHUDODG5.js +0 -213
- package/js/chunk-FZJOYIZO.js +0 -19
- package/js/chunk-LGIYBDWA.js +0 -85
- package/js/chunk-M6ZRRIBI.js +0 -877
- package/js/chunk-PLCMJREA.js +0 -590
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-W7D7WVSY.js +0 -18
- package/js/chunk-Z5NMEGJN.js +0 -29
- package/js/chunk-ZJWDMTE3.js +0 -63
- 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 -33
- 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 -13
|
@@ -1,41 +1,68 @@
|
|
|
1
1
|
import { ProviderError } from "../contracts/provider-error.js";
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
|
-
import { McpError, McpToolsOptions } from "../contracts/mcp.js";
|
|
3
|
+
import { McpCredentialsUnverified, McpError, McpToolsOptions, type McpHealthCheck, type McpHealthOptions } from "../contracts/mcp.js";
|
|
4
|
+
import { NetworkRefused } from "../contracts/network.js";
|
|
4
5
|
/** Discover and call with a fresh selected-account transport for each operation. */
|
|
5
6
|
export declare const mcpClientEffect: (input: McpToolsOptions, changed?: Effect.Effect<void, unknown>) => Effect.Effect<{
|
|
6
7
|
list: Effect.Effect<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
readonly
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readonly
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
tools: {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly inputSchema: {
|
|
11
|
+
readonly [x: string]: Schema.Json;
|
|
12
|
+
};
|
|
13
|
+
readonly description?: string | undefined;
|
|
14
|
+
readonly _meta?: {
|
|
15
|
+
readonly [x: string]: Schema.Json;
|
|
16
|
+
} | undefined;
|
|
17
|
+
readonly title?: string | undefined;
|
|
18
|
+
readonly annotations?: {
|
|
19
|
+
readonly title?: string;
|
|
20
|
+
readonly readOnlyHint?: boolean;
|
|
21
|
+
readonly destructiveHint?: boolean;
|
|
22
|
+
readonly idempotentHint?: boolean;
|
|
23
|
+
readonly openWorldHint?: boolean;
|
|
24
|
+
} | undefined;
|
|
25
|
+
readonly outputSchema?: {
|
|
26
|
+
readonly [x: string]: Schema.Json;
|
|
27
|
+
} | undefined;
|
|
28
|
+
}[];
|
|
29
|
+
server: {
|
|
30
|
+
readonly description?: string;
|
|
31
|
+
readonly version?: string;
|
|
32
|
+
readonly name?: string;
|
|
33
|
+
readonly instructions?: string;
|
|
20
34
|
readonly title?: string;
|
|
21
|
-
readonly
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
readonly icons?: readonly {
|
|
36
|
+
readonly src: string;
|
|
37
|
+
readonly mimeType?: string;
|
|
38
|
+
readonly sizes?: readonly string[];
|
|
39
|
+
readonly theme?: "light" | "dark";
|
|
40
|
+
}[];
|
|
41
|
+
readonly websiteUrl?: string;
|
|
42
|
+
} | {};
|
|
43
|
+
}, ProviderError | NetworkRefused | McpError, never>;
|
|
44
|
+
check: Effect.Effect<void, ProviderError | NetworkRefused | McpError, never>;
|
|
27
45
|
call: (name: string, input: import("../index.js").JsonObject, context: import("../mcp.js").McpToolContext) => Effect.Effect<{
|
|
28
46
|
readonly content: readonly {
|
|
29
47
|
readonly [x: string]: Schema.Json;
|
|
30
48
|
}[];
|
|
31
49
|
readonly _meta?: {
|
|
32
50
|
readonly [x: string]: Schema.Json;
|
|
33
|
-
}
|
|
51
|
+
};
|
|
34
52
|
readonly structuredContent?: {
|
|
35
53
|
readonly [x: string]: Schema.Json;
|
|
36
|
-
}
|
|
37
|
-
readonly isError?: boolean
|
|
38
|
-
}, ProviderError | import("../index.js").ElicitationFailed | McpError, never>;
|
|
54
|
+
};
|
|
55
|
+
readonly isError?: boolean;
|
|
56
|
+
}, ProviderError | NetworkRefused | import("../index.js").ElicitationFailed | McpError, never>;
|
|
39
57
|
}, McpError, never>;
|
|
58
|
+
/**
|
|
59
|
+
* Check one account: initialize and read the first page of tools with the account's headers, then
|
|
60
|
+
* repeat that with no headers on a fresh transport. A refused account fails with its
|
|
61
|
+
* `ProviderError`, and anything else that stops the first check is an `McpError`; the second never
|
|
62
|
+
* runs. The check passes only when the server refuses the second, which shows it checked the
|
|
63
|
+
* credentials. Otherwise it fails with `McpCredentialsUnverified`. Both share one budget, which
|
|
64
|
+
* ends early enough before the check context's deadline to close the session and report why.
|
|
65
|
+
*/
|
|
66
|
+
export declare const mcpHealthEffect: (check: McpHealthCheck, options: McpHealthOptions) => Effect.Effect<void, ProviderError | NetworkRefused | McpError | McpCredentialsUnverified, never>;
|
|
40
67
|
/** Discover and compile all tools for connection probes and low-level consumers. */
|
|
41
|
-
export declare const mcpToolsEffect: (input: McpToolsOptions) => Effect.Effect<Readonly<Record<string, import("../contracts/mcp.js").McpTool>>, ProviderError | McpError, never>;
|
|
68
|
+
export declare const mcpToolsEffect: (input: McpToolsOptions) => Effect.Effect<Readonly<Record<string, import("../contracts/mcp.js").McpTool>>, ProviderError | NetworkRefused | McpError, never>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Typed refusals and option checks for the fetch app code receives from the framework. */
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import type { HttpClientResponse } from "effect/http";
|
|
4
|
+
import { type NetworkRefused } from "../contracts/network.js";
|
|
5
|
+
type Fetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
6
|
+
/** Fail with the refusal a protocol helper's response carries, or continue to its own handling. */
|
|
7
|
+
export declare const failOnNetworkRefusal: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<void, NetworkRefused>;
|
|
8
|
+
/**
|
|
9
|
+
* The fetch app code receives as `ctx.fetch`. It rejects a RequestInit value the app runtime
|
|
10
|
+
* would reject, naming the option, on every host. A request Executor's app network refused
|
|
11
|
+
* rejects with `NetworkRefused`: the service never answered, so there is no response to return.
|
|
12
|
+
*/
|
|
13
|
+
export declare const appFetch: (fetch: Fetch) => Fetch;
|
|
14
|
+
/** The invocation's correlated, cancellable fetch, as app code receives it. */
|
|
15
|
+
export declare const appInvocationFetch: (signal: AbortSignal) => Effect.Effect<Fetch, never, never>;
|
|
16
|
+
export {};
|
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
/** Compile an OpenAPI document into tool declarations inside the app runtime, never a second execution engine. */
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
3
|
import { JsonObject } from "../contracts/schema.js";
|
|
4
|
+
import { OpenapiErrorResponse } from "../contracts/openapi.js";
|
|
4
5
|
import { OpenapiCompileError as TemplateError } from "../contracts/openapi-compile.js";
|
|
5
6
|
import type { OpenApiImport } from "../contracts/openapi-document.js";
|
|
6
7
|
import { type GeneratedOperation, type GeneratedSecrets } from "../contracts/openapi-document.js";
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
import { type OpenApiDocument } from "./openapi-document.js";
|
|
9
|
+
/** Keep tagged errors, including response/component refs and anyOf alternatives.
|
|
10
|
+
* Public text comes from a declared string message or the schema's static description.
|
|
11
|
+
* `scripts/check-api-errors.ts` applies this to Executor's own API documents.
|
|
12
|
+
*/
|
|
13
|
+
export declare function errorResponses(document: OpenApiDocument, operation: JsonObject, at: string): OpenapiErrorResponse[];
|
|
14
|
+
/** Compile a revision of a live OpenAPI source into tool declarations for the app runtime.
|
|
15
|
+
* The document is consumed: compilation upgrades it in place instead of copying it. It must be a
|
|
16
|
+
* tree, with no object reached twice, as parsed JSON is.
|
|
17
|
+
*/
|
|
18
|
+
export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocument: JsonObject, options?: {
|
|
9
19
|
readonly baseUrl?: string;
|
|
10
20
|
readonly allowedOrigin?: string;
|
|
21
|
+
/** Inserted between every operation's server and path; see `prefixParameters`. */
|
|
22
|
+
readonly pathPrefix?: string;
|
|
11
23
|
readonly securitySchemes?: Readonly<Record<string, JsonObject>>;
|
|
12
24
|
readonly fallbackSecurity?: GeneratedOperation["request"]["security"];
|
|
13
25
|
}) => Effect.Effect<{
|
|
14
26
|
operations: {
|
|
15
|
-
readonly name: string;
|
|
16
|
-
readonly path: string;
|
|
17
27
|
readonly description: string;
|
|
18
28
|
readonly request: {
|
|
19
29
|
readonly parameters: readonly {
|
|
20
30
|
readonly name: string;
|
|
21
|
-
readonly in: "query" | "
|
|
31
|
+
readonly in: "path" | "query" | "querystring" | "header" | "cookie";
|
|
22
32
|
readonly required?: boolean;
|
|
23
33
|
readonly schema?: {
|
|
24
34
|
readonly [x: string]: Schema.Json;
|
|
@@ -53,10 +63,12 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
|
|
|
53
63
|
readonly required?: boolean;
|
|
54
64
|
};
|
|
55
65
|
};
|
|
66
|
+
readonly path: string;
|
|
67
|
+
readonly name: string;
|
|
56
68
|
readonly input: {
|
|
57
69
|
readonly [x: string]: Schema.Json;
|
|
58
70
|
};
|
|
59
|
-
readonly method: "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
|
|
71
|
+
readonly method: "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "QUERY";
|
|
60
72
|
readonly securitySchemes: {
|
|
61
73
|
readonly [x: string]: {
|
|
62
74
|
readonly [x: string]: Schema.Json;
|
|
@@ -67,6 +79,7 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
|
|
|
67
79
|
readonly outputSchema?: {
|
|
68
80
|
readonly [x: string]: Schema.Json;
|
|
69
81
|
};
|
|
82
|
+
readonly tags?: readonly string[];
|
|
70
83
|
readonly operationId?: string;
|
|
71
84
|
readonly streaming?: true;
|
|
72
85
|
readonly errorResponses?: readonly {
|
|
@@ -83,6 +96,14 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
|
|
|
83
96
|
};
|
|
84
97
|
}[];
|
|
85
98
|
}[];
|
|
99
|
+
/** Declared operations left out of `operations`, in definition order. */
|
|
100
|
+
skipped: {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
readonly method: string;
|
|
103
|
+
readonly path: string;
|
|
104
|
+
readonly code: "server_protocol" | "server_url" | "external_reference" | "circular_reference" | "schema_keyword" | "schema_reference" | "missing_component" | "openapi_version" | "auth_helper" | "auth_missing" | "operation_path" | "operation_method" | "duplicate_operation" | "server_missing" | "multiple_hosts" | "parameter_encoding" | "parameter_style" | "request_body" | "combined_oauth" | "auth_method" | "event_stream" | "input_schema" | "no_operations" | "no_supported_operations" | "invalid_document" | "source_generation" | "authoring_reference";
|
|
105
|
+
readonly reason: string;
|
|
106
|
+
}[];
|
|
86
107
|
definitions: {
|
|
87
108
|
[k: string]: {
|
|
88
109
|
readonly [x: string]: Schema.Json;
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { JsonObject } from "../contracts/schema.js";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
/**
|
|
4
|
+
* An object in a document that was validated as JSON when it was read. Compilation only turns JSON
|
|
5
|
+
* into JSON, so inside it an object's shape is checked, not its every leaf again: re-validating
|
|
6
|
+
* whole documents was most of a large API's compile time.
|
|
7
7
|
*/
|
|
8
|
-
export declare
|
|
8
|
+
export declare const DocumentObject: Schema.declare<{
|
|
9
|
+
readonly [x: string]: Schema.Json;
|
|
10
|
+
}, {
|
|
11
|
+
readonly [x: string]: Schema.Json;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const documentObject: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => {
|
|
14
|
+
readonly [x: string]: Schema.Json;
|
|
15
|
+
};
|
|
16
|
+
/** One JSON Pointer reference token. */
|
|
17
|
+
export declare const pointerToken: (key: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Decode one part of the definition, located by the JSON Pointer `at`. A mismatch names the
|
|
20
|
+
* pointer of the first failing value and what was expected there.
|
|
21
|
+
*/
|
|
22
|
+
export declare const decodeDefinition: <S extends Schema.Decoder<unknown>>(schema: S, value: unknown, at: string, what: string) => S["Type"];
|
|
23
|
+
/** Resolve OpenAPI objects once; schemas retain their original recursive references.
|
|
24
|
+
* Scalar first upgrades Swagger 2.0 and OpenAPI 3.0 to 3.1, so the importer reads 3.1 and 3.2,
|
|
25
|
+
* whose Schema Objects share one dialect, and 3.1 keywords that appear in 3.0 documents keep
|
|
26
|
+
* their meaning. Unsupported versions, references and conversions throw TemplateError at the
|
|
27
|
+
* import boundary.
|
|
28
|
+
*/
|
|
29
|
+
export declare function openApiDocument(input: JsonObject): Promise<{
|
|
9
30
|
spec: {
|
|
10
31
|
readonly openapi: string;
|
|
11
32
|
readonly paths: {
|
|
@@ -13,39 +34,45 @@ export declare function openApiDocument(input: unknown): Promise<{
|
|
|
13
34
|
readonly [x: string]: Schema.Json;
|
|
14
35
|
};
|
|
15
36
|
};
|
|
16
|
-
readonly security?: readonly {
|
|
17
|
-
readonly [x: string]: readonly string[];
|
|
18
|
-
}[];
|
|
19
|
-
readonly servers?: readonly {
|
|
20
|
-
readonly url: string;
|
|
21
|
-
readonly variables?: {
|
|
22
|
-
readonly [x: string]: Schema.Json;
|
|
23
|
-
};
|
|
24
|
-
}[];
|
|
25
37
|
readonly components?: {
|
|
26
|
-
readonly
|
|
38
|
+
readonly schemas?: {
|
|
27
39
|
readonly [x: string]: {
|
|
28
40
|
readonly [x: string]: Schema.Json;
|
|
29
41
|
};
|
|
30
42
|
};
|
|
31
|
-
readonly
|
|
43
|
+
readonly securitySchemes?: {
|
|
32
44
|
readonly [x: string]: {
|
|
33
45
|
readonly [x: string]: Schema.Json;
|
|
34
46
|
};
|
|
35
47
|
};
|
|
36
48
|
};
|
|
49
|
+
readonly security?: readonly {
|
|
50
|
+
readonly [x: string]: readonly string[];
|
|
51
|
+
}[];
|
|
52
|
+
readonly servers?: readonly {
|
|
53
|
+
readonly url: string;
|
|
54
|
+
readonly variables?: {
|
|
55
|
+
readonly [x: string]: Schema.Json;
|
|
56
|
+
};
|
|
57
|
+
}[];
|
|
37
58
|
};
|
|
38
59
|
definitions: Map<string, {
|
|
39
60
|
readonly [x: string]: Schema.Json;
|
|
40
61
|
}>;
|
|
62
|
+
/**
|
|
63
|
+
* The JSON Pointer of the object a local reference resolved to, so a diagnostic can locate
|
|
64
|
+
* a resolved Response, Parameter, Request Body or Path Item where the definition declares it.
|
|
65
|
+
*/
|
|
66
|
+
origin(value: unknown): string | undefined;
|
|
41
67
|
/** Inspect a component schema without expanding its children. OpenAPI object refs must already be resolved by Swagger. */
|
|
42
68
|
resolve(value: JsonObject): JsonObject;
|
|
43
69
|
/** Compose a Draft 2020-12 schema around API Schema Objects. Only values passed to
|
|
44
70
|
* `api` use the document's OpenAPI dialect; Executor-authored wrappers are already
|
|
45
|
-
* Draft 2020-12 and must not be reinterpreted.
|
|
46
|
-
*
|
|
71
|
+
* Draft 2020-12 and must not be reinterpreted. `api` takes the schema's JSON Pointer in the
|
|
72
|
+
* definition, which failures name. Reached components are converted once into the shared
|
|
73
|
+
* `definitions` and stay references here; nothing is inlined or copied per operation.
|
|
47
74
|
*/
|
|
48
|
-
schema(build: (api: (input: Schema.Json) => JsonObject) => JsonObject): JsonObject;
|
|
75
|
+
schema(build: (api: (input: Schema.Json, at: string) => JsonObject) => JsonObject): JsonObject;
|
|
49
76
|
}>;
|
|
50
77
|
/** A parsed document with one reference scope and one schema dialect. */
|
|
51
78
|
export type OpenApiDocument = Awaited<ReturnType<typeof openApiDocument>>;
|
|
@@ -11,8 +11,13 @@ export interface OperationNameInput {
|
|
|
11
11
|
readonly path: string;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* the path's version segment, then by the
|
|
16
|
-
*
|
|
14
|
+
* Name every input, in input order. Names that collide, whether or not they come from an
|
|
15
|
+
* operationId, are refined together: first by the path's version segment, then by the path
|
|
16
|
+
* segments that tell them apart (`GET /items` and `GET /items/{id}` are `items.getItems` and
|
|
17
|
+
* `items.getItemsById`), then by the whole path, then by the HTTP method, then by a stable hash.
|
|
18
|
+
* Refinement only touches the colliding names, so adding an operation never renames an unrelated
|
|
19
|
+
* one.
|
|
17
20
|
*/
|
|
18
|
-
export declare const planOperationNames: (inputs: readonly
|
|
21
|
+
export declare const planOperationNames: <I extends OperationNameInput>(inputs: readonly I[]) => (I & {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
})[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NetworkRefused } from "../contracts/network.js";
|
|
1
2
|
import { ProviderError } from "../contracts/provider-error.js";
|
|
2
3
|
/** Swagger constructs requests; Effect owns HTTP policy and bounded results. */
|
|
3
4
|
import { Effect, Schema } from "effect";
|
|
@@ -6,12 +7,19 @@ import { OpenapiError, type CredentialBinding, type OpenapiOperation, type Opena
|
|
|
6
7
|
type DeclaredError = OpenapiErrorResponse & {
|
|
7
8
|
readonly decoder: Schema.Decoder<Schema.Json>;
|
|
8
9
|
};
|
|
10
|
+
/** What decides whether an account can call an operation: its transport and security. */
|
|
11
|
+
export interface OpenapiOperationAccess {
|
|
12
|
+
readonly streaming?: true;
|
|
13
|
+
readonly request: {
|
|
14
|
+
readonly security: OpenapiOperation["request"]["security"];
|
|
15
|
+
};
|
|
16
|
+
}
|
|
9
17
|
/** Create request helpers from credential-free generated authentication metadata. */
|
|
10
18
|
export declare function createRequest(config: {
|
|
11
19
|
readonly methods: Readonly<Record<string, readonly CredentialBinding[]>>;
|
|
12
20
|
readonly oauth: readonly string[];
|
|
13
21
|
}): {
|
|
14
|
-
available: (op:
|
|
15
|
-
call: (op: OpenapiOperation, input: unknown, account: OpenapiAccount | undefined, errors: readonly DeclaredError[]) => Effect.Effect<Schema.Json, ProviderError | OpenapiResponseError | OpenapiError, never>;
|
|
22
|
+
available: (op: OpenapiOperationAccess, account: OpenapiAccount | undefined) => boolean;
|
|
23
|
+
call: (op: OpenapiOperation, input: unknown, account: OpenapiAccount | undefined, errors: readonly DeclaredError[]) => Effect.Effect<Schema.Json, ProviderError | NetworkRefused | OpenapiResponseError | OpenapiError, never>;
|
|
16
24
|
};
|
|
17
25
|
export {};
|
|
@@ -3,8 +3,8 @@ import { Duration } from "effect";
|
|
|
3
3
|
import type { AppCache } from "../contracts/cache.js";
|
|
4
4
|
import { OpenapiOperation, type OpenapiToolsOptions } from "../contracts/openapi.js";
|
|
5
5
|
import { JsonObject, JsonValue } from "../contracts/schema.js";
|
|
6
|
-
import type { DynamicTools } from "../contracts/dynamic-tools.js";
|
|
7
6
|
import { type OperationKinds } from "./protocol-operations.js";
|
|
7
|
+
import { type RouterDeclaration } from "./router.js";
|
|
8
8
|
/** Static credential placement and destination are reviewed when the app is authored/imported. */
|
|
9
9
|
export interface OpenapiSourceOptions extends Omit<OpenapiToolsOptions, "operations" | "definitions"> {
|
|
10
10
|
readonly cache: AppCache;
|
|
@@ -16,6 +16,12 @@ export interface OpenapiSourceOptions extends Omit<OpenapiToolsOptions, "operati
|
|
|
16
16
|
readonly allowedOrigin: string;
|
|
17
17
|
readonly securitySchemes: Readonly<Record<string, JsonObject>>;
|
|
18
18
|
readonly baseUrl?: string;
|
|
19
|
+
/**
|
|
20
|
+
* A path inserted between the server and every operation's path, for a definition that omits a
|
|
21
|
+
* leading segment, such as `/projects/{project}`. Each `{name}` becomes a required string path
|
|
22
|
+
* parameter of every tool, unless the operation already declares it without placing it.
|
|
23
|
+
*/
|
|
24
|
+
readonly pathPrefix?: string;
|
|
19
25
|
readonly freshFor?: Duration.Input;
|
|
20
26
|
readonly staleFor?: Duration.Input;
|
|
21
27
|
/**
|
|
@@ -33,8 +39,4 @@ export interface OpenapiSourceOptions extends Omit<OpenapiToolsOptions, "operati
|
|
|
33
39
|
/** JSON-object patches are static app configuration and are reapplied to every revision. */
|
|
34
40
|
export declare function patchOpenapi(root: JsonObject, patches: OpenapiSourceOptions["patches"]): JsonObject;
|
|
35
41
|
/** No I/O during app construction. All accounts share credential-free compilation. */
|
|
36
|
-
export declare const
|
|
37
|
-
readonly queries: {};
|
|
38
|
-
readonly mutations: {};
|
|
39
|
-
readonly dynamicTools: DynamicTools;
|
|
40
|
-
};
|
|
42
|
+
export declare const liveOpenapiRouter: (options: OpenapiSourceOptions) => RouterDeclaration;
|
|
@@ -7,16 +7,39 @@ 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
|
+
/** Private key for a router's native definition. */
|
|
42
|
+
export declare const NativeRouterKey: unique symbol;
|
|
20
43
|
/** Typed operation handles drive browser reference inference without bundling handlers. */
|
|
21
44
|
export interface Operation<Input, Output, Kind extends "query" | "mutation", Context = AppContext> extends OperationDeclaration<Kind, Context> {
|
|
22
45
|
readonly [NativeOperation]: AppOperation<Input, Output> & {
|
|
@@ -56,8 +79,18 @@ export declare const operationOptions: <Input, Output>(options: OperationOptions
|
|
|
56
79
|
title?: string;
|
|
57
80
|
description?: string;
|
|
58
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Replace a native operation's approval. Property descriptors are copied so an output schema that
|
|
84
|
+
* a protocol adapter builds only when read stays lazy.
|
|
85
|
+
*/
|
|
86
|
+
export declare const approvedOperation: <Input, Native extends AppOperation<Input, unknown>>(operation: Native, approval: Approval<Input>) => Native;
|
|
59
87
|
/** Attach the same approval function to a generated or shared operation. */
|
|
60
88
|
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>;
|
|
89
|
+
/**
|
|
90
|
+
* The advisory hints an operation carries, such as an MCP server's `destructiveHint`. App code
|
|
91
|
+
* reads them to choose an approval; the framework never infers one from them.
|
|
92
|
+
*/
|
|
93
|
+
export declare const toolAnnotations: (operation: OperationDeclaration<"query" | "mutation", never>) => ToolAnnotations | undefined;
|
|
61
94
|
/** Read operation. External reads are allowed; only database writes are mechanically prohibited. */
|
|
62
95
|
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
96
|
/** 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;
|