apps 0.0.1-beta.1 → 0.0.1-beta.11
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 +65 -43
- package/framework-reference.json +1 -1
- package/js/browser-XIPJGLH2.js +65 -0
- package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
- package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
- package/js/{chunk-2HHMABB6.js → chunk-5T57N25Q.js} +61 -13
- package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
- package/js/{chunk-X7SFGU4Q.js → chunk-EFAPIRVB.js} +28 -9
- package/js/chunk-GPFVWWDZ.js +209 -0
- package/js/{chunk-OHRT55C4.js → chunk-IJX4CYZO.js} +3 -6
- package/js/{chunk-ZTFQHGEB.js → chunk-IPI4MFSN.js} +3 -5
- package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
- package/js/{chunk-IHQ4ML7K.js → chunk-KRSCJDTW.js} +586 -111
- package/js/chunk-KUMBKVJD.js +39 -0
- package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
- package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
- package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
- package/js/chunk-NKLWZJLE.js +172 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-ODEIDRGW.js} +3 -4
- package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
- package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
- package/js/chunk-R3EV5FTO.js +97 -0
- package/js/{chunk-KOXMLKTM.js → chunk-RELFXUOO.js} +308 -316
- package/js/{chunk-6YBRWRK3.js → chunk-RFVIONFX.js} +43 -14
- package/js/{chunk-RBAC33PQ.js → chunk-TYVDBQSI.js} +58 -83
- package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
- package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
- package/js/{chunk-4LPG6RCH.js → chunk-VFZKSM3T.js} +5 -25
- package/js/{chunk-6IIO4NPI.js → chunk-WVVV4TX2.js} +21 -9
- package/js/{chunk-G7IE6BKC.js → chunk-YBRC463S.js} +8 -8
- package/js/chunk-Z2QY3YTF.js +507 -0
- package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
- package/js/client.js +10 -26
- package/js/contracts.js +70 -15
- package/js/effect.js +19 -19
- package/js/es-APDZKREY.js +40968 -0
- package/js/graphql.js +34 -39
- package/js/host.js +23 -23
- package/js/index.js +199 -195
- package/js/mcp/effect.js +21 -21
- package/js/mcp/stdio.js +25 -25
- package/js/mcp.js +60 -44
- package/js/openapi.js +826 -41682
- package/js/react.js +3 -3
- package/js/skills/effect.js +3 -4
- package/js/skills.js +53 -17
- package/js/storage/facet.js +4 -4
- package/js/ui/auth/contracts.js +8 -9
- package/js/ui/auth.js +16 -14
- package/js/ui/contracts.js +4 -4
- package/js/ui/serving.js +9 -8
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +42 -2
- package/types/app-cache/src/index.d.ts +59 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/app-data/src/implementation/schema.d.ts +2 -17
- package/types/apps/src/contracts/app.d.ts +7 -6
- package/types/apps/src/contracts/cache.d.ts +4 -1
- package/types/apps/src/contracts/failure.d.ts +25 -0
- package/types/apps/src/contracts/host.d.ts +34 -679
- package/types/apps/src/contracts/mcp.d.ts +16 -0
- package/types/apps/src/contracts/openapi.d.ts +11 -1
- package/types/apps/src/contracts/operations.d.ts +0 -5
- package/types/apps/src/contracts/protocol-version.d.ts +6 -0
- package/types/apps/src/contracts/protocols/1.d.ts +1589 -0
- package/types/apps/src/contracts/protocols/2.d.ts +668 -0
- package/types/apps/src/contracts/protocols/3.d.ts +676 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1090 -0
- package/types/apps/src/contracts/provider.d.ts +56 -5
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +17 -8
- package/types/apps/src/contracts/storage.d.ts +3 -3
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/contracts/workflows.d.ts +34 -3
- 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/cache.d.ts +3 -1
- package/types/apps/src/implementation/catalog-cache.d.ts +9 -2
- package/types/apps/src/implementation/elicitation.d.ts +1 -1
- package/types/apps/src/implementation/failure-detail.d.ts +25 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +1 -4
- package/types/apps/src/implementation/mcp-catalog.d.ts +1 -4
- package/types/apps/src/implementation/mcp-client.d.ts +35 -19
- package/types/apps/src/implementation/mcp.d.ts +35 -19
- package/types/apps/src/implementation/openapi-compile.d.ts +3 -2
- package/types/apps/src/implementation/openapi-document.d.ts +0 -2
- package/types/apps/src/implementation/openapi-names.d.ts +18 -0
- package/types/apps/src/implementation/openapi-request.d.ts +0 -1
- package/types/apps/src/implementation/openapi-source.d.ts +7 -7
- package/types/apps/src/implementation/operations.d.ts +26 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
- package/types/apps/src/implementation/provider.d.ts +9 -4
- package/types/apps/src/implementation/router-catalog.d.ts +225 -0
- package/types/apps/src/implementation/router.d.ts +59 -0
- package/types/apps/src/implementation/schema.d.ts +5 -6
- package/types/apps/src/implementation/storage.d.ts +5 -3
- package/types/apps/src/implementation/swagger-client.d.ts +28 -0
- package/types/apps/src/implementation/ui-auth.d.ts +11 -5
- package/types/apps/src/implementation/ui-serving.d.ts +4 -2
- 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 +21 -6
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +5 -4
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/skills.d.ts +6 -3
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/types/telemetry/src/browser-operations.d.ts +5 -2
- package/js/chunk-PZ36XMXW.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-TE4KO4HI.js +0 -47
- package/js/chunk-W7D7WVSY.js +0 -18
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
|
@@ -1,7 +1,6 @@
|
|
|
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 "../contracts/swagger-client.ts";
|
|
5
4
|
import { OpenapiCompileError as TemplateError } from "../contracts/openapi-compile.js";
|
|
6
5
|
import type { OpenApiImport } from "../contracts/openapi-document.js";
|
|
7
6
|
import { type GeneratedOperation, type GeneratedSecrets } from "../contracts/openapi-document.js";
|
|
@@ -57,7 +56,7 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
|
|
|
57
56
|
readonly input: {
|
|
58
57
|
readonly [x: string]: Schema.Json;
|
|
59
58
|
};
|
|
60
|
-
readonly method: "
|
|
59
|
+
readonly method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
61
60
|
readonly securitySchemes: {
|
|
62
61
|
readonly [x: string]: {
|
|
63
62
|
readonly [x: string]: Schema.Json;
|
|
@@ -68,6 +67,8 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
|
|
|
68
67
|
readonly outputSchema?: {
|
|
69
68
|
readonly [x: string]: Schema.Json;
|
|
70
69
|
};
|
|
70
|
+
readonly tags?: readonly string[];
|
|
71
|
+
readonly operationId?: string;
|
|
71
72
|
readonly streaming?: true;
|
|
72
73
|
readonly errorResponses?: readonly {
|
|
73
74
|
readonly code: string;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** OpenAPI reference and dialect rules, shared by every part of the app importer. */
|
|
2
|
-
import "../contracts/swagger-client.ts";
|
|
3
1
|
import { Schema } from "effect";
|
|
4
2
|
import { JsonObject } from "../contracts/schema.js";
|
|
5
3
|
/** Resolve OpenAPI objects once with Swagger; schemas retain their original recursive references.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Group generated OpenAPI tool names as `<group>.<leaf>`, ported from Executor v1's tool paths.
|
|
3
|
+
* The group is the first tag, or the first meaningful path segment. The leaf is the operationId
|
|
4
|
+
* without a repeated group prefix, or a method-and-path name when there is no operationId.
|
|
5
|
+
*/
|
|
6
|
+
export interface OperationNameInput {
|
|
7
|
+
readonly operationId: string | undefined;
|
|
8
|
+
/** The first non-empty tag. */
|
|
9
|
+
readonly tag: string | undefined;
|
|
10
|
+
readonly method: string;
|
|
11
|
+
readonly path: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Plan one name per input, in input order. Names that collide are refined together: first by
|
|
15
|
+
* the path's version segment, then by the HTTP method, then by a stable hash. Refinement only
|
|
16
|
+
* touches the colliding names, so adding an operation never renames an unrelated one.
|
|
17
|
+
*/
|
|
18
|
+
export declare const planOperationNames: (inputs: readonly OperationNameInput[]) => string[];
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { Duration } from "effect";
|
|
3
3
|
import type { AppCache } from "../contracts/cache.js";
|
|
4
4
|
import { OpenapiOperation, type OpenapiToolsOptions } from "../contracts/openapi.js";
|
|
5
|
-
import { JsonObject,
|
|
6
|
-
import type { DynamicTools } from "../contracts/dynamic-tools.js";
|
|
5
|
+
import { JsonObject, JsonValue } from "../contracts/schema.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;
|
|
@@ -18,6 +18,10 @@ export interface OpenapiSourceOptions extends Omit<OpenapiToolsOptions, "operati
|
|
|
18
18
|
readonly baseUrl?: string;
|
|
19
19
|
readonly freshFor?: Duration.Input;
|
|
20
20
|
readonly staleFor?: Duration.Input;
|
|
21
|
+
/**
|
|
22
|
+
* Query or mutation overrides keyed by the document's operationId. An operation without an
|
|
23
|
+
* operationId is keyed by its generated name without the kind, such as `users.getUsers`.
|
|
24
|
+
*/
|
|
21
25
|
readonly kinds?: OperationKinds;
|
|
22
26
|
readonly fallbackSecurity?: OpenapiOperation["request"]["security"];
|
|
23
27
|
readonly patches?: readonly {
|
|
@@ -29,8 +33,4 @@ export interface OpenapiSourceOptions extends Omit<OpenapiToolsOptions, "operati
|
|
|
29
33
|
/** JSON-object patches are static app configuration and are reapplied to every revision. */
|
|
30
34
|
export declare function patchOpenapi(root: JsonObject, patches: OpenapiSourceOptions["patches"]): JsonObject;
|
|
31
35
|
/** No I/O during app construction. All accounts share credential-free compilation. */
|
|
32
|
-
export declare const
|
|
33
|
-
readonly queries: {};
|
|
34
|
-
readonly mutations: {};
|
|
35
|
-
readonly dynamicTools: DynamicTools;
|
|
36
|
-
};
|
|
36
|
+
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> & {
|
|
@@ -17,8 +17,7 @@ interface ProtocolOperation {
|
|
|
17
17
|
readonly run: (context: OperationContext, input: JsonValue) => Effect.Effect<unknown, unknown>;
|
|
18
18
|
}
|
|
19
19
|
/** 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
|
-
};
|
|
20
|
+
export declare const protocolOperations: (operations: Readonly<Record<string, ProtocolOperation>>, kinds?: OperationKinds) => Record<string, Operation<Schema.Json, unknown, "query" | "mutation", OperationContext>>;
|
|
21
|
+
/** Operations already discovered, as a router keyed by upstream name. */
|
|
22
|
+
export declare const protocolRouter: (operations: Readonly<Record<string, ProtocolOperation>>, kinds?: OperationKinds) => import("./operations.js").RouterDeclaration<unknown, unknown>;
|
|
24
23
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
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, 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: {
|
|
@@ -9,8 +10,12 @@ export declare const secrets: <Fields extends Schema.Decoder<unknown>>(options:
|
|
|
9
10
|
}) => SecretsMethod<Fields>;
|
|
10
11
|
/** Validate OAuth endpoints while declaring their app-visible response projection. */
|
|
11
12
|
export declare const oauth2: <Response extends Schema.Decoder<unknown>>(config: OAuth2Config, response: Response) => Effect.Effect<OAuth2Method<Response>, ValidationError>;
|
|
12
|
-
/**
|
|
13
|
-
export
|
|
13
|
+
/** Author options: the account check is an ordinary async function. */
|
|
14
|
+
export interface ProviderOptions<Auth extends AuthMethods> {
|
|
14
15
|
readonly name: string;
|
|
15
16
|
readonly auth: Auth;
|
|
16
|
-
|
|
17
|
+
/** Verify a connected account with a safe read, optionally reporting its upstream identity. */
|
|
18
|
+
readonly health?: PromiseMethod<AccountCheck<Auth>["run"]>;
|
|
19
|
+
}
|
|
20
|
+
/** Retain the provider and literal method names without registering or authenticating it. */
|
|
21
|
+
export declare const defineProvider: <const Auth extends AuthMethods>({ health, ...options }: ProviderOptions<Auth>) => Provider<Auth>;
|
|
@@ -0,0 +1,225 @@
|
|
|
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 { McpError } from "../contracts/mcp.js";
|
|
8
|
+
import type { AppOperation } from "../contracts/operations.js";
|
|
9
|
+
import type { AppRouter, DynamicRouter, RouterMeta } from "../contracts/router.js";
|
|
10
|
+
import { SkillLoadFailed } from "../contracts/skills.js";
|
|
11
|
+
import type { OperationSchedule } from "../contracts/schedules.js";
|
|
12
|
+
/**
|
|
13
|
+
* Keep only a failure's safe fields. Anything unrecognized becomes an evaluation failure with the
|
|
14
|
+
* error's name and bounded message, with the given account secrets replaced.
|
|
15
|
+
*/
|
|
16
|
+
export declare const safeFailure: (error: unknown, secrets: readonly string[]) => HostRouterError;
|
|
17
|
+
/**
|
|
18
|
+
* Router skills are named `tools` for the root and `tools-<path>` below it, so a router's
|
|
19
|
+
* instructions never take an authored skill's name by accident.
|
|
20
|
+
*/
|
|
21
|
+
export declare const routerSkillPrefix = "tools";
|
|
22
|
+
/**
|
|
23
|
+
* The skill name for a router path. A path of lowercase letters and digits is spelled out:
|
|
24
|
+
* `issues.open` is `tools-issues-open`. Any other path, or one too long, is a readable slug
|
|
25
|
+
* followed by a hash of the exact path, such as `tools-issues-list-0123456789`. Plain segments
|
|
26
|
+
* start with a letter and a hash is all digits, so the two forms never meet, and paths that slug
|
|
27
|
+
* alike, such as `issues_list` and `issues.list`, get different names.
|
|
28
|
+
*/
|
|
29
|
+
export declare const routerSkillName: (path: string) => string;
|
|
30
|
+
/** A declared operation's catalog entry without schemas. `router` is its owning router's path. */
|
|
31
|
+
export declare const operationSummary: (name: string, router: string, operation: AppOperation, schedules?: readonly OperationSchedule[]) => Effect.Effect<{
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly description: string;
|
|
34
|
+
readonly title?: string;
|
|
35
|
+
readonly annotations?: {
|
|
36
|
+
readonly title?: string;
|
|
37
|
+
readonly readOnlyHint?: boolean;
|
|
38
|
+
readonly destructiveHint?: boolean;
|
|
39
|
+
readonly idempotentHint?: boolean;
|
|
40
|
+
readonly openWorldHint?: boolean;
|
|
41
|
+
};
|
|
42
|
+
readonly schedules?: readonly {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly timing: {
|
|
45
|
+
readonly kind: "interval";
|
|
46
|
+
readonly milliseconds: number;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: "cron";
|
|
49
|
+
readonly calendar: {
|
|
50
|
+
readonly expression: string;
|
|
51
|
+
readonly timezone: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
readonly input: Schema.Json;
|
|
55
|
+
}[];
|
|
56
|
+
readonly readOnly?: boolean;
|
|
57
|
+
readonly router?: string;
|
|
58
|
+
readonly tags?: readonly string[];
|
|
59
|
+
}, HostDeclarationInvalid, never>;
|
|
60
|
+
/** A declared operation's full description, including rendered schemas. */
|
|
61
|
+
export declare const operationDescription: (name: string, router: string, operation: AppOperation, schedules?: readonly OperationSchedule[]) => Effect.Effect<{
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly description: string;
|
|
64
|
+
readonly inputSchema: {
|
|
65
|
+
readonly [x: string]: Schema.Json;
|
|
66
|
+
};
|
|
67
|
+
readonly _meta?: {
|
|
68
|
+
readonly [x: string]: Schema.Json;
|
|
69
|
+
};
|
|
70
|
+
readonly title?: string;
|
|
71
|
+
readonly annotations?: {
|
|
72
|
+
readonly title?: string;
|
|
73
|
+
readonly readOnlyHint?: boolean;
|
|
74
|
+
readonly destructiveHint?: boolean;
|
|
75
|
+
readonly idempotentHint?: boolean;
|
|
76
|
+
readonly openWorldHint?: boolean;
|
|
77
|
+
};
|
|
78
|
+
readonly outputSchema?: {
|
|
79
|
+
readonly [x: string]: Schema.Json;
|
|
80
|
+
};
|
|
81
|
+
readonly schedules?: readonly {
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly timing: {
|
|
84
|
+
readonly kind: "interval";
|
|
85
|
+
readonly milliseconds: number;
|
|
86
|
+
} | {
|
|
87
|
+
readonly kind: "cron";
|
|
88
|
+
readonly calendar: {
|
|
89
|
+
readonly expression: string;
|
|
90
|
+
readonly timezone: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
readonly input: Schema.Json;
|
|
94
|
+
}[];
|
|
95
|
+
readonly readOnly?: boolean;
|
|
96
|
+
readonly router?: string;
|
|
97
|
+
readonly tags?: readonly string[];
|
|
98
|
+
}, HostDeclarationInvalid, never>;
|
|
99
|
+
/**
|
|
100
|
+
* A dynamic router over operations already discovered, such as an eager OpenAPI document or a
|
|
101
|
+
* stdio server. Upstream names can contain dots, which static router keys cannot.
|
|
102
|
+
*/
|
|
103
|
+
export declare const fixedRouter: (operations: Readonly<Record<string, AppOperation>>, meta?: RouterMeta) => DynamicRouter;
|
|
104
|
+
export interface CatalogOptions {
|
|
105
|
+
/** Omit schemas. */
|
|
106
|
+
readonly summary: boolean;
|
|
107
|
+
/** Account secrets that a failure's message must not reveal. */
|
|
108
|
+
readonly secrets: readonly string[];
|
|
109
|
+
/** Only these full tool names. Routers with none of them are not read. */
|
|
110
|
+
readonly wanted?: ReadonlySet<string>;
|
|
111
|
+
/** Schedules that target a declared operation, by full name. */
|
|
112
|
+
readonly schedules: (name: string) => readonly OperationSchedule[];
|
|
113
|
+
/**
|
|
114
|
+
* Only declared operations that have schedules. Schedules never target dynamic routers, and
|
|
115
|
+
* their catalogs can be expensive to discover, so none is read.
|
|
116
|
+
*/
|
|
117
|
+
readonly scheduled?: true;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Read a router tree. Every nested router is listed, for grouping; the root only when it has
|
|
121
|
+
* metadata. A nested dynamic source that fails is reported on its router's entry.
|
|
122
|
+
*/
|
|
123
|
+
export declare const readCatalog: (root: AppRouter | DynamicRouter | undefined, options: CatalogOptions) => Effect.Effect<{
|
|
124
|
+
tools: ({
|
|
125
|
+
readonly name: string;
|
|
126
|
+
readonly description: string;
|
|
127
|
+
readonly inputSchema: {
|
|
128
|
+
readonly [x: string]: Schema.Json;
|
|
129
|
+
};
|
|
130
|
+
readonly _meta?: {
|
|
131
|
+
readonly [x: string]: Schema.Json;
|
|
132
|
+
};
|
|
133
|
+
readonly title?: string;
|
|
134
|
+
readonly annotations?: {
|
|
135
|
+
readonly title?: string;
|
|
136
|
+
readonly readOnlyHint?: boolean;
|
|
137
|
+
readonly destructiveHint?: boolean;
|
|
138
|
+
readonly idempotentHint?: boolean;
|
|
139
|
+
readonly openWorldHint?: boolean;
|
|
140
|
+
};
|
|
141
|
+
readonly outputSchema?: {
|
|
142
|
+
readonly [x: string]: Schema.Json;
|
|
143
|
+
};
|
|
144
|
+
readonly schedules?: readonly {
|
|
145
|
+
readonly name: string;
|
|
146
|
+
readonly timing: {
|
|
147
|
+
readonly kind: "interval";
|
|
148
|
+
readonly milliseconds: number;
|
|
149
|
+
} | {
|
|
150
|
+
readonly kind: "cron";
|
|
151
|
+
readonly calendar: {
|
|
152
|
+
readonly expression: string;
|
|
153
|
+
readonly timezone: string;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
readonly input: Schema.Json;
|
|
157
|
+
}[];
|
|
158
|
+
readonly readOnly?: boolean;
|
|
159
|
+
readonly router?: string;
|
|
160
|
+
readonly tags?: readonly string[];
|
|
161
|
+
} | {
|
|
162
|
+
readonly name: string;
|
|
163
|
+
readonly description: string;
|
|
164
|
+
readonly title?: string;
|
|
165
|
+
readonly annotations?: {
|
|
166
|
+
readonly title?: string;
|
|
167
|
+
readonly readOnlyHint?: boolean;
|
|
168
|
+
readonly destructiveHint?: boolean;
|
|
169
|
+
readonly idempotentHint?: boolean;
|
|
170
|
+
readonly openWorldHint?: boolean;
|
|
171
|
+
};
|
|
172
|
+
readonly schedules?: readonly {
|
|
173
|
+
readonly name: string;
|
|
174
|
+
readonly timing: {
|
|
175
|
+
readonly kind: "interval";
|
|
176
|
+
readonly milliseconds: number;
|
|
177
|
+
} | {
|
|
178
|
+
readonly kind: "cron";
|
|
179
|
+
readonly calendar: {
|
|
180
|
+
readonly expression: string;
|
|
181
|
+
readonly timezone: string;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
readonly input: Schema.Json;
|
|
185
|
+
}[];
|
|
186
|
+
readonly readOnly?: boolean;
|
|
187
|
+
readonly router?: string;
|
|
188
|
+
readonly tags?: readonly string[];
|
|
189
|
+
})[];
|
|
190
|
+
routers: {
|
|
191
|
+
readonly path: string;
|
|
192
|
+
readonly error?: import("../index.js").ProviderError | SkillLoadFailed | McpError | HostDeclarationInvalid | HostEvaluationFailed;
|
|
193
|
+
readonly description?: string;
|
|
194
|
+
readonly title?: string;
|
|
195
|
+
readonly tags?: {
|
|
196
|
+
readonly [x: string]: string;
|
|
197
|
+
};
|
|
198
|
+
readonly icons?: readonly {
|
|
199
|
+
readonly src: string;
|
|
200
|
+
readonly mimeType?: string;
|
|
201
|
+
readonly sizes?: readonly string[];
|
|
202
|
+
readonly theme?: "light" | "dark";
|
|
203
|
+
}[];
|
|
204
|
+
readonly skill?: string;
|
|
205
|
+
}[];
|
|
206
|
+
}, import("../index.js").ProviderError | SkillLoadFailed | McpError | HostDeclarationInvalid | HostEvaluationFailed, never>;
|
|
207
|
+
/**
|
|
208
|
+
* One skill for each router with instructions. Skills and tools fail independently: a dynamic
|
|
209
|
+
* router whose metadata cannot be read, including the root, contributes no skill and does not
|
|
210
|
+
* fail the others. Metadata comes through each source's catalog cache, like a tool listing.
|
|
211
|
+
*/
|
|
212
|
+
export declare const routerSkills: (root: AppRouter | DynamicRouter | undefined) => Effect.Effect<{
|
|
213
|
+
readonly name: string;
|
|
214
|
+
readonly description: string;
|
|
215
|
+
readonly files: readonly {
|
|
216
|
+
readonly path: string;
|
|
217
|
+
readonly content: string;
|
|
218
|
+
}[];
|
|
219
|
+
readonly license?: string;
|
|
220
|
+
readonly compatibility?: string;
|
|
221
|
+
readonly metadata?: {
|
|
222
|
+
readonly [x: string]: string;
|
|
223
|
+
};
|
|
224
|
+
readonly "allowed-tools"?: string;
|
|
225
|
+
}[], never, never>;
|
|
@@ -0,0 +1,59 @@
|
|
|
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 OperationDeclaration, type RouterChild, type RouterDeclaration } from "./operations.js";
|
|
5
|
+
export type { RouterChild, RouterDeclaration } from "./operations.js";
|
|
6
|
+
/** Author metadata for a router. Instructions become a skill named after the router's path. */
|
|
7
|
+
export interface RouterOptions {
|
|
8
|
+
readonly title?: string;
|
|
9
|
+
readonly description?: string;
|
|
10
|
+
readonly instructions?: string;
|
|
11
|
+
readonly icons?: readonly RouterIcon[];
|
|
12
|
+
readonly tags?: Readonly<Record<string, string>>;
|
|
13
|
+
}
|
|
14
|
+
/** Wrap a native router. Protocol helpers use this for the routers they build. */
|
|
15
|
+
export declare const routerDeclaration: (node: AppRouter | DynamicRouter) => RouterDeclaration;
|
|
16
|
+
/** Accept only framework-created routers. */
|
|
17
|
+
export declare const nativeRouter: (value: unknown) => AppRouter | DynamicRouter | undefined;
|
|
18
|
+
/** Author fields win; a field the author omits keeps the source's value. */
|
|
19
|
+
export declare const mergeMeta: (base: RouterMeta | undefined, override: RouterMeta | undefined) => RouterMeta | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Group operations and routers under path keys, like tRPC's nested routers, with metadata an
|
|
22
|
+
* agent can read. Passing an existing router instead of children overrides its metadata:
|
|
23
|
+
* `router(mcpRouter(options), { description: "..." })`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function router<Query = unknown, Mutation = unknown>(children: Readonly<Record<string, RouterChild<Query, Mutation>>>, options?: RouterOptions): RouterDeclaration<Query, Mutation>;
|
|
26
|
+
export declare function router<Query, Mutation>(source: RouterDeclaration<Query, Mutation>, options: RouterOptions): RouterDeclaration<Query, Mutation>;
|
|
27
|
+
/**
|
|
28
|
+
* Declare a router whose tools are discovered when read. `list` returns tools with names relative
|
|
29
|
+
* to this router; mark queries with `readOnly: true`. `resolve` receives one of those names.
|
|
30
|
+
*/
|
|
31
|
+
export declare const dynamicRouter: (source: {
|
|
32
|
+
readonly meta?: () => RouterOptions | Promise<RouterOptions>;
|
|
33
|
+
readonly list: () => readonly HostedTool[] | Promise<readonly HostedTool[]>;
|
|
34
|
+
readonly resolve: (name: string) => OperationDeclaration<"query" | "mutation", unknown> | undefined | Promise<OperationDeclaration<"query" | "mutation", unknown> | undefined>;
|
|
35
|
+
}) => RouterDeclaration;
|
|
36
|
+
/** Join a router path and a relative name. The root router's path is "". */
|
|
37
|
+
export declare const joinPath: (path: string, name: string) => string;
|
|
38
|
+
/** Where a full tool name points: a declared operation, or a name inside a dynamic router. */
|
|
39
|
+
export type Location = {
|
|
40
|
+
readonly kind: "operation";
|
|
41
|
+
readonly operation: AppOperation;
|
|
42
|
+
readonly router: string;
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: "dynamic";
|
|
45
|
+
readonly source: DynamicRouter;
|
|
46
|
+
readonly router: string;
|
|
47
|
+
readonly name: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Walk static keys until the name ends at an operation or enters a dynamic router, which receives
|
|
51
|
+
* the rest of the name. Static keys contain no dots, so every name has at most one location.
|
|
52
|
+
*/
|
|
53
|
+
export declare const locate: (root: AppRouter | DynamicRouter | undefined, name: string) => Location | undefined;
|
|
54
|
+
/** Every declared operation with its full name and owning router. Dynamic routers are not listed. */
|
|
55
|
+
export declare const declaredOperations: (root: AppRouter | undefined, path?: string) => Array<{
|
|
56
|
+
readonly name: string;
|
|
57
|
+
readonly router: string;
|
|
58
|
+
readonly operation: AppOperation;
|
|
59
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
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 {
|
|
3
|
+
import { JsonObject, ValidationError } from "../contracts/schema.js";
|
|
4
4
|
import type { Field } from "../../../app-data/src/contracts/database.js";
|
|
5
5
|
declare const StorageField: unique symbol;
|
|
6
6
|
declare const Decoder: unique symbol;
|
|
@@ -80,11 +80,6 @@ export declare const compileJsonSchemaDecoder: (document: JsonObject) => Effect.
|
|
|
80
80
|
readonly [x: string]: EffectSchema.Json;
|
|
81
81
|
};
|
|
82
82
|
}, ValidationError, never>;
|
|
83
|
-
/**
|
|
84
|
-
* Build the document only when a value is first decoded or the schema is described, then
|
|
85
|
-
* compile its validator once. Imported apps can share definitions between many schemas
|
|
86
|
-
* without making each one self-contained up front.
|
|
87
|
-
*/
|
|
88
83
|
export declare const lazyJsonSchemaDecoder: (document: () => JsonObject) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, never, never>;
|
|
89
84
|
/** Preserve the JSON document; compile its validator only when a value is first decoded. */
|
|
90
85
|
export declare const jsonSchemaDecoder: (input: unknown) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, ValidationError, never>;
|
|
@@ -96,4 +91,8 @@ export declare const storageFieldOf: (schema: Schema<unknown, boolean>) => Field
|
|
|
96
91
|
export declare const id: (table: string) => Schema<string>;
|
|
97
92
|
/** A host user identifier, stored as a string without imposing a product auth model. */
|
|
98
93
|
export declare const userId: () => Schema<string>;
|
|
94
|
+
/** Render a decoder as a JSON Schema document, keeping an imported upstream document as-is. */
|
|
95
|
+
export declare const jsonSchemaDocument: (decoder: EffectSchema.Decoder<unknown>) => Effect.Effect<{
|
|
96
|
+
readonly [x: string]: EffectSchema.Json;
|
|
97
|
+
}, EffectSchema.SchemaError, never>;
|
|
99
98
|
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { type DatabaseSession } from "../../../app-data/src/index.js";
|
|
1
|
+
import { type DatabaseSession, type reservedFieldNames } from "../../../app-data/src/index.js";
|
|
2
|
+
type ReservedFieldName = (typeof reservedFieldNames)[number];
|
|
2
3
|
import { type AppStorage } from "../contracts/storage.js";
|
|
3
4
|
import type { DatabaseDefinition, Database, Table, Tables } from "../contracts/storage.js";
|
|
4
5
|
import { type Fields } from "./schema.js";
|
|
5
6
|
export type { DatabaseDefinition, Database, DatabaseReader, Table, Tables, RowOf, } from "../contracts/storage.js";
|
|
6
|
-
/** Declare scalar columns using the same schemas as operation inputs.
|
|
7
|
-
|
|
7
|
+
/** Declare scalar columns using the same schemas as operation inputs. The host adds `id`,
|
|
8
|
+
* `createdAt` and `updatedAt` to every row, so tables cannot declare those names. */
|
|
9
|
+
export declare const table: <const F extends Fields & { readonly [K in ReservedFieldName]?: never; }>(fields: F) => Table<F>;
|
|
8
10
|
/** Build a fresh Promise database facade for one authorized invocation. */
|
|
9
11
|
export declare const authorDatabase: <T extends Tables>(tables: T, session: DatabaseSession, signal: AbortSignal, writable: boolean) => Database<T>;
|
|
10
12
|
/** Declare storage independently of handlers; the host binds each invocation's database. */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Swagger is most of the OpenAPI module's code. Discovery from a cached catalog never needs it,
|
|
2
|
+
* so a cold app Worker evaluates it only when it resolves a document or builds a request.
|
|
3
|
+
*/
|
|
4
|
+
import "../contracts/swagger-client.ts";
|
|
5
|
+
export type SwaggerClient = typeof import("swagger-client").default;
|
|
6
|
+
export declare const loadSwaggerClient: () => Promise<{
|
|
7
|
+
buildRequest(options: {
|
|
8
|
+
spec: unknown;
|
|
9
|
+
operationId?: string;
|
|
10
|
+
pathName?: string;
|
|
11
|
+
method?: string;
|
|
12
|
+
parameters?: Readonly<Record<string, unknown>>;
|
|
13
|
+
requestBody?: unknown;
|
|
14
|
+
requestContentType?: string;
|
|
15
|
+
securities?: {
|
|
16
|
+
authorized: Readonly<Record<string, unknown>>;
|
|
17
|
+
};
|
|
18
|
+
}): unknown;
|
|
19
|
+
resolve(options: {
|
|
20
|
+
spec: unknown;
|
|
21
|
+
skipNormalization: boolean;
|
|
22
|
+
useCircularStructures: boolean;
|
|
23
|
+
requestInterceptor: () => never;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
spec: unknown;
|
|
26
|
+
errors: readonly unknown[];
|
|
27
|
+
}>;
|
|
28
|
+
}>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Host responses around app sign-in. They carry no script and never contain product credentials. */
|
|
2
2
|
import { HttpServerResponse } from "effect/unstable/http";
|
|
3
|
+
import { type AppSignInId } from "../contracts/ui-auth.js";
|
|
3
4
|
/** Private app responses must not leak authentication URLs through caches or referrers. */
|
|
4
5
|
export declare const appPrivateHeaders: {
|
|
5
6
|
"cache-control": string;
|
|
@@ -7,7 +8,12 @@ export declare const appPrivateHeaders: {
|
|
|
7
8
|
"x-content-type-options": string;
|
|
8
9
|
"content-security-policy": string;
|
|
9
10
|
};
|
|
10
|
-
/**
|
|
11
|
-
export declare const
|
|
12
|
-
/**
|
|
13
|
-
|
|
11
|
+
/** Every sign-in hop is a server redirect, so the browser paints nothing until the app itself. */
|
|
12
|
+
export declare const appRedirect: (url: string) => HttpServerResponse.HttpServerResponse;
|
|
13
|
+
/**
|
|
14
|
+
* The callback URL carries the code in its query. It exists only as a redirect `Location`, never as
|
|
15
|
+
* a rendered document, and redeeming it also requires the attempt's HttpOnly cookie.
|
|
16
|
+
*/
|
|
17
|
+
export declare const appSignInCallback: (origin: string, request: AppSignInId, code: string) => string;
|
|
18
|
+
/** A failed callback explains itself without script; reopening the app URL starts a new attempt. */
|
|
19
|
+
export declare const appSignInFailed: () => HttpServerResponse.HttpServerResponse;
|
|
@@ -9,8 +9,10 @@ export declare const appDocument: <E, R>(options: {
|
|
|
9
9
|
readonly origin: string;
|
|
10
10
|
readonly asset: (path: string) => Effect.Effect<AppUiAsset | undefined, E, R>;
|
|
11
11
|
}) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiForbidden | E, HttpServerRequest.HttpServerRequest | R>;
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
12
|
+
/** Serve an asset only after the host has checked current access and file existence.
|
|
13
|
+
* Asset URLs name their deployment, so their bytes never change: the browser keeps them for a year
|
|
14
|
+
* and does not ask again. Shared proxies never store them. Revoking access stops every new request
|
|
15
|
+
* and all app data, while bytes a browser already downloaded stay in its cache.
|
|
14
16
|
* HTML remains an uncached host-rendered entry point.
|
|
15
17
|
*/
|
|
16
18
|
export declare const appAsset: (asset: AppUiAsset | undefined, build: string, path: string) => Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest>;
|
|
@@ -26,4 +26,4 @@ export declare const dispatchWebhook: <Context extends {
|
|
|
26
26
|
readonly [x: string]: string;
|
|
27
27
|
};
|
|
28
28
|
readonly body: string;
|
|
29
|
-
},
|
|
29
|
+
}, HostOperationNotFound | HostInputInvalid | HostOutputInvalid | HostDeclarationInvalid | HostOperationFailed, never>;
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import type { AppDefinition } from "../contracts/app.js";
|
|
4
4
|
import { WorkflowFailure, type WorkflowContext, type WorkflowExecution, type WorkflowStepContext } from "../contracts/workflows.js";
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Preserve typed failures and cancellation. Other errors keep their name and bounded message,
|
|
7
|
+
* with the given account secrets replaced.
|
|
8
|
+
*/
|
|
9
|
+
export declare const workflowSafe: <A>(work: Effect.Effect<A, unknown>, secrets: readonly string[]) => Effect.Effect<A, WorkflowFailure>;
|
|
7
10
|
/** Construct one replay's Promise context. Step callbacks acquire fresh capabilities per actual attempt. */
|
|
8
|
-
export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "
|
|
11
|
+
export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "tools">,
|
|
12
|
+
/** A step attempt's context, and the raw account secrets its failures must not reveal. */
|
|
13
|
+
fresh: (stepId: string, signal: AbortSignal) => Effect.Effect<{
|
|
14
|
+
readonly context: WorkflowStepContext;
|
|
15
|
+
readonly secrets: readonly string[];
|
|
16
|
+
}, WorkflowFailure>, signal: AbortSignal) => Effect.Effect<WorkflowContext>;
|