apps 0.0.1-beta.1 → 0.0.1-beta.100

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 (211) hide show
  1. package/README.md +112 -72
  2. package/framework-reference.json +1 -1
  3. package/js/browser-XIPJGLH2.js +65 -0
  4. package/js/chunk-2CURR5Y7.js +264 -0
  5. package/js/chunk-2LSGC7XY.js +42 -0
  6. package/js/{chunk-YEJOQEII.js → chunk-4PIQKACY.js} +65 -10
  7. package/js/chunk-4UPC36ZL.js +5185 -0
  8. package/js/{chunk-4LPG6RCH.js → chunk-4X2UI4R2.js} +7 -27
  9. package/js/chunk-5C6RAGAS.js +335 -0
  10. package/js/chunk-62NVUKED.js +39 -0
  11. package/js/chunk-74H25C4X.js +95 -0
  12. package/js/chunk-7HG422GB.js +90 -0
  13. package/js/chunk-7STIP5CS.js +171 -0
  14. package/js/{chunk-QKHR7BMF.js → chunk-ACQXVKVQ.js} +87 -51
  15. package/js/{chunk-OHRT55C4.js → chunk-DILSCQPJ.js} +226 -265
  16. package/js/chunk-ILYCJ3HV.js +449 -0
  17. package/js/chunk-K6TSCYAO.js +712 -0
  18. package/js/{chunk-EVJUVWN2.js → chunk-KLSEU35Y.js} +463 -218
  19. package/js/chunk-OD3KFKZD.js +1617 -0
  20. package/js/chunk-OWN3DP2W.js +88 -0
  21. package/js/{chunk-ZTFQHGEB.js → chunk-PBGPES67.js} +3 -5
  22. package/js/chunk-QI66R4FP.js +786 -0
  23. package/js/chunk-RN4YB4JT.js +1922 -0
  24. package/js/{chunk-ZCAMUXSG.js → chunk-URKOTNDA.js} +795 -177
  25. package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
  26. package/js/{chunk-2HHMABB6.js → chunk-VAI3EVCS.js} +700 -78
  27. package/js/chunk-VCYWAA4N.js +49 -0
  28. package/js/{chunk-HDJH3RPR.js → chunk-YDW7DX3A.js} +4 -4
  29. package/js/chunk-YWVISRZD.js +268 -0
  30. package/js/{chunk-FW5HBOIK.js → chunk-ZKDXML77.js} +19272 -18299
  31. package/js/client.js +148 -100
  32. package/js/contracts.js +208 -24
  33. package/js/effect.js +18 -19
  34. package/js/es-DIULA3ZF.js +39371 -0
  35. package/js/graphql.js +62 -58
  36. package/js/host.js +83 -60
  37. package/js/index.js +381 -263
  38. package/js/mcp/effect.js +21 -21
  39. package/js/mcp.js +117 -74
  40. package/js/openapi.js +4613 -42691
  41. package/js/react.js +2 -3
  42. package/js/skills/effect.js +6 -4
  43. package/js/skills.js +233 -70
  44. package/js/storage/facet.js +1 -540
  45. package/js/ui/auth/contracts.js +8 -9
  46. package/js/ui/auth.js +16 -14
  47. package/js/ui/contracts.js +9 -8
  48. package/js/ui/serving.js +8609 -227
  49. package/package.json +3 -8
  50. package/runtime.json +1 -1
  51. package/types/app-cache/src/contracts/cache.d.ts +60 -2
  52. package/types/app-cache/src/index.d.ts +92 -2
  53. package/types/app-data/src/contracts/database.d.ts +33 -6
  54. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  55. package/types/apps/src/contracts/app.d.ts +63 -17
  56. package/types/apps/src/contracts/cache.d.ts +24 -1
  57. package/types/apps/src/contracts/context.d.ts +60 -17
  58. package/types/apps/src/contracts/elicitation.d.ts +23 -7
  59. package/types/apps/src/contracts/events.d.ts +94 -0
  60. package/types/apps/src/contracts/failure.d.ts +54 -0
  61. package/types/apps/src/contracts/graphql.d.ts +2 -1
  62. package/types/apps/src/contracts/host.d.ts +1325 -534
  63. package/types/apps/src/contracts/icons.d.ts +28 -0
  64. package/types/apps/src/contracts/live.d.ts +2 -0
  65. package/types/apps/src/contracts/mcp.d.ts +97 -20
  66. package/types/apps/src/contracts/network.d.ts +120 -0
  67. package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
  68. package/types/apps/src/contracts/openapi-document.d.ts +1 -1
  69. package/types/apps/src/contracts/openapi.d.ts +51 -9
  70. package/types/apps/src/contracts/operations.d.ts +14 -12
  71. package/types/apps/src/contracts/placement.d.ts +102 -0
  72. package/types/apps/src/contracts/protocol-version.d.ts +6 -0
  73. package/types/apps/src/contracts/protocols/1.d.ts +2241 -0
  74. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  75. package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
  76. package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
  77. package/types/apps/src/contracts/protocols/2.d.ts +711 -0
  78. package/types/apps/src/contracts/protocols/3.d.ts +776 -0
  79. package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
  80. package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
  81. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  82. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  83. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  84. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  85. package/types/apps/src/contracts/protocols/current.d.ts +6857 -0
  86. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  87. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  88. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  89. package/types/apps/src/contracts/provider.d.ts +140 -10
  90. package/types/apps/src/contracts/router.d.ts +59 -0
  91. package/types/apps/src/contracts/schedules.d.ts +7 -1
  92. package/types/apps/src/contracts/schema.d.ts +21 -0
  93. package/types/apps/src/contracts/shared-catalog.d.ts +11 -0
  94. package/types/apps/src/contracts/skills.d.ts +60 -14
  95. package/types/apps/src/contracts/sql.d.ts +63 -0
  96. package/types/apps/src/contracts/ui-auth.d.ts +6 -14
  97. package/types/apps/src/contracts/ui.d.ts +70 -30
  98. package/types/apps/src/contracts/webhooks.d.ts +24 -7
  99. package/types/apps/src/contracts/workflows.d.ts +89 -36
  100. package/types/apps/src/facet.d.ts +4 -5
  101. package/types/apps/src/graphql.d.ts +1 -3
  102. package/types/apps/src/host.d.ts +5 -0
  103. package/types/apps/src/implementation/account-router.d.ts +13 -0
  104. package/types/apps/src/implementation/app.d.ts +44 -16
  105. package/types/apps/src/implementation/authoring.d.ts +25 -5
  106. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  107. package/types/apps/src/implementation/cache.d.ts +32 -3
  108. package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
  109. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  110. package/types/apps/src/implementation/events.d.ts +64 -0
  111. package/types/apps/src/implementation/failure-detail.d.ts +48 -0
  112. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  113. package/types/apps/src/implementation/graphql.d.ts +4 -3
  114. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  115. package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
  116. package/types/apps/src/implementation/live.d.ts +2 -2
  117. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  118. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  119. package/types/apps/src/implementation/mcp-client.d.ts +49 -25
  120. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  121. package/types/apps/src/implementation/mcp.d.ts +52 -25
  122. package/types/apps/src/implementation/network.d.ts +16 -0
  123. package/types/apps/src/implementation/openapi-compile.d.ts +30 -8
  124. package/types/apps/src/implementation/openapi-document.d.ts +46 -21
  125. package/types/apps/src/implementation/openapi-names.d.ts +23 -0
  126. package/types/apps/src/implementation/openapi-request.d.ts +10 -3
  127. package/types/apps/src/implementation/openapi-source.d.ts +30 -8
  128. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  129. package/types/apps/src/implementation/operations.d.ts +84 -10
  130. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  131. package/types/apps/src/implementation/placement.d.ts +60 -0
  132. package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
  133. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  134. package/types/apps/src/implementation/provider.d.ts +26 -6
  135. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  136. package/types/apps/src/implementation/router-catalog.d.ts +227 -0
  137. package/types/apps/src/implementation/router.d.ts +78 -0
  138. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  139. package/types/apps/src/implementation/schedules.d.ts +39 -8
  140. package/types/apps/src/implementation/schema.d.ts +111 -15
  141. package/types/apps/src/implementation/skills.d.ts +18 -24
  142. package/types/apps/src/implementation/sql.d.ts +71 -0
  143. package/types/apps/src/implementation/swagger-client.d.ts +28 -0
  144. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  145. package/types/apps/src/implementation/ui-auth.d.ts +12 -6
  146. package/types/apps/src/implementation/ui-client.d.ts +3 -3
  147. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  148. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  149. package/types/apps/src/implementation/ui-serving.d.ts +31 -12
  150. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  151. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  152. package/types/apps/src/implementation/webhooks.d.ts +15 -6
  153. package/types/apps/src/implementation/workflow-context.d.ts +17 -5
  154. package/types/apps/src/implementation/workflows.d.ts +11 -4
  155. package/types/apps/src/index.d.ts +71 -21
  156. package/types/apps/src/mcp.d.ts +25 -5
  157. package/types/apps/src/openapi.d.ts +11 -6
  158. package/types/apps/src/react.d.ts +1 -1
  159. package/types/apps/src/skills.d.ts +13 -8
  160. package/types/apps/src/ui-auth.d.ts +2 -2
  161. package/types/apps/src/ui-serving.d.ts +1 -1
  162. package/types/telemetry/src/app-records.d.ts +42 -0
  163. package/types/telemetry/src/browser-operations.d.ts +7 -4
  164. package/types/telemetry/src/browser.d.ts +8 -3
  165. package/types/telemetry/src/config.d.ts +2 -2
  166. package/types/telemetry/src/index.d.ts +2 -1
  167. package/types/telemetry/src/layer.d.ts +10 -4
  168. package/types/telemetry/src/measurements.d.ts +1 -1
  169. package/types/telemetry/src/ownership.d.ts +60 -0
  170. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  171. package/types/telemetry/src/relay.d.ts +16 -6
  172. package/types/telemetry/src/span-attributes.d.ts +17 -1
  173. package/types/telemetry/src/transport.d.ts +8 -1
  174. package/types/utils/src/api-error.d.ts +55 -0
  175. package/types/utils/src/connection-failure.d.ts +33 -0
  176. package/types/utils/src/legacy-keys.d.ts +20 -0
  177. package/types/utils/src/recorded-message.d.ts +18 -0
  178. package/types/utils/src/schema-definitions.d.ts +13 -0
  179. package/types/utils/src/user-facing-error.d.ts +83 -0
  180. package/js/chunk-6IIO4NPI.js +0 -29
  181. package/js/chunk-6YBRWRK3.js +0 -160
  182. package/js/chunk-BMOIAIVR.js +0 -138
  183. package/js/chunk-FZJOYIZO.js +0 -19
  184. package/js/chunk-G7IE6BKC.js +0 -224
  185. package/js/chunk-IHQ4ML7K.js +0 -2193
  186. package/js/chunk-KOXMLKTM.js +0 -1288
  187. package/js/chunk-M6ZRRIBI.js +0 -877
  188. package/js/chunk-PLCMJREA.js +0 -590
  189. package/js/chunk-PZ36XMXW.js +0 -93
  190. package/js/chunk-RBAC33PQ.js +0 -267
  191. package/js/chunk-SATWJKN6.js +0 -34
  192. package/js/chunk-SWPD52J7.js +0 -35
  193. package/js/chunk-TE4KO4HI.js +0 -47
  194. package/js/chunk-W7D7WVSY.js +0 -18
  195. package/js/chunk-X7SFGU4Q.js +0 -280
  196. package/js/chunk-ZJWDMTE3.js +0 -63
  197. package/js/mcp/stdio.js +0 -128
  198. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  199. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  200. package/types/app-data/src/implementation/promise.d.ts +0 -68
  201. package/types/app-data/src/implementation/range.d.ts +0 -8
  202. package/types/app-data/src/implementation/schema.d.ts +0 -33
  203. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  204. package/types/app-data/src/index.d.ts +0 -4
  205. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  206. package/types/apps/src/contracts/storage.d.ts +0 -68
  207. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  208. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
  209. package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
  210. package/types/apps/src/implementation/storage.d.ts +0 -13
  211. package/types/apps/src/mcp-stdio.d.ts +0 -8
