apps 0.0.1-beta.34 → 0.0.1-beta.36

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 (91) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/{chunk-OX233L7N.js → chunk-4U2VUDET.js} +2 -2
  3. package/js/{chunk-HW3DPBZR.js → chunk-556EWA6P.js} +3 -2
  4. package/js/{chunk-UMCMZFXW.js → chunk-73AV3JVU.js} +1 -1
  5. package/js/{chunk-QKVZGWGZ.js → chunk-A2NN45C7.js} +7 -7
  6. package/js/{chunk-6ZJ2H6P4.js → chunk-A4O72Z3A.js} +298 -190
  7. package/js/{chunk-FBBXFFFJ.js → chunk-BI45HZWM.js} +2 -2
  8. package/js/{chunk-DXGWKNTQ.js → chunk-BI6R577B.js} +2 -2
  9. package/js/{chunk-QUEPZ67T.js → chunk-BKJDZYK7.js} +3 -3
  10. package/js/{chunk-QZD2RZ4S.js → chunk-CZLCA2O4.js} +8 -8
  11. package/js/{chunk-IU6OK5G2.js → chunk-ENJCQWVF.js} +3 -3
  12. package/js/{chunk-DASNNAP4.js → chunk-HDAQBRT5.js} +391 -14
  13. package/js/{chunk-EXGKN554.js → chunk-IJQ5LE74.js} +9805 -9254
  14. package/js/{chunk-5JVNM3CQ.js → chunk-IU7CCCUC.js} +12 -12
  15. package/js/{chunk-Q7Q5JTRW.js → chunk-JU7F4PRK.js} +2 -2
  16. package/js/{chunk-CJY5X26R.js → chunk-KOOJUMLR.js} +86 -50
  17. package/js/{chunk-ETLILMHY.js → chunk-KZFV3WCJ.js} +21 -19
  18. package/js/{chunk-ZOY7PDMI.js → chunk-NHCFIWN5.js} +1 -1
  19. package/js/chunk-NHUHTWAF.js +0 -0
  20. package/js/{chunk-QYM4STZW.js → chunk-PHO7HXTC.js} +149 -353
  21. package/js/{chunk-O3OAFU7Q.js → chunk-POOIHRPF.js} +2 -2
  22. package/js/{chunk-AUFVX4KM.js → chunk-RSNZDT4L.js} +2 -2
  23. package/js/{chunk-EPUWF4ZG.js → chunk-SRB2WDU7.js} +3 -3
  24. package/js/{chunk-MFHUR5SB.js → chunk-TADLIUEU.js} +4 -4
  25. package/js/{chunk-5OM6HBNU.js → chunk-UBAKWXAJ.js} +20 -29
  26. package/js/chunk-V5DWGYRK.js +268 -0
  27. package/js/{chunk-MYH3QZ4L.js → chunk-WAGGHNWH.js} +23 -15
  28. package/js/{chunk-GZ4UHXRT.js → chunk-WDBUOIWV.js} +3 -3
  29. package/js/{chunk-PUBNIORL.js → chunk-WMVTBHGK.js} +2 -2
  30. package/js/{chunk-DSUKW6KJ.js → chunk-XEXUHXC3.js} +296 -174
  31. package/js/{chunk-6KG4DZD7.js → chunk-Y3XN4X4Q.js} +1 -1
  32. package/js/{chunk-UKMIHP2G.js → chunk-YW333DH3.js} +4 -4
  33. package/js/{chunk-O4QOPXQT.js → chunk-ZQWDOHEO.js} +31 -24
  34. package/js/client.js +12 -11
  35. package/js/contracts.js +14 -11
  36. package/js/effect.js +23 -21
  37. package/js/graphql.js +25 -23
  38. package/js/host.js +23 -21
  39. package/js/index.js +16 -14
  40. package/js/mcp/effect.js +25 -23
  41. package/js/mcp/stdio.js +25 -23
  42. package/js/mcp.js +27 -25
  43. package/js/openapi.js +22 -21
  44. package/js/react.js +3 -3
  45. package/js/skills/effect.js +6 -5
  46. package/js/skills.js +60 -45
  47. package/js/storage/facet.js +19 -345
  48. package/js/ui/auth/contracts.js +2 -2
  49. package/js/ui/auth.js +5 -5
  50. package/js/ui/contracts.js +6 -5
  51. package/js/ui/serving.js +10 -9
  52. package/package.json +3 -3
  53. package/runtime.json +1 -1
  54. package/types/app-data/src/implementation/sqlite.d.ts +1 -1
  55. package/types/apps/src/contracts/elicitation.d.ts +6 -6
  56. package/types/apps/src/contracts/host.d.ts +10 -6
  57. package/types/apps/src/contracts/mcp.d.ts +6 -1
  58. package/types/apps/src/contracts/openapi.d.ts +1 -1
  59. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  60. package/types/apps/src/contracts/protocols/1.d.ts +12 -5
  61. package/types/apps/src/contracts/protocols/2.d.ts +5 -5
  62. package/types/apps/src/contracts/protocols/3.d.ts +5 -6
  63. package/types/apps/src/contracts/protocols/4.d.ts +5 -6
  64. package/types/apps/src/contracts/protocols/5.d.ts +7 -7
  65. package/types/apps/src/contracts/protocols/6.d.ts +7 -7
  66. package/types/apps/src/contracts/protocols/7.d.ts +7 -7
  67. package/types/apps/src/contracts/protocols/8.d.ts +17 -6
  68. package/types/apps/src/contracts/protocols/9.d.ts +1106 -0
  69. package/types/apps/src/contracts/skills.d.ts +5 -0
  70. package/types/apps/src/contracts/ui.d.ts +1 -1
  71. package/types/apps/src/implementation/failure-detail.d.ts +4 -3
  72. package/types/apps/src/implementation/live.d.ts +2 -2
  73. package/types/apps/src/implementation/mcp-client.d.ts +1 -1
  74. package/types/apps/src/implementation/mcp.d.ts +1 -1
  75. package/types/apps/src/implementation/network.d.ts +1 -1
  76. package/types/apps/src/implementation/openapi-compile.d.ts +1 -1
  77. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  78. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  79. package/types/apps/src/implementation/router-catalog.d.ts +2 -3
  80. package/types/apps/src/implementation/skills.d.ts +8 -8
  81. package/types/apps/src/implementation/ui-auth.d.ts +1 -1
  82. package/types/apps/src/implementation/ui-client.d.ts +1 -1
  83. package/types/apps/src/implementation/ui-serving.d.ts +1 -1
  84. package/types/apps/src/react.d.ts +1 -1
  85. package/types/apps/src/skills.d.ts +2 -1
  86. package/types/telemetry/src/browser-operations.d.ts +1 -1
  87. package/types/telemetry/src/browser.d.ts +2 -2
  88. package/types/telemetry/src/layer.d.ts +2 -2
  89. package/types/telemetry/src/relay.d.ts +2 -2
  90. package/types/telemetry/src/transport.d.ts +1 -1
  91. package/types/utils/src/api-error.d.ts +1 -1
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  JsonObject,
3
3
  ValidationError
