apps 0.0.1-beta.5 → 0.0.1-beta.54

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 (185) hide show
  1. package/README.md +68 -44
  2. package/framework-reference.json +1 -1
  3. package/js/chunk-5FHWNLCI.js +88 -0
  4. package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
  5. package/js/chunk-7UUHJR2Q.js +49 -0
  6. package/js/{chunk-CYYBFC2K.js → chunk-AQU56EPI.js} +9 -5
  7. package/js/chunk-CDXQDN7W.js +92 -0
  8. package/js/{chunk-UDDE5KOR.js → chunk-D45JTD6N.js} +148 -34
  9. package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
  10. package/js/chunk-GDYPM7RS.js +266 -0
  11. package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
  12. package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
  13. package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
  14. package/js/{chunk-RJDDBDSN.js → chunk-JM7LOD2W.js} +628 -85
  15. package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
  16. package/js/{chunk-DQAZTA4I.js → chunk-JY56GVSV.js} +1324 -209
  17. package/js/{chunk-FWQC6I3C.js → chunk-KGCTYL2S.js} +523 -63
  18. package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
  19. package/js/chunk-LTDHQJ2Z.js +171 -0
  20. package/js/chunk-MWKHKOTL.js +240 -0
  21. package/js/chunk-OD3KFKZD.js +1617 -0
  22. package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
  23. package/js/chunk-PO5NPRFT.js +1885 -0
  24. package/js/chunk-QKHTRD6G.js +42 -0
  25. package/js/chunk-SVHI6AKV.js +729 -0
  26. package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
  27. package/js/{chunk-XHO2ZX6W.js → chunk-UM62MBJQ.js} +96 -41
  28. package/js/chunk-X5U5KIWQ.js +221 -0
  29. package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
  30. package/js/chunk-YQD2MLFY.js +340 -0
  31. package/js/client.js +142 -94
  32. package/js/contracts.js +123 -33
  33. package/js/effect.js +19 -21
  34. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  35. package/js/graphql.js +63 -60
  36. package/js/host.js +83 -60
  37. package/js/index.js +262 -222
  38. package/js/mcp/effect.js +23 -23
  39. package/js/mcp/stdio.js +48 -40
  40. package/js/mcp.js +109 -72
  41. package/js/openapi.js +4129 -1419
  42. package/js/react.js +2 -3
  43. package/js/skills/effect.js +6 -3
  44. package/js/skills.js +208 -82
  45. package/js/storage/facet.js +1 -540
  46. package/js/ui/auth/contracts.js +2 -2
  47. package/js/ui/auth.js +5 -5
  48. package/js/ui/contracts.js +5 -4
  49. package/js/ui/serving.js +8517 -214
  50. package/package.json +2 -3
  51. package/runtime.json +1 -1
  52. package/types/app-cache/src/index.d.ts +10 -1
  53. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  54. package/types/apps/src/contracts/app.d.ts +9 -8
  55. package/types/apps/src/contracts/cache.d.ts +20 -0
  56. package/types/apps/src/contracts/context.d.ts +19 -11
  57. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  58. package/types/apps/src/contracts/events.d.ts +93 -0
  59. package/types/apps/src/contracts/failure.d.ts +30 -1
  60. package/types/apps/src/contracts/graphql.d.ts +2 -1
  61. package/types/apps/src/contracts/host.d.ts +55 -16
  62. package/types/apps/src/contracts/live.d.ts +2 -0
  63. package/types/apps/src/contracts/mcp.d.ts +96 -10
  64. package/types/apps/src/contracts/network.d.ts +84 -0
  65. package/types/apps/src/contracts/openapi-compile.d.ts +32 -3
  66. package/types/apps/src/contracts/openapi.d.ts +45 -9
  67. package/types/apps/src/contracts/operations.d.ts +8 -9
  68. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  69. package/types/apps/src/contracts/protocols/1.d.ts +248 -73
  70. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  71. package/types/apps/src/contracts/protocols/11.d.ts +1098 -0
  72. package/types/apps/src/contracts/protocols/2.d.ts +65 -23
  73. package/types/apps/src/contracts/protocols/3.d.ts +65 -26
  74. package/types/apps/src/contracts/protocols/4.d.ts +1297 -0
  75. package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
  76. package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
  77. package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
  78. package/types/apps/src/contracts/protocols/8.d.ts +1130 -0
  79. package/types/apps/src/contracts/protocols/9.d.ts +1106 -0
  80. package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
  81. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  82. package/types/apps/src/contracts/provider.d.ts +115 -10
  83. package/types/apps/src/contracts/router.d.ts +59 -0
  84. package/types/apps/src/contracts/skills.d.ts +50 -13
  85. package/types/apps/src/contracts/sql.d.ts +58 -0
  86. package/types/apps/src/contracts/ui.d.ts +19 -1
  87. package/types/apps/src/contracts/workflows.d.ts +6 -0
  88. package/types/apps/src/facet.d.ts +4 -5
  89. package/types/apps/src/graphql.d.ts +1 -3
  90. package/types/apps/src/host.d.ts +5 -0
  91. package/types/apps/src/implementation/account-router.d.ts +13 -0
  92. package/types/apps/src/implementation/app.d.ts +5 -4
  93. package/types/apps/src/implementation/authoring.d.ts +25 -5
  94. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  95. package/types/apps/src/implementation/cache.d.ts +4 -0
  96. package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
  97. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  98. package/types/apps/src/implementation/events.d.ts +59 -0
  99. package/types/apps/src/implementation/failure-detail.d.ts +25 -3
  100. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  101. package/types/apps/src/implementation/graphql.d.ts +4 -3
  102. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  103. package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
  104. package/types/apps/src/implementation/live.d.ts +2 -2
  105. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  106. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  107. package/types/apps/src/implementation/mcp-client.d.ts +49 -25
  108. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  109. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  110. package/types/apps/src/implementation/mcp.d.ts +52 -25
  111. package/types/apps/src/implementation/network.d.ts +16 -0
  112. package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
  113. package/types/apps/src/implementation/openapi-document.d.ts +46 -19
  114. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  115. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  116. package/types/apps/src/implementation/openapi-source.d.ts +8 -6
  117. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  118. package/types/apps/src/implementation/operations.d.ts +43 -5
  119. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  120. package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
  121. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  122. package/types/apps/src/implementation/provider.d.ts +19 -5
  123. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  124. package/types/apps/src/implementation/router-catalog.d.ts +223 -0
  125. package/types/apps/src/implementation/router.d.ts +70 -0
  126. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  127. package/types/apps/src/implementation/schema.d.ts +95 -11
  128. package/types/apps/src/implementation/skills.d.ts +18 -24
  129. package/types/apps/src/implementation/sql.d.ts +71 -0
  130. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  131. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  132. package/types/apps/src/implementation/ui-client.d.ts +2 -2
  133. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  134. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  135. package/types/apps/src/implementation/ui-serving.d.ts +11 -5
  136. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  137. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  138. package/types/apps/src/implementation/workflow-context.d.ts +1 -1
  139. package/types/apps/src/implementation/workflows.d.ts +1 -1
  140. package/types/apps/src/index.d.ts +32 -13
  141. package/types/apps/src/mcp-stdio.d.ts +2 -5
  142. package/types/apps/src/mcp.d.ts +25 -5
  143. package/types/apps/src/openapi.d.ts +6 -6
  144. package/types/apps/src/react.d.ts +1 -1
  145. package/types/apps/src/skills.d.ts +10 -8
  146. package/types/telemetry/src/app-records.d.ts +42 -0
  147. package/types/telemetry/src/browser-operations.d.ts +7 -4
  148. package/types/telemetry/src/browser.d.ts +8 -3
  149. package/types/telemetry/src/config.d.ts +2 -2
  150. package/types/telemetry/src/index.d.ts +1 -0
  151. package/types/telemetry/src/layer.d.ts +2 -2
  152. package/types/telemetry/src/ownership.d.ts +56 -0
  153. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  154. package/types/telemetry/src/relay.d.ts +2 -2
  155. package/types/telemetry/src/transport.d.ts +8 -1
  156. package/types/utils/src/api-error.d.ts +55 -0
  157. package/types/utils/src/connection-failure.d.ts +33 -0
  158. package/types/utils/src/recorded-message.d.ts +18 -0
  159. package/types/utils/src/user-facing-error.d.ts +83 -0
  160. package/js/chunk-3XKZDQLM.js +0 -93
  161. package/js/chunk-4M277YTM.js +0 -136
  162. package/js/chunk-67EVWIGJ.js +0 -224
  163. package/js/chunk-C3VAOK5B.js +0 -215
  164. package/js/chunk-G7T27IWB.js +0 -63
  165. package/js/chunk-LUVSFETN.js +0 -1347
  166. package/js/chunk-N7YDVXYJ.js +0 -186
  167. package/js/chunk-PJJ24GU7.js +0 -877
  168. package/js/chunk-PZB6T6KU.js +0 -19
  169. package/js/chunk-SB3V4YVR.js +0 -18
  170. package/js/chunk-TDNYXSIX.js +0 -29
  171. package/js/chunk-W4DMKWAB.js +0 -35
  172. package/js/chunk-YEPYT6SD.js +0 -85
  173. package/js/chunk-ZQINWV4W.js +0 -630
  174. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  175. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  176. package/types/app-data/src/implementation/promise.d.ts +0 -68
  177. package/types/app-data/src/implementation/range.d.ts +0 -8
  178. package/types/app-data/src/implementation/schema.d.ts +0 -18
  179. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  180. package/types/app-data/src/index.d.ts +0 -4
  181. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  182. package/types/apps/src/contracts/storage.d.ts +0 -68
  183. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  184. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
  185. package/types/apps/src/implementation/storage.d.ts +0 -15
@@ -1,28 +1,27 @@
1
- import {
2
- DatabaseFieldReserved,
3
- DatabaseLimitExceeded,
4
- DatabaseSchema
5
- } from "./chunk-N7YDVXYJ.js";
6
1
  import {
7
2
  CacheCommand,
8
- CacheReply
9
- } from "./chunk-YEPYT6SD.js";
10
- import {
11
- AppSkills,
12
- SkillLoadFailed
13
- } from "./chunk-JU7VHODU.js";
3
+ CacheReply,
4
+ FailureCode,
5
+ FailureDetail,
6
+ FailureMessage,
7
+ FailureName,
8
+ FailureSource,
9
+ ProviderError,
10
+ UpstreamError
11
+ } from "./chunk-MWKHKOTL.js";
14
12
  import {
15
- OpenapiResponseError
16
- } from "./chunk-W4DMKWAB.js";
13
+ AppSkillName,
14
+ AppSkills
15
+ } from "./chunk-H72MEDMN.js";
17
16
  import {
18
- ProviderError
19
- } from "./chunk-SB3V4YVR.js";
17
+ RecordedMessage
18
+ } from "./chunk-5FHWNLCI.js";
20
19
  import {
21
20
  AccountId,
22
21
  HttpUrl,
23
22
  JsonObject as JsonObject2,
24
23
  JsonValue
25
- } from "./chunk-27F7W2LG.js";
24
+ } from "./chunk-H2CJWXA3.js";
26
25
  import {
27
26
  Any,
28
27
  ArraySchema,
@@ -58,13 +57,13 @@ import {
58
57
  declare,
59
58
  decode,
60
59
  decodeTo,
61
- empty2 as empty,
60
+ empty,
62
61
  flatMap,
63
62
  fromUndefinedOr,
64
63
  isBetween,
65
64
  isSchema,
66
65
  isStream,
67
- make6 as make,
66
+ make2 as make,
68
67
  merge,
69
68
  optional,
70
69
  optionalKey,
@@ -73,97 +72,38 @@ import {
73
72
  symbol3 as symbol,
74
73
  sync2 as sync,
75
74
  tag,
75
+ toType,
76
76
  transformOptional,
77
77
  withConstructorDefault,
78
78
  withDefault
79
- } from "./chunk-CDL5PM2Q.js";
80
-
81
- // src/contracts/tools.ts
82
- var ToolAnnotations = Schema_exports.Struct({
83
- title: Schema_exports.optionalKey(Schema_exports.String),
84
- readOnlyHint: Schema_exports.optionalKey(Schema_exports.Boolean),
85
- destructiveHint: Schema_exports.optionalKey(Schema_exports.Boolean),
86
- idempotentHint: Schema_exports.optionalKey(Schema_exports.Boolean),
87
- openWorldHint: Schema_exports.optionalKey(Schema_exports.Boolean)
88
- });
79
+ } from "./chunk-IFJU5SYQ.js";
89
80
 
90
- // src/contracts/mcp.ts
91
- var McpClientLimits = Schema_exports.Struct({
92
- timeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
93
- maxTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
94
- maxTools: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
95
- maxPaginationCursors: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
96
- cleanupTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
97
- });
98
- var defaultMcpClientLimits = McpClientLimits.make({
99
- timeoutMs: 3e4,
100
- maxTimeoutMs: 3e5,
101
- maxTools: 5e4,
102
- maxPaginationCursors: 1e3,
103
- cleanupTimeoutMs: 1e3
81
+ // src/contracts/api-response-error.ts
82
+ var maxApiErrorInstructionsLength = 4096;
83
+ var ApiErrorRecovery = Schema_exports.Struct({
84
+ action: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(1024)),
85
+ instructions: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(maxApiErrorInstructionsLength))
104
86
  });
105
- var mcpSdkTimerCeilingMs = 2147483647;
106
- var McpToolsOptions = Schema_exports.Struct({
107
- url: HttpUrl,
108
- accountId: Schema_exports.optional(AccountId),
109
- headers: Schema_exports.optional(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
110
- signal: Schema_exports.optional(Schema_exports.instanceOf(AbortSignal)),
111
- timeoutMs: Schema_exports.optional(
112
- Schema_exports.Number.check(
113
- Schema_exports.isInt(),
114
- Schema_exports.isBetween({ minimum: 1, maximum: defaultMcpClientLimits.maxTimeoutMs })
115
- )
116
- )
117
- });
118
- var McpToolResult = Schema_exports.Struct({
119
- content: Schema_exports.Array(JsonObject2),
120
- structuredContent: Schema_exports.optional(JsonObject2),
121
- isError: Schema_exports.optional(Schema_exports.Boolean),
122
- _meta: Schema_exports.optional(JsonObject2)
87
+ var maxApiErrorMessageLength = 4096;
88
+ var ApiErrorResponse = Schema_exports.Struct({
89
+ code: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(128)),
90
+ status: Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 400, maximum: 599 })),
91
+ message: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(maxApiErrorMessageLength)),
92
+ recovery: Schema_exports.optionalKey(ApiErrorRecovery)
123
93
  });
