apps 0.0.1-beta.0 → 0.0.1-beta.2

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 (114) hide show
  1. package/README.md +97 -4
  2. package/framework-reference.json +1 -1
  3. package/js/browser-XIPJGLH2.js +65 -0
  4. package/js/{chunk-SBKHUC5L.js → chunk-4LPG6RCH.js} +2 -2
  5. package/js/chunk-5MQZEB6Y.js +172 -0
  6. package/js/{chunk-7JXHF5IF.js → chunk-BMOIAIVR.js} +1 -1
  7. package/js/chunk-CZ7CSFO4.js +39 -0
  8. package/js/chunk-D47C7KG5.js +172 -0
  9. package/js/{chunk-YDR4CPJA.js → chunk-EVJUVWN2.js} +8 -8
  10. package/js/chunk-FDNTX5QJ.js +78 -0
  11. package/js/{chunk-2OTCEKL2.js → chunk-FW5HBOIK.js} +2352 -1493
  12. package/js/{chunk-EP6AEUZO.js → chunk-FZJOYIZO.js} +1 -1
  13. package/js/{chunk-VFUZI3NY.js → chunk-HDJH3RPR.js} +4 -4
  14. package/js/{chunk-WIDTG42X.js → chunk-HDTGZWP2.js} +79 -26
  15. package/js/{chunk-Q2FD5IBM.js → chunk-J7O55ZV7.js} +298 -37
  16. package/js/{chunk-X3YBZCJW.js → chunk-JN55AYQH.js} +8 -41
  17. package/js/chunk-LGIYBDWA.js +85 -0
  18. package/js/{chunk-D6BKYP2L.js → chunk-M6ZRRIBI.js} +4 -4
  19. package/js/{chunk-HP7E42X6.js → chunk-MYYEW3RA.js} +767 -249
  20. package/js/{chunk-3ANFZFCV.js → chunk-OHRT55C4.js} +15 -15
  21. package/js/{chunk-R6JMJSVT.js → chunk-PLCMJREA.js} +2 -2
  22. package/js/{chunk-C24KEZXR.js → chunk-PYUYJRSK.js} +36 -2
  23. package/js/{chunk-W7Q5EOTS.js → chunk-QKHR7BMF.js} +32 -32
  24. package/js/{chunk-KWTCHVLT.js → chunk-RN2MXB4R.js} +47 -51
  25. package/js/{chunk-36DNRFZQ.js → chunk-SATWJKN6.js} +1 -1
  26. package/js/chunk-SWPD52J7.js +35 -0
  27. package/js/{chunk-BKVL7XAJ.js → chunk-TE4KO4HI.js} +1 -1
  28. package/js/chunk-UVL56Z6E.js +6641 -0
  29. package/js/chunk-W7D7WVSY.js +18 -0
  30. package/js/{chunk-BPEFS4YF.js → chunk-WFSQXYUT.js} +109 -17
  31. package/js/chunk-YEJOQEII.js +104 -0
  32. package/js/{chunk-LOKGDT6B.js → chunk-Z5NMEGJN.js} +5 -4
  33. package/js/{chunk-OWD2YICM.js → chunk-ZCAMUXSG.js} +116 -87
  34. package/js/chunk-ZJWDMTE3.js +63 -0
  35. package/js/client.js +11 -11
  36. package/js/contracts.js +88 -25
  37. package/js/effect.js +21 -15
  38. package/js/es-APDZKREY.js +40968 -0
  39. package/js/graphql.js +224 -121
  40. package/js/host.js +76 -19
  41. package/js/index.js +193 -51
  42. package/js/mcp/effect.js +25 -17
  43. package/js/mcp/stdio.js +23 -17
  44. package/js/mcp.js +110 -24
  45. package/js/openapi.js +3045 -105
  46. package/js/operations/approval.js +1 -1
  47. package/js/react.js +4 -4
  48. package/js/skills/effect.js +11 -0
  49. package/js/skills.js +894 -0
  50. package/js/storage/facet.js +7 -7
  51. package/js/ui/auth/contracts.js +6 -6
  52. package/js/ui/auth.js +8 -8
  53. package/js/ui/contracts.js +5 -5
  54. package/js/ui/serving.js +12 -12
  55. package/package.json +9 -1
  56. package/runtime.json +1 -1
  57. package/types/app-cache/src/contracts/cache.d.ts +119 -0
  58. package/types/app-cache/src/index.d.ts +93 -0
  59. package/types/apps/src/contracts/api-response-error.d.ts +43 -0
  60. package/types/apps/src/contracts/app.d.ts +11 -0
  61. package/types/apps/src/contracts/cache.d.ts +44 -0
  62. package/types/apps/src/contracts/dynamic-skills.d.ts +10 -0
  63. package/types/apps/src/contracts/dynamic-tools.d.ts +13 -0
  64. package/types/apps/src/contracts/graphql.d.ts +18 -1
  65. package/types/apps/src/contracts/host.d.ts +54 -525
  66. package/types/apps/src/contracts/mcp.d.ts +3 -1
  67. package/types/apps/src/contracts/openapi-compile.d.ts +11 -0
  68. package/types/apps/src/contracts/openapi-document.d.ts +53 -0
  69. package/types/apps/src/contracts/openapi.d.ts +156 -30
  70. package/types/apps/src/contracts/protocol-version.d.ts +6 -0
  71. package/types/apps/src/contracts/protocols/1.d.ts +1575 -0
  72. package/types/apps/src/contracts/provider-error.d.ts +15 -0
  73. package/types/apps/src/contracts/provider.d.ts +18 -1
  74. package/types/apps/src/contracts/skills.d.ts +122 -0
  75. package/types/apps/src/contracts/swagger-client.d.ts +29 -0
  76. package/types/apps/src/graphql.d.ts +6 -6
  77. package/types/apps/src/host.d.ts +1 -0
  78. package/types/apps/src/implementation/account-operations.d.ts +122 -3
  79. package/types/apps/src/implementation/app.d.ts +1 -1
  80. package/types/apps/src/implementation/cache-session.d.ts +7 -0
  81. package/types/apps/src/implementation/cache.d.ts +8 -0
  82. package/types/apps/src/implementation/catalog-cache.d.ts +29 -0
  83. package/types/apps/src/implementation/dynamic-skills.d.ts +7 -0
  84. package/types/apps/src/implementation/dynamic-tools.d.ts +8 -0
  85. package/types/apps/src/implementation/elicitation.d.ts +12 -12
  86. package/types/apps/src/implementation/git.d.ts +25 -0
  87. package/types/apps/src/implementation/graphql-catalog.d.ts +10 -0
  88. package/types/apps/src/implementation/graphql.d.ts +81 -3
  89. package/types/apps/src/implementation/inflate.d.ts +16 -0
  90. package/types/apps/src/implementation/input-problems.d.ts +3 -0
  91. package/types/apps/src/implementation/mcp-call.d.ts +3 -2
  92. package/types/apps/src/implementation/mcp-catalog.d.ts +12 -0
  93. package/types/apps/src/implementation/mcp-client.d.ts +9 -8
  94. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  95. package/types/apps/src/implementation/mcp-tools.d.ts +6 -3
  96. package/types/apps/src/implementation/mcp.d.ts +39 -2
  97. package/types/apps/src/implementation/openapi-compile.d.ts +119 -0
  98. package/types/apps/src/implementation/openapi-document.d.ts +51 -0
  99. package/types/apps/src/implementation/openapi-names.d.ts +18 -0
  100. package/types/apps/src/implementation/openapi-request.d.ts +10 -4
  101. package/types/apps/src/implementation/openapi-source.d.ts +40 -0
  102. package/types/apps/src/implementation/openapi.d.ts +39 -3
  103. package/types/apps/src/implementation/provider-error.d.ts +10 -0
  104. package/types/apps/src/implementation/schema.d.ts +6 -5
  105. package/types/apps/src/implementation/skill-files.d.ts +10 -0
  106. package/types/apps/src/implementation/skills.d.ts +43 -0
  107. package/types/apps/src/implementation/swagger-client.d.ts +28 -0
  108. package/types/apps/src/index.d.ts +7 -0
  109. package/types/apps/src/mcp.d.ts +5 -5
  110. package/types/apps/src/openapi.d.ts +3 -1
  111. package/types/apps/src/skills.d.ts +75 -0
  112. package/types/telemetry/src/config.d.ts +2 -0
  113. package/js/chunk-22WRQZT7.js +0 -389
  114. package/js/chunk-MLKGABMK.js +0 -9
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Schema_exports
3
- } from "./chunk-2OTCEKL2.js";
3
+ } from "./chunk-FW5HBOIK.js";
4
4
 
