apps 0.0.1-beta.10 → 0.0.1-beta.101

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 (195) hide show
  1. package/README.md +60 -42
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-Z5M2LQOZ.js → chunk-2CURR5Y7.js} +113 -58
  4. package/js/{chunk-72JNVHPK.js → chunk-2LSGC7XY.js} +4 -3
  5. package/js/{chunk-JU7VHODU.js → chunk-4PIQKACY.js} +65 -10
  6. package/js/chunk-4UPC36ZL.js +5185 -0
  7. package/js/{chunk-VFZKSM3T.js → chunk-4X2UI4R2.js} +3 -3
  8. package/js/chunk-5C6RAGAS.js +335 -0
  9. package/js/{chunk-KUMBKVJD.js → chunk-62NVUKED.js} +2 -2
  10. package/js/chunk-74H25C4X.js +95 -0
  11. package/js/chunk-7HG422GB.js +90 -0
  12. package/js/chunk-7STIP5CS.js +171 -0
  13. package/js/{chunk-UK573G7W.js → chunk-ACQXVKVQ.js} +87 -51
  14. package/js/{chunk-IJX4CYZO.js → chunk-DILSCQPJ.js} +228 -264
  15. package/js/chunk-ILYCJ3HV.js +449 -0
  16. package/js/chunk-K6TSCYAO.js +712 -0
  17. package/js/{chunk-M3B3DE4K.js → chunk-KLSEU35Y.js} +463 -218
  18. package/js/chunk-OD3KFKZD.js +1617 -0
  19. package/js/chunk-OWN3DP2W.js +88 -0
  20. package/js/{chunk-IPI4MFSN.js → chunk-PBGPES67.js} +2 -2
  21. package/js/{chunk-FL2QR3XW.js → chunk-QI66R4FP.js} +355 -76
  22. package/js/{chunk-V5KNQVCT.js → chunk-RN4YB4JT.js} +931 -289
  23. package/js/{chunk-ODEIDRGW.js → chunk-URKOTNDA.js} +795 -176
  24. package/js/{chunk-5T57N25Q.js → chunk-VAI3EVCS.js} +643 -69
  25. package/js/chunk-VCYWAA4N.js +49 -0
  26. package/js/{chunk-57RKNWL2.js → chunk-YDW7DX3A.js} +4 -4
  27. package/js/{chunk-RFVIONFX.js → chunk-YWVISRZD.js} +123 -44
  28. package/js/{chunk-CDL5PM2Q.js → chunk-ZKDXML77.js} +19239 -18404
  29. package/js/client.js +148 -84
  30. package/js/contracts.js +150 -21
  31. package/js/effect.js +18 -19
  32. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  33. package/js/graphql.js +49 -40
  34. package/js/host.js +85 -62
  35. package/js/index.js +212 -98
  36. package/js/mcp/effect.js +21 -21
  37. package/js/mcp.js +84 -57
  38. package/js/openapi.js +4331 -1415
  39. package/js/react.js +2 -3
  40. package/js/skills/effect.js +6 -3
  41. package/js/skills.js +208 -81
  42. package/js/storage/facet.js +1 -540
  43. package/js/ui/auth/contracts.js +2 -2
  44. package/js/ui/auth.js +5 -5
  45. package/js/ui/contracts.js +9 -8
  46. package/js/ui/serving.js +8609 -228
  47. package/package.json +3 -8
  48. package/runtime.json +1 -1
  49. package/types/app-cache/src/contracts/cache.d.ts +18 -0
  50. package/types/app-cache/src/index.d.ts +34 -2
  51. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  52. package/types/apps/src/contracts/app.d.ts +56 -11
  53. package/types/apps/src/contracts/cache.d.ts +20 -0
  54. package/types/apps/src/contracts/context.d.ts +60 -17
  55. package/types/apps/src/contracts/elicitation.d.ts +23 -7
  56. package/types/apps/src/contracts/events.d.ts +94 -0
  57. package/types/apps/src/contracts/failure.d.ts +30 -1
  58. package/types/apps/src/contracts/graphql.d.ts +2 -1
  59. package/types/apps/src/contracts/host.d.ts +1456 -20
  60. package/types/apps/src/contracts/icons.d.ts +28 -0
  61. package/types/apps/src/contracts/live.d.ts +2 -0
  62. package/types/apps/src/contracts/mcp.d.ts +81 -20
  63. package/types/apps/src/contracts/network.d.ts +120 -0
  64. package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
  65. package/types/apps/src/contracts/openapi-document.d.ts +1 -1
  66. package/types/apps/src/contracts/openapi.d.ts +41 -9
  67. package/types/apps/src/contracts/operations.d.ts +14 -7
  68. package/types/apps/src/contracts/placement.d.ts +102 -0
  69. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  70. package/types/apps/src/contracts/protocols/1.d.ts +733 -81
  71. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  72. package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
  73. package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
  74. package/types/apps/src/contracts/protocols/2.d.ts +69 -26
  75. package/types/apps/src/contracts/protocols/3.d.ts +133 -33
  76. package/types/apps/src/contracts/protocols/4.d.ts +122 -45
  77. package/types/apps/src/contracts/protocols/5.d.ts +157 -47
  78. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  79. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  80. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  81. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  82. package/types/apps/src/contracts/protocols/current.d.ts +6857 -0
  83. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  84. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  85. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  86. package/types/apps/src/contracts/provider.d.ts +90 -6
  87. package/types/apps/src/contracts/schedules.d.ts +7 -1
  88. package/types/apps/src/contracts/schema.d.ts +21 -0
  89. package/types/apps/src/contracts/shared-catalog.d.ts +11 -0
  90. package/types/apps/src/contracts/skills.d.ts +50 -13
  91. package/types/apps/src/contracts/sql.d.ts +63 -0
  92. package/types/apps/src/contracts/ui.d.ts +70 -30
  93. package/types/apps/src/contracts/webhooks.d.ts +24 -7
  94. package/types/apps/src/contracts/workflows.d.ts +56 -34
  95. package/types/apps/src/facet.d.ts +4 -5
  96. package/types/apps/src/host.d.ts +5 -0
  97. package/types/apps/src/implementation/account-router.d.ts +4 -3
  98. package/types/apps/src/implementation/app.d.ts +41 -14
  99. package/types/apps/src/implementation/authoring.d.ts +25 -5
  100. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  101. package/types/apps/src/implementation/cache.d.ts +29 -2
  102. package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
  103. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  104. package/types/apps/src/implementation/events.d.ts +64 -0
  105. package/types/apps/src/implementation/failure-detail.d.ts +28 -5
  106. package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
  107. package/types/apps/src/implementation/graphql.d.ts +4 -3
  108. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  109. package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
  110. package/types/apps/src/implementation/live.d.ts +2 -2
  111. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  112. package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
  113. package/types/apps/src/implementation/mcp-client.d.ts +17 -9
  114. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  115. package/types/apps/src/implementation/mcp.d.ts +20 -9
  116. package/types/apps/src/implementation/network.d.ts +16 -0
  117. package/types/apps/src/implementation/openapi-compile.d.ts +38 -7
  118. package/types/apps/src/implementation/openapi-document.d.ts +50 -20
  119. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  120. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  121. package/types/apps/src/implementation/openapi-source.d.ts +23 -1
  122. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  123. package/types/apps/src/implementation/operations.d.ts +58 -7
  124. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  125. package/types/apps/src/implementation/placement.d.ts +60 -0
  126. package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
  127. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  128. package/types/apps/src/implementation/provider.d.ts +19 -4
  129. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  130. package/types/apps/src/implementation/router-catalog.d.ts +20 -18
  131. package/types/apps/src/implementation/router.d.ts +24 -5
  132. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  133. package/types/apps/src/implementation/schedules.d.ts +39 -8
  134. package/types/apps/src/implementation/schema.d.ts +108 -11
  135. package/types/apps/src/implementation/skills.d.ts +18 -24
  136. package/types/apps/src/implementation/sql.d.ts +71 -0
  137. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  138. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  139. package/types/apps/src/implementation/ui-client.d.ts +3 -3
  140. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  141. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  142. package/types/apps/src/implementation/ui-serving.d.ts +28 -11
  143. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  144. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  145. package/types/apps/src/implementation/webhooks.d.ts +15 -6
  146. package/types/apps/src/implementation/workflow-context.d.ts +6 -2
  147. package/types/apps/src/implementation/workflows.d.ts +11 -4
  148. package/types/apps/src/index.d.ts +68 -19
  149. package/types/apps/src/mcp.d.ts +20 -1
  150. package/types/apps/src/openapi.d.ts +22 -1
  151. package/types/apps/src/react.d.ts +1 -1
  152. package/types/apps/src/skills.d.ts +10 -8
  153. package/types/apps/src/ui-serving.d.ts +1 -1
  154. package/types/telemetry/src/app-records.d.ts +42 -0
  155. package/types/telemetry/src/browser-operations.d.ts +2 -2
  156. package/types/telemetry/src/browser.d.ts +8 -3
  157. package/types/telemetry/src/config.d.ts +2 -2
  158. package/types/telemetry/src/index.d.ts +2 -1
  159. package/types/telemetry/src/layer.d.ts +10 -4
  160. package/types/telemetry/src/measurements.d.ts +1 -1
  161. package/types/telemetry/src/ownership.d.ts +60 -0
  162. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  163. package/types/telemetry/src/relay.d.ts +16 -6
  164. package/types/telemetry/src/span-attributes.d.ts +17 -1
  165. package/types/telemetry/src/transport.d.ts +8 -1
  166. package/types/utils/src/api-error.d.ts +55 -0
  167. package/types/utils/src/connection-failure.d.ts +33 -0
  168. package/types/utils/src/legacy-keys.d.ts +20 -0
  169. package/types/utils/src/recorded-message.d.ts +18 -0
  170. package/types/utils/src/schema-definitions.d.ts +13 -0
  171. package/types/utils/src/user-facing-error.d.ts +83 -0
  172. package/js/chunk-27F7W2LG.js +0 -34
  173. package/js/chunk-CRDWFA74.js +0 -299
  174. package/js/chunk-EPT3ZP52.js +0 -224
  175. package/js/chunk-MKWZPDR6.js +0 -63
  176. package/js/chunk-N7YDVXYJ.js +0 -186
  177. package/js/chunk-NKLWZJLE.js +0 -172
  178. package/js/chunk-PJJ24GU7.js +0 -877
  179. package/js/chunk-PZB6T6KU.js +0 -19
  180. package/js/chunk-R3EV5FTO.js +0 -97
  181. package/js/chunk-WLE7WX2U.js +0 -2645
  182. package/js/chunk-YXQHV65J.js +0 -242
  183. package/js/chunk-ZQINWV4W.js +0 -630
  184. package/js/mcp/stdio.js +0 -128
  185. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  186. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  187. package/types/app-data/src/implementation/promise.d.ts +0 -68
  188. package/types/app-data/src/implementation/range.d.ts +0 -8
  189. package/types/app-data/src/implementation/schema.d.ts +0 -18
  190. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  191. package/types/app-data/src/index.d.ts +0 -4
  192. package/types/apps/src/contracts/storage.d.ts +0 -68
  193. package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
  194. package/types/apps/src/implementation/storage.d.ts +0 -15
  195. package/types/apps/src/mcp-stdio.d.ts +0 -5