4
- } from "./chunk-FBBXFFFJ.js";
4
+ } from "./chunk-BI45HZWM.js";
5
5
  import {
6
6
  Cause_exports,
7
7
  Effect_exports,
@@ -10,7 +10,7 @@ import {
10
10
  SchemaIssue_exports,
11
11
  SchemaParser_exports,
12
12
  Schema_exports
13
- } from "./chunk-EXGKN554.js";
13
+ } from "./chunk-IJQ5LE74.js";
14
14
 
15
15
  // ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
16
16
  function deepCompareStrict(a, b) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  appSignInCallbackPath
3
- } from "./chunk-ZOY7PDMI.js";
3
+ } from "./chunk-NHCFIWN5.js";
4
4
  import {
5
5
  HttpServerResponse_exports
6
- } from "./chunk-CJY5X26R.js";
6
+ } from "./chunk-KOOJUMLR.js";
7
7
 
8
8
  // src/implementation/ui-auth.ts
9
9
  var appPrivateHeaders = {
@@ -5,14 +5,14 @@ import {
5
5
  networkRefusalHeader,
6
6
  networkRefusalStatus,
7
7
  supportedFetchOptions
8
- } from "./chunk-DXGWKNTQ.js";
8
+ } from "./chunk-BI6R577B.js";
9
9
  import {
10
10
  invocationFetch
11
- } from "./chunk-ETLILMHY.js";
11
+ } from "./chunk-KZFV3WCJ.js";
12
12
  import {
13
13
  Effect_exports,
14
14
  Schema_exports
15
- } from "./chunk-EXGKN554.js";
15
+ } from "./chunk-IJQ5LE74.js";
16
16
 
