apps 0.0.1-beta.25 → 0.0.1-beta.27

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 (62) hide show
  1. package/README.md +6 -6
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-VWU6I23D.js → chunk-3TEX4ZND.js} +23 -17
  4. package/js/{chunk-K3MQX2KO.js → chunk-4OD7PHQL.js} +2 -2
  5. package/js/{chunk-AAAMPT6F.js → chunk-65SZ23BK.js} +2 -2
  6. package/js/{chunk-XBG3M64K.js → chunk-6JBTHTI5.js} +1 -1
  7. package/js/{chunk-J3RUZMLO.js → chunk-7AZNPMQH.js} +149 -15
  8. package/js/{chunk-VGEPL4BV.js → chunk-7R5JY5H7.js} +19 -5
  9. package/js/{chunk-VSLWGXPW.js → chunk-AHI26TO6.js} +24 -8
  10. package/js/{chunk-OBXHLFGQ.js → chunk-B5YJQU45.js} +1 -1
  11. package/js/{chunk-T7WRQJUF.js → chunk-BRGF7VFN.js} +2 -2
  12. package/js/{chunk-HQKIPKM5.js → chunk-BTJMXW4I.js} +1 -1
  13. package/js/{chunk-GG4IFBN3.js → chunk-HIJW4LWC.js} +64 -21
  14. package/js/{chunk-DAIW2WM3.js → chunk-KQCMHI3K.js} +3 -3
  15. package/js/{chunk-GH6PY5BQ.js → chunk-M2KEEOIQ.js} +1 -1
  16. package/js/{chunk-TACLXEAE.js → chunk-NSBRV4FJ.js} +1 -1
  17. package/js/{chunk-DM5U7G7V.js → chunk-NXTXZ635.js} +1842 -1840
  18. package/js/{chunk-3YN4UDPB.js → chunk-PTUZSCEV.js} +2 -2
  19. package/js/{chunk-KKGRSXUK.js → chunk-PWF2DRJ3.js} +1 -1
  20. package/js/{chunk-2TP7C25K.js → chunk-SDLIDQXG.js} +3 -3
  21. package/js/{chunk-NXO2GN2T.js → chunk-T2UFJKZR.js} +8 -8
  22. package/js/{chunk-PC5RHPUP.js → chunk-TSLG2WPA.js} +2 -2
  23. package/js/{chunk-WPKXOTKM.js → chunk-TX2XCAL6.js} +3 -3
  24. package/js/{chunk-KNJAOYV4.js → chunk-V2I3MMPM.js} +2 -2
  25. package/js/{chunk-ZVMZWXVF.js → chunk-VUVBMNKC.js} +2 -2
  26. package/js/{chunk-SUY33XAY.js → chunk-WQ5MVBTP.js} +1 -1
  27. package/js/{chunk-LPN4ONWW.js → chunk-XBQTJP76.js} +2 -2
  28. package/js/{chunk-IE6W5RNN.js → chunk-YML53Z7H.js} +2 -2
  29. package/js/{chunk-DUEZ2XCO.js → chunk-YXKXKGN6.js} +3 -3
  30. package/js/{chunk-XIRAIB3P.js → chunk-ZZOCEUTB.js} +4 -4
  31. package/js/client.js +10 -10
  32. package/js/contracts.js +7 -7
  33. package/js/effect.js +19 -19
  34. package/js/graphql.js +21 -21
  35. package/js/host.js +19 -19
  36. package/js/index.js +12 -12
  37. package/js/mcp/effect.js +23 -21
  38. package/js/mcp/stdio.js +21 -21
  39. package/js/mcp.js +29 -24
  40. package/js/openapi.js +595 -200
  41. package/js/react.js +3 -3
  42. package/js/skills/effect.js +3 -3
  43. package/js/skills.js +11 -11
  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/apps/src/contracts/mcp.d.ts +49 -3
  52. package/types/apps/src/contracts/openapi-compile.d.ts +31 -3
  53. package/types/apps/src/contracts/openapi.d.ts +16 -6
  54. package/types/apps/src/contracts/provider.d.ts +6 -0
  55. package/types/apps/src/implementation/failure-detail.d.ts +3 -2
  56. package/types/apps/src/implementation/mcp-client.d.ts +1 -0
  57. package/types/apps/src/implementation/mcp.d.ts +11 -1
  58. package/types/apps/src/implementation/openapi-compile.d.ts +12 -2
  59. package/types/apps/src/implementation/openapi-document.d.ts +20 -6
  60. package/types/apps/src/implementation/openapi-names.d.ts +9 -4
  61. package/types/apps/src/implementation/openapi-source.d.ts +6 -0
  62. package/types/apps/src/mcp.d.ts +20 -1
