apps 0.0.1-beta.90 → 0.0.1-beta.91

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  prepareElicitation
3
- } from "./chunk-WMD4NHXZ.js";
3
+ } from "./chunk-XPRZTLHD.js";
4
4
  import {
5
5
  failOnNetworkRefusal
6
6
  } from "./chunk-YRGL4QEF.js";
@@ -1723,8 +1723,9 @@ function dispatch(app, request, context, signal, emitted) {
1723
1723
  const response = Schema_exports.decodeUnknownOption(OpenapiResponseError)(error);
1724
1724
  const mcp = parseMcpError(error, secrets);
1725
1725
  const failure = Schema_exports.decodeUnknownOption(ElicitationFailed)(error);
1726
+ const removed = Schema_exports.is(HostToolNotFound)(error) ? request.operation === "call" ? new HostToolNotFound() : new HostOperationNotFound() : void 0;
1726
1727
  return Effect_exports.fail(
1727
- Option_exports.isSome(provider) ? leavingProviderError(provider.value, secrets, "call") : Option_exports.isSome(response) ? new OpenapiResponseError({
1728
+ removed !== void 0 ? removed : Option_exports.isSome(provider) ? leavingProviderError(provider.value, secrets, "call") : Option_exports.isSome(response) ? new OpenapiResponseError({
1728
1729
  code: response.value.code,
1729
1730
  status: response.value.status,
1730
1731
  message: response.value.message,
package/js/effect.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  ApprovalDecision,
4
4
  createAppHandler,
5
5
  prepareElicitation
6
- } from "./chunk-WMD4NHXZ.js";
6
+ } from "./chunk-XPRZTLHD.js";
7
7
  import "./chunk-7PHHWYV4.js";
8
8
  import "./chunk-5MDA7MKL.js";
9
9
  import "./chunk-YRGL4QEF.js";
package/js/graphql.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  protocolOperations
7
7
  } from "./chunk-PYQLOLOC.js";
8
8
  import "./chunk-BCSNKUAC.js";
9
- import "./chunk-WMD4NHXZ.js";
9
+ import "./chunk-XPRZTLHD.js";
10
10
  import {
11
11
  cacheKey
12
12
  } from "./chunk-7PHHWYV4.js";
package/js/host.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAppHandler
3
- } from "./chunk-WMD4NHXZ.js";
3
+ } from "./chunk-XPRZTLHD.js";
4
4
  import "./chunk-7PHHWYV4.js";
5
5
  import "./chunk-5MDA7MKL.js";
6
6
  import "./chunk-YRGL4QEF.js";
package/js/mcp/effect.js CHANGED
@@ -2,9 +2,9 @@ import {
2
2
  mcpClientEffect,
3
3
  mcpHealthEffect,
4
4
  mcpToolsEffect
5
- } from "../chunk-36UFTECB.js";
5
+ } from "../chunk-3LEVTFD4.js";
6
6
  import "../chunk-BCSNKUAC.js";
7
- import "../chunk-WMD4NHXZ.js";
7
+ import "../chunk-XPRZTLHD.js";
8
8
  import "../chunk-7PHHWYV4.js";
9
9
  import "../chunk-5MDA7MKL.js";
10
10
  import "../chunk-YRGL4QEF.js";
package/js/mcp.js CHANGED
@@ -9,9 +9,9 @@ import {
9
9
  adaptMcpTool,
10
10
  mcpClientEffect,
11
11
  mcpHealthEffect
12
- } from "./chunk-36UFTECB.js";
12
+ } from "./chunk-3LEVTFD4.js";
13
13
  import "./chunk-BCSNKUAC.js";
14
- import "./chunk-WMD4NHXZ.js";
14
+ import "./chunk-XPRZTLHD.js";
15
15
  import {
16
16
  cacheKey
17
17
  } from "./chunk-7PHHWYV4.js";
