apps 0.0.1-beta.2 → 0.0.1-beta.21

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.
Files changed (119) hide show
  1. package/README.md +68 -44
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
  4. package/js/{chunk-WFSQXYUT.js → chunk-4QQ62BVS.js} +37 -3
  5. package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
  6. package/js/chunk-625MBYU4.js +524 -0
  7. package/js/{chunk-RN2MXB4R.js → chunk-BLI53LPN.js} +28 -9
  8. package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
  9. package/js/{chunk-J7O55ZV7.js → chunk-CHAK4P5C.js} +317 -176
  10. package/js/{chunk-HDTGZWP2.js → chunk-CMRKLZZY.js} +8 -8
  11. package/js/{chunk-OHRT55C4.js → chunk-IJX4CYZO.js} +3 -6
  12. package/js/{chunk-FDNTX5QJ.js → chunk-IPI4MFSN.js} +2 -2
  13. package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
  14. package/js/chunk-KUMBKVJD.js +39 -0
  15. package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
  16. package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
  17. package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
  18. package/js/{chunk-D47C7KG5.js → chunk-NKLWZJLE.js} +2 -2
  19. package/js/chunk-NMKHTJOQ.js +254 -0
  20. package/js/chunk-OD3KFKZD.js +1617 -0
  21. package/js/{chunk-ZCAMUXSG.js → chunk-ODEIDRGW.js} +3 -4
  22. package/js/{chunk-5MQZEB6Y.js → chunk-OZ4UK3CD.js} +37 -12
  23. package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
  24. package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
  25. package/js/{chunk-LGIYBDWA.js → chunk-R3EV5FTO.js} +13 -1
  26. package/js/{chunk-Z5NMEGJN.js → chunk-RAAPJMVZ.js} +21 -9
  27. package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
  28. package/js/{chunk-4LPG6RCH.js → chunk-VFZKSM3T.js} +5 -25
  29. package/js/{chunk-MYYEW3RA.js → chunk-VXWY44LE.js} +780 -55
  30. package/js/{chunk-JN55AYQH.js → chunk-XNCYIB4D.js} +61 -32
  31. package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
  32. package/js/client.js +10 -26
  33. package/js/contracts.js +74 -16
  34. package/js/effect.js +19 -20
  35. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  36. package/js/graphql.js +47 -49
  37. package/js/host.js +19 -20
  38. package/js/index.js +232 -201
  39. package/js/mcp/effect.js +21 -22
  40. package/js/mcp/stdio.js +25 -26
  41. package/js/mcp.js +74 -56
  42. package/js/openapi.js +3428 -1276
  43. package/js/react.js +3 -3
  44. package/js/skills/effect.js +3 -3
  45. package/js/skills.js +12 -13
  46. package/js/storage/facet.js +4 -4
  47. package/js/ui/auth/contracts.js +8 -9
  48. package/js/ui/auth.js +16 -14
  49. package/js/ui/contracts.js +4 -4
  50. package/js/ui/serving.js +71 -218
  51. package/package.json +1 -1
  52. package/runtime.json +1 -1
  53. package/types/app-data/src/contracts/database.d.ts +33 -6
  54. package/types/app-data/src/implementation/schema.d.ts +2 -17
  55. package/types/apps/src/contracts/app.d.ts +7 -6
  56. package/types/apps/src/contracts/failure.d.ts +25 -0
  57. package/types/apps/src/contracts/host.d.ts +31 -10
  58. package/types/apps/src/contracts/mcp.d.ts +16 -0
  59. package/types/apps/src/contracts/openapi.d.ts +5 -1
  60. package/types/apps/src/contracts/operations.d.ts +0 -5
  61. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  62. package/types/apps/src/contracts/protocols/1.d.ts +235 -67
  63. package/types/apps/src/contracts/protocols/2.d.ts +710 -0
  64. package/types/apps/src/contracts/protocols/3.d.ts +718 -0
  65. package/types/apps/src/contracts/protocols/4.d.ts +1299 -0
  66. package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
  67. package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
  68. package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
  69. package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
  70. package/types/apps/src/contracts/provider.d.ts +109 -10
  71. package/types/apps/src/contracts/router.d.ts +59 -0
  72. package/types/apps/src/contracts/storage.d.ts +3 -3
  73. package/types/apps/src/contracts/ui-auth.d.ts +6 -14
  74. package/types/apps/src/contracts/ui.d.ts +18 -0
  75. package/types/apps/src/contracts/workflows.d.ts +34 -3
  76. package/types/apps/src/graphql.d.ts +1 -3
  77. package/types/apps/src/implementation/account-router.d.ts +12 -0
  78. package/types/apps/src/implementation/app.d.ts +5 -4
  79. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  80. package/types/apps/src/implementation/catalog-cache.d.ts +34 -4
  81. package/types/apps/src/implementation/elicitation.d.ts +2 -2
  82. package/types/apps/src/implementation/failure-detail.d.ts +26 -0
  83. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  84. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  85. package/types/apps/src/implementation/mcp-client.d.ts +35 -19
  86. package/types/apps/src/implementation/mcp.d.ts +35 -19
  87. package/types/apps/src/implementation/openapi-compile.d.ts +9 -5
  88. package/types/apps/src/implementation/openapi-document.d.ts +15 -2
  89. package/types/apps/src/implementation/openapi-request.d.ts +8 -1
  90. package/types/apps/src/implementation/openapi-source.d.ts +2 -6
  91. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  92. package/types/apps/src/implementation/operations.d.ts +36 -3
  93. package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
  94. package/types/apps/src/implementation/provider.d.ts +19 -5
  95. package/types/apps/src/implementation/router-catalog.d.ts +225 -0
  96. package/types/apps/src/implementation/router.d.ts +68 -0
  97. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  98. package/types/apps/src/implementation/schema.d.ts +44 -1
  99. package/types/apps/src/implementation/storage.d.ts +5 -3
  100. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  101. package/types/apps/src/implementation/ui-auth.d.ts +11 -5
  102. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  103. package/types/apps/src/implementation/ui-serving.d.ts +10 -4
  104. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  105. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  106. package/types/apps/src/implementation/workflow-context.d.ts +11 -3
  107. package/types/apps/src/index.d.ts +28 -11
  108. package/types/apps/src/mcp-stdio.d.ts +2 -5
  109. package/types/apps/src/mcp.d.ts +5 -4
  110. package/types/apps/src/openapi.d.ts +6 -6
  111. package/types/apps/src/ui-auth.d.ts +2 -2
  112. package/types/telemetry/src/browser-operations.d.ts +5 -2
  113. package/js/chunk-PYUYJRSK.js +0 -93
  114. package/js/chunk-SWPD52J7.js +0 -35
  115. package/js/chunk-TE4KO4HI.js +0 -47
  116. package/js/chunk-W7D7WVSY.js +0 -18
  117. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  118. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  119. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
