apps 0.0.1-beta.16 → 0.0.1-beta.18
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/framework-reference.json +1 -1
- package/js/{chunk-RFVIONFX.js → chunk-4EMWIFFJ.js} +1 -1
- package/js/{chunk-5T57N25Q.js → chunk-4QQ62BVS.js} +22 -0
- package/js/{chunk-QAXLPXKL.js → chunk-7H44SOSX.js} +4 -4
- package/js/{chunk-CIUZ3HSV.js → chunk-F2IASQK2.js} +3 -3
- package/js/{chunk-L2QHGLWF.js → chunk-HQY4UTYX.js} +2 -2
- package/js/{chunk-S2HMUOAV.js → chunk-MAF4BRQF.js} +2 -2
- package/js/{chunk-TEFD5OBS.js → chunk-NMKHTJOQ.js} +2 -2
- package/js/{chunk-CL3O2NIN.js → chunk-VXWY44LE.js} +91 -7
- package/js/{chunk-TXFDBLWA.js → chunk-XNCYIB4D.js} +3 -3
- package/js/{chunk-ZBGV4RN4.js → chunk-ZKISLYWM.js} +22 -9
- package/js/client.js +1 -1
- package/js/contracts.js +5 -1
- package/js/effect.js +6 -6
- package/js/graphql.js +8 -8
- package/js/host.js +6 -6
- package/js/index.js +32 -7
- package/js/mcp/effect.js +8 -8
- package/js/mcp/stdio.js +8 -8
- package/js/mcp.js +10 -10
- package/js/openapi.js +5 -5
- package/js/skills.js +2 -2
- package/js/ui/serving.js +98 -1
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/apps/src/contracts/host.d.ts +5 -4
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
- package/types/apps/src/contracts/provider.d.ts +15 -0
- package/types/apps/src/contracts/ui.d.ts +18 -0
- package/types/apps/src/implementation/elicitation.d.ts +1 -1
- package/types/apps/src/implementation/openapi-compile.d.ts +2 -2
- package/types/apps/src/implementation/provider.d.ts +11 -2
- package/types/apps/src/implementation/schema.d.ts +39 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-serving.d.ts +6 -2
- package/types/apps/src/index.d.ts +6 -4
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/** Provider declarations use native Effect schemas. The trusted host interprets them. */
|
|
2
2
|
import { Data, type Effect, Schema } from "effect";
|
|
3
3
|
import { type AccountId } from "./schema.js";
|
|
4
|
+
/**
|
|
5
|
+
* How app code sees a field of a provider that declares hosts. Unmarked string fields are secret:
|
|
6
|
+
* app code receives sealed handles that only the host's outbound network turns into values.
|
|
7
|
+
* `plain` fields are not secret. `raw` fields are secret, but app code reads the real value.
|
|
8
|
+
*/
|
|
9
|
+
export type FieldExposure = "plain" | "raw";
|
|
4
10
|
declare const SecretsMethod_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Readonly<A> & {
|
|
5
11
|
readonly _tag: "secrets";
|
|
6
12
|
} & import("effect/Pipeable").Pipeable;
|
|
@@ -8,6 +14,8 @@ declare const SecretsMethod_base: new <A extends Record<string, any> = {}>(args:
|
|
|
8
14
|
export declare class SecretsMethod<Fields extends Schema.Decoder<unknown>> extends SecretsMethod_base<{
|
|
9
15
|
readonly label: string;
|
|
10
16
|
readonly fields: Fields;
|
|
17
|
+
/** Fields marked with `plain()` or `raw()`. */
|
|
18
|
+
readonly exposure?: Readonly<Record<string, FieldExposure>>;
|
|
11
19
|
}> {
|
|
12
20
|
}
|
|
13
21
|
/** How an OAuth client authenticates at the token endpoint; raw Basic is an explicit provider compatibility option. */
|
|
@@ -114,6 +122,8 @@ declare const OAuth2Method_base: new <A extends Record<string, any> = {}>(args:
|
|
|
114
122
|
export declare class OAuth2Method<Response extends Schema.Decoder<unknown>> extends OAuth2Method_base<{
|
|
115
123
|
readonly config: OAuth2Config;
|
|
116
124
|
readonly response: Response;
|
|
125
|
+
/** Response fields marked with `plain()` or `raw()`. */
|
|
126
|
+
readonly exposure?: Readonly<Record<string, FieldExposure>>;
|
|
117
127
|
}> {
|
|
118
128
|
}
|
|
119
129
|
/** Supported declarations; these acquire credentials rather than normalize them. */
|
|
@@ -165,6 +175,11 @@ export interface AccountCheck<Auth extends AuthMethods> {
|
|
|
165
175
|
export declare class Provider<Auth extends AuthMethods> extends Data.Class<{
|
|
166
176
|
readonly name: string;
|
|
167
177
|
readonly auth: Auth;
|
|
178
|
+
/**
|
|
179
|
+
* The hosts this provider's credentials may be sent to. When present, secret fields reach app
|
|
180
|
+
* code as handles that the outbound network replaces only on requests to these hosts.
|
|
181
|
+
*/
|
|
182
|
+
readonly hosts?: readonly string[];
|
|
168
183
|
/**
|
|
169
184
|
* Stored without its method types so a specific provider still fills a general slot. The host
|
|
170
185
|
* binds the account against this provider's methods before running it.
|
|
@@ -7,6 +7,24 @@ export declare const UiContext: Schema.Struct<{
|
|
|
7
7
|
readonly profile: Schema.optional<Schema.NonEmptyString>;
|
|
8
8
|
readonly expectedProfileRevision: Schema.optional<Schema.Int>;
|
|
9
9
|
}>;
|
|
10
|
+
/** A problem with one of the page profile's accounts, from stored state. Labels are the owner's own names. */
|
|
11
|
+
export type UiAccountProblem = {
|
|
12
|
+
readonly provider: string;
|
|
13
|
+
readonly reason: "missing" | "removed" | "incompatible";
|
|
14
|
+
} | {
|
|
15
|
+
readonly provider: string;
|
|
16
|
+
readonly account: string;
|
|
17
|
+
readonly reason: "credentials_rejected" | "forbidden" | "upstream_unavailable" | "check_failed";
|
|
18
|
+
};
|
|
19
|
+
/** Account problems found when the page opened, with dashboard links that resolve them. */
|
|
20
|
+
export interface UiAccountNotice {
|
|
21
|
+
readonly app: string;
|
|
22
|
+
readonly problems: readonly UiAccountProblem[];
|
|
23
|
+
/** The profile's accounts in the dashboard. */
|
|
24
|
+
readonly fix: string;
|
|
25
|
+
/** The dashboard chooser, returning to this page. */
|
|
26
|
+
readonly choose: string;
|
|
27
|
+
}
|
|
10
28
|
/** Retained browser bytes. Hosts authorize access before reading or rendering them. */
|
|
11
29
|
export interface AppUiAsset {
|
|
12
30
|
readonly body: Uint8Array;
|
|
@@ -58,8 +58,8 @@ export declare const prepareElicitation: (input: unknown) => Effect.Effect<{
|
|
|
58
58
|
} | {
|
|
59
59
|
readonly type: "string";
|
|
60
60
|
readonly default?: string;
|
|
61
|
-
readonly format?: "email" | "uri" | "date" | "date-time";
|
|
62
61
|
readonly description?: string;
|
|
62
|
+
readonly format?: "email" | "uri" | "date" | "date-time";
|
|
63
63
|
readonly title?: string;
|
|
64
64
|
readonly minLength?: number;
|
|
65
65
|
readonly maxLength?: number;
|
|
@@ -16,8 +16,6 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
|
|
|
16
16
|
}) => Effect.Effect<{
|
|
17
17
|
operations: {
|
|
18
18
|
readonly name: string;
|
|
19
|
-
readonly path: string;
|
|
20
|
-
readonly description: string;
|
|
21
19
|
readonly request: {
|
|
22
20
|
readonly parameters: readonly {
|
|
23
21
|
readonly name: string;
|
|
@@ -56,6 +54,8 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
|
|
|
56
54
|
readonly required?: boolean;
|
|
57
55
|
};
|
|
58
56
|
};
|
|
57
|
+
readonly path: string;
|
|
58
|
+
readonly description: string;
|
|
59
59
|
readonly input: {
|
|
60
60
|
readonly [x: string]: Schema.Json;
|
|
61
61
|
};
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
/** Pure constructors over the native provider contracts. */
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
3
|
import { type PromiseMethod } from "./authoring.js";
|
|
4
|
-
import { type AccountCheck, type AuthMethods, OAuth2Config, OAuth2Method, Provider, SecretsMethod } from "../contracts/provider.js";
|
|
4
|
+
import { type AccountCheck, type AuthMethods, type FieldExposure, OAuth2Config, OAuth2Method, Provider, SecretsMethod } from "../contracts/provider.js";
|
|
5
5
|
import type { ValidationError } from "../contracts/schema.js";
|
|
6
6
|
/** Declare a secrets method with an Effect decoder. */
|
|
7
7
|
export declare const secrets: <Fields extends Schema.Decoder<unknown>>(options: {
|
|
8
8
|
readonly label: string;
|
|
9
9
|
readonly fields: Fields;
|
|
10
|
+
readonly exposure?: Readonly<Record<string, FieldExposure>>;
|
|
10
11
|
}) => SecretsMethod<Fields>;
|
|
11
12
|
/** Validate OAuth endpoints while declaring their app-visible response projection. */
|
|
12
|
-
export declare const oauth2: <Response extends Schema.Decoder<unknown>>(config: OAuth2Config, response: Response) => Effect.Effect<OAuth2Method<Response>, ValidationError>;
|
|
13
|
+
export declare const oauth2: <Response extends Schema.Decoder<unknown>>(config: OAuth2Config, response: Response, exposure?: Readonly<Record<string, FieldExposure>>) => Effect.Effect<OAuth2Method<Response>, ValidationError>;
|
|
13
14
|
/** Author options: the account check is an ordinary async function. */
|
|
14
15
|
export interface ProviderOptions<Auth extends AuthMethods> {
|
|
15
16
|
readonly name: string;
|
|
16
17
|
readonly auth: Auth;
|
|
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[];
|
|
17
26
|
/** Verify a connected account with a safe read, optionally reporting its upstream identity. */
|
|
18
27
|
readonly health?: PromiseMethod<AccountCheck<Auth>["run"]>;
|
|
19
28
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Effect, Schema as EffectSchema } from "effect";
|
|
3
3
|
import { JsonObject, ValidationError } from "../contracts/schema.js";
|
|
4
4
|
import type { Field } from "../../../app-data/src/contracts/database.js";
|
|
5
|
+
import type { FieldExposure } from "../contracts/provider.js";
|
|
5
6
|
declare const StorageField: unique symbol;
|
|
6
7
|
declare const Decoder: unique symbol;
|
|
7
8
|
/** An author-facing value schema. Effect is never required in author code. */
|
|
@@ -59,6 +60,44 @@ export declare function literal<const T extends string | number | boolean | null
|
|
|
59
60
|
export declare const array: <T>(item: Schema<T, boolean>) => Schema<readonly T[]>;
|
|
60
61
|
/** Parse declared fields and omit undeclared fields. */
|
|
61
62
|
export declare function object<const F extends Fields>(fields: F): ObjectSchema<F>;
|
|
63
|
+
declare const Exposure: unique symbol;
|
|
64
|
+
/** A schema marked with how app code sees the field in a provider that declares hosts. */
|
|
65
|
+
export type Exposed<S, E extends FieldExposure = FieldExposure> = S & {
|
|
66
|
+
readonly [Exposure]: E;
|
|
67
|
+
};
|
|
68
|
+
/** The marking of one account field, if any. */
|
|
69
|
+
export declare const exposureOf: (schema: Schema<unknown, boolean>) => FieldExposure | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* A field that is not secret, such as a subdomain or region. App code reads its real value and
|
|
72
|
+
* the connect form shows it.
|
|
73
|
+
*/
|
|
74
|
+
export declare const plain: <S extends Schema<unknown, boolean>>(schema: S) => Exposed<S, "plain">;
|
|
75
|
+
/**
|
|
76
|
+
* A secret field that app code reads as its real value, for request signing and similar uses.
|
|
77
|
+
* The connect form warns that the app can read it. Prefer an unmarked field, which app code
|
|
78
|
+
* receives as a handle that only reaches the provider's declared hosts.
|
|
79
|
+
*/
|
|
80
|
+
export declare const raw: <S extends Schema<unknown, boolean>>(schema: S) => Exposed<S, "raw">;
|
|
81
|
+
/** Marked fields of an account object, by name. */
|
|
82
|
+
export declare const fieldExposure: (fields: Fields) => Readonly<Record<string, FieldExposure>>;
|
|
83
|
+
declare const Secret: unique symbol;
|
|
84
|
+
/**
|
|
85
|
+
* A secret account value. In a provider that declares hosts it is a handle, which the host's
|
|
86
|
+
* outbound network replaces with the real value only on requests to those hosts. Pass it to
|
|
87
|
+
* clients and headers as an ordinary string; do not decode or transform it.
|
|
88
|
+
*/
|
|
89
|
+
export type SecretString = string & {
|
|
90
|
+
readonly [Secret]: true;
|
|
91
|
+
};
|
|
92
|
+
type Sealed<T> = T extends string ? SecretString : T;
|
|
93
|
+
/** Account fields as app code receives them: unmarked string fields are secret. */
|
|
94
|
+
export type SecretFields<F extends Fields> = {
|
|
95
|
+
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];
|
|
96
|
+
};
|
|
97
|
+
/** An account object without declared fields, such as a default OAuth projection. */
|
|
98
|
+
export type SecretObject<T> = {
|
|
99
|
+
readonly [Key in keyof T]: Sealed<T[Key]>;
|
|
100
|
+
};
|
|
62
101
|
declare const ImportedJsonSchema: unique symbol;
|
|
63
102
|
/** Read the original document for an imported decoder without a lossy schema round trip. */
|
|
64
103
|
export declare const importedJsonSchema: (decoder: EffectSchema.Decoder<unknown>) => unknown | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Host-rendered account notices; no authored app code or provider responses enter them. */
|
|
2
|
+
import type { UiAccountNotice, UiAccountProblem } from "../contracts/ui.js";
|
|
3
|
+
/** Missing, removed, incompatible, or rejected accounts stop the app; other failed checks are advisory. */
|
|
4
|
+
export declare const accountProblemBlocks: (problem: UiAccountProblem) => boolean;
|
|
5
|
+
export declare const accountProblemText: (problem: UiAccountProblem) => string;
|
|
6
|
+
/** Full page shown instead of the app while an account problem stops it from working. */
|
|
7
|
+
export declare const accountBlockedPage: (notice: UiAccountNotice) => string;
|
|
8
|
+
/** Inline card for advisory problems; the app still loads underneath. */
|
|
9
|
+
export declare const accountNoticeBootstrap: (notice: UiAccountNotice) => string;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
3
|
-
import { UiForbidden, type AppUiAsset } from "../contracts/ui.js";
|
|
4
|
-
/**
|
|
3
|
+
import { UiForbidden, type AppUiAsset, type UiAccountNotice } from "../contracts/ui.js";
|
|
4
|
+
/**
|
|
5
|
+
* Render an authorized deployment with a host-owned deployment watcher. Account problems that stop
|
|
6
|
+
* the app replace its document with a page that links to their fix; others add a dismissible card.
|
|
7
|
+
*/
|
|
5
8
|
export declare const appDocument: <E, R>(options: {
|
|
6
9
|
readonly deployment: string;
|
|
7
10
|
readonly profile?: string | undefined;
|
|
8
11
|
readonly expectedProfileRevision?: number | undefined;
|
|
9
12
|
readonly origin: string;
|
|
13
|
+
readonly accounts?: UiAccountNotice | undefined;
|
|
10
14
|
readonly asset: (path: string) => Effect.Effect<AppUiAsset | undefined, E, R>;
|
|
11
15
|
}) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiForbidden | E, HttpServerRequest.HttpServerRequest | R>;
|
|
12
16
|
/** Serve an asset only after the host has checked current access and file existence.
|
|
@@ -11,9 +11,9 @@ import { type JsonResponse as NativeResponse } from "./contracts/http.js";
|
|
|
11
11
|
import { type OAuth2Config as NativeOAuth2Config, type OAuth2Method as NativeOAuth2Method, type ReservedAuthorizationParam, type SecretsMethod as NativeSecretsMethod } from "./contracts/provider.js";
|
|
12
12
|
import type { Webhook as NativeWebhook } from "./contracts/webhooks.js";
|
|
13
13
|
import { type PromiseMethods } from "./implementation/authoring.js";
|
|
14
|
-
import { type Fields, type Infer, type ObjectSchema, type Schema } from "./implementation/schema.js";
|
|
14
|
+
import { type Fields, type Infer, type ObjectSchema, type Schema, type SecretFields, type SecretObject } from "./implementation/schema.js";
|
|
15
15
|
export { type JsonObject, type JsonValue, ValidationError } from "./contracts/schema.js";
|
|
16
|
-
export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Schema, array, boolean, json, jsonSchema, literal, number, object, record, string, } from "./implementation/schema.js";
|
|
16
|
+
export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Schema, array, boolean, json, jsonSchema, literal, number, object, record, string, plain, raw, type SecretString, } from "./implementation/schema.js";
|
|
17
17
|
export { type AccountCheckContext, type AccountCheckResult, type AccountInfo, type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type Provider, type ReservedAuthorizationParam, } from "./contracts/provider.js";
|
|
18
18
|
export { defineProvider, type ProviderOptions } from "./implementation/provider.js";
|
|
19
19
|
export { accountRouter } from "./implementation/account-router.js";
|
|
@@ -21,10 +21,12 @@ export { router, dynamicRouter, withApprovals, type RouterDeclaration, type Rout
|
|
|
21
21
|
export type { RouterIcon } from "./contracts/router.js";
|
|
22
22
|
export { dynamicSkills } from "./implementation/dynamic-skills.js";
|
|
23
23
|
export type { HostedTool as OperationDescription } from "./contracts/host.js";
|
|
24
|
+
/** Account fields as app code receives them from a method declared with this schema. */
|
|
25
|
+
type AccountFields<S> = S extends ObjectSchema<infer F> ? SecretFields<F> : SecretObject<Infer<S>>;
|
|
24
26
|
/** A secrets declaration inferred from an author schema. */
|
|
25
|
-
export type SecretsMethod<Shape extends ObjectSchema<Fields>> = NativeSecretsMethod<EffectSchema.Decoder<
|
|
27
|
+
export type SecretsMethod<Shape extends ObjectSchema<Fields>> = NativeSecretsMethod<EffectSchema.Decoder<AccountFields<Shape>>>;
|
|
26
28
|
/** An OAuth declaration inferred from its author-facing response schema. */
|
|
27
|
-
export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAuth2Method<EffectSchema.Decoder<
|
|
29
|
+
export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAuth2Method<EffectSchema.Decoder<AccountFields<Response>>>;
|
|
28
30
|
/** Default OAuth fields visible to app code. Host-only grants and clients stay private. */
|
|
29
31
|
export declare const OAuth2AccessToken: Schema<{
|
|
30
32
|
readonly access_token: string;
|