5
5
  // src/contracts/storage.ts
6
6
  var StorageName = Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(200));
@@ -4,7 +4,7 @@ import {
4
4
  fromWeb,
5
5
  layerMergedContext,
6
6
  make2 as make
7
- } from "./chunk-W7Q5EOTS.js";
7
+ } from "./chunk-QKHR7BMF.js";
8
8
  import {
9
9
  Reference,
10
10
  Service,
@@ -17,12 +17,12 @@ import {
17
17
  succeed4 as succeed,
18
18
  toReadableStreamEffect,
19
19
  tryPromise
20
- } from "./chunk-2OTCEKL2.js";
20
+ } from "./chunk-FW5HBOIK.js";
21
21
  import {
22
22
  __export
23
- } from "./chunk-MLKGABMK.js";
23
+ } from "./chunk-CZ7CSFO4.js";
24
24
 
25
- // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b0796b742bddeb797269d/node_modules/effect/dist/unstable/http/FetchHttpClient.js
25
+ // ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/http/FetchHttpClient.js
26
26
  var FetchHttpClient_exports = {};
27
27
  __export(FetchHttpClient_exports, {
28
28
  Fetch: () => Fetch,
@@ -2,54 +2,71 @@ import {
2
2
  adaptMcpTools,
3
3
  mcpClient,
4
4
  mcpJsonSchemaValidator
5
- } from "./chunk-KWTCHVLT.js";
5
+ } from "./chunk-RN2MXB4R.js";
6
+ import {
7
+ accountProviderError,
8
+ httpProviderError
9
+ } from "./chunk-ZJWDMTE3.js";
6
10
  import {
7
11
  McpError,
8
12
  McpToolsOptions,
9
13
  defaultMcpClientLimits
10
- } from "./chunk-22WRQZT7.js";
14
+ } from "./chunk-MYYEW3RA.js";
15
+ import {
16
+ ProviderError
17
+ } from "./chunk-W7D7WVSY.js";
11
18
  import {
12
19
  captureTelemetry
13
- } from "./chunk-OWD2YICM.js";
20
+ } from "./chunk-ZCAMUXSG.js";
14
21
  import {
15
22
  FetchHttpClient_exports
16
- } from "./chunk-VFUZI3NY.js";
23
+ } from "./chunk-HDJH3RPR.js";
17
24
  import {
18
25
  HttpClientRequest_exports,
19
26
  HttpClient_exports
20
- } from "./chunk-W7Q5EOTS.js";
27
+ } from "./chunk-QKHR7BMF.js";
21
28
  import {
29
+ Deferred_exports,
22
30
  Effect_exports,
23
31
  Redacted_exports,
24
32
  Schema_exports,
25
33
  Stream_exports
26
- } from "./chunk-2OTCEKL2.js";
34
+ } from "./chunk-FW5HBOIK.js";
27
35
 