@@ -3,40 +3,46 @@ import {
3
3
  answeredError,
4
4
  mcpClient,
5
5
  mcpJsonSchemaValidator
6
- } from "./chunk-VSLWGXPW.js";
6
+ } from "./chunk-AHI26TO6.js";
7
7
  import {
8
8
  accountProviderError,
9
9
  bodyUpstreamError,
10
10
  httpProviderError,
11
11
  providerErrorDetail
12
- } from "./chunk-DAIW2WM3.js";
12
+ } from "./chunk-KQCMHI3K.js";
13
13
  import {
14
+ McpCredentialsUnverified,
14
15
  McpError,
16
+ McpHealthInput,
15
17
  McpToolsOptions,
16
- defaultMcpClientLimits
17
- } from "./chunk-VGEPL4BV.js";
18
+ defaultMcpClientLimits,
19
+ mcpHealthReserveMs
20
+ } from "./chunk-7R5JY5H7.js";
18
21
  import {
19
22
  ProviderError
20
- } from "./chunk-T7WRQJUF.js";
23
+ } from "./chunk-BRGF7VFN.js";
21
24
  import {
22
25
  captureTelemetry
23
- } from "./chunk-DUEZ2XCO.js";
26
+ } from "./chunk-YXKXKGN6.js";
24
27
  import {
25
28
  FetchHttpClient_exports
26
- } from "./chunk-KNJAOYV4.js";
29
+ } from "./chunk-V2I3MMPM.js";
27
30
  import {
28
31
  HttpClientRequest_exports,
29
32
  HttpClient_exports
30
- } from "./chunk-OBXHLFGQ.js";
33
+ } from "./chunk-B5YJQU45.js";
31
34
  import {
35
+ Clock_exports,
32
36
  Deferred_exports,
33
37
  Effect_exports,
38
+ Match_exports,
34
39
  Option_exports,
40
+ Predicate_exports,
35
41
  Redacted_exports,
36
42
  Ref_exports,
37
43
  Schema_exports,
38
44
  Stream_exports
39
- } from "./chunk-DM5U7G7V.js";
45
+ } from "./chunk-NXTXZ635.js";
40
46
 
41
47
  // src/implementation/mcp.ts
42
48
  import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
@@ -51,16 +57,16 @@ import {
51
57
  StreamableHTTPClientTransport,
52
58
  StreamableHTTPError
53
59
  } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
60
+ var unreadable = (error) => error instanceof SyntaxError || error instanceof Error && Predicate_exports.hasProperty(error, "issues") && Array.isArray(error.issues);
54
61
  var failure = (phase, error) => {
55
62
  if (Schema_exports.is(ProviderError)(error) || Schema_exports.is(McpError)(error)) return error;
56
- const status = error instanceof UnauthorizedError ? 401 : error instanceof StreamableHTTPError || error instanceof SseError ? error.code : void 0;
57
- const provider = status === void 0 ? void 0 : httpProviderError(status);
58
- if (provider !== void 0) return provider;
63
+ const code = error instanceof UnauthorizedError ? 401 : error instanceof StreamableHTTPError || error instanceof SseError ? error.code : void 0;
64
+ if (code !== void 0 && code >= 300 && code <= 599)
65
+ return httpProviderError(code) ?? new McpError({ phase, reason: "request", status: code });
59
66
  const upstream = answeredError(error);
60
67
  return new McpError({
61
68
  phase,
62
- reason: error instanceof ProtocolError && error.code === ErrorCode.RequestTimeout ? "timeout" : "request",
63
- ...status === void 0 ? {} : { status },
69
+ reason: code !== void 0 || unreadable(error) ? "invalid_response" : error instanceof ProtocolError && error.code === ErrorCode.RequestTimeout ? "timeout" : "request",
64
70
  ...upstream === void 0 ? {} : { upstream }
65
71
  });
66
72
  };