package/js/openapi.js CHANGED
@@ -50,6 +50,7 @@ import {
50
50
  import {
51
51
  ApiErrorRecovery,
52
52
  ApiErrorResponse,
53
+ HostToolNotFound,
53
54
  NetworkRefused,
54
55
  OpenapiResponseError,
55
56
  ProviderError,
@@ -81,6 +82,7 @@ import {
81
82
  } from "./chunk-EOPQ727L.js";
82
83
  import {
83
84
  Base64_exports,
85
+ Clock_exports,
84
86
  Deferred_exports,
85
87
  Duration_exports,
86
88
  Effect_exports,
@@ -5308,6 +5310,9 @@ var retain = (revision, parts, bytes2) => {
5308
5310
  stored.set(revision, { parts, bytes: bytes2 });
5309
5311
  storedBytes += bytes2;
5310
5312
  };
5313
+ var rechecked = /* @__PURE__ */ new Map();
5314
+ var recheckEvery = 3e4;
5315
+ var missingRoute = (error) => (Schema_exports.is(OpenapiError)(error) && error.reason === "request" || Schema_exports.is(OpenapiResponseError)(error)) && (error.status === 404 || error.status === 405);
5311
5316
  function patchOpenapi(root, patches) {
5312
5317
  let result = root;
5313
5318
  for (const patch of patches ?? []) {
@@ -5581,6 +5586,47 @@ var liveOpenapiRouter = (options) => {
5581
5586
  )
5582
5587
  );
5583
5588
  });
5589
+ const recheck = Effect_exports.gen(function* () {
5590
+ const id = yield* sourceId;
5591
+ const now = yield* Clock_exports.currentTimeMillis;
5592
+ const last = rechecked.get(id);
5593
+ if (last !== void 0 && !last.running && now - last.started < recheckEvery)
5594
+ return yield* current;
5595
+ const owned2 = last === void 0 || !last.running ? { started: now, running: true } : void 0;
5596
+ if (owned2 !== void 0) {
5597
+ rechecked.delete(id);
5598
+ rechecked.set(id, owned2);
5599
+ if (rechecked.size > 64) rechecked.delete(rechecked.keys().next().value ?? id);
5600
+ }
5601
+ return yield* pointer.pipe(
5602
+ Effect_exports.flatMap(
5603
+ (key) => fromPromise(
5604
+ method(options.cache, "revalidate"),
5605
+ "cache"
5606
+ )({
5607
+ key,
5608
+ schema: schema(Manifest),
5609
+ freshFor,
5610
+ staleFor,
5611
+ load: toPromise(refresh, (context) => context.signal)
5612
+ })
5613
+ ),
5614
+ Effect_exports.ensuring(
5615
+ Effect_exports.sync(() => {
5616
+ if (owned2 !== void 0) owned2.running = false;
5617
+ })
5618
+ )
5619
+ );
5620
+ });
5621
+ const removedOr = (name, error) => recheck.pipe(
5622
+ Effect_exports.flatMap((manifest) => operationFor(manifest, name)),
5623
+ Effect_exports.catch(() => Effect_exports.succeed(void 0)),
5624
+ Effect_exports.flatMap(
5625
+ (found) => Effect_exports.fail(
5626
+ found !== void 0 && found.value === void 0 ? new HostToolNotFound() : error
5627
+ )
5628
+ )
5629
+ );
5584
5630
  const read = (revision, kind, names, decoder) => {
5585
5631
  const retained = stored.get(revision);
5586
5632
  const decode = decodeText(decoder);
@@ -5727,6 +5773,23 @@ var liveOpenapiRouter = (options) => {
5727
5773
  }
5728
5774
  return yield* invalid();
5729
5775
  });
5776
+ const recheckMissing = (tools, name) => Object.fromEntries(
5777
+ Object.entries(tools).map(([key, tool]) => {
5778
+ const guarded = {
5779
+ description: tool.description,
5780
+ readOnly: tool.readOnly,
5781
+ input: tool.input,
5782
+ run: (context, input) => tool.run(context, input).pipe(Effect_exports.catchIf(missingRoute, (error) => removedOr(name, error)))
5783
+ };
5784
+ return [
5785
+ key,
5786
+ "outputSchema" in tool ? Object.defineProperty(guarded, "outputSchema", {
5787
+ enumerable: true,
5788
+ get: () => tool.outputSchema
5789
+ }) : guarded
5790
+ ];
5791
+ })
5792
+ );
5730
5793
  return routerDeclaration({
5731
5794
  kind: "dynamic",
5732
5795
  meta: () => current.pipe(Effect_exports.map((manifest) => manifest.meta ?? {})),
@@ -5749,7 +5812,7 @@ var liveOpenapiRouter = (options) => {
5749
5812
  { ...options, operations: [operation], definitions },
5750
5813
  /* @__PURE__ */ new Map([[operation.name, schemas]])
5751
5814
  );
5752
- const declarations = protocolOperations(tools, {
5815
+ const declarations = protocolOperations(recheckMissing(tools, name), {
5753
5816
  [operation.name]: kindOf(operation)
5754
5817
  });
5755
5818
  const declaration = Object.hasOwn(declarations, name) ? declarations[name] : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps",
3
- "version": "0.0.1-beta.90",
3
+ "version": "0.0.1-beta.91",
4
4
  "description": "TypeScript apps with typed tools, accounts, storage, and UI.",
5
5
  "type": "module",
6
6
  "sideEffects": false,