124
- var McpToolMetadata = Schema_exports.Struct({
125
- name: Schema_exports.String,
126
- title: Schema_exports.optional(Schema_exports.String),
127
- description: Schema_exports.optional(Schema_exports.String),
128
- inputSchema: JsonObject2,
129
- outputSchema: Schema_exports.optional(JsonObject2),
130
- annotations: Schema_exports.optional(ToolAnnotations),
131
- _meta: Schema_exports.optional(JsonObject2)
132
- });
133
- var McpError = class extends Schema_exports.TaggedError()("McpError", {
134
- phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
135
- reason: Schema_exports.Literals([
136
- "request",
137
- "unauthorized",
138
- "invalid_response",
139
- "timeout",
140
- "invalid_input"
141
- ]),
142
- status: Schema_exports.optional(Schema_exports.Number)
143
- }) {
94
+ var OpenapiResponseError = class extends Schema_exports.TaggedError()(
95
+ "OpenapiResponseError",
96
+ ApiErrorResponse.fields
97
+ ) {
144
98
  };
145
- var ProcessConfig = Schema_exports.Struct({
146
- command: Schema_exports.NonEmptyString,
147
- args: Schema_exports.Array(Schema_exports.String),
148
- cwd: Schema_exports.optional(Schema_exports.String),
149
- env: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
150
- timeoutMs: Schema_exports.Int.check(
151
- Schema_exports.isBetween({ minimum: 1, maximum: defaultMcpClientLimits.maxTimeoutMs })
152
- )
99
+ var OpenapiErrorLimits = Schema_exports.Struct({
100
+ maxBodyBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
101
+ readTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
102
+ });
103
+ var defaultOpenapiErrorLimits = OpenapiErrorLimits.make({
104
+ maxBodyBytes: 65536,
105
+ readTimeoutMs: 2e3
153
106
  });
154
-
155
- // src/contracts/failure.ts
156
- var maxFailureMessageLength = 2048;
157
- var FailureSource = Schema_exports.Literals(["app", "storage", "service"]);
158
- var FailureName = Schema_exports.String.check(Schema_exports.isMaxLength(128));
159
- var FailureCode = Schema_exports.String.check(Schema_exports.isMaxLength(128));
160
- var FailureMessage = Schema_exports.String.check(Schema_exports.isMaxLength(maxFailureMessageLength));
161
- var FailureDetail = {
162
- source: Schema_exports.optionalKey(FailureSource),
163
- errorName: Schema_exports.optionalKey(FailureName),
164
- code: Schema_exports.optionalKey(FailureCode),
165
- message: Schema_exports.optionalKey(FailureMessage)
166
- };
167
107
 
168
108
  // src/contracts/workflows.ts
169
109
  var WorkflowRunId = Schema_exports.NonEmptyString.pipe(Schema_exports.brand("wfr"));
@@ -229,6 +169,13 @@ var WorkflowFailure = class extends Schema_exports.TaggedError()("WorkflowFailur
229
169
  ]),
230
170
  retryable: Schema_exports.Boolean
231
171
  }) {
172
+ /**
173
+ * The step name and error detail are the app's. Its run's owner reads them; telemetry records
174
+ * only the reason, however the failure was built or decoded.
175
+ */
176
+ get [RecordedMessage]() {
177
+ return this.step === void 0 && this.errorName === void 0 && !this.message ? void 0 : `The workflow failed (${this.reason}); the app's error is not recorded`;
178
+ }
232
179
  };
233
180
  var NonRetryableError = class extends Error {
234
181
  name = "NonRetryableError";
@@ -335,7 +282,178 @@ var WorkflowControlCommand = Schema_exports.Union([
335
282
  Schema_exports.Struct({ operation: Schema_exports.Literal("terminate"), run: WorkflowRunId })
336
283
  ]);
337
284
 
338
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/rpc/RpcSchema.js
285
+ // ../app-data/src/contracts/database.ts
286
+ var DataName = Schema_exports.String.check(
287
+ Schema_exports.makeFilter((value) => /^[A-Za-z][A-Za-z0-9_]*$/.test(value) && value.length <= 128)
288
+ );
289
+ var Scalar = Schema_exports.Union([Schema_exports.String, Schema_exports.Finite, Schema_exports.Boolean]);
290
+ var Field = Schema_exports.Struct({
291
+ kind: Schema_exports.Literals(["string", "number", "boolean", "id", "userId"]),
292
+ optional: Schema_exports.optional(Schema_exports.Boolean),
293
+ default: Schema_exports.optional(Scalar),
294
+ references: Schema_exports.optional(DataName)
295
+ });
296
+ var Index = Schema_exports.Struct({ name: DataName, fields: Schema_exports.NonEmptyArray(DataName) });
297
+ var Table = Schema_exports.Struct({
298
+ fields: Schema_exports.Record(DataName, Field),
299
+ indexes: Schema_exports.Array(Index)
300
+ });
301
+ var DatabaseSchema = Schema_exports.Record(DataName, Table);
302
+ var Row = Schema_exports.Record(Schema_exports.String, Scalar);
303
+ var RowMetadata = Schema_exports.Struct({
304
+ id: Schema_exports.NonEmptyString,
305
+ createdAt: Schema_exports.String,
306
+ updatedAt: Schema_exports.String
307
+ });
308
+ var Patch = Schema_exports.Record(DataName, Schema_exports.NullOr(Scalar));
309
+ var RangeClause = Schema_exports.Struct({
310
+ field: DataName,
311
+ op: Schema_exports.Literals(["eq", "gt", "gte", "lt", "lte"]),
312
+ value: Schema_exports.NullOr(Scalar)
313
+ });
314
+ var QueryPlan = Schema_exports.Struct({
315
+ table: DataName,
316
+ index: DataName,
317
+ order: Schema_exports.Literals(["asc", "desc"]),
318
+ clauses: Schema_exports.Array(RangeClause)
319
+ });
320
+ var QueryTerminal = Schema_exports.Union([
321
+ Schema_exports.Struct({ kind: Schema_exports.Literal("collect") }),
322
+ Schema_exports.Struct({ kind: Schema_exports.Literal("count") }),
323
+ Schema_exports.Struct({ kind: Schema_exports.Literal("first") }),
324
+ Schema_exports.Struct({
325
+ kind: Schema_exports.Literal("take"),
326
+ count: Schema_exports.Int.check(Schema_exports.isGreaterThanOrEqualTo(0))
327
+ }),
328
+ Schema_exports.Struct({
329
+ kind: Schema_exports.Literal("paginate"),
330
+ cursor: Schema_exports.NullOr(Schema_exports.String),
331
+ numItems: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
332
+ })
333
+ ]);
334
+ var DatabaseOperation = Schema_exports.Union([
335
+ Schema_exports.Struct({ kind: Schema_exports.Literal("get"), table: DataName, id: Schema_exports.NonEmptyString }),
336
+ Schema_exports.Struct({ kind: Schema_exports.Literal("insert"), table: DataName, value: Patch }),
337
+ Schema_exports.Struct({
338
+ kind: Schema_exports.Literal("update"),
339
+ table: DataName,
340
+ id: Schema_exports.NonEmptyString,
341
+ patch: Patch
342
+ }),
343
+ Schema_exports.Struct({ kind: Schema_exports.Literal("delete"), table: DataName, id: Schema_exports.NonEmptyString }),
344
+ Schema_exports.Struct({ kind: Schema_exports.Literal("query"), plan: QueryPlan, terminal: QueryTerminal })
345
+ ]);
346
+ var PaginationResult = Schema_exports.Struct({
347
+ page: Schema_exports.Array(Row),
348
+ continueCursor: Schema_exports.NullOr(Schema_exports.String),
349
+ isDone: Schema_exports.Boolean
350
+ });
351
+ var OperationResult = Schema_exports.Union([
352
+ Row,
353
+ Schema_exports.Array(Row),
354
+ PaginationResult,
355
+ Schema_exports.Boolean,
356
+ Schema_exports.Finite,
357
+ Schema_exports.Null
358
+ ]);
359
+ var AppDatabaseError = class extends Schema_exports.TaggedError()("AppDatabaseError", {
360
+ reason: Schema_exports.Literals([
361
+ "schema",
362
+ "schema_changed",
363
+ "table",
364
+ "index",
365
+ "range",
366
+ "value",
367
+ "readonly",
368
+ "cursor",
369
+ "limit",
370
+ "closed",
371
+ "storage",
372
+ "replay"
373
+ ])
374
+ }) {
375
+ };
376
+ var DatabaseLimits = Schema_exports.Struct({
377
+ rowsRead: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
378
+ rowsReturned: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
379
+ bytesRead: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
380
+ writes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
381
+ scanCalls: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
382
+ directGets: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
383
+ valueBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
384
+ indexBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
385
+ });
386
+ var defaultDatabaseLimits = {
387
+ rowsRead: 5e3,
388
+ rowsReturned: 1e3,
389
+ bytesRead: 4 * 1024 * 1024,
390
+ writes: 1e3,
391
+ scanCalls: 100,
392
+ directGets: 1e3,
393
+ valueBytes: 64 * 1024,
394
+ indexBytes: 2048
395
+ };
396
+ var DatabaseLimit = Schema_exports.Literals([
397
+ "scanCalls",
398
+ "directGets",
399
+ "rowsRead",
400
+ "rowsReturned",
401
+ "pageSize",
402
+ "bytesRead",
403
+ "writes",
404
+ "valueBytes"
405
+ ]);
406
+ var count = (value) => value.toLocaleString("en-US");
407
+ var limitMessages = {
408
+ scanCalls: (maximum, requested) => `This invocation made ${count(requested)} index queries; the limit is ${count(maximum)}. Each first(), take(), collect(), count() or paginate() call on withIndex(...) counts once. Read related rows with one take() or paginate() over a shared index prefix instead of one first() per item, use get(id) for known IDs, or split the work across workflow steps.`,
409
+ directGets: (maximum, requested) => `This invocation made ${count(requested)} get(id) calls, including those made by update and delete; the limit is ${count(maximum)}. Split the work across workflow steps or mutations.`,
410
+ rowsRead: (maximum, requested) => `This invocation read ${count(requested)} rows; the limit is ${count(maximum)}. Read fewer rows per call, through an index or a LIMIT, or split the work across calls or workflow steps.`,
411
+ rowsReturned: (maximum, requested) => `This invocation returned ${count(requested)} rows; the limit is ${count(maximum)}. collect() fails rather than truncating. Page with paginate() across calls or workflow steps.`,
412
+ pageSize: (maximum, requested) => `One call asked for ${count(requested)} rows; take(n) and paginate({ numItems }) accept at most ${count(maximum)}. Page with paginate() across calls or workflow steps.`,
413
+ bytesRead: (maximum, requested) => `This invocation read ${count(requested)} bytes; the limit is ${count(maximum)}. Read fewer or smaller rows per call, or page with paginate() across calls or workflow steps.`,
414
+ writes: (maximum, requested) => `This invocation wrote ${count(requested)} rows; the limit is ${count(maximum)}. Split large ingests into batches, one batch per mutation or workflow step.`,
415
+ valueBytes: (maximum, requested) => `A row encodes to ${count(requested)} bytes; each row may use at most ${count(maximum)}. Store large content outside the row or split it across rows.`
416
+ };
417
+ var DatabaseLimitExceeded = class extends Schema_exports.TaggedError()(
418
+ "DatabaseLimitExceeded",
419
+ {
420
+ limit: DatabaseLimit,
421
+ maximum: Schema_exports.Int,
422
+ requested: Schema_exports.Int
423
+ }
424
+ ) {
425
+ get message() {
426
+ return limitMessages[this.limit](this.maximum, this.requested);
427
+ }
428
+ };
429
+ var reservedFieldNames = ["id", "createdAt", "updatedAt"];
430
+ var DatabaseFieldReserved = class extends Schema_exports.TaggedError()(
431
+ "DatabaseFieldReserved",
432
+ {
433
+ table: Schema_exports.String,
434
+ field: Schema_exports.Literals(reservedFieldNames)
435
+ }
436
+ ) {
437
+ get message() {
438
+ return `Table "${this.table}" declares "${this.field}", which is reserved: the host adds id, createdAt and updatedAt to every row. Rename the field, or use the row's own ${this.field}.`;
439
+ }
440
+ };
441
+ var DatabaseRuntimeLimits = Schema_exports.Struct({
442
+ maxCursorChars: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
443
+ connectionCacheCapacity: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
444
+ connectionCacheTtlMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
445
+ });
446
+ var defaultDatabaseRuntimeLimits = DatabaseRuntimeLimits.make({
447
+ maxCursorChars: 8192,
448
+ connectionCacheCapacity: 64,
449
+ connectionCacheTtlMs: 5 * 60 * 1e3
450
+ });
451
+
452
+ // src/contracts/sql.ts
453
+ var reservedTablePrefix = "_executor_";
454
+ var migrationsDirectory = "migrations";
455
+
456
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/rpc/RpcSchema.js
339
457
  var StreamSchemaTypeId = "~effect/rpc/RpcSchema/StreamSchema";
340
458
  var schema = /* @__PURE__ */ declare(isStream);
341
459
  function Stream(success, error) {
@@ -346,7 +464,7 @@ function Stream(success, error) {
346
464
  });
347
465
  }
