apps 0.0.1-beta.4 → 0.0.1-beta.6

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 (96) hide show
  1. package/README.md +65 -43
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
  4. package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
  5. package/js/{chunk-WFSQXYUT.js → chunk-5T57N25Q.js} +15 -3
  6. package/js/{chunk-EQB7JMAL.js → chunk-6BSSI67S.js} +8 -8
  7. package/js/{chunk-3M2MEDNL.js → chunk-B3EOZTK3.js} +351 -33
  8. package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
  9. package/js/{chunk-Z5NMEGJN.js → chunk-ECQFRCH4.js} +21 -9
  10. package/js/{chunk-G7ZIRKMK.js → chunk-IJX4CYZO.js} +3 -3
  11. package/js/{chunk-FDNTX5QJ.js → chunk-IPI4MFSN.js} +2 -2
  12. package/js/{chunk-2VPJHFOU.js → chunk-ITM77QPO.js} +28 -9
  13. package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
  14. package/js/{chunk-NQ3OMCA5.js → chunk-KUMBKVJD.js} +2 -2
  15. package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
  16. package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
  17. package/js/chunk-MNMNLXBL.js +507 -0
  18. package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
  19. package/js/{chunk-D47C7KG5.js → chunk-NKLWZJLE.js} +2 -2
  20. package/js/{chunk-DHUDODG5.js → chunk-OE3QQTSB.js} +41 -32
  21. package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
  22. package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
  23. package/js/{chunk-LGIYBDWA.js → chunk-R3EV5FTO.js} +13 -1
  24. package/js/{chunk-5MQZEB6Y.js → chunk-RFVIONFX.js} +29 -12
  25. package/js/{chunk-ZCAMUXSG.js → chunk-RJDDBDSN.js} +3 -3
  26. package/js/{chunk-6VRYO2BG.js → chunk-SB4HEPNJ.js} +191 -170
  27. package/js/chunk-T7GKZBLP.js +209 -0
  28. package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
  29. package/js/{chunk-T2LAZCAD.js → chunk-VFZKSM3T.js} +1 -1
  30. package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
  31. package/js/client.js +10 -10
  32. package/js/contracts.js +52 -16
  33. package/js/effect.js +19 -20
  34. package/js/graphql.js +34 -40
  35. package/js/host.js +19 -20
  36. package/js/index.js +189 -178
  37. package/js/mcp/effect.js +21 -22
  38. package/js/mcp/stdio.js +25 -26
  39. package/js/mcp.js +60 -45
  40. package/js/openapi.js +182 -224
  41. package/js/react.js +3 -3
  42. package/js/skills/effect.js +3 -3
  43. package/js/skills.js +12 -13
  44. package/js/storage/facet.js +4 -4
  45. package/js/ui/auth/contracts.js +2 -2
  46. package/js/ui/auth.js +5 -5
  47. package/js/ui/contracts.js +4 -4
  48. package/js/ui/serving.js +8 -8
  49. package/package.json +1 -1
  50. package/runtime.json +1 -1
  51. package/types/app-data/src/contracts/database.d.ts +33 -6
  52. package/types/app-data/src/implementation/schema.d.ts +2 -17
  53. package/types/apps/src/contracts/app.d.ts +2 -5
  54. package/types/apps/src/contracts/failure.d.ts +25 -0
  55. package/types/apps/src/contracts/host.d.ts +18 -9
  56. package/types/apps/src/contracts/mcp.d.ts +16 -0
  57. package/types/apps/src/contracts/openapi.d.ts +5 -1
  58. package/types/apps/src/contracts/operations.d.ts +0 -5
  59. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  60. package/types/apps/src/contracts/protocols/1.d.ts +15 -1
  61. package/types/apps/src/contracts/protocols/2.d.ts +2 -2
  62. package/types/apps/src/contracts/protocols/3.d.ts +676 -0
  63. package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
  64. package/types/apps/src/contracts/router.d.ts +59 -0
  65. package/types/apps/src/contracts/storage.d.ts +3 -3
  66. package/types/apps/src/contracts/workflows.d.ts +34 -3
  67. package/types/apps/src/graphql.d.ts +1 -3
  68. package/types/apps/src/implementation/account-router.d.ts +12 -0
  69. package/types/apps/src/implementation/app.d.ts +5 -4
  70. package/types/apps/src/implementation/catalog-cache.d.ts +9 -2
  71. package/types/apps/src/implementation/elicitation.d.ts +1 -1
  72. package/types/apps/src/implementation/failure-detail.d.ts +25 -0
  73. package/types/apps/src/implementation/graphql-catalog.d.ts +1 -4
  74. package/types/apps/src/implementation/mcp-catalog.d.ts +1 -4
  75. package/types/apps/src/implementation/mcp-client.d.ts +35 -19
  76. package/types/apps/src/implementation/mcp.d.ts +35 -19
  77. package/types/apps/src/implementation/openapi-compile.d.ts +2 -1
  78. package/types/apps/src/implementation/openapi-source.d.ts +2 -6
  79. package/types/apps/src/implementation/operations.d.ts +26 -3
  80. package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
  81. package/types/apps/src/implementation/router-catalog.d.ts +225 -0
  82. package/types/apps/src/implementation/router.d.ts +59 -0
  83. package/types/apps/src/implementation/schema.d.ts +5 -1
  84. package/types/apps/src/implementation/storage.d.ts +5 -3
  85. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  86. package/types/apps/src/implementation/workflow-context.d.ts +11 -3
  87. package/types/apps/src/index.d.ts +3 -2
  88. package/types/apps/src/mcp-stdio.d.ts +2 -5
  89. package/types/apps/src/mcp.d.ts +5 -4
  90. package/types/apps/src/openapi.d.ts +6 -6
  91. package/js/chunk-PYUYJRSK.js +0 -93
  92. package/js/chunk-SWPD52J7.js +0 -35
  93. package/js/chunk-W7D7WVSY.js +0 -18
  94. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  95. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  96. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Schema_exports
