apps 0.0.1-beta.14 → 0.0.1-beta.16

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.
@@ -0,0 +1,89 @@
1
+ /** OAuth declarations frozen for host protocols 1 through 5. */
2
+ import { Schema } from "effect";
3
+ /** How an OAuth client authenticates at the token endpoint; raw Basic is an explicit provider compatibility option. */
4
+ export declare const OAuthClientAuth: Schema.Literals<readonly ["none", "client_secret_post", "client_secret_basic", "client_secret_basic_raw"]>;
5
+ export type OAuthClientAuth = typeof OAuthClientAuth.Type;
6
+ /** Machine clients always authenticate; public clients cannot use the client-credentials grant. */
7
+ export declare const OAuthSecretClientAuth: Schema.Literals<readonly ["client_secret_post", "client_secret_basic", "client_secret_basic_raw"]>;
8
+ /** Parameters the host sets on every authorization request; a declaration cannot replace them. */
9
+ export declare const reservedAuthorizationParams: readonly ["response_type", "client_id", "redirect_uri", "state", "scope", "code_challenge", "code_challenge_method", "nonce", "resource", "request", "request_uri"];
10
+ /** A protocol parameter only the host sets on the authorization request. */
11
+ export type ReservedAuthorizationParam = (typeof reservedAuthorizationParams)[number];
12
+ /**
13
+ * Extra authorization request parameters, such as `access_type: "offline"`. RFC 6749 §3.1
14
+ * lets services define their own; the protocol and security parameters stay host-owned.
15
+ */
16
+ export declare const OAuthAuthorizationParams: Schema.$Record<Schema.String, Schema.String>;
17
+ /** How the token endpoint reads requests. RFC 6749 uses a form; some services want JSON. */
18
+ export declare const OAuthTokenRequestFormat: Schema.Literals<readonly ["form", "json"]>;
19
+ export type OAuthTokenRequestFormat = typeof OAuthTokenRequestFormat.Type;
20
+ /**
21
+ * Where a service nests the grant in its token response, as a dot-separated member path. Slack
22
+ * returns a user token under `authed_user`.
23
+ */
24
+ export declare const OAuthTokenResponse: Schema.Struct<{
25
+ readonly path: Schema.String;
26
+ }>;
27
+ export type OAuthTokenResponse = typeof OAuthTokenResponse.Type;
28
+ /**
29
+ * OAuth endpoints and protocol choices. Omitted grant means authorization code; clients remain
30
+ * host-owned. Declared endpoints may name an RFC 7009 `revocationUrl`; discovery reads the
31
+ * server's `revocation_endpoint` metadata instead.
32
+ */
33
+ export declare const OAuth2Config: Schema.Union<readonly [Schema.Struct<{
34
+ readonly discover: Schema.String;
35
+ readonly authorizationUrl: Schema.optionalKey<Schema.Never>;
36
+ readonly tokenUrl: Schema.optionalKey<Schema.Never>;
37
+ readonly revocationUrl: Schema.optionalKey<Schema.Never>;
38
+ readonly scopes: Schema.optionalKey<Schema.$Array<Schema.String>>;
39
+ readonly tokenResponse: Schema.optionalKey<Schema.Struct<{
40
+ readonly path: Schema.String;
41
+ }>>;
42
+ readonly grant: Schema.optionalKey<Schema.Literal<"authorization_code">>;
43
+ readonly authorizationParams: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
44
+ readonly tokenEndpointAuthMethod: Schema.optionalKey<Schema.Literals<readonly ["none", "client_secret_post", "client_secret_basic", "client_secret_basic_raw"]>>;
45
+ readonly resource: Schema.optionalKey<Schema.NullOr<Schema.String>>;
46
+ readonly scopeSeparator: Schema.optionalKey<Schema.String>;
47
+ readonly tokenRequestFormat: Schema.optionalKey<Schema.Literals<readonly ["form", "json"]>>;
48
+ }>, Schema.Struct<{
49
+ /** Its query is kept; it cannot set protocol parameters or repeat `authorizationParams`. */
50
+ readonly authorizationUrl: Schema.String;
51
+ readonly tokenUrl: Schema.String;
52
+ readonly revocationUrl: Schema.optionalKey<Schema.String>;
53
+ readonly scopes: Schema.$Array<Schema.String>;
54
+ /** RFC 8414 issuer identifier. Declared issuers are checked against the callback's `iss`. */
55
+ readonly issuer: Schema.optionalKey<Schema.String>;
56
+ readonly discover: Schema.optionalKey<Schema.Never>;
57
+ readonly tokenResponse: Schema.optionalKey<Schema.Struct<{
58
+ readonly path: Schema.String;
59
+ }>>;
60
+ readonly grant: Schema.optionalKey<Schema.Literal<"authorization_code">>;
61
+ readonly authorizationParams: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
62
+ readonly tokenEndpointAuthMethod: Schema.optionalKey<Schema.Literals<readonly ["none", "client_secret_post", "client_secret_basic", "client_secret_basic_raw"]>>;
63
+ readonly resource: Schema.optionalKey<Schema.NullOr<Schema.String>>;
64
+ readonly scopeSeparator: Schema.optionalKey<Schema.String>;
65
+ readonly tokenRequestFormat: Schema.optionalKey<Schema.Literals<readonly ["form", "json"]>>;
66
+ }>, Schema.Struct<{
67
+ readonly tokenEndpointAuthMethod: Schema.Literals<readonly ["client_secret_post", "client_secret_basic", "client_secret_basic_raw"]>;
68
+ readonly resource: Schema.optionalKey<Schema.NullOr<Schema.String>>;
69
+ readonly scopeSeparator: Schema.optionalKey<Schema.String>;
70
+ readonly tokenRequestFormat: Schema.optionalKey<Schema.Literals<readonly ["form", "json"]>>;
71
+ readonly grant: Schema.Literal<"client_credentials">;
72
+ readonly discover: Schema.String;
73
+ readonly authorizationUrl: Schema.optionalKey<Schema.Never>;
74
+ readonly tokenUrl: Schema.optionalKey<Schema.Never>;
75
+ readonly revocationUrl: Schema.optionalKey<Schema.Never>;
76
+ readonly scopes: Schema.optionalKey<Schema.$Array<Schema.String>>;
77
+ }>, Schema.Struct<{
78
+ readonly tokenEndpointAuthMethod: Schema.Literals<readonly ["client_secret_post", "client_secret_basic", "client_secret_basic_raw"]>;
79
+ readonly resource: Schema.optionalKey<Schema.NullOr<Schema.String>>;
80
+ readonly authorizationUrl: Schema.optionalKey<Schema.Never>;
81
+ readonly discover: Schema.optionalKey<Schema.Never>;
82
+ readonly scopeSeparator: Schema.optionalKey<Schema.String>;
83
+ readonly tokenRequestFormat: Schema.optionalKey<Schema.Literals<readonly ["form", "json"]>>;
84
+ readonly grant: Schema.Literal<"client_credentials">;
85
+ readonly tokenUrl: Schema.String;
86
+ readonly revocationUrl: Schema.optionalKey<Schema.String>;
87
+ readonly scopes: Schema.$Array<Schema.String>;
88
+ }>]>;
89
+ export type OAuth2Config = typeof OAuth2Config.Type;
@@ -42,6 +42,8 @@ export type OAuthTokenResponse = typeof OAuthTokenResponse.Type;
42
42
  */