348
466
 
349
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/rpc/Rpc.js
467
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/rpc/Rpc.js
350
468
  var TypeId = "~effect/rpc/Rpc";
351
469
  var Proto = {
352
470
  [TypeId]: TypeId,
@@ -464,7 +582,7 @@ var make2 = (tag2, options) => {
464
582
  });
465
583
  };
466
584
 
467
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/ai/McpSchema.js
585
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/ai/McpSchema.js
468
586
  var optionalWithDefault = (schema2, defaultValue) => {
469
587
  const effect = sync(defaultValue);
470
588
  return optionalKey(schema2).pipe(decode({
@@ -472,7 +590,7 @@ var optionalWithDefault = (schema2, defaultValue) => {
472
590
  encode: passthrough()
473
591
  }), withConstructorDefault(effect));
474
592
  };
475
- var optional2 = (schema2) => optionalKey(schema2).pipe(decodeTo(optional(schema2), {
593
+ var optional2 = (schema2) => optionalKey(schema2).pipe(decodeTo(toType(optional(schema2)), {
476
594
  decode: passthrough(),
477
595
  encode: transformOptional(flatMap(fromUndefinedOr))
478
596
  }));
@@ -734,7 +852,7 @@ var InternalError = class _InternalError extends (/* @__PURE__ */ Error2("effect
734
852
  message: "Not implemented"
735
853
  });
736
854
  };
737
- var McpError2 = /* @__PURE__ */ Union([ParseError, InvalidRequest, MethodNotFound, InvalidParams, InternalError, McpErrorBase]);
855
+ var McpError = /* @__PURE__ */ Union([ParseError, InvalidRequest, MethodNotFound, InvalidParams, InternalError, McpErrorBase]);
738
856
  var InitializeResult = class extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
739
857
  ...ResultMeta.fields,
740
858
  /**
@@ -757,7 +875,7 @@ var InitializeResult = class extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ S
757
875
  };
758
876
  var Initialize = class extends (/* @__PURE__ */ make2("initialize", {
759
877
  success: InitializeResult,
760
- error: McpError2,
878
+ error: McpError,
761
879
  payload: {
762
880
  ...RequestMeta.fields,
763
881
  /**
@@ -956,7 +1074,7 @@ var ReadResourceResult = class extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */
956
1074
  };
957
1075
  var ReadResource = class extends (/* @__PURE__ */ make2("resources/read", {
958
1076
  success: ReadResourceResult,
959
- error: McpError2,
1077
+ error: McpError,
960
1078
  payload: {
961
1079
  ...RequestMeta.fields,
962
1080
  /**
@@ -969,7 +1087,7 @@ var ReadResource = class extends (/* @__PURE__ */ make2("resources/read", {
969
1087
  };
970
1088
  var Subscribe = class extends (/* @__PURE__ */ make2("resources/subscribe", {
971
1089
  success: /* @__PURE__ */ Struct({}),
972
- error: McpError2,
1090
+ error: McpError,
973
1091
  payload: {
974
1092
  ...RequestMeta.fields,
975
1093
  /**
@@ -982,7 +1100,7 @@ var Subscribe = class extends (/* @__PURE__ */ make2("resources/subscribe", {
982
1100
  };
983
1101
  var Unsubscribe = class extends (/* @__PURE__ */ make2("resources/unsubscribe", {
984
1102
  success: /* @__PURE__ */ Struct({}),
985
- error: McpError2,
1103
+ error: McpError,
986
1104
  payload: {
987
1105
  ...RequestMeta.fields,
988
1106
  /**
@@ -1126,7 +1244,7 @@ var GetPromptResult = class extends (/* @__PURE__ */ Class("@effect/ai/McpSchema
1126
1244
  };
1127
1245
  var GetPrompt = class extends (/* @__PURE__ */ make2("prompts/get", {
1128
1246
  success: GetPromptResult,
1129
- error: McpError2,
1247
+ error: McpError,
1130
1248
  payload: {
1131
1249
  ...RequestMeta.fields,
1132
1250
  /**
@@ -1141,7 +1259,7 @@ var GetPrompt = class extends (/* @__PURE__ */ make2("prompts/get", {
1141
1259
  }
1142
1260
  })) {
1143
1261
  };
1144
- var ToolAnnotations2 = class extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
1262
+ var ToolAnnotations = class extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
1145
1263
  /**
1146
1264
  * A human-readable title for the tool.
1147
1265
  */
@@ -1210,7 +1328,7 @@ var Tool = class extends (/* @__PURE__ */ Class("@effect/ai/McpSchema/Tool")({
1210
1328
  /**
1211
1329
  * Optional additional tool information.
1212
1330
  */
1213
- annotations: /* @__PURE__ */ optional2(ToolAnnotations2),
1331
+ annotations: /* @__PURE__ */ optional2(ToolAnnotations),
1214
1332
  /**
1215
1333
  * Icons that clients can display for this tool.
1216
1334
  */
@@ -1246,7 +1364,7 @@ var CallToolResult = class extends (/* @__PURE__ */ Class("@effect/ai/McpSchema/
1246
1364
  };
1247
1365
  var CallTool = class extends (/* @__PURE__ */ make2("tools/call", {
1248
1366
  success: CallToolResult,
1249
- error: McpError2,
1367
+ error: McpError,
1250
1368
  payload: {
1251
1369
  ...RequestMeta.fields,
1252
1370
  name: String,
@@ -1266,7 +1384,7 @@ var SetLevel = class extends (/* @__PURE__ */ make2("logging/setLevel", {
1266
1384
  level: LoggingLevel
1267
1385
  },
1268
1386
  success: /* @__PURE__ */ Struct({}),
1269
- error: McpError2
1387
+ error: McpError
1270
1388
  })) {
1271
1389
  };
1272
1390
  var LoggingMessageNotification = class extends (/* @__PURE__ */ make2("notifications/message", {
@@ -1412,7 +1530,7 @@ var CreateMessageResult = class extends (/* @__PURE__ */ Class("@effect/ai/McpSc
1412
1530
  };
1413
1531
  var CreateMessage = class extends (/* @__PURE__ */ make2("sampling/createMessage", {
1414
1532
  success: CreateMessageResult,
1415
- error: McpError2,
1533
+ error: McpError,
1416
1534
  payload: {
1417
1535
  messages: /* @__PURE__ */ ArraySchema(SamplingMessage),
1418
1536
  /**
@@ -1475,6 +1593,7 @@ var CompleteResult = class _CompleteResult extends (/* @__PURE__ */ Opaque()(/*
1475
1593
  /**
1476
1594
  * Empty completion result used when a completion request has no values.
1477
1595
  *
1596
+ * @stability unstable
1478
1597
  * @since 4.0.0
1479
1598
  */
1480
1599
  static empty = /* @__PURE__ */ _CompleteResult.make({
@@ -1623,7 +1742,7 @@ var ElicitDeclineResult = class extends (/* @__PURE__ */ Class("@effect/ai/McpSc
1623
1742
  var ElicitResult = /* @__PURE__ */ Union([ElicitAcceptResult, ElicitDeclineResult]);
1624
1743
  var Elicit = class extends (/* @__PURE__ */ make2("elicitation/create", {
1625
1744
  success: ElicitResult,
1626
- error: McpError2,
1745
+ error: McpError,
1627
1746
  payload: ElicitRequestParams
1628
1747
  })) {
1629
1748
  };
@@ -1689,6 +1808,126 @@ ${JSON.stringify(input, null, 2)}`,
1689
1808
  requestedSchema: { type: "object", properties: {} }
1690
1809
  });
1691
1810
 
1811
+ // src/contracts/router.ts
1812
+ var reservedRouterKeys = /* @__PURE__ */ new Set([
1813
+ "__proto__",
1814
+ "constructor",
1815
+ "prototype"
1816
+ ]);
1817
+ var RouterKey = Schema_exports.String.check(
1818
+ Schema_exports.isPattern(/^[A-Za-z_][A-Za-z0-9_-]{0,99}$/u),
1819
+ Schema_exports.makeFilter((key) => !reservedRouterKeys.has(key))
1820
+ );
1821
+ var RouterIcon = Schema_exports.Struct({
1822
+ src: Schema_exports.NonEmptyString,
1823
+ mimeType: Schema_exports.optionalKey(Schema_exports.String),
1824
+ sizes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String)),
1825
+ theme: Schema_exports.optionalKey(Schema_exports.Literals(["light", "dark"]))
1826
+ });
1827
+ var RouterMeta = Schema_exports.Struct({
1828
+ title: Schema_exports.optionalKey(Schema_exports.String),
1829
+ description: Schema_exports.optionalKey(Schema_exports.String),
1830
+ instructions: Schema_exports.optionalKey(Schema_exports.String),
1831
+ icons: Schema_exports.optionalKey(Schema_exports.Array(RouterIcon)),
1832
+ tags: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.NonEmptyString, Schema_exports.String))
1833
+ });
1834
+
1835
+ // src/contracts/tools.ts
1836
+ var ToolAnnotations2 = Schema_exports.Struct({
1837
+ title: Schema_exports.optionalKey(Schema_exports.String),
1838
+ readOnlyHint: Schema_exports.optionalKey(Schema_exports.Boolean),
1839
+ destructiveHint: Schema_exports.optionalKey(Schema_exports.Boolean),
1840
+ idempotentHint: Schema_exports.optionalKey(Schema_exports.Boolean),
1841
+ openWorldHint: Schema_exports.optionalKey(Schema_exports.Boolean)
1842
+ });
1843
+
1844
+ // src/contracts/mcp.ts
1845
+ var McpClientLimits = Schema_exports.Struct({
1846
+ timeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1847
+ maxTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1848
+ maxTools: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1849
+ maxPaginationCursors: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1850
+ cleanupTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
1851
+ });
1852
+ var defaultMcpClientLimits = McpClientLimits.make({
1853
+ timeoutMs: 3e4,
1854
+ maxTimeoutMs: 3e5,
1855
+ maxTools: 5e4,
1856
+ maxPaginationCursors: 1e3,
1857
+ cleanupTimeoutMs: 1e3
1858
+ });
1859
+ var mcpSdkTimerCeilingMs = 2147483647;
1860
+ var McpToolsOptions = Schema_exports.Struct({
1861
+ url: HttpUrl,
1862
+ accountId: Schema_exports.optional(AccountId),
1863
+ headers: Schema_exports.optional(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
1864
+ signal: Schema_exports.optional(Schema_exports.instanceOf(AbortSignal)),
1865
+ timeoutMs: Schema_exports.optional(
1866
+ Schema_exports.Number.check(
1867
+ Schema_exports.isInt(),
1868
+ Schema_exports.isBetween({ minimum: 1, maximum: defaultMcpClientLimits.maxTimeoutMs })
1869
+ )
1870
+ )
1871
+ });
1872
+ var McpHealthInput = Schema_exports.Struct({
1873
+ ...McpToolsOptions.fields,
1874
+ headers: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
1875
+ deadline: Schema_exports.optional(Schema_exports.Finite)
1876
+ });
1877
+ var mcpHealthReserveMs = 2 * defaultMcpClientLimits.cleanupTimeoutMs + 250;
1878
+ var McpToolResult = Schema_exports.Struct({
1879
+ content: Schema_exports.Array(JsonObject2),
1880
+ structuredContent: Schema_exports.optionalKey(JsonObject2),
1881
+ isError: Schema_exports.optionalKey(Schema_exports.Boolean),
1882
+ _meta: Schema_exports.optionalKey(JsonObject2)
1883
+ });
1884
+ var McpToolMetadata = Schema_exports.Struct({
1885
+ name: Schema_exports.String,
1886
+ title: Schema_exports.optional(Schema_exports.String),
1887
+ description: Schema_exports.optional(Schema_exports.String),
1888
+ inputSchema: JsonObject2,
1889
+ outputSchema: Schema_exports.optional(JsonObject2),
1890
+ annotations: Schema_exports.optional(ToolAnnotations2),
1891
+ _meta: Schema_exports.optional(JsonObject2)
1892
+ });
1893
+ var McpServerHeader = Schema_exports.Struct({
1894
+ name: Schema_exports.optionalKey(Schema_exports.String),
1895
+ title: Schema_exports.optionalKey(Schema_exports.String),
1896
+ version: Schema_exports.optionalKey(Schema_exports.String),
1897
+ description: Schema_exports.optionalKey(Schema_exports.String),
1898
+ websiteUrl: Schema_exports.optionalKey(Schema_exports.String),
1899
+ icons: Schema_exports.optionalKey(Schema_exports.Array(RouterIcon)),
1900
+ instructions: Schema_exports.optionalKey(Schema_exports.String)
1901
+ });
1902
+ var McpError2 = class extends Schema_exports.TaggedError()("McpError", {
1903
+ phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
1904
+ reason: Schema_exports.Literals([
1905
+ "request",
1906
+ "unauthorized",
1907
+ "invalid_response",
1908
+ "timeout",
1909
+ "invalid_input"
1910
+ ]),
1911
+ status: Schema_exports.optional(Schema_exports.Number),
1912
+ upstream: Schema_exports.optional(UpstreamError),
1913
+ session: Schema_exports.optional(Schema_exports.Literal(true))
1914
+ }) {
1915
+ };
1916
+ var McpCredentialsUnverified = class extends Schema_exports.TaggedError()(
1917
+ "McpCredentialsUnverified",
1918
+ { anonymous: Schema_exports.Union([Schema_exports.Literal("answered"), McpError2, ProviderError]) }
1919
+ ) {
1920
+ };
1921
+ var ProcessConfig = Schema_exports.Struct({
1922
+ command: Schema_exports.NonEmptyString,
1923
+ args: Schema_exports.Array(Schema_exports.String),
1924
+ cwd: Schema_exports.optional(Schema_exports.String),
1925
+ env: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
1926
+ timeoutMs: Schema_exports.Int.check(
1927
+ Schema_exports.isBetween({ minimum: 1, maximum: defaultMcpClientLimits.maxTimeoutMs })
1928
+ )
1929
+ });
1930
+
1692
1931
  // src/contracts/webhook-protocol.ts
1693
1932
  var WebhookTransportLimits = Schema_exports.Struct({
1694
1933
  maxBodyBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
@@ -1744,6 +1983,52 @@ var WebhookCommand = Schema_exports.Union([
1744
1983
  })
1745
1984
  ]);
1746
1985
 
1986
+ // src/contracts/events.ts
1987
+ var EventName = Schema_exports.String.check(
1988
+ Schema_exports.isPattern(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*$/u),
1989
+ Schema_exports.isMaxLength(64)
1990
+ );
1991
+ var EventFilterValue = Schema_exports.Union([Schema_exports.String, Schema_exports.Finite, Schema_exports.Boolean]);
1992
+ var EventLimits = Schema_exports.Struct({
1993
+ /** An occurrence's `data`, leaving room under a 256 KiB delivery for its envelope. */
1994
+ maxDataBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1995
+ maxEventsPerInvocation: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1996
+ maxDescriptionLength: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1997
+ maxIdLength: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
1998
+ });
1999
+ var defaultEventLimits = EventLimits.make({
2000
+ maxDataBytes: 250 * 1024,
2001
+ maxEventsPerInvocation: 100,
2002
+ maxDescriptionLength: 1e3,
2003
+ maxIdLength: 200
2004
+ });
2005
+ var DeclaredEvent = Schema_exports.Struct({
2006
+ description: Schema_exports.String.check(
2007
+ Schema_exports.isMinLength(1),
2008
+ Schema_exports.isMaxLength(defaultEventLimits.maxDescriptionLength)
2009
+ ),
2010
+ /** An object of scalar fields. Subscribers may name any of them to narrow an event. */
2011
+ filters: JsonObject2,
2012
+ /** The shape of each occurrence's `data`. */
2013
+ payload: JsonObject2
2014
+ });
2015
+ var DeclaredEvents = Schema_exports.Record(EventName, DeclaredEvent);
2016
+ var EmittedEvent = Schema_exports.Struct({
2017
+ name: EventName,
2018
+ id: Schema_exports.String.check(
2019
+ Schema_exports.isMinLength(1),
2020
+ Schema_exports.isMaxLength(defaultEventLimits.maxIdLength)
2021
+ ),
2022
+ /** Milliseconds since the epoch when the event happened. */
2023
+ occurredAt: Schema_exports.Int.check(Schema_exports.isGreaterThanOrEqualTo(0)),
2024
+ data: JsonValue,
2025
+ filters: Schema_exports.Record(Schema_exports.String, EventFilterValue),
2026
+ account: Schema_exports.NullOr(AccountId)
2027
+ });
2028
+ var EmittedEvents = Schema_exports.Array(EmittedEvent).check(
2029
+ Schema_exports.isMaxLength(defaultEventLimits.maxEventsPerInvocation)
2030
+ );
2031
+
1747
2032
  // src/contracts/provider.ts
1748
2033
  var SecretsMethod = class extends Data_exports.TaggedClass(
1749
2034
  "secrets"
@@ -1760,7 +2045,7 @@ var OAuthSecretClientAuth = Schema_exports.Literals([
1760
2045
  "client_secret_basic",
1761
2046
  "client_secret_basic_raw"
1762
2047
  ]);
1763
- var reservedAuthorizationParams = /* @__PURE__ */ new Set([
2048
+ var reservedAuthorizationParams = [
1764
2049
  "response_type",
1765
2050
  "client_id",
1766
2051
  "redirect_uri",
@@ -1772,17 +2057,55 @@ var reservedAuthorizationParams = /* @__PURE__ */ new Set([
1772
2057
  "resource",
1773
2058
  "request",
1774
2059
  "request_uri"
1775
- ]);
2060
+ ];
2061
+ var reserved = new Set(reservedAuthorizationParams);
1776
2062
  var OAuthAuthorizationParams = Schema_exports.Record(Schema_exports.String, Schema_exports.String).check(
1777
- Schema_exports.makeFilter(
1778
- (params) => Object.keys(params).every((key) => !reservedAuthorizationParams.has(key)),
1779
- {
1780
- message: "Authorization parameters cannot replace protocol parameters such as state or scope."
1781
- }
1782
- )
2063
+ Schema_exports.makeFilter((params) => Object.keys(params).every((key) => !reserved.has(key)), {
2064
+ message: "Authorization parameters cannot replace protocol parameters such as state or scope."
2065
+ })
1783
2066
  );
2067
+ var declaredAuthorizationQuery = Schema_exports.makeFilter(
2068
+ (config) => {
2069
+ const keys = [...new URL(config.authorizationUrl).searchParams.keys()];
2070
+ const owned = keys.filter((key) => reserved.has(key));
2071
+ if (owned.length > 0)
2072
+ return {
2073
+ path: ["authorizationUrl"],
2074
+ issue: `authorizationUrl cannot set protocol parameters: ${owned.join(", ")}.`
2075
+ };
2076
+ const repeated = keys.filter((key) => Object.hasOwn(config.authorizationParams ?? {}, key));
2077
+ if (repeated.length > 0)
2078
+ return {
2079
+ path: ["authorizationParams"],
2080
+ issue: `Declare each parameter once; authorizationUrl already sets: ${repeated.join(", ")}.`
2081
+ };
2082
+ return void 0;
2083
+ }
2084
+ );
2085
+ var OAuthTokenRequestFormat = Schema_exports.Literals(["form", "json"]);
2086
+ var OAuthTokenResponse = Schema_exports.Struct({
2087
+ path: Schema_exports.String.check(Schema_exports.isPattern(/^[^.]+(\.[^.]+)*$/))
2088
+ });
2089
+ var tokenRequestOptions = {
2090
+ /** Joins requested scopes; Linear wants `","`. Defaults to RFC 6749's space. */
2091
+ scopeSeparator: Schema_exports.optionalKey(Schema_exports.String.check(Schema_exports.isMinLength(1))),
2092
+ /** Encoding of token requests. Defaults to `"form"`; Atlassian, ClickUp and Notion need `"json"`. */
2093
+ tokenRequestFormat: Schema_exports.optionalKey(OAuthTokenRequestFormat)
2094
+ };
1784
2095
  var oauthOptions = {
2096
+ ...tokenRequestOptions,
2097
+ /**
2098
+ * Read the grant from this nested member of the token response when the top-level response has
2099
+ * no access token or no scope. Slack's user tokens use `{ path: "authed_user" }`.
2100
+ */
2101
+ tokenResponse: Schema_exports.optionalKey(OAuthTokenResponse),
1785
2102
  grant: Schema_exports.optionalKey(Schema_exports.Literal("authorization_code")),
2103
+ /**
2104
+ * Service-defined authorization request parameters, such as Google's
2105
+ * `{ access_type: "offline", prompt: "consent" }`. Host-owned protocol parameters
2106
+ * (`state`, `scope`, `redirect_uri`, PKCE and the others in `reservedAuthorizationParams`)
2107
+ * are rejected. A discovered endpoint's own query parameter of the same name is replaced.
2108
+ */
1786
2109
  authorizationParams: Schema_exports.optionalKey(OAuthAuthorizationParams),
1787
2110
  tokenEndpointAuthMethod: Schema_exports.optionalKey(OAuthClientAuth),
1788
2111
  /** Omitted uses discovery; null explicitly suppresses the resource parameter. */
@@ -1792,6 +2115,8 @@ var OAuth2Config = Schema_exports.Union([
1792
2115
  Schema_exports.Struct({
1793
2116
  ...oauthOptions,
1794
2117
  discover: HttpUrl,
2118
+ /** Fetch this exact metadata document and verify its issuer against discovery. */
2119
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(HttpUrl),
1795
2120
  authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
1796
2121
  tokenUrl: Schema_exports.optionalKey(Schema_exports.Never),
1797
2122
  revocationUrl: Schema_exports.optionalKey(Schema_exports.Never),
@@ -1799,21 +2124,26 @@ var OAuth2Config = Schema_exports.Union([
1799
2124
  }),
1800
2125
  Schema_exports.Struct({
1801
2126
  ...oauthOptions,
2127
+ /** Its query is kept; it cannot set protocol parameters or repeat `authorizationParams`. */
1802
2128
  authorizationUrl: HttpUrl,
1803
2129
  tokenUrl: HttpUrl,
1804
2130
  revocationUrl: Schema_exports.optionalKey(HttpUrl),
1805
2131
  scopes: Schema_exports.Array(Schema_exports.String),
1806
2132
  /** RFC 8414 issuer identifier. Declared issuers are checked against the callback's `iss`. */
1807
2133
  issuer: Schema_exports.optionalKey(HttpUrl),
1808
- discover: Schema_exports.optionalKey(Schema_exports.Never)
1809
- }),
2134
+ discover: Schema_exports.optionalKey(Schema_exports.Never),
2135
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(Schema_exports.Never)
2136
+ }).check(declaredAuthorizationQuery),
1810
2137
  Schema_exports.Struct({
1811
2138
  grant: Schema_exports.Literal("client_credentials"),
1812
2139
  discover: HttpUrl,
2140
+ /** Fetch this exact metadata document and verify its issuer against discovery. */
2141
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(HttpUrl),
1813
2142
  authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
1814
2143
  tokenUrl: Schema_exports.optionalKey(Schema_exports.Never),
1815
2144
  revocationUrl: Schema_exports.optionalKey(Schema_exports.Never),
1816
2145
  scopes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String)),
2146
+ ...tokenRequestOptions,
1817
2147
  tokenEndpointAuthMethod: OAuthSecretClientAuth,
1818
2148
  resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl))
1819
2149
  }),
@@ -1822,10 +2152,12 @@ var OAuth2Config = Schema_exports.Union([
1822
2152
  tokenUrl: HttpUrl,
1823
2153
  revocationUrl: Schema_exports.optionalKey(HttpUrl),
1824
2154
  scopes: Schema_exports.Array(Schema_exports.String),
2155
+ ...tokenRequestOptions,
1825
2156
  tokenEndpointAuthMethod: OAuthSecretClientAuth,
1826
2157
  resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl)),
1827
2158
  authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
1828
- discover: Schema_exports.optionalKey(Schema_exports.Never)
2159
+ discover: Schema_exports.optionalKey(Schema_exports.Never),
2160
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(Schema_exports.Never)
1829
2161
  })
1830
2162
  ]);
1831
2163
  var OAuth2AccessToken = Schema_exports.Struct({ access_token: Schema_exports.String });
@@ -1833,6 +2165,16 @@ var OAuth2Method = class extends Data_exports.TaggedClass(
1833
2165
  "oauth2"
1834
2166
  ) {
1835
2167
  };
2168
+ var displayText = Schema_exports.String.check(Schema_exports.isMinLength(1), Schema_exports.isMaxLength(255));
2169
+ var AccountInfo = Schema_exports.Struct({
2170
+ externalId: Schema_exports.optionalKey(displayText),
2171
+ displayName: Schema_exports.optionalKey(displayText),
2172
+ username: Schema_exports.optionalKey(displayText),
2173
+ email: Schema_exports.optionalKey(displayText),
2174
+ avatarUrl: Schema_exports.optionalKey(HttpUrl),
2175
+ profileUrl: Schema_exports.optionalKey(HttpUrl)
2176
+ });
2177
+ var AccountCheckResult = Schema_exports.Struct({ accountInfo: Schema_exports.optionalKey(AccountInfo) });
1836
2178
  var Provider = class extends Data_exports.Class {
1837
2179
  /** Declare zero or more accounts from this provider without performing I/O. */
1838
2180
  many() {
@@ -1843,36 +2185,158 @@ var ManyAccounts = class extends Data_exports.TaggedClass("many") {
1843
2185
  };
1844
2186
 
1845
2187
  // src/contracts/protocol-version.ts
1846
- var frameworkProtocol = 3;
2188
+ var frameworkProtocol = 11;
1847
2189
 
1848
- // src/contracts/schedules.ts
1849
- var minimumIntervalMilliseconds = 6e4;
1850
- var count = Schema_exports.Int.check(Schema_exports.isGreaterThan(0));
1851
- var absent = Schema_exports.optionalKey(Schema_exports.Never);
1852
- var Interval = Schema_exports.Union([
1853
- Schema_exports.Struct({ seconds: count, minutes: absent, hours: absent }),
1854
- Schema_exports.Struct({ seconds: absent, minutes: count, hours: absent }),
1855
- Schema_exports.Struct({ seconds: absent, minutes: absent, hours: count })
1856
- ]);
1857
- var CalendarSchedule = Schema_exports.Struct({
1858
- expression: Schema_exports.NonEmptyString,
1859
- timezone: Schema_exports.NonEmptyString
1860
- }).check(
1861
- Schema_exports.makeFilter(
1862
- (value) => value.expression.trim().split(/\s+/).length === 5 && Result_exports.isSuccess(Cron_exports.parse(value.expression, value.timezone))
1863
- )
1864
- );
1865
- var ScheduleTiming = Schema_exports.Union([
1866
- Schema_exports.Struct({
1867
- kind: Schema_exports.Literal("interval"),
1868
- milliseconds: Schema_exports.Int.check(
1869
- Schema_exports.makeFilter((value) => value >= minimumIntervalMilliseconds, {
1870
- message: "Schedule intervals must be at least 60 seconds"
1871
- }),
1872
- Schema_exports.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER)
1873
- )
1874
- }),
1875
- Schema_exports.Struct({ kind: Schema_exports.Literal("cron"), calendar: CalendarSchedule })
2190
+ // src/contracts/protocols/oauth.ts
2191
+ var OAuthClientAuth2 = Schema_exports.Literals([
2192
+ "none",
2193
+ "client_secret_post",
2194
+ "client_secret_basic",
2195
+ "client_secret_basic_raw"
2196
+ ]);
2197
+ var OAuthSecretClientAuth2 = Schema_exports.Literals([
2198
+ "client_secret_post",
2199
+ "client_secret_basic",
2200
+ "client_secret_basic_raw"
2201
+ ]);
2202
+ var reservedAuthorizationParams2 = [
2203
+ "response_type",
2204
+ "client_id",
2205
+ "redirect_uri",
2206
+ "state",
2207
+ "scope",
2208
+ "code_challenge",
2209
+ "code_challenge_method",
2210
+ "nonce",
2211
+ "resource",
2212
+ "request",
2213
+ "request_uri"
2214
+ ];
2215
+ var reserved2 = new Set(reservedAuthorizationParams2);
2216
+ var OAuthAuthorizationParams2 = Schema_exports.Record(Schema_exports.String, Schema_exports.String).check(
2217
+ Schema_exports.makeFilter((params) => Object.keys(params).every((key) => !reserved2.has(key)), {
2218
+ message: "Authorization parameters cannot replace protocol parameters such as state or scope."
2219
+ })
2220
+ );
2221
+ var declaredAuthorizationQuery2 = Schema_exports.makeFilter(
2222
+ (config) => {
2223
+ const keys = [...new URL(config.authorizationUrl).searchParams.keys()];
2224
+ const owned = keys.filter((key) => reserved2.has(key));
2225
+ if (owned.length > 0)
2226
+ return {
2227
+ path: ["authorizationUrl"],
2228
+ issue: `authorizationUrl cannot set protocol parameters: ${owned.join(", ")}.`
2229
+ };
2230
+ const repeated = keys.filter((key) => Object.hasOwn(config.authorizationParams ?? {}, key));
2231
+ if (repeated.length > 0)
2232
+ return {
2233
+ path: ["authorizationParams"],
2234
+ issue: `Declare each parameter once; authorizationUrl already sets: ${repeated.join(", ")}.`
2235
+ };
2236
+ return void 0;
2237
+ }
2238
+ );
2239
+ var OAuthTokenRequestFormat2 = Schema_exports.Literals(["form", "json"]);
2240
+ var OAuthTokenResponse2 = Schema_exports.Struct({
2241
+ path: Schema_exports.String.check(Schema_exports.isPattern(/^[^.]+(\.[^.]+)*$/))
2242
+ });
2243
+ var tokenRequestOptions2 = {
2244
+ /** Joins requested scopes; Linear wants `","`. Defaults to RFC 6749's space. */
2245
+ scopeSeparator: Schema_exports.optionalKey(Schema_exports.String.check(Schema_exports.isMinLength(1))),
2246
+ /** Encoding of token requests. Defaults to `"form"`; Atlassian, ClickUp and Notion need `"json"`. */
2247
+ tokenRequestFormat: Schema_exports.optionalKey(OAuthTokenRequestFormat2)
2248
+ };
2249
+ var oauthOptions2 = {
2250
+ ...tokenRequestOptions2,
2251
+ /**
2252
+ * Read the grant from this nested member of the token response when the top-level response has
2253
+ * no access token or no scope. Slack's user tokens use `{ path: "authed_user" }`.
2254
+ */
2255
+ tokenResponse: Schema_exports.optionalKey(OAuthTokenResponse2),
2256
+ grant: Schema_exports.optionalKey(Schema_exports.Literal("authorization_code")),
2257
+ /**
2258
+ * Service-defined authorization request parameters, such as Google's
2259
+ * `{ access_type: "offline", prompt: "consent" }`. Host-owned protocol parameters
2260
+ * (`state`, `scope`, `redirect_uri`, PKCE and the others in `reservedAuthorizationParams`)
2261
+ * are rejected. A discovered endpoint's own query parameter of the same name is replaced.
2262
+ */
2263
+ authorizationParams: Schema_exports.optionalKey(OAuthAuthorizationParams2),
2264
+ tokenEndpointAuthMethod: Schema_exports.optionalKey(OAuthClientAuth2),
2265
+ /** Omitted uses discovery; null explicitly suppresses the resource parameter. */
2266
+ resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl))
2267
+ };
2268
+ var OAuth2Config2 = Schema_exports.Union([
2269
+ Schema_exports.Struct({
2270
+ ...oauthOptions2,
2271
+ discover: HttpUrl,
2272
+ authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
2273
+ tokenUrl: Schema_exports.optionalKey(Schema_exports.Never),
2274
+ revocationUrl: Schema_exports.optionalKey(Schema_exports.Never),
2275
+ scopes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String))
2276
+ }),
2277
+ Schema_exports.Struct({
2278
+ ...oauthOptions2,
2279
+ /** Its query is kept; it cannot set protocol parameters or repeat `authorizationParams`. */
2280
+ authorizationUrl: HttpUrl,
2281
+ tokenUrl: HttpUrl,
2282
+ revocationUrl: Schema_exports.optionalKey(HttpUrl),
2283
+ scopes: Schema_exports.Array(Schema_exports.String),
2284
+ /** RFC 8414 issuer identifier. Declared issuers are checked against the callback's `iss`. */
2285
+ issuer: Schema_exports.optionalKey(HttpUrl),
2286
+ discover: Schema_exports.optionalKey(Schema_exports.Never)
2287
+ }).check(declaredAuthorizationQuery2),
2288
+ Schema_exports.Struct({
2289
+ grant: Schema_exports.Literal("client_credentials"),
2290
+ discover: HttpUrl,
2291
+ authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
2292
+ tokenUrl: Schema_exports.optionalKey(Schema_exports.Never),
2293
+ revocationUrl: Schema_exports.optionalKey(Schema_exports.Never),
2294
+ scopes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String)),
2295
+ ...tokenRequestOptions2,
2296
+ tokenEndpointAuthMethod: OAuthSecretClientAuth2,
2297
+ resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl))
2298
+ }),
2299
+ Schema_exports.Struct({
2300
+ grant: Schema_exports.Literal("client_credentials"),
2301
+ tokenUrl: HttpUrl,
2302
+ revocationUrl: Schema_exports.optionalKey(HttpUrl),
2303
+ scopes: Schema_exports.Array(Schema_exports.String),
2304
+ ...tokenRequestOptions2,
2305
+ tokenEndpointAuthMethod: OAuthSecretClientAuth2,
2306
+ resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl)),
2307
+ authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
2308
+ discover: Schema_exports.optionalKey(Schema_exports.Never)
2309
+ })
2310
+ ]);
2311
+
2312
+ // src/contracts/schedules.ts
2313
+ var minimumIntervalMilliseconds = 6e4;
2314
+ var count2 = Schema_exports.Int.check(Schema_exports.isGreaterThan(0));
2315
+ var absent = Schema_exports.optionalKey(Schema_exports.Never);
2316
+ var Interval = Schema_exports.Union([
2317
+ Schema_exports.Struct({ seconds: count2, minutes: absent, hours: absent }),
2318
+ Schema_exports.Struct({ seconds: absent, minutes: count2, hours: absent }),
2319
+ Schema_exports.Struct({ seconds: absent, minutes: absent, hours: count2 })
2320
+ ]);
2321
+ var CalendarSchedule = Schema_exports.Struct({
2322
+ expression: Schema_exports.NonEmptyString,
2323
+ timezone: Schema_exports.NonEmptyString
2324
+ }).check(
2325
+ Schema_exports.makeFilter(
2326
+ (value) => value.expression.trim().split(/\s+/).length === 5 && Result_exports.isSuccess(Cron_exports.parse(value.expression, value.timezone))
2327
+ )
2328
+ );
2329
+ var ScheduleTiming = Schema_exports.Union([
2330
+ Schema_exports.Struct({
2331
+ kind: Schema_exports.Literal("interval"),
2332
+ milliseconds: Schema_exports.Int.check(
2333
+ Schema_exports.makeFilter((value) => value >= minimumIntervalMilliseconds, {
2334
+ message: "Schedule intervals must be at least 60 seconds"
2335
+ }),
2336
+ Schema_exports.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER)
2337
+ )
2338
+ }),
2339
+ Schema_exports.Struct({ kind: Schema_exports.Literal("cron"), calendar: CalendarSchedule })
1876
2340
  ]);
1877
2341
  var OperationSchedule = Schema_exports.Struct({
1878
2342
  name: Schema_exports.NonEmptyString,
@@ -1881,6 +2345,38 @@ var OperationSchedule = Schema_exports.Struct({
1881
2345
  });
1882
2346
 
1883
2347
  // src/contracts/protocols/1.ts
2348
+ var ProviderError2 = class extends Schema_exports.TaggedError()("ProviderError", {
2349
+ reason: Schema_exports.Literals(["unauthorized", "forbidden", "rate_limited", "unavailable", "rejected"]),
2350
+ status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
2351
+ accountId: Schema_exports.optional(AccountId)
2352
+ }) {
2353
+ };
2354
+ var McpError3 = class extends Schema_exports.TaggedError()("McpError", {
2355
+ phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
2356
+ reason: Schema_exports.Literals([
2357
+ "request",
2358
+ "unauthorized",
2359
+ "invalid_response",
2360
+ "timeout",
2361
+ "invalid_input"
2362
+ ]),
2363
+ status: Schema_exports.optional(Schema_exports.Number)
2364
+ }) {
2365
+ };
2366
+ var SkillLoadFailed = class extends Schema_exports.TaggedError()("SkillLoadFailed", {
2367
+ reason: Schema_exports.Literals([
2368
+ "source",
2369
+ "request",
2370
+ "rate_limited",
2371
+ "document",
2372
+ "limit",
2373
+ "changed",
2374
+ "encoding"
2375
+ ]),
2376
+ message: Schema_exports.optional(Schema_exports.String.check(Schema_exports.isMaxLength(500))),
2377
+ status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 })))
2378
+ }) {
2379
+ };
1884
2380
  var WorkflowFailure2 = class extends Schema_exports.TaggedError()("WorkflowFailure", {
1885
2381
  reason: Schema_exports.Literals([
1886
2382
  "unavailable",
@@ -1906,22 +2402,22 @@ var DeclaredAuthMethod = Schema_exports.Union([
1906
2402
  Schema_exports.Struct({ type: Schema_exports.Literal("secrets"), label: Schema_exports.String, fields: JsonObject2 }),
1907
2403
  Schema_exports.Struct({
1908
2404
  type: Schema_exports.Literal("oauth2"),
1909
- ...OAuth2Config.members[0].fields,
2405
+ ...OAuth2Config2.members[0].fields,
1910
2406
  response: JsonObject2
1911
2407
  }),
1912
2408
  Schema_exports.Struct({
1913
2409
  type: Schema_exports.Literal("oauth2"),
1914
- ...OAuth2Config.members[1].fields,
2410
+ ...OAuth2Config2.members[1].fields,
1915
2411
  response: JsonObject2
1916
2412
  }),
1917
2413
  Schema_exports.Struct({
1918
2414
  type: Schema_exports.Literal("oauth2"),
1919
- ...OAuth2Config.members[2].fields,
2415
+ ...OAuth2Config2.members[2].fields,
1920
2416
  response: JsonObject2
1921
2417
  }),
1922
2418
  Schema_exports.Struct({
1923
2419
  type: Schema_exports.Literal("oauth2"),
1924
- ...OAuth2Config.members[3].fields,
2420
+ ...OAuth2Config2.members[3].fields,
1925
2421
  response: JsonObject2
1926
2422
  })
1927
2423
  ]);
@@ -1976,7 +2472,7 @@ var HostedTool = Schema_exports.Struct({
1976
2472
  readOnly: Schema_exports.optionalKey(Schema_exports.Boolean),
1977
2473
  title: Schema_exports.optionalKey(Schema_exports.String),
1978
2474
  outputSchema: Schema_exports.optionalKey(JsonObject2),
1979
- annotations: Schema_exports.optionalKey(ToolAnnotations),
2475
+ annotations: Schema_exports.optionalKey(ToolAnnotations2),
1980
2476
  _meta: Schema_exports.optionalKey(JsonObject2)
1981
2477
  });
1982
2478
  var HostedToolSummary = HostedTool.mapFields(
@@ -2083,8 +2579,8 @@ var HostOutputInvalid = class extends Schema_exports.TaggedError()(
2083
2579
  };
2084
2580
  var HostError = Schema_exports.Union([
2085
2581
  OpenapiResponseError,
2086
- ProviderError,
2087
- McpError,
2582
+ ProviderError2,
2583
+ McpError3,
2088
2584
  SkillLoadFailed,
2089
2585
  WorkflowFailure2,
2090
2586
  HostRequestInvalid,
@@ -2150,25 +2646,31 @@ var protocol2 = {
2150
2646
  };
2151
2647
 
2152
2648
  // src/contracts/protocols/3.ts
2649
+ var FailureDetail2 = {
2650
+ source: Schema_exports.optionalKey(FailureSource),
2651
+ errorName: Schema_exports.optionalKey(FailureName),
2652
+ code: Schema_exports.optionalKey(FailureCode),
2653
+ message: Schema_exports.optionalKey(FailureMessage)
2654
+ };
2153
2655
  var HostDeclarationInvalid2 = class extends Schema_exports.TaggedError()(
2154
2656
  "HostDeclarationInvalid",
2155
- FailureDetail
2657
+ FailureDetail2
2156
2658
  ) {
2157
2659
  };
2158
2660
  var HostEvaluationFailed2 = class extends Schema_exports.TaggedError()(
2159
2661
  "HostEvaluationFailed",
2160
- FailureDetail
2662
+ FailureDetail2
2161
2663
  ) {
2162
2664
  };
2163
2665
  var HostOperationFailed2 = class extends Schema_exports.TaggedError()(
2164
2666
  "HostOperationFailed",
2165
- FailureDetail
2667
+ FailureDetail2
2166
2668
  ) {
2167
2669
  };
2168
2670
  var HostError2 = Schema_exports.Union([
2169
2671
  OpenapiResponseError,
2170
- ProviderError,
2171
- McpError,
2672
+ ProviderError2,
2673
+ McpError3,
2172
2674
  SkillLoadFailed,
2173
2675
  WorkflowFailure,
2174
2676
  HostRequestInvalid,
@@ -2215,8 +2717,554 @@ var protocol3 = {
2215
2717
  }
2216
2718
  };
2217
2719
 
2218
- // src/contracts/operations.ts
2219
- var OperationToolPrefixes = { query: "queries.", mutate: "mutations." };
2720
+ // src/contracts/protocols/4.ts
2721
+ var HostedTool2 = Schema_exports.Struct({
2722
+ schedules: Schema_exports.optionalKey(Schema_exports.Array(OperationSchedule)),
2723
+ name: Schema_exports.NonEmptyString,
2724
+ router: Schema_exports.optionalKey(Schema_exports.NonEmptyString),
2725
+ tags: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
2726
+ description: Schema_exports.String,
2727
+ inputSchema: JsonObject2,
2728
+ readOnly: Schema_exports.optionalKey(Schema_exports.Boolean),
2729
+ title: Schema_exports.optionalKey(Schema_exports.String),
2730
+ outputSchema: Schema_exports.optionalKey(JsonObject2),
2731
+ annotations: Schema_exports.optionalKey(ToolAnnotations2),
2732
+ _meta: Schema_exports.optionalKey(JsonObject2)
2733
+ });
2734
+ var HostedToolSummary2 = HostedTool2.mapFields(
2735
+ ({ inputSchema: _input, outputSchema: _output, _meta, ...fields }) => fields
2736
+ );
2737
+ var HostRouterError = Schema_exports.Union([
2738
+ ProviderError2,
2739
+ McpError3,
2740
+ SkillLoadFailed,
2741
+ HostDeclarationInvalid2,
2742
+ HostEvaluationFailed2
2743
+ ]);
2744
+ var HostedRouter = Schema_exports.Struct({
2745
+ path: Schema_exports.String,
2746
+ title: Schema_exports.optionalKey(Schema_exports.String),
2747
+ description: Schema_exports.optionalKey(Schema_exports.String),
2748
+ icons: Schema_exports.optionalKey(Schema_exports.Array(RouterIcon)),
2749
+ tags: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.NonEmptyString, Schema_exports.String)),
2750
+ skill: Schema_exports.optionalKey(AppSkillName),
2751
+ error: Schema_exports.optionalKey(HostRouterError)
2752
+ });
2753
+ var HostedCatalog = Schema_exports.Struct({
2754
+ tools: Schema_exports.Array(HostedTool2),
2755
+ routers: Schema_exports.Array(HostedRouter)
2756
+ });
2757
+ var HostedCatalogSummary = Schema_exports.Struct({
2758
+ tools: Schema_exports.Array(HostedToolSummary2),
2759
+ routers: Schema_exports.Array(HostedRouter)
2760
+ });
2761
+ var ToolKind = Schema_exports.Literals(["query", "mutation"]);
2762
+ var HostRequest2 = Schema_exports.Union([
2763
+ WorkflowCommand,
2764
+ WebhookCommand,
2765
+ Schema_exports.Struct({ operation: Schema_exports.Literal("requirements") }),
2766
+ Schema_exports.Struct({
2767
+ operation: Schema_exports.Literal("inspect"),
2768
+ /** Omit schemas. Only builds that declare the toolIndex capability accept this. */
2769
+ detail: Schema_exports.optionalKey(Schema_exports.Literal("summary")),
2770
+ /** Describe only these tools. Only builds that declare the toolIndex capability accept this. */
2771
+ tools: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
2772
+ /**
2773
+ * Describe only declared operations that have schedules, without dynamic tool discovery.
2774
+ * Only builds that declare the scheduledTools capability accept this.
2775
+ */
2776
+ scheduled: Schema_exports.optionalKey(Schema_exports.Literal(true))
2777
+ }),
2778
+ Schema_exports.Struct({
2779
+ operation: Schema_exports.Literal("skills"),
2780
+ /** Answer with SkillSources. Only builds that declare the skillSources capability accept this. */
2781
+ sources: Schema_exports.optionalKey(Schema_exports.Literal(true))
2782
+ }),
2783
+ Schema_exports.Struct({
2784
+ operation: Schema_exports.Literal("query"),
2785
+ name: Schema_exports.NonEmptyString,
2786
+ input: JsonValue
2787
+ }),
2788
+ Schema_exports.Struct({
2789
+ operation: Schema_exports.Literal("mutate"),
2790
+ name: Schema_exports.NonEmptyString,
2791
+ input: JsonValue
2792
+ }),
2793
+ Schema_exports.Struct({
2794
+ operation: Schema_exports.Literal("call"),
2795
+ tool: Schema_exports.NonEmptyString,
2796
+ /**
2797
+ * The caller's claim; the bundle rejects a call whose tool has the other kind. The host omits
2798
+ * it for a tool its catalog does not list, and then opens storage for writing.
2799
+ */
2800
+ kind: Schema_exports.optionalKey(ToolKind),
2801
+ input: JsonValue
2802
+ })
2803
+ ]);
2804
+ var HostKindMismatch = class extends Schema_exports.TaggedError()("HostKindMismatch", {
2805
+ tool: Schema_exports.NonEmptyString,
2806
+ requested: ToolKind,
2807
+ actual: ToolKind
2808
+ }) {
2809
+ };
2810
+ var HostError3 = Schema_exports.Union([...HostError2.members, HostKindMismatch]);
2811
+ var HostResponse3 = Schema_exports.Union([
2812
+ Schema_exports.Struct({
2813
+ ok: Schema_exports.Literal(true),
2814
+ value: JsonValue,
2815
+ toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
2816
+ }),
2817
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError3 })
2818
+ ]);
2819
+ var HostInvocation2 = Schema_exports.Struct({
2820
+ command: HostRequest2,
2821
+ accounts: ResolvedAccounts,
2822
+ approval: Schema_exports.optionalKey(TrustedToolApproval),
2823
+ replay: Schema_exports.optionalKey(WorkflowReplay),
2824
+ deadline: Schema_exports.optionalKey(InvocationDeadline),
2825
+ workflowRun: Schema_exports.optionalKey(WorkflowRunId)
2826
+ });
2827
+ var protocol4 = {
2828
+ version: 4,
2829
+ schemas: {
2830
+ invocation: HostInvocation2,
2831
+ request: HostRequest2,
2832
+ response: HostResponse3,
2833
+ requirements: DeclaredRequirements,
2834
+ catalog: HostedCatalog,
2835
+ catalogSummary: HostedCatalogSummary,
2836
+ skills: SkillCatalogResponse2,
2837
+ elicitationRequest: FormElicitation,
2838
+ elicitationReply: ElicitationReply,
2839
+ workflowStep: WorkflowRpcCommand,
2840
+ workflowStepReply: WorkflowRpcResult,
2841
+ workflowControl: WorkflowControlCommand,
2842
+ cacheCommand: CacheCommand,
2843
+ cacheReply: CacheReply
2844
+ }
2845
+ };
2846
+
2847
+ // src/contracts/protocols/5.ts
2848
+ var DeclaredRequirements2 = Schema_exports.Struct({
2849
+ /** Protocol support of this retained framework build, not an author-declared requirement. */
2850
+ capabilities: Schema_exports.optionalKey(
2851
+ Schema_exports.Struct({
2852
+ skills: Schema_exports.Literal(true),
2853
+ toolIndex: Schema_exports.optionalKey(Schema_exports.Literal(true)),
2854
+ skillSources: Schema_exports.optionalKey(Schema_exports.Literal(true)),
2855
+ scheduledTools: Schema_exports.optionalKey(Schema_exports.Literal(true))
2856
+ })
2857
+ ),
2858
+ database: Schema_exports.optionalKey(DatabaseSchema),
2859
+ accounts: Schema_exports.Record(
2860
+ Schema_exports.NonEmptyString,
2861
+ Schema_exports.Struct({
2862
+ definition: DeclaredProvider,
2863
+ cardinality: Schema_exports.Literals(["one", "many"]),
2864
+ /**
2865
+ * The slot's provider defines an account check. Kept beside the definition, not in it, so
2866
+ * adding or editing a check never changes the provider's identity.
2867
+ */
2868
+ health: Schema_exports.optionalKey(Schema_exports.Literal(true))
2869
+ })
2870
+ )
2871
+ });
2872
+ var AccountCheckCommand = Schema_exports.Struct({
2873
+ operation: Schema_exports.Literal("account-check"),
2874
+ requirement: Schema_exports.NonEmptyString
2875
+ });
2876
+ var HostRequest3 = Schema_exports.Union([
2877
+ ...protocol4.schemas.request.members,
2878
+ AccountCheckCommand
2879
+ ]);
2880
+ var HostInvocation3 = Schema_exports.Struct({
2881
+ command: HostRequest3,
2882
+ accounts: ResolvedAccounts,
2883
+ approval: Schema_exports.optionalKey(TrustedToolApproval),
2884
+ replay: Schema_exports.optionalKey(WorkflowReplay),
2885
+ deadline: Schema_exports.optionalKey(InvocationDeadline),
2886
+ workflowRun: Schema_exports.optionalKey(WorkflowRunId)
2887
+ });
2888
+ var protocol5 = {
2889
+ version: 5,
2890
+ schemas: {
2891
+ ...protocol4.schemas,
2892
+ invocation: HostInvocation3,
2893
+ request: HostRequest3,
2894
+ requirements: DeclaredRequirements2,
2895
+ accountCheck: AccountCheckResult
2896
+ }
2897
+ };
2898
+
2899
+ // src/contracts/protocols/6.ts
2900
+ var DeclaredAuthMethod2 = Schema_exports.Union([
2901
+ Schema_exports.Struct({ type: Schema_exports.Literal("secrets"), label: Schema_exports.String, fields: JsonObject2 }),
2902
+ Schema_exports.Struct({
2903
+ type: Schema_exports.Literal("oauth2"),
2904
+ ...OAuth2Config.members[0].fields,
2905
+ response: JsonObject2
2906
+ }),
2907
+ Schema_exports.Struct({
2908
+ type: Schema_exports.Literal("oauth2"),
2909
+ ...OAuth2Config.members[1].fields,
2910
+ response: JsonObject2
2911
+ }),
2912
+ Schema_exports.Struct({
2913
+ type: Schema_exports.Literal("oauth2"),
2914
+ ...OAuth2Config.members[2].fields,
2915
+ response: JsonObject2
2916
+ }),
2917
+ Schema_exports.Struct({
2918
+ type: Schema_exports.Literal("oauth2"),
2919
+ ...OAuth2Config.members[3].fields,
2920
+ response: JsonObject2
2921
+ })
2922
+ ]);
2923
+ var DeclaredProvider2 = Schema_exports.Struct({
2924
+ name: Schema_exports.NonEmptyString,
2925
+ auth: Schema_exports.Record(Schema_exports.NonEmptyString, DeclaredAuthMethod2)
2926
+ });
2927
+ var DeclaredRequirements3 = Schema_exports.Struct({
2928
+ ...DeclaredRequirements2.fields,
2929
+ accounts: Schema_exports.Record(
2930
+ Schema_exports.NonEmptyString,
2931
+ Schema_exports.Struct({
2932
+ definition: DeclaredProvider2,
2933
+ cardinality: Schema_exports.Literals(["one", "many"]),
2934
+ health: Schema_exports.optionalKey(Schema_exports.Literal(true))
2935
+ })
2936
+ )
2937
+ });
2938
+ var ResolvedAccount2 = Schema_exports.Struct({
2939
+ ...ResolvedAccount.fields,
2940
+ provider: DeclaredProvider2
2941
+ });
2942
+ var ResolvedAccounts2 = Schema_exports.Record(
2943
+ Schema_exports.NonEmptyString,
2944
+ Schema_exports.Union([ResolvedAccount2, Schema_exports.Array(ResolvedAccount2)])
2945
+ );
2946
+ var HostInvocation4 = Schema_exports.Struct({
2947
+ ...HostInvocation3.fields,
2948
+ accounts: ResolvedAccounts2
2949
+ });
2950
+ var protocol6 = {
2951
+ version: 6,
2952
+ schemas: {
2953
+ ...protocol5.schemas,
2954
+ requirements: DeclaredRequirements3,
2955
+ accounts: ResolvedAccounts2,
2956
+ invocation: HostInvocation4
2957
+ }
2958
+ };
2959
+
2960
+ // src/contracts/protocols/7.ts
2961
+ var CredentialHost = Schema_exports.String.check(
2962
+ Schema_exports.isPattern(
2963
+ /^(\*\.)?[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*(?::[0-9]{1,5})?$/
2964
+ )
2965
+ );
2966
+ var exposure = {
2967
+ /** Not secret: app code reads the real value and forms show it. */
2968
+ plain: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
2969
+ /** Secret, but app code reads the real value, for signing and similar uses. */
2970
+ raw: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString))
2971
+ };
2972
+ var DeclaredAuthMethod3 = Schema_exports.Union([
2973
+ Schema_exports.Struct({
2974
+ type: Schema_exports.Literal("secrets"),
2975
+ label: Schema_exports.String,
2976
+ fields: JsonObject2,
2977
+ ...exposure
2978
+ }),
2979
+ Schema_exports.Struct({
2980
+ type: Schema_exports.Literal("oauth2"),
2981
+ ...OAuth2Config.members[0].fields,
2982
+ response: JsonObject2,
2983
+ ...exposure
2984
+ }),
2985
+ Schema_exports.Struct({
2986
+ type: Schema_exports.Literal("oauth2"),
2987
+ ...OAuth2Config.members[1].fields,
2988
+ response: JsonObject2,
2989
+ ...exposure
2990
+ }),
2991
+ Schema_exports.Struct({
2992
+ type: Schema_exports.Literal("oauth2"),
2993
+ ...OAuth2Config.members[2].fields,
2994
+ response: JsonObject2,
2995
+ ...exposure
2996
+ }),
2997
+ Schema_exports.Struct({
2998
+ type: Schema_exports.Literal("oauth2"),
2999
+ ...OAuth2Config.members[3].fields,
3000
+ response: JsonObject2,
3001
+ ...exposure
3002
+ })
3003
+ ]);
3004
+ var DeclaredProvider3 = Schema_exports.Struct({
3005
+ name: Schema_exports.NonEmptyString,
3006
+ auth: Schema_exports.Record(Schema_exports.NonEmptyString, DeclaredAuthMethod3),
3007
+ hosts: Schema_exports.optionalKey(Schema_exports.Array(CredentialHost))
3008
+ });
3009
+ var DeclaredRequirements4 = Schema_exports.Struct({
3010
+ ...DeclaredRequirements3.fields,
3011
+ accounts: Schema_exports.Record(
3012
+ Schema_exports.NonEmptyString,
3013
+ Schema_exports.Struct({
3014
+ definition: DeclaredProvider3,
3015
+ cardinality: Schema_exports.Literals(["one", "many"]),
3016
+ health: Schema_exports.optionalKey(Schema_exports.Literal(true))
3017
+ })
3018
+ )
3019
+ });
3020
+ var ResolvedAccount3 = Schema_exports.Struct({
3021
+ ...ResolvedAccount2.fields,
3022
+ provider: DeclaredProvider3
3023
+ });
3024
+ var ResolvedAccounts3 = Schema_exports.Record(
3025
+ Schema_exports.NonEmptyString,
3026
+ Schema_exports.Union([ResolvedAccount3, Schema_exports.Array(ResolvedAccount3)])
3027
+ );
3028
+ var HostInvocation5 = Schema_exports.Struct({
3029
+ ...HostInvocation4.fields,
3030
+ accounts: ResolvedAccounts3
3031
+ });
3032
+ var protocol7 = {
3033
+ version: 7,
3034
+ schemas: {
3035
+ ...protocol6.schemas,
3036
+ requirements: DeclaredRequirements4,
3037
+ accounts: ResolvedAccounts3,
3038
+ invocation: HostInvocation5
3039
+ }
3040
+ };
3041
+
3042
+ // src/contracts/protocols/8.ts
3043
+ var McpError4 = class extends Schema_exports.TaggedError()("McpError", {
3044
+ phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
3045
+ reason: Schema_exports.Literals([
3046
+ "request",
3047
+ "unauthorized",
3048
+ "invalid_response",
3049
+ "timeout",
3050
+ "invalid_input"
3051
+ ]),
3052
+ status: Schema_exports.optional(Schema_exports.Number),
3053
+ upstream: Schema_exports.optional(UpstreamError)
3054
+ }) {
3055
+ };
3056
+ var HostDeclarationInvalid3 = class extends Schema_exports.TaggedError()(
3057
+ "HostDeclarationInvalid",
3058
+ FailureDetail
3059
+ ) {
3060
+ };
3061
+ var HostEvaluationFailed3 = class extends Schema_exports.TaggedError()(
3062
+ "HostEvaluationFailed",
3063
+ FailureDetail
3064
+ ) {
3065
+ };
3066
+ var HostOperationFailed3 = class extends Schema_exports.TaggedError()(
3067
+ "HostOperationFailed",
3068
+ FailureDetail
3069
+ ) {
3070
+ };
3071
+ var HostRouterError2 = Schema_exports.Union([
3072
+ ProviderError,
3073
+ McpError4,
3074
+ SkillLoadFailed,
3075
+ HostDeclarationInvalid3,
3076
+ HostEvaluationFailed3
3077
+ ]);
3078
+ var HostedRouter2 = Schema_exports.Struct({
3079
+ ...HostedRouter.fields,
3080
+ error: Schema_exports.optionalKey(HostRouterError2)
3081
+ });
3082
+ var HostedCatalog2 = Schema_exports.Struct({
3083
+ ...HostedCatalog.fields,
3084
+ routers: Schema_exports.Array(HostedRouter2)
3085
+ });
3086
+ var HostedCatalogSummary2 = Schema_exports.Struct({
3087
+ ...HostedCatalogSummary.fields,
3088
+ routers: Schema_exports.Array(HostedRouter2)
3089
+ });
3090
+ var HostError4 = Schema_exports.Union([
3091
+ OpenapiResponseError,
3092
+ ProviderError,
3093
+ McpError4,
3094
+ SkillLoadFailed,
3095
+ WorkflowFailure,
3096
+ HostRequestInvalid,
3097
+ HostAccountsInvalid,
3098
+ HostDeclarationInvalid3,
3099
+ HostEvaluationFailed3,
3100
+ HostOperationNotFound,
3101
+ HostOperationFailed3,
3102
+ DatabaseLimitExceeded,
3103
+ DatabaseFieldReserved,
3104
+ HostToolNotFound,
3105
+ HostInputInvalid,
3106
+ HostOutputInvalid,
3107
+ HostToolBlocked,
3108
+ HostToolApprovalRequired,
3109
+ HostToolPolicyFailed,
3110
+ ElicitationFailed,
3111
+ HostKindMismatch
3112
+ ]);
3113
+ var HostResponse4 = Schema_exports.Union([
3114
+ Schema_exports.Struct({
3115
+ ok: Schema_exports.Literal(true),
3116
+ value: JsonValue,
3117
+ toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
3118
+ }),
3119
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError4 })
3120
+ ]);
3121
+ var protocol8 = {
3122
+ version: 8,
3123
+ schemas: {
3124
+ ...protocol7.schemas,
3125
+ response: HostResponse4,
3126
+ catalog: HostedCatalog2,
3127
+ catalogSummary: HostedCatalogSummary2
3128
+ }
3129
+ };
3130
+
3131
+ // src/contracts/protocols/9.ts
3132
+ var McpError5 = class extends Schema_exports.TaggedError()("McpError", {
3133
+ phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
3134
+ reason: Schema_exports.Literals([
3135
+ "request",
3136
+ "unauthorized",
3137
+ "invalid_response",
3138
+ "timeout",
3139
+ "invalid_input"
3140
+ ]),
3141
+ status: Schema_exports.optional(Schema_exports.Number),
3142
+ upstream: Schema_exports.optional(UpstreamError),
3143
+ session: Schema_exports.optional(Schema_exports.Literal(true))
3144
+ }) {
3145
+ };
3146
+ var SkillLoadFailed2 = class extends Schema_exports.TaggedError()("SkillLoadFailed", {
3147
+ reason: Schema_exports.Literals([
3148
+ "source",
3149
+ "request",
3150
+ "rate_limited",
3151
+ "document",
3152
+ "limit",
3153
+ "changed",
3154
+ "encoding"
3155
+ ]),
3156
+ message: Schema_exports.optional(Schema_exports.String.check(Schema_exports.isMaxLength(500))),
3157
+ status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
3158
+ missing: Schema_exports.optional(Schema_exports.Literals(["repository", "ref"]))
3159
+ }) {
3160
+ };
3161
+ var HostRouterError3 = Schema_exports.Union([
3162
+ ProviderError,
3163
+ McpError5,
3164
+ SkillLoadFailed2,
3165
+ HostDeclarationInvalid3,
3166
+ HostEvaluationFailed3
3167
+ ]);
3168
+ var HostedRouter3 = Schema_exports.Struct({
3169
+ ...HostedRouter2.fields,
3170
+ error: Schema_exports.optionalKey(HostRouterError3)
3171
+ });
3172
+ var HostedCatalog3 = Schema_exports.Struct({
3173
+ ...HostedCatalog2.fields,
3174
+ routers: Schema_exports.Array(HostedRouter3)
3175
+ });
3176
+ var HostedCatalogSummary3 = Schema_exports.Struct({
3177
+ ...HostedCatalogSummary2.fields,
3178
+ routers: Schema_exports.Array(HostedRouter3)
3179
+ });
3180
+ var HostError5 = Schema_exports.Union([
3181
+ OpenapiResponseError,
3182
+ ProviderError,
3183
+ McpError5,
3184
+ SkillLoadFailed2,
3185
+ WorkflowFailure,
3186
+ HostRequestInvalid,
3187
+ HostAccountsInvalid,
3188
+ HostDeclarationInvalid3,
3189
+ HostEvaluationFailed3,
3190
+ HostOperationNotFound,
3191
+ HostOperationFailed3,
3192
+ DatabaseLimitExceeded,
3193
+ DatabaseFieldReserved,
3194
+ HostToolNotFound,
3195
+ HostInputInvalid,
3196
+ HostOutputInvalid,
3197
+ HostToolBlocked,
3198
+ HostToolApprovalRequired,
3199
+ HostToolPolicyFailed,
3200
+ ElicitationFailed,
3201
+ HostKindMismatch
3202
+ ]);
3203
+ var HostResponse5 = Schema_exports.Union([
3204
+ Schema_exports.Struct({
3205
+ ok: Schema_exports.Literal(true),
3206
+ value: JsonValue,
3207
+ toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
3208
+ }),
3209
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError5 })
3210
+ ]);
3211
+ var protocol9 = {
3212
+ version: 9,
3213
+ schemas: {
3214
+ ...protocol8.schemas,
3215
+ response: HostResponse5,
3216
+ catalog: HostedCatalog3,
3217
+ catalogSummary: HostedCatalogSummary3
3218
+ }
3219
+ };
3220
+
3221
+ // src/contracts/protocols/10.ts
3222
+ var DeclaredRequirements5 = Schema_exports.Struct({
3223
+ ...DeclaredRequirements4.fields,
3224
+ sql: Schema_exports.optionalKey(Schema_exports.Literal(true))
3225
+ });
3226
+ var MigrateCommand = Schema_exports.Struct({ operation: Schema_exports.Literal("migrate") });
3227
+ var MigrateResult = Schema_exports.Array(
3228
+ Schema_exports.Struct({ id: Schema_exports.Int, name: Schema_exports.NonEmptyString })
3229
+ );
3230
+ var HostRequest4 = Schema_exports.Union([...HostRequest3.members, MigrateCommand]);
3231
+ var HostInvocation6 = Schema_exports.Struct({
3232
+ ...HostInvocation5.fields,
3233
+ command: HostRequest4
3234
+ });
3235
+ var protocol10 = {
3236
+ version: 10,
3237
+ schemas: {
3238
+ ...protocol9.schemas,
3239
+ request: HostRequest4,
3240
+ requirements: DeclaredRequirements5,
3241
+ invocation: HostInvocation6,
3242
+ migrate: MigrateResult
3243
+ }
3244
+ };
3245
+
3246
+ // src/contracts/protocols/11.ts
3247
+ var DeclaredRequirements6 = Schema_exports.Struct({
3248
+ ...DeclaredRequirements5.fields,
3249
+ events: Schema_exports.optionalKey(DeclaredEvents)
3250
+ });
3251
+ var HostResponse6 = Schema_exports.Union([
3252
+ Schema_exports.Struct({
3253
+ ok: Schema_exports.Literal(true),
3254
+ value: JsonValue,
3255
+ toolError: Schema_exports.optionalKey(Schema_exports.Literal(true)),
3256
+ events: Schema_exports.optionalKey(EmittedEvents)
3257
+ }),
3258
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError5 })
3259
+ ]);
3260
+ var protocol11 = {
3261
+ version: 11,
3262
+ schemas: {
3263
+ ...protocol10.schemas,
3264
+ requirements: DeclaredRequirements6,
3265
+ response: HostResponse6
3266
+ }
3267
+ };
2220
3268
 
2221
3269
  // src/contracts/host.ts
2222
3270
  var skillsCommand = (sources) => sources ? { operation: "skills", sources: true } : { operation: "skills" };
@@ -2227,20 +3275,20 @@ var inspectCommand = (tools, scheduled) => ({
2227
3275
  ...scheduled === void 0 ? {} : { scheduled }
2228
3276
  });
2229
3277
  var indexCommand = { operation: "inspect", detail: "summary" };
2230
- var selectTools = (tools) => (all) => tools === void 0 ? all : all.filter((tool) => tools.includes(tool.name));
3278
+ var selectTools = (tools) => (catalog) => tools === void 0 ? catalog : { ...catalog, tools: catalog.tools.filter((tool) => tools.includes(tool.name)) };
2231
3279
  var HostRequirementsError = Schema_exports.Union([
2232
3280
  HostRequestInvalid,
2233
- HostDeclarationInvalid2,
3281
+ HostDeclarationInvalid3,
2234
3282
  DatabaseFieldReserved
2235
3283
  ]);
2236
3284
  var HostInspectError = Schema_exports.Union([
2237
3285
  ProviderError,
2238
- McpError,
2239
- SkillLoadFailed,
3286
+ McpError5,
3287
+ SkillLoadFailed2,
2240
3288
  HostRequestInvalid,
2241
- HostDeclarationInvalid2,
3289
+ HostDeclarationInvalid3,
2242
3290
  HostAccountsInvalid,
2243
- HostEvaluationFailed2
3291
+ HostEvaluationFailed3
2244
3292
  ]);
2245
3293
  var HostCallError = Schema_exports.Union([
2246
3294
  OpenapiResponseError,
@@ -2248,7 +3296,8 @@ var HostCallError = Schema_exports.Union([
2248
3296
  HostInspectError,
2249
3297
  HostToolNotFound,
2250
3298
  HostOperationNotFound,
2251
- HostOperationFailed2,
3299
+ HostKindMismatch,
3300
+ HostOperationFailed3,
2252
3301
  DatabaseLimitExceeded,
2253
3302
  HostInputInvalid,
2254
3303
  HostOutputInvalid,
@@ -2257,37 +3306,53 @@ var HostCallError = Schema_exports.Union([
2257
3306
  HostToolPolicyFailed,
2258
3307
  ElicitationFailed
2259
3308
  ]);
3309
+ var HostAccountCheckError = Schema_exports.Union([
3310
+ ProviderError,
3311
+ WorkflowFailure,
3312
+ HostRequestInvalid,
3313
+ HostDeclarationInvalid3,
3314
+ HostAccountsInvalid,
3315
+ HostOperationNotFound,
3316
+ HostOperationFailed3,
3317
+ HostOutputInvalid
3318
+ ]);
2260
3319
  var HostDataError = HostCallError;
2261
3320
  var ToolResultObservation = Context_exports.Reference(
2262
3321
  "apps/ToolResultObservation",
2263
3322
  { defaultValue: () => ({ failed: () => {
2264
3323
  } }) }
2265
3324
  );
3325
+ var InvocationTiming = Schema_exports.Struct({
3326
+ elapsedMs: Schema_exports.Finite,
3327
+ upstreamMs: Schema_exports.Finite,
3328
+ elicitationMs: Schema_exports.Finite,
3329
+ authoredMs: Schema_exports.Finite
3330
+ });
3331
+ var InvocationTimingSink = Context_exports.Reference(
3332
+ "apps/InvocationTimingSink",
3333
+ { defaultValue: () => () => {
3334
+ } }
3335
+ );
2266
3336
 
2267
3337
  export {
2268
3338
  SecretsMethod,
2269
3339
  OAuthClientAuth,
2270
3340
  OAuthSecretClientAuth,
3341
+ OAuthTokenRequestFormat,
3342
+ OAuthTokenResponse,
2271
3343
  OAuth2Config,
2272
3344
  OAuth2AccessToken,
2273
3345
  OAuth2Method,
3346
+ AccountInfo,
3347
+ AccountCheckResult,
2274
3348
  Provider,
2275
3349
  ManyAccounts,
2276
- ToolAnnotations,
2277
- McpClientLimits,
2278
- defaultMcpClientLimits,
2279
- mcpSdkTimerCeilingMs,
2280
- McpToolsOptions,
2281
- McpToolResult,
2282
- McpToolMetadata,
2283
- McpError,
2284
- ProcessConfig,
2285
- maxFailureMessageLength,
2286
- FailureSource,
2287
- FailureName,
2288
- FailureCode,
2289
- FailureMessage,
2290
- FailureDetail,
3350
+ maxApiErrorInstructionsLength,
3351
+ ApiErrorRecovery,
3352
+ maxApiErrorMessageLength,
3353
+ ApiErrorResponse,
3354
+ OpenapiResponseError,
3355
+ defaultOpenapiErrorLimits,
2291
3356
  WorkflowRunId,
2292
3357
  WorkflowName,
2293
3358
  workflowDurationMillis,
@@ -2306,6 +3371,10 @@ export {
2306
3371
  WorkflowRpcCommand,
2307
3372
  WorkflowRpcResult,
2308
3373
  WorkflowControlCommand,
3374
+ DatabaseLimitExceeded,
3375
+ DatabaseFieldReserved,
3376
+ reservedTablePrefix,
3377
+ migrationsDirectory,
2309
3378
  ElicitationLimits,
2310
3379
  defaultElicitationLimits,
2311
3380
  FormElicitation,
@@ -2315,6 +3384,23 @@ export {
2315
3384
  ApprovalElicitation,
2316
3385
  ApprovalResponse,
2317
3386
  approvalElicitation,
3387
+ reservedRouterKeys,
3388
+ RouterKey,
3389
+ RouterIcon,
3390
+ RouterMeta,
3391
+ ToolAnnotations2 as ToolAnnotations,
3392
+ McpClientLimits,
3393
+ defaultMcpClientLimits,
3394
+ mcpSdkTimerCeilingMs,
3395
+ McpToolsOptions,
3396
+ McpHealthInput,
3397
+ mcpHealthReserveMs,
3398
+ McpToolResult,
3399
+ McpToolMetadata,
3400
+ McpServerHeader,
3401
+ McpError2 as McpError,
3402
+ McpCredentialsUnverified,
3403
+ ProcessConfig,
2318
3404
  WebhookTransportLimits,
2319
3405
  defaultWebhookTransportLimits,
2320
3406
  WebhookRequestData,
@@ -2323,22 +3409,22 @@ export {
2323
3409
  ManualWebhookDescriptor,
2324
3410
  HostedWebhook,
2325
3411
  WebhookCommand,
3412
+ EventName,
3413
+ EventFilterValue,
3414
+ EventLimits,
3415
+ defaultEventLimits,
3416
+ DeclaredEvent,
3417
+ DeclaredEvents,
3418
+ EmittedEvent,
3419
+ EmittedEvents,
2326
3420
  frameworkProtocol,
2327
3421
  minimumIntervalMilliseconds,
2328
3422
  Interval,
2329
3423
  CalendarSchedule,
2330
3424
  ScheduleTiming,
2331
3425
  OperationSchedule,
2332
- DeclaredAuthMethod,
2333
- DeclaredProvider,
2334
- DeclaredRequirements,
2335
- ResolvedAccount,
2336
- ResolvedAccounts,
2337
3426
  TrustedToolApproval,
2338
3427
  InvocationDeadline,
2339
- HostedTool,
2340
- HostedToolSummary,
2341
- HostRequest,
2342
3428
  HostRequestInvalid,
2343
3429
  HostAccountsInvalid,
2344
3430
  HostOperationNotFound,
@@ -2350,18 +3436,44 @@ export {
2350
3436
  HostToolApprovalRequired,
2351
3437
  HostToolPolicyFailed,
2352
3438
  HostOutputInvalid,
2353
- HostInvocation,
2354
3439
  protocol1,
2355
3440
  SkillSources2 as SkillSources,
2356
3441
  SkillCatalogResponse2 as SkillCatalogResponse,
2357
3442
  protocol2,
2358
- HostDeclarationInvalid2 as HostDeclarationInvalid,
2359
- HostEvaluationFailed2 as HostEvaluationFailed,
2360
- HostOperationFailed2 as HostOperationFailed,
2361
- HostError2 as HostError,
2362
- HostResponse2 as HostResponse,
2363
3443
  protocol3,
2364
- OperationToolPrefixes,
3444
+ HostedTool2 as HostedTool,
3445
+ HostedToolSummary2 as HostedToolSummary,
3446
+ HostKindMismatch,
3447
+ protocol4,
3448
+ AccountCheckCommand,
3449
+ protocol5,
3450
+ protocol6,
3451
+ CredentialHost,
3452
+ DeclaredAuthMethod3 as DeclaredAuthMethod,
3453
+ DeclaredProvider3 as DeclaredProvider,
3454
+ ResolvedAccount3 as ResolvedAccount,
3455
+ ResolvedAccounts3 as ResolvedAccounts,
3456
+ protocol7,
3457
+ HostDeclarationInvalid3 as HostDeclarationInvalid,
3458
+ HostEvaluationFailed3 as HostEvaluationFailed,
3459
+ HostOperationFailed3 as HostOperationFailed,
3460
+ protocol8,
3461
+ McpError5 as McpError2,
3462
+ SkillLoadFailed2 as SkillLoadFailed,
3463
+ HostRouterError3 as HostRouterError,
3464
+ HostedRouter3 as HostedRouter,
3465
+ HostedCatalog3 as HostedCatalog,
3466
+ HostedCatalogSummary3 as HostedCatalogSummary,
3467
+ HostError5 as HostError,
3468
+ protocol9,
3469
+ MigrateCommand,
3470
+ MigrateResult,
3471
+ HostRequest4 as HostRequest,
3472
+ HostInvocation6 as HostInvocation,
3473
+ protocol10,
3474
+ DeclaredRequirements6 as DeclaredRequirements,
3475
+ HostResponse6 as HostResponse,
3476
+ protocol11,
2365
3477
  skillsCommand,
2366
3478
  skillCatalog,
2367
3479
  inspectCommand,
@@ -2370,6 +3482,9 @@ export {
2370
3482
  HostRequirementsError,
2371
3483
  HostInspectError,
2372
3484
  HostCallError,
3485
+ HostAccountCheckError,
2373
3486
  HostDataError,
2374
- ToolResultObservation
3487
+ ToolResultObservation,
3488
+ InvocationTiming,
3489
+ InvocationTimingSink
2375
3490
  };