3
- } from "./chunk-FW5HBOIK.js";
3
+ } from "./chunk-CDL5PM2Q.js";
4
4
 
5
5
  // src/contracts/schema.ts
6
6
  var JsonValue = Schema_exports.Json;
@@ -4,7 +4,7 @@ import {
4
4
  fromWeb,
5
5
  layerMergedContext,
6
6
  make2 as make
7
- } from "./chunk-QKHR7BMF.js";
7
+ } from "./chunk-UK573G7W.js";
8
8
  import {
9
9
  Reference,
10
10
  Service,
@@ -17,7 +17,7 @@ import {
17
17
  succeed4 as succeed,
18
18
  toReadableStreamEffect,
19
19
  tryPromise
20
- } from "./chunk-FW5HBOIK.js";
20
+ } from "./chunk-CDL5PM2Q.js";
21
21
  import {
22
22
  __export
23
23
  } from "./chunk-CZ7CSFO4.js";
@@ -1,6 +1,7 @@
1
1
  import {
2
+ JsonObject,
2
3
  ValidationError
3
- } from "./chunk-SATWJKN6.js";
4
+ } from "./chunk-27F7W2LG.js";
4
5
  import {
5
6
  Cause_exports,
6
7
  Effect_exports,
@@ -9,7 +10,7 @@ import {
9
10
  SchemaIssue_exports,
10
11
  SchemaParser_exports,
11
12
  Schema_exports
12
- } from "./chunk-FW5HBOIK.js";
13
+ } from "./chunk-CDL5PM2Q.js";
13
14
 
14
15
  // ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
