apps 0.0.1-beta.15 → 0.0.1-beta.17
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-YHLXXXKH.js → chunk-7H44SOSX.js} +4 -4
- package/js/{chunk-H34RQANV.js → chunk-F2IASQK2.js} +3 -3
- package/js/{chunk-4J3IQXFD.js → chunk-HQY4UTYX.js} +2 -2
- package/js/{chunk-GKHJITGG.js → chunk-MAF4BRQF.js} +2 -2
- package/js/{chunk-SWXGYMUW.js → chunk-NMKHTJOQ.js} +52 -7
- package/js/{chunk-CL3O2NIN.js → chunk-VXWY44LE.js} +91 -7
- package/js/{chunk-O5G3NDEO.js → chunk-XNCYIB4D.js} +3 -3
- package/js/{chunk-JAKBOQ5T.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 +37 -8
- 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/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/implementation/elicitation.d.ts +1 -1
- package/types/apps/src/implementation/openapi-compile.d.ts +2 -2
- package/types/apps/src/implementation/operations.d.ts +10 -0
- package/types/apps/src/implementation/provider.d.ts +11 -2
- package/types/apps/src/implementation/router.d.ts +9 -0
- package/types/apps/src/implementation/schema.d.ts +39 -0
- package/types/apps/src/index.d.ts +8 -6
|
@@ -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.
|
|
@@ -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
|
};
|
|
@@ -79,8 +79,18 @@ export declare const operationOptions: <Input, Output>(options: OperationOptions
|
|
|
79
79
|
title?: string;
|
|
80
80
|
description?: string;
|
|
81
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;
|
|
82
87
|
/** Attach the same approval function to a generated or shared operation. */
|
|
83
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;
|
|
84
94
|
/** Read operation. External reads are allowed; only database writes are mechanically prohibited. */
|
|
85
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>;
|
|
86
96
|
/** Explicit write operation. Database writes roll back on failure; external effects cannot be undone. */
|
|
@@ -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
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HostedTool } from "../contracts/host.js";
|
|
2
2
|
import type { AppOperation } from "../contracts/operations.js";
|
|
3
3
|
import { RouterMeta, type AppRouter, type DynamicRouter, type RouterIcon } from "../contracts/router.js";
|
|
4
|
+
import type { Approval } from "../approval.js";
|
|
4
5
|
import { type OperationDeclaration, type RouterChild, type RouterDeclaration } from "./operations.js";
|
|
5
6
|
export type { RouterChild, RouterDeclaration } from "./operations.js";
|
|
6
7
|
/** Author metadata for a router. Instructions become a skill named after the router's path. */
|
|
@@ -57,3 +58,11 @@ export declare const declaredOperations: (root: AppRouter | undefined, path?: st
|
|
|
57
58
|
readonly router: string;
|
|
58
59
|
readonly operation: AppOperation;
|
|
59
60
|
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Choose an approval for each operation a router contains, including tools a dynamic router
|
|
63
|
+
* resolves later. `policy` receives the operation and its name relative to this router; returning
|
|
64
|
+
* undefined keeps the operation's own approval. Read hints with `toolAnnotations(operation)`.
|
|
65
|
+
* Apply it to each account's router before `accountRouter` combines them, so every account keeps
|
|
66
|
+
* its own tools' hints.
|
|
67
|
+
*/
|
|
68
|
+
export declare const withApprovals: <Query, Mutation>(source: RouterDeclaration<Query, Mutation>, policy: (operation: OperationDeclaration<"query" | "mutation", never>, name: string) => Approval | undefined) => RouterDeclaration<Query, Mutation>;
|
|
@@ -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;
|
|
@@ -11,20 +11,22 @@ 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";
|
|
20
|
-
export { router, dynamicRouter, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
|
|
20
|
+
export { router, dynamicRouter, withApprovals, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
|
|
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;
|
|
@@ -72,7 +74,7 @@ export { NotImplemented } from "./contracts/app.js";
|
|
|
72
74
|
export { ElicitationFailed, type FormElicitation, type ElicitationResponse, type Elicit, } from "./contracts/elicitation.js";
|
|
73
75
|
export { table, defineDatabase, type Table, type DatabaseReader, type Database, type DatabaseDefinition, } from "./implementation/storage.js";
|
|
74
76
|
export { id, userId } from "./implementation/schema.js";
|
|
75
|
-
export { query, mutation, withApproval, type Operation, type OperationOptions, } from "./implementation/operations.js";
|
|
77
|
+
export { query, mutation, withApproval, toolAnnotations, type Operation, type OperationOptions, } from "./implementation/operations.js";
|
|
76
78
|
export type { OperationContext } from "./contracts/operations.js";
|
|
77
79
|
export { workflow, type Workflow, type WorkflowDeclaration } from "./implementation/workflows.js";
|
|
78
80
|
export { NonRetryableError, WorkflowFailure, type WorkflowContext, type WorkflowStepContext, type WorkflowStep, type WorkflowStepOptions, type WorkflowDuration, type WorkflowReads, type WorkflowControls, } from "./contracts/workflows.js";
|