28
36
  // src/implementation/mcp.ts
29
37
  import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
30
38
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
31
- import { ErrorCode, McpError as ProtocolError } from "@modelcontextprotocol/sdk/types.js";
39
+ import {
40
+ ErrorCode,
41
+ McpError as ProtocolError,
42
+ ToolListChangedNotificationSchema
43
+ } from "@modelcontextprotocol/sdk/types.js";
32
44
  import { SSEClientTransport, SseError } from "@modelcontextprotocol/sdk/client/sse.js";
33
45
  import {
34
46
  StreamableHTTPClientTransport,
35
47
  StreamableHTTPError
36
48
  } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
37
49
  var failure = (phase, error) => {
50
+ if (Schema_exports.is(ProviderError)(error) || Schema_exports.is(McpError)(error)) return error;
38
51
  const status = error instanceof UnauthorizedError ? 401 : error instanceof StreamableHTTPError || error instanceof SseError ? error.code : void 0;
52
+ const provider = status === void 0 ? void 0 : httpProviderError(status);
53
+ if (provider !== void 0) return provider;
39
54
  return new McpError({
40
55
  phase,
41
- reason: error instanceof ProtocolError && error.code === ErrorCode.RequestTimeout ? "timeout" : status === 401 || status === 403 ? "unauthorized" : "request",
56
+ reason: error instanceof ProtocolError && error.code === ErrorCode.RequestTimeout ? "timeout" : "request",
42
57
  ...status === void 0 ? {} : { status }
43
58
  });
44
59
  };