15
16
  function deepCompareStrict(a, b) {
@@ -1387,6 +1388,16 @@ var jsonSchema = (input) => {
1387
1388
  var storageFieldOf = (schema) => schema[StorageField];
1388
1389
  var id = (table) => wrap(Schema_exports.NonEmptyString, false, { kind: "id", references: table });
1389
1390
  var userId = () => wrap(Schema_exports.NonEmptyString, false, { kind: "userId" });
1391
+ var jsonSchemaDocument = (decoder) => {
1392
+ const imported = importedJsonSchema(decoder);
1393
+ if (imported !== void 0) return Schema_exports.decodeUnknownEffect(JsonObject)(imported);
1394
+ const document = Schema_exports.toJsonSchemaDocument(decoder);
1395
+ return Schema_exports.decodeUnknownEffect(JsonObject)({
1396
+ ...document.schema,
1397
+ $defs: document.definitions,
1398
+ $schema: "https://json-schema.org/draft/2020-12/schema"
1399
+ });
1400
+ };
1390
1401
 
1391
1402
  export {
1392
1403
  decoderOf,
@@ -1411,5 +1422,6 @@ export {
1411
1422
  jsonSchema,
1412
1423
  storageFieldOf,
1413
1424
  id,
1414
- userId
1425
+ userId,
1426
+ jsonSchemaDocument
1415
1427
  };
@@ -2,36 +2,36 @@ import {
2
2
  adaptMcpTools,
3
3
  mcpClient,
4
4
  mcpJsonSchemaValidator
5
- } from "./chunk-2VPJHFOU.js";
5
+ } from "./chunk-ITM77QPO.js";
6
6
  import {
7
7
  accountProviderError,
8
8
  httpProviderError
9
- } from "./chunk-ZJWDMTE3.js";
9
+ } from "./chunk-MKWZPDR6.js";
10
10
  import {
11
11
  McpError,
12
12
  McpToolsOptions,
13
13
  defaultMcpClientLimits
14
- } from "./chunk-3M2MEDNL.js";
14
+ } from "./chunk-B3EOZTK3.js";
15
15
  import {
16
16
  ProviderError
17
- } from "./chunk-W7D7WVSY.js";
17
+ } from "./chunk-R3EV5FTO.js";
18
18
  import {
19
19
  captureTelemetry
20
- } from "./chunk-ZCAMUXSG.js";
20
+ } from "./chunk-RJDDBDSN.js";
21
21
  import {
22
22
  FetchHttpClient_exports
23
- } from "./chunk-HDJH3RPR.js";
23
+ } from "./chunk-57RKNWL2.js";
24
24
  import {
25
25
  HttpClientRequest_exports,
26
26
  HttpClient_exports
27
- } from "./chunk-QKHR7BMF.js";
27
+ } from "./chunk-UK573G7W.js";
28
28
  import {
29
29
  Deferred_exports,
30
30
  Effect_exports,
31
31
  Redacted_exports,
32
32
  Schema_exports,
33
33
  Stream_exports
34
- } from "./chunk-FW5HBOIK.js";
34
+ } from "./chunk-CDL5PM2Q.js";
35
35
 
36
36
  // src/implementation/mcp.ts
37
37
  import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
@@ -1,26 +1,24 @@
1
1
  import {
2
+ DatabaseFieldReserved,
3
+ DatabaseLimitExceeded,
2
4
  DatabaseSchema
3
- } from "./chunk-BMOIAIVR.js";
5
+ } from "./chunk-N7YDVXYJ.js";
4
6
  import {
5
7
  CacheCommand,
6
- CacheReply
7
- } from "./chunk-LGIYBDWA.js";
8
+ CacheReply,
9
+ ProviderError
10
+ } from "./chunk-R3EV5FTO.js";
8
11
  import {
12
+ AppSkillName,
9
13
  AppSkills,
10
14
  SkillLoadFailed
11
- } from "./chunk-YEJOQEII.js";
12
- import {
13
- OpenapiResponseError
14
- } from "./chunk-SWPD52J7.js";
15
- import {
16
- ProviderError
17
- } from "./chunk-W7D7WVSY.js";
15
+ } from "./chunk-JU7VHODU.js";
18
16
  import {
19
17
  AccountId,
20
18
  HttpUrl,
21
19
  JsonObject as JsonObject2,
22
20
  JsonValue
23
- } from "./chunk-SATWJKN6.js";
21
+ } from "./chunk-27F7W2LG.js";
24
22
  import {
25
23
  Any,
26
24
  ArraySchema,
@@ -74,7 +72,31 @@ import {
74
72
  transformOptional,
75
73
  withConstructorDefault,
76
74
  withDefault
77
- } from "./chunk-FW5HBOIK.js";
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
+ });
78
100
 
79
101
  // src/contracts/tools.ts