@@ -1,51 +1,59 @@
1
1
  import {
2
2
  skillFromFiles
3
- } from "./chunk-IPI4MFSN.js";
3
+ } from "./chunk-PBGPES67.js";
4
4
  import {
5
5
  joinPath,
6
6
  mergeMeta
7
- } from "./chunk-Z5M2LQOZ.js";
7
+ } from "./chunk-2CURR5Y7.js";
8
8
  import {
9
- parseProviderError
10
- } from "./chunk-MKWZPDR6.js";
9
+ isShortenedUpstream,
10
+ parseProviderError,
11
+ providerError
12
+ } from "./chunk-7STIP5CS.js";
11
13
  import {
12
14
  ApiErrorResponse,
15
+ CacheError,
16
+ FailureCode,
17
+ FailureFieldName,
18
+ FetchOptionUnsupported,
13
19
  HostDeclarationInvalid,
14
20
  HostEvaluationFailed,
15
21
  HostedRouter,
16
22
  HostedTool,
17
23
  HostedToolSummary,
24
+ McpCredentialsUnverified,
18
25
  McpError,
19
- maxFailureMessageLength
20
- } from "./chunk-WLE7WX2U.js";
21
- import {
22
- AppDatabaseError
23
- } from "./chunk-N7YDVXYJ.js";
26
+ McpError2,
27
+ NetworkRefused,
28
+ SkillLoadFailed as SkillLoadFailed2,
29
+ cacheLimits,
30
+ maxFailureFieldLength,
31
+ maxFailureFields,
32
+ maxFailureMessageLength,
33
+ maxUpstreamMessageLength
34
+ } from "./chunk-4UPC36ZL.js";
24
35
  import {
25
36
  SkillLoadFailed,
26
37
  skillFormatLimits
27
- } from "./chunk-JU7VHODU.js";
38
+ } from "./chunk-4PIQKACY.js";
28
39
  import {
29
40
  jsonSchemaDocument
30
- } from "./chunk-5T57N25Q.js";
31
- import {
32
- AppStorageError,
33
- AppStorageUnavailable
34
- } from "./chunk-PZB6T6KU.js";
41
+ } from "./chunk-VAI3EVCS.js";
35
42
  import {
36
43
  AccountId,
37
44
  HttpUrl,
38
45
  JsonObject
39
- } from "./chunk-27F7W2LG.js";
46
+ } from "./chunk-7HG422GB.js";
40
47
  import {
41
48
  Cause_exports,
42
49
  Effect_exports,
50
+ Match_exports,
43
51
  Option_exports,
44
52
  Predicate_exports,
45
53
  Redacted_exports,
46
54
  Result_exports,
47
55
  Schema_exports
48
- } from "./chunk-CDL5PM2Q.js";
56
+ } from "./chunk-ZKDXML77.js";
49
57
 
