feat(core): add pluggable web search (#35558)
Co-authored-by: Dax Raad <d@ironbay.co>
This commit is contained in:
parent
2ddc91a0e8
commit
efb629a33a
57 changed files with 1700 additions and 587 deletions
|
|
@ -36,6 +36,7 @@ import { TuiEvent } from "./tui-event.js"
|
|||
import { VcsEvent } from "./vcs-event.js"
|
||||
import { WorkspaceEvent } from "./workspace-event.js"
|
||||
import { WorktreeEvent } from "./worktree-event.js"
|
||||
import { WebSearch } from "./websearch.js"
|
||||
|
||||
const sessionV1DurableDefinitions = SessionV1.Event.Definitions.filter(
|
||||
(definition) => definition.durability === "durable",
|
||||
|
|
@ -67,6 +68,7 @@ const featureDefinitions = Event.inventory(
|
|||
...Shell.Event.Definitions,
|
||||
...Question.Event.Definitions,
|
||||
...Form.Event.Definitions,
|
||||
...WebSearch.Event.Definitions,
|
||||
)
|
||||
|
||||
export const ServerDefinitions = Event.inventory(
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export { Project } from "./project.js"
|
|||
export { ProjectCopy } from "./project-copy.js"
|
||||
export { Provider } from "./provider.js"
|
||||
export { Reference } from "./reference.js"
|
||||
export { WebSearch } from "./websearch.js"
|
||||
export { Session } from "./session.js"
|
||||
export { Vcs } from "./vcs.js"
|
||||
export { SessionPending } from "./session-pending.js"
|
||||
|
|
|
|||
42
packages/schema/src/websearch.ts
Normal file
42
packages/schema/src/websearch.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
export * as WebSearch from "./websearch.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { optional } from "./schema.js"
|
||||
|
||||
export const ID = Schema.String.pipe(Schema.brand("WebSearch.ID"))
|
||||
export type ID = typeof ID.Type
|
||||
|
||||
export interface Provider extends Schema.Schema.Type<typeof Provider> {}
|
||||
export const Provider = Schema.Struct({
|
||||
id: ID,
|
||||
name: Schema.String,
|
||||
}).annotate({ identifier: "WebSearch.Provider" })
|
||||
|
||||
export interface Input extends Schema.Schema.Type<typeof Input> {}
|
||||
export const Input = Schema.Struct({
|
||||
query: Schema.String,
|
||||
providerID: ID.pipe(optional),
|
||||
}).annotate({ identifier: "WebSearch.Input" })
|
||||
export type ProviderInput = Pick<Input, "query">
|
||||
|
||||
export interface Result extends Schema.Schema.Type<typeof Result> {}
|
||||
export const Result = Schema.Struct({
|
||||
url: Schema.String,
|
||||
title: Schema.String.pipe(optional),
|
||||
content: Schema.String.pipe(optional),
|
||||
time: Schema.Struct({
|
||||
published: Schema.Finite.pipe(optional),
|
||||
}),
|
||||
}).annotate({ identifier: "WebSearch.Result" })
|
||||
|
||||
export class Response extends Schema.Class<Response>("WebSearch.Response")({
|
||||
providerID: ID,
|
||||
results: Schema.Array(Result),
|
||||
}) {}
|
||||
|
||||
const Updated = ephemeral({
|
||||
type: "websearch.updated",
|
||||
schema: {},
|
||||
})
|
||||
export const Event = { Updated, Definitions: inventory(Updated) }
|
||||
Loading…
Add table
Add a link
Reference in a new issue