43
43
  export declare const OAuth2Config: Schema.Union<readonly [Schema.Struct<{
44
44
  readonly discover: Schema.String;
45
+ /** Fetch this exact metadata document and verify its issuer against discovery. */
46
+ readonly authorizationServerMetadataUrl: Schema.optionalKey<Schema.String>;
45
47
  readonly authorizationUrl: Schema.optionalKey<Schema.Never>;
46
48
  readonly tokenUrl: Schema.optionalKey<Schema.Never>;
47
49
  readonly revocationUrl: Schema.optionalKey<Schema.Never>;
@@ -64,6 +66,7 @@ export declare const OAuth2Config: Schema.Union<readonly [Schema.Struct<{
64
66
  /** RFC 8414 issuer identifier. Declared issuers are checked against the callback's `iss`. */
65
67
  readonly issuer: Schema.optionalKey<Schema.String>;
66
68
  readonly discover: Schema.optionalKey<Schema.Never>;
69
+ readonly authorizationServerMetadataUrl: Schema.optionalKey<Schema.Never>;
67
70
  readonly tokenResponse: Schema.optionalKey<Schema.Struct<{
68
71
  readonly path: Schema.String;
69
72
  }>>;
@@ -80,6 +83,8 @@ export declare const OAuth2Config: Schema.Union<readonly [Schema.Struct<{
80
83
  readonly tokenRequestFormat: Schema.optionalKey<Schema.Literals<readonly ["form", "json"]>>;
81
84
  readonly grant: Schema.Literal<"client_credentials">;
82
85
  readonly discover: Schema.String;
86
+ /** Fetch this exact metadata document and verify its issuer against discovery. */
87
+ readonly authorizationServerMetadataUrl: Schema.optionalKey<Schema.String>;
83
88
  readonly authorizationUrl: Schema.optionalKey<Schema.Never>;
84
89
  readonly tokenUrl: Schema.optionalKey<Schema.Never>;
85
90
  readonly revocationUrl: Schema.optionalKey<Schema.Never>;
@@ -89,6 +94,7 @@ export declare const OAuth2Config: Schema.Union<readonly [Schema.Struct<{
89
94
  readonly resource: Schema.optionalKey<Schema.NullOr<Schema.String>>;
90
95
  readonly authorizationUrl: Schema.optionalKey<Schema.Never>;
91
96
  readonly discover: Schema.optionalKey<Schema.Never>;
97
+ readonly authorizationServerMetadataUrl: Schema.optionalKey<Schema.Never>;
92
98
  readonly scopeSeparator: Schema.optionalKey<Schema.String>;
93
99
  readonly tokenRequestFormat: Schema.optionalKey<Schema.Literals<readonly ["form", "json"]>>;
94
100
  readonly grant: Schema.Literal<"client_credentials">;
@@ -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,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>;
@@ -17,7 +17,7 @@ export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Sche
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";
@@ -72,7 +72,7 @@ export { NotImplemented } from "./contracts/app.js";
72
72
  export { ElicitationFailed, type FormElicitation, type ElicitationResponse, type Elicit, } from "./contracts/elicitation.js";
73
73
  export { table, defineDatabase, type Table, type DatabaseReader, type Database, type DatabaseDefinition, } from "./implementation/storage.js";
74
74
  export { id, userId } from "./implementation/schema.js";
75
- export { query, mutation, withApproval, type Operation, type OperationOptions, } from "./implementation/operations.js";
75
+ export { query, mutation, withApproval, toolAnnotations, type Operation, type OperationOptions, } from "./implementation/operations.js";
76
76
  export type { OperationContext } from "./contracts/operations.js";
77
77
  export { workflow, type Workflow, type WorkflowDeclaration } from "./implementation/workflows.js";
78
78
  export { NonRetryableError, WorkflowFailure, type WorkflowContext, type WorkflowStepContext, type WorkflowStep, type WorkflowStepOptions, type WorkflowDuration, type WorkflowReads, type WorkflowControls, } from "./contracts/workflows.js";