feat(sdk): expose web search
This commit is contained in:
parent
56f44dbcaa
commit
66220071b5
17 changed files with 416 additions and 0 deletions
|
|
@ -887,6 +887,23 @@ export interface DebugApi<E = never> {
|
|||
readonly location: DebugLocationOperation<E>
|
||||
}
|
||||
|
||||
type Endpoint26_0Request = Parameters<RawClient["server.search"]["search.query"]>[0]
|
||||
export type Endpoint26_0Input = {
|
||||
readonly location?: Endpoint26_0Request["query"]["location"]
|
||||
readonly query: Endpoint26_0Request["payload"]["query"]
|
||||
readonly providerID?: Endpoint26_0Request["payload"]["providerID"]
|
||||
readonly numResults?: Endpoint26_0Request["payload"]["numResults"]
|
||||
readonly livecrawl?: Endpoint26_0Request["payload"]["livecrawl"]
|
||||
readonly type?: Endpoint26_0Request["payload"]["type"]
|
||||
readonly contextMaxCharacters?: Endpoint26_0Request["payload"]["contextMaxCharacters"]
|
||||
}
|
||||
export type Endpoint26_0Output = EffectValue<ReturnType<RawClient["server.search"]["search.query"]>>
|
||||
export type SearchQueryOperation<E = never> = (input: Endpoint26_0Input) => Effect.Effect<Endpoint26_0Output, E>
|
||||
|
||||
export interface SearchApi<E = never> {
|
||||
readonly query: SearchQueryOperation<E>
|
||||
}
|
||||
|
||||
export interface AppApi<E = never> {
|
||||
readonly health: HealthApi<E>
|
||||
readonly location: LocationApi<E>
|
||||
|
|
@ -914,4 +931,5 @@ export interface AppApi<E = never> {
|
|||
readonly projectCopy: ProjectCopyApi<E>
|
||||
readonly vcs: VcsApi<E>
|
||||
readonly debug: DebugApi<E>
|
||||
readonly search: SearchApi<E>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1066,6 +1066,31 @@ const Endpoint25_0 = (raw: RawClient["server.debug"]) => () =>
|
|||
|
||||
const adaptGroup25 = (raw: RawClient["server.debug"]) => ({ location: Endpoint25_0(raw) })
|
||||
|
||||
type Endpoint26_0Request = Parameters<RawClient["server.search"]["search.query"]>[0]
|
||||
type Endpoint26_0Input = {
|
||||
readonly location?: Endpoint26_0Request["query"]["location"]
|
||||
readonly query: Endpoint26_0Request["payload"]["query"]
|
||||
readonly providerID?: Endpoint26_0Request["payload"]["providerID"]
|
||||
readonly numResults?: Endpoint26_0Request["payload"]["numResults"]
|
||||
readonly livecrawl?: Endpoint26_0Request["payload"]["livecrawl"]
|
||||
readonly type?: Endpoint26_0Request["payload"]["type"]
|
||||
readonly contextMaxCharacters?: Endpoint26_0Request["payload"]["contextMaxCharacters"]
|
||||
}
|
||||
const Endpoint26_0 = (raw: RawClient["server.search"]) => (input: Endpoint26_0Input) =>
|
||||
raw["search.query"]({
|
||||
query: { location: input["location"] },
|
||||
payload: {
|
||||
query: input["query"],
|
||||
providerID: input["providerID"],
|
||||
numResults: input["numResults"],
|
||||
livecrawl: input["livecrawl"],
|
||||
type: input["type"],
|
||||
contextMaxCharacters: input["contextMaxCharacters"],
|
||||
},
|
||||
}).pipe(Effect.mapError(mapClientError))
|
||||
|
||||
const adaptGroup26 = (raw: RawClient["server.search"]) => ({ query: Endpoint26_0(raw) })
|
||||
|
||||
const adaptClient = (raw: RawClient) => ({
|
||||
health: adaptGroup0(raw["server.health"]),
|
||||
location: adaptGroup1(raw["server.location"]),
|
||||
|
|
@ -1093,6 +1118,7 @@ const adaptClient = (raw: RawClient) => ({
|
|||
projectCopy: adaptGroup23(raw["server.projectCopy"]),
|
||||
vcs: adaptGroup24(raw["server.vcs"]),
|
||||
debug: adaptGroup25(raw["server.debug"]),
|
||||
search: adaptGroup26(raw["server.search"]),
|
||||
})
|
||||
|
||||
export const make = (options?: { readonly baseUrl?: URL | string }) =>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export type {
|
|||
PluginApi,
|
||||
ProviderApi,
|
||||
ReferenceApi,
|
||||
SearchApi,
|
||||
SessionApi,
|
||||
SkillApi,
|
||||
} from "./api.js"
|
||||
|
|
@ -36,6 +37,7 @@ export { Provider } from "@opencode-ai/schema/provider"
|
|||
export { Pty } from "@opencode-ai/schema/pty"
|
||||
export { Question } from "@opencode-ai/schema/question"
|
||||
export { Reference } from "@opencode-ai/schema/reference"
|
||||
export { Search } from "@opencode-ai/schema/search"
|
||||
export { AbsolutePath, RelativePath } from "@opencode-ai/schema/schema"
|
||||
export { Session } from "@opencode-ai/schema/session"
|
||||
export { SessionInput } from "@opencode-ai/schema/session-input"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import type {
|
|||
PluginApi as EffectPluginApi,
|
||||
ProviderApi as EffectProviderApi,
|
||||
ReferenceApi as EffectReferenceApi,
|
||||
SearchApi as EffectSearchApi,
|
||||
SessionApi as EffectSessionApi,
|
||||
SkillApi as EffectSkillApi,
|
||||
} from "../effect/api/api.js"
|
||||
|
|
@ -32,6 +33,7 @@ export type ModelApi = PromisifyApi<EffectModelApi<unknown>>
|
|||
export type PluginApi = PromisifyApi<EffectPluginApi<unknown>>
|
||||
export type ProviderApi = PromisifyApi<EffectProviderApi<unknown>>
|
||||
export type ReferenceApi = PromisifyApi<EffectReferenceApi<unknown>>
|
||||
export type SearchApi = PromisifyApi<EffectSearchApi<unknown>>
|
||||
export type SessionApi = PromisifyApi<EffectSessionApi<unknown>>
|
||||
export type SkillApi = PromisifyApi<EffectSkillApi<unknown>>
|
||||
|
||||
|
|
|
|||
|
|
@ -177,6 +177,8 @@ import type {
|
|||
VcsDiffInput,
|
||||
VcsDiffOutput,
|
||||
DebugLocationOutput,
|
||||
SearchQueryInput,
|
||||
SearchQueryOutput,
|
||||
} from "./types"
|
||||
import { ClientError } from "./client-error"
|
||||
|
||||
|
|
@ -1483,6 +1485,28 @@ export function make(options: ClientOptions) {
|
|||
requestOptions,
|
||||
),
|
||||
},
|
||||
search: {
|
||||
query: (input: SearchQueryInput, requestOptions?: RequestOptions) =>
|
||||
request<SearchQueryOutput>(
|
||||
{
|
||||
method: "POST",
|
||||
path: `/api/search`,
|
||||
query: { location: input["location"] },
|
||||
body: {
|
||||
query: input["query"],
|
||||
providerID: input["providerID"],
|
||||
numResults: input["numResults"],
|
||||
livecrawl: input["livecrawl"],
|
||||
type: input["type"],
|
||||
contextMaxCharacters: input["contextMaxCharacters"],
|
||||
},
|
||||
successStatus: 200,
|
||||
declaredStatuses: [400, 503, 401],
|
||||
empty: false,
|
||||
},
|
||||
requestOptions,
|
||||
),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6084,3 +6084,66 @@ export type VcsDiffOutput = {
|
|||
}
|
||||
|
||||
export type DebugLocationOutput = ReadonlyArray<{ readonly directory: string; readonly workspaceID?: string }>
|
||||
|
||||
export type SearchQueryInput = {
|
||||
readonly location?: {
|
||||
readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
|
||||
}["location"]
|
||||
readonly query: {
|
||||
readonly query: string
|
||||
readonly providerID?: string
|
||||
readonly numResults?: number
|
||||
readonly livecrawl?: "fallback" | "preferred"
|
||||
readonly type?: "auto" | "fast" | "deep"
|
||||
readonly contextMaxCharacters?: number
|
||||
}["query"]
|
||||
readonly providerID?: {
|
||||
readonly query: string
|
||||
readonly providerID?: string
|
||||
readonly numResults?: number
|
||||
readonly livecrawl?: "fallback" | "preferred"
|
||||
readonly type?: "auto" | "fast" | "deep"
|
||||
readonly contextMaxCharacters?: number
|
||||
}["providerID"]
|
||||
readonly numResults?: {
|
||||
readonly query: string
|
||||
readonly providerID?: string
|
||||
readonly numResults?: number
|
||||
readonly livecrawl?: "fallback" | "preferred"
|
||||
readonly type?: "auto" | "fast" | "deep"
|
||||
readonly contextMaxCharacters?: number
|
||||
}["numResults"]
|
||||
readonly livecrawl?: {
|
||||
readonly query: string
|
||||
readonly providerID?: string
|
||||
readonly numResults?: number
|
||||
readonly livecrawl?: "fallback" | "preferred"
|
||||
readonly type?: "auto" | "fast" | "deep"
|
||||
readonly contextMaxCharacters?: number
|
||||
}["livecrawl"]
|
||||
readonly type?: {
|
||||
readonly query: string
|
||||
readonly providerID?: string
|
||||
readonly numResults?: number
|
||||
readonly livecrawl?: "fallback" | "preferred"
|
||||
readonly type?: "auto" | "fast" | "deep"
|
||||
readonly contextMaxCharacters?: number
|
||||
}["type"]
|
||||
readonly contextMaxCharacters?: {
|
||||
readonly query: string
|
||||
readonly providerID?: string
|
||||
readonly numResults?: number
|
||||
readonly livecrawl?: "fallback" | "preferred"
|
||||
readonly type?: "auto" | "fast" | "deep"
|
||||
readonly contextMaxCharacters?: number
|
||||
}["contextMaxCharacters"]
|
||||
}
|
||||
|
||||
export type SearchQueryOutput = {
|
||||
readonly location: {
|
||||
readonly directory: string
|
||||
readonly workspaceID?: string
|
||||
readonly project: { readonly id: string; readonly directory: string }
|
||||
}
|
||||
readonly data: { readonly providerID: string; readonly text: string; readonly metadata?: JsonValue }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export type {
|
|||
PluginApi,
|
||||
ProviderApi,
|
||||
ReferenceApi,
|
||||
SearchApi,
|
||||
SessionApi,
|
||||
SkillApi,
|
||||
} from "./api.js"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue