refactor(search): persist provider in global config
This commit is contained in:
parent
48f8b5de98
commit
ccad83549d
38 changed files with 736 additions and 589 deletions
|
|
@ -50,7 +50,6 @@ export function host(overrides: Overrides = {}): PluginContext {
|
|||
integration: overrides.integration ?? {
|
||||
list: () => Effect.die("unused integration.list"),
|
||||
get: () => Effect.die("unused integration.get"),
|
||||
selectCapability: () => Effect.die("unused integration.selectCapability"),
|
||||
connectKey: () => Effect.die("unused integration.connectKey"),
|
||||
connectOauth: () => Effect.die("unused integration.connectOauth"),
|
||||
attemptStatus: () => Effect.die("unused integration.attemptStatus"),
|
||||
|
|
@ -195,7 +194,6 @@ export function integrationHost(integration: Integration.Interface): PluginConte
|
|||
return {
|
||||
list: () => Effect.die("unused integration.list"),
|
||||
get: () => Effect.die("unused integration.get"),
|
||||
selectCapability: () => Effect.die("unused integration.selectCapability"),
|
||||
connectKey: () => Effect.die("unused integration.connectKey"),
|
||||
connectOauth: () => Effect.die("unused integration.connectOauth"),
|
||||
attemptStatus: () => Effect.die("unused integration.attemptStatus"),
|
||||
|
|
@ -257,9 +255,9 @@ function registerIntegration(draft: Integration.Draft, definition: IntegrationDe
|
|||
)
|
||||
}
|
||||
if (!definition.search) return
|
||||
draft.capability.search.update({
|
||||
draft.search.update({
|
||||
integrationID,
|
||||
capability: { type: "search", connection: definition.search.connection },
|
||||
connection: definition.search.connection,
|
||||
execute: definition.search.execute,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,6 @@ describe("ModelsDevPlugin", () => {
|
|||
names: ["ACME_API_KEY"],
|
||||
},
|
||||
],
|
||||
capabilities: [],
|
||||
connections: [],
|
||||
}),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ describe("fromPromise", () => {
|
|||
name: "Promise Search",
|
||||
methods: [{ type: "env", names: ["PROMISE_SEARCH_KEY"] }],
|
||||
})
|
||||
const provider = yield* integrations.capability.search.get(Integration.ID.make("promise-search"))
|
||||
const provider = yield* integrations.search.get(Integration.ID.make("promise-search"))
|
||||
if (!provider) return yield* Effect.die("Expected promise search provider")
|
||||
expect(yield* provider.execute({ query: "effect" }, {})).toEqual({ text: "promise: effect" })
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ describe("built-in search integrations", () => {
|
|||
expect(yield* integrations.get(Integration.ID.make("test-search"))).toMatchObject({
|
||||
name: "Test Search",
|
||||
methods: [{ type: "key", label: "API key" }],
|
||||
capabilities: [{ type: "search", connection: "required" }],
|
||||
search: { connection: "required" },
|
||||
})
|
||||
yield* registration.dispose
|
||||
expect(yield* integrations.get(Integration.ID.make("test-search"))).toBeUndefined()
|
||||
|
|
@ -53,9 +53,9 @@ describe("built-in search integrations", () => {
|
|||
id: "exa",
|
||||
name: "Exa",
|
||||
methods: [{ type: "key" }, { type: "env", names: ["EXA_API_KEY"] }],
|
||||
capabilities: [{ type: "search", connection: "optional", selected: false }],
|
||||
search: { connection: "optional" },
|
||||
})
|
||||
const provider = yield* integrations.capability.search.get(Integration.ID.make("exa"))
|
||||
const provider = yield* integrations.search.get(Integration.ID.make("exa"))
|
||||
if (!provider) return yield* Effect.die("Expected Exa search provider")
|
||||
expect(
|
||||
yield* provider.execute(
|
||||
|
|
@ -97,7 +97,7 @@ describe("built-in search integrations", () => {
|
|||
Effect.gen(function* () {
|
||||
const integrations = yield* Integration.Service
|
||||
yield* SearchParallel.Plugin.effect(host({ integration: integrationHost(integrations) }))
|
||||
const provider = yield* integrations.capability.search.get(Integration.ID.make("parallel"))
|
||||
const provider = yield* integrations.search.get(Integration.ID.make("parallel"))
|
||||
if (!provider) return yield* Effect.die("Expected Parallel search provider")
|
||||
|
||||
const output = yield* provider.execute(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue