apps 0.0.1-beta.8 → 0.0.1-beta.81

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 (180) hide show
  1. package/README.md +25 -22
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-72JNVHPK.js → chunk-4NFSABEA.js} +4 -3
  4. package/js/chunk-5FHWNLCI.js +88 -0
  5. package/js/chunk-5WGONRKQ.js +426 -0
  6. package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
  7. package/js/chunk-CDXQDN7W.js +92 -0
  8. package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
  9. package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
  10. package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
  11. package/js/{chunk-FL2QR3XW.js → chunk-HJG4RBYM.js} +333 -69
  12. package/js/chunk-I6Q7ZPKJ.js +49 -0
  13. package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
  14. package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
  15. package/js/{chunk-5T57N25Q.js → chunk-KGCTYL2S.js} +511 -63
  16. package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
  17. package/js/{chunk-WLE7WX2U.js → chunk-NG56RPCA.js} +2348 -472
  18. package/js/chunk-OD3KFKZD.js +1617 -0
  19. package/js/{chunk-Z5M2LQOZ.js → chunk-OY47QPQY.js} +67 -55
  20. package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
  21. package/js/chunk-PL5KOEZD.js +334 -0
  22. package/js/chunk-Q4IZAUIF.js +285 -0
  23. package/js/{chunk-RJDDBDSN.js → chunk-QWQM3CLH.js} +795 -177
  24. package/js/{chunk-RFVIONFX.js → chunk-TE25A7D6.js} +123 -44
  25. package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
  26. package/js/chunk-W6XCQAXP.js +171 -0
  27. package/js/chunk-WCGAO3X5.js +348 -0
  28. package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
  29. package/js/{chunk-CMYUWAX7.js → chunk-YQUG4CES.js} +126 -31
  30. package/js/{chunk-UESPOTUI.js → chunk-Z2SWTZCF.js} +861 -231
  31. package/js/client.js +142 -94
  32. package/js/contracts.js +127 -26
  33. package/js/effect.js +19 -19
  34. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  35. package/js/graphql.js +50 -40
  36. package/js/host.js +83 -58
  37. package/js/index.js +131 -46
  38. package/js/mcp/effect.js +23 -21
  39. package/js/mcp/stdio.js +44 -34
  40. package/js/mcp.js +76 -53
  41. package/js/openapi.js +4071 -1357
  42. package/js/react.js +2 -3
  43. package/js/skills/effect.js +6 -3
  44. package/js/skills.js +208 -81
  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 +8604 -223
  50. package/package.json +3 -4
  51. package/runtime.json +1 -1
  52. package/types/app-cache/src/contracts/cache.d.ts +18 -0
  53. package/types/app-cache/src/index.d.ts +34 -2
  54. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  55. package/types/apps/src/contracts/app.d.ts +7 -3
  56. package/types/apps/src/contracts/cache.d.ts +20 -0
  57. package/types/apps/src/contracts/context.d.ts +19 -11
  58. package/types/apps/src/contracts/elicitation.d.ts +23 -7
  59. package/types/apps/src/contracts/events.d.ts +93 -0
  60. package/types/apps/src/contracts/failure.d.ts +30 -1
  61. package/types/apps/src/contracts/graphql.d.ts +2 -1
  62. package/types/apps/src/contracts/host.d.ts +649 -17
  63. package/types/apps/src/contracts/live.d.ts +2 -0
  64. package/types/apps/src/contracts/mcp.d.ts +80 -10
  65. package/types/apps/src/contracts/network.d.ts +120 -0
  66. package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
  67. package/types/apps/src/contracts/openapi.d.ts +41 -9
  68. package/types/apps/src/contracts/operations.d.ts +8 -4
  69. package/types/apps/src/contracts/placement.d.ts +102 -0
  70. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  71. package/types/apps/src/contracts/protocols/1.d.ts +733 -81
  72. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  73. package/types/apps/src/contracts/protocols/2.d.ts +69 -26
  74. package/types/apps/src/contracts/protocols/3.d.ts +133 -33
  75. package/types/apps/src/contracts/protocols/4.d.ts +122 -45
  76. package/types/apps/src/contracts/protocols/5.d.ts +157 -47
  77. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  78. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  79. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  80. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  81. package/types/apps/src/contracts/protocols/current.d.ts +3843 -0
  82. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  83. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  84. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  85. package/types/apps/src/contracts/provider.d.ts +90 -6
  86. package/types/apps/src/contracts/skills.d.ts +50 -13
  87. package/types/apps/src/contracts/sql.d.ts +63 -0
  88. package/types/apps/src/contracts/ui.d.ts +37 -3
  89. package/types/apps/src/contracts/workflows.d.ts +6 -0
  90. package/types/apps/src/facet.d.ts +4 -5
  91. package/types/apps/src/host.d.ts +5 -0
  92. package/types/apps/src/implementation/account-router.d.ts +4 -3
  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 +28 -1
  96. package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
  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 +3 -3
  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 +18 -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 +6 -4
  107. package/types/apps/src/implementation/mcp-client.d.ts +17 -9
  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 +20 -9
  111. package/types/apps/src/implementation/network.d.ts +16 -0
  112. package/types/apps/src/implementation/openapi-compile.d.ts +26 -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 +18 -0
  117. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  118. package/types/apps/src/implementation/operations.d.ts +17 -2
  119. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  120. package/types/apps/src/implementation/placement.d.ts +60 -0
  121. package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
  122. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  123. package/types/apps/src/implementation/provider.d.ts +18 -3
  124. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  125. package/types/apps/src/implementation/router-catalog.d.ts +11 -13
  126. package/types/apps/src/implementation/router.d.ts +16 -5
  127. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  128. package/types/apps/src/implementation/schema.d.ts +90 -10
  129. package/types/apps/src/implementation/skills.d.ts +18 -24
  130. package/types/apps/src/implementation/sql.d.ts +71 -0
  131. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  132. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  133. package/types/apps/src/implementation/ui-client.d.ts +2 -2
  134. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  135. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  136. package/types/apps/src/implementation/ui-serving.d.ts +28 -9
  137. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  138. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  139. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  140. package/types/apps/src/implementation/workflows.d.ts +1 -1
  141. package/types/apps/src/index.d.ts +55 -13
  142. package/types/apps/src/mcp.d.ts +20 -1
  143. package/types/apps/src/openapi.d.ts +1 -1
  144. package/types/apps/src/react.d.ts +1 -1
  145. package/types/apps/src/skills.d.ts +10 -8
  146. package/types/apps/src/ui-serving.d.ts +1 -1
  147. package/types/telemetry/src/app-records.d.ts +42 -0
  148. package/types/telemetry/src/browser-operations.d.ts +2 -2
  149. package/types/telemetry/src/browser.d.ts +8 -3
  150. package/types/telemetry/src/config.d.ts +2 -2
  151. package/types/telemetry/src/index.d.ts +2 -1
  152. package/types/telemetry/src/layer.d.ts +10 -4
  153. package/types/telemetry/src/measurements.d.ts +1 -1
  154. package/types/telemetry/src/ownership.d.ts +60 -0
  155. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  156. package/types/telemetry/src/relay.d.ts +16 -6
  157. package/types/telemetry/src/span-attributes.d.ts +17 -1
  158. package/types/telemetry/src/transport.d.ts +8 -1
  159. package/types/utils/src/api-error.d.ts +55 -0
  160. package/types/utils/src/connection-failure.d.ts +33 -0
  161. package/types/utils/src/recorded-message.d.ts +18 -0
  162. package/types/utils/src/user-facing-error.d.ts +83 -0
  163. package/js/chunk-MKWZPDR6.js +0 -63
  164. package/js/chunk-N7YDVXYJ.js +0 -186
  165. package/js/chunk-NKLWZJLE.js +0 -172
  166. package/js/chunk-OCYUEU47.js +0 -224
  167. package/js/chunk-PJJ24GU7.js +0 -877
  168. package/js/chunk-PZB6T6KU.js +0 -19
  169. package/js/chunk-R3EV5FTO.js +0 -97
  170. package/js/chunk-YXQHV65J.js +0 -242
  171. package/js/chunk-ZQINWV4W.js +0 -630
  172. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  173. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  174. package/types/app-data/src/implementation/promise.d.ts +0 -68
  175. package/types/app-data/src/implementation/range.d.ts +0 -8
  176. package/types/app-data/src/implementation/schema.d.ts +0 -18
  177. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  178. package/types/app-data/src/index.d.ts +0 -4
  179. package/types/apps/src/contracts/storage.d.ts +0 -68
  180. package/types/apps/src/implementation/storage.d.ts +0 -15
@@ -1,27 +1,29 @@
1
- import {
2
- DatabaseFieldReserved,
3
- DatabaseLimitExceeded,
4
- DatabaseSchema
5
- } from "./chunk-N7YDVXYJ.js";
6
1
  import {
7
2
  CacheCommand,
8
3
  CacheReply,
9
- ProviderError
10
- } from "./chunk-R3EV5FTO.js";
4
+ FailureDetail,
5
+ FailureMessage,
6
+ FailureName,
7
+ ProviderError,
8
+ UpstreamError
9
+ } from "./chunk-Q4IZAUIF.js";
11
10
  import {
12
11
  AppSkillName,
13
- AppSkills,
14
- SkillLoadFailed
15
- } from "./chunk-JU7VHODU.js";
12
+ AppSkills
13
+ } from "./chunk-H72MEDMN.js";
14
+ import {
15
+ RecordedMessage
16
+ } from "./chunk-5FHWNLCI.js";
16
17
  import {
17
18
  AccountId,
18
19
  HttpUrl,
19
20
  JsonObject as JsonObject2,
20
21
  JsonValue
21
- } from "./chunk-27F7W2LG.js";
22
+ } from "./chunk-H2CJWXA3.js";
22
23
  import {
23
24
  Any,
24
25
  ArraySchema,
26
+ Base64_exports,
25
27
  Boolean,
26
28
  Class2 as Class,
27
29
  Context_exports,
@@ -54,13 +56,13 @@ import {
54
56
  declare,
55
57
  decode,
56
58
  decodeTo,
57
- empty2 as empty,
59
+ empty,
58
60
  flatMap,
59
61
  fromUndefinedOr,
60
62
  isBetween,
61
63
  isSchema,
62
64
  isStream,
63
- make6 as make,
65
+ make2 as make,
64
66
  merge,
65
67
  optional,
66
68
  optionalKey,
@@ -69,127 +71,23 @@ import {
69
71
  symbol3 as symbol,
70
72
  sync2 as sync,
71
73
  tag,
74
+ toType,
72
75
  transformOptional,
73
76
  withConstructorDefault,
74
77
  withDefault
75
- } from "./chunk-CDL5PM2Q.js";
76
-
77
- // src/contracts/router.ts
78
- var reservedRouterKeys = /* @__PURE__ */ new Set([
79
- "__proto__",
80
- "constructor",
81
- "prototype"
82
- ]);
83
- var RouterKey = Schema_exports.String.check(
84
- Schema_exports.isPattern(/^[A-Za-z_][A-Za-z0-9_-]{0,99}$/),
85
- Schema_exports.makeFilter((key) => !reservedRouterKeys.has(key))
86
- );
87
- var RouterIcon = Schema_exports.Struct({
88
- src: Schema_exports.NonEmptyString,
89
- mimeType: Schema_exports.optionalKey(Schema_exports.String),
90
- sizes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String)),
91
- theme: Schema_exports.optionalKey(Schema_exports.Literals(["light", "dark"]))
92
- });
93
- var RouterMeta = Schema_exports.Struct({
94
- title: Schema_exports.optionalKey(Schema_exports.String),
95
- description: Schema_exports.optionalKey(Schema_exports.String),
96
- instructions: Schema_exports.optionalKey(Schema_exports.String),
97
- icons: Schema_exports.optionalKey(Schema_exports.Array(RouterIcon)),
98
- tags: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.NonEmptyString, Schema_exports.String))
99
- });
100
-
101
- // src/contracts/tools.ts
102
- var ToolAnnotations = Schema_exports.Struct({
103
- title: Schema_exports.optionalKey(Schema_exports.String),
104
- readOnlyHint: Schema_exports.optionalKey(Schema_exports.Boolean),
105
- destructiveHint: Schema_exports.optionalKey(Schema_exports.Boolean),
106
- idempotentHint: Schema_exports.optionalKey(Schema_exports.Boolean),
107
- openWorldHint: Schema_exports.optionalKey(Schema_exports.Boolean)
108
- });
109
-
110
- // src/contracts/mcp.ts
111
- var McpClientLimits = Schema_exports.Struct({
112
- timeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
113
- maxTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
114
- maxTools: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
115
- maxPaginationCursors: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
116
- cleanupTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
117
- });
118
- var defaultMcpClientLimits = McpClientLimits.make({
119
- timeoutMs: 3e4,
120
- maxTimeoutMs: 3e5,
121
- maxTools: 5e4,
122
- maxPaginationCursors: 1e3,
123
- cleanupTimeoutMs: 1e3
124
- });
125
- var mcpSdkTimerCeilingMs = 2147483647;
126
- var McpToolsOptions = Schema_exports.Struct({
127
- url: HttpUrl,
128
- accountId: Schema_exports.optional(AccountId),
129
- headers: Schema_exports.optional(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
130
- signal: Schema_exports.optional(Schema_exports.instanceOf(AbortSignal)),
131
- timeoutMs: Schema_exports.optional(
132
- Schema_exports.Number.check(
133
- Schema_exports.isInt(),
134
- Schema_exports.isBetween({ minimum: 1, maximum: defaultMcpClientLimits.maxTimeoutMs })
135
- )
136
- )
137
- });
138
- var McpToolResult = Schema_exports.Struct({
139
- content: Schema_exports.Array(JsonObject2),
140
- structuredContent: Schema_exports.optional(JsonObject2),
141
- isError: Schema_exports.optional(Schema_exports.Boolean),
142
- _meta: Schema_exports.optional(JsonObject2)
143
- });
144
- var McpToolMetadata = Schema_exports.Struct({
145
- name: Schema_exports.String,
146
- title: Schema_exports.optional(Schema_exports.String),
147
- description: Schema_exports.optional(Schema_exports.String),
148
- inputSchema: JsonObject2,
149
- outputSchema: Schema_exports.optional(JsonObject2),
150
- annotations: Schema_exports.optional(ToolAnnotations),
151
- _meta: Schema_exports.optional(JsonObject2)
152
- });
153
- var McpServerHeader = Schema_exports.Struct({
154
- name: Schema_exports.optionalKey(Schema_exports.String),
155
- title: Schema_exports.optionalKey(Schema_exports.String),
156
- version: Schema_exports.optionalKey(Schema_exports.String),
157
- description: Schema_exports.optionalKey(Schema_exports.String),
158
- websiteUrl: Schema_exports.optionalKey(Schema_exports.String),
159
- icons: Schema_exports.optionalKey(Schema_exports.Array(RouterIcon)),
160
- instructions: Schema_exports.optionalKey(Schema_exports.String)
161
- });
162
- var McpError = class extends Schema_exports.TaggedError()("McpError", {
163
- phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
164
- reason: Schema_exports.Literals([
165
- "request",
166
- "unauthorized",
167
- "invalid_response",
168
- "timeout",
169
- "invalid_input"
170
- ]),
171
- status: Schema_exports.optional(Schema_exports.Number)
172
- }) {
173
- };
174
- var ProcessConfig = Schema_exports.Struct({
175
- command: Schema_exports.NonEmptyString,
176
- args: Schema_exports.Array(Schema_exports.String),
177
- cwd: Schema_exports.optional(Schema_exports.String),
178
- env: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
179
- timeoutMs: Schema_exports.Int.check(
180
- Schema_exports.isBetween({ minimum: 1, maximum: defaultMcpClientLimits.maxTimeoutMs })
181
- )
182
- });
78
+ } from "./chunk-IFJU5SYQ.js";
183
79
 
184
80
  // src/contracts/api-response-error.ts
81
+ var maxApiErrorInstructionsLength = 4096;
185
82
  var ApiErrorRecovery = Schema_exports.Struct({
186
83
  action: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(1024)),
187
- instructions: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(4096))
84
+ instructions: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(maxApiErrorInstructionsLength))
188
85
  });
86
+ var maxApiErrorMessageLength = 4096;
189
87
  var ApiErrorResponse = Schema_exports.Struct({
190
88
  code: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(128)),
191
89
  status: Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 400, maximum: 599 })),
192
- message: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(4096)),
90
+ message: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(maxApiErrorMessageLength)),
193
91
  recovery: Schema_exports.optionalKey(ApiErrorRecovery)
194
92
  });
195
93
  var OpenapiResponseError = class extends Schema_exports.TaggedError()(
@@ -206,19 +104,6 @@ var defaultOpenapiErrorLimits = OpenapiErrorLimits.make({
206
104
  readTimeoutMs: 2e3
207
105
  });
208
106
 
209
- // src/contracts/failure.ts
210
- var maxFailureMessageLength = 2048;
211
- var FailureSource = Schema_exports.Literals(["app", "storage", "service"]);
212
- var FailureName = Schema_exports.String.check(Schema_exports.isMaxLength(128));
213
- var FailureCode = Schema_exports.String.check(Schema_exports.isMaxLength(128));
214
- var FailureMessage = Schema_exports.String.check(Schema_exports.isMaxLength(maxFailureMessageLength));
215
- var FailureDetail = {
216
- source: Schema_exports.optionalKey(FailureSource),
217
- errorName: Schema_exports.optionalKey(FailureName),
218
- code: Schema_exports.optionalKey(FailureCode),
219
- message: Schema_exports.optionalKey(FailureMessage)
220
- };
221
-
222
107
  // src/contracts/workflows.ts
223
108
  var WorkflowRunId = Schema_exports.NonEmptyString.pipe(Schema_exports.brand("wfr"));
224
109
  var WorkflowName = Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(200));
@@ -283,6 +168,13 @@ var WorkflowFailure = class extends Schema_exports.TaggedError()("WorkflowFailur
283
168
  ]),
284
169
  retryable: Schema_exports.Boolean
285
170
  }) {
171
+ /**
172
+ * The step name and error detail are the app's. Its run's owner reads them; telemetry records
173
+ * only the reason, however the failure was built or decoded.
174
+ */
175
+ get [RecordedMessage]() {
176
+ 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`;
177
+ }
286
178
  };
287
179
  var NonRetryableError = class extends Error {
288
180
  name = "NonRetryableError";
@@ -389,7 +281,179 @@ var WorkflowControlCommand = Schema_exports.Union([
389
281
  Schema_exports.Struct({ operation: Schema_exports.Literal("terminate"), run: WorkflowRunId })
390
282
  ]);
391
283
 
392
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/rpc/RpcSchema.js
284
+ // ../app-data/src/contracts/database.ts
285
+ var DataName = Schema_exports.String.check(
286
+ Schema_exports.makeFilter((value) => /^[A-Za-z][A-Za-z0-9_]*$/.test(value) && value.length <= 128)
287
+ );
288
+ var Scalar = Schema_exports.Union([Schema_exports.String, Schema_exports.Finite, Schema_exports.Boolean]);
289
+ var Field = Schema_exports.Struct({
290
+ kind: Schema_exports.Literals(["string", "number", "boolean", "id", "userId"]),
291
+ optional: Schema_exports.optional(Schema_exports.Boolean),
292
+ default: Schema_exports.optional(Scalar),
293
+ references: Schema_exports.optional(DataName)
294
+ });
295
+ var Index = Schema_exports.Struct({ name: DataName, fields: Schema_exports.NonEmptyArray(DataName) });
296
+ var Table = Schema_exports.Struct({
297
+ fields: Schema_exports.Record(DataName, Field),
298
+ indexes: Schema_exports.Array(Index)
299
+ });
300
+ var DatabaseSchema = Schema_exports.Record(DataName, Table);
301
+ var Row = Schema_exports.Record(Schema_exports.String, Scalar);
302
+ var RowMetadata = Schema_exports.Struct({
303
+ id: Schema_exports.NonEmptyString,
304
+ createdAt: Schema_exports.String,
305
+ updatedAt: Schema_exports.String
306
+ });
307
+ var Patch = Schema_exports.Record(DataName, Schema_exports.NullOr(Scalar));
308
+ var RangeClause = Schema_exports.Struct({
309
+ field: DataName,
310
+ op: Schema_exports.Literals(["eq", "gt", "gte", "lt", "lte"]),
311
+ value: Schema_exports.NullOr(Scalar)
312
+ });
313
+ var QueryPlan = Schema_exports.Struct({
314
+ table: DataName,
315
+ index: DataName,
316
+ order: Schema_exports.Literals(["asc", "desc"]),
317
+ clauses: Schema_exports.Array(RangeClause)
318
+ });
319
+ var QueryTerminal = Schema_exports.Union([
320
+ Schema_exports.Struct({ kind: Schema_exports.Literal("collect") }),
321
+ Schema_exports.Struct({ kind: Schema_exports.Literal("count") }),
322
+ Schema_exports.Struct({ kind: Schema_exports.Literal("first") }),
323
+ Schema_exports.Struct({
324
+ kind: Schema_exports.Literal("take"),
325
+ count: Schema_exports.Int.check(Schema_exports.isGreaterThanOrEqualTo(0))
326
+ }),
327
+ Schema_exports.Struct({
328
+ kind: Schema_exports.Literal("paginate"),
329
+ cursor: Schema_exports.NullOr(Schema_exports.String),
330
+ numItems: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
331
+ })
332
+ ]);
333
+ var DatabaseOperation = Schema_exports.Union([
334
+ Schema_exports.Struct({ kind: Schema_exports.Literal("get"), table: DataName, id: Schema_exports.NonEmptyString }),
335
+ Schema_exports.Struct({ kind: Schema_exports.Literal("insert"), table: DataName, value: Patch }),
336
+ Schema_exports.Struct({
337
+ kind: Schema_exports.Literal("update"),
338
+ table: DataName,
339
+ id: Schema_exports.NonEmptyString,
340
+ patch: Patch
341
+ }),
342
+ Schema_exports.Struct({ kind: Schema_exports.Literal("delete"), table: DataName, id: Schema_exports.NonEmptyString }),
343
+ Schema_exports.Struct({ kind: Schema_exports.Literal("query"), plan: QueryPlan, terminal: QueryTerminal })
344
+ ]);
345
+ var PaginationResult = Schema_exports.Struct({
346
+ page: Schema_exports.Array(Row),
347
+ continueCursor: Schema_exports.NullOr(Schema_exports.String),
348
+ isDone: Schema_exports.Boolean
349
+ });
350
+ var OperationResult = Schema_exports.Union([
351
+ Row,
352
+ Schema_exports.Array(Row),
353
+ PaginationResult,
354
+ Schema_exports.Boolean,
355
+ Schema_exports.Finite,
356
+ Schema_exports.Null
357
+ ]);
358
+ var AppDatabaseError = class extends Schema_exports.TaggedError()("AppDatabaseError", {
359
+ reason: Schema_exports.Literals([
360
+ "schema",
361
+ "schema_changed",
362
+ "table",
363
+ "index",
364
+ "range",
365
+ "value",
366
+ "readonly",
367
+ "cursor",
368
+ "limit",
369
+ "closed",
370
+ "storage",
371
+ "replay"
372
+ ])
373
+ }) {
374
+ };
375
+ var DatabaseLimits = Schema_exports.Struct({
376
+ rowsRead: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
377
+ rowsReturned: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
378
+ bytesRead: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
379
+ writes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
380
+ scanCalls: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
381
+ directGets: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
382
+ valueBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
383
+ indexBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
384
+ });
385
+ var defaultDatabaseLimits = {
386
+ rowsRead: 5e3,
387
+ rowsReturned: 1e3,
388
+ bytesRead: 4 * 1024 * 1024,
389
+ writes: 1e3,
390
+ scanCalls: 100,
391
+ directGets: 1e3,
392
+ valueBytes: 64 * 1024,
393
+ indexBytes: 2048
394
+ };
395
+ var DatabaseLimit = Schema_exports.Literals([
396
+ "scanCalls",
397
+ "directGets",
398
+ "rowsRead",
399
+ "rowsReturned",
400
+ "pageSize",
401
+ "bytesRead",
402
+ "writes",
403
+ "valueBytes"
404
+ ]);
405
+ var count = (value) => value.toLocaleString("en-US");
406
+ var limitMessages = {
407
+ 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.`,
408
+ 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.`,
409
+ 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.`,
410
+ 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.`,
411
+ 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.`,
412
+ 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.`,
413
+ 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.`,
414
+ 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.`
415
+ };
416
+ var DatabaseLimitExceeded = class extends Schema_exports.TaggedError()(
417
+ "DatabaseLimitExceeded",
418
+ {
419
+ limit: DatabaseLimit,
420
+ maximum: Schema_exports.Int,
421
+ requested: Schema_exports.Int
422
+ }
423
+ ) {
424
+ get message() {
425
+ return limitMessages[this.limit](this.maximum, this.requested);
426
+ }
427
+ };
428
+ var reservedFieldNames = ["id", "createdAt", "updatedAt"];
429
+ var DatabaseFieldReserved = class extends Schema_exports.TaggedError()(
430
+ "DatabaseFieldReserved",
431
+ {
432
+ table: Schema_exports.String,
433
+ field: Schema_exports.Literals(reservedFieldNames)
434
+ }
435
+ ) {
436
+ get message() {
437
+ 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}.`;
438
+ }
439
+ };
440
+ var DatabaseRuntimeLimits = Schema_exports.Struct({
441
+ maxCursorChars: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
442
+ connectionCacheCapacity: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
443
+ connectionCacheTtlMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
444
+ });
445
+ var defaultDatabaseRuntimeLimits = DatabaseRuntimeLimits.make({
446
+ maxCursorChars: 8192,
447
+ connectionCacheCapacity: 64,
448
+ connectionCacheTtlMs: 5 * 60 * 1e3
449
+ });
450
+
451
+ // src/contracts/sql.ts
452
+ var reservedTablePrefix = "_executor_";
453
+ var migrationsDirectory = "migrations";
454
+ var sqlBindingsLimit = 100;
455
+
456
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/rpc/RpcSchema.js
393
457
  var StreamSchemaTypeId = "~effect/rpc/RpcSchema/StreamSchema";
