apps 0.0.1-beta.5 → 0.0.1-beta.55

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 (188) hide show
  1. package/README.md +68 -44
  2. package/framework-reference.json +1 -1
  3. package/js/chunk-47F7VXST.js +221 -0
  4. package/js/chunk-5FHWNLCI.js +88 -0
  5. package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
  6. package/js/chunk-7UUHJR2Q.js +49 -0
  7. package/js/{chunk-CYYBFC2K.js → chunk-AQU56EPI.js} +9 -5
  8. package/js/chunk-BTSIG4NQ.js +1885 -0
  9. package/js/chunk-CDXQDN7W.js +92 -0
  10. package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
  11. package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
  12. package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
  13. package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
  14. package/js/{chunk-UDDE5KOR.js → chunk-JK5S2N2S.js} +148 -34
  15. package/js/{chunk-RJDDBDSN.js → chunk-JM7LOD2W.js} +628 -85
  16. package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
  17. package/js/{chunk-FWQC6I3C.js → chunk-KGCTYL2S.js} +523 -63
  18. package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
  19. package/js/chunk-L4K2K22P.js +42 -0
  20. package/js/chunk-LTDHQJ2Z.js +171 -0
  21. package/js/chunk-MWKHKOTL.js +240 -0
  22. package/js/chunk-OD3KFKZD.js +1617 -0
  23. package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
  24. package/js/chunk-PXXZ6ABC.js +266 -0
  25. package/js/chunk-QEBRH5AP.js +729 -0
  26. package/js/chunk-TLWLJ7PD.js +4342 -0
  27. package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
  28. package/js/{chunk-XHO2ZX6W.js → chunk-UM62MBJQ.js} +96 -41
  29. package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
  30. package/js/chunk-XCSG7FT7.js +340 -0
  31. package/js/client.js +142 -94
  32. package/js/contracts.js +123 -33
  33. package/js/effect.js +19 -21
  34. package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
  35. package/js/graphql.js +63 -60
  36. package/js/host.js +83 -60
  37. package/js/index.js +262 -222
  38. package/js/mcp/effect.js +23 -23
  39. package/js/mcp/stdio.js +48 -40
  40. package/js/mcp.js +109 -72
  41. package/js/openapi.js +4129 -1419
  42. package/js/react.js +2 -3
  43. package/js/skills/effect.js +6 -3
  44. package/js/skills.js +208 -82
  45. package/js/storage/facet.js +1 -540
  46. package/js/ui/auth/contracts.js +2 -2
  47. package/js/ui/auth.js +5 -5
  48. package/js/ui/contracts.js +5 -4
  49. package/js/ui/serving.js +8517 -214
  50. package/package.json +2 -3
  51. package/runtime.json +1 -1
  52. package/types/app-cache/src/index.d.ts +10 -1
  53. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  54. package/types/apps/src/contracts/app.d.ts +9 -8
  55. package/types/apps/src/contracts/cache.d.ts +20 -0
  56. package/types/apps/src/contracts/context.d.ts +19 -11
  57. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  58. package/types/apps/src/contracts/events.d.ts +93 -0
  59. package/types/apps/src/contracts/failure.d.ts +30 -1
  60. package/types/apps/src/contracts/graphql.d.ts +2 -1
  61. package/types/apps/src/contracts/host.d.ts +57 -18
  62. package/types/apps/src/contracts/live.d.ts +2 -0
  63. package/types/apps/src/contracts/mcp.d.ts +96 -10
  64. package/types/apps/src/contracts/network.d.ts +84 -0
  65. package/types/apps/src/contracts/openapi-compile.d.ts +32 -3
  66. package/types/apps/src/contracts/openapi.d.ts +45 -9
  67. package/types/apps/src/contracts/operations.d.ts +8 -9
  68. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  69. package/types/apps/src/contracts/protocols/1.d.ts +733 -81
  70. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  71. package/types/apps/src/contracts/protocols/2.d.ts +69 -26
  72. package/types/apps/src/contracts/protocols/3.d.ts +133 -33
  73. package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
  74. package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
  75. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  76. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  77. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  78. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  79. package/types/apps/src/contracts/protocols/current.d.ts +2476 -0
  80. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  81. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  82. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  83. package/types/apps/src/contracts/provider.d.ts +115 -10
  84. package/types/apps/src/contracts/router.d.ts +59 -0
  85. package/types/apps/src/contracts/skills.d.ts +50 -13
  86. package/types/apps/src/contracts/sql.d.ts +58 -0
  87. package/types/apps/src/contracts/ui.d.ts +19 -1
  88. package/types/apps/src/contracts/workflows.d.ts +6 -0
  89. package/types/apps/src/facet.d.ts +4 -5
  90. package/types/apps/src/graphql.d.ts +1 -3
  91. package/types/apps/src/host.d.ts +5 -0
  92. package/types/apps/src/implementation/account-router.d.ts +13 -0
  93. package/types/apps/src/implementation/app.d.ts +5 -4
  94. package/types/apps/src/implementation/authoring.d.ts +25 -5
  95. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  96. package/types/apps/src/implementation/cache.d.ts +4 -0
  97. package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
  98. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  99. package/types/apps/src/implementation/events.d.ts +59 -0
  100. package/types/apps/src/implementation/failure-detail.d.ts +25 -3
  101. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  102. package/types/apps/src/implementation/graphql.d.ts +4 -3
  103. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  104. package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
  105. package/types/apps/src/implementation/live.d.ts +2 -2
  106. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  107. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  108. package/types/apps/src/implementation/mcp-client.d.ts +49 -25
  109. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  110. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  111. package/types/apps/src/implementation/mcp.d.ts +52 -25
  112. package/types/apps/src/implementation/network.d.ts +16 -0
  113. package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
  114. package/types/apps/src/implementation/openapi-document.d.ts +46 -19
  115. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  116. package/types/apps/src/implementation/openapi-request.d.ts +10 -2
  117. package/types/apps/src/implementation/openapi-source.d.ts +8 -6
  118. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  119. package/types/apps/src/implementation/operations.d.ts +43 -5
  120. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  121. package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
  122. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  123. package/types/apps/src/implementation/provider.d.ts +19 -5
  124. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  125. package/types/apps/src/implementation/router-catalog.d.ts +223 -0
  126. package/types/apps/src/implementation/router.d.ts +70 -0
  127. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  128. package/types/apps/src/implementation/schema.d.ts +95 -11
  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 +11 -5
  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/workflow-context.d.ts +1 -1
  141. package/types/apps/src/implementation/workflows.d.ts +1 -1
  142. package/types/apps/src/index.d.ts +32 -13
  143. package/types/apps/src/mcp-stdio.d.ts +2 -5
  144. package/types/apps/src/mcp.d.ts +25 -5
  145. package/types/apps/src/openapi.d.ts +6 -6
  146. package/types/apps/src/react.d.ts +1 -1
  147. package/types/apps/src/skills.d.ts +10 -8
  148. package/types/telemetry/src/app-records.d.ts +42 -0
  149. package/types/telemetry/src/browser-operations.d.ts +7 -4
  150. package/types/telemetry/src/browser.d.ts +8 -3
  151. package/types/telemetry/src/config.d.ts +2 -2
  152. package/types/telemetry/src/index.d.ts +1 -0
  153. package/types/telemetry/src/layer.d.ts +2 -2
  154. package/types/telemetry/src/ownership.d.ts +56 -0
  155. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  156. package/types/telemetry/src/relay.d.ts +2 -2
  157. package/types/telemetry/src/transport.d.ts +8 -1
  158. package/types/utils/src/api-error.d.ts +55 -0
  159. package/types/utils/src/connection-failure.d.ts +33 -0
  160. package/types/utils/src/recorded-message.d.ts +18 -0
  161. package/types/utils/src/user-facing-error.d.ts +83 -0
  162. package/js/chunk-3XKZDQLM.js +0 -93
  163. package/js/chunk-4M277YTM.js +0 -136
  164. package/js/chunk-67EVWIGJ.js +0 -224
  165. package/js/chunk-C3VAOK5B.js +0 -215
  166. package/js/chunk-DQAZTA4I.js +0 -2375
  167. package/js/chunk-G7T27IWB.js +0 -63
  168. package/js/chunk-LUVSFETN.js +0 -1347
  169. package/js/chunk-N7YDVXYJ.js +0 -186
  170. package/js/chunk-PJJ24GU7.js +0 -877
  171. package/js/chunk-PZB6T6KU.js +0 -19
  172. package/js/chunk-SB3V4YVR.js +0 -18
  173. package/js/chunk-TDNYXSIX.js +0 -29
  174. package/js/chunk-W4DMKWAB.js +0 -35
  175. package/js/chunk-YEPYT6SD.js +0 -85
  176. package/js/chunk-ZQINWV4W.js +0 -630
  177. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  178. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  179. package/types/app-data/src/implementation/promise.d.ts +0 -68
  180. package/types/app-data/src/implementation/range.d.ts +0 -8
  181. package/types/app-data/src/implementation/schema.d.ts +0 -18
  182. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  183. package/types/app-data/src/index.d.ts +0 -4
  184. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  185. package/types/apps/src/contracts/storage.d.ts +0 -68
  186. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  187. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
  188. package/types/apps/src/implementation/storage.d.ts +0 -15