@@ -1,1288 +0,0 @@
1
- import {
2
- folderSkillsEffect
3
- } from "./chunk-ZTFQHGEB.js";
4
- import {
5
- CacheEntry,
6
- CacheError,
7
- authorDatabase,
8
- cacheLimits,
9
- isApp,
10
- toEffectApp,
11
- unavailableStorage
12
- } from "./chunk-RBAC33PQ.js";
13
- import {
14
- fromPromise,
15
- nativeOperation,
16
- toPromise
17
- } from "./chunk-PZ36XMXW.js";
18
- import {
19
- parseProviderError
20
- } from "./chunk-ZJWDMTE3.js";
21
- import {
22
- DeclaredProvider,
23
- DeclaredRequirements,
24
- ElicitationFailed,
25
- ElicitationResponse,
26
- FormElicitation,
27
- HostAccountsInvalid,
28
- HostDeclarationInvalid,
29
- HostError,
30
- HostEvaluationFailed,
31
- HostInputInvalid,
32
- HostOperationFailed,
33
- HostOperationNotFound,
34
- HostOutputInvalid,
35
- HostRequest,
36
- HostRequestInvalid,
37
- HostToolApprovalRequired,
38
- HostToolBlocked,
39
- HostToolNotFound,
40
- HostToolPolicyFailed,
41
- HostedTool,
42
- HostedToolSummary,
43
- HostedWebhook,
44
- HostedWorkflow,
45
- InvocationDeadline,
46
- ManualWebhookSetup,
47
- ManyAccounts,
48
- McpError,
49
- NonRetryableError,
50
- OperationToolPrefixes,
51
- ResolvedAccounts,
52
- ToolResultObservation,
53
- TrustedToolApproval,
54
- WebhookResponseData,
55
- WorkflowDuration,
56
- WorkflowFailure,
57
- WorkflowName,
58
- WorkflowReplay,
59
- WorkflowStepOptions,
60
- WorkflowValue,
61
- approvalElicitation,
62
- defaultWebhookTransportLimits,
63
- maxInputProblems,
64
- workflowDurationMillis
65
- } from "./chunk-IHQ4ML7K.js";
66
- import {
67
- AppSkills,
68
- SkillFile,
69
- SkillLoadFailed
70
- } from "./chunk-YEJOQEII.js";
71
- import {
72
- OpenapiResponseError
73
- } from "./chunk-SWPD52J7.js";
74
- import {
75
- captureTelemetry,
76
- invocationFetch
77
- } from "./chunk-ZCAMUXSG.js";
78
- import {
79
- decoderOf,
80
- importedJsonSchema,
81
- jsonSchemaDecoder
82
- } from "./chunk-2HHMABB6.js";
83
- import {
84
- JsonObject,
85
- JsonValue
86
- } from "./chunk-SATWJKN6.js";
87
- import {
88
- Cause_exports,
89
- Clock_exports,
90
- Duration_exports,
91
- Effect_exports,
92
- Encoding_exports,
93
- Match_exports,
94
- Option_exports,
95
- Redacted_exports,
96
- SchemaIssue_exports,
97
- Schema_exports,
98
- Stream_exports
99
- } from "./chunk-FW5HBOIK.js";
100
-
101
- // src/implementation/elicitation.ts
102
- var prepareElicitation = (input) => Effect_exports.gen(function* () {
103
- const request = yield* Schema_exports.decodeUnknownEffect(FormElicitation)(input, {
104
- onExcessProperty: "error"
105
- }).pipe(Effect_exports.mapError(() => new ElicitationFailed({ reason: "invalid-request" })));
106
- const content = yield* jsonSchemaDecoder(request.requestedSchema).pipe(
107
- Effect_exports.mapError(() => new ElicitationFailed({ reason: "invalid-request" }))
108
- );
109
- const respond = (input2) => Effect_exports.gen(function* () {
110
- const response = yield* Schema_exports.decodeUnknownEffect(ElicitationResponse)(input2).pipe(
111
- Effect_exports.catchTag(
112
- "SchemaError",
113
- () => Effect_exports.fail(new ElicitationFailed({ reason: "invalid-response" }))
114
- )
115
- );
116
- if (response.action === "accept") {
117
- const fields = response.content === void 0 ? {} : response.content;
118
- yield* Schema_exports.decodeUnknownEffect(content)(fields).pipe(
119
- Effect_exports.mapError(() => new ElicitationFailed({ reason: "invalid-response" }))
120
- );
121
- return { ...response, content: fields };
122
- }
123
- return response;
124
- });
125
- return { request, respond };
126
- });
127
- var makeElicit = (handler, signal) => toPromise(
128
- (input) => Effect_exports.gen(function* () {
129
- if (handler === void 0) return yield* new ElicitationFailed({ reason: "unavailable" });
130
- const form = yield* prepareElicitation(input);
131
- return yield* handler(form.request, signal).pipe(Effect_exports.flatMap(form.respond));
132
- }),
133
- signal
134
- );
135
-
136
- // src/contracts/approval.ts
137
- var ApprovalDecision = Schema_exports.Literals(["approved", "denied", "user-approval"]);
138
-
139
- // src/implementation/workflow-context.ts
140
- var workflowSafe = (work) => work.pipe(
141
- Effect_exports.catchCause((cause) => {
142
- if (Cause_exports.hasInterrupts(cause)) return Effect_exports.interrupt;
143
- const error = Cause_exports.squash(cause);
144
- if (Schema_exports.is(WorkflowFailure)(error)) return Effect_exports.fail(error);
145
- return Effect_exports.fail(
146
- new WorkflowFailure({
147
- reason: "execution",
148
- retryable: !(error instanceof NonRetryableError)
149
- })
150
- );
151
- })
152
- );
153
- var makeWorkflowContext = (execution, definition, fresh, signal) => Effect_exports.gen(function* () {
154
- const services = yield* Effect_exports.context();
155
- const counts = /* @__PURE__ */ new Map();
156
- const identify = (kind, name) => Effect_exports.gen(function* () {
157
- yield* Schema_exports.decodeUnknownEffect(WorkflowName)(name).pipe(
158
- Effect_exports.mapError(() => new WorkflowFailure({ reason: "input", retryable: false }))
159
- );
160
- const key = JSON.stringify([kind, name]);
161
- const count = (counts.get(key) ?? 0) + 1;
162
- counts.set(key, count);
163
- const digest = yield* Effect_exports.tryPromise({
164
- try: () => crypto.subtle.digest(
165
- "SHA-256",
166
- new TextEncoder().encode(JSON.stringify([execution.runId, kind, name, count]))
167
- ),
168
- catch: () => new WorkflowFailure({ reason: "execution", retryable: false })
169
- });
170
- return Array.from(
171
- new Uint8Array(digest),
172
- (byte) => byte.toString(16).padStart(2, "0")
173
- ).join("");
174
- });
175
- const attempt = (options, work) => {
176
- const timeout = workflowDurationMillis(options.timeout ?? "10 minutes");
177
- if (timeout === void 0)
178
- return Effect_exports.fail(new WorkflowFailure({ reason: "input", retryable: false }));
179
- return work.pipe(
180
- Effect_exports.timeout(timeout),
181
- Effect_exports.catchTag(
182
- "TimeoutError",
183
- () => (
184
- // Both the capability deadline and the native engine deadline describe
185
- // the same cancellation, regardless of which timer fires first.
186
- Effect_exports.fail(new WorkflowFailure({ reason: "engine", retryable: true }))
187
- )
188
- )
189
- );
190
- };
191
- const runStep = (name, options, callback) => Effect_exports.gen(function* () {
192
- const stepId = yield* identify("do", name);
193
- const parsed = yield* Schema_exports.decodeUnknownEffect(WorkflowStepOptions)(options).pipe(
194
- Effect_exports.mapError(() => new WorkflowFailure({ reason: "input", retryable: false }))
195
- );
196
- return yield* execution.driver.do(
197
- `do:${name.slice(0, 100)}:${stepId}`,
198
- parsed,
199
- () => attempt(
200
- parsed,
201
- Effect_exports.scoped(
202
- Effect_exports.gen(function* () {
203
- const controller = yield* Effect_exports.acquireRelease(
204
- Effect_exports.sync(() => new AbortController()),
205
- (controller2) => Effect_exports.sync(() => controller2.abort())
206
- );
207
- const ctx = yield* fresh(stepId, AbortSignal.any([signal, controller.signal]));
208
- const result = yield* workflowSafe(
209
- Effect_exports.tryPromise({ try: () => callback(ctx), catch: (error) => error })
210
- );
211
- return yield* Schema_exports.decodeUnknownEffect(WorkflowValue)(result).pipe(
212
- Effect_exports.mapError(
213
- () => new WorkflowFailure({ reason: "output", retryable: false })
214
- )
215
- );
216
- })
217
- ).pipe(Effect_exports.provideContext(services))
218
- )
219
- );
220
- });
221
- const operationStep = (kind, name, operation, input, options) => Effect_exports.gen(function* () {
222
- const target = nativeOperation(operation);
223
- const catalog = kind === "query" ? definition.queries : definition.mutations;
224
- const match = Object.entries(catalog ?? {}).find(
225
- ([, value]) => value === target && value.kind === kind
226
- );
227
- if (target === void 0 || match === void 0)
228
- return yield* new WorkflowFailure({ reason: "operation", retryable: false });
229
- const args = yield* Schema_exports.decodeUnknownEffect(JsonValue)(input).pipe(
230
- Effect_exports.mapError(() => new WorkflowFailure({ reason: "input", retryable: false }))
231
- );
232
- const parsed = yield* Schema_exports.decodeUnknownEffect(WorkflowStepOptions)(options).pipe(
233
- Effect_exports.mapError(() => new WorkflowFailure({ reason: "input", retryable: false }))
234
- );
235
- const stepId = yield* identify(kind, name);
236
- const timeout = workflowDurationMillis(parsed.timeout ?? "10 minutes");
237
- if (timeout === void 0)
238
- return yield* new WorkflowFailure({ reason: "input", retryable: false });
239
- return yield* execution.driver.do(
240
- `${kind}:${name.slice(0, 100)}:${stepId}`,
241
- parsed,
242
- () => attempt(
243
- parsed,
244
- execution.invoke({ kind, name: match[0], input: args, stepId, timeout }).pipe(Effect_exports.provideContext(services))
245
- )
246
- );
247
- });
248
- const invoke = (effect) => toPromise(() => effect.pipe(Effect_exports.provideContext(services)), signal)();
249
- const step = {
250
- do: (name, options, run) => {
251
- const callback = typeof options === "function" ? options : run;
252
- if (callback === void 0)
253
- return Promise.reject(new WorkflowFailure({ reason: "input", retryable: false }));
254
- return invoke(runStep(name, typeof options === "function" ? {} : options, callback));
255
- },
256
- runQuery: (name, operation, input, options = {}) => invoke(operationStep("query", name, operation, input, options)),
257
- runMutation: (name, operation, input, options = {}) => invoke(operationStep("mutation", name, operation, input, options)),
258
- sleep: (name, duration) => invoke(
259
- Schema_exports.decodeUnknownEffect(WorkflowDuration)(duration).pipe(
260
- Effect_exports.mapError(() => new WorkflowFailure({ reason: "input", retryable: false })),
261
- Effect_exports.flatMap(
262
- (parsed) => identify("sleep", name).pipe(
263
- Effect_exports.flatMap(
264
- (id) => execution.driver.sleep(`sleep:${name.slice(0, 100)}:${id}`, parsed)
265
- )
266
- )
267
- )
268
- )
269
- ),
270
- sleepUntil: (name, timestamp) => invoke(
271
- identify("until", name).pipe(
272
- Effect_exports.flatMap(
273
- (id) => execution.driver.sleepUntil(
274
- `until:${name.slice(0, 100)}:${id}`,
275
- timestamp instanceof Date ? timestamp.getTime() : timestamp
276
- )
277
- )
278
- )
279
- )
280
- };
281
- return { runId: execution.runId, step };
282
- });
283
-
284
- // src/implementation/input-problems.ts
285
- var leafHook = (issue) => SchemaIssue_exports.hasInput(issue) ? "Invalid value" : SchemaIssue_exports.defaultLeafHook(issue);
286
- var checkHook = (issue) => SchemaIssue_exports.hasInput(issue) || SchemaIssue_exports.hasInput(issue.issue) ? SchemaIssue_exports.defaultCheckHook(issue) ?? "Invalid value" : SchemaIssue_exports.defaultCheckHook(issue);
287
- var format = SchemaIssue_exports.makeFormatterStandardSchemaV1({ leafHook, checkHook });
288
- var segment = (key) => typeof key === "number" ? `[${key}]` : typeof key === "string" && /^[A-Za-z_$][\w$-]{0,63}$/.test(key) ? `.${key}` : "[key]";
289
- var inputInvalid = (error) => {
290
- if (!Schema_exports.isSchemaError(error)) return new HostInputInvalid();
291
- const problems = format(error.issue).issues.slice(0, maxInputProblems).map(({ path, message }) => {
292
- const location = (path ?? []).map((key) => segment(typeof key === "object" ? key.key : key));
293
- return `${location.length === 0 ? "input" : `input${location.join("")}`}: ${message}`.slice(
294
- 0,
295
- 512
296
- );
297
- });
298
- return new HostInputInvalid({ problems });
299
- };
300
-
301
- // src/implementation/webhooks.ts
302
- var safe = (work, error) => Effect_exports.suspend(work).pipe(
303
- Effect_exports.catchCause(
304
- (cause) => Cause_exports.hasInterrupts(cause) ? Effect_exports.interrupt : Effect_exports.fail(error)
305
- )
306
- );
307
- var dispatchWebhook = (definition, command, context, accounts) => Effect_exports.gen(function* () {
308
- const hooks = definition.webhooks ?? {};
309
- if (command.operation === "webhooks") {
310
- return yield* Effect_exports.forEach(
311
- Object.entries(hooks),
312
- ([name, hook2]) => safe(
313
- () => Effect_exports.gen(function* () {
314
- if (!Object.hasOwn(accounts, hook2.account))
315
- return yield* new HostDeclarationInvalid();
316
- const describe = (schema) => {
317
- const imported = importedJsonSchema(schema);
318
- if (imported !== void 0) return Schema_exports.decodeUnknownEffect(JsonObject)(imported);
319
- const document = Schema_exports.toJsonSchemaDocument(schema);
320
- return Schema_exports.decodeUnknownEffect(JsonObject)({
321
- ...document.schema,
322
- $defs: document.definitions
323
- });
324
- };
325
- const configSchema = yield* describe(hook2.config);
326
- if (hook2.setup === void 0 ? hook2.register === void 0 || hook2.unregister === void 0 : hook2.register !== void 0 || hook2.unregister !== void 0)
327
- return yield* new HostDeclarationInvalid();
328
- const setup = hook2.setup === void 0 ? void 0 : {
329
- ...yield* Schema_exports.decodeUnknownEffect(ManualWebhookSetup)(hook2.setup),
330
- stateSchema: yield* describe(hook2.state)
331
- };
332
- return yield* Schema_exports.decodeUnknownEffect(HostedWebhook)({
333
- name,
334
- account: hook2.account,
335
- configSchema,
336
- ...setup === void 0 ? {} : { setup }
337
- });
338
- }),
339
- new HostDeclarationInvalid()
340
- )
341
- );
342
- }
343
- const hook = Object.hasOwn(hooks, command.name) ? hooks[command.name] : void 0;
344
- if (hook === void 0) return yield* new HostOperationNotFound();
345
- const selected = accounts[hook.account];
346
- const source = Array.isArray(selected) ? selected.find((account2) => account2.id === command.sourceAccount) : selected;
347
- if (source === void 0 || source.id !== command.sourceAccount)
348
- return yield* new HostInputInvalid();
349
- const bound = context.accounts[hook.account];
350
- const account = Array.isArray(bound) ? bound.find(
351
- (value) => typeof value === "object" && value !== null && "id" in value && value.id === source.id
352
- ) : bound;
353
- const config = yield* safe(
354
- () => Schema_exports.decodeUnknownEffect(hook.config)(command.config),
355
- new HostInputInvalid()
356
- );
357
- if (command.operation === "webhook-validate")
358
- return yield* safe(
359
- () => Schema_exports.decodeUnknownEffect(JsonValue)(config),
360
- new HostInputInvalid()
361
- );
362
- const input = {
363
- config,
364
- subscriptionId: command.subscriptionId,
365
- account,
366
- callbackUrl: command.callbackUrl,
367
- secret: command.secret
368
- };
369
- const invoke = (callback, value) => safe(() => callback(context, value), new HostOperationFailed());
370
- if (command.operation === "webhook-complete") {
371
- if (hook.setup === void 0) return yield* new HostInputInvalid();
372
- return yield* safe(
373
- () => Schema_exports.decodeUnknownEffect(hook.state)(command.state).pipe(
374
- Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(JsonValue))
375
- ),
376
- new HostInputInvalid()
377
- );
378
- }
379
- if (command.operation === "webhook-register") {
380
- if (hook.register === void 0 || hook.setup !== void 0)
381
- return yield* new HostOperationFailed();
382
- const state2 = yield* invoke(hook.register, input);
383
- return yield* safe(
384
- () => Schema_exports.decodeUnknownEffect(hook.state)(state2).pipe(
385
- Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(JsonValue))
386
- ),
387
- new HostOutputInvalid()
388
- );
389
- }
390
- const state = command.state === null ? null : yield* safe(
391
- () => Schema_exports.decodeUnknownEffect(hook.state)(command.state),
392
- new HostInputInvalid()
393
- );
394
- if (command.operation === "webhook-unregister") {
395
- if (hook.unregister === void 0 || hook.setup !== void 0)
396
- return yield* new HostOperationFailed();
397
- yield* invoke(hook.unregister, { ...input, state });
398
- return null;
399
- }
400
- const body = yield* Effect_exports.fromResult(Encoding_exports.decodeBase64(command.request.body)).pipe(
401
- Effect_exports.mapError(() => new HostInputInvalid())
402
- );
403
- if (body.byteLength > defaultWebhookTransportLimits.maxBodyBytes)
404
- return yield* new HostInputInvalid();
405
- const request = yield* safe(
406
- () => Effect_exports.sync(
407
- () => new Request(command.request.url, {
408
- method: command.request.method,
409
- headers: command.request.headers,
410
- ...context.signal === void 0 ? {} : { signal: context.signal },
411
- ...command.request.method === "GET" || command.request.method === "HEAD" ? {} : { body: Uint8Array.from(body) }
412
- })
413
- ),
414
- new HostInputInvalid()
415
- );
416
- const response = yield* invoke(hook.handle, { ...input, state, request });
417
- if (!(response instanceof Response)) return yield* new HostOutputInvalid();
418
- const chunks = [];
419
- let size = 0;
420
- const stream = response.body;
421
- if (stream !== null)
422
- yield* Stream_exports.fromReadableStream({
423
- evaluate: () => stream,
424
- onError: () => new HostOutputInvalid()
425
- }).pipe(
426
- Stream_exports.runForEach(
427
- (chunk) => Effect_exports.gen(function* () {
428
- size += chunk.byteLength;
429
- if (size > defaultWebhookTransportLimits.maxBodyBytes)
430
- return yield* new HostOutputInvalid();
431
- chunks.push(chunk);
432
- })
433
- )
434
- );
435
- const bytes = new Uint8Array(size);
436
- let offset = 0;
437
- for (const chunk of chunks) {
438
- bytes.set(chunk, offset);
439
- offset += chunk.byteLength;
440
- }
441
- const headers = {};
442
- response.headers.forEach((value, name) => {
443
- headers[name] = value;
444
- });
445
- return yield* safe(
446
- () => Schema_exports.decodeUnknownEffect(WebhookResponseData)({
447
- status: response.status,
448
- headers,
449
- body: Encoding_exports.encodeBase64(new Uint8Array(bytes))
450
- }),
451
- new HostOutputInvalid()
452
- );
453
- });
454
-
455
- // ../app-cache/src/index.ts
456
- var canonical = (value) => {
457
- if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
458
- if (value !== null && typeof value === "object")
459
- return `{${Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(",")}}`;
460
- return JSON.stringify(value);
461
- };
462
- var cacheKey = (key) => Effect_exports.gen(function* () {
463
- const parsed = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Json)(key).pipe(
464
- Effect_exports.mapError(() => new CacheError({ reason: "invalid" }))
465
- );
466
- const bytes = new TextEncoder().encode(canonical(parsed));
467
- if (bytes.byteLength > cacheLimits.keyBytes)
468
- return yield* new CacheError({ reason: "capacity" });
469
- const hash = yield* Effect_exports.tryPromise({
470
- try: () => crypto.subtle.digest("SHA-256", bytes),
471
- catch: () => new CacheError({ reason: "invalid" })
472
- });
473
- return [...new Uint8Array(hash)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
474
- });
475
- var makeCache = (transport, background, scope = "shared") => {
476
- const keyOf = (key) => cacheKey([scope, key]);
477
- const readKeys = (keys) => transport({ operation: "read", keys }).pipe(
478
- Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(Schema_exports.NullOr(CacheEntry)))),
479
- Effect_exports.mapError(() => new CacheError({ reason: "storage" }))
480
- );
481
- const durations = (freshFor, staleFor = 0) => Effect_exports.try({
482
- try: () => {
483
- const fresh = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(freshFor));
484
- const stale = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(staleFor));
485
- if (![fresh, stale].every((value) => Number.isFinite(value) && value >= 0) || fresh + stale > cacheLimits.retentionMs)
486
- throw new CacheError({ reason: "invalid" });
487
- return { fresh, stale };
488
- },
489
- catch: () => new CacheError({ reason: "invalid" })
490
- });
491
- const get = (options, refresh) => Effect_exports.gen(function* () {
492
- const key = yield* keyOf(options.key);
493
- const { fresh, stale } = yield* durations(options.freshFor, options.staleFor);
494
- const decode = (value) => Schema_exports.decodeUnknownEffect(options.schema)(value);
495
- const load = (lease) => Effect_exports.gen(function* () {
496
- const value = yield* options.load.pipe(Effect_exports.flatMap(decode));
497
- const json = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Json)(value).pipe(
498
- Effect_exports.mapError(() => new CacheError({ reason: "invalid" }))
499
- );
500
- const now = yield* Clock_exports.currentTimeMillis;
501
- const published = yield* transport({
502
- operation: "publish",
503
- key,
504
- lease,
505
- entry: {
506
- value: json,
507
- version: crypto.randomUUID(),
508
- freshUntil: now + fresh,
509
- staleUntil: now + fresh + stale
510
- }
511
- });
512
- if (published !== true) return yield* new CacheError({ reason: "unavailable" });
513
- return value;
514
- }).pipe(
515
- Effect_exports.withSpan("app.cache.load"),
516
- Effect_exports.timeout(cacheLimits.loadTimeoutMs),
517
- Effect_exports.ensuring(
518
- transport({ operation: "release", key, lease }).pipe(Effect_exports.catch(() => Effect_exports.void))
519
- )
520
- );
521
- const deadline = (yield* Clock_exports.currentTimeMillis) + cacheLimits.leaseMs;
522
- let initialVersion;
523
- while (true) {
524
- const entry = (yield* readKeys([key]))[0] ?? null;
525
- const now = yield* Clock_exports.currentTimeMillis;
526
- if (initialVersion === void 0) initialVersion = entry?.version ?? null;
527
- const refreshed = refresh && entry !== null && entry.version !== initialVersion;
528
- if (entry !== null && (refreshed || !refresh && now < entry.freshUntil)) {
529
- yield* Effect_exports.annotateCurrentSpan("cache.result", "fresh");
530
- return yield* decode(entry.value);
531
- }
532
- const lease = yield* transport({
533
- operation: "claim",
534
- key,
535
- version: entry?.version ?? null
536
- }).pipe(Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.NullOr(Schema_exports.String))));
537
- if (!refresh && entry !== null && now < entry.staleUntil) {
538
- yield* Effect_exports.annotateCurrentSpan("cache.result", "stale");
539
- if (lease !== null) yield* background(load(lease).pipe(Effect_exports.asVoid));
540
- return yield* decode(entry.value);
541
- }
542
- if (lease !== null) {
543
- yield* Effect_exports.annotateCurrentSpan("cache.result", "miss");
544
- return yield* load(lease);
545
- }
546
- if (now >= deadline) return yield* new CacheError({ reason: "timeout" });
547
- yield* Effect_exports.sleep("100 millis");
548
- }
549
- }).pipe(Effect_exports.withSpan("app.cache.get"));
550
- return {
551
- /** Read arbitrary retained JSON entries without initiating a refresh. Missing and null are distinct. */
552
- read: (keys) => Effect_exports.forEach(keys, keyOf).pipe(Effect_exports.flatMap(readKeys)),
553
- /** Publish bounded immutable parts before publishing the manifest that references them. */
554
- write: (entries, retention) => Effect_exports.gen(function* () {
555
- const { fresh } = yield* durations(retention);
556
- const now = yield* Clock_exports.currentTimeMillis;
557
- const values = yield* Effect_exports.forEach(
558
- entries,
559
- ({ key, value }) => Effect_exports.gen(function* () {
560
- return {
561
- key: yield* keyOf(key),
562
- entry: {
563
- value,
564
- version: crypto.randomUUID(),
565
- freshUntil: now + fresh,
566
- staleUntil: now + fresh
567
- }
568
- };
569
- })
570
- );
571
- yield* transport({ operation: "write", entries: values });
572
- }),
573
- /** Revoke retained data and any loader's right to publish its in-flight result. */
574
- invalidate: (key) => keyOf(key).pipe(
575
- Effect_exports.flatMap((key2) => transport({ operation: "invalidate", key: key2 })),
576
- Effect_exports.asVoid
577
- ),
578
- /** Read fresh data, refresh stale data in the background, or wait for the lease owner. */
579
- get: (options) => get(options, false),
580
- /** Force one awaited refresh without removing the retained value. Concurrent refreshes share a load. */
581
- revalidate: (options) => get(options, true)
582
- };
583
- };
584
-
585
- // src/implementation/cache.ts
586
- var unavailableCache = {
587
- transport: () => Effect_exports.fail(new CacheError({ reason: "unavailable" })),
588
- background: () => Effect_exports.die(new Error("Cache background runner is unavailable"))
589
- };
590
- var authorCache = (host, accounts, signal) => {
591
- const scoped = (scope, callerSignal = signal) => {
592
- const cache = makeCache(host.transport, host.background, scope);
593
- const load = (method, options) => cache[method]({
594
- key: options.key,
595
- schema: decoderOf(options.schema),
596
- freshFor: options.freshFor,
597
- ...options.staleFor === void 0 ? {} : { staleFor: options.staleFor },
598
- load: Effect_exports.acquireUseRelease(
599
- Effect_exports.sync(() => new AbortController()),
600
- (controller) => invocationFetch(controller.signal).pipe(
601
- Effect_exports.flatMap(
602
- (fetch) => fromPromise(options.load)({
603
- fetch,
604
- signal: controller.signal,
605
- cache: scoped(scope, controller.signal)
606
- })
607
- )
608
- ),
609
- (controller) => Effect_exports.sync(() => controller.abort())
610
- )
611
- });
612
- return {
613
- get: toPromise((options) => load("get", options), callerSignal),
614
- revalidate: toPromise(
615
- (options) => load("revalidate", options),
616
- callerSignal
617
- ),
618
- read: toPromise(
619
- (key, schema) => cache.read([key]).pipe(
620
- Effect_exports.flatMap((entries) => {
621
- const entry = entries[0];
622
- return entry === void 0 || entry === null ? Effect_exports.succeed(void 0) : Schema_exports.decodeUnknownEffect(decoderOf(schema))(entry.value);
623
- })
624
- ),
625
- callerSignal
626
- ),
627
- readMany: toPromise(
628
- (keys, schema) => cache.read(keys).pipe(
629
- Effect_exports.flatMap(
630
- (entries) => Effect_exports.forEach(
631
- entries,
632
- (entry) => entry === null ? Effect_exports.succeed(void 0) : Schema_exports.decodeUnknownEffect(decoderOf(schema))(entry.value)
633
- )
634
- )
635
- ),
636
- callerSignal
637
- ),
638
- write: toPromise(cache.write, callerSignal),
639
- invalidate: toPromise(cache.invalidate, callerSignal),
640
- forAccount: (account) => {
641
- const bound = Object.values(accounts).flatMap((value) => Array.isArray(value) ? value : [value]).find((value) => value.id === account.id);
642
- if (bound === void 0) throw new CacheError({ reason: "invalid" });
643
- return scoped(
644
- { account: bound.id, method: bound.method, fields: bound.fields },
645
- callerSignal
646
- );
647
- }
648
- };
649
- };
650
- return scoped("shared");
651
- };
652
-
653
- // src/implementation/host.ts
654
- function safe2(work, failure) {
655
- return Effect_exports.suspend(work).pipe(
656
- Effect_exports.catchCause(
657
- (cause) => Cause_exports.hasInterrupts(cause) ? Effect_exports.interrupt : Effect_exports.fail(failure)
658
- )
659
- );
660
- }
661
- var evaluationSafe = (work) => work.pipe(
662
- Effect_exports.catchCause((cause) => {
663
- if (Cause_exports.hasInterrupts(cause)) return Effect_exports.interrupt;
664
- const error = Cause_exports.squash(cause);
665
- const provider = parseProviderError(error);
666
- const skills = parseSkillLoadFailed(error);
667
- const mcp = parseMcpError(error);
668
- return Effect_exports.fail(
669
- Option_exports.isSome(provider) ? provider.value : Option_exports.isSome(skills) ? skills.value : Option_exports.isSome(mcp) ? mcp.value : new HostEvaluationFailed()
670
- );
671
- })
672
- );
673
- function jsonSchema(decoder) {
674
- const imported = importedJsonSchema(decoder);
675
- if (imported !== void 0) return Schema_exports.decodeUnknownEffect(JsonObject)(imported);
676
- const document = Schema_exports.toJsonSchemaDocument(decoder);
677
- return Schema_exports.decodeUnknownEffect(JsonObject)({
678
- ...document.schema,
679
- $defs: document.definitions,
680
- $schema: "https://json-schema.org/draft/2020-12/schema"
681
- });
682
- }
683
- function providerDeclaration(provider) {
684
- return safe2(
685
- () => Effect_exports.gen(function* () {
686
- const auth = /* @__PURE__ */ new Map();
687
- for (const [name, method] of Object.entries(provider.auth)) {
688
- switch (method._tag) {
689
- case "secrets":
690
- auth.set(name, {
691
- type: "secrets",
692
- label: method.label,
693
- fields: yield* jsonSchema(method.fields)
694
- });
695
- break;
696
- case "oauth2":
697
- auth.set(name, {
698
- type: "oauth2",
699
- ...method.config,
700
- response: yield* jsonSchema(method.response)
701
- });
702
- break;
703
- }
704
- }
705
- return yield* Schema_exports.decodeUnknownEffect(DeclaredProvider)({
706
- name: provider.name,
707
- auth: Object.fromEntries(auth)
708
- });
709
- }),
710
- new HostDeclarationInvalid()
711
- );
712
- }
713
- function requirements(slots, database) {
714
- return Effect_exports.gen(function* () {
715
- const accounts = /* @__PURE__ */ new Map();
716
- for (const [slot, selection] of Object.entries(slots)) {
717
- accounts.set(slot, {
718
- cardinality: selection instanceof ManyAccounts ? "many" : "one",
719
- definition: yield* providerDeclaration(
720
- selection instanceof ManyAccounts ? selection.provider : selection
721
- )
722
- });
723
- }
724
- return yield* Schema_exports.decodeUnknownEffect(DeclaredRequirements)({
725
- accounts: Object.fromEntries(accounts),
726
- capabilities: { skills: true, toolIndex: true, skillSources: true, scheduledTools: true },
727
- ...database === void 0 ? {} : { database }
728
- }).pipe(Effect_exports.mapError(() => new HostDeclarationInvalid()));
729
- });
730
- }
731
- function canonical2(value) {
732
- if (Array.isArray(value)) return `[${value.map(canonical2).join(",")}]`;
733
- if (value !== null && typeof value === "object") {
734
- return `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${JSON.stringify(key)}:${canonical2(item)}`).join(",")}}`;
735
- }
736
- return JSON.stringify(value);
737
- }
738
- function bindAccounts(slots, declarations, context) {
739
- return safe2(
740
- () => Effect_exports.gen(function* () {
741
- const selected = yield* Schema_exports.decodeUnknownEffect(ResolvedAccounts)(
742
- Redacted_exports.value(context.accounts)
743
- );
744
- if (Object.keys(selected).some((slot) => !Object.hasOwn(slots, slot))) {
745
- return yield* Effect_exports.fail(new HostAccountsInvalid());
746
- }
747
- const bound = /* @__PURE__ */ new Map();
748
- for (const [slot, selection] of Object.entries(slots)) {
749
- const requirement = declarations.accounts[slot];
750
- const supplied = Object.hasOwn(selected, slot) ? selected[slot] : void 0;
751
- if (requirement === void 0 || supplied === void 0)
752
- return yield* Effect_exports.fail(new HostAccountsInvalid());
753
- const provider = selection instanceof ManyAccounts ? selection.provider : selection;
754
- const many = selection instanceof ManyAccounts;
755
- if (many !== Array.isArray(supplied))
756
- return yield* Effect_exports.fail(new HostAccountsInvalid());
757
- const accounts = Array.isArray(supplied) ? supplied : [supplied];
758
- const ids = /* @__PURE__ */ new Set();
759
- const values = [];
760
- for (const account of accounts) {
761
- if (ids.has(account.id)) return yield* Effect_exports.fail(new HostAccountsInvalid());
762
- ids.add(account.id);
763
- if (canonical2(account.provider) !== canonical2(requirement.definition) || !Object.hasOwn(provider.auth, account.method))
764
- return yield* Effect_exports.fail(new HostAccountsInvalid());
765
- const method = provider.auth[account.method];
766
- if (method === void 0) return yield* Effect_exports.fail(new HostAccountsInvalid());
767
- const fields = yield* Schema_exports.decodeUnknownEffect(
768
- method._tag === "secrets" ? method.fields : method.response
769
- )(account.fields);
770
- values.push({ id: account.id, method: account.method, fields });
771
- }
772
- if (many) bound.set(slot, values);
773
- else {
774
- const account = values[0];
775
- if (account === void 0) return yield* Effect_exports.fail(new HostAccountsInvalid());
776
- bound.set(slot, account);
777
- }
778
- }
779
- return { accounts: Object.fromEntries(bound) };
780
- }),
781
- new HostAccountsInvalid()
782
- );
783
- }
784
- function dispatch(app, request, context, signal) {
785
- return Effect_exports.scoped(
786
- Effect_exports.gen(function* () {
787
- if (!isApp(app)) return yield* Effect_exports.fail(new HostDeclarationInvalid());
788
- const native = toEffectApp(app);
789
- const declared = yield* requirements(native.accounts, native.database?.schema);
790
- if (request.operation === "requirements")
791
- return yield* safe2(
792
- () => Schema_exports.decodeUnknownEffect(JsonValue)(declared),
793
- new HostDeclarationInvalid()
794
- );
795
- const lifetime = yield* Effect_exports.acquireRelease(
796
- Effect_exports.sync(() => new AbortController()),
797
- (controller) => Effect_exports.sync(() => controller.abort())
798
- );
799
- const invocationSignal = AbortSignal.any([signal, lifetime.signal]);
800
- const deadline = context.deadline === void 0 ? void 0 : yield* safe2(
801
- () => Schema_exports.decodeUnknownEffect(InvocationDeadline)(context.deadline),
802
- new HostInputInvalid()
803
- );
804
- const withinDeadline = (work) => Effect_exports.gen(function* () {
805
- if (deadline === void 0) return yield* work;
806
- const remaining = deadline - (yield* Clock_exports.currentTimeMillis);
807
- if (remaining <= 0)
808
- return yield* new WorkflowFailure({ reason: "engine", retryable: true });
809
- const result = yield* work.pipe(
810
- Effect_exports.timeout(remaining),
811
- Effect_exports.catchTag(
812
- "TimeoutError",
813
- () => Effect_exports.fail(new WorkflowFailure({ reason: "engine", retryable: true }))
814
- )
815
- );
816
- if ((yield* Clock_exports.currentTimeMillis) >= deadline)
817
- return yield* new WorkflowFailure({ reason: "engine", retryable: true });
818
- return result;
819
- });
820
- let running;
821
- let transactionOpen = false;
822
- const delivery = (request2, signal2) => Effect_exports.suspend(
823
- () => transactionOpen ? Effect_exports.fail(new ElicitationFailed({ reason: "transaction" })) : running !== void 0 && context.elicitation !== void 0 ? context.elicitation(request2, signal2).pipe(
824
- Effect_exports.withSpan("app.tool.elicitation"),
825
- Effect_exports.provideContext(running.context)
826
- ) : Effect_exports.fail(new ElicitationFailed({ reason: "unavailable" }))
827
- );
828
- const unavailableWorkflow = () => Effect_exports.fail(new WorkflowFailure({ reason: "unavailable", retryable: false }));
829
- const workflowControls = {
830
- start: toPromise(
831
- (input2) => context.workflowControls === void 0 ? unavailableWorkflow() : context.workflowControls.start(input2),
832
- invocationSignal
833
- ),
834
- get: toPromise(
835
- (input2) => context.workflowControls === void 0 ? unavailableWorkflow() : context.workflowControls.get(input2),
836
- invocationSignal
837
- ),
838
- list: toPromise(
839
- (input2) => context.workflowControls === void 0 ? unavailableWorkflow() : context.workflowControls.list(input2),
840
- invocationSignal
841
- ),
842
- terminate: toPromise(
843
- (input2) => context.workflowControls === void 0 ? unavailableWorkflow() : context.workflowControls.terminate(input2),
844
- invocationSignal
845
- )
846
- };
847
- const workflowReads = {
848
- get: workflowControls.get,
849
- list: workflowControls.list
850
- };
851
- const files = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Array(SkillFile))(
852
- context.files ?? []
853
- ).pipe(Effect_exports.mapError(() => new HostDeclarationInvalid()));
854
- const bound = {
855
- cache: authorCache(
856
- context.cache ?? unavailableCache,
857
- Redacted_exports.value(context.accounts),
858
- invocationSignal
859
- ),
860
- files,
861
- ...yield* bindAccounts(native.accounts, declared, context).pipe(
862
- Effect_exports.withSpan("app.accounts.bind")
863
- ),
864
- workflows: workflowReads,
865
- signal: invocationSignal,
866
- fetch: yield* invocationFetch(invocationSignal),
867
- elicit: makeElicit(delivery, invocationSignal)
868
- };
869
- const definition = yield* evaluationSafe(native.evaluate(bound)).pipe(
870
- Effect_exports.withSpan("app.evaluate")
871
- );
872
- if (request.operation === "skills") {
873
- const declared2 = definition.skills ?? (yield* folderSkillsEffect({ files }).pipe(
874
- Effect_exports.mapError(() => new HostDeclarationInvalid())
875
- ));
876
- const source2 = definition.dynamicSkills;
877
- const dynamic = source2 === void 0 ? [] : yield* evaluationSafe(Effect_exports.suspend(source2.list)).pipe(
878
- Effect_exports.withSpan("app.skills.load")
879
- );
880
- const skills = yield* Schema_exports.decodeUnknownEffect(AppSkills)([...declared2, ...dynamic]).pipe(
881
- Effect_exports.mapError(() => new HostDeclarationInvalid())
882
- );
883
- return request.sources === true ? { skills, dynamic: source2 !== void 0 } : skills;
884
- }
885
- if (request.operation === "workflows") {
886
- return yield* Effect_exports.forEach(
887
- Object.entries(definition.workflows ?? {}),
888
- ([name2, entry]) => safe2(
889
- () => Effect_exports.gen(function* () {
890
- return yield* Schema_exports.decodeUnknownEffect(HostedWorkflow)({
891
- name: name2,
892
- ...entry.description === void 0 ? {} : { description: entry.description },
893
- inputSchema: yield* jsonSchema(entry.input),
894
- ...entry.output === void 0 ? {} : { outputSchema: yield* jsonSchema(entry.output) }
895
- });
896
- }),
897
- new HostDeclarationInvalid()
898
- )
899
- );
900
- }
901
- if (request.operation === "workflow-validate" || request.operation === "workflow-run") {
902
- const entry = definition.workflows !== void 0 && Object.hasOwn(definition.workflows, request.name) ? definition.workflows[request.name] : void 0;
903
- if (entry === void 0)
904
- return yield* new WorkflowFailure({ reason: "not_found", retryable: false });
905
- const input2 = yield* safe2(
906
- () => Schema_exports.decodeUnknownEffect(entry.input)(request.input),
907
- new WorkflowFailure({ reason: "input", retryable: false })
908
- );
909
- if (request.operation === "workflow-validate")
910
- return yield* safe2(
911
- () => Schema_exports.decodeUnknownEffect(WorkflowValue)(input2),
912
- new WorkflowFailure({ reason: "input", retryable: false })
913
- );
914
- const execution = context.workflow;
915
- if (execution === void 0)
916
- return yield* new WorkflowFailure({ reason: "unavailable", retryable: false });
917
- const workflowContext = yield* makeWorkflowContext(
918
- execution,
919
- definition,
920
- (stepId, signal2) => Effect_exports.gen(function* () {
921
- const current = yield* execution.resolve();
922
- const accounts = yield* safe2(
923
- () => bindAccounts(native.accounts, declared, current),
924
- new WorkflowFailure({ reason: "credentials", retryable: false })
925
- );
926
- return {
927
- ...accounts,
928
- cache: authorCache(
929
- context.cache ?? unavailableCache,
930
- Redacted_exports.value(current.accounts),
931
- signal2
932
- ),
933
- files,
934
- fetch: yield* invocationFetch(signal2),
935
- signal: signal2,
936
- runId: execution.runId,
937
- stepId,
938
- idempotencyKey: stepId
939
- };
940
- }),
941
- invocationSignal
942
- );
943
- const output = yield* workflowSafe(entry.run(workflowContext, input2));
944
- const outputSchema = entry.output;
945
- const decoded = outputSchema === void 0 ? output : yield* safe2(
946
- () => Schema_exports.decodeUnknownEffect(outputSchema)(output),
947
- new WorkflowFailure({ reason: "output", retryable: false })
948
- );
949
- return yield* safe2(
950
- () => Schema_exports.decodeUnknownEffect(WorkflowValue)(decoded),
951
- new WorkflowFailure({ reason: "output", retryable: false })
952
- );
953
- }
954
- if (request.operation === "inspect") {
955
- const summary = request.detail === "summary";
956
- const wanted = request.tools === void 0 ? void 0 : new Set(request.tools);
957
- const metadata = [];
958
- for (const [prefix, readOnly, catalog2] of [
959
- [OperationToolPrefixes.query, true, definition.queries],
960
- [OperationToolPrefixes.mutate, false, definition.mutations]
961
- ]) {
962
- for (const [name2, operation] of Object.entries(catalog2 ?? {})) {
963
- if (wanted !== void 0 && !wanted.has(`${prefix}${name2}`)) continue;
964
- const schedules = Object.entries(definition.schedules ?? {}).filter(([, schedule]) => schedule.tool === `${prefix}${name2}`).map(([name3, { tool: _tool, ...schedule }]) => ({ name: name3, ...schedule }));
965
- if (request.scheduled === true && schedules.length === 0) continue;
966
- metadata.push(
967
- yield* safe2(
968
- () => Effect_exports.gen(function* () {
969
- const fields = {
970
- name: `${prefix}${name2}`,
971
- schedules,
972
- description: operation.description ?? `${readOnly ? "Query" : "Mutate"} ${name2}`,
973
- ...operation.title === void 0 ? {} : { title: operation.title },
974
- readOnly,
975
- annotations: { ...operation.annotations, readOnlyHint: readOnly }
976
- };
977
- if (summary)
978
- return yield* Schema_exports.decodeUnknownEffect(HostedToolSummary)(fields);
979
- return yield* Schema_exports.decodeUnknownEffect(HostedTool)({
980
- ...fields,
981
- inputSchema: yield* jsonSchema(operation.input),
982
- ...operation.output === void 0 ? operation.outputSchema === void 0 ? {} : { outputSchema: operation.outputSchema } : { outputSchema: yield* jsonSchema(operation.output) },
983
- ...operation._meta === void 0 ? {} : { _meta: operation._meta }
984
- });
985
- }),
986
- new HostDeclarationInvalid()
987
- )
988
- );
989
- }
990
- }
991
- const dynamic = request.scheduled === true ? void 0 : definition.dynamicTools;
992
- if (dynamic !== void 0 && (wanted === void 0 || metadata.length < wanted.size)) {
993
- const declared2 = new Set(metadata.map((tool2) => tool2.name));
994
- const discover = () => {
995
- if (summary && dynamic.summaries !== void 0) return dynamic.summaries();
996
- if (wanted !== void 0 && dynamic.describe !== void 0) {
997
- const describe = dynamic.describe;
998
- return Effect_exports.forEach(
999
- [...wanted].filter((name2) => !declared2.has(name2)),
1000
- (name2) => describe(name2),
1001
- { concurrency: "unbounded" }
1002
- ).pipe(Effect_exports.map((tools) => tools.filter((tool2) => tool2 !== void 0)));
1003
- }
1004
- return dynamic.list();
1005
- };
1006
- const discovered = yield* evaluationSafe(discover()).pipe(
1007
- Effect_exports.flatMap(
1008
- (value) => safe2(
1009
- () => summary ? Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedToolSummary))(value) : Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedTool))(value),
1010
- new HostDeclarationInvalid()
1011
- )
1012
- )
1013
- );
1014
- const names = new Set(declared2);
1015
- for (const tool2 of discovered) {
1016
- const readOnly = tool2.name.startsWith(OperationToolPrefixes.query);
1017
- if (!readOnly && !tool2.name.startsWith(OperationToolPrefixes.mutate) || tool2.name === OperationToolPrefixes.query || tool2.name === OperationToolPrefixes.mutate || names.has(tool2.name))
1018
- return yield* new HostDeclarationInvalid();
1019
- names.add(tool2.name);
1020
- if (wanted !== void 0 && !wanted.has(tool2.name)) continue;
1021
- metadata.push({
1022
- ...tool2,
1023
- readOnly,
1024
- annotations: { ...tool2.annotations, readOnlyHint: readOnly }
1025
- });
1026
- }
1027
- }
1028
- return metadata;
1029
- }
1030
- if (request.operation === "webhook-complete" || request.operation === "webhook-validate" || request.operation === "webhooks" || request.operation === "webhook-register" || request.operation === "webhook-handle" || request.operation === "webhook-unregister") {
1031
- const executeWebhook = (db) => dispatchWebhook(
1032
- definition,
1033
- request,
1034
- {
1035
- files,
1036
- cache: bound.cache,
1037
- accounts: bound.accounts,
1038
- workflows: workflowControls,
1039
- signal: bound.signal,
1040
- fetch: bound.fetch,
1041
- ...db === void 0 || native.database === void 0 ? {} : {
1042
- db: authorDatabase(native.database.tables, db, invocationSignal, true)
1043
- }
1044
- },
1045
- Redacted_exports.value(context.accounts)
1046
- );
1047
- if (native.database === void 0 || !["webhook-register", "webhook-handle", "webhook-unregister"].includes(request.operation))
1048
- return yield* executeWebhook();
1049
- const storage2 = context.storage ?? unavailableStorage;
1050
- return yield* storage2.mutate(native.database.schema, executeWebhook).pipe(
1051
- Effect_exports.catchTags({
1052
- AppDatabaseError: () => Effect_exports.fail(new HostOperationFailed()),
1053
- AppStorageUnavailable: () => Effect_exports.fail(new HostOperationFailed()),
1054
- AppStorageError: () => Effect_exports.fail(new HostOperationFailed())
1055
- })
1056
- );
1057
- }
1058
- const kind = request.operation === "call" ? request.tool.startsWith(OperationToolPrefixes.query) ? "query" : request.tool.startsWith(OperationToolPrefixes.mutate) ? "mutate" : void 0 : request.operation;
1059
- if (kind === void 0) return yield* new HostToolNotFound();
1060
- const name = request.operation === "call" ? request.tool.slice(OperationToolPrefixes[kind].length) : request.name;
1061
- const toolName = `${OperationToolPrefixes[kind]}${name}`;
1062
- const catalog = kind === "query" ? definition.queries : definition.mutations;
1063
- const declaredTool = catalog !== void 0 && Object.hasOwn(catalog, name) ? catalog[name] : void 0;
1064
- const source = definition.dynamicTools;
1065
- const resolvedTool = source === void 0 || declaredTool !== void 0 ? void 0 : yield* evaluationSafe(source.resolve(toolName));
1066
- const tool = declaredTool ?? resolvedTool;
1067
- if (tool !== void 0 && tool.kind !== (kind === "query" ? "query" : "mutation"))
1068
- return yield* new HostDeclarationInvalid();
1069
- if (tool === void 0)
1070
- return yield* request.operation === "call" ? new HostToolNotFound() : new HostOperationNotFound();
1071
- const input = yield* Effect_exports.suspend(
1072
- () => Schema_exports.decodeUnknownEffect(tool.input)(request.input)
1073
- ).pipe(
1074
- Effect_exports.catchCause(
1075
- (cause) => Cause_exports.hasInterrupts(cause) ? Effect_exports.interrupt : Effect_exports.fail(inputInvalid(Cause_exports.squash(cause)))
1076
- )
1077
- );
1078
- if (context.approval !== void 0) {
1079
- const approved = yield* safe2(
1080
- () => Schema_exports.decodeUnknownEffect(TrustedToolApproval)(context.approval),
1081
- new HostInputInvalid()
1082
- );
1083
- const decoded = yield* safe2(
1084
- () => Schema_exports.decodeUnknownEffect(JsonValue)(input),
1085
- new HostInputInvalid()
1086
- );
1087
- if (approved.tool !== toolName || !Schema_exports.toEquivalence(JsonValue)(approved.input, decoded)) {
1088
- return yield* new HostInputInvalid();
1089
- }
1090
- } else if (tool.approval !== void 0) {
1091
- const approval = tool.approval;
1092
- const decision = yield* safe2(
1093
- () => approval({ toolName, toolInput: input, signal: invocationSignal }).pipe(
1094
- Effect_exports.withSpan("app.tool.approval", {
1095
- attributes: { "executor.tool.name": toolName }
1096
- }),
1097
- Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(ApprovalDecision))
1098
- ),
1099
- new HostToolPolicyFailed()
1100
- );
1101
- yield* Match_exports.value(decision).pipe(
1102
- Match_exports.when("approved", () => Effect_exports.void),
1103
- Match_exports.when("denied", () => Effect_exports.fail(new HostToolBlocked())),
1104
- Match_exports.when(
1105
- "user-approval",
1106
- () => safe2(() => Schema_exports.decodeUnknownEffect(JsonValue)(input), new HostInputInvalid()).pipe(
1107
- Effect_exports.flatMap(
1108
- (input2) => Effect_exports.fail(
1109
- new HostToolApprovalRequired({
1110
- input: input2,
1111
- elicitation: approvalElicitation(toolName, input2)
1112
- })
1113
- )
1114
- )
1115
- )
1116
- ),
1117
- Match_exports.exhaustive
1118
- );
1119
- }
1120
- const execute = (db) => Effect_exports.gen(function* () {
1121
- transactionOpen = db !== void 0;
1122
- const output = yield* Effect_exports.gen(function* () {
1123
- running = yield* captureTelemetry;
1124
- const fetch = yield* invocationFetch(invocationSignal);
1125
- return yield* tool.run(
1126
- {
1127
- ...bound,
1128
- fetch,
1129
- workflows: kind === "mutate" ? workflowControls : workflowReads,
1130
- ...db === void 0 || native.database === void 0 ? {} : {
1131
- db: authorDatabase(
1132
- native.database.tables,
1133
- db,
1134
- invocationSignal,
1135
- kind === "mutate"
1136
- )
1137
- }
1138
- },
1139
- input
1140
- );
1141
- }).pipe(
1142
- Effect_exports.ensuring(
1143
- Effect_exports.sync(() => {
1144
- running = void 0;
1145
- })
1146
- ),
1147
- Effect_exports.catchCause((cause) => {
1148
- if (Cause_exports.hasInterrupts(cause)) return Effect_exports.interrupt;
1149
- const error = Cause_exports.squash(cause);
1150
- const provider = parseProviderError(error);
1151
- const response = Schema_exports.decodeUnknownOption(OpenapiResponseError)(error);
1152
- const failure = Schema_exports.decodeUnknownOption(ElicitationFailed)(error);
1153
- return Effect_exports.fail(
1154
- Option_exports.isSome(provider) ? provider.value : Option_exports.isSome(response) ? new OpenapiResponseError({
1155
- code: response.value.code,
1156
- status: response.value.status,
1157
- message: response.value.message,
1158
- ...response.value.recovery === void 0 ? {} : { recovery: response.value.recovery }
1159
- }) : Option_exports.isSome(failure) ? failure.value : new HostOperationFailed()
1160
- );
1161
- }),
1162
- Effect_exports.withSpan("app.operation.execute", {
1163
- attributes: { "executor.tool.name": toolName, "executor.operation": kind }
1164
- })
1165
- );
1166
- const outputSchema = tool.output;
1167
- const decoded = outputSchema === void 0 ? output : yield* safe2(
1168
- () => Schema_exports.decodeUnknownEffect(outputSchema)(output),
1169
- new HostOutputInvalid()
1170
- );
1171
- return yield* safe2(
1172
- () => Schema_exports.decodeUnknownEffect(JsonValue)(decoded),
1173
- new HostOutputInvalid()
1174
- );
1175
- });
1176
- const replay = context.replay === void 0 ? void 0 : yield* safe2(
1177
- () => Schema_exports.decodeUnknownEffect(WorkflowReplay)(context.replay),
1178
- new HostInputInvalid()
1179
- );
1180
- if (replay !== void 0 && kind !== "mutate") return yield* new HostInputInvalid();
1181
- if (native.database === void 0) return yield* withinDeadline(execute());
1182
- const storage = context.storage ?? unavailableStorage;
1183
- return yield* storage[kind === "query" ? "read" : "mutate"](
1184
- native.database.schema,
1185
- (db) => withinDeadline(
1186
- replay === void 0 ? execute(db) : db.once(replay.key, replay.fingerprint, () => execute(db))
1187
- )
1188
- ).pipe(
1189
- Effect_exports.catchTags({
1190
- AppDatabaseError: () => Effect_exports.fail(new HostOperationFailed()),
1191
- AppStorageUnavailable: () => Effect_exports.fail(new HostOperationFailed()),
1192
- AppStorageError: () => Effect_exports.fail(new HostOperationFailed())
1193
- })
1194
- );
1195
- })
1196
- );
1197
- }
1198
- var parseSkillLoadFailed = (error) => Schema_exports.decodeUnknownOption(SkillLoadFailed)(error).pipe(
1199
- Option_exports.map(
1200
- ({ reason, message, status }) => new SkillLoadFailed({
1201
- reason,
1202
- ...message ? { message } : {},
1203
- ...status === void 0 ? {} : { status }
1204
- })
1205
- )
1206
- );
1207
- var parseMcpError = (error) => Schema_exports.decodeUnknownOption(McpError)(error).pipe(
1208
- Option_exports.map(
1209
- ({ phase, reason, status }) => new McpError({ phase, reason, ...status === void 0 ? {} : { status } })
1210
- )
1211
- );
1212
- var errorStatus = Match_exports.type().pipe(
1213
- Match_exports.tagsExhaustive({
1214
- ProviderError: () => 502,
1215
- McpError: () => 502,
1216
- SkillLoadFailed: () => 502,
1217
- OpenapiResponseError: () => 502,
1218
- WorkflowFailure: () => 422,
1219
- HostRequestInvalid: () => 400,
1220
- HostAccountsInvalid: () => 422,
1221
- HostInputInvalid: () => 422,
1222
- HostOperationNotFound: () => 404,
1223
- HostToolNotFound: () => 404,
1224
- HostToolBlocked: () => 403,
1225
- HostToolApprovalRequired: () => 409,
1226
- HostToolPolicyFailed: () => 500,
1227
- HostOperationFailed: () => 500,
1228
- HostDeclarationInvalid: () => 500,
1229
- HostEvaluationFailed: () => 500,
1230
- HostOutputInvalid: () => 500,
1231
- ElicitationFailed: () => 422
1232
- })
1233
- );
1234
- var createAppHandler = (app) => (request, context) => Effect_exports.gen(function* () {
1235
- if (request.method !== "POST") return yield* Effect_exports.fail(new HostRequestInvalid());
1236
- const input = yield* Effect_exports.tryPromise({
1237
- try: () => request.json(),
1238
- catch: () => new HostRequestInvalid()
1239
- });
1240
- const command = yield* Schema_exports.decodeUnknownEffect(HostRequest)(input, {
1241
- onExcessProperty: "error"
1242
- }).pipe(Effect_exports.mapError(() => new HostRequestInvalid()));
1243
- yield* Effect_exports.annotateCurrentSpan({
1244
- "executor.operation": command.operation,
1245
- ...command.operation === "call" ? { "executor.tool.name": command.tool } : {}
1246
- });
1247
- let toolError = false;
1248
- const value = yield* dispatch(app, command, context, request.signal).pipe(
1249
- Effect_exports.provideService(ToolResultObservation, {
1250
- failed: () => {
1251
- toolError = true;
1252
- }
1253
- }),
1254
- Effect_exports.withSpan(`app.${command.operation}`)
1255
- );
1256
- if (toolError)
1257
- yield* Effect_exports.annotateCurrentSpan({
1258
- "executor.outcome": "failed",
1259
- "error.type": "McpToolError"
1260
- });
1261
- return Response.json({ ok: true, value, ...toolError ? { toolError: true } : {} });
1262
- }).pipe(
1263
- Effect_exports.catch(
1264
- (error) => Schema_exports.encodeEffect(HostError)(error).pipe(
1265
- Effect_exports.map(
1266
- (encoded) => Response.json({ ok: false, error: encoded }, { status: errorStatus(error) })
1267
- ),
1268
- Effect_exports.orDie
1269
- )
1270
- ),
1271
- Effect_exports.catchCause(
1272
- (cause) => Cause_exports.hasInterrupts(cause) ? Effect_exports.interrupt : Effect_exports.logError(cause).pipe(
1273
- Effect_exports.as(
1274
- Response.json(
1275
- { ok: false, error: { _tag: "HostDeclarationInvalid" } },
1276
- { status: 500 }
1277
- )
1278
- )
1279
- )
1280
- )
1281
- );
1282
-
1283
- export {
1284
- prepareElicitation,
1285
- ApprovalDecision,
1286
- cacheKey,
1287
- createAppHandler
1288
- };