394
458
  var schema = /* @__PURE__ */ declare(isStream);
395
459
  function Stream(success, error) {
@@ -400,7 +464,7 @@ function Stream(success, error) {
400
464
  });
401
465
  }
402
466
 
403
- // ../../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
404
468
  var TypeId = "~effect/rpc/Rpc";
405
469
  var Proto = {
406
470
  [TypeId]: TypeId,
@@ -451,9 +515,9 @@ var Proto = {
451
515
  middlewares: /* @__PURE__ */ new Set([...this.middlewares, middleware])
452
516
  });
453
517
  },
454
- prefix(prefix) {
518
+ prefix(prefix2) {
455
519
  return makeProto({
456
- _tag: `${prefix}${this._tag}`,
520
+ _tag: `${prefix2}${this._tag}`,
457
521
  payloadSchema: this.payloadSchema,
458
522
  successSchema: this.successSchema,
459
523
  errorSchema: this.errorSchema,
@@ -518,7 +582,7 @@ var make2 = (tag2, options) => {
518
582
  });
519
583
  };
520
584
 
521
- // ../../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
522
586
  var optionalWithDefault = (schema2, defaultValue) => {
523
587
  const effect = sync(defaultValue);
524
588
  return optionalKey(schema2).pipe(decode({
@@ -526,7 +590,7 @@ var optionalWithDefault = (schema2, defaultValue) => {
526
590
  encode: passthrough()
527
591
  }), withConstructorDefault(effect));
528
592
  };
529
- var optional2 = (schema2) => optionalKey(schema2).pipe(decodeTo(optional(schema2), {
593
+ var optional2 = (schema2) => optionalKey(schema2).pipe(decodeTo(toType(optional(schema2)), {
530
594
  decode: passthrough(),
531
595
  encode: transformOptional(flatMap(fromUndefinedOr))
532
596
  }));
@@ -788,7 +852,7 @@ var InternalError = class _InternalError extends (/* @__PURE__ */ Error2("effect
788
852
  message: "Not implemented"
789
853
  });
790
854
  };
791
- var McpError2 = /* @__PURE__ */ Union([ParseError, InvalidRequest, MethodNotFound, InvalidParams, InternalError, McpErrorBase]);
855
+ var McpError = /* @__PURE__ */ Union([ParseError, InvalidRequest, MethodNotFound, InvalidParams, InternalError, McpErrorBase]);
792
856
  var InitializeResult = class extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
793
857
  ...ResultMeta.fields,
794
858
  /**
@@ -811,7 +875,7 @@ var InitializeResult = class extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ S
811
875
  };
812
876
  var Initialize = class extends (/* @__PURE__ */ make2("initialize", {
813
877
  success: InitializeResult,
814
- error: McpError2,
878
+ error: McpError,
815
879
  payload: {
816
880
  ...RequestMeta.fields,
817
881
  /**
@@ -1010,7 +1074,7 @@ var ReadResourceResult = class extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */
1010
1074
  };
1011
1075
  var ReadResource = class extends (/* @__PURE__ */ make2("resources/read", {
1012
1076
  success: ReadResourceResult,
1013
- error: McpError2,
1077
+ error: McpError,
1014
1078
  payload: {
1015
1079
  ...RequestMeta.fields,
1016
1080
  /**
@@ -1023,7 +1087,7 @@ var ReadResource = class extends (/* @__PURE__ */ make2("resources/read", {
1023
1087
  };
1024
1088
  var Subscribe = class extends (/* @__PURE__ */ make2("resources/subscribe", {
1025
1089
  success: /* @__PURE__ */ Struct({}),
1026
- error: McpError2,
1090
+ error: McpError,
1027
1091
  payload: {
1028
1092
  ...RequestMeta.fields,
1029
1093
  /**
@@ -1036,7 +1100,7 @@ var Subscribe = class extends (/* @__PURE__ */ make2("resources/subscribe", {
1036
1100
  };
1037
1101
  var Unsubscribe = class extends (/* @__PURE__ */ make2("resources/unsubscribe", {
1038
1102
  success: /* @__PURE__ */ Struct({}),
1039
- error: McpError2,
1103
+ error: McpError,
1040
1104
  payload: {
1041
1105
  ...RequestMeta.fields,
1042
1106
  /**
@@ -1180,7 +1244,7 @@ var GetPromptResult = class extends (/* @__PURE__ */ Class("@effect/ai/McpSchema
1180
1244
  };
1181
1245
  var GetPrompt = class extends (/* @__PURE__ */ make2("prompts/get", {
1182
1246
  success: GetPromptResult,
1183
- error: McpError2,
1247
+ error: McpError,
1184
1248
  payload: {
1185
1249
  ...RequestMeta.fields,
1186
1250
  /**
@@ -1195,7 +1259,7 @@ var GetPrompt = class extends (/* @__PURE__ */ make2("prompts/get", {
1195
1259
  }
1196
1260
  })) {
1197
1261
  };
1198
- var ToolAnnotations2 = class extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
1262
+ var ToolAnnotations = class extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
1199
1263
  /**
1200
1264
  * A human-readable title for the tool.
1201
1265
  */
@@ -1264,7 +1328,7 @@ var Tool = class extends (/* @__PURE__ */ Class("@effect/ai/McpSchema/Tool")({
1264
1328
  /**
1265
1329
  * Optional additional tool information.
1266
1330
  */
1267
- annotations: /* @__PURE__ */ optional2(ToolAnnotations2),
1331
+ annotations: /* @__PURE__ */ optional2(ToolAnnotations),
1268
1332
  /**
1269
1333
  * Icons that clients can display for this tool.
1270
1334
  */
@@ -1300,7 +1364,7 @@ var CallToolResult = class extends (/* @__PURE__ */ Class("@effect/ai/McpSchema/
1300
1364
  };
1301
1365
  var CallTool = class extends (/* @__PURE__ */ make2("tools/call", {
1302
1366
  success: CallToolResult,
1303
- error: McpError2,
1367
+ error: McpError,
1304
1368
  payload: {
1305
1369
  ...RequestMeta.fields,
1306
1370
  name: String,
@@ -1320,7 +1384,7 @@ var SetLevel = class extends (/* @__PURE__ */ make2("logging/setLevel", {
1320
1384
  level: LoggingLevel
1321
1385
  },
1322
1386
  success: /* @__PURE__ */ Struct({}),
1323
- error: McpError2
1387
+ error: McpError
1324
1388
  })) {
1325
1389
  };
1326
1390
  var LoggingMessageNotification = class extends (/* @__PURE__ */ make2("notifications/message", {
@@ -1466,7 +1530,7 @@ var CreateMessageResult = class extends (/* @__PURE__ */ Class("@effect/ai/McpSc
1466
1530
  };
1467
1531
  var CreateMessage = class extends (/* @__PURE__ */ make2("sampling/createMessage", {
1468
1532
  success: CreateMessageResult,
1469
- error: McpError2,
1533
+ error: McpError,
1470
1534
  payload: {
1471
1535
  messages: /* @__PURE__ */ ArraySchema(SamplingMessage),
1472
1536
  /**
@@ -1529,6 +1593,7 @@ var CompleteResult = class _CompleteResult extends (/* @__PURE__ */ Opaque()(/*
1529
1593
  /**
1530
1594
  * Empty completion result used when a completion request has no values.
1531
1595
  *
1596
+ * @stability unstable
1532
1597
  * @since 4.0.0
1533
1598
  */
1534
1599
  static empty = /* @__PURE__ */ _CompleteResult.make({
@@ -1677,7 +1742,7 @@ var ElicitDeclineResult = class extends (/* @__PURE__ */ Class("@effect/ai/McpSc
1677
1742
  var ElicitResult = /* @__PURE__ */ Union([ElicitAcceptResult, ElicitDeclineResult]);
1678
1743
  var Elicit = class extends (/* @__PURE__ */ make2("elicitation/create", {
1679
1744
  success: ElicitResult,
1680
- error: McpError2,
1745
+ error: McpError,
1681
1746
  payload: ElicitRequestParams
1682
1747
  })) {
1683
1748
  };
@@ -1734,45 +1799,245 @@ var ApprovalResponse = ElicitationResponse.check(
1734
1799
  (response) => response.action !== "accept" || response.content === void 0 || Object.keys(response.content).length === 0
1735
1800
  )
1736
1801
  );
1737
- var approvalElicitation = (toolName, input) => ({
1802
+ var approvalPreviewChars = 4e3;
1803
+ var shortestKept = 32;
1804
+ var isHigh = (unit) => unit >= 55296 && unit <= 56319;
1805
+ var isLow = (unit) => unit >= 56320 && unit <= 57343;
1806
+ var prefix = (text, length) => text.slice(0, isHigh(text.charCodeAt(length - 1)) ? length - 1 : length);
1807
+ var isArray = (value) => Array.isArray(value);
1808
+ var characters = (text) => {
1809
+ let pairs = 0;
1810
+ for (let index = 1; index < text.length; index += 1)
1811
+ if (isLow(text.charCodeAt(index)) && isHigh(text.charCodeAt(index - 1))) pairs += 1;
1812
+ return text.length - pairs;
1813
+ };
1814
+ var emit = (output, text) => {
1815
+ output.parts.push(text);
1816
+ output.room -= text.length;
1817
+ };
1818
+ var write = (value, keep, indent, output) => {
1819
+ if (typeof value === "string") {
1820
+ if (value.length > keep)
1821
+ emit(output, `${JSON.stringify(prefix(value, keep))}\u2026 (${characters(value)} characters)`);
1822
+ else
1823
+ emit(
1824
+ output,
1825
+ JSON.stringify(value.length > output.room ? prefix(value, output.room + 1) : value)
1826
+ );
1827
+ return;
1828
+ }
1829
+ if (typeof value !== "object" || value === null) return emit(output, JSON.stringify(value));
1830
+ const inner = `${indent} `;
1831
+ const member = (index, key, entry) => {
1832
+ emit(
1833
+ output,
1834
+ `${index === 0 ? "" : ","}
1835
+ ${inner}${key === void 0 ? "" : `${JSON.stringify(key)}: `}`
1836
+ );
1837
+ if (output.room >= 0) write(entry, keep, inner, output);
1838
+ return output.room >= 0;
1839
+ };
1840
+ if (isArray(value)) {
1841
+ if (value.length === 0) return emit(output, "[]");
1842
+ emit(output, "[");
1843
+ value.every((entry, index) => member(index, void 0, entry));
1844
+ return emit(output, `
1845
+ ${indent}]`);
1846
+ }
1847
+ const entries = Object.entries(value);
1848
+ if (entries.length === 0) return emit(output, "{}");
1849
+ emit(output, "{");
1850
+ entries.every(([key, entry], index) => member(index, key, entry));
1851
+ emit(output, `
1852
+ ${indent}}`);
1853
+ };
1854
+ var printed = (value, keep, room) => {
1855
+ const output = { parts: [], room };
1856
+ write(value, keep, "", output);
1857
+ return { text: output.parts.join(""), fits: output.room >= 0 };
1858
+ };
1859
+ var shortened = (input) => {
1860
+ let keep = approvalPreviewChars / 2;
1861
+ let shown = printed(input, keep, approvalPreviewChars);
1862
+ while (!shown.fits && keep > shortestKept) {
1863
+ keep = Math.max(shortestKept, Math.floor(keep / 2));
1864
+ shown = printed(input, keep, approvalPreviewChars);
1865
+ }
1866
+ return shown.fits ? shown.text : `${prefix(shown.text, approvalPreviewChars)}
1867
+ \u2026 (the rest is not shown)`;
1868
+ };
1869
+ var consent = (toolName, shown) => ({
1738
1870
  mode: "form",
1739
1871
  message: `Approve ${toolName}?
1740
1872
 
1741
- Arguments:
1742
- ${JSON.stringify(input, null, 2)}`,
1873
+ ${shown}`,
1743
1874
  requestedSchema: { type: "object", properties: {} }
1744
1875
  });
1876
+ var exactApprovalElicitation = (toolName, input, maxChars) => {
1877
+ const exact = printed(input, Number.POSITIVE_INFINITY, maxChars);
1878
+ return exact.fits ? consent(toolName, `Arguments:
1879
+ ${exact.text}`) : void 0;
1880
+ };
1881
+ var approvalElicitation = (toolName, input) => {
1882
+ const exact = exactApprovalElicitation(toolName, input, approvalPreviewChars);
1883
+ if (exact !== void 0) return exact;
1884
+ return consent(
1885
+ toolName,
1886
+ `Arguments, shortened for review. Approving runs the call with the complete arguments:
1887
+ ${shortened(input)}`
1888
+ );
1889
+ };
1745
1890
 
1746
- // src/contracts/webhook-protocol.ts
1747
- var WebhookTransportLimits = Schema_exports.Struct({
1748
- maxBodyBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
1891
+ // src/contracts/router.ts
1892
+ var reservedRouterKeys = /* @__PURE__ */ new Set([
1893
+ "__proto__",
1894
+ "constructor",
1895
+ "prototype"
1896
+ ]);
1897
+ var RouterKey = Schema_exports.String.check(
1898
+ Schema_exports.isPattern(/^[A-Za-z_][A-Za-z0-9_-]{0,99}$/u),
1899
+ Schema_exports.makeFilter((key) => !reservedRouterKeys.has(key))
1900
+ );
1901
+ var RouterIcon = Schema_exports.Struct({
1902
+ src: Schema_exports.NonEmptyString,
1903
+ mimeType: Schema_exports.optionalKey(Schema_exports.String),
1904
+ sizes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String)),
1905
+ theme: Schema_exports.optionalKey(Schema_exports.Literals(["light", "dark"]))
1749
1906
  });
1750
- var defaultWebhookTransportLimits = WebhookTransportLimits.make({
1751
- maxBodyBytes: 1024 * 1024
1907
+ var RouterMeta = Schema_exports.Struct({
1908
+ title: Schema_exports.optionalKey(Schema_exports.String),
1909
+ description: Schema_exports.optionalKey(Schema_exports.String),
1910
+ instructions: Schema_exports.optionalKey(Schema_exports.String),
1911
+ icons: Schema_exports.optionalKey(Schema_exports.Array(RouterIcon)),
1912
+ tags: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.NonEmptyString, Schema_exports.String))
1752
1913
  });
1753
- var encodedBodyChars = 4 * Math.ceil(defaultWebhookTransportLimits.maxBodyBytes / 3);
1754
- var WebhookRequestData = Schema_exports.Struct({
1914
+
1915
+ // src/contracts/tools.ts
1916
+ var ToolAnnotations2 = Schema_exports.Struct({
1917
+ title: Schema_exports.optionalKey(Schema_exports.String),
1918
+ readOnlyHint: Schema_exports.optionalKey(Schema_exports.Boolean),
1919
+ destructiveHint: Schema_exports.optionalKey(Schema_exports.Boolean),
1920
+ idempotentHint: Schema_exports.optionalKey(Schema_exports.Boolean),
1921
+ openWorldHint: Schema_exports.optionalKey(Schema_exports.Boolean)
1922
+ });
1923
+
1924
+ // src/contracts/mcp.ts
1925
+ var McpClientLimits = Schema_exports.Struct({
1926
+ timeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1927
+ maxTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1928
+ maxTools: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1929
+ maxPaginationCursors: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
1930
+ cleanupTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
1931
+ });
1932
+ var defaultMcpClientLimits = McpClientLimits.make({
1933
+ timeoutMs: 3e4,
1934
+ maxTimeoutMs: 3e5,
1935
+ maxTools: 5e4,
1936
+ maxPaginationCursors: 1e3,
1937
+ cleanupTimeoutMs: 1e3
1938
+ });
1939
+ var mcpSdkTimerCeilingMs = 2147483647;
1940
+ var McpToolsOptions = Schema_exports.Struct({
1755
1941
  url: HttpUrl,
1756
- method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]),
1757
- headers: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
1758
- body: Schema_exports.String.check(Schema_exports.isMaxLength(encodedBodyChars))
1942
+ accountId: Schema_exports.optional(AccountId),
1943
+ headers: Schema_exports.optional(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
1944
+ signal: Schema_exports.optional(Schema_exports.instanceOf(AbortSignal)),
1945
+ timeoutMs: Schema_exports.optional(
1946
+ Schema_exports.Number.check(
1947
+ Schema_exports.isInt(),
1948
+ Schema_exports.isBetween({ minimum: 1, maximum: defaultMcpClientLimits.maxTimeoutMs })
1949
+ )
1950
+ )
1759
1951
  });
1760
- var WebhookResponseData = Schema_exports.Struct({
1761
- status: Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 200, maximum: 599 })),
1952
+ var McpHealthInput = Schema_exports.Struct({
1953
+ ...McpToolsOptions.fields,
1762
1954
  headers: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
1763
- body: Schema_exports.String.check(Schema_exports.isMaxLength(encodedBodyChars))
1955
+ deadline: Schema_exports.optional(Schema_exports.Finite)
1764
1956
  });
1765
- var ManualWebhookSetup = Schema_exports.Struct({
1766
- instructions: Schema_exports.NonEmptyString,
1767
- signingSecret: Schema_exports.Literals(["executor", "provider"])
1957
+ var mcpHealthReserveMs = 2 * defaultMcpClientLimits.cleanupTimeoutMs + 250;
1958
+ var McpToolResult = Schema_exports.Struct({
1959
+ content: Schema_exports.Array(JsonObject2),
1960
+ structuredContent: Schema_exports.optionalKey(JsonObject2),
1961
+ isError: Schema_exports.optionalKey(Schema_exports.Boolean),
1962
+ _meta: Schema_exports.optionalKey(JsonObject2)
1768
1963
  });
1769
- var ManualWebhookDescriptor = Schema_exports.Struct({
1770
- ...ManualWebhookSetup.fields,
1771
- stateSchema: JsonObject2
1964
+ var McpToolMetadata = Schema_exports.Struct({
1965
+ name: Schema_exports.String,
1966
+ title: Schema_exports.optional(Schema_exports.String),
1967
+ description: Schema_exports.optional(Schema_exports.String),
1968
+ inputSchema: JsonObject2,
1969
+ outputSchema: Schema_exports.optional(JsonObject2),
1970
+ annotations: Schema_exports.optional(ToolAnnotations2),
1971
+ _meta: Schema_exports.optional(JsonObject2)
1772
1972
  });
1773
- var HostedWebhook = Schema_exports.Struct({
1774
- name: Schema_exports.NonEmptyString,
1775
- account: Schema_exports.NonEmptyString,
1973
+ var McpServerHeader = Schema_exports.Struct({
1974
+ name: Schema_exports.optionalKey(Schema_exports.String),
1975
+ title: Schema_exports.optionalKey(Schema_exports.String),
1976
+ version: Schema_exports.optionalKey(Schema_exports.String),
1977
+ description: Schema_exports.optionalKey(Schema_exports.String),
1978
+ websiteUrl: Schema_exports.optionalKey(Schema_exports.String),
1979
+ icons: Schema_exports.optionalKey(Schema_exports.Array(RouterIcon)),
1980
+ instructions: Schema_exports.optionalKey(Schema_exports.String)
1981
+ });
1982
+ var McpError2 = class extends Schema_exports.TaggedError()("McpError", {
1983
+ phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
1984
+ reason: Schema_exports.Literals([
1985
+ "request",
1986
+ "unauthorized",
1987
+ "invalid_response",
1988
+ "timeout",
1989
+ "invalid_input"
1990
+ ]),
1991
+ status: Schema_exports.optional(Schema_exports.Number),
1992
+ upstream: Schema_exports.optional(UpstreamError),
1993
+ session: Schema_exports.optional(Schema_exports.Literal(true))
1994
+ }) {
1995
+ };
1996
+ var McpCredentialsUnverified = class extends Schema_exports.TaggedError()(
1997
+ "McpCredentialsUnverified",
1998
+ { anonymous: Schema_exports.Union([Schema_exports.Literal("answered"), McpError2, ProviderError]) }
1999
+ ) {
2000
+ };
2001
+ var ProcessConfig = Schema_exports.Struct({
2002
+ command: Schema_exports.NonEmptyString,
2003
+ args: Schema_exports.Array(Schema_exports.String),
2004
+ cwd: Schema_exports.optional(Schema_exports.String),
2005
+ env: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
2006
+ timeoutMs: Schema_exports.Int.check(
2007
+ Schema_exports.isBetween({ minimum: 1, maximum: defaultMcpClientLimits.maxTimeoutMs })
2008
+ )
2009
+ });
2010
+
2011
+ // src/contracts/webhook-protocol.ts
2012
+ var WebhookTransportLimits = Schema_exports.Struct({
2013
+ maxBodyBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
2014
+ });
2015
+ var defaultWebhookTransportLimits = WebhookTransportLimits.make({
2016
+ maxBodyBytes: 1024 * 1024
2017
+ });
2018
+ var encodedBodyChars = 4 * Math.ceil(defaultWebhookTransportLimits.maxBodyBytes / 3);
2019
+ var WebhookRequestData = Schema_exports.Struct({
2020
+ url: HttpUrl,
2021
+ method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]),
2022
+ headers: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
2023
+ body: Schema_exports.String.check(Schema_exports.isMaxLength(encodedBodyChars))
2024
+ });
2025
+ var WebhookResponseData = Schema_exports.Struct({
2026
+ status: Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 200, maximum: 599 })),
2027
+ headers: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
2028
+ body: Schema_exports.String.check(Schema_exports.isMaxLength(encodedBodyChars))
2029
+ });
2030
+ var ManualWebhookSetup = Schema_exports.Struct({
2031
+ instructions: Schema_exports.NonEmptyString,
2032
+ signingSecret: Schema_exports.Literals(["executor", "provider"])
2033
+ });
2034
+ var ManualWebhookDescriptor = Schema_exports.Struct({
2035
+ ...ManualWebhookSetup.fields,
2036
+ stateSchema: JsonObject2
2037
+ });
2038
+ var HostedWebhook = Schema_exports.Struct({
2039
+ name: Schema_exports.NonEmptyString,
2040
+ account: Schema_exports.NonEmptyString,
1776
2041
  configSchema: JsonObject2,
1777
2042
  setup: Schema_exports.optionalKey(ManualWebhookDescriptor)
1778
2043
  });
@@ -1798,6 +2063,109 @@ var WebhookCommand = Schema_exports.Union([
1798
2063
  })
1799
2064
  ]);
1800
2065
 
2066
+ // src/contracts/events.ts
2067
+ var EventName = Schema_exports.String.check(
2068
+ Schema_exports.isPattern(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*$/u),
2069
+ Schema_exports.isMaxLength(64)
2070
+ );
2071
+ var EventFilterValue = Schema_exports.Union([Schema_exports.String, Schema_exports.Finite, Schema_exports.Boolean]);
2072
+ var EventLimits = Schema_exports.Struct({
2073
+ /** An occurrence's `data`, leaving room under a 256 KiB delivery for its envelope. */
2074
+ maxDataBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
2075
+ maxEventsPerInvocation: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
2076
+ maxDescriptionLength: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
2077
+ maxIdLength: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
2078
+ });
2079
+ var defaultEventLimits = EventLimits.make({
2080
+ maxDataBytes: 250 * 1024,
2081
+ maxEventsPerInvocation: 100,
2082
+ maxDescriptionLength: 1e3,
2083
+ maxIdLength: 200
2084
+ });
2085
+ var DeclaredEvent = Schema_exports.Struct({
2086
+ description: Schema_exports.String.check(
2087
+ Schema_exports.isMinLength(1),
2088
+ Schema_exports.isMaxLength(defaultEventLimits.maxDescriptionLength)
2089
+ ),
2090
+ /** An object of scalar fields. Subscribers may name any of them to narrow an event. */
2091
+ filters: JsonObject2,
2092
+ /** The shape of each occurrence's `data`. */
2093
+ payload: JsonObject2
2094
+ });
2095
+ var DeclaredEvents = Schema_exports.Record(EventName, DeclaredEvent);
2096
+ var EmittedEvent = Schema_exports.Struct({
2097
+ name: EventName,
2098
+ id: Schema_exports.String.check(
2099
+ Schema_exports.isMinLength(1),
2100
+ Schema_exports.isMaxLength(defaultEventLimits.maxIdLength)
2101
+ ),
2102
+ /** Milliseconds since the epoch when the event happened. */
2103
+ occurredAt: Schema_exports.Int.check(Schema_exports.isGreaterThanOrEqualTo(0)),
2104
+ data: JsonValue,
2105
+ filters: Schema_exports.Record(Schema_exports.String, EventFilterValue),
2106
+ account: Schema_exports.NullOr(AccountId)
2107
+ });
2108
+ var EmittedEvents = Schema_exports.Array(EmittedEvent).check(
2109
+ Schema_exports.isMaxLength(defaultEventLimits.maxEventsPerInvocation)
2110
+ );
2111
+
2112
+ // src/contracts/placement.ts
2113
+ var PlacementField = Schema_exports.Struct({ field: Schema_exports.NonEmptyString });
2114
+ var PlacementText = Schema_exports.Union([Schema_exports.String, PlacementField]);
2115
+ var PlacementBase64 = Schema_exports.Struct({
2116
+ base64: Schema_exports.Array(PlacementText).check(Schema_exports.isMinLength(1))
2117
+ });
2118
+ var PlacementPart = Schema_exports.Union([Schema_exports.String, PlacementField, PlacementBase64]);
2119
+ var template = Schema_exports.Array(PlacementPart).check(Schema_exports.isMinLength(1));
2120
+ var PlacementHeaderName = Schema_exports.String.check(
2121
+ Schema_exports.isPattern(/^[!#$%&'*+.^_`|~0-9a-z-]+$/u)
2122
+ );
2123
+ var Placement = Schema_exports.Union([
2124
+ Schema_exports.Struct({ in: Schema_exports.Literal("header"), name: PlacementHeaderName, value: template }),
2125
+ Schema_exports.Struct({ in: Schema_exports.Literal("query"), name: Schema_exports.NonEmptyString, value: template })
2126
+ ]);
2127
+ var Placements = Schema_exports.Array(Placement);
2128
+ var isPlacementField = (part) => typeof part === "object" && "field" in part;
2129
+ var placementFields = (placement) => new Set(
2130
+ placement.value.flatMap(
2131
+ (part) => typeof part === "string" ? [] : isPlacementField(part) ? [part.field] : part.base64.flatMap((text) => typeof text === "string" ? [] : [text.field])
2132
+ )
2133
+ );
2134
+ var canonical = Schema_exports.encodeSync(Schema_exports.fromJsonString(Placement));
2135
+ var placementKey = (placement) => canonical(placement);
2136
+ var normalizePlacements = (placements) => [...new Map(placements.map((placement) => [placementKey(placement), placement])).entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([, placement]) => placement);
2137
+ var PlacementFieldMissing = class extends Schema_exports.TaggedError()(
2138
+ "PlacementFieldMissing",
2139
+ { field: Schema_exports.String }
2140
+ ) {
2141
+ get message() {
2142
+ return `The credential placement references the account field "${this.field}", which has no string value.`;
2143
+ }
2144
+ };
2145
+ var renderPlacement = (placement, fields) => {
2146
+ const text = (parts) => {
2147
+ let rendered2 = "";
2148
+ for (const part of parts) {
2149
+ if (typeof part === "string") {
2150
+ rendered2 += part;
2151
+ continue;
2152
+ }
2153
+ const value = Object.hasOwn(fields, part.field) ? fields[part.field] : void 0;
2154
+ if (typeof value !== "string")
2155
+ return Result_exports.fail(new PlacementFieldMissing({ field: part.field }));
2156
+ rendered2 += value;
2157
+ }
2158
+ return Result_exports.succeed(rendered2);
2159
+ };
2160
+ let rendered = "";
2161
+ for (const part of placement.value) {
2162
+ const value = typeof part === "string" || isPlacementField(part) ? text([part]) : Result_exports.map(text(part.base64), (inner) => Base64_exports.encode(inner));
2163
+ if (Result_exports.isFailure(value)) return value;
2164
+ rendered += value.success;
2165
+ }
2166
+ return Result_exports.succeed(rendered);
2167
+ };
2168
+
1801
2169
  // src/contracts/provider.ts
1802
2170
  var SecretsMethod = class extends Data_exports.TaggedClass(
1803
2171
  "secrets"
@@ -1814,7 +2182,7 @@ var OAuthSecretClientAuth = Schema_exports.Literals([
1814
2182
  "client_secret_basic",
1815
2183
  "client_secret_basic_raw"
1816
2184
  ]);
1817
- var reservedAuthorizationParams = /* @__PURE__ */ new Set([
2185
+ var reservedAuthorizationParams = [
1818
2186
  "response_type",
1819
2187
  "client_id",
1820
2188
  "redirect_uri",
@@ -1826,17 +2194,55 @@ var reservedAuthorizationParams = /* @__PURE__ */ new Set([
1826
2194
  "resource",
1827
2195
  "request",
1828
2196
  "request_uri"
1829
- ]);
2197
+ ];
2198
+ var reserved = new Set(reservedAuthorizationParams);
1830
2199
  var OAuthAuthorizationParams = Schema_exports.Record(Schema_exports.String, Schema_exports.String).check(
1831
- Schema_exports.makeFilter(
1832
- (params) => Object.keys(params).every((key) => !reservedAuthorizationParams.has(key)),
1833
- {
1834
- message: "Authorization parameters cannot replace protocol parameters such as state or scope."
1835
- }
1836
- )
2200
+ Schema_exports.makeFilter((params) => Object.keys(params).every((key) => !reserved.has(key)), {
2201
+ message: "Authorization parameters cannot replace protocol parameters such as state or scope."
2202
+ })
1837
2203
  );
2204
+ var declaredAuthorizationQuery = Schema_exports.makeFilter(
2205
+ (config) => {
2206
+ const keys = [...new URL(config.authorizationUrl).searchParams.keys()];
2207
+ const owned = keys.filter((key) => reserved.has(key));
2208
+ if (owned.length > 0)
2209
+ return {
2210
+ path: ["authorizationUrl"],
2211
+ issue: `authorizationUrl cannot set protocol parameters: ${owned.join(", ")}.`
2212
+ };
2213
+ const repeated = keys.filter((key) => Object.hasOwn(config.authorizationParams ?? {}, key));
2214
+ if (repeated.length > 0)
2215
+ return {
2216
+ path: ["authorizationParams"],
2217
+ issue: `Declare each parameter once; authorizationUrl already sets: ${repeated.join(", ")}.`
2218
+ };
2219
+ return void 0;
2220
+ }
2221
+ );
2222
+ var OAuthTokenRequestFormat = Schema_exports.Literals(["form", "json"]);
2223
+ var OAuthTokenResponse = Schema_exports.Struct({
2224
+ path: Schema_exports.String.check(Schema_exports.isPattern(/^[^.]+(\.[^.]+)*$/))
2225
+ });
2226
+ var tokenRequestOptions = {
2227
+ /** Joins requested scopes; Linear wants `","`. Defaults to RFC 6749's space. */
2228
+ scopeSeparator: Schema_exports.optionalKey(Schema_exports.String.check(Schema_exports.isMinLength(1))),
2229
+ /** Encoding of token requests. Defaults to `"form"`; Atlassian, ClickUp and Notion need `"json"`. */
2230
+ tokenRequestFormat: Schema_exports.optionalKey(OAuthTokenRequestFormat)
2231
+ };
1838
2232
  var oauthOptions = {
2233
+ ...tokenRequestOptions,
2234
+ /**
2235
+ * Read the grant from this nested member of the token response when the top-level response has
2236
+ * no access token or no scope. Slack's user tokens use `{ path: "authed_user" }`.
2237
+ */
2238
+ tokenResponse: Schema_exports.optionalKey(OAuthTokenResponse),
1839
2239
  grant: Schema_exports.optionalKey(Schema_exports.Literal("authorization_code")),
2240
+ /**
2241
+ * Service-defined authorization request parameters, such as Google's
2242
+ * `{ access_type: "offline", prompt: "consent" }`. Host-owned protocol parameters
2243
+ * (`state`, `scope`, `redirect_uri`, PKCE and the others in `reservedAuthorizationParams`)
2244
+ * are rejected. A discovered endpoint's own query parameter of the same name is replaced.
2245
+ */
1840
2246
  authorizationParams: Schema_exports.optionalKey(OAuthAuthorizationParams),
1841
2247
  tokenEndpointAuthMethod: Schema_exports.optionalKey(OAuthClientAuth),
1842
2248
  /** Omitted uses discovery; null explicitly suppresses the resource parameter. */
@@ -1846,6 +2252,8 @@ var OAuth2Config = Schema_exports.Union([
1846
2252
  Schema_exports.Struct({
1847
2253
  ...oauthOptions,
1848
2254
  discover: HttpUrl,
2255
+ /** Fetch this exact metadata document and verify its issuer against discovery. */
2256
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(HttpUrl),
1849
2257
  authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
1850
2258
  tokenUrl: Schema_exports.optionalKey(Schema_exports.Never),
1851
2259
  revocationUrl: Schema_exports.optionalKey(Schema_exports.Never),
@@ -1853,21 +2261,26 @@ var OAuth2Config = Schema_exports.Union([
1853
2261
  }),
1854
2262
  Schema_exports.Struct({
1855
2263
  ...oauthOptions,
2264
+ /** Its query is kept; it cannot set protocol parameters or repeat `authorizationParams`. */
1856
2265
  authorizationUrl: HttpUrl,
1857
2266
  tokenUrl: HttpUrl,
1858
2267
  revocationUrl: Schema_exports.optionalKey(HttpUrl),
1859
2268
  scopes: Schema_exports.Array(Schema_exports.String),
1860
2269
  /** RFC 8414 issuer identifier. Declared issuers are checked against the callback's `iss`. */
1861
2270
  issuer: Schema_exports.optionalKey(HttpUrl),
1862
- discover: Schema_exports.optionalKey(Schema_exports.Never)
1863
- }),
2271
+ discover: Schema_exports.optionalKey(Schema_exports.Never),
2272
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(Schema_exports.Never)
2273
+ }).check(declaredAuthorizationQuery),
1864
2274
  Schema_exports.Struct({
1865
2275
  grant: Schema_exports.Literal("client_credentials"),
1866
2276
  discover: HttpUrl,
2277
+ /** Fetch this exact metadata document and verify its issuer against discovery. */
2278
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(HttpUrl),
1867
2279
  authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
1868
2280
  tokenUrl: Schema_exports.optionalKey(Schema_exports.Never),
1869
2281
  revocationUrl: Schema_exports.optionalKey(Schema_exports.Never),
1870
2282
  scopes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String)),
2283
+ ...tokenRequestOptions,
1871
2284
  tokenEndpointAuthMethod: OAuthSecretClientAuth,
1872
2285
  resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl))
1873
2286
  }),
@@ -1876,10 +2289,12 @@ var OAuth2Config = Schema_exports.Union([
1876
2289
  tokenUrl: HttpUrl,
1877
2290
  revocationUrl: Schema_exports.optionalKey(HttpUrl),
1878
2291
  scopes: Schema_exports.Array(Schema_exports.String),
2292
+ ...tokenRequestOptions,
1879
2293
  tokenEndpointAuthMethod: OAuthSecretClientAuth,
1880
2294
  resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl)),
1881
2295
  authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
1882
- discover: Schema_exports.optionalKey(Schema_exports.Never)
2296
+ discover: Schema_exports.optionalKey(Schema_exports.Never),
2297
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(Schema_exports.Never)
1883
2298
  })
1884
2299
  ]);
1885
2300
  var OAuth2AccessToken = Schema_exports.Struct({ access_token: Schema_exports.String });
@@ -1907,17 +2322,263 @@ var ManyAccounts = class extends Data_exports.TaggedClass("many") {
1907
2322
  };
1908
2323
 
1909
2324
  // src/contracts/protocol-version.ts
1910
- var frameworkProtocol = 5;
2325
+ var frameworkProtocol = 12;
1911
2326
 
1912
- // src/contracts/schedules.ts
1913
- var minimumIntervalMilliseconds = 6e4;
1914
- var count = Schema_exports.Int.check(Schema_exports.isGreaterThan(0));
1915
- var absent = Schema_exports.optionalKey(Schema_exports.Never);
1916
- var Interval = Schema_exports.Union([
1917
- Schema_exports.Struct({ seconds: count, minutes: absent, hours: absent }),
1918
- Schema_exports.Struct({ seconds: absent, minutes: count, hours: absent }),
1919
- Schema_exports.Struct({ seconds: absent, minutes: absent, hours: count })
2327
+ // src/contracts/protocols/oauth.ts
2328
+ var HttpUrl2 = Schema_exports.String.check(
2329
+ Schema_exports.makeFilter((value) => {
2330
+ try {
2331
+ const url = new URL(value);
2332
+ return url.protocol === "https:" || url.protocol === "http:";
2333
+ } catch {
2334
+ return false;
2335
+ }
2336
+ })
2337
+ );
2338
+ var OAuthClientAuth2 = Schema_exports.Literals([
2339
+ "none",
2340
+ "client_secret_post",
2341
+ "client_secret_basic",
2342
+ "client_secret_basic_raw"
2343
+ ]);
2344
+ var OAuthSecretClientAuth2 = Schema_exports.Literals([
2345
+ "client_secret_post",
2346
+ "client_secret_basic",
2347
+ "client_secret_basic_raw"
2348
+ ]);
2349
+ var reservedAuthorizationParams2 = [
2350
+ "response_type",
2351
+ "client_id",
2352
+ "redirect_uri",
2353
+ "state",
2354
+ "scope",
2355
+ "code_challenge",
2356
+ "code_challenge_method",
2357
+ "nonce",
2358
+ "resource",
2359
+ "request",
2360
+ "request_uri"
2361
+ ];
2362
+ var reserved2 = new Set(reservedAuthorizationParams2);
2363
+ var OAuthAuthorizationParams2 = Schema_exports.Record(Schema_exports.String, Schema_exports.String).check(
2364
+ Schema_exports.makeFilter((params) => Object.keys(params).every((key) => !reserved2.has(key)), {
2365
+ message: "Authorization parameters cannot replace protocol parameters such as state or scope."
2366
+ })
2367
+ );
2368
+ var declaredAuthorizationQuery2 = Schema_exports.makeFilter(
2369
+ (config) => {
2370
+ const keys = [...new URL(config.authorizationUrl).searchParams.keys()];
2371
+ const owned = keys.filter((key) => reserved2.has(key));
2372
+ if (owned.length > 0)
2373
+ return {
2374
+ path: ["authorizationUrl"],
2375
+ issue: `authorizationUrl cannot set protocol parameters: ${owned.join(", ")}.`
2376
+ };
2377
+ const repeated = keys.filter((key) => Object.hasOwn(config.authorizationParams ?? {}, key));
2378
+ if (repeated.length > 0)
2379
+ return {
2380
+ path: ["authorizationParams"],
2381
+ issue: `Declare each parameter once; authorizationUrl already sets: ${repeated.join(", ")}.`
2382
+ };
2383
+ return void 0;
2384
+ }
2385
+ );
2386
+ var OAuthTokenRequestFormat2 = Schema_exports.Literals(["form", "json"]);
2387
+ var OAuthTokenResponse2 = Schema_exports.Struct({
2388
+ path: Schema_exports.String.check(Schema_exports.isPattern(/^[^.]+(\.[^.]+)*$/))
2389
+ });
2390
+ var tokenRequestOptions2 = {
2391
+ /** Joins requested scopes; Linear wants `","`. Defaults to RFC 6749's space. */
2392
+ scopeSeparator: Schema_exports.optionalKey(Schema_exports.String.check(Schema_exports.isMinLength(1))),
2393
+ /** Encoding of token requests. Defaults to `"form"`; Atlassian, ClickUp and Notion need `"json"`. */
2394
+ tokenRequestFormat: Schema_exports.optionalKey(OAuthTokenRequestFormat2)
2395
+ };
2396
+ var oauthOptions2 = {
2397
+ ...tokenRequestOptions2,
2398
+ /**
2399
+ * Read the grant from this nested member of the token response when the top-level response has
2400
+ * no access token or no scope. Slack's user tokens use `{ path: "authed_user" }`.
2401
+ */
2402
+ tokenResponse: Schema_exports.optionalKey(OAuthTokenResponse2),
2403
+ grant: Schema_exports.optionalKey(Schema_exports.Literal("authorization_code")),
2404
+ /**
2405
+ * Service-defined authorization request parameters, such as Google's
2406
+ * `{ access_type: "offline", prompt: "consent" }`. Host-owned protocol parameters
2407
+ * (`state`, `scope`, `redirect_uri`, PKCE and the others in `reservedAuthorizationParams`)
2408
+ * are rejected. A discovered endpoint's own query parameter of the same name is replaced.
2409
+ */
2410
+ authorizationParams: Schema_exports.optionalKey(OAuthAuthorizationParams2),
2411
+ tokenEndpointAuthMethod: Schema_exports.optionalKey(OAuthClientAuth2),
2412
+ /** Omitted uses discovery; null explicitly suppresses the resource parameter. */
2413
+ resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl2))
2414
+ };
2415
+ var OAuth2Config2 = Schema_exports.Union([
2416
+ Schema_exports.Struct({
2417
+ ...oauthOptions2,
2418
+ discover: HttpUrl2,
2419
+ authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
2420
+ tokenUrl: Schema_exports.optionalKey(Schema_exports.Never),
2421
+ revocationUrl: Schema_exports.optionalKey(Schema_exports.Never),
2422
+ scopes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String))
2423
+ }),
2424
+ Schema_exports.Struct({
2425
+ ...oauthOptions2,
2426
+ /** Its query is kept; it cannot set protocol parameters or repeat `authorizationParams`. */
2427
+ authorizationUrl: HttpUrl2,
2428
+ tokenUrl: HttpUrl2,
2429
+ revocationUrl: Schema_exports.optionalKey(HttpUrl2),
2430
+ scopes: Schema_exports.Array(Schema_exports.String),
2431
+ /** RFC 8414 issuer identifier. Declared issuers are checked against the callback's `iss`. */
2432
+ issuer: Schema_exports.optionalKey(HttpUrl2),
2433
+ discover: Schema_exports.optionalKey(Schema_exports.Never)
2434
+ }).check(declaredAuthorizationQuery2),
2435
+ Schema_exports.Struct({
2436
+ grant: Schema_exports.Literal("client_credentials"),
2437
+ discover: HttpUrl2,
2438
+ authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
2439
+ tokenUrl: Schema_exports.optionalKey(Schema_exports.Never),
2440
+ revocationUrl: Schema_exports.optionalKey(Schema_exports.Never),
2441
+ scopes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String)),
2442
+ ...tokenRequestOptions2,
2443
+ tokenEndpointAuthMethod: OAuthSecretClientAuth2,
2444
+ resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl2))
2445
+ }),
2446
+ Schema_exports.Struct({
2447
+ grant: Schema_exports.Literal("client_credentials"),
2448
+ tokenUrl: HttpUrl2,
2449
+ revocationUrl: Schema_exports.optionalKey(HttpUrl2),
2450
+ scopes: Schema_exports.Array(Schema_exports.String),
2451
+ ...tokenRequestOptions2,
2452
+ tokenEndpointAuthMethod: OAuthSecretClientAuth2,
2453
+ resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl2)),
2454
+ authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
2455
+ discover: Schema_exports.optionalKey(Schema_exports.Never)
2456
+ })
2457
+ ]);
2458
+
2459
+ // src/contracts/protocols/1.ts
2460
+ var JsonValue2 = Schema_exports.Json;
2461
+ var JsonObject3 = Schema_exports.Record(Schema_exports.String, JsonValue2);
2462
+ var AccountId2 = Schema_exports.String.pipe(
2463
+ Schema_exports.check(Schema_exports.isStartingWith("acc_"), Schema_exports.isMinLength(5)),
2464
+ Schema_exports.brand("acc")
2465
+ );
2466
+ var CacheError = class extends Schema_exports.TaggedError()("CacheError", {
2467
+ reason: Schema_exports.Literals(["unavailable", "storage", "invalid", "capacity", "timeout"])
2468
+ }) {
2469
+ };
2470
+ var Key = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{64}$/));
2471
+ var Time = Schema_exports.Finite.check(Schema_exports.isGreaterThanOrEqualTo(0));
2472
+ var CacheEntry = Schema_exports.Struct({
2473
+ value: Schema_exports.Json,
2474
+ version: Schema_exports.String,
2475
+ freshUntil: Time,
2476
+ staleUntil: Time
2477
+ });
2478
+ var CacheCommand2 = Schema_exports.Union([
2479
+ Schema_exports.Struct({ operation: Schema_exports.Literal("read"), keys: Schema_exports.Array(Key) }),
2480
+ Schema_exports.Struct({
2481
+ operation: Schema_exports.Literal("acquire"),
2482
+ key: Key,
2483
+ /** Claim even a fresh entry, as an explicit refresh does. */
2484
+ refresh: Schema_exports.Boolean,
2485
+ /** Claim only while the entry still has this version. Absent accepts the current one. */
2486
+ version: Schema_exports.optionalKey(Schema_exports.NullOr(Schema_exports.String))
2487
+ }),
2488
+ Schema_exports.Struct({
2489
+ operation: Schema_exports.Literal("claim"),
2490
+ key: Key,
2491
+ version: Schema_exports.NullOr(Schema_exports.String)
2492
+ }),
2493
+ Schema_exports.Struct({
2494
+ operation: Schema_exports.Literal("publish"),
2495
+ key: Key,
2496
+ lease: Schema_exports.String,
2497
+ entry: CacheEntry
2498
+ }),
2499
+ Schema_exports.Struct({ operation: Schema_exports.Literal("release"), key: Key, lease: Schema_exports.String }),
2500
+ /** Extend a lease its holder still owns. Replies false once the lease lapsed or was replaced. */
2501
+ Schema_exports.Struct({ operation: Schema_exports.Literal("renew"), key: Key, lease: Schema_exports.String }),
2502
+ Schema_exports.Struct({
2503
+ operation: Schema_exports.Literal("write"),
2504
+ entries: Schema_exports.Array(Schema_exports.Struct({ key: Key, entry: CacheEntry }))
2505
+ }),
2506
+ Schema_exports.Struct({ operation: Schema_exports.Literal("invalidate"), key: Key })
2507
+ ]);
2508
+ var CacheReply2 = Schema_exports.Union([
2509
+ Schema_exports.Struct({ ok: Schema_exports.Literal(true), value: Schema_exports.Json }),
2510
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: CacheError })
2511
+ ]);
2512
+ var DataName2 = Schema_exports.String.check(
2513
+ Schema_exports.makeFilter((value) => /^[A-Za-z][A-Za-z0-9_]*$/.test(value) && value.length <= 128)
2514
+ );
2515
+ var Scalar2 = Schema_exports.Union([Schema_exports.String, Schema_exports.Finite, Schema_exports.Boolean]);
2516
+ var Field2 = Schema_exports.Struct({
2517
+ kind: Schema_exports.Literals(["string", "number", "boolean", "id", "userId"]),
2518
+ optional: Schema_exports.optional(Schema_exports.Boolean),
2519
+ default: Schema_exports.optional(Scalar2),
2520
+ references: Schema_exports.optional(DataName2)
2521
+ });
2522
+ var Index2 = Schema_exports.Struct({ name: DataName2, fields: Schema_exports.NonEmptyArray(DataName2) });
2523
+ var Table2 = Schema_exports.Struct({
2524
+ fields: Schema_exports.Record(DataName2, Field2),
2525
+ indexes: Schema_exports.Array(Index2)
2526
+ });
2527
+ var DatabaseSchema2 = Schema_exports.Record(DataName2, Table2);
2528
+ var maxApiErrorInstructionsLength2 = 4096;
2529
+ var ApiErrorRecovery2 = Schema_exports.Struct({
2530
+ action: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(1024)),
2531
+ instructions: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(maxApiErrorInstructionsLength2))
2532
+ });
2533
+ var maxApiErrorMessageLength2 = 4096;
2534
+ var ApiErrorResponse2 = Schema_exports.Struct({
2535
+ code: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(128)),
2536
+ status: Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 400, maximum: 599 })),
2537
+ message: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(maxApiErrorMessageLength2)),
2538
+ recovery: Schema_exports.optionalKey(ApiErrorRecovery2)
2539
+ });
2540
+ var OpenapiResponseError2 = class extends Schema_exports.TaggedError()(
2541
+ "OpenapiResponseError",
2542
+ ApiErrorResponse2.fields
2543
+ ) {
2544
+ };
2545
+ var FormElicitation2 = Schema_exports.Struct({
2546
+ ...ElicitRequestFormParams.fields,
2547
+ mode: Schema_exports.Literal("form"),
2548
+ requestedSchema: Schema_exports.toEncoded(ElicitRequestFormParams.fields.requestedSchema),
2549
+ _meta: Schema_exports.optional(JsonObject3)
2550
+ });
2551
+ var ElicitationResponse2 = Schema_exports.Union([
2552
+ Schema_exports.Struct({ ...ElicitAcceptResult.fields, _meta: Schema_exports.optional(JsonObject3) }),
2553
+ Schema_exports.Struct({ ...ElicitDeclineResult.fields, _meta: Schema_exports.optional(JsonObject3) })
2554
+ ]);
2555
+ var ElicitationFailed2 = class extends Schema_exports.TaggedError()(
2556
+ "ElicitationFailed",
2557
+ {
2558
+ reason: Schema_exports.Literals([
2559
+ "unavailable",
2560
+ "transaction",
2561
+ "invalid-request",
2562
+ "invalid-response",
2563
+ "transport",
2564
+ "expired",
2565
+ "forbidden"
2566
+ ])
2567
+ }
2568
+ ) {
2569
+ };
2570
+ var ElicitationReply2 = Schema_exports.Union([
2571
+ Schema_exports.Struct({ ok: Schema_exports.Literal(true), response: ElicitationResponse2 }),
2572
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: ElicitationFailed2 })
1920
2573
  ]);
2574
+ var ApprovalElicitation2 = Schema_exports.Struct({
2575
+ ...FormElicitation2.fields,
2576
+ requestedSchema: Schema_exports.Struct({
2577
+ type: Schema_exports.Literal("object"),
2578
+ properties: Schema_exports.Record(Schema_exports.String, Schema_exports.Never)
2579
+ })
2580
+ });
2581
+ var minimumIntervalMilliseconds = 6e4;
1921
2582
  var CalendarSchedule = Schema_exports.Struct({
1922
2583
  expression: Schema_exports.NonEmptyString,
1923
2584
  timezone: Schema_exports.NonEmptyString
@@ -1941,52 +2602,272 @@ var ScheduleTiming = Schema_exports.Union([
1941
2602
  var OperationSchedule = Schema_exports.Struct({
1942
2603
  name: Schema_exports.NonEmptyString,
1943
2604
  timing: ScheduleTiming,
1944
- input: JsonValue
2605
+ input: JsonValue2
1945
2606
  });
1946
-
1947
- // src/contracts/protocols/1.ts
1948
- var WorkflowFailure2 = class extends Schema_exports.TaggedError()("WorkflowFailure", {
1949
- reason: Schema_exports.Literals([
1950
- "unavailable",
1951
- "not_found",
1952
- "input",
1953
- "output",
1954
- "operation",
1955
- "approval",
1956
- "credentials",
1957
- "terminated",
1958
- "execution",
1959
- "conflict",
1960
- "engine"
1961
- ]),
1962
- retryable: Schema_exports.Boolean
1963
- }) {
2607
+ var SkillFilePath = Schema_exports.NonEmptyString.check(
2608
+ Schema_exports.makeFilter(
2609
+ (path) => !path.startsWith("/") && !path.includes("\\") && !path.includes("\0") && path.split("/").every((part) => part !== "" && part !== "." && part !== "..")
2610
+ )
2611
+ );
2612
+ var SkillFile = Schema_exports.Struct({ path: SkillFilePath, content: Schema_exports.String });
2613
+ var skillFormatLimits = {
2614
+ nameCharacters: 64,
2615
+ descriptionCharacters: 1024,
2616
+ compatibilityCharacters: 500
1964
2617
  };
1965
- var WorkflowRpcResult2 = Schema_exports.Union([
1966
- Schema_exports.Struct({ ok: Schema_exports.Literal(true), value: JsonValue }),
1967
- Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: WorkflowFailure2 })
1968
- ]);
1969
- var DeclaredAuthMethod = Schema_exports.Union([
1970
- Schema_exports.Struct({ type: Schema_exports.Literal("secrets"), label: Schema_exports.String, fields: JsonObject2 }),
1971
- Schema_exports.Struct({
1972
- type: Schema_exports.Literal("oauth2"),
1973
- ...OAuth2Config.members[0].fields,
1974
- response: JsonObject2
1975
- }),
1976
- Schema_exports.Struct({
1977
- type: Schema_exports.Literal("oauth2"),
1978
- ...OAuth2Config.members[1].fields,
1979
- response: JsonObject2
1980
- }),
1981
- Schema_exports.Struct({
1982
- type: Schema_exports.Literal("oauth2"),
1983
- ...OAuth2Config.members[2].fields,
1984
- response: JsonObject2
1985
- }),
1986
- Schema_exports.Struct({
1987
- type: Schema_exports.Literal("oauth2"),
1988
- ...OAuth2Config.members[3].fields,
1989
- response: JsonObject2
2618
+ var AppSkillName2 = Schema_exports.NonEmptyString.check(
2619
+ Schema_exports.makeFilter(
2620
+ (value) => value === value.toLowerCase() && /^[\p{L}\p{N}]+(?:-[\p{L}\p{N}]+)*$/u.test(value) && [...value].length <= skillFormatLimits.nameCharacters
2621
+ )
2622
+ );
2623
+ var AppSkillMetadata = Schema_exports.Struct({
2624
+ name: AppSkillName2,
2625
+ description: Schema_exports.String.check(
2626
+ Schema_exports.makeFilter(
2627
+ (value) => value.trim().length > 0 && [...value].length <= skillFormatLimits.descriptionCharacters
2628
+ )
2629
+ ),
2630
+ license: Schema_exports.optionalKey(Schema_exports.String),
2631
+ compatibility: Schema_exports.optionalKey(
2632
+ Schema_exports.String.check(
2633
+ Schema_exports.makeFilter(
2634
+ (value) => value.trim().length > 0 && [...value].length <= skillFormatLimits.compatibilityCharacters
2635
+ )
2636
+ )
2637
+ ),
2638
+ metadata: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
2639
+ "allowed-tools": Schema_exports.optionalKey(Schema_exports.String)
2640
+ });
2641
+ var AppSkillSource = Schema_exports.Struct({
2642
+ ...AppSkillMetadata.fields,
2643
+ files: Schema_exports.Array(SkillFile).check(
2644
+ Schema_exports.makeFilter(
2645
+ (files) => files.some((file) => file.path === "SKILL.md") && new Set(files.map((file) => file.path)).size === files.length
2646
+ )
2647
+ )
2648
+ });
2649
+ var AppSkills2 = Schema_exports.Array(AppSkillSource).check(
2650
+ Schema_exports.makeFilter((skills) => new Set(skills.map((skill) => skill.name)).size === skills.length)
2651
+ );
2652
+ var ToolAnnotations3 = Schema_exports.Struct({
2653
+ title: Schema_exports.optionalKey(Schema_exports.String),
2654
+ readOnlyHint: Schema_exports.optionalKey(Schema_exports.Boolean),
2655
+ destructiveHint: Schema_exports.optionalKey(Schema_exports.Boolean),
2656
+ idempotentHint: Schema_exports.optionalKey(Schema_exports.Boolean),
2657
+ openWorldHint: Schema_exports.optionalKey(Schema_exports.Boolean)
2658
+ });
2659
+ var WebhookTransportLimits2 = Schema_exports.Struct({
2660
+ maxBodyBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
2661
+ });
2662
+ var defaultWebhookTransportLimits2 = WebhookTransportLimits2.make({
2663
+ maxBodyBytes: 1024 * 1024
2664
+ });
2665
+ var encodedBodyChars2 = 4 * Math.ceil(defaultWebhookTransportLimits2.maxBodyBytes / 3);
2666
+ var WebhookRequestData2 = Schema_exports.Struct({
2667
+ url: HttpUrl2,
2668
+ method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]),
2669
+ headers: Schema_exports.Record(Schema_exports.String, Schema_exports.String),
2670
+ body: Schema_exports.String.check(Schema_exports.isMaxLength(encodedBodyChars2))
2671
+ });
2672
+ var identity2 = {
2673
+ name: Schema_exports.NonEmptyString,
2674
+ subscriptionId: Schema_exports.NonEmptyString,
2675
+ sourceAccount: AccountId2,
2676
+ callbackUrl: HttpUrl2,
2677
+ secret: Schema_exports.String,
2678
+ config: JsonValue2
2679
+ };
2680
+ var WebhookCommand2 = Schema_exports.Union([
2681
+ Schema_exports.Struct({ operation: Schema_exports.Literal("webhooks") }),
2682
+ Schema_exports.Struct({ operation: Schema_exports.Literal("webhook-validate"), ...identity2 }),
2683
+ Schema_exports.Struct({ operation: Schema_exports.Literal("webhook-complete"), ...identity2, state: JsonValue2 }),
2684
+ Schema_exports.Struct({ operation: Schema_exports.Literal("webhook-register"), ...identity2 }),
2685
+ Schema_exports.Struct({ operation: Schema_exports.Literal("webhook-unregister"), ...identity2, state: JsonValue2 }),
2686
+ Schema_exports.Struct({
2687
+ operation: Schema_exports.Literal("webhook-handle"),
2688
+ ...identity2,
2689
+ state: JsonValue2,
2690
+ request: WebhookRequestData2
2691
+ })
2692
+ ]);
2693
+ var WorkflowRunId2 = Schema_exports.NonEmptyString.pipe(Schema_exports.brand("wfr"));
2694
+ var WorkflowName2 = Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(200));
2695
+ var durationUnits2 = {
2696
+ millisecond: 1,
2697
+ milliseconds: 1,
2698
+ second: 1e3,
2699
+ seconds: 1e3,
2700
+ minute: 6e4,
2701
+ minutes: 6e4,
2702
+ hour: 36e5,
2703
+ hours: 36e5,
2704
+ day: 864e5,
2705
+ days: 864e5,
2706
+ week: 6048e5,
2707
+ weeks: 6048e5
2708
+ };
2709
+ var workflowDurationMillis2 = (value) => {
2710
+ if (typeof value === "number") return Number.isFinite(value) && value >= 0 ? value : void 0;
2711
+ const match = /^(\d+(?:\.\d+)?) (milliseconds?|seconds?|minutes?|hours?|days?|weeks?)$/.exec(
2712
+ value
2713
+ );
2714
+ const unit = match?.[2] === void 0 ? void 0 : durationUnits2[match[2]];
2715
+ if (unit === void 0) return void 0;
2716
+ const result = Number(match?.[1]) * unit;
2717
+ return Number.isFinite(result) ? result : void 0;
2718
+ };
2719
+ var WorkflowDuration2 = Schema_exports.Union([
2720
+ Schema_exports.Finite.check(Schema_exports.isGreaterThanOrEqualTo(0)),
2721
+ Schema_exports.NonEmptyString
2722
+ ]).check(Schema_exports.makeFilter((value) => workflowDurationMillis2(value) !== void 0));
2723
+ var WorkflowStepOptions2 = Schema_exports.Struct({
2724
+ retries: Schema_exports.optionalKey(
2725
+ Schema_exports.Struct({
2726
+ limit: Schema_exports.Int.check(Schema_exports.isGreaterThanOrEqualTo(0)),
2727
+ delay: WorkflowDuration2,
2728
+ backoff: Schema_exports.optionalKey(Schema_exports.Literals(["constant", "linear", "exponential"]))
2729
+ })
2730
+ ),
2731
+ timeout: Schema_exports.optionalKey(WorkflowDuration2)
2732
+ });
2733
+ var WorkflowValue2 = JsonValue2.check(
2734
+ Schema_exports.makeFilter(
2735
+ (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 1024 * 1024
2736
+ )
2737
+ );
2738
+ var WorkflowReplay2 = Schema_exports.Struct({
2739
+ key: Schema_exports.NonEmptyString,
2740
+ fingerprint: Schema_exports.NonEmptyString
2741
+ });
2742
+ var WorkflowCommand2 = Schema_exports.Union([
2743
+ Schema_exports.Struct({ operation: Schema_exports.Literal("workflows") }),
2744
+ Schema_exports.Struct({
2745
+ operation: Schema_exports.Literal("workflow-validate"),
2746
+ name: WorkflowName2,
2747
+ input: JsonValue2
2748
+ }),
2749
+ Schema_exports.Struct({
2750
+ operation: Schema_exports.Literal("workflow-run"),
2751
+ name: WorkflowName2,
2752
+ input: JsonValue2
2753
+ })
2754
+ ]);
2755
+ var WorkflowRpcCommand2 = Schema_exports.Union([
2756
+ Schema_exports.Struct({
2757
+ operation: Schema_exports.Literal("do"),
2758
+ name: WorkflowName2,
2759
+ options: WorkflowStepOptions2
2760
+ }),
2761
+ Schema_exports.Struct({
2762
+ operation: Schema_exports.Literal("sleep"),
2763
+ name: WorkflowName2,
2764
+ duration: WorkflowDuration2
2765
+ }),
2766
+ Schema_exports.Struct({
2767
+ operation: Schema_exports.Literal("until"),
2768
+ name: WorkflowName2,
2769
+ timestamp: Schema_exports.Finite
2770
+ }),
2771
+ Schema_exports.Struct({ operation: Schema_exports.Literal("context") }),
2772
+ Schema_exports.Struct({
2773
+ operation: Schema_exports.Literal("invoke"),
2774
+ kind: Schema_exports.Literals(["query", "mutation"]),
2775
+ name: Schema_exports.NonEmptyString,
2776
+ input: JsonValue2,
2777
+ stepId: Schema_exports.NonEmptyString,
2778
+ timeout: Schema_exports.Finite.check(Schema_exports.isGreaterThanOrEqualTo(0))
2779
+ })
2780
+ ]);
2781
+ var WorkflowControlCommand2 = Schema_exports.Union([
2782
+ Schema_exports.Struct({
2783
+ operation: Schema_exports.Literal("start"),
2784
+ workflow: WorkflowName2,
2785
+ input: WorkflowValue2,
2786
+ key: Schema_exports.optionalKey(Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(128)))
2787
+ }),
2788
+ Schema_exports.Struct({ operation: Schema_exports.Literal("get"), run: WorkflowRunId2 }),
2789
+ Schema_exports.Struct({
2790
+ operation: Schema_exports.Literal("list"),
2791
+ workflow: Schema_exports.optionalKey(WorkflowName2),
2792
+ cursor: Schema_exports.optionalKey(WorkflowRunId2),
2793
+ limit: Schema_exports.optionalKey(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 1, maximum: 100 })))
2794
+ }),
2795
+ Schema_exports.Struct({ operation: Schema_exports.Literal("terminate"), run: WorkflowRunId2 })
2796
+ ]);
2797
+ var ProviderError2 = class extends Schema_exports.TaggedError()("ProviderError", {
2798
+ reason: Schema_exports.Literals(["unauthorized", "forbidden", "rate_limited", "unavailable", "rejected"]),
2799
+ status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
2800
+ accountId: Schema_exports.optional(AccountId2)
2801
+ }) {
2802
+ };
2803
+ var McpError3 = class extends Schema_exports.TaggedError()("McpError", {
2804
+ phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
2805
+ reason: Schema_exports.Literals([
2806
+ "request",
2807
+ "unauthorized",
2808
+ "invalid_response",
2809
+ "timeout",
2810
+ "invalid_input"
2811
+ ]),
2812
+ status: Schema_exports.optional(Schema_exports.Number)
2813
+ }) {
2814
+ };
2815
+ var SkillLoadFailed = class extends Schema_exports.TaggedError()("SkillLoadFailed", {
2816
+ reason: Schema_exports.Literals([
2817
+ "source",
2818
+ "request",
2819
+ "rate_limited",
2820
+ "document",
2821
+ "limit",
2822
+ "changed",
2823
+ "encoding"
2824
+ ]),
2825
+ message: Schema_exports.optional(Schema_exports.String.check(Schema_exports.isMaxLength(500))),
2826
+ status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 })))
2827
+ }) {
2828
+ };
2829
+ var WorkflowFailure2 = class extends Schema_exports.TaggedError()("WorkflowFailure", {
2830
+ reason: Schema_exports.Literals([
2831
+ "unavailable",
2832
+ "not_found",
2833
+ "input",
2834
+ "output",
2835
+ "operation",
2836
+ "approval",
2837
+ "credentials",
2838
+ "terminated",
2839
+ "execution",
2840
+ "conflict",
2841
+ "engine"
2842
+ ]),
2843
+ retryable: Schema_exports.Boolean
2844
+ }) {
2845
+ };
2846
+ var WorkflowRpcResult2 = Schema_exports.Union([
2847
+ Schema_exports.Struct({ ok: Schema_exports.Literal(true), value: JsonValue2 }),
2848
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: WorkflowFailure2 })
2849
+ ]);
2850
+ var DeclaredAuthMethod = Schema_exports.Union([
2851
+ Schema_exports.Struct({ type: Schema_exports.Literal("secrets"), label: Schema_exports.String, fields: JsonObject3 }),
2852
+ Schema_exports.Struct({
2853
+ type: Schema_exports.Literal("oauth2"),
2854
+ ...OAuth2Config2.members[0].fields,
2855
+ response: JsonObject3
2856
+ }),
2857
+ Schema_exports.Struct({
2858
+ type: Schema_exports.Literal("oauth2"),
2859
+ ...OAuth2Config2.members[1].fields,
2860
+ response: JsonObject3
2861
+ }),
2862
+ Schema_exports.Struct({
2863
+ type: Schema_exports.Literal("oauth2"),
2864
+ ...OAuth2Config2.members[2].fields,
2865
+ response: JsonObject3
2866
+ }),
2867
+ Schema_exports.Struct({
2868
+ type: Schema_exports.Literal("oauth2"),
2869
+ ...OAuth2Config2.members[3].fields,
2870
+ response: JsonObject3
1990
2871
  })
1991
2872
  ]);
1992
2873
  var DeclaredProvider = Schema_exports.Struct({
@@ -2006,7 +2887,7 @@ var DeclaredRequirements = Schema_exports.Struct({
2006
2887
  scheduledTools: Schema_exports.optionalKey(Schema_exports.Literal(true))
2007
2888
  })
2008
2889
  ),
2009
- database: Schema_exports.optionalKey(DatabaseSchema),
2890
+ database: Schema_exports.optionalKey(DatabaseSchema2),
2010
2891
  accounts: Schema_exports.Record(
2011
2892
  Schema_exports.NonEmptyString,
2012
2893
  Schema_exports.Struct({
@@ -2016,7 +2897,7 @@ var DeclaredRequirements = Schema_exports.Struct({
2016
2897
  )
2017
2898
  });
2018
2899
  var ResolvedAccount = Schema_exports.Struct({
2019
- id: AccountId,
2900
+ id: AccountId2,
2020
2901
  provider: DeclaredProvider,
2021
2902
  method: Schema_exports.NonEmptyString,
2022
2903
  /**
@@ -2024,33 +2905,33 @@ var ResolvedAccount = Schema_exports.Struct({
2024
2905
  * send it since credential generations; `apps@0.0.1-beta.0` and `beta.1` ignore it.
2025
2906
  */
2026
2907
  generation: Schema_exports.optionalKey(Schema_exports.Int),
2027
- fields: JsonObject2
2908
+ fields: JsonObject3
2028
2909
  });
2029
2910
  var ResolvedAccounts = Schema_exports.Record(
2030
2911
  Schema_exports.NonEmptyString,
2031
2912
  Schema_exports.Union([ResolvedAccount, Schema_exports.Array(ResolvedAccount)])
2032
2913
  );
2033
- var TrustedToolApproval = Schema_exports.Struct({ tool: Schema_exports.NonEmptyString, input: JsonValue });
2914
+ var TrustedToolApproval = Schema_exports.Struct({ tool: Schema_exports.NonEmptyString, input: JsonValue2 });
2034
2915
  var InvocationDeadline = Schema_exports.Finite.check(Schema_exports.isGreaterThanOrEqualTo(0));
2035
2916
  var HostedTool = Schema_exports.Struct({
2036
2917
  schedules: Schema_exports.optionalKey(Schema_exports.Array(OperationSchedule)),
2037
2918
  name: Schema_exports.NonEmptyString,
2038
2919
  description: Schema_exports.String,
2039
- inputSchema: JsonObject2,
2920
+ inputSchema: JsonObject3,
2040
2921
  readOnly: Schema_exports.optionalKey(Schema_exports.Boolean),
2041
2922
  title: Schema_exports.optionalKey(Schema_exports.String),
2042
- outputSchema: Schema_exports.optionalKey(JsonObject2),
2043
- annotations: Schema_exports.optionalKey(ToolAnnotations),
2044
- _meta: Schema_exports.optionalKey(JsonObject2)
2923
+ outputSchema: Schema_exports.optionalKey(JsonObject3),
2924
+ annotations: Schema_exports.optionalKey(ToolAnnotations3),
2925
+ _meta: Schema_exports.optionalKey(JsonObject3)
2045
2926
  });
2046
2927
  var HostedToolSummary = HostedTool.mapFields(
2047
2928
  ({ inputSchema: _input, outputSchema: _output, _meta, ...fields }) => fields
2048
2929
  );
2049
- var SkillSources = Schema_exports.Struct({ skills: AppSkills, dynamic: Schema_exports.Boolean });
2050
- var SkillCatalogResponse = Schema_exports.Union([SkillSources, AppSkills]);
2930
+ var SkillSources = Schema_exports.Struct({ skills: AppSkills2, dynamic: Schema_exports.Boolean });
2931
+ var SkillCatalogResponse = Schema_exports.Union([SkillSources, AppSkills2]);
2051
2932
  var HostRequest = Schema_exports.Union([
2052
- WorkflowCommand,
2053
- WebhookCommand,
2933
+ WorkflowCommand2,
2934
+ WebhookCommand2,
2054
2935
  Schema_exports.Struct({ operation: Schema_exports.Literal("requirements") }),
2055
2936
  Schema_exports.Struct({
2056
2937
  operation: Schema_exports.Literal("inspect"),
@@ -2072,17 +2953,17 @@ var HostRequest = Schema_exports.Union([
2072
2953
  Schema_exports.Struct({
2073
2954
  operation: Schema_exports.Literal("query"),
2074
2955
  name: Schema_exports.NonEmptyString,
2075
- input: JsonValue
2956
+ input: JsonValue2
2076
2957
  }),
2077
2958
  Schema_exports.Struct({
2078
2959
  operation: Schema_exports.Literal("mutate"),
2079
2960
  name: Schema_exports.NonEmptyString,
2080
- input: JsonValue
2961
+ input: JsonValue2
2081
2962
  }),
2082
2963
  Schema_exports.Struct({
2083
2964
  operation: Schema_exports.Literal("call"),
2084
2965
  tool: Schema_exports.NonEmptyString,
2085
- input: JsonValue
2966
+ input: JsonValue2
2086
2967
  })
2087
2968
  ]);
2088
2969
  var HostRequestInvalid = class extends Schema_exports.TaggedError()(
@@ -2132,7 +3013,7 @@ var HostToolBlocked = class extends Schema_exports.TaggedError()("HostToolBlocke
2132
3013
  };
2133
3014
  var HostToolApprovalRequired = class extends Schema_exports.TaggedError()(
2134
3015
  "HostToolApprovalRequired",
2135
- { input: JsonValue, elicitation: ApprovalElicitation }
3016
+ { input: JsonValue2, elicitation: ApprovalElicitation2 }
2136
3017
  ) {
2137
3018
  };
2138
3019
  var HostToolPolicyFailed = class extends Schema_exports.TaggedError()(
@@ -2146,9 +3027,9 @@ var HostOutputInvalid = class extends Schema_exports.TaggedError()(
2146
3027
  ) {
2147
3028
  };
2148
3029
  var HostError = Schema_exports.Union([
2149
- OpenapiResponseError,
2150
- ProviderError,
2151
- McpError,
3030
+ OpenapiResponseError2,
3031
+ ProviderError2,
3032
+ McpError3,
2152
3033
  SkillLoadFailed,
2153
3034
  WorkflowFailure2,
2154
3035
  HostRequestInvalid,
@@ -2163,12 +3044,12 @@ var HostError = Schema_exports.Union([
2163
3044
  HostToolBlocked,
2164
3045
  HostToolApprovalRequired,
2165
3046
  HostToolPolicyFailed,
2166
- ElicitationFailed
3047
+ ElicitationFailed2
2167
3048
  ]);
2168
3049
  var HostResponse = Schema_exports.Union([
2169
3050
  Schema_exports.Struct({
2170
3051
  ok: Schema_exports.Literal(true),
2171
- value: JsonValue,
3052
+ value: JsonValue2,
2172
3053
  toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
2173
3054
  }),
2174
3055
  Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError })
@@ -2177,9 +3058,9 @@ var HostInvocation = Schema_exports.Struct({
2177
3058
  command: HostRequest,
2178
3059
  accounts: ResolvedAccounts,
2179
3060
  approval: Schema_exports.optionalKey(TrustedToolApproval),
2180
- replay: Schema_exports.optionalKey(WorkflowReplay),
3061
+ replay: Schema_exports.optionalKey(WorkflowReplay2),
2181
3062
  deadline: Schema_exports.optionalKey(InvocationDeadline),
2182
- workflowRun: Schema_exports.optionalKey(WorkflowRunId)
3063
+ workflowRun: Schema_exports.optionalKey(WorkflowRunId2)
2183
3064
  });
2184
3065
  var protocol1 = {
2185
3066
  version: 1,
@@ -2191,70 +3072,136 @@ var protocol1 = {
2191
3072
  tools: Schema_exports.Array(HostedTool),
2192
3073
  toolSummaries: Schema_exports.Array(HostedToolSummary),
2193
3074
  skills: SkillCatalogResponse,
2194
- elicitationRequest: FormElicitation,
2195
- elicitationReply: ElicitationReply,
2196
- workflowStep: WorkflowRpcCommand,
3075
+ elicitationRequest: FormElicitation2,
3076
+ elicitationReply: ElicitationReply2,
3077
+ workflowStep: WorkflowRpcCommand2,
2197
3078
  workflowStepReply: WorkflowRpcResult2,
2198
- workflowControl: WorkflowControlCommand,
2199
- cacheCommand: CacheCommand,
2200
- cacheReply: CacheReply
3079
+ workflowControl: WorkflowControlCommand2,
3080
+ cacheCommand: CacheCommand2,
3081
+ cacheReply: CacheReply2
2201
3082
  }
2202
3083
  };
2203
3084
 
2204
3085
  // src/contracts/protocols/2.ts
2205
3086
  var SkillSources2 = Schema_exports.Struct({
2206
- skills: AppSkills,
3087
+ skills: AppSkills2,
2207
3088
  dynamic: Schema_exports.Boolean,
2208
3089
  cached: Schema_exports.optionalKey(Schema_exports.Boolean)
2209
3090
  });
2210
- var SkillCatalogResponse2 = Schema_exports.Union([SkillSources2, AppSkills]);
3091
+ var SkillCatalogResponse2 = Schema_exports.Union([SkillSources2, AppSkills2]);
2211
3092
  var protocol2 = {
2212
3093
  version: 2,
2213
3094
  schemas: { ...protocol1.schemas, skills: SkillCatalogResponse2 }
2214
3095
  };
2215
3096
 
2216
3097
  // src/contracts/protocols/3.ts
3098
+ var maxFailureMessageLength = 2048;
3099
+ var FailureSource = Schema_exports.Literals(["app", "storage", "service"]);
3100
+ var FailureName2 = Schema_exports.String.check(Schema_exports.isMaxLength(128));
3101
+ var FailureCode = Schema_exports.String.check(Schema_exports.isMaxLength(128));
3102
+ var FailureMessage2 = Schema_exports.String.check(Schema_exports.isMaxLength(maxFailureMessageLength));
3103
+ var WorkflowFailureDetail2 = {
3104
+ step: Schema_exports.optionalKey(Schema_exports.String.check(Schema_exports.isMaxLength(200))),
3105
+ errorName: Schema_exports.optionalKey(FailureName2),
3106
+ message: Schema_exports.optionalKey(FailureMessage2)
3107
+ };
3108
+ var WorkflowFailure3 = class extends Schema_exports.TaggedError()("WorkflowFailure", {
3109
+ ...WorkflowFailureDetail2,
3110
+ reason: Schema_exports.Literals([
3111
+ "unavailable",
3112
+ "not_found",
3113
+ "input",
3114
+ "output",
3115
+ "operation",
3116
+ "approval",
3117
+ "credentials",
3118
+ "terminated",
3119
+ "execution",
3120
+ "conflict",
3121
+ "engine"
3122
+ ]),
3123
+ retryable: Schema_exports.Boolean
3124
+ }) {
3125
+ };
3126
+ var WorkflowRpcResult3 = Schema_exports.Union([
3127
+ Schema_exports.Struct({ ok: Schema_exports.Literal(true), value: JsonValue2 }),
3128
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: WorkflowFailure3 })
3129
+ ]);
3130
+ var DatabaseLimit2 = Schema_exports.Literals([
3131
+ "scanCalls",
3132
+ "directGets",
3133
+ "rowsRead",
3134
+ "rowsReturned",
3135
+ "pageSize",
3136
+ "bytesRead",
3137
+ "writes",
3138
+ "valueBytes"
3139
+ ]);
3140
+ var DatabaseLimitExceeded2 = class extends Schema_exports.TaggedError()(
3141
+ "DatabaseLimitExceeded",
3142
+ {
3143
+ limit: DatabaseLimit2,
3144
+ maximum: Schema_exports.Int,
3145
+ requested: Schema_exports.Int
3146
+ }
3147
+ ) {
3148
+ };
3149
+ var reservedFieldNames2 = ["id", "createdAt", "updatedAt"];
3150
+ var DatabaseFieldReserved2 = class extends Schema_exports.TaggedError()(
3151
+ "DatabaseFieldReserved",
3152
+ {
3153
+ table: Schema_exports.String,
3154
+ field: Schema_exports.Literals(reservedFieldNames2)
3155
+ }
3156
+ ) {
3157
+ };
3158
+ var FailureDetail2 = {
3159
+ source: Schema_exports.optionalKey(FailureSource),
3160
+ errorName: Schema_exports.optionalKey(FailureName2),
3161
+ code: Schema_exports.optionalKey(FailureCode),
3162
+ message: Schema_exports.optionalKey(FailureMessage2)
3163
+ };
2217
3164
  var HostDeclarationInvalid2 = class extends Schema_exports.TaggedError()(
2218
3165
  "HostDeclarationInvalid",
2219
- FailureDetail
3166
+ FailureDetail2
2220
3167
  ) {
2221
3168
  };
2222
3169
  var HostEvaluationFailed2 = class extends Schema_exports.TaggedError()(
2223
3170
  "HostEvaluationFailed",
2224
- FailureDetail
3171
+ FailureDetail2
2225
3172
  ) {
2226
3173
  };
2227
3174
  var HostOperationFailed2 = class extends Schema_exports.TaggedError()(
2228
3175
  "HostOperationFailed",
2229
- FailureDetail
3176
+ FailureDetail2
2230
3177
  ) {
2231
3178
  };
2232
3179
  var HostError2 = Schema_exports.Union([
2233
- OpenapiResponseError,
2234
- ProviderError,
2235
- McpError,
3180
+ OpenapiResponseError2,
3181
+ ProviderError2,
3182
+ McpError3,
2236
3183
  SkillLoadFailed,
2237
- WorkflowFailure,
3184
+ WorkflowFailure3,
2238
3185
  HostRequestInvalid,
2239
3186
  HostAccountsInvalid,
2240
3187
  HostDeclarationInvalid2,
2241
3188
  HostEvaluationFailed2,
2242
3189
  HostOperationNotFound,
2243
3190
  HostOperationFailed2,
2244
- DatabaseLimitExceeded,
2245
- DatabaseFieldReserved,
3191
+ DatabaseLimitExceeded2,
3192
+ DatabaseFieldReserved2,
2246
3193
  HostToolNotFound,
2247
3194
  HostInputInvalid,
2248
3195
  HostOutputInvalid,
2249
3196
  HostToolBlocked,
2250
3197
  HostToolApprovalRequired,
2251
3198
  HostToolPolicyFailed,
2252
- ElicitationFailed
3199
+ ElicitationFailed2
2253
3200
  ]);
2254
3201
  var HostResponse2 = Schema_exports.Union([
2255
3202
  Schema_exports.Struct({
2256
3203
  ok: Schema_exports.Literal(true),
2257
- value: JsonValue,
3204
+ value: JsonValue2,
2258
3205
  toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
2259
3206
  }),
2260
3207
  Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError2 })
@@ -2266,62 +3213,894 @@ var protocol3 = {
2266
3213
  request: HostRequest,
2267
3214
  response: HostResponse2,
2268
3215
  requirements: DeclaredRequirements,
2269
- tools: Schema_exports.Array(HostedTool),
2270
- toolSummaries: Schema_exports.Array(HostedToolSummary),
3216
+ tools: protocol1.schemas.tools,
3217
+ toolSummaries: protocol1.schemas.toolSummaries,
2271
3218
  skills: SkillCatalogResponse2,
2272
- elicitationRequest: FormElicitation,
2273
- elicitationReply: ElicitationReply,
2274
- workflowStep: WorkflowRpcCommand,
2275
- workflowStepReply: WorkflowRpcResult,
2276
- workflowControl: WorkflowControlCommand,
2277
- cacheCommand: CacheCommand,
2278
- cacheReply: CacheReply
3219
+ elicitationRequest: FormElicitation2,
3220
+ elicitationReply: ElicitationReply2,
3221
+ workflowStep: WorkflowRpcCommand2,
3222
+ workflowStepReply: WorkflowRpcResult3,
3223
+ workflowControl: WorkflowControlCommand2,
3224
+ cacheCommand: CacheCommand2,
3225
+ cacheReply: CacheReply2
2279
3226
  }
2280
3227
  };
2281
3228
 
2282
3229
  // src/contracts/protocols/4.ts
3230
+ var RouterIcon2 = Schema_exports.Struct({
3231
+ src: Schema_exports.NonEmptyString,
3232
+ mimeType: Schema_exports.optionalKey(Schema_exports.String),
3233
+ sizes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String)),
3234
+ theme: Schema_exports.optionalKey(Schema_exports.Literals(["light", "dark"]))
3235
+ });
2283
3236
  var HostedTool2 = Schema_exports.Struct({
2284
3237
  schedules: Schema_exports.optionalKey(Schema_exports.Array(OperationSchedule)),
2285
3238
  name: Schema_exports.NonEmptyString,
2286
3239
  router: Schema_exports.optionalKey(Schema_exports.NonEmptyString),
2287
3240
  tags: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
2288
3241
  description: Schema_exports.String,
3242
+ inputSchema: JsonObject3,
3243
+ readOnly: Schema_exports.optionalKey(Schema_exports.Boolean),
3244
+ title: Schema_exports.optionalKey(Schema_exports.String),
3245
+ outputSchema: Schema_exports.optionalKey(JsonObject3),
3246
+ annotations: Schema_exports.optionalKey(ToolAnnotations3),
3247
+ _meta: Schema_exports.optionalKey(JsonObject3)
3248
+ });
3249
+ var HostedToolSummary2 = HostedTool2.mapFields(
3250
+ ({ inputSchema: _input, outputSchema: _output, _meta, ...fields }) => fields
3251
+ );
3252
+ var HostRouterError = Schema_exports.Union([
3253
+ ProviderError2,
3254
+ McpError3,
3255
+ SkillLoadFailed,
3256
+ HostDeclarationInvalid2,
3257
+ HostEvaluationFailed2
3258
+ ]);
3259
+ var HostedRouter = Schema_exports.Struct({
3260
+ path: Schema_exports.String,
3261
+ title: Schema_exports.optionalKey(Schema_exports.String),
3262
+ description: Schema_exports.optionalKey(Schema_exports.String),
3263
+ icons: Schema_exports.optionalKey(Schema_exports.Array(RouterIcon2)),
3264
+ tags: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.NonEmptyString, Schema_exports.String)),
3265
+ skill: Schema_exports.optionalKey(AppSkillName2),
3266
+ error: Schema_exports.optionalKey(HostRouterError)
3267
+ });
3268
+ var HostedCatalog = Schema_exports.Struct({
3269
+ tools: Schema_exports.Array(HostedTool2),
3270
+ routers: Schema_exports.Array(HostedRouter)
3271
+ });
3272
+ var HostedCatalogSummary = Schema_exports.Struct({
3273
+ tools: Schema_exports.Array(HostedToolSummary2),
3274
+ routers: Schema_exports.Array(HostedRouter)
3275
+ });
3276
+ var ToolKind = Schema_exports.Literals(["query", "mutation"]);
3277
+ var HostRequest2 = Schema_exports.Union([
3278
+ WorkflowCommand2,
3279
+ WebhookCommand2,
3280
+ Schema_exports.Struct({ operation: Schema_exports.Literal("requirements") }),
3281
+ Schema_exports.Struct({
3282
+ operation: Schema_exports.Literal("inspect"),
3283
+ /** Omit schemas. Only builds that declare the toolIndex capability accept this. */
3284
+ detail: Schema_exports.optionalKey(Schema_exports.Literal("summary")),
3285
+ /** Describe only these tools. Only builds that declare the toolIndex capability accept this. */
3286
+ tools: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
3287
+ /**
3288
+ * Describe only declared operations that have schedules, without dynamic tool discovery.
3289
+ * Only builds that declare the scheduledTools capability accept this.
3290
+ */
3291
+ scheduled: Schema_exports.optionalKey(Schema_exports.Literal(true))
3292
+ }),
3293
+ Schema_exports.Struct({
3294
+ operation: Schema_exports.Literal("skills"),
3295
+ /** Answer with SkillSources. Only builds that declare the skillSources capability accept this. */
3296
+ sources: Schema_exports.optionalKey(Schema_exports.Literal(true))
3297
+ }),
3298
+ Schema_exports.Struct({
3299
+ operation: Schema_exports.Literal("query"),
3300
+ name: Schema_exports.NonEmptyString,
3301
+ input: JsonValue2
3302
+ }),
3303
+ Schema_exports.Struct({
3304
+ operation: Schema_exports.Literal("mutate"),
3305
+ name: Schema_exports.NonEmptyString,
3306
+ input: JsonValue2
3307
+ }),
3308
+ Schema_exports.Struct({
3309
+ operation: Schema_exports.Literal("call"),
3310
+ tool: Schema_exports.NonEmptyString,
3311
+ /**
3312
+ * The caller's claim; the bundle rejects a call whose tool has the other kind. The host omits
3313
+ * it for a tool its catalog does not list, and then opens storage for writing.
3314
+ */
3315
+ kind: Schema_exports.optionalKey(ToolKind),
3316
+ input: JsonValue2
3317
+ })
3318
+ ]);
3319
+ var HostKindMismatch = class extends Schema_exports.TaggedError()("HostKindMismatch", {
3320
+ tool: Schema_exports.NonEmptyString,
3321
+ requested: ToolKind,
3322
+ actual: ToolKind
3323
+ }) {
3324
+ };
3325
+ var HostError3 = Schema_exports.Union([...HostError2.members, HostKindMismatch]);
3326
+ var HostResponse3 = Schema_exports.Union([
3327
+ Schema_exports.Struct({
3328
+ ok: Schema_exports.Literal(true),
3329
+ value: JsonValue2,
3330
+ toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
3331
+ }),
3332
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError3 })
3333
+ ]);
3334
+ var HostInvocation2 = Schema_exports.Struct({
3335
+ command: HostRequest2,
3336
+ accounts: ResolvedAccounts,
3337
+ approval: Schema_exports.optionalKey(TrustedToolApproval),
3338
+ replay: Schema_exports.optionalKey(WorkflowReplay2),
3339
+ deadline: Schema_exports.optionalKey(InvocationDeadline),
3340
+ workflowRun: Schema_exports.optionalKey(WorkflowRunId2)
3341
+ });
3342
+ var protocol4 = {
3343
+ version: 4,
3344
+ schemas: {
3345
+ invocation: HostInvocation2,
3346
+ request: HostRequest2,
3347
+ response: HostResponse3,
3348
+ requirements: protocol3.schemas.requirements,
3349
+ catalog: HostedCatalog,
3350
+ catalogSummary: HostedCatalogSummary,
3351
+ skills: protocol3.schemas.skills,
3352
+ elicitationRequest: protocol3.schemas.elicitationRequest,
3353
+ elicitationReply: protocol3.schemas.elicitationReply,
3354
+ workflowStep: protocol3.schemas.workflowStep,
3355
+ workflowStepReply: protocol3.schemas.workflowStepReply,
3356
+ workflowControl: protocol3.schemas.workflowControl,
3357
+ cacheCommand: protocol3.schemas.cacheCommand,
3358
+ cacheReply: protocol3.schemas.cacheReply
3359
+ }
3360
+ };
3361
+
3362
+ // src/contracts/protocols/5.ts
3363
+ var displayText2 = Schema_exports.String.check(Schema_exports.isMinLength(1), Schema_exports.isMaxLength(255));
3364
+ var AccountInfo2 = Schema_exports.Struct({
3365
+ externalId: Schema_exports.optionalKey(displayText2),
3366
+ displayName: Schema_exports.optionalKey(displayText2),
3367
+ username: Schema_exports.optionalKey(displayText2),
3368
+ email: Schema_exports.optionalKey(displayText2),
3369
+ avatarUrl: Schema_exports.optionalKey(HttpUrl2),
3370
+ profileUrl: Schema_exports.optionalKey(HttpUrl2)
3371
+ });
3372
+ var AccountCheckResult2 = Schema_exports.Struct({ accountInfo: Schema_exports.optionalKey(AccountInfo2) });
3373
+ var DeclaredRequirements2 = Schema_exports.Struct({
3374
+ /** Protocol support of this retained framework build, not an author-declared requirement. */
3375
+ capabilities: Schema_exports.optionalKey(
3376
+ Schema_exports.Struct({
3377
+ skills: Schema_exports.Literal(true),
3378
+ toolIndex: Schema_exports.optionalKey(Schema_exports.Literal(true)),
3379
+ skillSources: Schema_exports.optionalKey(Schema_exports.Literal(true)),
3380
+ scheduledTools: Schema_exports.optionalKey(Schema_exports.Literal(true))
3381
+ })
3382
+ ),
3383
+ database: Schema_exports.optionalKey(DatabaseSchema2),
3384
+ accounts: Schema_exports.Record(
3385
+ Schema_exports.NonEmptyString,
3386
+ Schema_exports.Struct({
3387
+ definition: DeclaredProvider,
3388
+ cardinality: Schema_exports.Literals(["one", "many"]),
3389
+ /**
3390
+ * The slot's provider defines an account check. Kept beside the definition, not in it, so
3391
+ * adding or editing a check never changes the provider's identity.
3392
+ */
3393
+ health: Schema_exports.optionalKey(Schema_exports.Literal(true))
3394
+ })
3395
+ )
3396
+ });
3397
+ var AccountCheckCommand = Schema_exports.Struct({
3398
+ operation: Schema_exports.Literal("account-check"),
3399
+ requirement: Schema_exports.NonEmptyString
3400
+ });
3401
+ var HostRequest3 = Schema_exports.Union([
3402
+ ...protocol4.schemas.request.members,
3403
+ AccountCheckCommand
3404
+ ]);
3405
+ var HostInvocation3 = Schema_exports.Struct({
3406
+ command: HostRequest3,
3407
+ accounts: ResolvedAccounts,
3408
+ approval: Schema_exports.optionalKey(TrustedToolApproval),
3409
+ replay: Schema_exports.optionalKey(WorkflowReplay2),
3410
+ deadline: Schema_exports.optionalKey(InvocationDeadline),
3411
+ workflowRun: Schema_exports.optionalKey(WorkflowRunId2)
3412
+ });
3413
+ var protocol5 = {
3414
+ version: 5,
3415
+ schemas: {
3416
+ ...protocol4.schemas,
3417
+ invocation: HostInvocation3,
3418
+ request: HostRequest3,
3419
+ requirements: DeclaredRequirements2,
3420
+ accountCheck: AccountCheckResult2
3421
+ }
3422
+ };
3423
+
3424
+ // src/contracts/protocols/oauth-6.ts
3425
+ var OAuth2Config3 = Schema_exports.Union([
3426
+ Schema_exports.Struct({
3427
+ ...oauthOptions2,
3428
+ discover: HttpUrl2,
3429
+ /** Fetch this exact metadata document and verify its issuer against discovery. */
3430
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(HttpUrl2),
3431
+ authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
3432
+ tokenUrl: Schema_exports.optionalKey(Schema_exports.Never),
3433
+ revocationUrl: Schema_exports.optionalKey(Schema_exports.Never),
3434
+ scopes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String))
3435
+ }),
3436
+ Schema_exports.Struct({
3437
+ ...oauthOptions2,
3438
+ /** Its query is kept; it cannot set protocol parameters or repeat `authorizationParams`. */
3439
+ authorizationUrl: HttpUrl2,
3440
+ tokenUrl: HttpUrl2,
3441
+ revocationUrl: Schema_exports.optionalKey(HttpUrl2),
3442
+ scopes: Schema_exports.Array(Schema_exports.String),
3443
+ /** RFC 8414 issuer identifier. Declared issuers are checked against the callback's `iss`. */
3444
+ issuer: Schema_exports.optionalKey(HttpUrl2),
3445
+ discover: Schema_exports.optionalKey(Schema_exports.Never),
3446
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(Schema_exports.Never)
3447
+ }).check(declaredAuthorizationQuery2),
3448
+ Schema_exports.Struct({
3449
+ grant: Schema_exports.Literal("client_credentials"),
3450
+ discover: HttpUrl2,
3451
+ /** Fetch this exact metadata document and verify its issuer against discovery. */
3452
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(HttpUrl2),
3453
+ authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
3454
+ tokenUrl: Schema_exports.optionalKey(Schema_exports.Never),
3455
+ revocationUrl: Schema_exports.optionalKey(Schema_exports.Never),
3456
+ scopes: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String)),
3457
+ ...tokenRequestOptions2,
3458
+ tokenEndpointAuthMethod: OAuthSecretClientAuth2,
3459
+ resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl2))
3460
+ }),
3461
+ Schema_exports.Struct({
3462
+ grant: Schema_exports.Literal("client_credentials"),
3463
+ tokenUrl: HttpUrl2,
3464
+ revocationUrl: Schema_exports.optionalKey(HttpUrl2),
3465
+ scopes: Schema_exports.Array(Schema_exports.String),
3466
+ ...tokenRequestOptions2,
3467
+ tokenEndpointAuthMethod: OAuthSecretClientAuth2,
3468
+ resource: Schema_exports.optionalKey(Schema_exports.NullOr(HttpUrl2)),
3469
+ authorizationUrl: Schema_exports.optionalKey(Schema_exports.Never),
3470
+ discover: Schema_exports.optionalKey(Schema_exports.Never),
3471
+ authorizationServerMetadataUrl: Schema_exports.optionalKey(Schema_exports.Never)
3472
+ })
3473
+ ]);
3474
+
3475
+ // src/contracts/protocols/6.ts
3476
+ var DeclaredAuthMethod2 = Schema_exports.Union([
3477
+ Schema_exports.Struct({ type: Schema_exports.Literal("secrets"), label: Schema_exports.String, fields: JsonObject3 }),
3478
+ Schema_exports.Struct({
3479
+ type: Schema_exports.Literal("oauth2"),
3480
+ ...OAuth2Config3.members[0].fields,
3481
+ response: JsonObject3
3482
+ }),
3483
+ Schema_exports.Struct({
3484
+ type: Schema_exports.Literal("oauth2"),
3485
+ ...OAuth2Config3.members[1].fields,
3486
+ response: JsonObject3
3487
+ }),
3488
+ Schema_exports.Struct({
3489
+ type: Schema_exports.Literal("oauth2"),
3490
+ ...OAuth2Config3.members[2].fields,
3491
+ response: JsonObject3
3492
+ }),
3493
+ Schema_exports.Struct({
3494
+ type: Schema_exports.Literal("oauth2"),
3495
+ ...OAuth2Config3.members[3].fields,
3496
+ response: JsonObject3
3497
+ })
3498
+ ]);
3499
+ var DeclaredProvider2 = Schema_exports.Struct({
3500
+ name: Schema_exports.NonEmptyString,
3501
+ auth: Schema_exports.Record(Schema_exports.NonEmptyString, DeclaredAuthMethod2)
3502
+ });
3503
+ var DeclaredRequirements3 = Schema_exports.Struct({
3504
+ ...DeclaredRequirements2.fields,
3505
+ accounts: Schema_exports.Record(
3506
+ Schema_exports.NonEmptyString,
3507
+ Schema_exports.Struct({
3508
+ definition: DeclaredProvider2,
3509
+ cardinality: Schema_exports.Literals(["one", "many"]),
3510
+ health: Schema_exports.optionalKey(Schema_exports.Literal(true))
3511
+ })
3512
+ )
3513
+ });
3514
+ var ResolvedAccount2 = Schema_exports.Struct({
3515
+ ...ResolvedAccount.fields,
3516
+ provider: DeclaredProvider2
3517
+ });
3518
+ var ResolvedAccounts2 = Schema_exports.Record(
3519
+ Schema_exports.NonEmptyString,
3520
+ Schema_exports.Union([ResolvedAccount2, Schema_exports.Array(ResolvedAccount2)])
3521
+ );
3522
+ var HostInvocation4 = Schema_exports.Struct({
3523
+ ...HostInvocation3.fields,
3524
+ accounts: ResolvedAccounts2
3525
+ });
3526
+ var protocol6 = {
3527
+ version: 6,
3528
+ schemas: {
3529
+ ...protocol5.schemas,
3530
+ requirements: DeclaredRequirements3,
3531
+ accounts: ResolvedAccounts2,
3532
+ invocation: HostInvocation4
3533
+ }
3534
+ };
3535
+
3536
+ // src/contracts/protocols/7.ts
3537
+ var CredentialHost = Schema_exports.String.check(
3538
+ Schema_exports.isPattern(
3539
+ /^(\*\.)?[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})?$/
3540
+ )
3541
+ );
3542
+ var exposure = {
3543
+ /** Not secret: app code reads the real value and forms show it. */
3544
+ plain: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
3545
+ /** Secret, but app code reads the real value, for signing and similar uses. */
3546
+ raw: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString))
3547
+ };
3548
+ var DeclaredAuthMethod3 = Schema_exports.Union([
3549
+ Schema_exports.Struct({
3550
+ type: Schema_exports.Literal("secrets"),
3551
+ label: Schema_exports.String,
3552
+ fields: JsonObject3,
3553
+ ...exposure
3554
+ }),
3555
+ Schema_exports.Struct({
3556
+ type: Schema_exports.Literal("oauth2"),
3557
+ ...OAuth2Config3.members[0].fields,
3558
+ response: JsonObject3,
3559
+ ...exposure
3560
+ }),
3561
+ Schema_exports.Struct({
3562
+ type: Schema_exports.Literal("oauth2"),
3563
+ ...OAuth2Config3.members[1].fields,
3564
+ response: JsonObject3,
3565
+ ...exposure
3566
+ }),
3567
+ Schema_exports.Struct({
3568
+ type: Schema_exports.Literal("oauth2"),
3569
+ ...OAuth2Config3.members[2].fields,
3570
+ response: JsonObject3,
3571
+ ...exposure
3572
+ }),
3573
+ Schema_exports.Struct({
3574
+ type: Schema_exports.Literal("oauth2"),
3575
+ ...OAuth2Config3.members[3].fields,
3576
+ response: JsonObject3,
3577
+ ...exposure
3578
+ })
3579
+ ]);
3580
+ var DeclaredProvider3 = Schema_exports.Struct({
3581
+ name: Schema_exports.NonEmptyString,
3582
+ auth: Schema_exports.Record(Schema_exports.NonEmptyString, DeclaredAuthMethod3),
3583
+ hosts: Schema_exports.optionalKey(Schema_exports.Array(CredentialHost))
3584
+ });
3585
+ var DeclaredRequirements4 = Schema_exports.Struct({
3586
+ ...DeclaredRequirements3.fields,
3587
+ accounts: Schema_exports.Record(
3588
+ Schema_exports.NonEmptyString,
3589
+ Schema_exports.Struct({
3590
+ definition: DeclaredProvider3,
3591
+ cardinality: Schema_exports.Literals(["one", "many"]),
3592
+ health: Schema_exports.optionalKey(Schema_exports.Literal(true))
3593
+ })
3594
+ )
3595
+ });
3596
+ var ResolvedAccount3 = Schema_exports.Struct({
3597
+ ...ResolvedAccount2.fields,
3598
+ provider: DeclaredProvider3
3599
+ });
3600
+ var ResolvedAccounts3 = Schema_exports.Record(
3601
+ Schema_exports.NonEmptyString,
3602
+ Schema_exports.Union([ResolvedAccount3, Schema_exports.Array(ResolvedAccount3)])
3603
+ );
3604
+ var HostInvocation5 = Schema_exports.Struct({
3605
+ ...HostInvocation4.fields,
3606
+ accounts: ResolvedAccounts3
3607
+ });
3608
+ var protocol7 = {
3609
+ version: 7,
3610
+ schemas: {
3611
+ ...protocol6.schemas,
3612
+ requirements: DeclaredRequirements4,
3613
+ accounts: ResolvedAccounts3,
3614
+ invocation: HostInvocation5
3615
+ }
3616
+ };
3617
+
3618
+ // src/contracts/protocols/8.ts
3619
+ var maxFailureFields = 8;
3620
+ var maxFailureFieldLength = 256;
3621
+ var FailureFieldName = Schema_exports.String.check(
3622
+ Schema_exports.isPattern(/^[A-Za-z_$][A-Za-z0-9_$]{0,63}$/)
3623
+ );
3624
+ var FailureFieldValue = Schema_exports.Union([
3625
+ Schema_exports.String.check(Schema_exports.isMaxLength(maxFailureFieldLength)),
3626
+ Schema_exports.Finite,
3627
+ Schema_exports.Boolean
3628
+ ]);
3629
+ var FailureFields = Schema_exports.Record(FailureFieldName, FailureFieldValue).check(
3630
+ Schema_exports.isMaxProperties(maxFailureFields)
3631
+ );
3632
+ var FailureDetail3 = {
3633
+ source: Schema_exports.optionalKey(FailureSource),
3634
+ errorName: Schema_exports.optionalKey(FailureName2),
3635
+ code: Schema_exports.optionalKey(FailureCode),
3636
+ message: Schema_exports.optionalKey(FailureMessage2),
3637
+ fields: Schema_exports.optionalKey(FailureFields)
3638
+ };
3639
+ var maxUpstreamMessageLength = 1024;
3640
+ var UpstreamError2 = Schema_exports.Struct({
3641
+ code: Schema_exports.Union([
3642
+ Schema_exports.Int,
3643
+ Schema_exports.String.check(Schema_exports.isMinLength(1), Schema_exports.isMaxLength(128))
3644
+ ]),
3645
+ message: Schema_exports.optionalKey(Schema_exports.String.check(Schema_exports.isMaxLength(maxUpstreamMessageLength)))
3646
+ });
3647
+ var FailurePhase = Schema_exports.Literals(["connect", "discover", "call"]);
3648
+ var ProviderError3 = class extends Schema_exports.TaggedError()("ProviderError", {
3649
+ reason: Schema_exports.Literals(["unauthorized", "forbidden", "rate_limited", "unavailable", "rejected"]),
3650
+ status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
3651
+ accountId: Schema_exports.optional(AccountId2),
3652
+ phase: Schema_exports.optional(FailurePhase),
3653
+ upstream: Schema_exports.optional(UpstreamError2)
3654
+ }) {
3655
+ };
3656
+ var McpError4 = class extends Schema_exports.TaggedError()("McpError", {
3657
+ phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
3658
+ reason: Schema_exports.Literals([
3659
+ "request",
3660
+ "unauthorized",
3661
+ "invalid_response",
3662
+ "timeout",
3663
+ "invalid_input"
3664
+ ]),
3665
+ status: Schema_exports.optional(Schema_exports.Number),
3666
+ upstream: Schema_exports.optional(UpstreamError2)
3667
+ }) {
3668
+ };
3669
+ var HostDeclarationInvalid3 = class extends Schema_exports.TaggedError()(
3670
+ "HostDeclarationInvalid",
3671
+ FailureDetail3
3672
+ ) {
3673
+ };
3674
+ var HostEvaluationFailed3 = class extends Schema_exports.TaggedError()(
3675
+ "HostEvaluationFailed",
3676
+ FailureDetail3
3677
+ ) {
3678
+ };
3679
+ var HostOperationFailed3 = class extends Schema_exports.TaggedError()(
3680
+ "HostOperationFailed",
3681
+ FailureDetail3
3682
+ ) {
3683
+ };
3684
+ var HostRouterError2 = Schema_exports.Union([
3685
+ ProviderError3,
3686
+ McpError4,
3687
+ SkillLoadFailed,
3688
+ HostDeclarationInvalid3,
3689
+ HostEvaluationFailed3
3690
+ ]);
3691
+ var HostedRouter2 = Schema_exports.Struct({
3692
+ ...HostedRouter.fields,
3693
+ error: Schema_exports.optionalKey(HostRouterError2)
3694
+ });
3695
+ var HostedCatalog2 = Schema_exports.Struct({
3696
+ ...HostedCatalog.fields,
3697
+ routers: Schema_exports.Array(HostedRouter2)
3698
+ });
3699
+ var HostedCatalogSummary2 = Schema_exports.Struct({
3700
+ ...HostedCatalogSummary.fields,
3701
+ routers: Schema_exports.Array(HostedRouter2)
3702
+ });
3703
+ var HostError4 = Schema_exports.Union([
3704
+ OpenapiResponseError2,
3705
+ ProviderError3,
3706
+ McpError4,
3707
+ SkillLoadFailed,
3708
+ WorkflowFailure3,
3709
+ HostRequestInvalid,
3710
+ HostAccountsInvalid,
3711
+ HostDeclarationInvalid3,
3712
+ HostEvaluationFailed3,
3713
+ HostOperationNotFound,
3714
+ HostOperationFailed3,
3715
+ DatabaseLimitExceeded2,
3716
+ DatabaseFieldReserved2,
3717
+ HostToolNotFound,
3718
+ HostInputInvalid,
3719
+ HostOutputInvalid,
3720
+ HostToolBlocked,
3721
+ HostToolApprovalRequired,
3722
+ HostToolPolicyFailed,
3723
+ ElicitationFailed2,
3724
+ HostKindMismatch
3725
+ ]);
3726
+ var HostResponse4 = Schema_exports.Union([
3727
+ Schema_exports.Struct({
3728
+ ok: Schema_exports.Literal(true),
3729
+ value: JsonValue2,
3730
+ toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
3731
+ }),
3732
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError4 })
3733
+ ]);
3734
+ var protocol8 = {
3735
+ version: 8,
3736
+ schemas: {
3737
+ ...protocol7.schemas,
3738
+ response: HostResponse4,
3739
+ catalog: HostedCatalog2,
3740
+ catalogSummary: HostedCatalogSummary2
3741
+ }
3742
+ };
3743
+
3744
+ // src/contracts/protocols/9.ts
3745
+ var McpError5 = class extends Schema_exports.TaggedError()("McpError", {
3746
+ phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
3747
+ reason: Schema_exports.Literals([
3748
+ "request",
3749
+ "unauthorized",
3750
+ "invalid_response",
3751
+ "timeout",
3752
+ "invalid_input"
3753
+ ]),
3754
+ status: Schema_exports.optional(Schema_exports.Number),
3755
+ upstream: Schema_exports.optional(UpstreamError2),
3756
+ session: Schema_exports.optional(Schema_exports.Literal(true))
3757
+ }) {
3758
+ };
3759
+ var SkillLoadFailed2 = class extends Schema_exports.TaggedError()("SkillLoadFailed", {
3760
+ reason: Schema_exports.Literals([
3761
+ "source",
3762
+ "request",
3763
+ "rate_limited",
3764
+ "document",
3765
+ "limit",
3766
+ "changed",
3767
+ "encoding"
3768
+ ]),
3769
+ message: Schema_exports.optional(Schema_exports.String.check(Schema_exports.isMaxLength(500))),
3770
+ status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
3771
+ missing: Schema_exports.optional(Schema_exports.Literals(["repository", "ref"]))
3772
+ }) {
3773
+ };
3774
+ var HostRouterError3 = Schema_exports.Union([
3775
+ ProviderError3,
3776
+ McpError5,
3777
+ SkillLoadFailed2,
3778
+ HostDeclarationInvalid3,
3779
+ HostEvaluationFailed3
3780
+ ]);
3781
+ var HostedRouter3 = Schema_exports.Struct({
3782
+ ...HostedRouter2.fields,
3783
+ error: Schema_exports.optionalKey(HostRouterError3)
3784
+ });
3785
+ var HostedCatalog3 = Schema_exports.Struct({
3786
+ ...HostedCatalog2.fields,
3787
+ routers: Schema_exports.Array(HostedRouter3)
3788
+ });
3789
+ var HostedCatalogSummary3 = Schema_exports.Struct({
3790
+ ...HostedCatalogSummary2.fields,
3791
+ routers: Schema_exports.Array(HostedRouter3)
3792
+ });
3793
+ var HostError5 = Schema_exports.Union([
3794
+ OpenapiResponseError2,
3795
+ ProviderError3,
3796
+ McpError5,
3797
+ SkillLoadFailed2,
3798
+ WorkflowFailure3,
3799
+ HostRequestInvalid,
3800
+ HostAccountsInvalid,
3801
+ HostDeclarationInvalid3,
3802
+ HostEvaluationFailed3,
3803
+ HostOperationNotFound,
3804
+ HostOperationFailed3,
3805
+ DatabaseLimitExceeded2,
3806
+ DatabaseFieldReserved2,
3807
+ HostToolNotFound,
3808
+ HostInputInvalid,
3809
+ HostOutputInvalid,
3810
+ HostToolBlocked,
3811
+ HostToolApprovalRequired,
3812
+ HostToolPolicyFailed,
3813
+ ElicitationFailed2,
3814
+ HostKindMismatch
3815
+ ]);
3816
+ var HostResponse5 = Schema_exports.Union([
3817
+ Schema_exports.Struct({
3818
+ ok: Schema_exports.Literal(true),
3819
+ value: JsonValue2,
3820
+ toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
3821
+ }),
3822
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError5 })
3823
+ ]);
3824
+ var protocol9 = {
3825
+ version: 9,
3826
+ schemas: {
3827
+ ...protocol8.schemas,
3828
+ response: HostResponse5,
3829
+ catalog: HostedCatalog3,
3830
+ catalogSummary: HostedCatalogSummary3
3831
+ }
3832
+ };
3833
+
3834
+ // src/contracts/protocols/10.ts
3835
+ var DeclaredRequirements5 = Schema_exports.Struct({
3836
+ ...DeclaredRequirements4.fields,
3837
+ sql: Schema_exports.optionalKey(Schema_exports.Literal(true))
3838
+ });
3839
+ var MigrateCommand = Schema_exports.Struct({ operation: Schema_exports.Literal("migrate") });
3840
+ var MigrateResult = Schema_exports.Array(
3841
+ Schema_exports.Struct({ id: Schema_exports.Int, name: Schema_exports.NonEmptyString })
3842
+ );
3843
+ var HostRequest4 = Schema_exports.Union([...HostRequest3.members, MigrateCommand]);
3844
+ var HostInvocation6 = Schema_exports.Struct({
3845
+ ...HostInvocation5.fields,
3846
+ command: HostRequest4
3847
+ });
3848
+ var protocol10 = {
3849
+ version: 10,
3850
+ schemas: {
3851
+ ...protocol9.schemas,
3852
+ request: HostRequest4,
3853
+ requirements: DeclaredRequirements5,
3854
+ invocation: HostInvocation6,
3855
+ migrate: MigrateResult
3856
+ }
3857
+ };
3858
+
3859
+ // src/contracts/schedules.ts
3860
+ var minimumIntervalMilliseconds2 = 6e4;
3861
+ var count2 = Schema_exports.Int.check(Schema_exports.isGreaterThan(0));
3862
+ var absent = Schema_exports.optionalKey(Schema_exports.Never);
3863
+ var Interval = Schema_exports.Union([
3864
+ Schema_exports.Struct({ seconds: count2, minutes: absent, hours: absent }),
3865
+ Schema_exports.Struct({ seconds: absent, minutes: count2, hours: absent }),
3866
+ Schema_exports.Struct({ seconds: absent, minutes: absent, hours: count2 })
3867
+ ]);
3868
+ var CalendarSchedule2 = Schema_exports.Struct({
3869
+ expression: Schema_exports.NonEmptyString,
3870
+ timezone: Schema_exports.NonEmptyString
3871
+ }).check(
3872
+ Schema_exports.makeFilter(
3873
+ (value) => value.expression.trim().split(/\s+/).length === 5 && Result_exports.isSuccess(Cron_exports.parse(value.expression, value.timezone))
3874
+ )
3875
+ );
3876
+ var ScheduleTiming2 = Schema_exports.Union([
3877
+ Schema_exports.Struct({
3878
+ kind: Schema_exports.Literal("interval"),
3879
+ milliseconds: Schema_exports.Int.check(
3880
+ Schema_exports.makeFilter((value) => value >= minimumIntervalMilliseconds2, {
3881
+ message: "Schedule intervals must be at least 60 seconds"
3882
+ }),
3883
+ Schema_exports.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER)
3884
+ )
3885
+ }),
3886
+ Schema_exports.Struct({ kind: Schema_exports.Literal("cron"), calendar: CalendarSchedule2 })
3887
+ ]);
3888
+ var OperationSchedule2 = Schema_exports.Struct({
3889
+ name: Schema_exports.NonEmptyString,
3890
+ timing: ScheduleTiming2,
3891
+ input: JsonValue
3892
+ });
3893
+
3894
+ // src/contracts/protocols/current.ts
3895
+ var McpError6 = class extends Schema_exports.TaggedError()("McpError", {
3896
+ phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
3897
+ reason: Schema_exports.Literals([
3898
+ "request",
3899
+ "unauthorized",
3900
+ "invalid_response",
3901
+ "timeout",
3902
+ "invalid_input"
3903
+ ]),
3904
+ status: Schema_exports.optional(Schema_exports.Number),
3905
+ /** The JSON-RPC error the server stated. */
3906
+ upstream: Schema_exports.optional(UpstreamError),
3907
+ /**
3908
+ * The refused request carried the session ID the server issued at initialization, so a 404 reads
3909
+ * as a session the server may have lost. Chooses the explanation only; the host never decides from
3910
+ * it whose side a failure is on.
3911
+ */
3912
+ session: Schema_exports.optional(Schema_exports.Literal(true))
3913
+ }) {
3914
+ };
3915
+ var SkillLoadFailed3 = class extends Schema_exports.TaggedError()("SkillLoadFailed", {
3916
+ reason: Schema_exports.Literals([
3917
+ "source",
3918
+ "request",
3919
+ "rate_limited",
3920
+ "document",
3921
+ "limit",
3922
+ "changed",
3923
+ "encoding"
3924
+ ]),
3925
+ message: Schema_exports.optional(Schema_exports.String.check(Schema_exports.isMaxLength(500))),
3926
+ status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
3927
+ /** What the service's answer points to as missing: the repository, or the branch or tag. */
3928
+ missing: Schema_exports.optional(Schema_exports.Literals(["repository", "ref"]))
3929
+ }) {
3930
+ };
3931
+ var CredentialHost2 = Schema_exports.String.check(
3932
+ Schema_exports.isPattern(
3933
+ /^(\*\.)?[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})?$/
3934
+ )
3935
+ );
3936
+ var exposure2 = {
3937
+ /** Not secret: app code reads the real value and forms show it. */
3938
+ plain: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
3939
+ /** Secret, but app code reads the real value, for signing and similar uses. */
3940
+ raw: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
3941
+ /**
3942
+ * The only places the outbound network substitutes this method's secret fields: whole header
3943
+ * values and query parameters, each an exact template. Part of the provider's identity. In an
3944
+ * invocation, an account's provider carries the placements granted to that account, which can
3945
+ * be narrower than the app's declaration.
3946
+ */
3947
+ request: Schema_exports.optionalKey(Placements)
3948
+ };
3949
+ var DeclaredAuthMethod4 = Schema_exports.Union([
3950
+ Schema_exports.Struct({
3951
+ type: Schema_exports.Literal("secrets"),
3952
+ label: Schema_exports.String,
3953
+ fields: JsonObject2,
3954
+ ...exposure2
3955
+ }),
3956
+ Schema_exports.Struct({
3957
+ type: Schema_exports.Literal("oauth2"),
3958
+ ...OAuth2Config.members[0].fields,
3959
+ response: JsonObject2,
3960
+ ...exposure2
3961
+ }),
3962
+ Schema_exports.Struct({
3963
+ type: Schema_exports.Literal("oauth2"),
3964
+ ...OAuth2Config.members[1].fields,
3965
+ response: JsonObject2,
3966
+ ...exposure2
3967
+ }),
3968
+ Schema_exports.Struct({
3969
+ type: Schema_exports.Literal("oauth2"),
3970
+ ...OAuth2Config.members[2].fields,
3971
+ response: JsonObject2,
3972
+ ...exposure2
3973
+ }),
3974
+ Schema_exports.Struct({
3975
+ type: Schema_exports.Literal("oauth2"),
3976
+ ...OAuth2Config.members[3].fields,
3977
+ response: JsonObject2,
3978
+ ...exposure2
3979
+ })
3980
+ ]);
3981
+ var DeclaredProvider4 = Schema_exports.Struct({
3982
+ name: Schema_exports.NonEmptyString,
3983
+ auth: Schema_exports.Record(Schema_exports.NonEmptyString, DeclaredAuthMethod4),
3984
+ hosts: Schema_exports.optionalKey(Schema_exports.Array(CredentialHost2))
3985
+ });
3986
+ var DeclaredRequirements6 = Schema_exports.Struct({
3987
+ /** Protocol support of this retained framework build, not an author-declared requirement. */
3988
+ capabilities: Schema_exports.optionalKey(
3989
+ Schema_exports.Struct({
3990
+ skills: Schema_exports.Literal(true),
3991
+ /** Accepts inspect detail and tools. Earlier builds reject both as excess fields. */
3992
+ toolIndex: Schema_exports.optionalKey(Schema_exports.Literal(true)),
3993
+ /** Accepts skills sources and reports whether the catalog includes a live loader. */
3994
+ skillSources: Schema_exports.optionalKey(Schema_exports.Literal(true)),
3995
+ /** Accepts scheduled inspection. Earlier builds reject it as an excess field. */
3996
+ scheduledTools: Schema_exports.optionalKey(Schema_exports.Literal(true))
3997
+ })
3998
+ ),
3999
+ /**
4000
+ * The document database an app of protocol 9 or earlier declared. Apps of this protocol declare
4001
+ * `sql` instead; the field remains so requirements read from older retained builds keep their meaning.
4002
+ */
4003
+ database: Schema_exports.optionalKey(DatabaseSchema),
4004
+ accounts: Schema_exports.Record(
4005
+ Schema_exports.NonEmptyString,
4006
+ Schema_exports.Struct({
4007
+ definition: DeclaredProvider4,
4008
+ cardinality: Schema_exports.Literals(["one", "many"]),
4009
+ /**
4010
+ * The slot's provider defines an account check. Kept beside the definition, not in it, so
4011
+ * adding or editing a check never changes the provider's identity.
4012
+ */
4013
+ health: Schema_exports.optionalKey(Schema_exports.Literal(true))
4014
+ })
4015
+ ),
4016
+ /** The build has SQL files in `migrations/` and owns a raw SQLite database. */
4017
+ sql: Schema_exports.optionalKey(Schema_exports.Literal(true)),
4018
+ /** The events the app declares, so a host lists them without evaluating the app. */
4019
+ events: Schema_exports.optionalKey(DeclaredEvents)
4020
+ });
4021
+ var ResolvedAccount4 = Schema_exports.Struct({
4022
+ id: AccountId,
4023
+ provider: DeclaredProvider4,
4024
+ method: Schema_exports.NonEmptyString,
4025
+ /**
4026
+ * Changes when the account is reconnected or its credentials replaced, not on renewal. Hosts
4027
+ * send it since credential generations; `apps@0.0.1-beta.0` and `beta.1` ignore it.
4028
+ */
4029
+ generation: Schema_exports.optionalKey(Schema_exports.Int),
4030
+ fields: JsonObject2
4031
+ });
4032
+ var ResolvedAccounts4 = Schema_exports.Record(
4033
+ Schema_exports.NonEmptyString,
4034
+ Schema_exports.Union([ResolvedAccount4, Schema_exports.Array(ResolvedAccount4)])
4035
+ );
4036
+ var TrustedToolApproval2 = Schema_exports.Struct({ tool: Schema_exports.NonEmptyString, input: JsonValue });
4037
+ var InvocationDeadline2 = Schema_exports.Finite.check(Schema_exports.isGreaterThanOrEqualTo(0));
4038
+ var HostedTool3 = Schema_exports.Struct({
4039
+ schedules: Schema_exports.optionalKey(Schema_exports.Array(OperationSchedule2)),
4040
+ name: Schema_exports.NonEmptyString,
4041
+ router: Schema_exports.optionalKey(Schema_exports.NonEmptyString),
4042
+ tags: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
4043
+ description: Schema_exports.String,
2289
4044
  inputSchema: JsonObject2,
2290
4045
  readOnly: Schema_exports.optionalKey(Schema_exports.Boolean),
2291
4046
  title: Schema_exports.optionalKey(Schema_exports.String),
2292
4047
  outputSchema: Schema_exports.optionalKey(JsonObject2),
2293
- annotations: Schema_exports.optionalKey(ToolAnnotations),
4048
+ annotations: Schema_exports.optionalKey(ToolAnnotations2),
2294
4049
  _meta: Schema_exports.optionalKey(JsonObject2)
2295
4050
  });
2296
- var HostedToolSummary2 = HostedTool2.mapFields(
4051
+ var HostedToolSummary3 = HostedTool3.mapFields(
2297
4052
  ({ inputSchema: _input, outputSchema: _output, _meta, ...fields }) => fields
2298
4053
  );
2299
- var HostRouterError = Schema_exports.Union([
4054
+ var HostDeclarationInvalid4 = class extends Schema_exports.TaggedError()(
4055
+ "HostDeclarationInvalid",
4056
+ FailureDetail
4057
+ ) {
4058
+ };
4059
+ var HostEvaluationFailed4 = class extends Schema_exports.TaggedError()(
4060
+ "HostEvaluationFailed",
4061
+ FailureDetail
4062
+ ) {
4063
+ };
4064
+ var HostRouterError4 = Schema_exports.Union([
2300
4065
  ProviderError,
2301
- McpError,
2302
- SkillLoadFailed,
2303
- HostDeclarationInvalid2,
2304
- HostEvaluationFailed2
4066
+ McpError6,
4067
+ SkillLoadFailed3,
4068
+ HostDeclarationInvalid4,
4069
+ HostEvaluationFailed4
2305
4070
  ]);
2306
- var HostedRouter = Schema_exports.Struct({
4071
+ var HostedRouter4 = Schema_exports.Struct({
2307
4072
  path: Schema_exports.String,
2308
4073
  title: Schema_exports.optionalKey(Schema_exports.String),
2309
4074
  description: Schema_exports.optionalKey(Schema_exports.String),
2310
4075
  icons: Schema_exports.optionalKey(Schema_exports.Array(RouterIcon)),
2311
4076
  tags: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.NonEmptyString, Schema_exports.String)),
2312
4077
  skill: Schema_exports.optionalKey(AppSkillName),
2313
- error: Schema_exports.optionalKey(HostRouterError)
4078
+ error: Schema_exports.optionalKey(HostRouterError4)
2314
4079
  });
2315
- var HostedCatalog = Schema_exports.Struct({
2316
- tools: Schema_exports.Array(HostedTool2),
2317
- routers: Schema_exports.Array(HostedRouter)
4080
+ var HostedCatalog4 = Schema_exports.Struct({
4081
+ tools: Schema_exports.Array(HostedTool3),
4082
+ routers: Schema_exports.Array(HostedRouter4)
2318
4083
  });
2319
- var HostedCatalogSummary = Schema_exports.Struct({
2320
- tools: Schema_exports.Array(HostedToolSummary2),
2321
- routers: Schema_exports.Array(HostedRouter)
4084
+ var HostedCatalogSummary4 = Schema_exports.Struct({
4085
+ tools: Schema_exports.Array(HostedToolSummary3),
4086
+ routers: Schema_exports.Array(HostedRouter4)
2322
4087
  });
2323
- var ToolKind = Schema_exports.Literals(["query", "mutation"]);
2324
- var HostRequest2 = Schema_exports.Union([
4088
+ var SkillSources3 = Schema_exports.Struct({
4089
+ skills: AppSkills,
4090
+ dynamic: Schema_exports.Boolean,
4091
+ cached: Schema_exports.optionalKey(Schema_exports.Boolean)
4092
+ });
4093
+ var SkillCatalogResponse3 = Schema_exports.Union([SkillSources3, AppSkills]);
4094
+ var ToolKind2 = Schema_exports.Literals(["query", "mutation"]);
4095
+ var AccountCheckCommand2 = Schema_exports.Struct({
4096
+ operation: Schema_exports.Literal("account-check"),
4097
+ requirement: Schema_exports.NonEmptyString
4098
+ });
4099
+ var MigrateCommand2 = Schema_exports.Struct({ operation: Schema_exports.Literal("migrate") });
4100
+ var MigrateResult2 = Schema_exports.Array(
4101
+ Schema_exports.Struct({ id: Schema_exports.Int, name: Schema_exports.NonEmptyString })
4102
+ );
4103
+ var HostRequest5 = Schema_exports.Union([
2325
4104
  WorkflowCommand,
2326
4105
  WebhookCommand,
2327
4106
  Schema_exports.Struct({ operation: Schema_exports.Literal("requirements") }),
@@ -2359,108 +4138,143 @@ var HostRequest2 = Schema_exports.Union([
2359
4138
  * The caller's claim; the bundle rejects a call whose tool has the other kind. The host omits
2360
4139
  * it for a tool its catalog does not list, and then opens storage for writing.
2361
4140
  */
2362
- kind: Schema_exports.optionalKey(ToolKind),
4141
+ kind: Schema_exports.optionalKey(ToolKind2),
2363
4142
  input: JsonValue
2364
- })
4143
+ }),
4144
+ AccountCheckCommand2,
4145
+ MigrateCommand2
2365
4146
  ]);
2366
- var HostKindMismatch = class extends Schema_exports.TaggedError()("HostKindMismatch", {
4147
+ var HostRequestInvalid2 = class extends Schema_exports.TaggedError()(
4148
+ "HostRequestInvalid",
4149
+ {}
4150
+ ) {
4151
+ };
4152
+ var HostAccountsInvalid2 = class extends Schema_exports.TaggedError()(
4153
+ "HostAccountsInvalid",
4154
+ {}
4155
+ ) {
4156
+ };
4157
+ var HostOperationNotFound2 = class extends Schema_exports.TaggedError()(
4158
+ "HostOperationNotFound",
4159
+ {}
4160
+ ) {
4161
+ };
4162
+ var HostOperationFailed4 = class extends Schema_exports.TaggedError()(
4163
+ "HostOperationFailed",
4164
+ FailureDetail
4165
+ ) {
4166
+ };
4167
+ var HostToolNotFound2 = class extends Schema_exports.TaggedError()(
4168
+ "HostToolNotFound",
4169
+ {}
4170
+ ) {
4171
+ };
4172
+ var HostKindMismatch2 = class extends Schema_exports.TaggedError()("HostKindMismatch", {
2367
4173
  tool: Schema_exports.NonEmptyString,
2368
- requested: ToolKind,
2369
- actual: ToolKind
4174
+ requested: ToolKind2,
4175
+ actual: ToolKind2
2370
4176
  }) {
2371
4177
  };
2372
- var HostError3 = Schema_exports.Union([...HostError2.members, HostKindMismatch]);
2373
- var HostResponse3 = Schema_exports.Union([
4178
+ var InputProblem2 = Schema_exports.String.check(Schema_exports.isMaxLength(512));
4179
+ var maxInputProblems2 = 10;
4180
+ var HostInputInvalid2 = class extends Schema_exports.TaggedError()("HostInputInvalid", {
4181
+ problems: Schema_exports.optionalKey(
4182
+ Schema_exports.Array(InputProblem2).check(Schema_exports.isMaxLength(maxInputProblems2))
4183
+ )
4184
+ }) {
4185
+ };
4186
+ var HostToolBlocked2 = class extends Schema_exports.TaggedError()("HostToolBlocked", {}) {
4187
+ };
4188
+ var HostToolApprovalRequired2 = class extends Schema_exports.TaggedError()(
4189
+ "HostToolApprovalRequired",
4190
+ { input: JsonValue, elicitation: ApprovalElicitation }
4191
+ ) {
4192
+ };
4193
+ var HostToolPolicyFailed2 = class extends Schema_exports.TaggedError()(
4194
+ "HostToolPolicyFailed",
4195
+ {}
4196
+ ) {
4197
+ };
4198
+ var HostOutputInvalid2 = class extends Schema_exports.TaggedError()(
4199
+ "HostOutputInvalid",
4200
+ {}
4201
+ ) {
4202
+ };
4203
+ var HostError6 = Schema_exports.Union([
4204
+ OpenapiResponseError,
4205
+ ProviderError,
4206
+ McpError6,
4207
+ SkillLoadFailed3,
4208
+ WorkflowFailure,
4209
+ HostRequestInvalid2,
4210
+ HostAccountsInvalid2,
4211
+ HostDeclarationInvalid4,
4212
+ HostEvaluationFailed4,
4213
+ HostOperationNotFound2,
4214
+ HostOperationFailed4,
4215
+ DatabaseLimitExceeded,
4216
+ DatabaseFieldReserved,
4217
+ HostToolNotFound2,
4218
+ HostInputInvalid2,
4219
+ HostOutputInvalid2,
4220
+ HostToolBlocked2,
4221
+ HostToolApprovalRequired2,
4222
+ HostToolPolicyFailed2,
4223
+ ElicitationFailed,
4224
+ HostKindMismatch2
4225
+ ]);
4226
+ var HostResponse6 = Schema_exports.Union([
2374
4227
  Schema_exports.Struct({
2375
4228
  ok: Schema_exports.Literal(true),
2376
4229
  value: JsonValue,
2377
- toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
4230
+ toolError: Schema_exports.optionalKey(Schema_exports.Literal(true)),
4231
+ /** The occurrences this invocation emitted, kept only because it succeeded. */
4232
+ events: Schema_exports.optionalKey(EmittedEvents)
2378
4233
  }),
2379
- Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError3 })
4234
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError6 })
2380
4235
  ]);
2381
- var HostInvocation2 = Schema_exports.Struct({
2382
- command: HostRequest2,
2383
- accounts: ResolvedAccounts,
2384
- approval: Schema_exports.optionalKey(TrustedToolApproval),
4236
+ var HostInvocation7 = Schema_exports.Struct({
4237
+ command: HostRequest5,
4238
+ accounts: ResolvedAccounts4,
4239
+ approval: Schema_exports.optionalKey(TrustedToolApproval2),
2385
4240
  replay: Schema_exports.optionalKey(WorkflowReplay),
2386
- deadline: Schema_exports.optionalKey(InvocationDeadline),
4241
+ deadline: Schema_exports.optionalKey(InvocationDeadline2),
2387
4242
  workflowRun: Schema_exports.optionalKey(WorkflowRunId)
2388
4243
  });
2389
- var protocol4 = {
2390
- version: 4,
4244
+ var current = {
4245
+ version: frameworkProtocol,
2391
4246
  schemas: {
2392
- invocation: HostInvocation2,
2393
- request: HostRequest2,
2394
- response: HostResponse3,
2395
- requirements: DeclaredRequirements,
2396
- catalog: HostedCatalog,
2397
- catalogSummary: HostedCatalogSummary,
2398
- skills: SkillCatalogResponse2,
4247
+ invocation: HostInvocation7,
4248
+ request: HostRequest5,
4249
+ response: HostResponse6,
4250
+ requirements: DeclaredRequirements6,
4251
+ catalog: HostedCatalog4,
4252
+ catalogSummary: HostedCatalogSummary4,
4253
+ skills: SkillCatalogResponse3,
2399
4254
  elicitationRequest: FormElicitation,
2400
4255
  elicitationReply: ElicitationReply,
2401
4256
  workflowStep: WorkflowRpcCommand,
2402
4257
  workflowStepReply: WorkflowRpcResult,
2403
4258
  workflowControl: WorkflowControlCommand,
2404
4259
  cacheCommand: CacheCommand,
2405
- cacheReply: CacheReply
2406
- }
2407
- };
2408
-
2409
- // src/contracts/protocols/5.ts
2410
- var DeclaredRequirements2 = Schema_exports.Struct({
2411
- /** Protocol support of this retained framework build, not an author-declared requirement. */
2412
- capabilities: Schema_exports.optionalKey(
2413
- Schema_exports.Struct({
2414
- skills: Schema_exports.Literal(true),
2415
- toolIndex: Schema_exports.optionalKey(Schema_exports.Literal(true)),
2416
- skillSources: Schema_exports.optionalKey(Schema_exports.Literal(true)),
2417
- scheduledTools: Schema_exports.optionalKey(Schema_exports.Literal(true))
2418
- })
2419
- ),
2420
- database: Schema_exports.optionalKey(DatabaseSchema),
2421
- accounts: Schema_exports.Record(
2422
- Schema_exports.NonEmptyString,
2423
- Schema_exports.Struct({
2424
- definition: DeclaredProvider,
2425
- cardinality: Schema_exports.Literals(["one", "many"]),
2426
- /**
2427
- * The slot's provider defines an account check. Kept beside the definition, not in it, so
2428
- * adding or editing a check never changes the provider's identity.
2429
- */
2430
- health: Schema_exports.optionalKey(Schema_exports.Literal(true))
2431
- })
2432
- )
2433
- });
2434
- var AccountCheckCommand = Schema_exports.Struct({
2435
- operation: Schema_exports.Literal("account-check"),
2436
- requirement: Schema_exports.NonEmptyString
2437
- });
2438
- var HostRequest3 = Schema_exports.Union([
2439
- ...protocol4.schemas.request.members,
2440
- AccountCheckCommand
2441
- ]);
2442
- var HostInvocation3 = Schema_exports.Struct({
2443
- command: HostRequest3,
2444
- accounts: ResolvedAccounts,
2445
- approval: Schema_exports.optionalKey(TrustedToolApproval),
2446
- replay: Schema_exports.optionalKey(WorkflowReplay),
2447
- deadline: Schema_exports.optionalKey(InvocationDeadline),
2448
- workflowRun: Schema_exports.optionalKey(WorkflowRunId)
2449
- });
2450
- var protocol5 = {
2451
- version: 5,
2452
- schemas: {
2453
- ...protocol4.schemas,
2454
- invocation: HostInvocation3,
2455
- request: HostRequest3,
2456
- requirements: DeclaredRequirements2,
2457
- accountCheck: AccountCheckResult
4260
+ cacheReply: CacheReply,
4261
+ accountCheck: AccountCheckResult,
4262
+ accounts: ResolvedAccounts4,
4263
+ migrate: MigrateResult2
2458
4264
  }
2459
4265
  };
2460
4266
 
2461
4267
  // src/contracts/host.ts
4268
+ var HostAccount = Schema_exports.Struct({
4269
+ ...ResolvedAccount4.fields,
4270
+ managed: Schema_exports.optionalKey(Schema_exports.Literal(true))
4271
+ });
4272
+ var HostAccounts = Schema_exports.Record(
4273
+ Schema_exports.NonEmptyString,
4274
+ Schema_exports.Union([HostAccount, Schema_exports.Array(HostAccount)])
4275
+ );
2462
4276
  var skillsCommand = (sources) => sources ? { operation: "skills", sources: true } : { operation: "skills" };
2463
- var skillCatalog = (response) => Schema_exports.is(SkillSources2)(response) ? response : { skills: response };
4277
+ var skillCatalog = (response) => Schema_exports.is(SkillSources3)(response) ? response : { skills: response };
2464
4278
  var inspectCommand = (tools, scheduled) => ({
2465
4279
  operation: "inspect",
2466
4280
  ...tools === void 0 ? {} : { tools: [...tools] },
@@ -2469,44 +4283,44 @@ var inspectCommand = (tools, scheduled) => ({
2469
4283
  var indexCommand = { operation: "inspect", detail: "summary" };
2470
4284
  var selectTools = (tools) => (catalog) => tools === void 0 ? catalog : { ...catalog, tools: catalog.tools.filter((tool) => tools.includes(tool.name)) };
2471
4285
  var HostRequirementsError = Schema_exports.Union([
2472
- HostRequestInvalid,
2473
- HostDeclarationInvalid2,
4286
+ HostRequestInvalid2,
4287
+ HostDeclarationInvalid4,
2474
4288
  DatabaseFieldReserved
2475
4289
  ]);
2476
4290
  var HostInspectError = Schema_exports.Union([
2477
4291
  ProviderError,
2478
- McpError,
2479
- SkillLoadFailed,
2480
- HostRequestInvalid,
2481
- HostDeclarationInvalid2,
2482
- HostAccountsInvalid,
2483
- HostEvaluationFailed2
4292
+ McpError6,
4293
+ SkillLoadFailed3,
4294
+ HostRequestInvalid2,
4295
+ HostDeclarationInvalid4,
4296
+ HostAccountsInvalid2,
4297
+ HostEvaluationFailed4
2484
4298
  ]);
2485
4299
  var HostCallError = Schema_exports.Union([
2486
4300
  OpenapiResponseError,
2487
4301
  WorkflowFailure,
2488
4302
  HostInspectError,
2489
- HostToolNotFound,
2490
- HostOperationNotFound,
2491
- HostKindMismatch,
2492
- HostOperationFailed2,
4303
+ HostToolNotFound2,
4304
+ HostOperationNotFound2,
4305
+ HostKindMismatch2,
4306
+ HostOperationFailed4,
2493
4307
  DatabaseLimitExceeded,
2494
- HostInputInvalid,
2495
- HostOutputInvalid,
2496
- HostToolBlocked,
2497
- HostToolApprovalRequired,
2498
- HostToolPolicyFailed,
4308
+ HostInputInvalid2,
4309
+ HostOutputInvalid2,
4310
+ HostToolBlocked2,
4311
+ HostToolApprovalRequired2,
4312
+ HostToolPolicyFailed2,
2499
4313
  ElicitationFailed
2500
4314
  ]);
2501
4315
  var HostAccountCheckError = Schema_exports.Union([
2502
4316
  ProviderError,
2503
4317
  WorkflowFailure,
2504
- HostRequestInvalid,
2505
- HostDeclarationInvalid2,
2506
- HostAccountsInvalid,
2507
- HostOperationNotFound,
2508
- HostOperationFailed2,
2509
- HostOutputInvalid
4318
+ HostRequestInvalid2,
4319
+ HostDeclarationInvalid4,
4320
+ HostAccountsInvalid2,
4321
+ HostOperationNotFound2,
4322
+ HostOperationFailed4,
4323
+ HostOutputInvalid2
2510
4324
  ]);
2511
4325
  var HostDataError = HostCallError;
2512
4326
  var ToolResultObservation = Context_exports.Reference(
@@ -2514,11 +4328,32 @@ var ToolResultObservation = Context_exports.Reference(
2514
4328
  { defaultValue: () => ({ failed: () => {
2515
4329
  } }) }
2516
4330
  );
4331
+ var InvocationTiming = Schema_exports.Struct({
4332
+ elapsedMs: Schema_exports.Finite,
4333
+ upstreamMs: Schema_exports.Finite,
4334
+ elicitationMs: Schema_exports.Finite,
4335
+ authoredMs: Schema_exports.Finite,
4336
+ /** Waiting on another call that holds the lease to load a cache entry this call needs. */
4337
+ leaseMs: Schema_exports.optionalKey(Schema_exports.Finite),
4338
+ /**
4339
+ * How long background work, such as a stale cache entry's refresh, ran within the invocation.
4340
+ * It runs beside the invocation, so it is not part of the division above.
4341
+ */
4342
+ backgroundMs: Schema_exports.optionalKey(Schema_exports.Finite)
4343
+ });
4344
+ var InvocationTimingSink = Context_exports.Reference(
4345
+ "apps/InvocationTimingSink",
4346
+ { defaultValue: () => () => {
4347
+ } }
4348
+ );
2517
4349
 
2518
4350
  export {
2519
4351
  SecretsMethod,
2520
4352
  OAuthClientAuth,
2521
4353
  OAuthSecretClientAuth,
4354
+ OAuthAuthorizationParams,
4355
+ OAuthTokenRequestFormat,
4356
+ OAuthTokenResponse,
2522
4357
  OAuth2Config,
2523
4358
  OAuth2AccessToken,
2524
4359
  OAuth2Method,
@@ -2526,30 +4361,25 @@ export {
2526
4361
  AccountCheckResult,
2527
4362
  Provider,
2528
4363
  ManyAccounts,
2529
- reservedRouterKeys,
2530
- RouterKey,
2531
- RouterIcon,
2532
- RouterMeta,
2533
- ToolAnnotations,
2534
- McpClientLimits,
2535
- defaultMcpClientLimits,
2536
- mcpSdkTimerCeilingMs,
2537
- McpToolsOptions,
2538
- McpToolResult,
2539
- McpToolMetadata,
2540
- McpServerHeader,
2541
- McpError,
2542
- ProcessConfig,
4364
+ PlacementField,
4365
+ PlacementText,
4366
+ PlacementBase64,
4367
+ PlacementPart,
4368
+ PlacementHeaderName,
4369
+ Placement,
4370
+ Placements,
4371
+ isPlacementField,
4372
+ placementFields,
4373
+ placementKey,
4374
+ normalizePlacements,
4375
+ PlacementFieldMissing,
4376
+ renderPlacement,
4377
+ maxApiErrorInstructionsLength,
2543
4378
  ApiErrorRecovery,
4379
+ maxApiErrorMessageLength,
2544
4380
  ApiErrorResponse,
2545
4381
  OpenapiResponseError,
2546
4382
  defaultOpenapiErrorLimits,
2547
- maxFailureMessageLength,
2548
- FailureSource,
2549
- FailureName,
2550
- FailureCode,
2551
- FailureMessage,
2552
- FailureDetail,
2553
4383
  WorkflowRunId,
2554
4384
  WorkflowName,
2555
4385
  workflowDurationMillis,
@@ -2568,6 +4398,11 @@ export {
2568
4398
  WorkflowRpcCommand,
2569
4399
  WorkflowRpcResult,
2570
4400
  WorkflowControlCommand,
4401
+ DatabaseLimitExceeded,
4402
+ DatabaseFieldReserved,
4403
+ reservedTablePrefix,
4404
+ migrationsDirectory,
4405
+ sqlBindingsLimit,
2571
4406
  ElicitationLimits,
2572
4407
  defaultElicitationLimits,
2573
4408
  FormElicitation,
@@ -2576,7 +4411,25 @@ export {
2576
4411
  ElicitationReply,
2577
4412
  ApprovalElicitation,
2578
4413
  ApprovalResponse,
4414
+ exactApprovalElicitation,
2579
4415
  approvalElicitation,
4416
+ reservedRouterKeys,
4417
+ RouterKey,
4418
+ RouterIcon,
4419
+ RouterMeta,
4420
+ ToolAnnotations2 as ToolAnnotations,
4421
+ McpClientLimits,
4422
+ defaultMcpClientLimits,
4423
+ mcpSdkTimerCeilingMs,
4424
+ McpToolsOptions,
4425
+ McpHealthInput,
4426
+ mcpHealthReserveMs,
4427
+ McpToolResult,
4428
+ McpToolMetadata,
4429
+ McpServerHeader,
4430
+ McpError2 as McpError,
4431
+ McpCredentialsUnverified,
4432
+ ProcessConfig,
2580
4433
  WebhookTransportLimits,
2581
4434
  defaultWebhookTransportLimits,
2582
4435
  WebhookRequestData,
@@ -2585,52 +4438,73 @@ export {
2585
4438
  ManualWebhookDescriptor,
2586
4439
  HostedWebhook,
2587
4440
  WebhookCommand,
4441
+ EventName,
4442
+ EventFilterValue,
4443
+ EventLimits,
4444
+ defaultEventLimits,
4445
+ DeclaredEvent,
4446
+ DeclaredEvents,
4447
+ EmittedEvent,
4448
+ EmittedEvents,
2588
4449
  frameworkProtocol,
2589
- minimumIntervalMilliseconds,
2590
- Interval,
2591
- CalendarSchedule,
2592
- ScheduleTiming,
2593
- OperationSchedule,
2594
- DeclaredAuthMethod,
2595
- DeclaredProvider,
2596
- ResolvedAccount,
2597
- ResolvedAccounts,
2598
- TrustedToolApproval,
2599
- InvocationDeadline,
2600
- HostRequestInvalid,
2601
- HostAccountsInvalid,
2602
- HostOperationNotFound,
2603
- HostToolNotFound,
2604
- InputProblem,
2605
- maxInputProblems,
2606
- HostInputInvalid,
2607
- HostToolBlocked,
2608
- HostToolApprovalRequired,
2609
- HostToolPolicyFailed,
2610
- HostOutputInvalid,
2611
4450
  protocol1,
2612
- SkillSources2 as SkillSources,
2613
- SkillCatalogResponse2 as SkillCatalogResponse,
2614
4451
  protocol2,
2615
- HostDeclarationInvalid2 as HostDeclarationInvalid,
2616
- HostEvaluationFailed2 as HostEvaluationFailed,
2617
- HostOperationFailed2 as HostOperationFailed,
2618
4452
  protocol3,
2619
- HostedTool2 as HostedTool,
2620
- HostedToolSummary2 as HostedToolSummary,
2621
- HostRouterError,
2622
- HostedRouter,
2623
- HostedCatalog,
2624
- HostedCatalogSummary,
2625
- HostKindMismatch,
2626
- HostError3 as HostError,
2627
- HostResponse3 as HostResponse,
2628
4453
  protocol4,
2629
- DeclaredRequirements2 as DeclaredRequirements,
2630
- AccountCheckCommand,
2631
- HostRequest3 as HostRequest,
2632
- HostInvocation3 as HostInvocation,
2633
4454
  protocol5,
4455
+ protocol6,
4456
+ protocol7,
4457
+ protocol8,
4458
+ protocol9,
4459
+ protocol10,
4460
+ minimumIntervalMilliseconds2 as minimumIntervalMilliseconds,
4461
+ Interval,
4462
+ CalendarSchedule2 as CalendarSchedule,
4463
+ ScheduleTiming2 as ScheduleTiming,
4464
+ OperationSchedule2 as OperationSchedule,
4465
+ McpError6 as McpError2,
4466
+ SkillLoadFailed3 as SkillLoadFailed,
4467
+ CredentialHost2 as CredentialHost,
4468
+ DeclaredAuthMethod4 as DeclaredAuthMethod,
4469
+ DeclaredProvider4 as DeclaredProvider,
4470
+ DeclaredRequirements6 as DeclaredRequirements,
4471
+ ResolvedAccount4 as ResolvedAccount,
4472
+ ResolvedAccounts4 as ResolvedAccounts,
4473
+ TrustedToolApproval2 as TrustedToolApproval,
4474
+ InvocationDeadline2 as InvocationDeadline,
4475
+ HostedTool3 as HostedTool,
4476
+ HostedToolSummary3 as HostedToolSummary,
4477
+ HostDeclarationInvalid4 as HostDeclarationInvalid,
4478
+ HostEvaluationFailed4 as HostEvaluationFailed,
4479
+ HostRouterError4 as HostRouterError,
4480
+ HostedRouter4 as HostedRouter,
4481
+ HostedCatalog4 as HostedCatalog,
4482
+ HostedCatalogSummary4 as HostedCatalogSummary,
4483
+ SkillSources3 as SkillSources,
4484
+ SkillCatalogResponse3 as SkillCatalogResponse,
4485
+ AccountCheckCommand2 as AccountCheckCommand,
4486
+ MigrateCommand2 as MigrateCommand,
4487
+ MigrateResult2 as MigrateResult,
4488
+ HostRequest5 as HostRequest,
4489
+ HostRequestInvalid2 as HostRequestInvalid,
4490
+ HostAccountsInvalid2 as HostAccountsInvalid,
4491
+ HostOperationNotFound2 as HostOperationNotFound,
4492
+ HostOperationFailed4 as HostOperationFailed,
4493
+ HostToolNotFound2 as HostToolNotFound,
4494
+ HostKindMismatch2 as HostKindMismatch,
4495
+ InputProblem2 as InputProblem,
4496
+ maxInputProblems2 as maxInputProblems,
4497
+ HostInputInvalid2 as HostInputInvalid,
4498
+ HostToolBlocked2 as HostToolBlocked,
4499
+ HostToolApprovalRequired2 as HostToolApprovalRequired,
4500
+ HostToolPolicyFailed2 as HostToolPolicyFailed,
4501
+ HostOutputInvalid2 as HostOutputInvalid,
4502
+ HostError6 as HostError,
4503
+ HostResponse6 as HostResponse,
4504
+ HostInvocation7 as HostInvocation,
4505
+ current,
4506
+ HostAccount,
4507
+ HostAccounts,
2634
4508
  skillsCommand,
2635
4509
  skillCatalog,
2636
4510
  inspectCommand,
@@ -2641,5 +4515,7 @@ export {
2641
4515
  HostCallError,
2642
4516
  HostAccountCheckError,
2643
4517
  HostDataError,
2644
- ToolResultObservation
4518
+ ToolResultObservation,
4519
+ InvocationTiming,
4520
+ InvocationTimingSink
2645
4521
  };