17
17
  // src/implementation/network.ts
18
18
  var refusalHeader = (status, header) => status === networkRefusalStatus && header !== null && header !== void 0 ? header : void 0;
@@ -4,7 +4,7 @@ import {
4
4
  fromWeb,
5
5
  layerMergedContext,
6
6
  make2 as make
7
- } from "./chunk-CJY5X26R.js";
7
+ } from "./chunk-KOOJUMLR.js";
8
8
  import {
9
9
  Reference,
10
10
  Service,
@@ -13,16 +13,16 @@ import {
13
13
  getOrUndefined2 as getOrUndefined,
14
14
  map3 as map,
15
15
  merge3 as merge,
16
- remove3 as remove,
16
+ remove2 as remove,
17
17
  succeed4 as succeed,
18
18
  toReadableStreamEffect,
19
19
  tryPromise
20
- } from "./chunk-EXGKN554.js";
20
+ } from "./chunk-IJQ5LE74.js";
21
21
  import {
22
22
  __export
23
23
  } from "./chunk-CZ7CSFO4.js";
24
24
 
25
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/http/FetchHttpClient.js
25
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/http/FetchHttpClient.js
26
26
  var FetchHttpClient_exports = {};
27
27
  __export(FetchHttpClient_exports, {
28
28
  Fetch: () => Fetch,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  makeCache
3
- } from "./chunk-Q7Q5JTRW.js";
3
+ } from "./chunk-JU7F4PRK.js";
4
4
  import {
5
5
  accountSecrets,
6
6
  boundFailureMessage,
@@ -8,37 +8,38 @@ import {
8
8
  failureDetail,
9
9
  leavingProviderError,
10
10
  parseMcpError,
11
+ parseSkillLoadFailed,
11
12
  readCatalog,
12
13
  routerSkills
13
- } from "./chunk-O4QOPXQT.js";
14
+ } from "./chunk-ZQWDOHEO.js";
14
15
  import {
15
16
  appInvocationFetch
16
- } from "./chunk-EPUWF4ZG.js";
17
+ } from "./chunk-SRB2WDU7.js";
17
18
  import {
18
19
  folderSkillsEffect
19
- } from "./chunk-OX233L7N.js";
20
+ } from "./chunk-4U2VUDET.js";
20
21
  import {
21
22
  ResponseStatusError,
22
23
  authorDatabase,
23
24
  isApp,
24
25
  toEffectApp,
25
26
  unavailableStorage
26
- } from "./chunk-QZD2RZ4S.js";
27
+ } from "./chunk-CZLCA2O4.js";
27
28
  import {
28
29
  parseDatabaseSchema
29
- } from "./chunk-5JVNM3CQ.js";
30
+ } from "./chunk-IU7CCCUC.js";
30
31
  import {
31
32
  declaredOperations,
32
33
  fromPromise,
33
34
  locate,
34
35
  nativeOperation,
35
36
  toPromise
36
- } from "./chunk-QUEPZ67T.js";
37
+ } from "./chunk-BKJDZYK7.js";
37
38
  import {
38
39
  accountProviderError,
39
40
  httpProviderError,
40
41
  parseProviderError
41
- } from "./chunk-IU6OK5G2.js";
42
+ } from "./chunk-ENJCQWVF.js";
42
43
  import {
43
44
  AccountCheckResult,
44
45
  DeclaredProvider,
@@ -85,18 +86,17 @@ import {
85
86
  defaultWebhookTransportLimits,
86
87
  maxInputProblems,
87
88
  workflowDurationMillis
88
- } from "./chunk-DSUKW6KJ.js";
89
+ } from "./chunk-XEXUHXC3.js";
89
90
  import {
90
91
  CacheError
91
- } from "./chunk-DXGWKNTQ.js";
92
+ } from "./chunk-BI6R577B.js";
92
93
  import {
93
94
  AppSkills,
94
- SkillFile,
95
- SkillLoadFailed
96
- } from "./chunk-HW3DPBZR.js";
95
+ SkillFile
96
+ } from "./chunk-556EWA6P.js";
97
97
  import {
98
98
  captureTelemetry
99
- } from "./chunk-ETLILMHY.js";
99
+ } from "./chunk-KZFV3WCJ.js";
100
100
  import {
101
101
  allowedValues,
102
102
  decoderOf,
@@ -107,16 +107,16 @@ import {
107
107
  maxAlternativeKeys,
108
108
  objectShape,
109
109
  unionShape
110
- } from "./chunk-O3OAFU7Q.js";
110
+ } from "./chunk-POOIHRPF.js";
111
111
  import {
112
112
  JsonObject,
113
113
  JsonValue
114
- } from "./chunk-FBBXFFFJ.js";
114
+ } from "./chunk-BI45HZWM.js";
115
115
  import {
116
+ Base64_exports,
116
117
  Cause_exports,
117
118
  Clock_exports,
118
119
  Effect_exports,
119
- Encoding_exports,
120
120
  Match_exports,
121
121
  Option_exports,
122
122
  Redacted_exports,
@@ -124,7 +124,7 @@ import {
124
124
  SchemaIssue_exports,
125
125
  Schema_exports,
126
126
  Stream_exports
127
- } from "./chunk-EXGKN554.js";
127
+ } from "./chunk-IJQ5LE74.js";
128
128
 