@@ -72,10 +78,10 @@ var errorBody = (response) => Effect_exports.gen(function* () {
72
78
  const length = response.headers["content-length"];
73
79
  if (!json || length !== void 0 && Number(length) > errorBodyLimits.maxBytes)
74
80
  return { body: Stream_exports.toReadableStream(response.stream), upstream: void 0 };
75
- const unreadable = new McpError({ phase: "transport", reason: "invalid_response" });
81
+ const unreadable2 = new McpError({ phase: "transport", reason: "invalid_response" });
76
82
  const read = yield* response.stream.pipe(
77
- Stream_exports.mapError(() => unreadable),
78
- Stream_exports.limitBytes(errorBodyLimits.maxBytes, () => Stream_exports.fail(unreadable)),
83
+ Stream_exports.mapError(() => unreadable2),
84
+ Stream_exports.limitBytes(errorBodyLimits.maxBytes, () => Stream_exports.fail(unreadable2)),
79
85
  Stream_exports.decodeText,
80
86
  Stream_exports.mkString,
81
87
  Effect_exports.timeout(errorBodyLimits.readTimeoutMs),
@@ -98,11 +104,14 @@ var transportFetch = (connection, telemetry, rejected, answered) => (url, init)
98
104
  return yield* new McpError({ phase: "transport", reason: "invalid_input" });
99
105
  if (target.origin !== connection.url.origin || target.username || target.password)
100
106
  return yield* new McpError({ phase: "transport", reason: "invalid_response" });
101
- const headers = new Headers(Redacted_exports.value(connection.headers));
102
- new Headers(init?.headers).forEach((value, name) => headers.set(name, value));
103
107
  const request = yield* Effect_exports.try({
104
- try: () => HttpClientRequest_exports.fromWeb(new Request(target, { ...init, headers })),
105
- catch: () => failure("transport", void 0)
108
+ try: () => {
109
+ const headers = new Headers(Redacted_exports.value(connection.headers));
110
+ new Headers(init?.headers).forEach((value, name) => headers.set(name, value));
111
+ return HttpClientRequest_exports.fromWeb(new Request(target, { ...init, headers }));
112
+ },
113
+ // The provider's headers cannot form an HTTP request, such as a name with a space.
114
+ catch: () => new McpError({ phase: "transport", reason: "invalid_input" })
106
115
  });
107
116
  const client = yield* HttpClient_exports.HttpClient;
108
117
  const response = yield* client.execute(request);
@@ -271,9 +280,43 @@ var mcpClientEffect = (input, changed) => Effect_exports.gen(function* () {
271
280
  failure
272
281
  );
273
282
  });
283
+ var refusesCredentials = (error) => Schema_exports.is(ProviderError)(error) && Match_exports.value(error.reason).pipe(
284
+ Match_exports.whenOr("unauthorized", "forbidden", "rejected", () => true),
285
+ Match_exports.whenOr("rate_limited", "unavailable", () => false),
286
+ Match_exports.exhaustive
287
+ );
288
+ var mcpHealthEffect = (check, options) => Effect_exports.gen(function* () {
289
+ const { deadline, timeoutMs, ...parsed } = yield* Schema_exports.decodeUnknownEffect(McpHealthInput)({
290
+ ...options,
291
+ accountId: check.account.id,
292
+ signal: check.signal,
293
+ deadline: check.deadline
294
+ }).pipe(Effect_exports.mapError(() => new McpError({ phase: "connect", reason: "invalid_input" })));
295
+ const end = Math.min(
296
+ (yield* Clock_exports.currentTimeMillis) + (timeoutMs ?? defaultMcpClientLimits.timeoutMs),
297
+ deadline === void 0 ? Number.POSITIVE_INFINITY : deadline - mcpHealthReserveMs
298
+ );
299
+ const remaining = Effect_exports.flatMap(
300
+ Clock_exports.currentTimeMillis,
301
+ (now) => end - now >= 1 ? Effect_exports.succeed(Math.floor(end - now)) : Effect_exports.fail(new McpError({ phase: "transport", reason: "timeout" }))
302
+ );
303
+ yield* (yield* mcpClientEffect({ ...parsed, timeoutMs: yield* remaining })).check;
304
+ return yield* remaining.pipe(
305
+ Effect_exports.flatMap(
306
+ (timeoutMs2) => mcpClientEffect({ url: parsed.url, signal: parsed.signal, timeoutMs: timeoutMs2 })
307
+ ),
308
+ Effect_exports.flatMap((anonymous) => anonymous.check),
309
+ Effect_exports.matchEffect({
310
+ onSuccess: () => Effect_exports.fail(new McpCredentialsUnverified({ anonymous: "answered" })),
311
+ onFailure: (error) => refusesCredentials(error) ? Effect_exports.void : Effect_exports.fail(new McpCredentialsUnverified({ anonymous: error }))
312
+ }),
313
+ Effect_exports.withSpan("provider.mcp.anonymous")
314
+ );
315
+ }).pipe(Effect_exports.withSpan("provider.mcp.health"));
274
316
  var mcpToolsEffect = (input) => mcpClientEffect(input).pipe(Effect_exports.flatMap(adaptMcpTools));
275
317
 
276
318
  export {
277
319
  mcpClientEffect,
320
+ mcpHealthEffect,
278
321
  mcpToolsEffect
279
322
  };
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  ProviderError,
3
3
  maxUpstreamMessageLength
4
- } from "./chunk-T7WRQJUF.js";
4
+ } from "./chunk-BRGF7VFN.js";
5
5
  import {
6
6
  AccountId
7
- } from "./chunk-KKGRSXUK.js";
7
+ } from "./chunk-PWF2DRJ3.js";
8
8
  import {
9
9
  Option_exports,
10
10
  Schema_exports
11
- } from "./chunk-DM5U7G7V.js";
11
+ } from "./chunk-NXTXZ635.js";
12
12
 
13
13
  // src/implementation/upstream-error.ts
14
14
  var ErrorToken = Schema_exports.String.check(Schema_exports.isPattern(/^[A-Za-z0-9._-]{1,128}$/));
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Schema_exports
3
- } from "./chunk-DM5U7G7V.js";
3
+ } from "./chunk-NXTXZ635.js";
4
4
 
5
5
  // ../app-data/src/contracts/database.ts
6
6
  var DataName = Schema_exports.String.check(
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Schema_exports
3
- } from "./chunk-DM5U7G7V.js";
3
+ } from "./chunk-NXTXZ635.js";
4
4
 
5
5
  // src/contracts/skills.ts
6
6
  var SkillFilePath = Schema_exports.NonEmptyString.check(