@@ -1,8 +1,8 @@
1
1
  import { Duration, Effect, Schema } from "effect";
2
2
  import type { AppCache, CacheLoadContext } from "../contracts/cache.js";
3
- import { type JsonValue } from "../contracts/schema.js";
3
+ import { JsonObject, type JsonValue } from "../contracts/schema.js";
4
4
  export interface CatalogCacheOptions {
5
- /** App/build scope, optionally narrowed to the current account. */
5
+ /** The app's cache. An account's catalog is kept in that account's scope. */
6
6
  readonly cache?: AppCache;
7
7
  /** Reuse metadata for this duration. Defaults to five minutes. */
8
8
  readonly freshFor?: Duration.Input;
@@ -11,9 +11,37 @@ export interface CatalogCacheOptions {
11
11
  /** Await a fresh revision at an explicit logical connection or refresh boundary. */
12
12
  readonly revalidate?: boolean;
13
13
  }
14
+ /**
15
+ * Whose catalog a remote router reads. A public server takes neither field. Credential headers
16
+ * come only with the account they belong to, so an authenticated catalog always has its account.
17
+ */
18
+ export type CatalogAccount = {
19
+ readonly account?: undefined;
20
+ readonly headers?: undefined;
21
+ } | {
22
+ /** The selected account, as `accounts.<slot>` provides it. */
23
+ readonly account: {
24
+ readonly id: string;
25
+ };
26
+ /** Headers for this account's requests, such as its credentials. */
27
+ readonly headers?: Readonly<Record<string, string>>;
28
+ };
29
+ /**
30
+ * The cache an account's catalog lives in: the account's own scope, which token renewals keep.
31
+ * Credentials never enter a key. Headers without an account, or an account the app was not
32
+ * given, fail with `invalid`.
33
+ */
34
+ export declare const catalogScope: <E>(options: CatalogCacheOptions & CatalogAccount, invalid: () => E) => Effect.Effect<AppCache | undefined, E>;
35
+ /** One load: the tools, and optionally a record describing the whole catalog. */
36
+ export interface CatalogLoad<A> {
37
+ readonly tools: readonly A[];
38
+ readonly header?: JsonObject;
39
+ }
14
40
  export declare const catalogCache: <A extends {
15
41
  readonly name: string;
16
- }, S>(options: CatalogCacheOptions & {
42
+ }, S>(options: Omit<CatalogCacheOptions, "cache"> & {
43
+ /** The scope from `catalogScope`; undefined keeps discovery invocation-local. */
44
+ readonly cache: AppCache | undefined;
17
45
  readonly prefix: readonly JsonValue[];
18
46
  readonly schema: Schema.Decoder<A>;
19
47
  /** Schema-free projection stored beside the full pages, so browsing never reads schemas. */
@@ -21,9 +49,11 @@ export declare const catalogCache: <A extends {
21
49
  readonly schema: Schema.Decoder<S>;
22
50
  readonly of: (tool: A) => S;
23
51
  };
24
- readonly load: (context?: CacheLoadContext) => Effect.Effect<readonly A[], unknown>;
52
+ readonly load: (context?: CacheLoadContext) => Effect.Effect<CatalogLoad<A>, unknown>;
25
53
  }) => Effect.Effect<{
26
54
  list: () => Effect.Effect<readonly A[], unknown, never>;
55
+ /** The record stored with the current revision, if the source supplied one. */
56
+ header: () => Effect.Effect<JsonObject | undefined, unknown>;
27
57
  summaries: () => Effect.Effect<S[], unknown, never>;
28
58
  resolve: (name: string) => Effect.Effect<A | undefined, unknown, never>;
29
59
  }, unknown, never>;
@@ -58,18 +58,18 @@ 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;
66
66
  } | {
67
67
  readonly type: "number" | "integer";
68
68
  readonly default?: number;
69
+ readonly maximum?: number;
69
70
  readonly description?: string;
70
71
  readonly title?: string;
71
72
  readonly minimum?: number;
72
- readonly maximum?: number;
73
73
  } | {
74
74
  readonly type: "boolean";
75
75
  readonly default?: boolean;
@@ -0,0 +1,26 @@
1
+ import { Redacted } from "effect";
2
+ import type { ResolvedAccounts } from "../contracts/host.js";
3
+ /** Fields of `FailureDetail` as constructor input. */
4
+ export interface FailureDetail {
5
+ readonly source?: "app" | "storage" | "service";
6
+ readonly errorName?: string;
7
+ readonly code?: string;
8
+ readonly message?: string;
9
+ }
10
+ /**
11
+ * Every credential field value of a slot-to-account record, longest first. Accepts both resolved
12
+ * host accounts and bound author accounts; each account keeps its credential values in `fields`.
13
+ */
14
+ export declare const accountFieldSecrets: (accounts: unknown) => string[];
15
+ /** Every credential field value of an invocation's selected accounts. */
16
+ export declare const accountSecrets: (accounts: Redacted.Redacted<ResolvedAccounts>) => string[];
17
+ /** Replace account secrets and bound the message for the runtime boundary. */
18
+ export declare const boundFailureMessage: (message: string, secrets: readonly string[]) => string;
19
+ /** `Name: message` for any thrown value, before redaction. */
20
+ export declare const describeFailure: (error: unknown) => string;
21
+ /**
22
+ * Describe what an operation raised for the app's own caller. App data failures keep their
23
+ * reason as a code, as do app cache failures; any other thrown value is the app's own error.
24
+ * Account secrets are replaced.
25
+ */
26
+ export declare const failureDetail: (error: unknown, secrets: readonly string[]) => FailureDetail;
@@ -1,10 +1,7 @@
1
1
  import { Effect } from "effect";
2
2
  import { GraphqlToolsOptions } from "../contracts/graphql.js";
3
- import type { DynamicTools } from "../contracts/dynamic-tools.js";
4
- import { type CatalogCacheOptions } from "./catalog-cache.js";
3
+ import { type CatalogAccount, type CatalogCacheOptions } from "./catalog-cache.js";
5
4
  import { type OperationKinds } from "./protocol-operations.js";
6
- export interface GraphqlCatalogOptions extends GraphqlToolsOptions, CatalogCacheOptions {
7
- }
8
- export declare const graphqlCatalog: (options: GraphqlCatalogOptions, kinds: OperationKinds) => Effect.Effect<{
9
- dynamicTools: DynamicTools;
10
- }, unknown, never>;
5
+ /** An endpoint, the account whose schema it is, and the metadata policy. */
6
+ export type GraphqlCatalogOptions = Omit<GraphqlToolsOptions, "accountId" | "headers"> & CatalogCacheOptions & CatalogAccount;
7
+ export declare const graphqlCatalog: (options: GraphqlCatalogOptions, kinds: OperationKinds) => Effect.Effect<import("./operations.js").RouterDeclaration<unknown, unknown>, unknown, never>;
@@ -1,12 +1,11 @@
1
1
  import { Effect } from "effect";
2
- import type { DynamicTools } from "../contracts/dynamic-tools.js";
3
2
  import { McpToolsOptions } from "../contracts/mcp.js";
4
- import { type CatalogCacheOptions } from "./catalog-cache.js";
3
+ import { type CatalogAccount, type CatalogCacheOptions } from "./catalog-cache.js";
5
4
  import { type OperationKinds } from "./protocol-operations.js";
6
- /** Metadata policy for HTTP/SSE sources. A missing cache keeps discovery invocation-local. */
7
- export interface McpCatalogOptions extends McpToolsOptions, CatalogCacheOptions {
8
- }
5
+ /**
6
+ * A server, the account whose catalog it is, and the metadata policy for HTTP/SSE sources. A
7
+ * missing cache keeps discovery invocation-local.
8
+ */
9
+ export type McpCatalogOptions = Omit<McpToolsOptions, "accountId" | "headers"> & CatalogCacheOptions & CatalogAccount;
9
10
  /** Construction opens no transport unless explicit revalidation is requested. */
10
- export declare const mcpCatalog: (options: McpCatalogOptions, kinds: OperationKinds) => Effect.Effect<{
11
- dynamicTools: DynamicTools;
12
- }, unknown, never>;
11
+ export declare const mcpCatalog: (options: McpCatalogOptions, kinds: OperationKinds) => Effect.Effect<import("./operations.js").RouterDeclaration<unknown, unknown>, unknown, never>;
@@ -14,26 +14,42 @@ export interface WithMcpClient {
14
14
  /** Shared client operations never cache catalogs or account credentials. */
15
15
  export declare function mcpClient(withClient: WithMcpClient, timeoutMs: number, failure: (phase: McpError["phase"], error: unknown) => McpError | ProviderError): {
16
16
  list: Effect.Effect<{
17
- readonly name: string;
18
- readonly inputSchema: {
19
- readonly [x: string]: Schema.Json;
20
- };
21
- readonly description?: string | undefined;
22
- readonly _meta?: {
23
- readonly [x: string]: Schema.Json;
24
- } | undefined;
25
- readonly title?: string | undefined;
26
- readonly outputSchema?: {
27
- readonly [x: string]: Schema.Json;
28
- } | undefined;
29
- readonly annotations?: {
17
+ tools: {
18
+ readonly name: string;
19
+ readonly inputSchema: {
20
+ readonly [x: string]: Schema.Json;
21
+ };
22
+ readonly description?: string | undefined;
23
+ readonly _meta?: {
24
+ readonly [x: string]: Schema.Json;
25
+ } | undefined;
26
+ readonly title?: string | undefined;
27
+ readonly annotations?: {
28
+ readonly title?: string;
29
+ readonly readOnlyHint?: boolean;
30
+ readonly destructiveHint?: boolean;
31
+ readonly idempotentHint?: boolean;
32
+ readonly openWorldHint?: boolean;
33
+ } | undefined;
34
+ readonly outputSchema?: {
35
+ readonly [x: string]: Schema.Json;
36
+ } | undefined;
37
+ }[];
38
+ server: {
39
+ readonly version?: string;
40
+ readonly name?: string;
41
+ readonly description?: string;
30
42
  readonly title?: string;
31
- readonly readOnlyHint?: boolean;
32
- readonly destructiveHint?: boolean;
33
- readonly idempotentHint?: boolean;
34
- readonly openWorldHint?: boolean;
35
- } | undefined;
36
- }[], ProviderError | McpError, never>;
43
+ readonly instructions?: string;
44
+ readonly icons?: readonly {
45
+ readonly src: string;
46
+ readonly mimeType?: string;
47
+ readonly sizes?: readonly string[];
48
+ readonly theme?: "light" | "dark";
49
+ }[];
50
+ readonly websiteUrl?: string;
51
+ } | {};
52
+ }, ProviderError | McpError, never>;
37
53
  call: (name: string, input: JsonObject, context: McpToolContext) => Effect.Effect<{
38
54
  readonly content: readonly {
39
55
  readonly [x: string]: Schema.Json;
@@ -4,26 +4,42 @@ import { McpError, McpToolsOptions } from "../contracts/mcp.js";
4
4
  /** Discover and call with a fresh selected-account transport for each operation. */
5
5
  export declare const mcpClientEffect: (input: McpToolsOptions, changed?: Effect.Effect<void, unknown>) => Effect.Effect<{
6
6
  list: Effect.Effect<{
7
- readonly name: string;
8
- readonly inputSchema: {
9
- readonly [x: string]: Schema.Json;
10
- };
11
- readonly description?: string | undefined;
12
- readonly _meta?: {
13
- readonly [x: string]: Schema.Json;
14
- } | undefined;
15
- readonly title?: string | undefined;
16
- readonly outputSchema?: {
17
- readonly [x: string]: Schema.Json;
18
- } | undefined;
19
- readonly annotations?: {
7
+ tools: {
8
+ readonly name: string;
9
+ readonly inputSchema: {
10
+ readonly [x: string]: Schema.Json;
11
+ };
12
+ readonly description?: string | undefined;
13
+ readonly _meta?: {
14
+ readonly [x: string]: Schema.Json;
15
+ } | undefined;
16
+ readonly title?: string | undefined;
17
+ readonly annotations?: {
18
+ readonly title?: string;
19
+ readonly readOnlyHint?: boolean;
20
+ readonly destructiveHint?: boolean;
21
+ readonly idempotentHint?: boolean;
22
+ readonly openWorldHint?: boolean;
23
+ } | undefined;
24
+ readonly outputSchema?: {
25
+ readonly [x: string]: Schema.Json;
26
+ } | undefined;
27
+ }[];
28
+ server: {
29
+ readonly version?: string;
30
+ readonly name?: string;
31
+ readonly description?: string;
20
32
  readonly title?: string;
21
- readonly readOnlyHint?: boolean;
22
- readonly destructiveHint?: boolean;
23
- readonly idempotentHint?: boolean;
24
- readonly openWorldHint?: boolean;
25
- } | undefined;
26
- }[], ProviderError | McpError, never>;
33
+ readonly instructions?: string;
34
+ readonly icons?: readonly {
35
+ readonly src: string;
36
+ readonly mimeType?: string;
37
+ readonly sizes?: readonly string[];
38
+ readonly theme?: "light" | "dark";
39
+ }[];
40
+ readonly websiteUrl?: string;
41
+ } | {};
42
+ }, ProviderError | McpError, never>;
27
43
  call: (name: string, input: import("../index.js").JsonObject, context: import("../mcp.js").McpToolContext) => Effect.Effect<{
28
44
  readonly content: readonly {
29
45
  readonly [x: string]: Schema.Json;
@@ -4,8 +4,11 @@ import { JsonObject } from "../contracts/schema.js";
4
4
  import { OpenapiCompileError as TemplateError } from "../contracts/openapi-compile.js";
5
5
  import type { OpenApiImport } from "../contracts/openapi-document.js";
6
6
  import { type GeneratedOperation, type GeneratedSecrets } from "../contracts/openapi-document.js";
7
- /** Compile a revision of a live OpenAPI source into tool declarations for the app runtime. */
8
- export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocument: unknown, options?: {
7
+ /** Compile a revision of a live OpenAPI source into tool declarations for the app runtime.
8
+ * The document is consumed: compilation upgrades it in place instead of copying it. It must be a
9
+ * tree, with no object reached twice, as parsed JSON is.
10
+ */
11
+ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocument: JsonObject, options?: {
9
12
  readonly baseUrl?: string;
10
13
  readonly allowedOrigin?: string;
11
14
  readonly securitySchemes?: Readonly<Record<string, JsonObject>>;
@@ -13,8 +16,6 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
13
16
  }) => Effect.Effect<{
14
17
  operations: {
15
18
  readonly name: string;
16
- readonly path: string;
17
- readonly description: string;
18
19
  readonly request: {
19
20
  readonly parameters: readonly {
20
21
  readonly name: string;
@@ -53,10 +54,12 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
53
54
  readonly required?: boolean;
54
55
  };
55
56
  };
57
+ readonly path: string;
58
+ readonly description: string;
56
59
  readonly input: {
57
60
  readonly [x: string]: Schema.Json;
58
61
  };
59
- readonly method: "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
62
+ readonly method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
60
63
  readonly securitySchemes: {
61
64
  readonly [x: string]: {
62
65
  readonly [x: string]: Schema.Json;
@@ -67,6 +70,7 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
67
70
  readonly outputSchema?: {
68
71
  readonly [x: string]: Schema.Json;
69
72
  };
73
+ readonly tags?: readonly string[];
70
74
  readonly operationId?: string;
71
75
  readonly streaming?: true;
72
76
  readonly errorResponses?: readonly {
@@ -1,11 +1,24 @@
1
1
  import { Schema } from "effect";
2
2
  import { JsonObject } from "../contracts/schema.js";
3
- /** Resolve OpenAPI objects once with Swagger; schemas retain their original recursive references.
3
+ /**
4
+ * An object in a document that was validated as JSON when it was read. Compilation only turns JSON
5
+ * into JSON, so inside it an object's shape is checked, not its every leaf again: re-validating
6
+ * whole documents was most of a large API's compile time.
7
+ */
8
+ export declare const DocumentObject: Schema.declare<{
9
+ readonly [x: string]: Schema.Json;
10
+ }, {
11
+ readonly [x: string]: Schema.Json;
12
+ }>;
13
+ export declare const documentObject: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => {
14
+ readonly [x: string]: Schema.Json;
15
+ };
16
+ /** Resolve OpenAPI objects once; schemas retain their original recursive references.
4
17
  * Scalar first upgrades Swagger 2.0 and OpenAPI 3.0 to 3.1, so the importer has one dialect and
5
18
  * 3.1 keywords that appear in 3.0 documents keep their meaning.
6
19
  * Unsupported versions, references and conversions throw TemplateError at the import boundary.
7
20
  */
8
- export declare function openApiDocument(input: unknown): Promise<{
21
+ export declare function openApiDocument(input: JsonObject): Promise<{
9
22
  spec: {
10
23
  readonly openapi: string;
11
24
  readonly paths: {
@@ -6,12 +6,19 @@ import { OpenapiError, type CredentialBinding, type OpenapiOperation, type Opena
6
6
  type DeclaredError = OpenapiErrorResponse & {
7
7
  readonly decoder: Schema.Decoder<Schema.Json>;
8
8
  };
9
+ /** What decides whether an account can call an operation: its transport and security. */
10
+ export interface OpenapiOperationAccess {
11
+ readonly streaming?: true;
12
+ readonly request: {
13
+ readonly security: OpenapiOperation["request"]["security"];
14
+ };
15
+ }
9
16
  /** Create request helpers from credential-free generated authentication metadata. */
10
17
  export declare function createRequest(config: {
11
18
  readonly methods: Readonly<Record<string, readonly CredentialBinding[]>>;
12
19
  readonly oauth: readonly string[];
13
20
  }): {
14
- available: (op: OpenapiOperation, account: OpenapiAccount | undefined) => boolean;
21
+ available: (op: OpenapiOperationAccess, account: OpenapiAccount | undefined) => boolean;
15
22
  call: (op: OpenapiOperation, input: unknown, account: OpenapiAccount | undefined, errors: readonly DeclaredError[]) => Effect.Effect<Schema.Json, ProviderError | OpenapiResponseError | OpenapiError, never>;
16
23
  };
17
24
  export {};
@@ -3,8 +3,8 @@ import { Duration } from "effect";
3
3
  import type { AppCache } from "../contracts/cache.js";
4
4
  import { OpenapiOperation, type OpenapiToolsOptions } from "../contracts/openapi.js";
5
5
  import { JsonObject, JsonValue } from "../contracts/schema.js";
6
- import type { DynamicTools } from "../contracts/dynamic-tools.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;
@@ -33,8 +33,4 @@ export interface OpenapiSourceOptions extends Omit<OpenapiToolsOptions, "operati
33
33
  /** JSON-object patches are static app configuration and are reapplied to every revision. */
34
34
  export declare function patchOpenapi(root: JsonObject, patches: OpenapiSourceOptions["patches"]): JsonObject;
35
35
  /** No I/O during app construction. All accounts share credential-free compilation. */
36
- export declare const liveOpenapiOperations: (options: OpenapiSourceOptions) => {
37
- readonly queries: {};
38
- readonly mutations: {};
39
- readonly dynamicTools: DynamicTools;
40
- };
36
+ export declare const liveOpenapiRouter: (options: OpenapiSourceOptions) => RouterDeclaration;
@@ -0,0 +1,4 @@
1
+ type Node = Record<string, unknown>;
2
+ /** Upgrade a 3.0 document the caller owns. Any other version is returned unchanged. */
3
+ export declare const upgradeOpenApi30InPlace: (document: Node) => Node;
4
+ export {};
@@ -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 HandlerContext: unique symbol;
11
- /** A server-only declaration with its category preserved for catalog validation. */
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 [HandlerContext]?: (context: Context) => void;
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> & {
@@ -56,8 +79,18 @@ export declare const operationOptions: <Input, Output>(options: OperationOptions
56
79
  title?: string;
57
80
  description?: string;
58
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;
59
87
  /** Attach the same approval function to a generated or shared operation. */
60
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;
61
94
  /** Read operation. External reads are allowed; only database writes are mechanically prohibited. */
62
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>;
63
96
  /** Explicit write operation. Database writes roll back on failure; external effects cannot be undone. */
@@ -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
- queries: Record<string, Operation<Schema.Json, unknown, "query", OperationContext>>;
22
- mutations: Record<string, Operation<Schema.Json, unknown, "mutation", OperationContext>>;
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,16 +1,30 @@
1
1
  /** Pure constructors over the native provider contracts. */
2
2
  import { Effect, Schema } from "effect";
3
- import { type AuthMethods, OAuth2Config, OAuth2Method, Provider, SecretsMethod } from "../contracts/provider.js";
3
+ import { type PromiseMethod } from "./authoring.js";
4
+ import { type AccountCheck, type AuthMethods, type FieldExposure, 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: {
7
8
  readonly label: string;
8
9
  readonly fields: Fields;
10
+ readonly exposure?: Readonly<Record<string, FieldExposure>>;
9
11
  }) => SecretsMethod<Fields>;
10
12
  /** Validate OAuth endpoints while declaring their app-visible response projection. */
11
- export declare const oauth2: <Response extends Schema.Decoder<unknown>>(config: OAuth2Config, response: Response) => Effect.Effect<OAuth2Method<Response>, ValidationError>;
12
- /** Retain the provider and literal method names without registering or authenticating it. */
13
- export declare const defineProvider: <const Auth extends AuthMethods>(options: {
13
+ export declare const oauth2: <Response extends Schema.Decoder<unknown>>(config: OAuth2Config, response: Response, exposure?: Readonly<Record<string, FieldExposure>>) => Effect.Effect<OAuth2Method<Response>, ValidationError>;
14
+ /** Author options: the account check is an ordinary async function. */
15
+ export interface ProviderOptions<Auth extends AuthMethods> {
14
16
  readonly name: string;
15
17
  readonly auth: Auth;
16
- }) => Provider<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[];
26
+ /** Verify a connected account with a safe read, optionally reporting its upstream identity. */
27
+ readonly health?: PromiseMethod<AccountCheck<Auth>["run"]>;
28
+ }
29
+ /** Retain the provider and literal method names without registering or authenticating it. */
30
+ export declare const defineProvider: <const Auth extends AuthMethods>({ health, ...options }: ProviderOptions<Auth>) => Provider<Auth>;