129
129
  // src/implementation/elicitation.ts
130
130
  var prepareElicitation = (input) => Effect_exports.gen(function* () {
@@ -520,7 +520,7 @@ var dispatchWebhook = (definition, command, context, accounts) => Effect_exports
520
520
  yield* invoke(hook.unregister, { ...input, state });
521
521
  return null;
522
522
  }
523
- const body = yield* Effect_exports.fromResult(Encoding_exports.decodeBase64(command.request.body)).pipe(
523
+ const body = yield* Effect_exports.fromResult(Base64_exports.decode(command.request.body)).pipe(
524
524
  Effect_exports.mapError(() => new HostInputInvalid())
525
525
  );
526
526
  if (body.byteLength > defaultWebhookTransportLimits.maxBodyBytes)
@@ -569,7 +569,7 @@ var dispatchWebhook = (definition, command, context, accounts) => Effect_exports
569
569
  () => Schema_exports.decodeUnknownEffect(WebhookResponseData)({
570
570
  status: response.status,
571
571
  headers,
572
- body: Encoding_exports.encodeBase64(new Uint8Array(bytes))
572
+ body: Base64_exports.encode(new Uint8Array(bytes))
573
573
  }),
574
574
  new HostOutputInvalid()
575
575
  );
@@ -1287,15 +1287,6 @@ function checkAccount(slots, declared, requirement, context, signal, deadline) {
1287
1287
  );
1288
1288
  });
1289
1289
  }
