apps 0.0.1-beta.0

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 (135) hide show
  1. package/README.md +191 -0
  2. package/check-publish.mjs +10 -0
  3. package/framework-reference.json +1 -0
  4. package/js/chunk-22WRQZT7.js +389 -0
  5. package/js/chunk-2OTCEKL2.js +29480 -0
  6. package/js/chunk-36DNRFZQ.js +34 -0
  7. package/js/chunk-3ANFZFCV.js +1799 -0
  8. package/js/chunk-7JXHF5IF.js +138 -0
  9. package/js/chunk-BCSNKUAC.js +0 -0
  10. package/js/chunk-BKVL7XAJ.js +47 -0
  11. package/js/chunk-BPEFS4YF.js +1323 -0
  12. package/js/chunk-C24KEZXR.js +59 -0
  13. package/js/chunk-D6BKYP2L.js +877 -0
  14. package/js/chunk-EP6AEUZO.js +19 -0
  15. package/js/chunk-HP7E42X6.js +1719 -0
  16. package/js/chunk-KWTCHVLT.js +284 -0
  17. package/js/chunk-LOKGDT6B.js +28 -0
  18. package/js/chunk-MLKGABMK.js +9 -0
  19. package/js/chunk-OWD2YICM.js +2486 -0
  20. package/js/chunk-Q2FD5IBM.js +899 -0
  21. package/js/chunk-R6JMJSVT.js +590 -0
  22. package/js/chunk-SBKHUC5L.js +56 -0
  23. package/js/chunk-VFUZI3NY.js +75 -0
  24. package/js/chunk-W7Q5EOTS.js +4375 -0
  25. package/js/chunk-WIDTG42X.js +171 -0
  26. package/js/chunk-X3YBZCJW.js +246 -0
  27. package/js/chunk-YDR4CPJA.js +2357 -0
  28. package/js/client.js +1023 -0
  29. package/js/contracts.js +163 -0
  30. package/js/effect.js +44 -0
  31. package/js/graphql.js +392 -0
  32. package/js/host.js +193 -0
  33. package/js/index.js +284 -0
  34. package/js/mcp/effect.js +23 -0
  35. package/js/mcp/stdio.js +123 -0
  36. package/js/mcp.js +37 -0
  37. package/js/openapi.js +246 -0
  38. package/js/operations/approval.js +9 -0
  39. package/js/react.js +37 -0
  40. package/js/storage/facet.js +546 -0
  41. package/js/ui/auth/contracts.js +19 -0
  42. package/js/ui/auth.js +28 -0
  43. package/js/ui/contracts.js +24 -0
  44. package/js/ui/serving.js +286 -0
  45. package/package.json +116 -0
  46. package/runtime.json +1 -0
  47. package/types/app-data/src/contracts/database.d.ts +193 -0
  48. package/types/app-data/src/implementation/cursor.d.ts +10 -0
  49. package/types/app-data/src/implementation/index-key.d.ts +7 -0
  50. package/types/app-data/src/implementation/promise.d.ts +68 -0
  51. package/types/app-data/src/implementation/range.d.ts +8 -0
  52. package/types/app-data/src/implementation/schema.d.ts +33 -0
  53. package/types/app-data/src/implementation/sqlite.d.ts +11 -0
  54. package/types/app-data/src/index.d.ts +4 -0
  55. package/types/apps/src/approval.d.ts +10 -0
  56. package/types/apps/src/client.d.ts +5 -0
  57. package/types/apps/src/contracts/app.d.ts +58 -0
  58. package/types/apps/src/contracts/approval.d.ts +14 -0
  59. package/types/apps/src/contracts/context.d.ts +25 -0
  60. package/types/apps/src/contracts/elicitation.d.ts +86 -0
  61. package/types/apps/src/contracts/graphql.d.ts +102 -0
  62. package/types/apps/src/contracts/host.d.ts +568 -0
  63. package/types/apps/src/contracts/http.d.ts +20 -0
  64. package/types/apps/src/contracts/live.d.ts +26 -0
  65. package/types/apps/src/contracts/mcp.d.ts +93 -0
  66. package/types/apps/src/contracts/openapi.d.ts +105 -0
  67. package/types/apps/src/contracts/operations.d.ts +30 -0
  68. package/types/apps/src/contracts/optimistic.d.ts +22 -0
  69. package/types/apps/src/contracts/provider.d.ts +96 -0
  70. package/types/apps/src/contracts/schedules.d.ts +51 -0
  71. package/types/apps/src/contracts/schema.d.ts +20 -0
  72. package/types/apps/src/contracts/storage.d.ts +68 -0
  73. package/types/apps/src/contracts/tools.d.ts +11 -0
  74. package/types/apps/src/contracts/ui-auth.d.ts +28 -0
  75. package/types/apps/src/contracts/ui.d.ts +90 -0
  76. package/types/apps/src/contracts/webhook-protocol.d.ts +102 -0
  77. package/types/apps/src/contracts/webhooks.d.ts +53 -0
  78. package/types/apps/src/contracts/workflows.d.ts +277 -0
  79. package/types/apps/src/effect.d.ts +10 -0
  80. package/types/apps/src/facet.d.ts +5 -0
  81. package/types/apps/src/graphql.d.ts +10 -0
  82. package/types/apps/src/host.d.ts +16 -0
  83. package/types/apps/src/implementation/account-operations.d.ts +32 -0
  84. package/types/apps/src/implementation/app.d.ts +40 -0
  85. package/types/apps/src/implementation/authoring.d.ts +12 -0
  86. package/types/apps/src/implementation/elicitation.d.ts +103 -0
  87. package/types/apps/src/implementation/graphql.d.ts +5 -0
  88. package/types/apps/src/implementation/host.d.ts +3 -0
  89. package/types/apps/src/implementation/http.d.ts +5 -0
  90. package/types/apps/src/implementation/live.d.ts +18 -0
  91. package/types/apps/src/implementation/mcp-call.d.ts +19 -0
  92. package/types/apps/src/implementation/mcp-client.d.ts +50 -0
  93. package/types/apps/src/implementation/mcp-stdio.d.ts +4 -0
  94. package/types/apps/src/implementation/mcp-tools.d.ts +6 -0
  95. package/types/apps/src/implementation/mcp.d.ts +4 -0
  96. package/types/apps/src/implementation/openapi-request.d.ts +11 -0
  97. package/types/apps/src/implementation/openapi.d.ts +5 -0
  98. package/types/apps/src/implementation/operations.d.ts +65 -0
  99. package/types/apps/src/implementation/optimistic.d.ts +30 -0
  100. package/types/apps/src/implementation/protocol-operations.d.ts +24 -0
  101. package/types/apps/src/implementation/provider.d.ts +16 -0
  102. package/types/apps/src/implementation/query-commit.d.ts +10 -0
  103. package/types/apps/src/implementation/schedules.d.ts +16 -0
  104. package/types/apps/src/implementation/schema.d.ts +93 -0
  105. package/types/apps/src/implementation/storage.d.ts +13 -0
  106. package/types/apps/src/implementation/ui-auth.d.ts +13 -0
  107. package/types/apps/src/implementation/ui-client.d.ts +16 -0
  108. package/types/apps/src/implementation/ui-errors.d.ts +2 -0
  109. package/types/apps/src/implementation/ui-serving.d.ts +16 -0
  110. package/types/apps/src/implementation/ui-watch.d.ts +2 -0
  111. package/types/apps/src/implementation/webhooks.d.ts +29 -0
  112. package/types/apps/src/implementation/workflow-context.d.ts +8 -0
  113. package/types/apps/src/implementation/workflow-rpc.d.ts +5 -0
  114. package/types/apps/src/implementation/workflows.d.ts +27 -0
  115. package/types/apps/src/index.d.ts +58 -0
  116. package/types/apps/src/mcp-stdio.d.ts +8 -0
  117. package/types/apps/src/mcp.d.ts +10 -0
  118. package/types/apps/src/openapi.d.ts +10 -0
  119. package/types/apps/src/react.d.ts +7 -0
  120. package/types/apps/src/ui-auth.d.ts +3 -0
  121. package/types/apps/src/ui-serving.d.ts +3 -0
  122. package/types/telemetry/src/browser-operations.d.ts +16 -0
  123. package/types/telemetry/src/browser-performance.d.ts +11 -0
  124. package/types/telemetry/src/browser-request-timing.d.ts +2 -0
  125. package/types/telemetry/src/browser.d.ts +27 -0
  126. package/types/telemetry/src/config.d.ts +83 -0
  127. package/types/telemetry/src/context.d.ts +14 -0
  128. package/types/telemetry/src/index.d.ts +9 -0
  129. package/types/telemetry/src/layer.d.ts +7 -0
  130. package/types/telemetry/src/measurements.d.ts +8 -0
  131. package/types/telemetry/src/pending-span.d.ts +7 -0
  132. package/types/telemetry/src/relay.d.ts +28 -0
  133. package/types/telemetry/src/span-attributes.d.ts +29 -0
  134. package/types/telemetry/src/trace-context.d.ts +20 -0
  135. package/types/telemetry/src/transport.d.ts +6 -0