80
102
  var ToolAnnotations = Schema_exports.Struct({
@@ -128,6 +150,15 @@ var McpToolMetadata = Schema_exports.Struct({
128
150
  annotations: Schema_exports.optional(ToolAnnotations),
129
151
  _meta: Schema_exports.optional(JsonObject2)
130
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
+ });
131
162
  var McpError = class extends Schema_exports.TaggedError()("McpError", {
132
163
  phase: Schema_exports.Literals(["connect", "discover", "call", "schema", "transport"]),
133
164
  reason: Schema_exports.Literals([
@@ -150,6 +181,44 @@ var ProcessConfig = Schema_exports.Struct({
150
181
  )
151
182
  });
152
183
 
184
+ // src/contracts/api-response-error.ts
185
+ var ApiErrorRecovery = Schema_exports.Struct({
186
+ action: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(1024)),
187
+ instructions: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(4096))
188
+ });
189
+ var ApiErrorResponse = Schema_exports.Struct({
190
+ code: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(128)),
191
+ status: Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 400, maximum: 599 })),
192
+ message: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(4096)),
193
+ recovery: Schema_exports.optionalKey(ApiErrorRecovery)
194
+ });
195
+ var OpenapiResponseError = class extends Schema_exports.TaggedError()(
196
+ "OpenapiResponseError",
197
+ ApiErrorResponse.fields
198
+ ) {
199
+ };
200
+ var OpenapiErrorLimits = Schema_exports.Struct({
201
+ maxBodyBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
202
+ readTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
203
+ });
204
+ var defaultOpenapiErrorLimits = OpenapiErrorLimits.make({
205
+ maxBodyBytes: 65536,
206
+ readTimeoutMs: 2e3
207
+ });
208
+
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
+
153
222
  // src/contracts/workflows.ts
154
223
  var WorkflowRunId = Schema_exports.NonEmptyString.pipe(Schema_exports.brand("wfr"));
155
224
  var WorkflowName = Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(200));
@@ -191,7 +260,14 @@ var WorkflowStepOptions = Schema_exports.Struct({
191
260
  ),
192
261
  timeout: Schema_exports.optionalKey(WorkflowDuration)
193
262
  });
