apps 0.0.1-beta.6 → 0.0.1-beta.8
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-ECQFRCH4.js → chunk-72JNVHPK.js} +2 -2
- package/js/{chunk-ITM77QPO.js → chunk-CMYUWAX7.js} +3 -3
- package/js/{chunk-MNMNLXBL.js → chunk-FL2QR3XW.js} +2 -2
- package/js/{chunk-6BSSI67S.js → chunk-OCYUEU47.js} +2 -2
- package/js/{chunk-SB4HEPNJ.js → chunk-UESPOTUI.js} +59 -7
- package/js/{chunk-B3EOZTK3.js → chunk-WLE7WX2U.js} +81 -4
- package/js/{chunk-OE3QQTSB.js → chunk-YXQHV65J.js} +22 -2
- package/js/{chunk-T7GKZBLP.js → chunk-Z5M2LQOZ.js} +1 -1
- package/js/contracts.js +11 -1
- package/js/effect.js +5 -5
- package/js/graphql.js +6 -6
- package/js/host.js +5 -5
- package/js/index.js +13 -22
- package/js/mcp/effect.js +7 -7
- package/js/mcp/stdio.js +7 -7
- package/js/mcp.js +8 -8
- package/js/openapi.js +4 -4
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/apps/src/contracts/host.d.ts +10 -2
- package/types/apps/src/contracts/protocol-version.d.ts +1 -1
- package/types/apps/src/contracts/protocols/5.d.ts +1090 -0
- package/types/apps/src/contracts/provider.d.ts +51 -5
- package/types/apps/src/implementation/provider.d.ts +9 -4
- package/types/apps/src/index.d.ts +2 -2
- package/types/telemetry/src/browser-operations.d.ts +5 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Provider declarations use native Effect schemas. The trusted host interprets them. */
|
|
2
|
-
import { Data, Schema } from "effect";
|
|
2
|
+
import { Data, type Effect, Schema } from "effect";
|
|
3
3
|
import { type AccountId } from "./schema.js";
|
|
4
4
|
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
5
|
readonly _tag: "secrets";
|
|
@@ -84,10 +84,54 @@ export declare class OAuth2Method<Response extends Schema.Decoder<unknown>> exte
|
|
|
84
84
|
export type AuthMethod = SecretsMethod<Schema.Decoder<unknown>> | OAuth2Method<Schema.Decoder<unknown>>;
|
|
85
85
|
/** Auth method names are chosen by the provider author. */
|
|
86
86
|
export type AuthMethods = Readonly<Record<string, AuthMethod>>;
|
|
87
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Upstream identity that a passing account check may report for display. Only these fields are
|
|
89
|
+
* retained; the host never stores raw provider responses.
|
|
90
|
+
*/
|
|
91
|
+
export declare const AccountInfo: Schema.Struct<{
|
|
92
|
+
readonly externalId: Schema.optionalKey<Schema.String>;
|
|
93
|
+
readonly displayName: Schema.optionalKey<Schema.String>;
|
|
94
|
+
readonly username: Schema.optionalKey<Schema.String>;
|
|
95
|
+
readonly email: Schema.optionalKey<Schema.String>;
|
|
96
|
+
readonly avatarUrl: Schema.optionalKey<Schema.String>;
|
|
97
|
+
readonly profileUrl: Schema.optionalKey<Schema.String>;
|
|
98
|
+
}>;
|
|
99
|
+
export type AccountInfo = typeof AccountInfo.Type;
|
|
100
|
+
/** A passing account check. Failures are thrown, so there is no failing variant. */
|
|
101
|
+
export declare const AccountCheckResult: Schema.Struct<{
|
|
102
|
+
readonly accountInfo: Schema.optionalKey<Schema.Struct<{
|
|
103
|
+
readonly externalId: Schema.optionalKey<Schema.String>;
|
|
104
|
+
readonly displayName: Schema.optionalKey<Schema.String>;
|
|
105
|
+
readonly username: Schema.optionalKey<Schema.String>;
|
|
106
|
+
readonly email: Schema.optionalKey<Schema.String>;
|
|
107
|
+
readonly avatarUrl: Schema.optionalKey<Schema.String>;
|
|
108
|
+
readonly profileUrl: Schema.optionalKey<Schema.String>;
|
|
109
|
+
}>>;
|
|
110
|
+
}>;
|
|
111
|
+
export type AccountCheckResult = typeof AccountCheckResult.Type;
|
|
112
|
+
/** The account a provider's check verifies, with invocation-owned HTTP and cancellation. */
|
|
113
|
+
export interface AccountCheckContext<Auth extends AuthMethods> {
|
|
114
|
+
readonly account: AccountOfMethods<Auth>;
|
|
115
|
+
readonly fetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
116
|
+
readonly signal: AbortSignal;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A safe authenticated read proving the account works for this app. Returning passes; a thrown
|
|
120
|
+
* `ProviderError` or HTTP status failure classifies the problem. Any other failure, including a
|
|
121
|
+
* timeout, means the check could not verify the account, not that its credentials are bad.
|
|
122
|
+
*/
|
|
123
|
+
export interface AccountCheck<Auth extends AuthMethods> {
|
|
124
|
+
run(context: AccountCheckContext<Auth>): Effect.Effect<AccountCheckResult | void, unknown>;
|
|
125
|
+
}
|
|
126
|
+
/** A provider declaration. The host derives its identity from the declaration, never its check. */
|
|
88
127
|
export declare class Provider<Auth extends AuthMethods> extends Data.Class<{
|
|
89
128
|
readonly name: string;
|
|
90
129
|
readonly auth: Auth;
|
|
130
|
+
/**
|
|
131
|
+
* Stored without its method types so a specific provider still fills a general slot. The host
|
|
132
|
+
* binds the account against this provider's methods before running it.
|
|
133
|
+
*/
|
|
134
|
+
readonly health?: AccountCheck<AuthMethods>;
|
|
91
135
|
}> {
|
|
92
136
|
/** Declare zero or more accounts from this provider without performing I/O. */
|
|
93
137
|
many(): ManyAccounts<Auth>;
|
|
@@ -102,12 +146,14 @@ export declare class ManyAccounts<Auth extends AuthMethods> extends ManyAccounts
|
|
|
102
146
|
}
|
|
103
147
|
/** Infer the data for one method from its native Effect decoder. */
|
|
104
148
|
export type AuthMethodData<Method> = Method extends SecretsMethod<infer Fields> ? Fields["Type"] : Method extends OAuth2Method<infer Response> ? Response["Type"] : never;
|
|
105
|
-
/** One
|
|
106
|
-
export type
|
|
149
|
+
/** One account for these methods, discriminated by its author-chosen method name. */
|
|
150
|
+
export type AccountOfMethods<Auth extends AuthMethods> = {
|
|
107
151
|
readonly [Method in keyof Auth & string]: {
|
|
108
152
|
readonly id: AccountId;
|
|
109
153
|
readonly method: Method;
|
|
110
154
|
readonly fields: AuthMethodData<Auth[Method]>;
|
|
111
155
|
};
|
|
112
|
-
}[keyof Auth & string]
|
|
156
|
+
}[keyof Auth & string];
|
|
157
|
+
/** One selected account, discriminated by its author-chosen method name. */
|
|
158
|
+
export type AccountOf<P> = P extends Provider<infer Auth> ? AccountOfMethods<Auth> : never;
|
|
113
159
|
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>;
|
|
@@ -14,8 +14,8 @@ import { type PromiseMethods } from "./implementation/authoring.js";
|
|
|
14
14
|
import { type Fields, type Infer, type ObjectSchema, type Schema } from "./implementation/schema.js";
|
|
15
15
|
export { type JsonObject, type JsonValue, ValidationError } from "./contracts/schema.js";
|
|
16
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";
|
|
17
|
-
export { type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type OAuth2Config, type Provider, } from "./contracts/provider.js";
|
|
18
|
-
export { defineProvider } from "./implementation/provider.js";
|
|
17
|
+
export { type AccountCheckContext, type AccountCheckResult, type AccountInfo, type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type OAuth2Config, type Provider, } from "./contracts/provider.js";
|
|
18
|
+
export { defineProvider, type ProviderOptions } from "./implementation/provider.js";
|
|
19
19
|
export { accountRouter } from "./implementation/account-router.js";
|
|
20
20
|
export { router, dynamicRouter, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
|
|
21
21
|
export type { RouterIcon } from "./contracts/router.js";
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/** Correlate transport and decoded outcomes without exporting response bodies or errors. */
|
|
2
2
|
import { Effect, Schema, Tracer } from "effect";
|
|
3
3
|
import { HttpClient, HttpClientError } from "effect/unstable/http";
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* A random identity for the current browser document. It is never an authentication or user
|
|
6
|
+
* identifier. Server renders have no document, so they get none instead of sharing one per isolate.
|
|
7
|
+
*/
|
|
8
|
+
export declare const browserPageId: () => string | undefined;
|
|
6
9
|
/** Safe event shared with the host's error reporter and product analytics. */
|
|
7
10
|
export declare const BrowserOperationFailure: Schema.Struct<{
|
|
8
11
|
readonly error_type: Schema.Literals<readonly ["BrowserDecodeFailed", "BrowserTransportFailed", "BrowserOperationFailed"]>;
|