1290
- var parseSkillLoadFailed = (error) => Schema_exports.decodeUnknownOption(SkillLoadFailed)(error).pipe(
1291
- Option_exports.map(
1292
- ({ reason, message, status }) => new SkillLoadFailed({
1293
- reason,
1294
- ...message ? { message } : {},
1295
- ...status === void 0 ? {} : { status }
1296
- })
1297
- )
1298
- );
1299
1290
  var errorStatus = Match_exports.type().pipe(
1300
1291
  Match_exports.tagsExhaustive({
1301
1292
  ProviderError: () => 502,
@@ -0,0 +1,268 @@
1
+ import {
2
+ String,
3
+ Struct,
4
+ TaggedClass,
5
+ TaggedError,
6
+ UndefinedOr,
7
+ decode2 as decode,
8
+ decodeTo,
9
+ fail,
10
+ fail4 as fail2,
11
+ flatMap2 as flatMap,
12
+ fromTransform,
13
+ hasProperty,
14
+ isArrayNonEmpty,
15
+ millis,
16
+ optional,
17
+ pipeTo,
18
+ succeed,
19
+ succeed4 as succeed2,
20
+ suspend,
21
+ sync2 as sync,
22
+ tag,
23
+ transform,
24
+ void_2 as void_
25
+ } from "./chunk-IJQ5LE74.js";
26
+
27
+ // ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/encoding/Sse.js
28
+ var SseErrorTypeId = "~effect/encoding/Sse/SseError";
29
+ var EventTooLarge = class extends (/* @__PURE__ */ TaggedError("EventTooLarge")) {
30
+ get message() {
31
+ return `Pending SSE event exceeded the maximum size of ${this.maxEventSize}`;
32
+ }
33
+ };
34
+ var SseError = class extends (/* @__PURE__ */ TaggedError("SseError")) {
35
+ /**
36
+ * Marks this value as an SSE decoding error.
37
+ *
38
+ * @stability unstable
39
+ * @since 4.0.0
40
+ */
41
+ [SseErrorTypeId] = SseErrorTypeId;
42
+ /**
43
+ * Delegates the public message to the underlying SSE error reason.
44
+ *
45
+ * @stability unstable
46
+ * @since 4.0.0
47
+ */
48
+ get message() {
49
+ return this.reason.message;
50
+ }
51
+ };
52
+ var defaultMaxEventSize = 10 * 1024 * 1024;
53
+ var decode2 = (options) => fromTransform((upstream, _scope) => sync(() => {
54
+ let buffer = [];
55
+ let retry;
56
+ const parser = makeParser((event) => {
57
+ if (event._tag === "Retry") {
58
+ retry = event;
59
+ } else {
60
+ buffer.push(event);
61
+ }
62
+ }, options);
63
+ const pump = flatMap(upstream, (arr) => {
64
+ for (let i = 0; i < arr.length; i++) {
65
+ const error = parser.feed(arr[i]);
66
+ if (error !== void 0) {
67
+ return fail2(error);
68
+ }
69
+ }
70
+ return void_;
71
+ });
72
+ return suspend(function loop() {
73
+ if (isArrayNonEmpty(buffer)) {
74
+ const out = buffer;
75
+ buffer = [];
76
+ return succeed2(out);
77
+ } else if (retry) {
78
+ return fail2(retry);
79
+ }
80
+ return flatMap(pump, loop);
81
+ });
82
+ }));
83
+ var decodeSchema = (schema, options, parseOptions) => pipeTo(decode2(options), decode(Event.pipe(decodeTo(schema, transformEvent)), parseOptions)());
84
+ function makeParser(onParse, options) {
85
+ const maxEventSize = options?.maxEventSize ?? defaultMaxEventSize;
86
+ let isFirstChunk;
87
+ let buffer;
88
+ let startingPosition;
89
+ let startingFieldLength;
90
+ let discardTrailingNewline;
91
+ let lastEventId;
92
+ let eventName;
93
+ let data;
94
+ reset();
95
+ return {
96
+ feed,
97
+ reset
98
+ };
99
+ function reset() {
100
+ isFirstChunk = true;
101
+ buffer = "";
102
+ startingPosition = 0;
103
+ startingFieldLength = -1;
104
+ discardTrailingNewline = false;
105
+ lastEventId = void 0;
106
+ eventName = void 0;
107
+ data = "";
108
+ }
109
+ function feed(chunk) {
110
+ buffer = buffer ? buffer + chunk : chunk;
111
+ if (isFirstChunk && buffer.startsWith(BOM)) {
112
+ buffer = buffer.slice(BOM.length);
113
+ }
114
+ isFirstChunk = false;
115
+ const length = buffer.length;
116
+ let position = 0;
117
+ while (position < length) {
118
+ if (discardTrailingNewline) {
119
+ if (buffer[position] === "\n") {
120
+ ++position;
121
+ }
122
+ discardTrailingNewline = false;
123
+ }
124
+ let lineLength = -1;
125
+ let fieldLength = startingFieldLength;
126
+ let character;
127
+ for (let index = position + startingPosition; lineLength < 0 && index < length; ++index) {
128
+ character = buffer[index];
129
+ if (character === ":" && fieldLength < 0) {
130
+ fieldLength = index - position;
131
+ } else if (character === "\r") {
132
+ discardTrailingNewline = true;
133
+ lineLength = index - position;
134
+ } else if (character === "\n") {
135
+ lineLength = index - position;
136
+ }
137
+ }
138
+ if (lineLength < 0) {
139
+ startingPosition = length - position;
140
+ startingFieldLength = fieldLength;
141
+ break;
142
+ } else {
143
+ startingPosition = 0;
144
+ startingFieldLength = -1;
145
+ }
146
+ parseEventStreamLine(buffer, position, fieldLength, lineLength);
147
+ position += lineLength + 1;
148
+ }
149
+ if (position === length) {
150
+ buffer = "";
151
+ } else if (position > 0) {
152
+ buffer = buffer.slice(position);
153
+ }
154
+ if (buffer.length + data.length > maxEventSize) {
155
+ const error = new SseError({
156
+ reason: new EventTooLarge({
157
+ maxEventSize
158
+ })
159
+ });
160
+ reset();
161
+ return error;
162
+ }
163
+ }
164
+ function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) {
165
+ if (lineLength === 0) {
166
+ if (data.length > 0) {
167
+ onParse({
168
+ _tag: "Event",
169
+ id: lastEventId,
170
+ event: eventName || "message",
171
+ data: data.slice(0, -1)
172
+ // remove trailing newline
173
+ });
174
+ data = "";
175
+ }
176
+ eventName = void 0;
177
+ return;
178
+ }
179
+ const noValue = fieldLength < 0;
180
+ const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength));
181
+ let step = 0;
182
+ if (noValue) {
183
+ step = lineLength;
184
+ } else if (lineBuffer[index + fieldLength + 1] === " ") {
185
+ step = fieldLength + 2;
186
+ } else {
187
+ step = fieldLength + 1;
188
+ }
189
+ const position = index + step;
190
+ const valueLength = lineLength - step;
191
+ const value = lineBuffer.slice(position, position + valueLength).toString();
192
+ if (field === "data") {
193
+ data += value ? `${value}
194
+ ` : "\n";
195
+ } else if (field === "event") {
196
+ eventName = value;
197
+ } else if (field === "id" && !value.includes("\0")) {
198
+ lastEventId = value;
199
+ } else if (field === "retry" && /^\d+$/.test(value)) {
200
+ const retry = parseInt(value, 10);
201
+ onParse(new Retry({
202
+ duration: millis(retry),
203
+ lastEventId
204
+ }));
205
+ }
206
+ }
207
+ }
208
+ var BOM = "\uFEFF";
209
+ var EventEncoded = /* @__PURE__ */ Struct({
210
+ id: /* @__PURE__ */ optional(String),
211
+ event: String,
212
+ data: String
213
+ });
214
+ var Event = /* @__PURE__ */ Struct({
215
+ _tag: /* @__PURE__ */ tag("Event"),
216
+ id: /* @__PURE__ */ UndefinedOr(String),
217
+ event: String,
218
+ data: String
219
+ });
220
+ var transformEvent = /* @__PURE__ */ transform({
221
+ decode: (event) => event.id === void 0 ? {
222
+ event: event.event,
223
+ data: event.data
224
+ } : {
225
+ id: event.id,
226
+ event: event.event,
227
+ data: event.data
228
+ },
229
+ encode: (event) => ({
230
+ _tag: "Event",
231
+ id: event.id,
232
+ event: event.event ?? "message",
233
+ data: event.data
234
+ })
235
+ });
236
+ var RetryTypeId = "~effect/encoding/Sse/Retry";
237
+ var Retry = class _Retry extends (/* @__PURE__ */ TaggedClass("Retry")) {
238
+ /**
239
+ * Marks this value as an SSE retry directive for runtime guards.
240
+ *
241
+ * @stability unstable
242
+ * @since 4.0.0
243
+ */
244
+ [RetryTypeId] = RetryTypeId;
245
+ /**
246
+ * Returns `true` when the value is an SSE retry directive.
247
+ *
248
+ * @stability unstable
249
+ * @since 4.0.0
250
+ */
251
+ static is(u) {
252
+ return hasProperty(u, RetryTypeId);
253
+ }
254
+ /**
255
+ * Separates SSE retry directives from regular event values.
256
+ *
257
+ * @stability unstable
258
+ * @since 4.0.0
259
+ */
260
+ static filter(u) {
261
+ return _Retry.is(u) ? succeed(u) : fail(u);
262
+ }
263
+ };
264
+
265
+ export {
266
+ decodeSchema,
267
+ EventEncoded
268
+ };
@@ -3,16 +3,16 @@ import {
3
3
  answeredError,
4
4
  mcpClient,
5
5
  mcpJsonSchemaValidator
6
- } from "./chunk-QKVZGWGZ.js";
6
+ } from "./chunk-A2NN45C7.js";
7
7
  import {
8
8
  failOnNetworkRefusal
9
- } from "./chunk-EPUWF4ZG.js";
9
+ } from "./chunk-SRB2WDU7.js";
10
10
  import {
11
11
  accountProviderError,
12
12
  bodyUpstreamError,
13
13
  httpProviderError,
14
14
  providerErrorDetail
15
- } from "./chunk-IU6OK5G2.js";
15
+ } from "./chunk-ENJCQWVF.js";
16
16
  import {
17
17
  McpCredentialsUnverified,
18
18
  McpError,
@@ -20,21 +20,21 @@ import {
20
20
  McpToolsOptions,
21
21
  defaultMcpClientLimits,
22
22
  mcpHealthReserveMs
23
- } from "./chunk-DSUKW6KJ.js";
23
+ } from "./chunk-XEXUHXC3.js";
24
24
  import {
25
25
  NetworkRefused,
26
26
  ProviderError
27
- } from "./chunk-DXGWKNTQ.js";
27
+ } from "./chunk-BI6R577B.js";
28
28
  import {
29
29
  captureTelemetry
30
- } from "./chunk-ETLILMHY.js";
30
+ } from "./chunk-KZFV3WCJ.js";
31
31
  import {
32
32
  FetchHttpClient_exports
33
- } from "./chunk-MFHUR5SB.js";
33
+ } from "./chunk-TADLIUEU.js";
34
34
  import {
35
35
  HttpClientRequest_exports,
36
36
  HttpClient_exports
37
- } from "./chunk-CJY5X26R.js";
37
+ } from "./chunk-KOOJUMLR.js";
38
38
  import {
39
39
  Clock_exports,
40
40
  Deferred_exports,
@@ -46,7 +46,7 @@ import {
46
46
  Ref_exports,
47
47
  Schema_exports,
48
48
  Stream_exports
49
- } from "./chunk-EXGKN554.js";
49
+ } from "./chunk-IJQ5LE74.js";
50
50
 
