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,102 @@
1
+ /** Private host protocol for webhook callbacks. Raw bytes are never parsed as JSON before verification. */
2
+ import { Schema } from "effect";
3
+ /** Raw-byte ceiling shared by callback HTTP, app execution and the encoded host protocol. */
4
+ export declare const WebhookTransportLimits: Schema.Struct<{
5
+ readonly maxBodyBytes: Schema.Int;
6
+ }>;
7
+ export type WebhookTransportLimits = typeof WebhookTransportLimits.Type;
8
+ /** Requests and responses use the same existing transport bound. */
9
+ export declare const defaultWebhookTransportLimits: {
10
+ readonly maxBodyBytes: number;
11
+ };
12
+ /** Bounded callback transport. Headers and base64 bytes preserve the provider signature input. */
13
+ export declare const WebhookRequestData: Schema.Struct<{
14
+ readonly url: Schema.String;
15
+ readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]>;
16
+ readonly headers: Schema.$Record<Schema.String, Schema.String>;
17
+ readonly body: Schema.String;
18
+ }>;
19
+ /** The app response is passed back to the provider after its handler completes. */
20
+ export declare const WebhookResponseData: Schema.Struct<{
21
+ readonly status: Schema.Int;
22
+ readonly headers: Schema.$Record<Schema.String, Schema.String>;
23
+ readonly body: Schema.String;
24
+ }>;
25
+ /** Manual instructions are text, never executable HTML. Signing secrets are exchanged only in the setup page. */
26
+ export declare const ManualWebhookSetup: Schema.Struct<{
27
+ readonly instructions: Schema.NonEmptyString;
28
+ readonly signingSecret: Schema.Literals<readonly ["executor", "provider"]>;
29
+ }>;
30
+ export type ManualWebhookSetup = typeof ManualWebhookSetup.Type;
31
+ /** The state schema describes the additional private fields collected during manual setup. */
32
+ export declare const ManualWebhookDescriptor: Schema.Struct<{
33
+ readonly stateSchema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
34
+ readonly instructions: Schema.NonEmptyString;
35
+ readonly signingSecret: Schema.Literals<readonly ["executor", "provider"]>;
36
+ }>;
37
+ /** Account-bound webhook metadata, evaluated without registering upstream resources. */
38
+ export declare const HostedWebhook: Schema.Struct<{
39
+ readonly name: Schema.NonEmptyString;
40
+ readonly account: Schema.NonEmptyString;
41
+ readonly configSchema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
42
+ readonly setup: Schema.optionalKey<Schema.Struct<{
43
+ readonly stateSchema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
44
+ readonly instructions: Schema.NonEmptyString;
45
+ readonly signingSecret: Schema.Literals<readonly ["executor", "provider"]>;
46
+ }>>;
47
+ }>;
48
+ /** Each command runs with a fresh factory and the subscription's saved account selections. */
49
+ export declare const WebhookCommand: Schema.Union<readonly [Schema.Struct<{
50
+ readonly operation: Schema.Literal<"webhooks">;
51
+ }>, Schema.Struct<{
52
+ readonly name: Schema.NonEmptyString;
53
+ readonly subscriptionId: Schema.NonEmptyString;
54
+ readonly sourceAccount: Schema.brand<Schema.String, "acc">;
55
+ readonly callbackUrl: Schema.String;
56
+ readonly secret: Schema.String;
57
+ readonly config: Schema.Codec<Schema.Json, Schema.Json, never, never>;
58
+ readonly operation: Schema.Literal<"webhook-validate">;
59
+ }>, Schema.Struct<{
60
+ readonly state: Schema.Codec<Schema.Json, Schema.Json, never, never>;
61
+ readonly name: Schema.NonEmptyString;
62
+ readonly subscriptionId: Schema.NonEmptyString;
63
+ readonly sourceAccount: Schema.brand<Schema.String, "acc">;
64
+ readonly callbackUrl: Schema.String;
65
+ readonly secret: Schema.String;
66
+ readonly config: Schema.Codec<Schema.Json, Schema.Json, never, never>;
67
+ readonly operation: Schema.Literal<"webhook-complete">;
68
+ }>, Schema.Struct<{
69
+ readonly name: Schema.NonEmptyString;
70
+ readonly subscriptionId: Schema.NonEmptyString;
71
+ readonly sourceAccount: Schema.brand<Schema.String, "acc">;
72
+ readonly callbackUrl: Schema.String;
73
+ readonly secret: Schema.String;
74
+ readonly config: Schema.Codec<Schema.Json, Schema.Json, never, never>;
75
+ readonly operation: Schema.Literal<"webhook-register">;
76
+ }>, Schema.Struct<{
77
+ readonly state: Schema.Codec<Schema.Json, Schema.Json, never, never>;
78
+ readonly name: Schema.NonEmptyString;
79
+ readonly subscriptionId: Schema.NonEmptyString;
80
+ readonly sourceAccount: Schema.brand<Schema.String, "acc">;
81
+ readonly callbackUrl: Schema.String;
82
+ readonly secret: Schema.String;
83
+ readonly config: Schema.Codec<Schema.Json, Schema.Json, never, never>;
84
+ readonly operation: Schema.Literal<"webhook-unregister">;
85
+ }>, Schema.Struct<{
86
+ readonly state: Schema.Codec<Schema.Json, Schema.Json, never, never>;
87
+ readonly request: Schema.Struct<{
88
+ readonly url: Schema.String;
89
+ readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]>;
90
+ readonly headers: Schema.$Record<Schema.String, Schema.String>;
91
+ readonly body: Schema.String;
92
+ }>;
93
+ readonly name: Schema.NonEmptyString;
94
+ readonly subscriptionId: Schema.NonEmptyString;
95
+ readonly sourceAccount: Schema.brand<Schema.String, "acc">;
96
+ readonly callbackUrl: Schema.String;
97
+ readonly secret: Schema.String;
98
+ readonly config: Schema.Codec<Schema.Json, Schema.Json, never, never>;
99
+ readonly operation: Schema.Literal<"webhook-handle">;
100
+ }>]>;
101
+ /** Parsed framework command; contains private host inputs and must not be logged. */
102
+ export type WebhookCommand = typeof WebhookCommand.Type;
@@ -0,0 +1,53 @@
1
+ /** Account-bound webhook lifecycle. Register and unregister must be idempotent for subscriptionId. */
2
+ import type { Effect, Schema } from "effect";
3
+ import type { ManualWebhookSetup } from "./webhook-protocol.js";
4
+ import type { AccountSlots, BoundContext } from "./app.js";
5
+ type SourceAccount<Context extends Pick<BoundContext<AccountSlots>, "accounts" | "fetch" | "signal">> = keyof Context["accounts"] & string;
6
+ type SelectedAccount<Context extends Pick<BoundContext<AccountSlots>, "accounts" | "fetch" | "signal">> = {
7
+ [Slot in keyof Context["accounts"]]: Context["accounts"][Slot] extends readonly (infer Account)[] ? Account : Context["accounts"][Slot];
8
+ }[keyof Context["accounts"]];
9
+ /**
10
+ * Registration, delivery and cleanup share the selected accounts.
11
+ * The host stores account IDs and parsed state, never credentials.
12
+ * Register runs when enabling a subscription, not on every app evaluation.
13
+ */
14
+ interface WebhookLifecycle<Context extends Pick<BoundContext<AccountSlots>, "accounts" | "fetch" | "signal">, Config extends Schema.Decoder<unknown>, State extends Schema.Decoder<unknown>, Error = unknown> {
15
+ readonly account: SourceAccount<Context>;
16
+ readonly config: Config;
17
+ readonly state: State;
18
+ readonly register: (context: Context, input: {
19
+ readonly config: Config["Type"];
20
+ readonly subscriptionId: string;
21
+ readonly account: SelectedAccount<Context>;
22
+ readonly callbackUrl: string;
23
+ readonly secret: string;
24
+ }) => Effect.Effect<State["Type"], Error>;
25
+ /** Verify the raw request before acting. */
26
+ readonly handle: (context: Context, input: {
27
+ readonly request: Request;
28
+ readonly config: Config["Type"];
29
+ readonly subscriptionId: string;
30
+ readonly account: SelectedAccount<Context>;
31
+ readonly callbackUrl: string;
32
+ readonly state: State["Type"] | null;
33
+ readonly secret: string;
34
+ }) => Effect.Effect<Response, Error>;
35
+ /** Remove the upstream registration using its saved state and original account. */
36
+ readonly unregister: (context: Context, input: {
37
+ readonly state: State["Type"] | null;
38
+ readonly config: Config["Type"];
39
+ readonly subscriptionId: string;
40
+ readonly account: SelectedAccount<Context>;
41
+ readonly callbackUrl: string;
42
+ readonly secret: string;
43
+ }) => Effect.Effect<void, Error>;
44
+ }
45
+ /** Manual subscriptions collect the state schema in a private browser form instead of invoking provider APIs. */
46
+ export type Webhook<Context extends Pick<BoundContext<AccountSlots>, "accounts" | "fetch" | "signal">, Config extends Schema.Decoder<unknown>, State extends Schema.Decoder<unknown>, Error = unknown> = (WebhookLifecycle<Context, Config, State, Error> & {
47
+ readonly setup?: never;
48
+ }) | (Omit<WebhookLifecycle<Context, Config, State, Error>, "register" | "unregister"> & {
49
+ readonly setup: typeof ManualWebhookSetup.Type;
50
+ readonly register?: never;
51
+ readonly unregister?: never;
52
+ });
53
+ export {};
@@ -0,0 +1,277 @@
1
+ /** Portable workflow declarations, run views and durable execution capabilities. */
2
+ import { Schema, type Effect } from "effect";
3
+ import { JsonValue } from "./schema.js";
4
+ import type { AppContext, AppRequirements, QueryContext, MutationContext } from "./context.js";
5
+ import type { Operation } from "../implementation/operations.js";
6
+ import type { HostContext } from "./host.js";
7
+ /** Run identity is opaque and shared by author and SDK interfaces. */
8
+ export declare const WorkflowRunId: Schema.brand<Schema.NonEmptyString, "wfr">;
9
+ export type WorkflowRunId = typeof WorkflowRunId.Type;
10
+ /** Stable names identify declarations and replay steps. */
11
+ export declare const WorkflowName: Schema.NonEmptyString;
12
+ /** Convert portable duration syntax to milliseconds; invalid or overflowing values are rejected. */
13
+ export declare const workflowDurationMillis: (value: number | string) => number | undefined;
14
+ /** Numbers are milliseconds; strings use a quantity and full unit, such as "5 minutes". */
15
+ export declare const WorkflowDuration: Schema.Union<readonly [Schema.Finite, Schema.NonEmptyString]>;
16
+ export type WorkflowDuration = typeof WorkflowDuration.Type;
17
+ /** Author retry and timeout options are passed to the durable engine. */
18
+ export declare const WorkflowStepOptions: Schema.Struct<{
19
+ readonly retries: Schema.optionalKey<Schema.Struct<{
20
+ readonly limit: Schema.Int;
21
+ readonly delay: Schema.Union<readonly [Schema.Finite, Schema.NonEmptyString]>;
22
+ readonly backoff: Schema.optionalKey<Schema.Literals<readonly ["constant", "linear", "exponential"]>>;
23
+ }>>;
24
+ readonly timeout: Schema.optionalKey<Schema.Union<readonly [Schema.Finite, Schema.NonEmptyString]>>;
25
+ }>;
26
+ export type WorkflowStepOptions = typeof WorkflowStepOptions.Type;
27
+ declare const WorkflowFailure_base: Schema.Class<WorkflowFailure, Schema.TaggedStruct<"WorkflowFailure", {
28
+ readonly reason: Schema.Literals<readonly ["unavailable", "not_found", "input", "output", "operation", "approval", "credentials", "terminated", "execution", "conflict", "engine"]>;
29
+ readonly retryable: Schema.Boolean;
30
+ }>, import("effect/Cause").YieldableError>;
31
+ /** Safe failures cross host boundaries without authored exceptions or account fields. */
32
+ export declare class WorkflowFailure extends WorkflowFailure_base {
33
+ }
34
+ /** Explicitly stop retrying an authored step. Its message stays inside the app runtime. */
35
+ export declare class NonRetryableError extends Error {
36
+ readonly name = "NonRetryableError";
37
+ }
38
+ /** Step outputs must fit the engine's persisted JSON result limit. */
39
+ export declare const WorkflowValue: Schema.Codec<Schema.Json, Schema.Json, never, never>;
40
+ /** Live workflow metadata carries schemas rather than executable handlers. */
41
+ export declare const HostedWorkflow: Schema.Struct<{
42
+ readonly name: Schema.NonEmptyString;
43
+ readonly description: Schema.optionalKey<Schema.String>;
44
+ readonly inputSchema: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
45
+ readonly outputSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
46
+ }>;
47
+ export type HostedWorkflow = typeof HostedWorkflow.Type;
48
+ /** Results are available only on completed runs; failure details are safe reason codes. */
49
+ export declare const WorkflowRun: Schema.Union<readonly [Schema.Struct<{
50
+ readonly status: Schema.Literals<readonly ["queued", "running", "waiting", "paused", "waitingForPause"]>;
51
+ readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
52
+ readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
53
+ readonly app: Schema.NonEmptyString;
54
+ readonly deployment: Schema.NonEmptyString;
55
+ readonly workflow: Schema.NonEmptyString;
56
+ readonly createdAt: Schema.String;
57
+ }>, Schema.Struct<{
58
+ readonly status: Schema.Literal<"complete">;
59
+ readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
60
+ readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
61
+ readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
62
+ readonly app: Schema.NonEmptyString;
63
+ readonly deployment: Schema.NonEmptyString;
64
+ readonly workflow: Schema.NonEmptyString;
65
+ readonly createdAt: Schema.String;
66
+ }>, Schema.Struct<{
67
+ readonly status: Schema.Literal<"errored">;
68
+ readonly error: Schema.Literals<readonly ["unavailable", "not_found", "input", "output", "operation", "approval", "credentials", "terminated", "execution", "conflict", "engine"]>;
69
+ readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
70
+ readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
71
+ readonly app: Schema.NonEmptyString;
72
+ readonly deployment: Schema.NonEmptyString;
73
+ readonly workflow: Schema.NonEmptyString;
74
+ readonly createdAt: Schema.String;
75
+ }>, Schema.Struct<{
76
+ readonly status: Schema.Literal<"terminated">;
77
+ readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
78
+ readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
79
+ readonly app: Schema.NonEmptyString;
80
+ readonly deployment: Schema.NonEmptyString;
81
+ readonly workflow: Schema.NonEmptyString;
82
+ readonly createdAt: Schema.String;
83
+ }>]>;
84
+ export type WorkflowRun = typeof WorkflowRun.Type;
85
+ /** A bounded run-history page, already scoped to an authorized configured app. */
86
+ export declare const WorkflowRunPage: Schema.Struct<{
87
+ readonly items: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
88
+ readonly status: Schema.Literals<readonly ["queued", "running", "waiting", "paused", "waitingForPause"]>;
89
+ readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
90
+ readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
91
+ readonly app: Schema.NonEmptyString;
92
+ readonly deployment: Schema.NonEmptyString;
93
+ readonly workflow: Schema.NonEmptyString;
94
+ readonly createdAt: Schema.String;
95
+ }>, Schema.Struct<{
96
+ readonly status: Schema.Literal<"complete">;
97
+ readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
98
+ readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
99
+ readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
100
+ readonly app: Schema.NonEmptyString;
101
+ readonly deployment: Schema.NonEmptyString;
102
+ readonly workflow: Schema.NonEmptyString;
103
+ readonly createdAt: Schema.String;
104
+ }>, Schema.Struct<{
105
+ readonly status: Schema.Literal<"errored">;
106
+ readonly error: Schema.Literals<readonly ["unavailable", "not_found", "input", "output", "operation", "approval", "credentials", "terminated", "execution", "conflict", "engine"]>;
107
+ readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
108
+ readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
109
+ readonly app: Schema.NonEmptyString;
110
+ readonly deployment: Schema.NonEmptyString;
111
+ readonly workflow: Schema.NonEmptyString;
112
+ readonly createdAt: Schema.String;
113
+ }>, Schema.Struct<{
114
+ readonly status: Schema.Literal<"terminated">;
115
+ readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
116
+ readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
117
+ readonly app: Schema.NonEmptyString;
118
+ readonly deployment: Schema.NonEmptyString;
119
+ readonly workflow: Schema.NonEmptyString;
120
+ readonly createdAt: Schema.String;
121
+ }>]>>;
122
+ readonly next: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "wfr">>;
123
+ }>;
124
+ export type WorkflowRunPage = typeof WorkflowRunPage.Type;
125
+ /** Query and factory contexts may inspect only their own app's runs. */
126
+ export interface WorkflowReads {
127
+ readonly get: (input: {
128
+ readonly run: string;
129
+ }) => Promise<WorkflowRun>;
130
+ readonly list: (input?: {
131
+ readonly workflow?: string;
132
+ readonly limit?: number;
133
+ readonly cursor?: string;
134
+ }) => Promise<WorkflowRunPage>;
135
+ }
136
+ /** Mutating handlers may start and terminate runs in their own configured app. */
137
+ export interface WorkflowControls extends WorkflowReads {
138
+ readonly start: (input: {
139
+ readonly workflow: string;
140
+ readonly input: JsonValue;
141
+ readonly key?: string;
142
+ }) => Promise<WorkflowRun>;
143
+ readonly terminate: (input: {
144
+ readonly run: string;
145
+ }) => Promise<WorkflowRun>;
146
+ }
147
+ /** External steps get fresh credentials and cancellation, without storage or live elicitation. */
148
+ export type WorkflowStepContext<Requirements extends AppRequirements = AppRequirements> = Omit<AppContext<Requirements>, "elicit" | "workflows"> & {
149
+ readonly runId: WorkflowRunId;
150
+ readonly stepId: string;
151
+ readonly idempotencyKey: string;
152
+ };
153
+ /** Explicit durable boundaries; database access passes through registered app operations. */
154
+ export interface WorkflowStep<Requirements extends AppRequirements = AppRequirements> {
155
+ do<Output>(name: string, run: (context: WorkflowStepContext<Requirements>) => Promise<Output>): Promise<Output>;
156
+ do<Output>(name: string, options: WorkflowStepOptions, run: (context: WorkflowStepContext<Requirements>) => Promise<Output>): Promise<Output>;
157
+ runQuery<Input, Output>(name: string, operation: Operation<Input, Output, "query", QueryContext<Requirements>>, input: NoInfer<Input>, options?: WorkflowStepOptions): Promise<Output>;
158
+ runMutation<Input, Output>(name: string, operation: Operation<Input, Output, "mutation", MutationContext<Requirements>>, input: NoInfer<Input>, options?: WorkflowStepOptions): Promise<Output>;
159
+ readonly sleep: (name: string, duration: WorkflowDuration) => Promise<void>;
160
+ readonly sleepUntil: (name: string, timestamp: number | Date) => Promise<void>;
161
+ }
162
+ /** The orchestration body gets no account, database or interactive capabilities. */
163
+ export interface WorkflowContext<Requirements extends AppRequirements = AppRequirements> {
164
+ readonly runId: WorkflowRunId;
165
+ readonly step: WorkflowStep<Requirements>;
166
+ }
167
+ /** Framework-owned native declaration; only the callback crosses the author Promise boundary. */
168
+ export interface AppWorkflow<Input = unknown, Output = unknown> {
169
+ readonly description?: string;
170
+ readonly input: Schema.Decoder<Input>;
171
+ readonly output?: Schema.Decoder<Output>;
172
+ readonly run: (context: WorkflowContext, input: Input) => Effect.Effect<Output, unknown>;
173
+ }
174
+ /** The backend supplies checkpoints and timers; app framework code supplies callbacks. */
175
+ export interface WorkflowDriver {
176
+ readonly do: (name: string, options: WorkflowStepOptions, run: () => Effect.Effect<JsonValue, WorkflowFailure>) => Effect.Effect<JsonValue, WorkflowFailure>;
177
+ readonly sleep: (name: string, duration: WorkflowDuration) => Effect.Effect<void, WorkflowFailure>;
178
+ readonly sleepUntil: (name: string, timestamp: number) => Effect.Effect<void, WorkflowFailure>;
179
+ }
180
+ /** Trusted host callbacks for one pinned run. Credentials are resolved only while executing a step. */
181
+ export interface WorkflowExecution {
182
+ readonly runId: WorkflowRunId;
183
+ readonly driver: WorkflowDriver;
184
+ readonly resolve: () => Effect.Effect<HostContext, WorkflowFailure>;
185
+ readonly invoke: (input: {
186
+ readonly kind: "query" | "mutation";
187
+ readonly name: string;
188
+ readonly input: JsonValue;
189
+ readonly stepId: string;
190
+ readonly timeout: number;
191
+ }) => Effect.Effect<JsonValue, WorkflowFailure>;
192
+ }
193
+ /** Private replay metadata is attached by the host, never accepted in author input. */
194
+ export declare const WorkflowReplay: Schema.Struct<{
195
+ readonly key: Schema.NonEmptyString;
196
+ readonly fingerprint: Schema.NonEmptyString;
197
+ }>;
198
+ export type WorkflowReplay = typeof WorkflowReplay.Type;
199
+ /** Portable discovery, input validation and execution commands. */
200
+ export declare const WorkflowCommand: Schema.Union<readonly [Schema.Struct<{
201
+ readonly operation: Schema.Literal<"workflows">;
202
+ }>, Schema.Struct<{
203
+ readonly operation: Schema.Literal<"workflow-validate">;
204
+ readonly name: Schema.NonEmptyString;
205
+ readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
206
+ }>, Schema.Struct<{
207
+ readonly operation: Schema.Literal<"workflow-run">;
208
+ readonly name: Schema.NonEmptyString;
209
+ readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
210
+ }>]>;
211
+ export type WorkflowCommand = typeof WorkflowCommand.Type;
212
+ /** Private invocation RPC protocol shared by the host and isolated app bundle. */
213
+ export declare const WorkflowRpcCommand: Schema.Union<readonly [Schema.Struct<{
214
+ readonly operation: Schema.Literal<"do">;
215
+ readonly name: Schema.NonEmptyString;
216
+ readonly options: Schema.Struct<{
217
+ readonly retries: Schema.optionalKey<Schema.Struct<{
218
+ readonly limit: Schema.Int;
219
+ readonly delay: Schema.Union<readonly [Schema.Finite, Schema.NonEmptyString]>;
220
+ readonly backoff: Schema.optionalKey<Schema.Literals<readonly ["constant", "linear", "exponential"]>>;
221
+ }>>;
222
+ readonly timeout: Schema.optionalKey<Schema.Union<readonly [Schema.Finite, Schema.NonEmptyString]>>;
223
+ }>;
224
+ }>, Schema.Struct<{
225
+ readonly operation: Schema.Literal<"sleep">;
226
+ readonly name: Schema.NonEmptyString;
227
+ readonly duration: Schema.Union<readonly [Schema.Finite, Schema.NonEmptyString]>;
228
+ }>, Schema.Struct<{
229
+ readonly operation: Schema.Literal<"until">;
230
+ readonly name: Schema.NonEmptyString;
231
+ readonly timestamp: Schema.Finite;
232
+ }>, Schema.Struct<{
233
+ readonly operation: Schema.Literal<"context">;
234
+ }>, Schema.Struct<{
235
+ readonly operation: Schema.Literal<"invoke">;
236
+ readonly kind: Schema.Literals<readonly ["query", "mutation"]>;
237
+ readonly name: Schema.NonEmptyString;
238
+ readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
239
+ readonly stepId: Schema.NonEmptyString;
240
+ readonly timeout: Schema.Finite;
241
+ }>]>;
242
+ export declare const WorkflowRpcResult: Schema.Union<readonly [Schema.Struct<{
243
+ readonly ok: Schema.Literal<true>;
244
+ readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
245
+ }>, Schema.Struct<{
246
+ readonly ok: Schema.Literal<false>;
247
+ readonly error: typeof WorkflowFailure;
248
+ }>]>;
249
+ export type WorkflowRpcResult = typeof WorkflowRpcResult.Type;
250
+ /** Callback functions are invocation-owned RPC capabilities, never persisted. */
251
+ export type WorkflowRpc = (input: unknown, callback?: () => Promise<unknown>) => Promise<unknown>;
252
+ /** Native app-scoped management capability supplied only by an authorized host invocation. */
253
+ export interface WorkflowHostControls {
254
+ readonly start: (input: Parameters<WorkflowControls["start"]>[0]) => Effect.Effect<WorkflowRun, WorkflowFailure>;
255
+ readonly get: (input: Parameters<WorkflowControls["get"]>[0]) => Effect.Effect<WorkflowRun, WorkflowFailure>;
256
+ readonly list: (input: Parameters<WorkflowControls["list"]>[0]) => Effect.Effect<WorkflowRunPage, WorkflowFailure>;
257
+ readonly terminate: (input: Parameters<WorkflowControls["terminate"]>[0]) => Effect.Effect<WorkflowRun, WorkflowFailure>;
258
+ }
259
+ /** Serializable requests do not contain an app ID; authority is captured in the supplied capability. */
260
+ export declare const WorkflowControlCommand: Schema.Union<readonly [Schema.Struct<{
261
+ readonly operation: Schema.Literal<"start">;
262
+ readonly workflow: Schema.NonEmptyString;
263
+ readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
264
+ readonly key: Schema.optionalKey<Schema.NonEmptyString>;
265
+ }>, Schema.Struct<{
266
+ readonly operation: Schema.Literal<"get">;
267
+ readonly run: Schema.brand<Schema.NonEmptyString, "wfr">;
268
+ }>, Schema.Struct<{
269
+ readonly operation: Schema.Literal<"list">;
270
+ readonly workflow: Schema.optionalKey<Schema.NonEmptyString>;
271
+ readonly cursor: Schema.optionalKey<Schema.brand<Schema.NonEmptyString, "wfr">>;
272
+ readonly limit: Schema.optionalKey<Schema.Int>;
273
+ }>, Schema.Struct<{
274
+ readonly operation: Schema.Literal<"terminate">;
275
+ readonly run: Schema.brand<Schema.NonEmptyString, "wfr">;
276
+ }>]>;
277
+ export {};
@@ -0,0 +1,10 @@
1
+ /** Native schema interop for app libraries written in Effect; ordinary authors use apps. */
2
+ export { HttpUrl, JsonObject, type JsonValue, ValidationError } from "./contracts/schema.js";
3
+ export { compileJsonSchemaDecoder, jsonSchemaDecoder, decoderOf, wrap, } from "./implementation/schema.js";
4
+ export type { PromiseMethods } from "./implementation/authoring.js";
5
+ export { ToolAnnotations } from "./contracts/tools.js";
6
+ export { ApprovalDecision, type Approval, type ApprovalContext } from "./contracts/approval.js";
7
+ /** Native host dispatch for trusted bundled apps; credentials remain invocation-local. */
8
+ export { createAppHandler } from "./implementation/host.js";
9
+ /** Parse a form and build its response parser for a host-owned interaction. */
10
+ export { prepareElicitation } from "./implementation/elicitation.js";
@@ -0,0 +1,5 @@
1
+ /** Native workerd SQLite capability; used only by the generated data facet, never browser bundles. */
2
+ import * as Sqlite from "@effect/sql-sqlite-do/SqliteClient";
3
+ import type { AppStorage } from "./contracts/storage.js";
4
+ /** Bind one facet's raw storage at the runtime edge. Each operation owns its native SQL scope. */
5
+ export declare const facetStorage: (storage: NonNullable<Sqlite.SqliteClientConfig["storage"]>) => AppStorage;
@@ -0,0 +1,10 @@
1
+ /** GraphQL helpers. Requires the optional graphql peer. */
2
+ import { type OperationKinds } from "./implementation/protocol-operations.js";
3
+ import type { GraphqlToolsOptions } from "./contracts/graphql.js";
4
+ export { GraphqlError, type GraphqlToolsOptions } from "./contracts/graphql.js";
5
+ /** Discover operations for the selected account. Kinds override uncertain upstream read-only hints. */
6
+ export declare const graphqlOperations: (options: GraphqlToolsOptions, kinds?: OperationKinds) => Promise<{
7
+ queries: Record<string, import("./index.js").Operation<import("effect/Schema").Json, unknown, "query", import("./index.js").OperationContext>>;
8
+ mutations: Record<string, import("./index.js").Operation<import("effect/Schema").Json, unknown, "mutation", import("./index.js").OperationContext>>;
9
+ }>;
10
+ export type { OperationKinds } from "./implementation/protocol-operations.js";
@@ -0,0 +1,16 @@
1
+ import { type HostContext, type ResolvedAccountsInput } from "./contracts/host.js";
2
+ import { type ElicitationHandler } from "./contracts/elicitation.js";
3
+ export type { HostContext, ResolvedAccountsInput } from "./contracts/host.js";
4
+ /** Parse trusted account bindings and an optional exact-call approval. Throws safe boundary errors on invalid input. */
5
+ export declare const hostContext: (accounts: ResolvedAccountsInput, approval?: unknown) => HostContext;
6
+ /** Portable Promise handler. Invoke only after the host has authorized and resolved accounts. */
7
+ export declare const createAppHandler: (app: unknown) => ((request: Request, context: HostContext) => Promise<Response>);
8
+ /** Isolates return bounded, telemetry beside the protocol result; no exporter secret enters app code. */
9
+ export declare const createIsolatedAppHandler: (app: unknown) => (request: Request, context: HostContext) => Promise<Response>;
10
+ /**
11
+ * Adapt a host-owned RPC callback into the handler an isolated app expects. Generated entry
12
+ * points call this instead of depending on Effect, which the app bundle cannot resolve.
13
+ * A transport failure aborts the lifetime so the invocation stops waiting.
14
+ */
15
+ export declare const isolatedElicitation: (deliver: (request: unknown) => Promise<unknown>, lifetime: AbortController) => ElicitationHandler;
16
+ export { isolatedWorkflowExecution, isolatedWorkflowControls, } from "./implementation/workflow-rpc.js";
@@ -0,0 +1,32 @@
1
+ import type { OperationContext } from "../contracts/operations.js";
2
+ import { type JsonValue } from "../contracts/schema.js";
3
+ import { type Operation } from "./operations.js";
4
+ type Operations = {
5
+ readonly queries: Readonly<Record<string, Operation<JsonValue, unknown, "query", OperationContext>>>;
6
+ readonly mutations: Readonly<Record<string, Operation<JsonValue, unknown, "mutation", OperationContext>>>;
7
+ };
8
+ /**
9
+ * Discover each selected account's protocol operations and combine matching names.
10
+ * Calls take { accountId, input }; each branch retains its account's input schema,
11
+ * credentials, approval and output validation. Empty selections expose no operations.
12
+ * Discovery is sequential and cancellation follows the caller's signal.
13
+ */
14
+ export declare const accountOperations: <Account extends {
15
+ readonly id: string;
16
+ }>(accounts: readonly Account[], discover: (account: Account) => Promise<Operations>, options: {
17
+ readonly signal: AbortSignal;
18
+ }) => Promise<{
19
+ queries: {
20
+ [k: string]: Operation<{
21
+ readonly accountId: string;
22
+ readonly input: unknown;
23
+ }, unknown, "query", import("../index.js").AppContext>;
24
+ };
25
+ mutations: {
26
+ [k: string]: Operation<{
27
+ readonly accountId: string;
28
+ readonly input: unknown;
29
+ }, unknown, "mutation", import("../index.js").AppContext>;
30
+ };
31
+ }>;
32
+ export {};
@@ -0,0 +1,40 @@
1
+ import type { ScheduleDeclaration } from "./schedules.js";
2
+ import type { App as NativeApp, AppDefinition as NativeDefinition } from "../contracts/app.js";
3
+ import type { AppRequirements, AppContext, QueryContext, MutationContext, WebhookContext } from "../contracts/context.js";
4
+ import { type PromiseMethods } from "./authoring.js";
5
+ import { type WorkflowDeclaration } from "./workflows.js";
6
+ import type { WorkflowContext } from "../contracts/workflows.js";
7
+ import { type OperationDeclaration } from "./operations.js";
8
+ import { type Schema } from "./schema.js";
9
+ type PromiseCatalog<Catalog> = Catalog extends Readonly<Record<string, object>> ? {
10
+ readonly [Name in keyof Catalog]: {
11
+ readonly [Key in keyof Catalog[Name]]: Key extends "config" | "state" ? Schema<unknown, boolean> : PromiseMethods<Catalog[Name]>[Key];
12
+ };
13
+ } : Catalog;
14
+ /** Author definition projected from native capabilities. Excluding callable objects keeps
15
+ * factories from being inferred as definitions and preserves contextual handler inference. */
16
+ export type AppDefinition<Requirements extends AppRequirements> = {
17
+ readonly [Key in keyof NativeDefinition<WebhookContext<Requirements>>]: Key extends "workflows" ? Readonly<Record<string, WorkflowDeclaration<WorkflowContext<Requirements>>>> : Key extends "schedules" ? Readonly<Record<string, ScheduleDeclaration<MutationContext<Requirements>>>> : Key extends "queries" ? Readonly<Record<string, OperationDeclaration<"query", QueryContext<Requirements>>>> : Key extends "mutations" ? Readonly<Record<string, OperationDeclaration<"mutation", MutationContext<Requirements>>>> : Key extends "webhooks" ? PromiseCatalog<NonNullable<NativeDefinition<WebhookContext<Requirements>>[Key]>> : NativeDefinition<WebhookContext<Requirements>>[Key];
18
+ } & {
19
+ readonly name?: never;
20
+ readonly tools?: never;
21
+ readonly call?: never;
22
+ };
23
+ /** Adapt operation and webhook catalogs without evaluating their handlers. */
24
+ export type EffectDefinition<Def> = {
25
+ readonly [Key in keyof Def]: Key extends "workflows" ? Readonly<Record<string, import("../contracts/workflows.js").AppWorkflow>> : Key extends "schedules" ? NonNullable<NativeDefinition<unknown>["schedules"]> : Key extends "queries" | "mutations" ? Readonly<Record<string, import("../contracts/operations.js").AppOperation>> : Key extends "webhooks" ? NonNullable<NativeDefinition<WebhookContext>["webhooks"]> : Def[Key];
26
+ };
27
+ declare const InternalApp: unique symbol;
28
+ /** Recognize a declaration from this framework instance before host adaptation. */
29
+ export declare const isApp: (value: unknown) => value is App<AppRequirements, AppDefinition<AppRequirements>>;
30
+ /** Public app handle; the native app is retained for host use without an async round trip. */
31
+ export interface App<Requirements extends AppRequirements, Def extends AppDefinition<Requirements>> {
32
+ readonly [InternalApp]: NativeApp<Requirements["accounts"], EffectDefinition<Def>>;
33
+ readonly accounts: Requirements["accounts"];
34
+ readonly evaluate: (context: AppContext<Requirements>) => Promise<Def>;
35
+ }
36
+ /** Retrieve the same declaration for an Effect host. No evaluation or I/O occurs. */
37
+ export declare const toEffectApp: <Requirements extends AppRequirements, Def extends AppDefinition<Requirements>>(app: App<Requirements, Def>) => NativeApp<Requirements["accounts"], EffectDefinition<Def>>;
38
+ /** Assemble app behavior. Package names belong in package.json; hosts name installed copies. */
39
+ export declare const defineApp: <const Requirements extends AppRequirements, Def extends AppDefinition<Requirements>>(requirements: Requirements, definition: (Def & AppDefinition<Requirements>) | ((context: AppContext<Requirements>) => Promise<Def & AppDefinition<Requirements>>)) => App<Requirements, Def>;
40
+ export {};
@@ -0,0 +1,12 @@
1
+ /** Small, explicit adapters between authored callbacks and native Effect operations. */
2
+ import { Effect } from "effect";
3
+ /** Project one Effect operation into its author-facing Promise signature. */
4
+ export type PromiseMethod<Method> = Method extends (...args: infer Args) => Effect.Effect<infer A, infer _E> ? (...args: Args) => Promise<A> : Method;
5
+ /** Project only an object's methods; data and schema types are not recursively rewritten. */
6
+ export type PromiseMethods<T> = {
7
+ readonly [Key in keyof T]: PromiseMethod<T[Key]>;
8
+ };
9
+ /** Reuse a framework callback's cancellation-bound Effect, or adapt an ordinary async callback. */
10
+ export declare const fromPromise: <Args extends readonly unknown[], A>(callback: (...args: Args) => Promise<A>) => ((...args: Args) => Effect.Effect<A, unknown>);
11
+ /** Bind cancellation once so Promise callers and native framework callers run the same operation. */
12
+ export declare const toPromise: <Args extends readonly unknown[], A, E>(operation: (...args: Args) => Effect.Effect<A, E>, signal?: AbortSignal) => ((...args: Args) => Promise<A>);