package/js/index.js CHANGED
@@ -1,21 +1,27 @@
1
1
  import {
2
+ ResponseDecodeError,
3
+ ResponseStatusError,
2
4
  defineApp,
3
- defineDatabase,
4
- table,
5
+ event,
5
6
  workflow
6
- } from "./chunk-C3VAOK5B.js";
7
- import "./chunk-ZQINWV4W.js";
7
+ } from "./chunk-PXXZ6ABC.js";
8
8
  import {
9
- fromPromise,
9
+ dynamicRouter,
10
10
  mutation,
11
11
  nativeOperation,
12
+ nativeRouter,
12
13
  operationDeclaration,
13
14
  query,
14
- withApproval
15
- } from "./chunk-3XKZDQLM.js";
15
+ router,
16
+ routerDeclaration,
17
+ toolAnnotations,
18
+ withApproval,
19
+ withApprovals
20
+ } from "./chunk-47F7VXST.js";
16
21
  import {
17
- accountProviderError
18
- } from "./chunk-G7T27IWB.js";
22
+ accountProviderError,
23
+ fromPromise
24
+ } from "./chunk-LTDHQJ2Z.js";
19
25
  import {
20
26
  CalendarSchedule,
21
27
  ElicitationFailed,
@@ -30,22 +36,21 @@ import {
30
36
  ScheduleTiming,
31
37
  SecretsMethod,
32
38
  WorkflowFailure
33
- } from "./chunk-DQAZTA4I.js";
34
- import "./chunk-N7YDVXYJ.js";
35
- import {
36
- CacheError
37
- } from "./chunk-YEPYT6SD.js";
38
- import "./chunk-JU7VHODU.js";
39
- import "./chunk-W4DMKWAB.js";
39
+ } from "./chunk-TLWLJ7PD.js";
40
40
  import {
41
+ CacheError,
42
+ FetchOptionUnsupported,
43
+ NetworkRefused,
41
44
  ProviderError
42
- } from "./chunk-SB3V4YVR.js";
45
+ } from "./chunk-MWKHKOTL.js";
46
+ import "./chunk-H72MEDMN.js";
43
47
  import {
44
48
  array,
45
49
  boolean,
46
50
  decoderOf,
47
- id,
51
+ fieldExposure,
48
52
  importedJsonSchema,
53
+ isSchema,
49
54
  json,
50
55
  jsonSchema,
51
56
  literal,
@@ -54,42 +59,29 @@ import {
54
59
  object,
55
60
  once,
56
61
  parse,
62
+ plain,
63
+ raw,
57
64
  record,
58
65
  string,
59
- userId,
60
66
  withLazyJsonSchemaDocument,
61
67
  wrap
62
- } from "./chunk-FWQC6I3C.js";
63
- import "./chunk-PZB6T6KU.js";
68
+ } from "./chunk-KGCTYL2S.js";
69
+ import "./chunk-JM7LOD2W.js";
70
+ import "./chunk-PD6I2SDG.js";
71
+ import "./chunk-5FHWNLCI.js";
64
72
  import {
65
73
  JsonObject,
66
74
  JsonValue,
67
75
  ValidationError
68
- } from "./chunk-27F7W2LG.js";
76
+ } from "./chunk-H2CJWXA3.js";
77
+ import "./chunk-TUMGL2OC.js";
78
+ import "./chunk-EOPQ727L.js";
69
79
  import {
70
80
  Effect_exports,
71
81
  Schema_exports
72
- } from "./chunk-CDL5PM2Q.js";
82
+ } from "./chunk-IFJU5SYQ.js";
73
83
  import "./chunk-CZ7CSFO4.js";
