Skip to content

Commit c41a178

Browse files
committed
refactor(cloudflare): require ai search backend
1 parent 717c784 commit c41a178

4 files changed

Lines changed: 5 additions & 41 deletions

File tree

apps/host-cloudflare/src/app.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ export const makeCloudflareApp = async (env: CloudflareEnv) => {
4141
config.secretKey,
4242
env.ANALYTICS,
4343
config.aiSearch,
44-
env.VECTORIZE,
45-
config.geminiApiKey,
4644
config.organizationId,
4745
);
4846

apps/host-cloudflare/src/config.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
R2Bucket,
66
} from "@cloudflare/workers-types";
77
import type { AnalyticsEngineDataset } from "@executor-js/plugin-execution-metrics/cloudflare";
8-
import type { AiSearchInstance, VectorizeIndex } from "@executor-js/plugin-semantic-search";
8+
import type { AiSearchInstance } from "@executor-js/plugin-semantic-search";
99

1010
import { isValidOrgSlug } from "@executor-js/api";
1111
import { missingPublicOriginWarning, resolvePublicOrigin } from "@executor-js/sdk/public-origin";
@@ -34,17 +34,8 @@ export interface CloudflareEnv {
3434
* bound (uncomment `analytics_engine_datasets` in wrangler.jsonc), each
3535
* finished execution/tool call writes a data point; absent, metrics are off. */
3636
readonly ANALYTICS?: AnalyticsEngineDataset;
37-
/** AI Search instance binding - preferred semantic `tools.search` backend. */
37+
/** AI Search instance binding for semantic `tools.search`. */
3838
readonly AI_SEARCH?: AiSearchInstance;
39-
/** Vectorize index binding — opt-in semantic `tools.search`. When bound (add a
40-
* `vectorize` binding in wrangler.jsonc) the semantic-search plugin embeds
41-
* the tool catalog and answers `tools.search` from it; absent, the engine
42-
* keeps its built-in lexical search. */
43-
readonly VECTORIZE?: VectorizeIndex;
44-
/** Gemini API key (a `wrangler secret`) powering the embeddings for the
45-
* Vectorize search. Absent → semantic search stays inert even if the index
46-
* is bound. */
47-
readonly GEMINI_API_KEY?: string;
4839
/** MCP session Durable Object namespace — one addressable isolate per MCP
4940
* session (the DO id IS the session id), so a session survives across the
5041
* Worker's stateless isolates. */
@@ -90,9 +81,6 @@ export interface CloudflareConfig {
9081
readonly secretKey: string;
9182
/** AI Search instance binding for semantic `tools.search`. */
9283
readonly aiSearch?: AiSearchInstance;
93-
/** Gemini API key for the Vectorize search embeddings (a `wrangler secret`).
94-
* Unset → vectorize search is inert. */
95-
readonly geminiApiKey?: string;
9684
readonly allowLocalNetwork: boolean;
9785
/** Explicit web base URL (`VITE_PUBLIC_SITE_URL`). Unset on a Worker with no
9886
* static URL — the per-request origin is used instead (see RequestWebOrigin). */
@@ -151,7 +139,6 @@ export const loadConfig = (env: CloudflareEnv): CloudflareConfig => {
151139
organizationSlug: resolveOrgSlug(env.SELF_HOSTED_ORG_SLUG),
152140
secretKey,
153141
aiSearch: env.AI_SEARCH,
154-
geminiApiKey: env.GEMINI_API_KEY?.trim() || undefined,
155142
allowLocalNetwork: env.ALLOW_LOCAL_NETWORK === "true",
156143
// Pinned origin via the shared resolver. A Worker receives no PaaS platform
157144
// vars (env: {} — there is nothing to detect), so only the explicit

apps/host-cloudflare/src/execution.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,7 @@ export const makeCloudflarePluginsProvider = (
3939
): Layer.Layer<PluginsProvider> =>
4040
Layer.succeed(PluginsProvider)({
4141
plugins: () =>
42-
makeCloudflarePlugins(
43-
config.secretKey,
44-
undefined,
45-
config.aiSearch,
46-
undefined,
47-
undefined,
48-
config.organizationId,
49-
),
42+
makeCloudflarePlugins(config.secretKey, undefined, config.aiSearch, config.organizationId),
5043
});
5144

5245
export const makeCloudflareHostConfig = (config: CloudflareConfig): Layer.Layer<HostConfig> =>

apps/host-cloudflare/src/plugins.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ import { serviceTokensPlugin } from "@executor-js/plugin-service-tokens/server";
1414
import { semanticSearchHttpPlugin } from "@executor-js/plugin-semantic-search/api";
1515
import {
1616
makeAiSearchToolSearchBackend,
17-
makeVectorizeStore,
18-
ToolSearchBackend,
19-
withCloudflareLimits,
2017
type AiSearchInstance,
21-
type VectorizeIndex,
2218
} from "@executor-js/plugin-semantic-search";
2319

2420
// ---------------------------------------------------------------------------
@@ -41,31 +37,21 @@ import {
4137
//
4238
// Semantic search follows the same opt-in-by-binding shape: the plugin is
4339
// always in the tuple (its reindex route keeps the API shape stable), but it is
44-
// inert until a search backend binding is present. Prefer Cloudflare AI Search
45-
// when bound; otherwise fall back to the Vectorize + Gemini backend.
40+
// inert until the Cloudflare AI Search binding is present.
4641
// ---------------------------------------------------------------------------
4742

4843
export const makeCloudflarePlugins = (
4944
secretKey: string,
5045
analytics?: AnalyticsEngineDataset,
5146
aiSearch?: AiSearchInstance,
52-
vectorize?: VectorizeIndex,
53-
geminiApiKey?: string,
5447
searchNamespace?: string,
5548
) => {
56-
const store = vectorize ? withCloudflareLimits(makeVectorizeStore(vectorize)) : undefined;
5749
const semanticSearchBackend = aiSearch
5850
? makeAiSearchToolSearchBackend({
5951
aiSearch,
6052
namespace: searchNamespace,
6153
})
62-
: store && geminiApiKey
63-
? ToolSearchBackend.vector({
64-
store,
65-
geminiApiKey,
66-
namespace: searchNamespace,
67-
})
68-
: undefined;
54+
: undefined;
6955
return [
7056
openApiHttpPlugin(),
7157
googleHttpPlugin(),

0 commit comments

Comments
 (0)