45
- var transportFetch = (connection, telemetry) => (url, init) => Effect_exports.runPromiseWith(telemetry.context)(
60
+ var transportFetch = (connection, telemetry, rejected) => (url, init) => Effect_exports.runPromiseWith(telemetry.context)(
46
61
  Effect_exports.gen(function* () {
47
62
  const target = yield* Effect_exports.try({
48
63
  try: () => new URL(url),
49
- catch: () => failure("transport", void 0)
64
+ catch: () => new McpError({ phase: "transport", reason: "invalid_response" })
50
65
  });
66
+ if (connection.url.username || connection.url.password)
67
+ return yield* new McpError({ phase: "transport", reason: "invalid_input" });
51
68
  if (target.origin !== connection.url.origin || target.username || target.password)
52
- return yield* failure("transport", void 0);
69
+ return yield* new McpError({ phase: "transport", reason: "invalid_response" });
53
70
  const headers = new Headers(Redacted_exports.value(connection.headers));
54
71
  new Headers(init?.headers).forEach((value, name) => headers.set(name, value));
55
72
  const request = yield* Effect_exports.try({
@@ -58,6 +75,11 @@ var transportFetch = (connection, telemetry) => (url, init) => Effect_exports.ru
58
75
  });
59
76
  const client = yield* HttpClient_exports.HttpClient;
60
77
  const response = yield* client.execute(request);
78
+ const provider = httpProviderError(response.status, response.headers);
79
+ if (provider !== void 0) {
80
+ yield* Deferred_exports.fail(rejected, provider);
81
+ return yield* provider;
82
+ }
61
83
  return new Response(
62
84
  [204, 205, 304].includes(response.status) ? null : Stream_exports.toReadableStream(response.stream),
63
85
  {
@@ -78,25 +100,40 @@ var transportFetch = (connection, telemetry) => (url, init) => Effect_exports.ru
78
100
  ])
79
101
  })
80
102
  ),
81
- Effect_exports.mapError(() => failure("transport", void 0))
103
+ Effect_exports.mapError((error) => failure("transport", error))
82
104
  ),
83
105
  init?.signal ? { signal: init.signal } : {}
84
106
  );