74
84
 
75
- // src/contracts/http.ts
76
- var ResponseStatusError = class extends Schema_exports.TaggedError()(
77
- "ResponseStatusError",
78
- { status: Schema_exports.Number }
79
- ) {
80
- get message() {
81
- return `Request failed with status ${this.status}`;
82
- }
83
- };
84
- var ResponseDecodeError = class extends Schema_exports.TaggedError()(
85
- "ResponseDecodeError",
86
- {}
87
- ) {
88
- get message() {
89
- return "Response body did not match the expected schema";
90
- }
91
- };
92
-
93
85
  // src/implementation/http.ts
94
86
  var decodeJson = (response, schema) => Effect_exports.gen(function* () {
95
87
  if (response.status < 200 || response.status >= 300) {
@@ -101,86 +93,101 @@ var decodeJson = (response, schema) => Effect_exports.gen(function* () {
101
93
 
102
94
  // src/implementation/provider.ts
103
95
  var secrets = (options) => new SecretsMethod(options);
104
- var oauth2 = (config, response) => parse(OAuth2Config, config).pipe(Effect_exports.map((config2) => new OAuth2Method({ config: config2, response })));
105
- var defineProvider = (options) => new Provider(options);
96
+ var oauth2 = (config, response, exposure) => parse(OAuth2Config, config).pipe(
97
+ Effect_exports.map(
98
+ (config2) => new OAuth2Method({ config: config2, response, ...exposure === void 0 ? {} : { exposure } })
99
+ )
100
+ );
101
+ var defineProvider = ({
102
+ health,
103
+ ...options
104
+ }) => {
105
+ if (health === void 0) return new Provider(options);
106
+ const run = fromPromise(health, "check");
107
+ return new Provider({ ...options, health: { run } });
108
+ };
106
109
 
107
- // src/implementation/account-operations.ts
108
- var inputDocument = (operation) => {
109
- const imported = importedJsonSchema(operation.input);
110
+ // src/implementation/account-router.ts
111
+ var decoderDocument = (decoder) => {
112
+ const imported = importedJsonSchema(decoder);
110
113
  if (imported !== void 0) return Schema_exports.decodeUnknownSync(JsonObject)(imported);
111
- const document = Schema_exports.toJsonSchemaDocument(operation.input);
114
+ const document = Schema_exports.toJsonSchemaDocument(decoder);
112
115
  return Schema_exports.decodeUnknownSync(JsonObject)({ ...document.schema, $defs: document.definitions });
113
116
  };
114
117
  var declaresOutput = (operation) => {
118
+ if (operation.output !== void 0) return true;
115
119
  const property = Object.getOwnPropertyDescriptor(operation, "outputSchema");
116
120
  return property !== void 0 && (property.get !== void 0 || property.value !== void 0);
117
121
  };
118
- var combine = (kind, groups) => Object.fromEntries(
119
- [...groups].map(([name, accounts]) => {
120
- const variants = [...accounts.values()];
121
- const first = variants[0];
122
- if (first === void 0)
123
- throw new Error("An account operation must have at least one account");
124
- const select = (input2) => {
125
- const operation = accounts.get(input2.accountId);
126
- if (operation === void 0)
127
- throw new Error("Account selection must be decoded before execution");
128
- return operation;
129
- };
130
- const input = Schema_exports.Union(
131
- [...accounts].map(
132
- ([accountId, operation]) => Schema_exports.Struct({ accountId: Schema_exports.Literal(accountId), input: operation.input })
133
- )
134
- );
135
- const inputSchema = () => ({
122
+ var outputDocument = (operation) => operation.output === void 0 ? operation.outputSchema : decoderDocument(operation.output);
123
+ var combineOperation = (accounts) => {
124
+ const variants = [...accounts.values()];
125
+ const first = variants[0];
126
+ if (first === void 0) throw new Error("An account operation must have at least one account");
127
+ const kind = variants.every((operation) => operation.kind === "query") ? "query" : "mutation";
128
+ const select = (input2) => {
129
+ const operation = accounts.get(input2.accountId);
130
+ if (operation === void 0)
131
+ throw new Error("Account selection must be decoded before execution");
132
+ return operation;
133
+ };
134
+ const input = Schema_exports.Union(
135
+ [...accounts].map(
136
+ ([accountId, operation]) => Schema_exports.Struct({ accountId: Schema_exports.Literal(accountId), input: operation.input })
137
+ )
138
+ );
139
+ const inputSchema = () => ({
140
+ type: "object",
141
+ anyOf: [...accounts].map(([accountId, operation], index) => ({
136
142
  type: "object",
137
- anyOf: [...accounts].map(([accountId, operation], index) => ({
138
- type: "object",
139
- properties: {
140
- accountId: { type: "string", const: accountId },
141
- input: nestJsonSchema(inputDocument(operation), `#/anyOf/${index}/properties/input`)
142
- },
143
- required: ["accountId", "input"]
144
- }))
145
- });
146
- const declaration2 = operationDeclaration({
147
- kind,
148
- ...first.description === void 0 ? {} : { description: first.description },
149
- ...first.title === void 0 ? {} : { title: first.title },
150
- ...first.annotations === void 0 || !variants.every(
151
- (operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
152
- ) ? {} : { annotations: first.annotations },
153
- ...first._meta === void 0 || !variants.every(
154
- (operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)
155
- ) ? {} : { _meta: first._meta },
156
- input: withLazyJsonSchemaDocument(input, inputSchema),
157
- approval: (context) => {
158
- const operation = select(context.toolInput);
159
- return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
143
+ properties: {
144
+ accountId: { type: "string", const: accountId },
145
+ input: nestJsonSchema(
146
+ decoderDocument(operation.input),
147
+ `#/anyOf/${index}/properties/input`
148
+ )
160
149
  },
161
- run: (context, input2) => {
162
- const operation = select(input2);
163
- return operation.run(context, input2.input).pipe(
164
- Effect_exports.mapError((error) => accountProviderError(error, input2.accountId)),
165
- Effect_exports.flatMap(
166
- (output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
167
- )
168
- );
169
- }
170
- });
171
- if (variants.every(declaresOutput)) {
172
- const outputSchema = once(() => ({
173
- anyOf: variants.flatMap(
174
- (operation) => operation.outputSchema === void 0 ? [] : [operation.outputSchema]
175
- ).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
176
- }));
177
- const native = nativeOperation(declaration2);
178
- if (native !== void 0)
179
- Object.defineProperty(native, "outputSchema", { enumerable: true, get: outputSchema });
150
+ required: ["accountId", "input"]
151
+ }))
152
+ });
153
+ const declaration2 = operationDeclaration({
154
+ kind,
155
+ ...first.description === void 0 ? {} : { description: first.description },
156
+ ...first.title === void 0 ? {} : { title: first.title },
157
+ ...first.annotations === void 0 || !variants.every(
158
+ (operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
159
+ ) ? {} : { annotations: first.annotations },
160
+ ...first._meta === void 0 || !variants.every((operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)) ? {} : { _meta: first._meta },
161
+ input: withLazyJsonSchemaDocument(input, inputSchema),
162
+ approval: (context) => {
163
+ const operation = select(context.toolInput);
164
+ return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
165
+ },
166
+ run: (context, input2) => {
167
+ const operation = select(input2);
168
+ return operation.run(context, input2.input).pipe(
169
+ Effect_exports.mapError((error) => accountProviderError(error, input2.accountId)),
170
+ Effect_exports.flatMap(
171
+ (output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
172
+ )
173
+ );
180
174
  }
181
- return [name, declaration2];
182
- })
183
- );
175
+ });
176
+ if (variants.every(declaresOutput)) {
177
+ const outputSchema = once(() => ({
178
+ anyOf: variants.flatMap((operation) => {
179
+ const output = outputDocument(operation);
180
+ return output === void 0 ? [] : [output];
181
+ }).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
182
+ }));
183
+ const native2 = nativeOperation(declaration2);
184
+ if (native2 !== void 0)
185
+ Object.defineProperty(native2, "outputSchema", { enumerable: true, get: outputSchema });
186
+ }
187
+ const native = nativeOperation(declaration2);
188
+ if (native === void 0) throw new Error("Expected a combined operation");
189
+ return native;
190
+ };
184
191
  var sameAcross = (key, variants) => {
185
192
  const first = variants[0]?.[1][key];
186
193
  return first !== void 0 && variants.every(([, tool]) => JSON.stringify(tool[key]) === JSON.stringify(first)) ? { [key]: first } : {};
@@ -192,7 +199,7 @@ var mergeSummary = (name, variants) => {
192
199
  name,
193
200
  description: first.description,
194
201
  ...first.title === void 0 ? {} : { title: first.title },
195
- readOnly: name.startsWith("queries."),
202
+ readOnly: variants.every(([, tool]) => tool.readOnly === true),
196
203
  ...sameAcross("annotations", variants)
197
204
  });
198
205
  };
@@ -218,115 +225,126 @@ var merge = (name, variants) => Schema_exports.decodeUnknownSync(HostedTool)({
218
225
  } : {},
219
226
  ...sameAcross("_meta", variants)
220
227
  });
221
- var accountOperations = (accounts, discover, options) => Effect_exports.runPromise(
228
+ var combineDynamic = (sources) => {
229
+ const first = [...sources.values()][0];
230
+ const grouped = (read) => Effect_exports.gen(function* () {
231
+ const groups = /* @__PURE__ */ new Map();
232
+ for (const [accountId, source] of sources) {
233
+ const tools = yield* read(source).pipe(
234
+ Effect_exports.mapError((error) => accountProviderError(error, accountId))
235
+ );
236
+ for (const tool of tools) {
237
+ const variants = groups.get(tool.name) ?? [];
238
+ if (variants.some(([id]) => id === accountId))
239
+ return yield* Effect_exports.die(new Error("Duplicate source operation"));
240
+ variants.push([accountId, tool]);
241
+ groups.set(tool.name, variants);
242
+ }
243
+ }
244
+ return groups;
245
+ });
246
+ return {
247
+ kind: "dynamic",
248
+ // Accounts share one source, so the first account describes the router.
249
+ ...first?.meta === void 0 ? {} : { meta: first.meta },
250
+ ...first?.overrides === void 0 ? {} : { overrides: first.overrides },
251
+ list: () => grouped((source) => source.list()).pipe(
252
+ Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
253
+ ),
254
+ summaries: () => grouped(
255
+ (source) => source.summaries === void 0 ? source.list() : source.summaries()
256
+ ).pipe(
257
+ Effect_exports.map((groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants)))
258
+ ),
259
+ describe: (name) => Effect_exports.gen(function* () {
260
+ const variants = [];
261
+ for (const [accountId, source] of sources) {
262
+ const tool = yield* (source.describe === void 0 ? source.list().pipe(Effect_exports.map((tools) => tools.find((tool2) => tool2.name === name))) : source.describe(name)).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
263
+ if (tool !== void 0) variants.push([accountId, tool]);
264
+ }
265
+ return variants.length === 0 ? void 0 : merge(name, variants);
266
+ }),
267
+ resolve: (name) => Effect_exports.gen(function* () {
268
+ const operations = /* @__PURE__ */ new Map();
269
+ for (const [accountId, source] of sources) {
270
+ const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
271
+ if (operation !== void 0) operations.set(accountId, operation);
272
+ }
273
+ return operations.size === 0 ? void 0 : combineOperation(operations);
274
+ })
275
+ };
276
+ };
277
+ var combineNode = (variants) => {
278
+ const nodes = [...variants.values()];
279
+ const first = nodes[0];
280
+ if (first === void 0) throw new Error("An account operation must have at least one account");
281
+ switch (first.kind) {
282
+ case "query":
283
+ case "mutation":
284
+ return combineOperation(
285
+ narrow(
286
+ variants,
287
+ (node) => node.kind === "query" || node.kind === "mutation"
288
+ )
289
+ );
290
+ case "dynamic":
291
+ return combineDynamic(
292
+ narrow(variants, (node) => node.kind === "dynamic")
293
+ );
294
+ case "router": {
295
+ const routers = narrow(variants, (node) => node.kind === "router");
296
+ const keys = new Set([...routers.values()].flatMap((router2) => Object.keys(router2.children)));
297
+ return {
298
+ kind: "router",
299
+ ...first.meta === void 0 ? {} : { meta: first.meta },
300
+ children: Object.fromEntries(
301
+ [...keys].map((key) => {
302
+ const children = /* @__PURE__ */ new Map();
303
+ for (const [accountId, router2] of routers) {
304
+ const child = Object.hasOwn(router2.children, key) ? router2.children[key] : void 0;
305
+ if (child !== void 0) children.set(accountId, child);
306
+ }
307
+ return [key, combineNode(children)];
308
+ })
309
+ )
310
+ };
311
+ }
312
+ }
313
+ };
314
+ var narrow = (variants, is) => {
315
+ const narrowed = /* @__PURE__ */ new Map();
316
+ for (const [accountId, node] of variants) {
317
+ if (!is(node)) throw new Error("Each account's router must have the same shape");
318
+ narrowed.set(accountId, node);
319
+ }
320
+ return narrowed;
321
+ };
322
+ var accountRouter = (accounts, discover, options) => Effect_exports.runPromise(
222
323
  Effect_exports.gen(function* () {
223
- const queries = /* @__PURE__ */ new Map();
224
- const mutations = /* @__PURE__ */ new Map();
225
- const sources = /* @__PURE__ */ new Map();
324
+ const routers = /* @__PURE__ */ new Map();
226
325
  for (const account of accounts) {
227
- const operations = yield* Effect_exports.tryPromise({
228
- try: () => discover(account),
326
+ const declaration2 = yield* Effect_exports.tryPromise({
327
+ try: async () => discover(account),
229
328
  catch: (error) => accountProviderError(error, account.id)
230
329
  });
231
- if (sources.has(account.id))
330
+ if (routers.has(account.id))
232
331
  return yield* Effect_exports.die(new Error("Account selections must be unique"));
233
- if (operations.dynamicTools !== void 0) sources.set(account.id, operations.dynamicTools);
234
- for (const [source, target] of [
235
- [operations.queries, queries],
236
- [operations.mutations, mutations]
237
- ]) {
238
- for (const [name, declaration2] of Object.entries(source ?? {})) {
239
- const operation = nativeOperation(declaration2);
240
- if (operation === void 0)
241
- return yield* Effect_exports.die(new Error("Expected a protocol operation"));
242
- const group = target.get(name) ?? /* @__PURE__ */ new Map();
243
- if (group.has(account.id))
244
- return yield* Effect_exports.die(new Error("Account selections must be unique"));
245
- group.set(account.id, operation);
246
- target.set(name, group);
247
- }
248
- }
332
+ const router2 = nativeRouter(declaration2);
333
+ if (router2 === void 0) return yield* Effect_exports.die(new Error("Expected a protocol router"));
334
+ routers.set(account.id, router2);
249
335
  }
250
- const declared = {
251
- queries: combine("query", queries),
252
- mutations: combine("mutation", mutations)
253
- };
254
- if (sources.size === 0) return declared;
255
- const grouped = (read) => Effect_exports.gen(function* () {
256
- const groups = /* @__PURE__ */ new Map();
257
- for (const [accountId, source] of sources) {
258
- const tools = yield* read(source).pipe(
259
- Effect_exports.mapError((error) => accountProviderError(error, accountId))
260
- );
261
- for (const tool of tools) {
262
- const variants = groups.get(tool.name) ?? [];
263
- if (variants.some(([id2]) => id2 === accountId))
264
- return yield* Effect_exports.die(new Error("Duplicate source operation"));
265
- variants.push([accountId, tool]);
266
- groups.set(tool.name, variants);
267
- }
268
- }
269
- return groups;
270
- });
271
- return {
272
- ...declared,
273
- dynamicTools: {
274
- list: () => grouped((source) => source.list()).pipe(
275
- Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
276
- ),
277
- summaries: () => grouped(
278
- (source) => source.summaries === void 0 ? source.list() : source.summaries()
279
- ).pipe(
280
- Effect_exports.map(
281
- (groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants))
282
- )
283
- ),
284
- describe: (name) => Effect_exports.gen(function* () {
285
- const variants = [];
286
- for (const [accountId, source] of sources) {
287
- const tool = yield* (source.describe === void 0 ? source.list().pipe(Effect_exports.map((tools) => tools.find((tool2) => tool2.name === name))) : source.describe(name)).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
288
- if (tool !== void 0) variants.push([accountId, tool]);
289
- }
290
- return variants.length === 0 ? void 0 : merge(name, variants);
291
- }),
292
- resolve: (name) => Effect_exports.gen(function* () {
293
- const kind = name.startsWith("queries.") ? "query" : "mutation";
294
- const operations = /* @__PURE__ */ new Map();
295
- for (const [accountId, source] of sources) {
296
- const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
297
- if (operation !== void 0) {
298
- if (operation.kind !== kind)
299
- return yield* Effect_exports.die(new Error("Operation kind changed"));
300
- operations.set(accountId, operation);
301
- }
302
- }
303
- if (operations.size === 0) return void 0;
304
- return nativeOperation(combine(kind, /* @__PURE__ */ new Map([[name, operations]]))[name]);
305
- })
306
- }
307
- };
336
+ if (routers.size === 0) return routerDeclaration({ kind: "router", children: {} });
337
+ const combined = combineNode(routers);
338
+ if (combined.kind !== "router" && combined.kind !== "dynamic")
339
+ return yield* Effect_exports.die(new Error("Expected a protocol router"));
340
+ return routerDeclaration(combined);
308
341
  }),
309
342
  options
310
343
  );
311
344
 
312
- // src/implementation/dynamic-tools.ts
313
- var dynamicTools = (source) => ({
314
- list: () => fromPromise(source.list)().pipe(
315
- Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedTool)))
316
- ),
317
- resolve: (name) => fromPromise(source.resolve)(name).pipe(
318
- Effect_exports.map((value) => {
319
- if (value === void 0) return void 0;
320
- const operation = nativeOperation(value);
321
- if (operation === void 0) throw new Error("Expected an operation declaration");
322
- return operation;
323
- })
324
- )
325
- });
326
-
327
345
  // src/implementation/dynamic-skills.ts
328
346
  var dynamicSkills = (source) => ({
329
- list: fromPromise(async () => source.list())
347
+ list: fromPromise(async () => source.list(), "skills")
330
348
  });
331
349
 
332
350
  // src/contracts/app.ts
@@ -365,21 +383,39 @@ var cron = (calendar, operation, input) => declaration(
365
383
  );
366
384
 
367
385
  // src/index.ts
386
+ var isFields = (value) => typeof value === "object" && value !== null && Object.values(value).every(isSchema);
387
+ var accountDecoder = (schema) => (
388
+ // SAFETY: the brand exists only in types; secret values are strings at runtime.
389
+ decoderOf(schema)
390
+ );
391
+ var exposureOf = (schema) => {
392
+ const marked = "fields" in schema && isFields(schema.fields) ? fieldExposure(schema.fields) : {};
393
+ return Object.keys(marked).length === 0 ? {} : { exposure: marked };
394
+ };
368
395
  var OAuth2AccessToken2 = wrap(OAuth2AccessToken, false);
369
- var secrets2 = (options) => secrets({ label: options.label, fields: decoderOf(options.fields) });
396
+ var secrets2 = (options) => secrets({
397
+ label: options.label,
398
+ fields: accountDecoder(options.fields),
399
+ ...exposureOf(options.fields)
400
+ });
370
401
  function oauth22(options) {
371
402
  const { response = OAuth2AccessToken2, ...config } = options;
372
- return Effect_exports.runSync(oauth2(config, decoderOf(response)));
403
+ return Effect_exports.runSync(
404
+ oauth2(config, accountDecoder(response), exposureOf(response).exposure)
405
+ );
373
406
  }
374
407
  var decodeJson2 = (response, schema) => {
375
408
  const native = {
376
409
  status: response.status,
377
- json: () => Effect_exports.tryPromise({
378
- try: () => response.json(),
379
- catch: (error) => error
380
- }).pipe(
381
- Effect_exports.catch(
382
- (error) => error instanceof SyntaxError ? Effect_exports.fail(new ResponseDecodeError()) : Effect_exports.die(error)
410
+ json: () => (
411
+ // oxlint-disable-next-line executor/authored-code-through-adapter -- a Response the app passes from its own code
412
+ Effect_exports.tryPromise({
413
+ try: () => response.json(),
414
+ catch: (error) => error
415
+ }).pipe(
416
+ Effect_exports.catch(
417
+ (error) => error instanceof SyntaxError ? Effect_exports.fail(new ResponseDecodeError()) : Effect_exports.die(error)
418
+ )
383
419
  )
384
420
  )
385
421
  };
@@ -388,6 +424,8 @@ var decodeJson2 = (response, schema) => {
388
424
  export {
389
425
  CacheError,
390
426
  ElicitationFailed,
427
+ FetchOptionUnsupported,
428
+ NetworkRefused,
391
429
  NonRetryableError,
392
430
  NotImplemented,
393
431
  OAuth2AccessToken2 as OAuth2AccessToken,
@@ -396,17 +434,16 @@ export {
396
434
  ResponseStatusError,
397
435
  ValidationError,
398
436
  WorkflowFailure,
399
- accountOperations,
437
+ accountRouter,
400
438
  array,
401
439
  boolean,
402
440
  cron,
403
441
  decodeJson2 as decodeJson,
404
442
  defineApp,
405
- defineDatabase,
406
443
  defineProvider,
444
+ dynamicRouter,
407
445
  dynamicSkills,
408
- dynamicTools,
409
- id,
446
+ event,
410
447
  interval,
411
448
  json,
412
449
  jsonSchema,
@@ -415,12 +452,15 @@ export {
415
452
  number,
416
453
  oauth22 as oauth2,
417
454
  object,
455
+ plain,
418
456
  query,
457
+ raw,
419
458
  record,
459
+ router,
420
460
  secrets2 as secrets,
421
461
  string,
422
- table,
423
- userId,
462
+ toolAnnotations,
424
463
  withApproval,
464
+ withApprovals,
425
465
  workflow
426
466
  };
package/js/mcp/effect.js CHANGED
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  mcpClientEffect,
3
+ mcpHealthEffect,
3
4
  mcpToolsEffect
4
- } from "../chunk-67EVWIGJ.js";
5
- import "../chunk-UDDE5KOR.js";
5
+ } from "../chunk-XCSG7FT7.js";
6
+ import "../chunk-JK5S2N2S.js";
6
7
  import "../chunk-BCSNKUAC.js";
7
- import "../chunk-LUVSFETN.js";
8
- import "../chunk-CYYBFC2K.js";
9
- import "../chunk-IPI4MFSN.js";
10
- import "../chunk-4M277YTM.js";
11
- import "../chunk-C3VAOK5B.js";
12
- import "../chunk-ZQINWV4W.js";
13
- import "../chunk-3XKZDQLM.js";
14
- import "../chunk-G7T27IWB.js";
15
- import "../chunk-DQAZTA4I.js";
16
- import "../chunk-N7YDVXYJ.js";
17
- import "../chunk-YEPYT6SD.js";
18
- import "../chunk-JU7VHODU.js";
19
- import "../chunk-W4DMKWAB.js";
20
- import "../chunk-SB3V4YVR.js";
21
- import "../chunk-RJDDBDSN.js";
22
- import "../chunk-57RKNWL2.js";
23
- import "../chunk-UK573G7W.js";
24
- import "../chunk-FWQC6I3C.js";
25
- import "../chunk-PZB6T6KU.js";
26
- import "../chunk-27F7W2LG.js";
27
- import "../chunk-CDL5PM2Q.js";
8
+ import "../chunk-BTSIG4NQ.js";
9
+ import "../chunk-AQU56EPI.js";
10
+ import "../chunk-QEBRH5AP.js";
11
+ import "../chunk-7UUHJR2Q.js";
12
+ import "../chunk-XBG7HHXC.js";
13
+ import "../chunk-PXXZ6ABC.js";
14
+ import "../chunk-47F7VXST.js";
15
+ import "../chunk-LTDHQJ2Z.js";
16
+ import "../chunk-TLWLJ7PD.js";
17
+ import "../chunk-MWKHKOTL.js";
18
+ import "../chunk-H72MEDMN.js";
19
+ import "../chunk-KGCTYL2S.js";
20
+ import "../chunk-JM7LOD2W.js";
21
+ import "../chunk-PD6I2SDG.js";
22
+ import "../chunk-5FHWNLCI.js";
23
+ import "../chunk-H2CJWXA3.js";
24
+ import "../chunk-TUMGL2OC.js";
25
+ import "../chunk-EOPQ727L.js";
26
+ import "../chunk-IFJU5SYQ.js";
28
27
  import "../chunk-CZ7CSFO4.js";
29
28
  export {
30
29
  mcpClientEffect,
30
+ mcpHealthEffect,
31
31
  mcpToolsEffect
32
32
  };