263
+ var WorkflowFailureDetail = {
264
+ step: Schema_exports.optionalKey(Schema_exports.String.check(Schema_exports.isMaxLength(200))),
265
+ errorName: Schema_exports.optionalKey(FailureName),
266
+ message: Schema_exports.optionalKey(FailureMessage)
267
+ };
268
+ var WorkflowRunFailure = Schema_exports.Struct(WorkflowFailureDetail);
194
269
  var WorkflowFailure = class extends Schema_exports.TaggedError()("WorkflowFailure", {
270
+ ...WorkflowFailureDetail,
195
271
  reason: Schema_exports.Literals([
196
272
  "unavailable",
197
273
  "not_found",
@@ -239,7 +315,9 @@ var WorkflowRun = Schema_exports.Union([
239
315
  Schema_exports.Struct({
240
316
  ...runFields,
241
317
  status: Schema_exports.Literal("errored"),
242
- error: WorkflowFailure.fields.reason
318
+ error: WorkflowFailure.fields.reason,
319
+ /** The failing step and the app's own error, when the run recorded them. */
320
+ failure: Schema_exports.optionalKey(WorkflowRunFailure)
243
321
  }),
244
322
  Schema_exports.Struct({ ...runFields, status: Schema_exports.Literal("terminated") })
245
323
  ]);
@@ -1819,7 +1897,7 @@ var ManyAccounts = class extends Data_exports.TaggedClass("many") {
1819
1897
  };
1820
1898
 
1821
1899
  // src/contracts/protocol-version.ts
1822
- var frameworkProtocol = 2;
1900
+ var frameworkProtocol = 4;
1823
1901
 
1824
1902
  // src/contracts/schedules.ts
1825
1903
  var minimumIntervalMilliseconds = 6e4;
@@ -1857,6 +1935,27 @@ var OperationSchedule = Schema_exports.Struct({
1857
1935
  });
1858
1936
 
1859
1937
  // src/contracts/protocols/1.ts
1938
+ var WorkflowFailure2 = class extends Schema_exports.TaggedError()("WorkflowFailure", {
1939
+ reason: Schema_exports.Literals([
1940
+ "unavailable",
1941
+ "not_found",
1942
+ "input",
1943
+ "output",
1944
+ "operation",
1945
+ "approval",
1946
+ "credentials",
1947
+ "terminated",
1948
+ "execution",
1949
+ "conflict",
1950
+ "engine"
1951
+ ]),
1952
+ retryable: Schema_exports.Boolean
1953
+ }) {
1954
+ };
1955
+ var WorkflowRpcResult2 = Schema_exports.Union([
1956
+ Schema_exports.Struct({ ok: Schema_exports.Literal(true), value: JsonValue }),
1957
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: WorkflowFailure2 })
1958
+ ]);
1860
1959
  var DeclaredAuthMethod = Schema_exports.Union([
1861
1960
  Schema_exports.Struct({ type: Schema_exports.Literal("secrets"), label: Schema_exports.String, fields: JsonObject2 }),
1862
1961
  Schema_exports.Struct({
@@ -2041,7 +2140,7 @@ var HostError = Schema_exports.Union([
2041
2140
  ProviderError,
2042
2141
  McpError,
2043
2142
  SkillLoadFailed,
2044
- WorkflowFailure,
2143
+ WorkflowFailure2,
2045
2144
  HostRequestInvalid,
2046
2145
  HostAccountsInvalid,
2047
2146
  HostDeclarationInvalid,
@@ -2085,7 +2184,7 @@ var protocol1 = {
2085
2184
  elicitationRequest: FormElicitation,
2086
2185
  elicitationReply: ElicitationReply,
2087
2186
  workflowStep: WorkflowRpcCommand,
2088
- workflowStepReply: WorkflowRpcResult,
2187
+ workflowStepReply: WorkflowRpcResult2,
2089
2188
  workflowControl: WorkflowControlCommand,
2090
2189
  cacheCommand: CacheCommand,
2091
2190
  cacheReply: CacheReply
@@ -2104,8 +2203,198 @@ var protocol2 = {
2104
2203
  schemas: { ...protocol1.schemas, skills: SkillCatalogResponse2 }
2105
2204
  };
2106
2205
 
2107
- // src/contracts/operations.ts
2108
- var OperationToolPrefixes = { query: "queries.", mutate: "mutations." };
2206
+ // src/contracts/protocols/3.ts
2207
+ var HostDeclarationInvalid2 = class extends Schema_exports.TaggedError()(
2208
+ "HostDeclarationInvalid",
2209
+ FailureDetail
2210
+ ) {
2211
+ };
2212
+ var HostEvaluationFailed2 = class extends Schema_exports.TaggedError()(
2213
+ "HostEvaluationFailed",
2214
+ FailureDetail
2215
+ ) {
2216
+ };
2217
+ var HostOperationFailed2 = class extends Schema_exports.TaggedError()(
2218
+ "HostOperationFailed",
2219
+ FailureDetail
2220
+ ) {
2221
+ };
2222
+ var HostError2 = Schema_exports.Union([
2223
+ OpenapiResponseError,
2224
+ ProviderError,
2225
+ McpError,
2226
+ SkillLoadFailed,
2227
+ WorkflowFailure,
2228
+ HostRequestInvalid,
2229
+ HostAccountsInvalid,
2230
+ HostDeclarationInvalid2,
2231
+ HostEvaluationFailed2,
2232
+ HostOperationNotFound,
2233
+ HostOperationFailed2,
2234
+ DatabaseLimitExceeded,
2235
+ DatabaseFieldReserved,
2236
+ HostToolNotFound,
2237
+ HostInputInvalid,
2238
+ HostOutputInvalid,
2239
+ HostToolBlocked,
2240
+ HostToolApprovalRequired,
2241
+ HostToolPolicyFailed,
2242
+ ElicitationFailed
2243
+ ]);
2244
+ var HostResponse2 = Schema_exports.Union([
2245
+ Schema_exports.Struct({
2246
+ ok: Schema_exports.Literal(true),
2247
+ value: JsonValue,
2248
+ toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
2249
+ }),
2250
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError2 })
2251
+ ]);
2252
+ var protocol3 = {
2253
+ version: 3,
2254
+ schemas: {
2255
+ invocation: HostInvocation,
2256
+ request: HostRequest,
2257
+ response: HostResponse2,
2258
+ requirements: DeclaredRequirements,
2259
+ tools: Schema_exports.Array(HostedTool),
2260
+ toolSummaries: Schema_exports.Array(HostedToolSummary),
2261
+ skills: SkillCatalogResponse2,
2262
+ elicitationRequest: FormElicitation,
2263
+ elicitationReply: ElicitationReply,
2264
+ workflowStep: WorkflowRpcCommand,
2265
+ workflowStepReply: WorkflowRpcResult,
2266
+ workflowControl: WorkflowControlCommand,
2267
+ cacheCommand: CacheCommand,
2268
+ cacheReply: CacheReply
2269
+ }
2270
+ };
2271
+
2272
+ // src/contracts/protocols/4.ts
2273
+ var HostedTool2 = Schema_exports.Struct({
2274
+ schedules: Schema_exports.optionalKey(Schema_exports.Array(OperationSchedule)),
2275
+ name: Schema_exports.NonEmptyString,
2276
+ router: Schema_exports.optionalKey(Schema_exports.NonEmptyString),
2277
+ tags: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
2278
+ description: Schema_exports.String,
2279
+ inputSchema: JsonObject2,
2280
+ readOnly: Schema_exports.optionalKey(Schema_exports.Boolean),
2281
+ title: Schema_exports.optionalKey(Schema_exports.String),
2282
+ outputSchema: Schema_exports.optionalKey(JsonObject2),
2283
+ annotations: Schema_exports.optionalKey(ToolAnnotations),
2284
+ _meta: Schema_exports.optionalKey(JsonObject2)
2285
+ });
2286
+ var HostedToolSummary2 = HostedTool2.mapFields(
2287
+ ({ inputSchema: _input, outputSchema: _output, _meta, ...fields }) => fields
2288
+ );
2289
+ var HostRouterError = Schema_exports.Union([
2290
+ ProviderError,
2291
+ McpError,
2292
+ SkillLoadFailed,
2293
+ HostDeclarationInvalid2,
2294
+ HostEvaluationFailed2
2295
+ ]);
2296
+ var HostedRouter = Schema_exports.Struct({
2297
+ path: Schema_exports.String,
2298
+ title: Schema_exports.optionalKey(Schema_exports.String),
2299
+ description: Schema_exports.optionalKey(Schema_exports.String),
2300
+ icons: Schema_exports.optionalKey(Schema_exports.Array(RouterIcon)),
2301
+ tags: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.NonEmptyString, Schema_exports.String)),
2302
+ skill: Schema_exports.optionalKey(AppSkillName),
2303
+ error: Schema_exports.optionalKey(HostRouterError)
2304
+ });
2305
+ var HostedCatalog = Schema_exports.Struct({
2306
+ tools: Schema_exports.Array(HostedTool2),
2307
+ routers: Schema_exports.Array(HostedRouter)
2308
+ });
2309
+ var HostedCatalogSummary = Schema_exports.Struct({
2310
+ tools: Schema_exports.Array(HostedToolSummary2),
2311
+ routers: Schema_exports.Array(HostedRouter)
2312
+ });
2313
+ var ToolKind = Schema_exports.Literals(["query", "mutation"]);
2314
+ var HostRequest2 = Schema_exports.Union([
2315
+ WorkflowCommand,
2316
+ WebhookCommand,
2317
+ Schema_exports.Struct({ operation: Schema_exports.Literal("requirements") }),
2318
+ Schema_exports.Struct({
2319
+ operation: Schema_exports.Literal("inspect"),
2320
+ /** Omit schemas. Only builds that declare the toolIndex capability accept this. */
2321
+ detail: Schema_exports.optionalKey(Schema_exports.Literal("summary")),
2322
+ /** Describe only these tools. Only builds that declare the toolIndex capability accept this. */
2323
+ tools: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.NonEmptyString)),
2324
+ /**
2325
+ * Describe only declared operations that have schedules, without dynamic tool discovery.
2326
+ * Only builds that declare the scheduledTools capability accept this.
2327
+ */
2328
+ scheduled: Schema_exports.optionalKey(Schema_exports.Literal(true))
2329
+ }),
2330
+ Schema_exports.Struct({
2331
+ operation: Schema_exports.Literal("skills"),
2332
+ /** Answer with SkillSources. Only builds that declare the skillSources capability accept this. */
2333
+ sources: Schema_exports.optionalKey(Schema_exports.Literal(true))
2334
+ }),
2335
+ Schema_exports.Struct({
2336
+ operation: Schema_exports.Literal("query"),
2337
+ name: Schema_exports.NonEmptyString,
2338
+ input: JsonValue
2339
+ }),
2340
+ Schema_exports.Struct({
2341
+ operation: Schema_exports.Literal("mutate"),
2342
+ name: Schema_exports.NonEmptyString,
2343
+ input: JsonValue
2344
+ }),
2345
+ Schema_exports.Struct({
2346
+ operation: Schema_exports.Literal("call"),
2347
+ tool: Schema_exports.NonEmptyString,
2348
+ /**
2349
+ * The caller's claim; the bundle rejects a call whose tool has the other kind. The host omits
2350
+ * it for a tool its catalog does not list, and then opens storage for writing.
2351
+ */
2352
+ kind: Schema_exports.optionalKey(ToolKind),
2353
+ input: JsonValue
2354
+ })
2355
+ ]);
2356
+ var HostKindMismatch = class extends Schema_exports.TaggedError()("HostKindMismatch", {
2357
+ tool: Schema_exports.NonEmptyString,
2358
+ requested: ToolKind,
2359
+ actual: ToolKind
2360
+ }) {
2361
+ };
2362
+ var HostError3 = Schema_exports.Union([...HostError2.members, HostKindMismatch]);
2363
+ var HostResponse3 = Schema_exports.Union([
2364
+ Schema_exports.Struct({
2365
+ ok: Schema_exports.Literal(true),
2366
+ value: JsonValue,
2367
+ toolError: Schema_exports.optionalKey(Schema_exports.Literal(true))
2368
+ }),
2369
+ Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: HostError3 })
2370
+ ]);
2371
+ var HostInvocation2 = Schema_exports.Struct({
2372
+ command: HostRequest2,
2373
+ accounts: ResolvedAccounts,
2374
+ approval: Schema_exports.optionalKey(TrustedToolApproval),
2375
+ replay: Schema_exports.optionalKey(WorkflowReplay),
2376
+ deadline: Schema_exports.optionalKey(InvocationDeadline),
2377
+ workflowRun: Schema_exports.optionalKey(WorkflowRunId)
2378
+ });
2379
+ var protocol4 = {
2380
+ version: 4,
2381
+ schemas: {
2382
+ invocation: HostInvocation2,
2383
+ request: HostRequest2,
2384
+ response: HostResponse3,
2385
+ requirements: DeclaredRequirements,
2386
+ catalog: HostedCatalog,
2387
+ catalogSummary: HostedCatalogSummary,
2388
+ skills: SkillCatalogResponse2,
2389
+ elicitationRequest: FormElicitation,
2390
+ elicitationReply: ElicitationReply,
2391
+ workflowStep: WorkflowRpcCommand,
2392
+ workflowStepReply: WorkflowRpcResult,
2393
+ workflowControl: WorkflowControlCommand,
2394
+ cacheCommand: CacheCommand,
2395
+ cacheReply: CacheReply
2396
+ }
2397
+ };
2109
2398
 
2110
2399
  // src/contracts/host.ts
2111
2400
  var skillsCommand = (sources) => sources ? { operation: "skills", sources: true } : { operation: "skills" };
@@ -2116,16 +2405,20 @@ var inspectCommand = (tools, scheduled) => ({
2116
2405
  ...scheduled === void 0 ? {} : { scheduled }
2117
2406
  });
2118
2407
  var indexCommand = { operation: "inspect", detail: "summary" };
2119
- var selectTools = (tools) => (all) => tools === void 0 ? all : all.filter((tool) => tools.includes(tool.name));
2120
- var HostRequirementsError = Schema_exports.Union([HostRequestInvalid, HostDeclarationInvalid]);
2408
+ var selectTools = (tools) => (catalog) => tools === void 0 ? catalog : { ...catalog, tools: catalog.tools.filter((tool) => tools.includes(tool.name)) };
2409
+ var HostRequirementsError = Schema_exports.Union([
2410
+ HostRequestInvalid,
2411
+ HostDeclarationInvalid2,
2412
+ DatabaseFieldReserved
2413
+ ]);
2121
2414
  var HostInspectError = Schema_exports.Union([
2122
2415
  ProviderError,
2123
2416
  McpError,
2124
2417
  SkillLoadFailed,
2125
2418
  HostRequestInvalid,
2126
- HostDeclarationInvalid,
2419
+ HostDeclarationInvalid2,
2127
2420
  HostAccountsInvalid,
2128
- HostEvaluationFailed
2421
+ HostEvaluationFailed2
2129
2422
  ]);
2130
2423
  var HostCallError = Schema_exports.Union([
2131
2424
  OpenapiResponseError,
@@ -2133,7 +2426,9 @@ var HostCallError = Schema_exports.Union([
2133
2426
  HostInspectError,
2134
2427
  HostToolNotFound,
2135
2428
  HostOperationNotFound,
2136
- HostOperationFailed,
2429
+ HostKindMismatch,
2430
+ HostOperationFailed2,
2431
+ DatabaseLimitExceeded,
2137
2432
  HostInputInvalid,
2138
2433
  HostOutputInvalid,
2139
2434
  HostToolBlocked,
@@ -2157,6 +2452,10 @@ export {
2157
2452
  OAuth2Method,
2158
2453
  Provider,
2159
2454
  ManyAccounts,
2455
+ reservedRouterKeys,
2456
+ RouterKey,
2457
+ RouterIcon,
2458
+ RouterMeta,
2160
2459
  ToolAnnotations,
2161
2460
  McpClientLimits,
2162
2461
  defaultMcpClientLimits,
@@ -2164,13 +2463,26 @@ export {
2164
2463
  McpToolsOptions,
2165
2464
  McpToolResult,
2166
2465
  McpToolMetadata,
2466
+ McpServerHeader,
2167
2467
  McpError,
2168
2468
  ProcessConfig,
2469
+ ApiErrorRecovery,
2470
+ ApiErrorResponse,
2471
+ OpenapiResponseError,
2472
+ defaultOpenapiErrorLimits,
2473
+ maxFailureMessageLength,
2474
+ FailureSource,
2475
+ FailureName,
2476
+ FailureCode,
2477
+ FailureMessage,
2478
+ FailureDetail,
2169
2479
  WorkflowRunId,
2170
2480
  WorkflowName,
2171
2481
  workflowDurationMillis,
2172
2482
  WorkflowDuration,
2173
2483
  WorkflowStepOptions,
2484
+ WorkflowFailureDetail,
2485
+ WorkflowRunFailure,
2174
2486
  WorkflowFailure,
2175
2487
  NonRetryableError,
2176
2488
  WorkflowValue,
@@ -2212,15 +2524,9 @@ export {
2212
2524
  ResolvedAccounts,
2213
2525
  TrustedToolApproval,
2214
2526
  InvocationDeadline,
2215
- HostedTool,
2216
- HostedToolSummary,
2217
- HostRequest,
2218
2527
  HostRequestInvalid,
2219
2528
  HostAccountsInvalid,
2220
- HostDeclarationInvalid,
2221
- HostEvaluationFailed,
2222
2529
  HostOperationNotFound,
2223
- HostOperationFailed,
2224
2530
  HostToolNotFound,
2225
2531
  InputProblem,
2226
2532
  maxInputProblems,
@@ -2229,14 +2535,26 @@ export {
2229
2535
  HostToolApprovalRequired,
2230
2536
  HostToolPolicyFailed,
2231
2537
  HostOutputInvalid,
2232
- HostError,
2233
- HostResponse,
2234
- HostInvocation,
2235
2538
  protocol1,
2236
2539
  SkillSources2 as SkillSources,
2237
2540
  SkillCatalogResponse2 as SkillCatalogResponse,
2238
2541
  protocol2,
2239
- OperationToolPrefixes,
2542
+ HostDeclarationInvalid2 as HostDeclarationInvalid,
2543
+ HostEvaluationFailed2 as HostEvaluationFailed,
2544
+ HostOperationFailed2 as HostOperationFailed,
2545
+ protocol3,
2546
+ HostedTool2 as HostedTool,
2547
+ HostedToolSummary2 as HostedToolSummary,
2548
+ HostRouterError,
2549
+ HostedRouter,
2550
+ HostedCatalog,
2551
+ HostedCatalogSummary,
2552
+ HostRequest2 as HostRequest,
2553
+ HostKindMismatch,
2554
+ HostError3 as HostError,
2555
+ HostResponse3 as HostResponse,
2556
+ HostInvocation2 as HostInvocation,
2557
+ protocol4,
2240
2558
  skillsCommand,
2241
2559
  skillCatalog,
2242
2560
  inspectCommand,