51
51
  // src/implementation/mcp.ts
52
52
  import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
@@ -138,7 +138,11 @@ var transportFetch = (connection, telemetry, rejected, answered) => (url, init)
138
138
  yield* Deferred_exports.fail(rejected, refused);
139
139
  return yield* refused;
140
140
  }
141
- yield* Ref_exports.set(answered, { status: response.status, upstream });
141
+ const session = new Headers(init?.headers).has("mcp-session-id");
142
+ yield* Ref_exports.update(
143
+ answered,
144
+ (responses) => new Map(responses).set(response.status, { upstream, session })
145
+ );
142
146
  return new Response(body, { status: response.status, headers: response.headers });
143
147
  }).pipe(
144
148
  Effect_exports.provide(FetchHttpClient_exports.layer),
@@ -157,26 +161,30 @@ var transportFetch = (connection, telemetry, rejected, answered) => (url, init)
157
161
  ),
158
162
  init?.signal ? { signal: init.signal } : {}
159
163
  );
160
- var explain = (error, phase, response) => {
164
+ var explain = (error, phase, responses) => {
161
165
  if (Schema_exports.is(ProviderError)(error)) return providerErrorDetail(error, { phase });
162
- if (!Schema_exports.is(McpError)(error) || error.upstream !== void 0 || error.status === void 0 || response?.status !== error.status || response.upstream === void 0)
166
+ if (!Schema_exports.is(McpError)(error) || error.status === void 0) return error;
167
+ const response = responses.get(error.status);
168
+ if (response === void 0 || (error.upstream !== void 0 || response.upstream === void 0) && !response.session)
163
169
  return error;
170
+ const upstream = error.upstream ?? response.upstream;
164
171
  return new McpError({
165
172
  phase: error.phase,
166
173
  reason: error.reason,
167
174
  status: error.status,
168
- upstream: response.upstream
175
+ ...upstream === void 0 ? {} : { upstream },
176
+ ...response.session ? { session: true } : {}
169
177
  });
170
178
  };
171
179
  var explained = (phase, answered) => (error) => Ref_exports.get(answered).pipe(
172
- Effect_exports.flatMap((response) => Effect_exports.fail(explain(error, phase, response)))
180
+ Effect_exports.flatMap((responses) => Effect_exports.fail(explain(error, phase, responses)))
173
181
  );
174
182
  function withClient(connection, mode, use, changed) {
175
183
  const attempt = (kind) => Effect_exports.scoped(
176
184
  Effect_exports.gen(function* () {
177
185
  const telemetry = yield* captureTelemetry;
178
186
  const rejected = yield* Deferred_exports.make();
179
- const answered = yield* Ref_exports.make(void 0);
187
+ const answered = yield* Ref_exports.make(/* @__PURE__ */ new Map());
180
188
  const pending = /* @__PURE__ */ new Set();
181
189
  const { client, transport } = yield* Effect_exports.acquireRelease(
182
190
  Effect_exports.sync(() => {
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  JsonValue
3
- } from "./chunk-FBBXFFFJ.js";
3
+ } from "./chunk-BI45HZWM.js";
4
4
  import {
5
5
  HttpApiEndpoint_exports,
6
6
  HttpApiGroup_exports,
7
7
  HttpApiSchema_exports,
8
8
  HttpApi_exports
9
- } from "./chunk-QYM4STZW.js";
9
+ } from "./chunk-PHO7HXTC.js";
10
10
  import {
11
11
  Schema_exports
12
- } from "./chunk-EXGKN554.js";
12
+ } from "./chunk-IJQ5LE74.js";
13
13
 
14
14
  // src/contracts/ui.ts
15
15
  var UiContext = Schema_exports.Struct({
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  fixedRouter
3
- } from "./chunk-O4QOPXQT.js";
3
+ } from "./chunk-ZQWDOHEO.js";
4
4
  import {
5
5
  nativeOperation,
6
6
  operationDeclaration,
7
7
  routerDeclaration
8
- } from "./chunk-QUEPZ67T.js";
8
+ } from "./chunk-BKJDZYK7.js";
9
9
 
10
10
  // src/implementation/protocol-operations.ts
11
11
  var protocolOperations = (operations, kinds = {}) => {