@@ -0,0 +1,103 @@
1
+ /** Validate both sides of a tool's form and bind delivery to its invocation lifetime. */
2
+ import { Effect, Schema } from "effect";
3
+ import { ElicitationFailed, type ElicitationHandler, type Elicit } from "../contracts/elicitation.js";
4
+ /** Parse a form and retain its response parser, so invalid answers can be rejected before consuming a host continuation. */
5
+ export declare const prepareElicitation: (input: unknown) => Effect.Effect<{
6
+ request: {
7
+ readonly message: string;
8
+ readonly mode: "form";
9
+ readonly requestedSchema: {
10
+ readonly properties: {
11
+ readonly [x: string]: {
12
+ readonly type: "string";
13
+ readonly enum: readonly string[];
14
+ readonly default?: string;
15
+ readonly title?: string;
16
+ readonly description?: string;
17
+ readonly enumNames?: readonly string[];
18
+ } | {
19
+ readonly type: "string";
20
+ readonly enum: readonly string[];
21
+ readonly default?: string;
22
+ readonly title?: string;
23
+ readonly description?: string;
24
+ } | {
25
+ readonly oneOf: readonly {
26
+ readonly const: string;
27
+ readonly title: string;
28
+ }[];
29
+ readonly type: "string";
30
+ readonly default?: string;
31
+ readonly title?: string;
32
+ readonly description?: string;
33
+ } | {
34
+ readonly items: {
35
+ readonly type: "string";
36
+ readonly enum: readonly string[];
37
+ };
38
+ readonly type: "array";
39
+ readonly default?: readonly string[];
40
+ readonly title?: string;
41
+ readonly description?: string;
42
+ readonly minItems?: number;
43
+ readonly maxItems?: number;
44
+ } | {
45
+ readonly items: {
46
+ readonly anyOf: readonly {
47
+ readonly const: string;
48
+ readonly title: string;
49
+ }[];
50
+ };
51
+ readonly type: "array";
52
+ readonly default?: readonly string[];
53
+ readonly title?: string;
54
+ readonly description?: string;
55
+ readonly minItems?: number;
56
+ readonly maxItems?: number;
57
+ } | {
58
+ readonly type: "string";
59
+ readonly default?: string;
60
+ readonly format?: "email" | "uri" | "date" | "date-time";
61
+ readonly title?: string;
62
+ readonly description?: string;
63
+ readonly minLength?: number;
64
+ readonly maxLength?: number;
65
+ } | {
66
+ readonly type: "number" | "integer";
67
+ readonly default?: number;
68
+ readonly title?: string;
69
+ readonly description?: string;
70
+ readonly minimum?: number;
71
+ readonly maximum?: number;
72
+ } | {
73
+ readonly type: "boolean";
74
+ readonly default?: boolean;
75
+ readonly title?: string;
76
+ readonly description?: string;
77
+ };
78
+ };
79
+ readonly type: "object";
80
+ readonly required?: readonly string[];
81
+ readonly $schema?: string;
82
+ };
83
+ readonly _meta?: {
84
+ readonly [x: string]: Schema.Json;
85
+ } | undefined;
86
+ };
87
+ respond: (input: unknown) => Effect.Effect<{
88
+ readonly action: "cancel" | "decline";
89
+ readonly _meta?: {
90
+ readonly [x: string]: Schema.Json;
91
+ } | undefined;
92
+ } | {
93
+ content: {
94
+ readonly [x: string]: string | number | boolean | readonly string[];
95
+ };
96
+ action: "accept";
97
+ _meta?: {
98
+ readonly [x: string]: Schema.Json;
99
+ } | undefined;
100
+ }, ElicitationFailed, never>;
101
+ }, ElicitationFailed, never>;
102
+ /** Bind a validated interaction to the live invocation; transport adapters share its form parser. */
103
+ export declare const makeElicit: (handler: ElicitationHandler | undefined, signal: AbortSignal) => Elicit;
@@ -0,0 +1,5 @@
1
+ /** Discover GraphQL tools live; transport, decoding and cancellation stay in Effect. */
2
+ import { Effect } from "effect";
3
+ import { GraphqlError, GraphqlToolsOptions, type GraphqlTools } from "../contracts/graphql.js";
4
+ /** Resolve schema and calls per account evaluation; never cache credentials or tools globally. */
5
+ export declare const graphqlToolsEffect: (input: GraphqlToolsOptions) => Effect.Effect<GraphqlTools, GraphqlError>;
@@ -0,0 +1,3 @@
1
+ import { type AppHandler } from "../contracts/host.js";
2
+ /** Construct a lazy native handler; requirements never evaluate the app factory. */
3
+ export declare const createAppHandler: (app: unknown) => AppHandler;
@@ -0,0 +1,5 @@
1
+ /** Effect-native decoding; fetch adaptation happens at the author boundary. */
2
+ import { Effect, type Schema } from "effect";
3
+ import { type JsonResponse, ResponseDecodeError, ResponseStatusError } from "../contracts/http.js";
4
+ /** Reject unsuccessful status before reading the body, then parse without leaking its contents. */
5
+ export declare const decodeJson: <T>(response: JsonResponse, schema: Schema.Decoder<T>) => Effect.Effect<T, ResponseStatusError | ResponseDecodeError>;
@@ -0,0 +1,18 @@
1
+ import { Atom } from "effect/unstable/reactivity";
2
+ import { AppQueryFailed, type OperationReference, type QueryTransport } from "../contracts/live.js";
3
+ import type { Operation } from "./operations.js";
4
+ import { type Schema } from "./schema.js";
5
+ type InputOf<OperationType> = OperationType extends Operation<infer Input, infer _Output, infer _Kind, infer _Context> ? Input : never;
6
+ type OutputOf<OperationType> = OperationType extends Operation<infer _Input, infer Output, infer _Kind, infer _Context> ? Output : never;
7
+ /** Make a query reference using a type-only server import. No handler is passed or bundled. */
8
+ export declare const queryReference: <Query>(name: Query extends Operation<infer _Input, infer _Output, "query", infer _Context> ? string : never) => OperationReference<InputOf<Query>, OutputOf<Query>, "query">;
9
+ /** Make a mutation reference using a type-only server import. */
10
+ export declare const mutationReference: <Mutation>(name: Mutation extends Operation<infer _Input, infer _Output, "mutation", infer _Context> ? string : never) => OperationReference<InputOf<Mutation>, OutputOf<Mutation>, "mutation">;
11
+ /** Subscribe for the atom's mounted lifetime and parse every result using a shared output schema.
12
+ * The host supplies routing, authentication and reconnection behavior through transport.
13
+ */
14
+ export declare const liveQueryAtom: <Input, Output>(reference: OperationReference<Input, Output, "query">, input: NoInfer<Input>, options: {
15
+ readonly output: Schema<NoInfer<Output>, boolean>;
16
+ readonly transport: QueryTransport;
17
+ }) => Atom.Atom<import("effect/unstable/reactivity/AsyncResult").AsyncResult<NoInfer<Output>, import("effect/Cause").NoSuchElementError | AppQueryFailed>>;
18
+ export {};
@@ -0,0 +1,19 @@
1
+ /** One upstream call, with form requests forwarded to the invocation's existing elicitation capability. */
2
+ import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
+ import { Effect, Schema } from "effect";
4
+ import { ElicitationFailed } from "../contracts/elicitation.js";
5
+ import { McpError, type McpToolContext } from "../contracts/mcp.js";
6
+ import type { JsonObject } from "../contracts/schema.js";
7
+ /** Register prompts only around tools/call, preserve metadata, and close every callback with the call. Never retries. */
8
+ export declare const mcpCall: (client: Client, name: string, input: JsonObject, context: McpToolContext, timeoutMs: number, failure: (phase: McpError["phase"], error: unknown) => McpError) => Effect.Effect<{
9
+ readonly content: readonly {
10
+ readonly [x: string]: Schema.Json;
11
+ }[];
12
+ readonly _meta?: {
13
+ readonly [x: string]: Schema.Json;
14
+ } | undefined;
15
+ readonly structuredContent?: {
16
+ readonly [x: string]: Schema.Json;
17
+ } | undefined;
18
+ readonly isError?: boolean | undefined;
19
+ }, ElicitationFailed | McpError, never>;
@@ -0,0 +1,50 @@
1
+ /** Shared MCP pagination, wire parsing and calls. Transport owns connection lifetime. */
2
+ import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
+ import type { jsonSchemaValidator } from "@modelcontextprotocol/sdk/validation/types.js";
4
+ import { Effect, Schema } from "effect";
5
+ import { McpError, type McpToolContext } from "../contracts/mcp.js";
6
+ import type { JsonObject } from "../effect.js";
7
+ /** Use the framework-owned interpreter at the MCP SDK's synchronous validation boundary. */
8
+ export declare const mcpJsonSchemaValidator: jsonSchemaValidator;
9
+ /** An operation owns its connection; it must close even when interrupted. */
10
+ export interface WithMcpClient {
11
+ <A, E>(mode: "discover" | "call", use: (client: Client) => Effect.Effect<A, E>): Effect.Effect<A, E | McpError>;
12
+ }
13
+ /** Shared client operations never cache catalogs or account credentials. */
14
+ export declare function mcpClient(withClient: WithMcpClient, timeoutMs: number, failure: (phase: McpError["phase"], error: unknown) => McpError): {
15
+ list: Effect.Effect<{
16
+ readonly name: string;
17
+ readonly inputSchema: {
18
+ readonly [x: string]: Schema.Json;
19
+ };
20
+ readonly _meta?: {
21
+ readonly [x: string]: Schema.Json;
22
+ } | undefined;
23
+ readonly title?: string | undefined;
24
+ readonly description?: string | undefined;
25
+ readonly annotations?: {
26
+ readonly title?: string;
27
+ readonly readOnlyHint?: boolean;
28
+ readonly destructiveHint?: boolean;
29
+ readonly idempotentHint?: boolean;
30
+ readonly openWorldHint?: boolean;
31
+ } | undefined;
32
+ readonly outputSchema?: {
33
+ readonly [x: string]: Schema.Json;
34
+ } | undefined;
35
+ }[], McpError, never>;
36
+ call: (name: string, input: JsonObject, context: McpToolContext) => Effect.Effect<{
37
+ readonly content: readonly {
38
+ readonly [x: string]: Schema.Json;
39
+ }[];
40
+ readonly _meta?: {
41
+ readonly [x: string]: Schema.Json;
42
+ } | undefined;
43
+ readonly structuredContent?: {
44
+ readonly [x: string]: Schema.Json;
45
+ } | undefined;
46
+ readonly isError?: boolean | undefined;
47
+ }, import("../index.js").ElicitationFailed | McpError, never>;
48
+ };
49
+ /** Transport-independent operations consumed by the app tool adapter. */
50
+ export type McpClient = ReturnType<typeof mcpClient>;
@@ -0,0 +1,4 @@
1
+ import { Effect } from "effect";
2
+ import { McpError, ProcessConfig } from "../contracts/mcp.js";
3
+ /** Each discovery/call owns and closes its subprocess. Deployment never starts it. */
4
+ export declare const stdioToolsEffect: (input: ProcessConfig) => Effect.Effect<Readonly<Record<string, import("../contracts/mcp.js").McpTool>>, McpError, never>;
@@ -0,0 +1,6 @@
1
+ /** Adapt any MCP transport into ordinary tools with shared validation behavior. */
2
+ import { Effect } from "effect";
3
+ import { McpError, type McpTools } from "../contracts/mcp.js";
4
+ import type { McpClient } from "./mcp-client.js";
5
+ /** Evaluate fresh metadata for the account bound to this client. */
6
+ export declare const adaptMcpTools: (client: McpClient) => Effect.Effect<McpTools, McpError>;
@@ -0,0 +1,4 @@
1
+ import { Effect } from "effect";
2
+ import { McpError, McpToolsOptions } from "../contracts/mcp.js";
3
+ /** Discover and call with a fresh selected-account transport for each operation. */
4
+ export declare const mcpToolsEffect: (input: McpToolsOptions) => Effect.Effect<Readonly<Record<string, import("../contracts/mcp.js").McpTool>>, McpError, never>;
@@ -0,0 +1,11 @@
1
+ /** HTTP serialization for normalized OpenAPI operations. */
2
+ import { Effect, Schema } from "effect";
3
+ import { OpenapiError, type CredentialBinding, type OpenapiOperation, type OpenapiAccount } from "../contracts/openapi.js";
4
+ /** Create request helpers from credential-free generated authentication metadata. */
5
+ export declare function createRequest(config: {
6
+ readonly methods: Readonly<Record<string, readonly CredentialBinding[]>>;
7
+ readonly oauth: readonly string[];
8
+ }): {
9
+ available: (op: OpenapiOperation, method: string | undefined) => boolean;
10
+ call: (op: OpenapiOperation, input: unknown, account: OpenapiAccount | undefined) => Effect.Effect<Schema.Json, OpenapiError, never>;
11
+ };
@@ -0,0 +1,5 @@
1
+ /** Evaluate normalized metadata into ordinary tools, with account-specific security filtering. */
2
+ import { Effect } from "effect";
3
+ import { OpenapiError, OpenapiToolsOptions, type OpenapiTools } from "../contracts/openapi.js";
4
+ /** Decode retained metadata and expose only operations supported by the selected account. */
5
+ export declare const openapiToolsEffect: (options: OpenapiToolsOptions) => Effect.Effect<OpenapiTools, OpenapiError>;
@@ -0,0 +1,65 @@
1
+ /** Pure operation declarations. Only the author callback crosses the Promise boundary. */
2
+ import { Effect, Schema as EffectSchema } from "effect";
3
+ import type { AppOperation } from "../contracts/operations.js";
4
+ import type { AppContext, QueryContext, MutationContext } from "../contracts/context.js";
5
+ import type { Approval } from "../approval.js";
6
+ import type { ToolAnnotations } from "../contracts/tools.js";
7
+ import type { JsonObject } from "../contracts/schema.js";
8
+ import { type Schema } from "./schema.js";
9
+ declare const NativeOperation: unique symbol;
10
+ declare const HandlerContext: unique symbol;
11
+ /** A server-only declaration with its category preserved for catalog validation. */
12
+ export interface OperationDeclaration<Kind extends "query" | "mutation", Context = never> {
13
+ readonly [HandlerContext]?: (context: Context) => void;
14
+ readonly kind: Kind;
15
+ readonly [NativeOperation]: Omit<AppOperation<never>, "kind" | "input"> & {
16
+ readonly kind: Kind;
17
+ readonly input: EffectSchema.Decoder<unknown>;
18
+ };
19
+ }
20
+ /** Typed operation handles drive browser reference inference without bundling handlers. */
21
+ export interface Operation<Input, Output, Kind extends "query" | "mutation", Context = AppContext> extends OperationDeclaration<Kind, Context> {
22
+ readonly [NativeOperation]: AppOperation<Input, Output> & {
23
+ readonly kind: Kind;
24
+ };
25
+ }
26
+ /** Retain a native operation without evaluating it. Used by database and protocol constructors. */
27
+ export declare const operationDeclaration: <Input, Output, Kind extends "query" | "mutation", Context = AppContext>(operation: AppOperation<Input, Output> & {
28
+ readonly kind: Kind;
29
+ }) => Operation<Input, Output, Kind, Context>;
30
+ /** Accept only framework-created declarations; input is decoded before its erased callback is invoked. */
31
+ export declare const nativeOperation: (value: unknown) => AppOperation | undefined;
32
+ /** Options shared by database and external operations. Output defaults to a JSON-safe host check. */
33
+ export interface OperationOptions<Input, Output> {
34
+ readonly description?: string;
35
+ readonly title?: string;
36
+ readonly input: Schema<Input, boolean>;
37
+ readonly output?: Schema<Output, boolean>;
38
+ readonly approval?: Approval<Input>;
39
+ readonly annotations?: ToolAnnotations;
40
+ readonly _meta?: JsonObject;
41
+ }
42
+ /** Adapt metadata and approval without running user code. */
43
+ export declare const operationOptions: <Input, Output>(options: OperationOptions<Input, Output>) => {
44
+ approval?: (context: Parameters<Approval<Input>>[0]) => Effect.Effect<"approved" | "denied" | "user-approval", unknown, never>;
45
+ input: EffectSchema.Decoder<Input, never>;
46
+ _meta?: {
47
+ readonly [x: string]: EffectSchema.Json;
48
+ };
49
+ annotations?: {
50
+ readonly title?: string;
51
+ readonly readOnlyHint?: boolean;
52
+ readonly destructiveHint?: boolean;
53
+ readonly idempotentHint?: boolean;
54
+ readonly openWorldHint?: boolean;
55
+ };
56
+ title?: string;
57
+ description?: string;
58
+ };
59
+ /** Attach the same approval function to a generated or shared operation. */
60
+ 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>;
61
+ /** Read operation. External reads are allowed; only database writes are mechanically prohibited. */
62
+ 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
+ /** Explicit write operation. Database writes roll back on failure; external effects cannot be undone. */
64
+ export declare const mutation: <Input, Output, Context extends AppContext = MutationContext>(options: OperationOptions<Input, Output>, run: (context: Context, input: Input) => Promise<Output>) => Operation<Input, Output, "mutation", Context>;
65
+ export {};
@@ -0,0 +1,30 @@
1
+ /** One client's mounted queries and ordered optimistic write/read handoffs. */
2
+ import { Effect } from "effect";
3
+ import { Atom, AsyncResult } from "effect/unstable/reactivity";
4
+ import type { AppMutation } from "../contracts/optimistic.js";
5
+ import type { OperationReference } from "../contracts/live.js";
6
+ import { JsonValue } from "../contracts/schema.js";
7
+ import type { Schema } from "./schema.js";
8
+ type Snapshot = AsyncResult.AsyncResult<unknown, unknown>;
9
+ /** Transport and fiber ownership remain with the browser client's runtime. */
10
+ export interface OptimisticTransport {
11
+ readonly source: (name: string, input: JsonValue, output: Schema<unknown, boolean>) => Atom.Atom<Snapshot>;
12
+ readonly read: (name: string, input: JsonValue, output: Schema<unknown, boolean>) => Effect.Effect<unknown, unknown>;
13
+ readonly write: (name: string, input: JsonValue, output: Schema<unknown, boolean>) => Effect.Effect<unknown, unknown>;
14
+ readonly fork: (effect: Effect.Effect<void>) => void;
15
+ readonly run: <A>(effect: Effect.Effect<A, unknown>) => Promise<A>;
16
+ readonly reportProjectionError: (details: {
17
+ readonly operationId: string;
18
+ readonly name: string;
19
+ readonly sent: boolean;
20
+ }) => void;
21
+ }
22
+ /** Owns cache entries and projections. Dispose before closing the transport runtime. */
23
+ export declare const makeOptimisticClient: (transport: OptimisticTransport) => {
24
+ mutation: <Input, Output>(reference: OperationReference<Input, Output, "mutation">, output: Schema<NoInfer<Output>, boolean>) => AppMutation<Input, Output>;
25
+ /** Shares state across mounts; the last subscriber releases the stream and cache entry. */
26
+ queryAtom: <Input, Output>(reference: OperationReference<Input, Output, "query">, input: NoInfer<Input>, output: Schema<NoInfer<Output>, boolean>) => Atom.Atom<AsyncResult.AsyncResult<Output, unknown>>;
27
+ /** Cancel callers and close streams; the transport owner then interrupts its fibers. */
28
+ dispose: () => void;
29
+ };
30
+ export {};
@@ -0,0 +1,24 @@
1
+ /** Project upstream protocol metadata into the same operations authors declare by hand. */
2
+ import type { Effect, Schema } from "effect";
3
+ import type { OperationContext } from "../contracts/operations.js";
4
+ import type { ToolAnnotations } from "../contracts/tools.js";
5
+ import type { JsonObject, JsonValue } from "../contracts/schema.js";
6
+ import { type Operation } from "./operations.js";
7
+ /** Explicit corrections for upstream read-only hints or unusual HTTP semantics. */
8
+ export type OperationKinds = Readonly<Record<string, "query" | "mutation">>;
9
+ interface ProtocolOperation {
10
+ readonly description: string;
11
+ readonly title?: string | undefined;
12
+ readonly readOnly?: boolean | undefined;
13
+ readonly annotations?: ToolAnnotations | undefined;
14
+ readonly _meta?: JsonObject | undefined;
15
+ readonly input: Schema.Decoder<JsonValue>;
16
+ readonly outputSchema?: JsonObject | undefined;
17
+ readonly run: (context: OperationContext, input: JsonValue) => Effect.Effect<unknown, unknown>;
18
+ }
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
+ };
24
+ export {};
@@ -0,0 +1,16 @@
1
+ /** Pure constructors over the native provider contracts. */
2
+ import { Effect, Schema } from "effect";
3
+ import { type AuthMethods, OAuth2Config, OAuth2Method, Provider, SecretsMethod } from "../contracts/provider.js";
4
+ import type { ValidationError } from "../contracts/schema.js";
5
+ /** Declare a secrets method with an Effect decoder. */
6
+ export declare const secrets: <Fields extends Schema.Decoder<unknown>>(options: {
7
+ readonly label: string;
8
+ readonly fields: Fields;
9
+ }) => SecretsMethod<Fields>;
10
+ /** 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: {
14
+ readonly name: string;
15
+ readonly auth: Auth;
16
+ }) => Provider<Auth>;
@@ -0,0 +1,10 @@
1
+ import { AsyncResult } from "effect/unstable/reactivity";
2
+ /** Per-result metadata follows the exact Atom registry snapshot, including concurrent mounts. */
3
+ export interface ObservedQueryValue<A> {
4
+ readonly value: A;
5
+ readonly commit: () => void;
6
+ }
7
+ /** Strip internal metadata at the atom boundary and retain only a weak association to its result. */
8
+ export declare const queryResult: <A, E>(result: AsyncResult.AsyncResult<ObservedQueryValue<A>, E>) => AsyncResult.AsyncResult<A, E>;
9
+ /** Called after React has committed this exact result to the DOM; unrelated atoms have no callback. */
10
+ export declare const queryCommitted: (result: object) => void;
@@ -0,0 +1,16 @@
1
+ import { Interval, ScheduleTiming } from "../contracts/schedules.js";
2
+ import { JsonValue } from "../contracts/schema.js";
3
+ import { type Operation, type OperationDeclaration } from "./operations.js";
4
+ /** The app adapter resolves this operation handle to its declared mutation name. */
5
+ export interface ScheduleDeclaration<Context = never> {
6
+ readonly operation: OperationDeclaration<"mutation", Context>;
7
+ readonly timing: ScheduleTiming;
8
+ readonly input: JsonValue;
9
+ }
10
+ /** Run an existing mutation at a fixed interval. Installation enablement belongs to the host. */
11
+ export declare const interval: <Input, Output, Context>(duration: Interval, operation: Operation<Input, Output, "mutation", Context>, input: NoInfer<Input>) => ScheduleDeclaration<Context>;
12
+ /** Calendar alternative for wall-clock schedules. UTC is the explicit default when timezone is omitted. */
13
+ export declare const cron: <Input, Output, Context>(calendar: {
14
+ readonly expression: string;
15
+ readonly timezone?: string;
16
+ }, operation: Operation<Input, Output, "mutation", Context>, input: NoInfer<Input>) => ScheduleDeclaration<Context>;
@@ -0,0 +1,93 @@
1
+ /** Author schema facade. Internals use the native decoder retained by each value. */
2
+ import { Effect, Schema as EffectSchema } from "effect";
3
+ import { ValidationError, type JsonObject } from "../contracts/schema.js";
4
+ import type { Field } from "../../../app-data/src/contracts/database.js";
5
+ declare const StorageField: unique symbol;
6
+ declare const Decoder: unique symbol;
7
+ /** An author-facing value schema. Effect is never required in author code. */
8
+ export interface Schema<T, Optional extends boolean = false> {
9
+ readonly [StorageField]?: Field;
10
+ readonly [Decoder]: EffectSchema.Decoder<T>;
11
+ readonly optionalValue: Optional;
12
+ /** Parse an unknown value; invalid input throws a safe ValidationError. */
13
+ parse(input: unknown): T;
14
+ /** Accept an absent field without changing the original schema. */
15
+ optional(): Schema<T | undefined, true>;
16
+ /** Validate the default now and use it for undefined input. */
17
+ default(value: T): Schema<T> & {
18
+ readonly hasDefault: true;
19
+ readonly inputOptional: Optional;
20
+ };
21
+ }
22
+ /** Infer the parsed author value. */
23
+ export type Infer<S> = S extends Schema<infer T, boolean> ? T : never;
24
+ /** Named author fields. */
25
+ export type Fields = Readonly<Record<string, Schema<unknown, boolean>>>;
26
+ /** Optional fields may be absent; defaulted fields are present after decoding. */
27
+ export type ObjectValue<F extends Fields> = {
28
+ readonly [Key in keyof F as F[Key]["optionalValue"] extends true ? never : Key]: Infer<F[Key]>;
29
+ } & {
30
+ readonly [Key in keyof F as F[Key]["optionalValue"] extends true ? Key : never]?: Infer<F[Key]>;
31
+ };
32
+ /** An author object schema with retained field declarations. */
33
+ export interface ObjectSchema<F extends Fields> extends Schema<ObjectValue<F>> {
34
+ readonly fields: F;
35
+ }
36
+ /** Retrieve a native decoder at the author boundary without erasing its type. */
37
+ export declare const decoderOf: <T>(schema: Schema<T, boolean>) => EffectSchema.Decoder<T>;
38
+ /** Recognize schemas made by this author facade when adapting a definition. */
39
+ export declare const isSchema: (value: unknown) => value is Schema<unknown, boolean>;
40
+ /** Decode within an Effect program. Invalid input is omitted from the failure. */
41
+ export declare const parse: <T>(decoder: EffectSchema.Decoder<T>, input: unknown) => Effect.Effect<T, ValidationError>;
42
+ /** Present a native decoder through the synchronous author API. */
43
+ export declare function wrap<T, Optional extends boolean>(decoder: EffectSchema.Decoder<T>, optionalValue: Optional, field?: Field): Schema<T, Optional>;
44
+ /** A string, optionally with a minimum length. No coercion. */
45
+ export declare function string(options?: {
46
+ readonly minLength?: number;
47
+ }): Schema<string>;
48
+ /** A finite JSON number. No coercion. */
49
+ export declare const number: () => Schema<number>;
50
+ /** A boolean. No coercion. */
51
+ export declare const boolean: () => Schema<boolean>;
52
+ /** Any JSON value. Values still cross the native JSON decoder. */
53
+ export declare const json: () => Schema<EffectSchema.Json>;
54
+ /** Named values with a common schema. */
55
+ export declare const record: <T>(value: Schema<T, boolean>) => Schema<Readonly<Record<string, T>>>;
56
+ /** One exact JSON scalar value. */
57
+ export declare function literal<const T extends string | number | boolean | null>(value: T): Schema<T>;
58
+ /** An array whose elements use the given schema. */
59
+ export declare const array: <T>(item: Schema<T, boolean>) => Schema<readonly T[]>;
60
+ /** Parse declared fields and omit undeclared fields. */
61
+ export declare function object<const F extends Fields>(fields: F): ObjectSchema<F>;
62
+ declare const ImportedJsonSchema: unique symbol;
63
+ /** Read the original document for an imported decoder without a lossy schema round trip. */
64
+ export declare const importedJsonSchema: (decoder: EffectSchema.Decoder<unknown>) => unknown | undefined;
65
+ /** Attach a composed discovery document without replacing its authoritative native decoder. */
66
+ export declare const withJsonSchemaDocument: <S extends EffectSchema.Decoder<unknown>>(decoder: S, document: JsonObject) => S;
67
+ /**
68
+ * Relocate a self-contained JSON Schema under a document pointer. Resolve references
69
+ * before nesting so account schemas can reuse definition names, IDs and anchors.
70
+ * Only schema nodes are rewritten; examples and ordinary property values stay intact.
71
+ */
72
+ export declare const nestJsonSchema: (input: JsonObject, pointer: string) => JsonObject;
73
+ /** Prepare an interpreted validator. No eval or generated JavaScript runs in any host. */
74
+ export declare const compileJsonSchemaDecoder: (document: JsonObject) => Effect.Effect<EffectSchema.Codec<EffectSchema.Json, EffectSchema.Json, never, never> & {
75
+ [ImportedJsonSchema]: {
76
+ readonly [x: string]: EffectSchema.Json;
77
+ };
78
+ }, ValidationError, never>;
79
+ /** Preserve the JSON document; compile its validator only when a value is first decoded. */
80
+ export declare const jsonSchemaDecoder: (input: unknown) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json> & {
81
+ [ImportedJsonSchema]: {
82
+ readonly [x: string]: EffectSchema.Json;
83
+ };
84
+ }, ValidationError, never>;
85
+ /** Import JSON metadata now; unsupported schemas and invalid values fail when parsed. */
86
+ export declare const jsonSchema: (input: unknown) => Schema<EffectSchema.Json>;
87
+ /** Database declaration retained by primitive constructors; nested payload schemas are not database fields. */
88
+ export declare const storageFieldOf: (schema: Schema<unknown, boolean>) => Field | undefined;
89
+ /** A row reference records the target table; existence is not a foreign-key constraint. */
90
+ export declare const id: (table: string) => Schema<string>;
91
+ /** A host user identifier, stored as a string without imposing a product auth model. */
92
+ export declare const userId: () => Schema<string>;
93
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type DatabaseSession } from "../../../app-data/src/index.js";
2
+ import { type AppStorage } from "../contracts/storage.js";
3
+ import type { DatabaseDefinition, Database, Table, Tables } from "../contracts/storage.js";
4
+ import { type Fields } from "./schema.js";
5
+ export type { DatabaseDefinition, Database, DatabaseReader, Table, Tables, RowOf, } from "../contracts/storage.js";
6
+ /** Declare scalar columns using the same schemas as operation inputs. */
7
+ export declare const table: <const F extends Fields>(fields: F) => Table<F>;
8
+ /** Build a fresh Promise database facade for one authorized invocation. */
9
+ export declare const authorDatabase: <T extends Tables>(tables: T, session: DatabaseSession, signal: AbortSignal, writable: boolean) => Database<T>;
10
+ /** Declare storage independently of handlers; the host binds each invocation's database. */
11
+ export declare const defineDatabase: <const T extends Tables>(tables: T) => DatabaseDefinition<T>;
12
+ /** Explicit missing capability, never a fallback to another app's data. */
13
+ export declare const unavailableStorage: AppStorage;
@@ -0,0 +1,13 @@
1
+ /** Trusted bootstrap documents run before authored UI and never contain product credentials. */
2
+ import { HttpServerResponse } from "effect/unstable/http";
3
+ /** Private app responses must not leak authentication URLs through caches or referrers. */
4
+ export declare const appPrivateHeaders: {
5
+ "cache-control": string;
6
+ "referrer-policy": string;
7
+ "x-content-type-options": string;
8
+ "content-security-policy": string;
9
+ };
10
+ /** Serve only a fixed host script while authentication runs; the original URL remains available to that script. */
11
+ export declare const appSignInPage: () => HttpServerResponse.HttpServerResponse;
12
+ /** Preserve deep links, erase callback proofs before any request, and let the host set HttpOnly cookies. */
13
+ export declare const appSignInScript: () => HttpServerResponse.HttpServerResponse;
@@ -0,0 +1,16 @@
1
+ import { Atom } from "effect/unstable/reactivity";
2
+ import { type OperationReference } from "../contracts/live.js";
3
+ import { type Schema } from "./schema.js";
4
+ /** A scoped page client. Host-injected context carries only the deployment, never credentials. */
5
+ export declare const createAppClient: () => {
6
+ /** Close this client when its page or embedding owner is removed. */
7
+ dispose: () => Promise<void>;
8
+ /** Query this app once, with a runtime-validated response. Does not populate the mounted query cache. */
9
+ query: <Input, Output>(reference: OperationReference<Input, Output, "query">, input: NoInfer<Input>, output: Schema<NoInfer<Output>, boolean>) => Promise<NoInfer<Output>>;
10
+ /** Execute a write once in this client's queue. Success acknowledges the write; queries reconcile afterward. */
11
+ mutate: <Input, Output>(reference: OperationReference<Input, Output, "mutation">, input: NoInfer<Input>, output: Schema<NoInfer<Output>, boolean>) => Promise<Output>;
12
+ /** Create a callable mutation with optional withOptimisticUpdate projections over mounted queries. */
13
+ mutation: <Input, Output>(reference: OperationReference<Input, Output, "mutation">, output: Schema<NoInfer<Output>, boolean>) => import("../client.js").AppMutation<Input, Output>;
14
+ /** Share a live query across mounts and reconcile optimistic changes against fresh server reads. */
15
+ queryAtom: <Input, Output>(reference: OperationReference<Input, Output, "query">, input: NoInfer<Input>, output: Schema<NoInfer<Output>, boolean>) => Atom.Atom<import("effect/unstable/reactivity/AsyncResult").AsyncResult<Output, unknown>>;
16
+ };
@@ -0,0 +1,2 @@
1
+ /** Inline host script: no app dependencies, credentials, or authored HTML enter its source. */
2
+ export declare const appFailureBootstrap: string;
@@ -0,0 +1,16 @@
1
+ import { Effect } from "effect";
2
+ import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
3
+ import { UiForbidden, type AppUiAsset } from "../contracts/ui.js";
4
+ /** Render an authorized deployment with a host-owned deployment watcher. */
5
+ export declare const appDocument: <E, R>(options: {
6
+ readonly deployment: string;
7
+ readonly profile?: string | undefined;
8
+ readonly expectedProfileRevision?: number | undefined;
9
+ readonly origin: string;
10
+ readonly asset: (path: string) => Effect.Effect<AppUiAsset | undefined, E, R>;
11
+ }) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiForbidden | E, HttpServerRequest.HttpServerRequest | R>;
12
+ /** Revalidate immutable assets only after the host has checked current access and file existence.
13
+ * Browsers may retain bytes, but neither browsers nor shared proxies may reuse them without authorization.
14
+ * HTML remains an uncached host-rendered entry point.
15
+ */
16
+ export declare const appAsset: (asset: AppUiAsset | undefined, build: string, path: string) => Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest>;
@@ -0,0 +1,2 @@
1
+ /** Dependency-free browser source served by each host after app authorization. */
2
+ export declare const appWatchScript: string;
@@ -0,0 +1,29 @@
1
+ /** Native webhook dispatch. The author verifies signatures before parsing or performing side effects. */
2
+ import { Effect, Schema } from "effect";
3
+ import type { AppDefinition } from "../contracts/app.js";
4
+ import { HostDeclarationInvalid, HostInputInvalid, HostOperationFailed, HostOperationNotFound, HostOutputInvalid, type ResolvedAccounts } from "../contracts/host.js";
5
+ import { type WebhookCommand } from "../contracts/webhook-protocol.js";
6
+ /** Run one hook with freshly bound context. No credentials or raw failures enter the response envelope. */
7
+ export declare const dispatchWebhook: <Context extends {
8
+ readonly signal?: AbortSignal;
9
+ readonly accounts: Readonly<Record<string, unknown>>;
10
+ }>(definition: AppDefinition<Context>, command: WebhookCommand, context: Context, accounts: ResolvedAccounts) => Effect.Effect<Schema.Json | {
11
+ readonly name: string;
12
+ readonly account: string;
13
+ readonly configSchema: {
14
+ readonly [x: string]: Schema.Json;
15
+ };
16
+ readonly setup?: {
17
+ readonly stateSchema: {
18
+ readonly [x: string]: Schema.Json;
19
+ };
20
+ readonly instructions: string;
21
+ readonly signingSecret: "provider" | "executor";
22
+ };
23
+ }[] | {
24
+ readonly status: number;
25
+ readonly headers: {
26
+ readonly [x: string]: string;
27
+ };
28
+ readonly body: string;
29
+ }, HostDeclarationInvalid | HostOperationNotFound | HostOperationFailed | HostInputInvalid | HostOutputInvalid, never>;