50
58
  // src/contracts/openapi.ts
51
59
  var OpenapiErrorResponse = Schema_exports.Struct({
@@ -59,7 +67,8 @@ var OpenapiErrorResponse = Schema_exports.Struct({
59
67
  });
60
68
  var OpenapiParameter = Schema_exports.Struct({
61
69
  name: Schema_exports.String,
62
- in: Schema_exports.Literals(["path", "query", "header", "cookie"]),
70
+ /** OpenAPI 3.2's `querystring` is the whole query string, serialized from one `content` value. */
71
+ in: Schema_exports.Literals(["path", "query", "querystring", "header", "cookie"]),
63
72
  required: Schema_exports.optionalKey(Schema_exports.Boolean),
64
73
  schema: Schema_exports.optionalKey(JsonObject),
65
74
  style: Schema_exports.optionalKey(Schema_exports.String),
@@ -84,7 +93,7 @@ var OpenapiOperation = Schema_exports.Struct({
84
93
  /** The document's operationId, when it declares one. `kinds` overrides are keyed by it. */
85
94
  operationId: Schema_exports.optionalKey(Schema_exports.String),
86
95
  description: Schema_exports.String,
87
- method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]),
96
+ method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "QUERY"]),
88
97
  path: Schema_exports.String,
89
98
  baseUrl: HttpUrl,
90
99
  openapi: Schema_exports.String,
@@ -104,6 +113,7 @@ var OpenapiOperation = Schema_exports.Struct({
104
113
  outputSchema: Schema_exports.optionalKey(JsonObject),
105
114
  errorResponses: Schema_exports.optionalKey(Schema_exports.Array(OpenapiErrorResponse))
106
115
  });
116
+ var isOpenapiReadMethod = (method) => method === "GET" || method === "HEAD" || method === "OPTIONS" || method === "QUERY";
107
117
  var CredentialBinding = Schema_exports.Struct({
108
118
  scheme: Schema_exports.String,
109
119
  field: Schema_exports.String,
@@ -136,16 +146,30 @@ var OpenapiToolsOptions = Schema_exports.Struct({
136
146
  Schema_exports.declare((value) => typeof value === "function")
137
147
  )
138
148
  });
149
+ var OpenapiFailedOperation = Schema_exports.Struct({
150
+ method: OpenapiOperation.fields.method,
151
+ path: Schema_exports.String
152
+ });
153
+ var OpenapiMediaType = Schema_exports.String.check(
154
+ Schema_exports.isMaxLength(128),
155
+ Schema_exports.isPattern(/^[\w!#$&^.+-]+\/[\w!#$&^.+-]+$/u)
156
+ );
139
157
  var OpenapiError = class extends Schema_exports.TaggedError()("OpenapiError", {
140
158
  reason: Schema_exports.Literals(["invalid_definition", "invalid_input", "request"]),
141
- status: Schema_exports.optional(Schema_exports.Number)
159
+ status: Schema_exports.optional(Schema_exports.Number),
160
+ /** Absent only when the definition itself could not be read. */
161
+ operation: Schema_exports.optional(OpenapiFailedOperation),
162
+ contentType: Schema_exports.optional(OpenapiMediaType),
163
+ /** The response's `content-length`, when it declared one. */
164
+ bytes: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isGreaterThanOrEqualTo(0)))
142
165
  }) {
143
166
  };
144
167
  var defaultOpenapiResponseLimits = {
145
168
  maxBodyBytes: 16777216,
146
169
  readTimeoutMs: 3e4
147
170
  };
148
- var isOpenapiTextMedia = (type) => /^(?:text\/|application\/(?:[\w.-]+\+)?(?:json|xml)|application\/(?:javascript|x-ndjson|x-www-form-urlencoded))/i.test(
171
+ var isOpenapiJsonSequence = (type) => /^application\/(?:x-)?(?:ndjson|jsonl|jsonlines|json-seq)\s*(?:;|$)/i.test(type);
172
+ var isOpenapiTextMedia = (type) => isOpenapiJsonSequence(type) || /^(?:text\/|application\/(?:[\w.-]+\+)?(?:json|xml)|application\/(?:javascript|x-www-form-urlencoded))/i.test(
149
173
  type
150
174
  );
151
175
  var isOpenapiFileSchema = (shape) => shape.contentMediaType !== void 0 && shape.contentEncoding === void 0 || shape.type === "string" && shape.format === "binary";
@@ -158,23 +182,158 @@ var openapiBinaryResultSchema = {
158
182
  required: ["base64", "contentType"],
159
183
  additionalProperties: false
160
184
  };
161
- var openapiMediaKind = (type) => type.includes("json") && !type.includes("ndjson") ? "json" : type === "application/x-www-form-urlencoded" ? "form" : type === "multipart/form-data" ? "multipart" : isOpenapiTextMedia(type) ? "text" : "binary";
185
+ var openapiMediaKind = (type) => type.includes("json") && !isOpenapiJsonSequence(type) ? "json" : type === "application/x-www-form-urlencoded" ? "form" : type === "multipart/form-data" ? "multipart" : isOpenapiTextMedia(type) ? "text" : "binary";
186
+
187
+ // src/contracts/openapi-compile.ts
188
+ var OpenapiCompileErrorCode = Schema_exports.Literals([
189
+ "server_protocol",
190
+ "server_url",
191
+ "external_reference",
192
+ "circular_reference",
193
+ "schema_keyword",
194
+ "schema_reference",
195
+ "missing_component",
196
+ "openapi_version",
197
+ "auth_helper",
198
+ "auth_missing",
199
+ "operation_path",
200
+ "operation_method",
201
+ "duplicate_operation",
202
+ "server_missing",
203
+ "multiple_hosts",
204
+ "parameter_encoding",
205
+ "parameter_style",
206
+ "request_body",
207
+ "combined_oauth",
208
+ "auth_method",
209
+ "event_stream",
210
+ "input_schema",
211
+ "no_operations",
212
+ "no_supported_operations",
213
+ "invalid_document",
214
+ "source_generation",
215
+ "authoring_reference"
216
+ ]);
217
+ var OpenapiSkippedOperation = Schema_exports.Struct({
218
+ /** The tool name the operation would have; reading that tool reports why it is missing. */
219
+ name: Schema_exports.String,
220
+ /** The HTTP method, such as `GET`. */
221
+ method: Schema_exports.String,
222
+ /** The path as the definition declares it. */
223
+ path: Schema_exports.String,
224
+ code: OpenapiCompileErrorCode,
225
+ reason: Schema_exports.String
226
+ });
227
+ var listedReasons = 8;
228
+ var reasonLength = 240;
229
+ var cut = (text) => text.length <= reasonLength ? text : `${text.slice(0, reasonLength - 1)}\u2026`;
230
+ var customTool = `To call a left-out operation anyway, write a custom tool for it in this app with the same account: see "Custom tools beside generated ones" in the app-authoring skill's integrations.md.`;
231
+ var compileMessage = (error) => {
232
+ const skipped = error.skipped ?? [];
233
+ if (skipped.length === 0) return error.reason;
234
+ const close = skipped.some(({ code }) => code !== "event_stream") ? ` ${customTool}` : "";
235
+ const groups = /* @__PURE__ */ new Map();
236
+ for (const operation of skipped) {
237
+ const key = JSON.stringify([operation.code, operation.reason]);
238
+ const group = groups.get(key);
239
+ if (group === void 0) groups.set(key, { first: operation, count: 1 });
240
+ else group.count++;
241
+ }
242
+ const example = ({ first, count: count2 }) => `${first.method} ${first.path}${count2 > 1 ? ` and ${count2 - 1} more` : ""}`;
243
+ const [only, ...others] = groups.values();
244
+ if (only !== void 0 && others.length === 0 && only.first.code === error.code && only.first.reason === error.reason)
245
+ return `${error.reason} Left out: ${example(only)}.${close}`;
246
+ const listed = [];
247
+ let room = maxFailureMessageLength - `${error.reason} Left out: ; and ${groups.size} other reasons.${close}`.length;
248
+ for (const group of groups.values()) {
249
+ const text = `${example(group)} (${group.first.code}: ${cut(group.first.reason.replace(/\.$/, ""))})`;
250
+ if (listed.length === listedReasons || text.length + 2 > room) break;
251
+ listed.push(text);
252
+ room -= text.length + 2;
253
+ }
254
+ const rest = groups.size - listed.length;
255
+ return `${error.reason} Left out: ${listed.join("; ")}${rest > 0 ? `; and ${rest} other reasons` : ""}.${close}`;
256
+ };
257
+ var OpenapiCompileError = class extends Schema_exports.TaggedError()(
258
+ "OpenapiCompileError",
259
+ {
260
+ code: OpenapiCompileErrorCode,
261
+ reason: Schema_exports.String,
262
+ skipped: Schema_exports.optionalKey(Schema_exports.Array(OpenapiSkippedOperation)),
263
+ origins: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String))
264
+ }
265
+ ) {
266
+ get message() {
267
+ return compileMessage(this);
268
+ }
269
+ };
270
+ var OpenapiToolName = Schema_exports.Struct({
271
+ /** The tool name relative to the router, as `withApprovals` receives it. */
272
+ name: Schema_exports.String,
273
+ /** The HTTP method, such as `GET`. */
274
+ method: Schema_exports.String,
275
+ /** The request path, including any `pathPrefix`. */
276
+ path: Schema_exports.String,
277
+ operationId: Schema_exports.optionalKey(Schema_exports.String),
278
+ /** After `kinds` (keyed by `operationId`, else `name`); otherwise reading methods are queries. */
279
+ kind: Schema_exports.Literals(["query", "mutation"]),
280
+ /** Callable without credentials, so every account and a router without one expose it. */
281
+ public: Schema_exports.Boolean,
282
+ /** The `methods` and `oauth` entries whose accounts expose it. */
283
+ methods: Schema_exports.Array(Schema_exports.String)
284
+ });
285
+ var OpenapiToolNames = Schema_exports.Struct({
286
+ tools: Schema_exports.Array(OpenapiToolName),
287
+ /**
288
+ * Operations the compiler left out, and why. An operation it imports but no configured `methods`
289
+ * or `oauth` entry can authorize is missing from `tools` and is not listed here.
290
+ */
291
+ skipped: Schema_exports.Array(OpenapiSkippedOperation)
292
+ });
162
293
 
163
294
  // src/implementation/failure-detail.ts
164
- var storageMessages = {
165
- schema: "The app's database schema is invalid.",
166
- schema_changed: "The app's database schema changed during this operation. Retry it.",
167
- table: "The operation used a table the app's database schema does not declare.",
168
- index: "The operation used an index the table does not declare, or used it incorrectly.",
169
- range: "The index range is invalid for the declared index.",
170
- value: "A value does not match the table's declared field schema.",
171
- readonly: "Queries cannot write. Move writes into a mutation.",
172
- cursor: "The pagination cursor is invalid or belongs to a different query.",
173
- limit: "The operation exceeded a per-invocation app data limit.",
174
- closed: "The database session closed before this operation finished.",
175
- storage: "App storage failed to complete the operation.",
176
- replay: "A workflow step replayed with different input than its first run."
295
+ var cacheMessages = {
296
+ capacity: "A cache key, value or batch exceeded the app cache's size limits.",
297
+ invalid: "The app made a cache request the app cache could not accept.",
298
+ unavailable: "The app cache was not available for this operation.",
299
+ storage: "The app cache failed to complete the operation.",
300
+ timeout: "The app cache did not respond in time."
301
+ };
302
+ var count = (value) => value.toLocaleString("en-US");
303
+ var cacheLimitMessages = {
304
+ keyBytes: `A cache key exceeded the app cache's limit of ${count(cacheLimits.keyBytes)} bytes per key.`,
305
+ entryBytes: `A cache value exceeded the app cache's limit of ${count(cacheLimits.entryBytes)} bytes per entry.`,
306
+ batchBytes: `A cache read or write exceeded the app cache's limit of ${count(cacheLimits.batchBytes)} bytes per batch.`,
307
+ batchEntries: `A cache read or write exceeded the app cache's limit of ${count(cacheLimits.batchEntries)} entries per batch.`,
308
+ totalBytes: `The app cache is full: it holds at most ${count(cacheLimits.totalBytes)} bytes.`,
309
+ totalEntries: `The app cache is full: it holds at most ${count(cacheLimits.totalEntries)} entries.`
310
+ };
311
+ var mcpStages = {
312
+ connect: "connecting",
313
+ transport: "connecting",
314
+ discover: "listing its tools",
315
+ schema: "reading a tool's schema",
316
+ call: "calling a tool"
317
+ };
318
+ var mcpMessage = ({ phase, reason, status }) => {
319
+ const stage = mcpStages[phase];
320
+ return Match_exports.value(reason).pipe(
321
+ Match_exports.when("timeout", () => `The MCP server did not respond in time while ${stage}.`),
322
+ Match_exports.when("unauthorized", () => `The MCP server rejected the credentials while ${stage}.`),
323
+ Match_exports.when(
324
+ "invalid_response",
325
+ () => `The MCP server returned a response Executor could not use while ${stage}, such as an unreadable message or an address on another origin.`
326
+ ),
327
+ Match_exports.when("invalid_input", () => "The MCP server URL or connection settings are invalid."),
328
+ // Only a transport failure has no answer from the server; a JSON-RPC error is an answer.
329
+ Match_exports.when(
330
+ "request",
331
+ () => status !== void 0 ? `The MCP server answered HTTP ${status} while ${stage}.` : phase === "transport" ? `Executor could not reach the MCP server while ${stage}.` : `The request to the MCP server failed while ${stage}.`
332
+ ),
333
+ Match_exports.exhaustive
334
+ );
177
335
  };
336
+ var unverifiedMessage = ({ anonymous }) => anonymous === "answered" ? "This MCP server answers without credentials, so Executor can't check this account. A refused key will show up when a tool is called." : `The MCP server accepted the credentials, but the same check without them failed, so Executor can't tell whether it requires them. ${Schema_exports.is(McpError)(anonymous) ? mcpMessage(anonymous) : anonymous.status === void 0 ? "The MCP server could not answer the request." : `The MCP server answered HTTP ${anonymous.status}.`}`;
178
337
  var minimumSecretLength = 6;
179
338
  var secretValues = (value, found) => {
180
339
  if (typeof value === "string") {
@@ -187,61 +346,165 @@ var secretValues = (value, found) => {
187
346
  var accountFieldSecrets = (accounts) => {
188
347
  const found = /* @__PURE__ */ new Set();
189
348
  if (Predicate_exports.isObject(accounts)) {
190
- for (const slot of Object.values(accounts))
191
- for (const account of Array.isArray(slot) ? slot : [slot])
192
- if (Predicate_exports.hasProperty(account, "fields")) secretValues(account.fields, found);
349
+ for (const scope of [accounts["app"], accounts["user"]])
350
+ if (Predicate_exports.isObject(scope)) {
351
+ for (const slot of Object.values(scope))
352
+ for (const account of Array.isArray(slot) ? slot : [slot])
353
+ if (Predicate_exports.hasProperty(account, "fields")) secretValues(account.fields, found);
354
+ }
193
355
  }
194
356
  return [...found].sort((a, b) => b.length - a.length);
195
357
  };
196
358
  var accountSecrets = (accounts) => accountFieldSecrets(Redacted_exports.value(accounts));
197
- var boundFailureMessage = (message, secrets) => {
198
- let redacted = message;
359
+ var replaceSecrets = (text, secrets) => {
360
+ let redacted = text;
199
361
  for (const secret of secrets) redacted = redacted.split(secret).join("[redacted]");
200
- return redacted.length <= maxFailureMessageLength ? redacted : `${redacted.slice(0, maxFailureMessageLength - 1)}\u2026`;
362
+ return redacted;
363
+ };
364
+ var bound = (text, maximum) => text.length <= maximum ? text : `${text.slice(0, maximum - 1)}\u2026`;
365
+ var boundText = (text, secrets, maximum) => bound(replaceSecrets(text, secrets), maximum);
366
+ var replaceSecretStart = (text, secrets) => {
367
+ let longest = 0;
368
+ for (const secret of secrets)
369
+ for (let length = Math.min(secret.length - 1, text.length); length > longest; length--)
370
+ if (text.endsWith(secret.slice(0, length))) {
371
+ longest = length;
372
+ break;
373
+ }
374
+ return longest === 0 ? text : `${text.slice(0, -longest)}[redacted]`;
201
375
  };
376
+ var boundFailureMessage = (message, secrets) => boundText(message, secrets, maxFailureMessageLength);
377
+ var redactUpstream = (upstream, secrets) => {
378
+ if (upstream?.message === void 0) return upstream;
379
+ const message = isShortenedUpstream(upstream.message) ? `${replaceSecretStart(replaceSecrets(upstream.message.slice(0, -1), secrets), secrets)}\u2026` : replaceSecrets(upstream.message, secrets);
380
+ return { code: upstream.code, message: bound(message, maxUpstreamMessageLength) };
381
+ };
382
+ var leavingProviderError = (error, secrets, phase) => providerError({
383
+ ...error,
384
+ phase: error.phase ?? phase,
385
+ upstream: redactUpstream(error.upstream, secrets)
386
+ });
387
+ var parseMcpError = (error, secrets) => Schema_exports.decodeUnknownOption(McpError)(error).pipe(
388
+ Option_exports.map(({ phase, reason, status, upstream, session }) => {
389
+ const stated = redactUpstream(upstream, secrets);
390
+ return new McpError2({
391
+ phase,
392
+ reason,
393
+ ...status === void 0 ? {} : { status },
394
+ ...stated === void 0 ? {} : { upstream: stated },
395
+ ...session === void 0 ? {} : { session }
396
+ });
397
+ })
398
+ );
399
+ var parseSkillLoadFailed = (error) => Schema_exports.decodeUnknownOption(SkillLoadFailed)(error).pipe(
400
+ Option_exports.map(
401
+ ({ reason, message, status, missing }) => new SkillLoadFailed2({
402
+ reason,
403
+ ...message ? { message } : {},
404
+ ...status === void 0 ? {} : { status },
405
+ ...missing === void 0 ? {} : { missing }
406
+ })
407
+ )
408
+ );
202
409
  var errorName = (error) => (error.name.length > 0 ? error.name : "Error").slice(0, 128);
410
+ var ownCode = (error, secrets) => Predicate_exports.hasProperty(error, "code") && Schema_exports.is(FailureCode)(error.code) && error.code !== "" ? boundText(error.code, secrets, 128) : void 0;
411
+ var reservedFields = /* @__PURE__ */ new Set(["name", "message", "stack", "cause", "_tag"]);
412
+ var ownFields = (error, code, secrets) => {
413
+ const fields = {};
414
+ let count2 = 0;
415
+ for (const [key, value] of Object.entries(error)) {
416
+ if (count2 === maxFailureFields) break;
417
+ if (reservedFields.has(key) || key === "code" && code !== void 0) continue;
418
+ if (!Schema_exports.is(FailureFieldName)(key)) continue;
419
+ if (typeof value === "string") fields[key] = boundText(value, secrets, maxFailureFieldLength);
420
+ else if (typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))
421
+ fields[key] = value;
422
+ else continue;
423
+ count2++;
424
+ }
425
+ return count2 === 0 ? void 0 : fields;
426
+ };
203
427
  var ownMessage = (error) => {
204
428
  const cause = error.cause;
205
429
  const suffix = cause instanceof Error && cause.message.length > 0 ? ` (caused by ${errorName(cause)}: ${cause.message})` : "";
206
430
  return error.message.length > 0 ? `${error.message}${suffix}` : void 0;
207
431
  };
208
432
  var describeFailure = (error) => error instanceof Error ? `${errorName(error)}: ${ownMessage(error) ?? "(no message)"}` : typeof error === "string" ? error : `A non-Error ${error === null ? "null" : typeof error} value was thrown`;
433
+ var openapiFailureMessage = (error) => {
434
+ const operation = error.operation === void 0 ? "The API request" : `${error.operation.method} ${error.operation.path}`;
435
+ if (error.reason === "invalid_definition")
436
+ return "The API's OpenAPI definition for this operation is invalid.";
437
+ if (error.reason === "invalid_input")
438
+ return error.operation === void 0 ? "The input could not be encoded as a request for this API operation." : `The input could not be encoded as a request for ${operation}.`;
439
+ if (error.status === void 0) return `${operation} failed before a response arrived.`;
440
+ const shape = [error.contentType, error.bytes === void 0 ? void 0 : `${error.bytes} bytes`].filter((part) => part !== void 0).join(", ");
441
+ const response = `${operation} responded with HTTP ${error.status}${shape === "" ? "" : ` (${shape})`}`;
442
+ return error.status >= 200 && error.status < 300 ? `${response}, but its body could not be read within the response limits.` : `${response}, which matches no error with a message in the API's OpenAPI document.`;
443
+ };
209
444
  var failureDetail = (error, secrets) => {
210
- if (Schema_exports.is(AppDatabaseError)(error))
445
+ if (Schema_exports.is(CacheError)(error))
211
446
  return {
212
447
  source: "storage",
213
- errorName: "AppDatabaseError",
448
+ errorName: "CacheError",
214
449
  code: error.reason,
215
- message: boundFailureMessage(ownMessage(error) ?? storageMessages[error.reason], secrets)
450
+ message: error.limit === void 0 ? cacheMessages[error.reason] : cacheLimitMessages[error.limit]
216
451
  };
217
- if (Schema_exports.is(AppStorageUnavailable)(error))
452
+ if (Schema_exports.is(OpenapiError)(error))
218
453
  return {
219
- source: "storage",
220
- errorName: "AppStorageUnavailable",
221
- message: "App storage is not available on this host."
454
+ source: "service",
455
+ errorName: "OpenapiError",
456
+ code: error.reason,
457
+ message: boundFailureMessage(openapiFailureMessage(error), secrets)
222
458
  };
223
- if (Schema_exports.is(AppStorageError)(error))
459
+ if (Schema_exports.is(McpError)(error))
224
460
  return {
225
- source: "storage",
226
- errorName: "AppStorageError",
227
- message: "App storage failed to complete the operation."
461
+ source: "service",
462
+ errorName: "McpError",
463
+ code: error.reason,
464
+ message: mcpMessage(error)
228
465
  };
229
- if (Schema_exports.is(OpenapiError)(error))
466
+ if (Schema_exports.is(McpCredentialsUnverified)(error))
230
467
  return {
231
468
  source: "service",
232
- errorName: "OpenapiError",
233
- code: error.reason,
234
- message: error.reason === "request" ? error.status === void 0 ? "The API request failed before a response arrived." : `The API responded with HTTP ${error.status}, which its OpenAPI document does not declare as an error with a message.` : error.reason === "invalid_input" ? "The input could not be encoded as a request for this API operation." : "The API's OpenAPI definition for this operation is invalid."
469
+ errorName: "McpCredentialsUnverified",
470
+ code: error.anonymous === "answered" ? "anonymous_access" : error.anonymous.reason,
471
+ message: unverifiedMessage(error)
235
472
  };
236
- if (error instanceof Error)
473
+ if (Schema_exports.is(OpenapiCompileError)(error))
474
+ return {
475
+ source: "app",
476
+ errorName: "OpenapiCompileError",
477
+ code: error.code,
478
+ message: boundFailureMessage(error.message, secrets)
479
+ };
480
+ if (Schema_exports.is(NetworkRefused)(error))
481
+ return {
482
+ source: "app",
483
+ errorName: "NetworkRefused",
484
+ code: error.refusal.reason,
485
+ message: boundFailureMessage(error.message, secrets)
486
+ };
487
+ if (Schema_exports.is(FetchOptionUnsupported)(error))
488
+ return {
489
+ source: "app",
490
+ errorName: "FetchOptionUnsupported",
491
+ code: error.option,
492
+ message: boundFailureMessage(error.message, secrets)
493
+ };
494
+ if (error instanceof Error) {
495
+ const code = ownCode(error, secrets);
496
+ const fields = ownFields(error, code, secrets);
237
497
  return {
238
498
  source: "app",
239
499
  errorName: errorName(error),
500
+ ...code === void 0 ? {} : { code },
240
501
  message: boundFailureMessage(
241
502
  ownMessage(error) ?? `${errorName(error)} was thrown without a message.`,
242
503
  secrets
243
- )
504
+ ),
505
+ ...fields === void 0 ? {} : { fields }
244
506
  };
507
+ }
245
508
  if (typeof error === "string")
246
509
  return { source: "app", errorName: "string", message: boundFailureMessage(error, secrets) };
247
510
  return {
@@ -254,21 +517,11 @@ var failureDetail = (error, secrets) => {
254
517
  // src/implementation/router-catalog.ts
255
518
  var safeFailure = (error, secrets) => {
256
519
  const provider = parseProviderError(error);
257
- if (Option_exports.isSome(provider)) return provider.value;
258
- const skills = Schema_exports.decodeUnknownOption(SkillLoadFailed)(error);
259
- if (Option_exports.isSome(skills)) {
260
- const { reason, message, status } = skills.value;
261
- return new SkillLoadFailed({
262
- reason,
263
- ...message ? { message } : {},
264
- ...status === void 0 ? {} : { status }
265
- });
266
- }
267
- const mcp = Schema_exports.decodeUnknownOption(McpError)(error);
268
- if (Option_exports.isSome(mcp)) {
269
- const { phase, reason, status } = mcp.value;
270
- return new McpError({ phase, reason, ...status === void 0 ? {} : { status } });
271
- }
520
+ if (Option_exports.isSome(provider)) return leavingProviderError(provider.value, secrets, "discover");
521
+ const skills = parseSkillLoadFailed(error);
522
+ if (Option_exports.isSome(skills)) return skills.value;
523
+ const mcp = parseMcpError(error, secrets);
524
+ if (Option_exports.isSome(mcp)) return mcp.value;
272
525
  if (Schema_exports.is(HostDeclarationInvalid)(error)) return error;
273
526
  return new HostEvaluationFailed(failureDetail(error, secrets));
274
527
  };
@@ -354,6 +607,22 @@ var fixedRouter = (operations, meta) => ({
354
607
  },
355
608
  resolve: (name) => Effect_exports.succeed(Object.hasOwn(operations, name) ? operations[name] : void 0)
356
609
  });
610
+ var ListedEntries = Schema_exports.Record(Schema_exports.String, Schema_exports.Unknown);
611
+ var ListedTool = HostedTool.mapFields((fields) => ({
612
+ ...fields,
613
+ inputSchema: ListedEntries,
614
+ outputSchema: Schema_exports.optionalKey(ListedEntries),
615
+ _meta: Schema_exports.optionalKey(ListedEntries)
616
+ }));
617
+ var isJson = Schema_exports.is(Schema_exports.Json);
618
+ var jsonTools = (tools) => isJson(
619
+ tools.flatMap(
620
+ (tool) => [tool.inputSchema, tool.outputSchema, tool._meta].flatMap(
621
+ (schema) => schema === void 0 ? [] : Object.values(schema)
622
+ )
623
+ )
624
+ );
625
+ var DescribedTools = Schema_exports.Array(ListedTool).pipe(Schema_exports.refine(jsonTools));
357
626
  var within = (wanted, path) => [...wanted].flatMap(
358
627
  (name) => path === "" ? [name] : name.startsWith(`${path}.`) ? [name.slice(path.length + 1)] : []
359
628
  );
@@ -375,9 +644,7 @@ var readCatalog = (root, options) => Effect_exports.gen(function* () {
375
644
  ],
376
645
  { concurrency: "unbounded" }
377
646
  );
378
- const parsed = yield* Schema_exports.decodeUnknownEffect(
379
- Schema_exports.Array(options.summary ? HostedToolSummary : HostedTool)
380
- )(listed).pipe(Effect_exports.mapError(() => new HostDeclarationInvalid()));
647
+ const parsed = yield* (options.summary ? Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedToolSummary))(listed) : Schema_exports.decodeUnknownEffect(DescribedTools)(listed)).pipe(Effect_exports.mapError(() => new HostDeclarationInvalid()));
381
648
  const names = /* @__PURE__ */ new Set();
382
649
  const found = [];
383
650
  for (const tool of parsed) {
@@ -490,17 +757,29 @@ export {
490
757
  OpenapiParameter,
491
758
  OpenapiRequestBody,
492
759
  OpenapiOperation,
760
+ isOpenapiReadMethod,
493
761
  OpenapiToolsOptions,
762
+ OpenapiMediaType,
494
763
  OpenapiError,
495
764
  defaultOpenapiResponseLimits,
765
+ isOpenapiJsonSequence,
496
766
  isOpenapiTextMedia,
497
767
  isOpenapiFileSchema,
498
768
  openapiBinaryResultSchema,
499
769
  openapiMediaKind,
770
+ OpenapiCompileErrorCode,
771
+ OpenapiSkippedOperation,
772
+ OpenapiCompileError,
773
+ OpenapiToolName,
774
+ OpenapiToolNames,
500
775
  accountSecrets,
501
776
  boundFailureMessage,
777
+ leavingProviderError,
778
+ parseMcpError,
779
+ parseSkillLoadFailed,
502
780
  describeFailure,
503
781
  failureDetail,
782
+ operationDescription,
504
783
  fixedRouter,
505
784
  readCatalog,
506
785
  routerSkills