Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions apps/host-cloudflare/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
} from "@executor-js/api/server";

import { internalPrincipal } from "./auth/cloudflare-access";
import { reconcileForVersion } from "./internal-integrations/reconcile";
import { reconcileInternalIntegrations } from "./internal-integrations/reconcile";
import { makeInternalListTools } from "./internal-integrations/list-tools";
import { loadConfig, type CloudflareConfig, type CloudflareEnv } from "./config";
import { makeCloudflarePlugins, type CloudflarePlugins } from "./plugins";
import { createD1ExecutorDb } from "./db/d1";
Expand Down Expand Up @@ -44,7 +45,7 @@ import { preloadQuickJs } from "./quickjs";
let internalIntegrationsReconciled: Promise<void> | null = null;

// Once per isolate, by a system executor that may write org rows. Also refreshes
// existing declared catalogs once per deployed version. Never fails the boot.
// existing declared catalogs whose tool list changed. Never fails the boot.
const reconcileOncePerIsolate = (
config: CloudflareConfig,
dbHandle: ExecutorDbHandle,
Expand All @@ -61,12 +62,10 @@ const reconcileOncePerIsolate = (
config.organizationName,
{ orgWrites: "allowed" },
);
yield* reconcileForVersion(
executor,
config.internalIntegrations,
env.CF_VERSION_METADATA?.id,
env.BLOBS,
).pipe(Effect.ensuring(executor.close().pipe(Effect.ignore)));
yield* reconcileInternalIntegrations(executor, config.internalIntegrations, {
listTools: makeInternalListTools(config.internalHosts),
store: env.BLOBS,
}).pipe(Effect.ensuring(executor.close().pipe(Effect.ignore)));
}).pipe(
Effect.provide(dbProviderLayer(Effect.succeed(dbHandle))),
Effect.provide(makeCloudflarePluginsProvider(config)),
Expand Down
5 changes: 1 addition & 4 deletions apps/host-cloudflare/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ export interface CloudflareEnv {
readonly DB: D1Database;
/** R2 bucket binding — holds values too large for a D1 row (~1-2MB cap). */
readonly BLOBS?: R2Bucket;
/** Version metadata binding (wrangler.jsonc `version_metadata`): the id of
* the deployed Worker version. */
readonly CF_VERSION_METADATA?: { readonly id: string };
/** Static assets binding (wrangler.jsonc `assets.binding`). The MCP session
* DO fetches the built MCP-Apps shell document through it — a deployed
* Worker has no filesystem to read the shell from. */
Expand Down Expand Up @@ -148,7 +145,7 @@ export interface CloudflareConfig {

type CloudflareConfigEnv = Omit<
CloudflareEnv,
"DB" | "BLOBS" | "CF_VERSION_METADATA" | "ASSETS" | "MCP_SESSION" | "MCP_EXECUTION_OWNER"
"DB" | "BLOBS" | "ASSETS" | "MCP_SESSION" | "MCP_EXECUTION_OWNER"
>;

type CloudflareAccessEnv = Pick<
Expand Down
21 changes: 21 additions & 0 deletions apps/host-cloudflare/src/internal-integrations/list-tools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Effect } from "effect";

import { discoverToolsFromInput } from "@executor-js/plugin-mcp";
import {
makeHostedHttpClientLayer,
type HostedInternalHosts,
} from "@executor-js/sdk/host-internal";

import type { ListTools } from "./reconcile";

/** Lists tools with the MCP plugin's discovery, routed like the plugin's own calls. */
export const makeInternalListTools = (internalHosts: HostedInternalHosts): ListTools => {
const httpClientLayer = makeHostedHttpClientLayer({ internalHosts });
return (endpoint) =>
discoverToolsFromInput({
transport: "remote",
endpoint,
remoteTransport: "streamable-http",
httpClientLayer,
}).pipe(Effect.map(({ manifest }) => manifest.tools));
};
Loading
Loading