85
- function withClient(connection, mode, use) {
107
+ function withClient(connection, mode, use, changed) {
86
108
  const attempt = (kind) => Effect_exports.scoped(
87
109
  Effect_exports.gen(function* () {
88
110
  const telemetry = yield* captureTelemetry;
111
+ const rejected = yield* Deferred_exports.make();
112
+ const pending = /* @__PURE__ */ new Set();
89
113
  const { client, transport } = yield* Effect_exports.acquireRelease(
90
114
  Effect_exports.sync(() => {
91
- const fetch = transportFetch(connection, telemetry);
115
+ const fetch = transportFetch(connection, telemetry, rejected);
116
+ const client2 = new Client(
117
+ { name: "executor-apps", version: "0.1.0" },
118
+ {
119
+ jsonSchemaValidator: mcpJsonSchemaValidator,
120
+ capabilities: mode === "call" ? { elicitation: { form: {} } } : {}
121
+ }
122
+ );
123
+ if (changed !== void 0) {
124
+ client2.setNotificationHandler(ToolListChangedNotificationSchema, () => {
125
+ const task = Effect_exports.runPromiseWith(telemetry.context)(
126
+ changed.pipe(
127
+ Effect_exports.timeout("5 seconds"),
128
+ Effect_exports.catchCause(() => Effect_exports.logWarning("MCP catalog invalidation failed"))
129
+ )
130
+ );
131
+ pending.add(task);
132
+ return task.finally(() => pending.delete(task));
133
+ });
134
+ }
92
135
  return {
93
- client: new Client(
94
- { name: "executor-apps", version: "0.1.0" },
95
- {
96
- jsonSchemaValidator: mcpJsonSchemaValidator,
97
- capabilities: mode === "call" ? { elicitation: { form: {} } } : {}
98
- }
99
- ),
136
+ client: client2,
100
137
  transport: kind === "http" ? new StreamableHTTPClientTransport(connection.url, {
101
138
  fetch,
102
139
  reconnectionOptions: {
@@ -109,6 +146,10 @@ function withClient(connection, mode, use) {
109
146
  };
110
147
  }),
111
148
  ({ client: client2, transport: transport2 }) => Effect_exports.gen(function* () {
149
+ client2.removeNotificationHandler("notifications/tools/list_changed");
150
+ yield* Effect_exports.promise(async () => {
151
+ await Promise.allSettled(pending);
152
+ });
112
153
  if (transport2 instanceof StreamableHTTPClientTransport && transport2.sessionId !== void 0) {
113
154
  yield* Effect_exports.tryPromise(() => transport2.terminateSession()).pipe(
114
155
  Effect_exports.timeout(defaultMcpClientLimits.cleanupTimeoutMs),
@@ -125,8 +166,12 @@ function withClient(connection, mode, use) {
125
166
  yield* Effect_exports.tryPromise({
126
167
  try: (signal) => client.connect(wire, { signal, timeout: connection.timeoutMs }),
127
168
  catch: (error) => failure("connect", error)
128
- }).pipe(Effect_exports.timeout(connection.timeoutMs), Effect_exports.withSpan("provider.mcp.connect"));
129
- return yield* use(client);
169
+ }).pipe(
170
+ Effect_exports.raceFirst(Deferred_exports.await(rejected)),
171
+ Effect_exports.timeout(connection.timeoutMs),
172
+ Effect_exports.withSpan("provider.mcp.connect")
173
+ );
174
+ return yield* use(client).pipe(Effect_exports.raceFirst(Deferred_exports.await(rejected)));
130
175
  })
131
176
  ).pipe(
132
177
  Effect_exports.withSpan("provider.mcp.session", {
@@ -149,7 +194,7 @@ function withClient(connection, mode, use) {
149
194
  )
150
195
  );
151
196
  }
152
- var mcpToolsEffect = (input) => Effect_exports.gen(function* () {
197
+ var mcpClientEffect = (input, changed) => Effect_exports.gen(function* () {
153
198
  const options = yield* Schema_exports.decodeUnknownEffect(McpToolsOptions)(input).pipe(
154
199
  Effect_exports.mapError(() => new McpError({ phase: "connect", reason: "invalid_input" }))
155
200
  );
@@ -161,11 +206,19 @@ var mcpToolsEffect = (input) => Effect_exports.gen(function* () {
161
206
  headers: Redacted_exports.make({ ...options.headers }),
162
207
  timeoutMs: options.timeoutMs ?? defaultMcpClientLimits.timeoutMs
163
208
  };
164
- return yield* adaptMcpTools(
165
- mcpClient((mode, use) => withClient(connection, mode, use), connection.timeoutMs, failure)
209
+ return mcpClient(
210
+ (mode, use) => withClient(connection, mode, use, changed).pipe(
211
+ Effect_exports.mapError(
212
+ (error) => options.accountId === void 0 ? error : accountProviderError(error, options.accountId)
213
+ )
214
+ ),
215
+ connection.timeoutMs,
216
+ failure
166
217
  );
167
218
  });
219
+ var mcpToolsEffect = (input) => mcpClientEffect(input).pipe(Effect_exports.flatMap(adaptMcpTools));
168
220
 
169
221
  export {
222
+ mcpClientEffect,
170
223
  mcpToolsEffect
171
224
  };