feat(core): add integration-backed search
This commit is contained in:
parent
41d11a8a89
commit
129012c3ee
50 changed files with 1745 additions and 478 deletions
|
|
@ -3,6 +3,7 @@ export * as Form from "./form.js"
|
|||
import { Schema } from "effect"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { ascending } from "./identifier.js"
|
||||
import { IntegrationID } from "./integration-id.js"
|
||||
import { NonNegativeInt, optional, statics } from "./schema.js"
|
||||
|
||||
const IDSchema = Schema.String.check(Schema.isStartsWith("frm_")).pipe(Schema.brand("Form.ID"))
|
||||
|
|
@ -124,8 +125,15 @@ export const UrlInfo = Schema.Struct({
|
|||
}).annotate({ identifier: "Form.UrlInfo" })
|
||||
export interface UrlInfo extends Schema.Schema.Type<typeof UrlInfo> {}
|
||||
|
||||
export const Info = Schema.Union([FormInfo, UrlInfo]).pipe(Schema.toTaggedUnion("mode"))
|
||||
export type Info = FormInfo | UrlInfo
|
||||
export const IntegrationInfo = Schema.Struct({
|
||||
...InfoBase,
|
||||
mode: Schema.Literal("integration"),
|
||||
integrationID: IntegrationID,
|
||||
}).annotate({ identifier: "Form.IntegrationInfo" })
|
||||
export interface IntegrationInfo extends Schema.Schema.Type<typeof IntegrationInfo> {}
|
||||
|
||||
export const Info = Schema.Union([FormInfo, UrlInfo, IntegrationInfo]).pipe(Schema.toTaggedUnion("mode"))
|
||||
export type Info = FormInfo | UrlInfo | IntegrationInfo
|
||||
|
||||
export const Value = Schema.Union([Schema.String, Schema.Number, Schema.Boolean, Schema.Array(Schema.String)]).annotate(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export { Project } from "./project.js"
|
|||
export { ProjectCopy } from "./project-copy.js"
|
||||
export { Provider } from "./provider.js"
|
||||
export { Reference } from "./reference.js"
|
||||
export { Search } from "./search.js"
|
||||
export { Revert } from "./revert.js"
|
||||
export { Session } from "./session.js"
|
||||
export { Vcs } from "./vcs.js"
|
||||
|
|
|
|||
|
|
@ -76,6 +76,16 @@ export type Method = typeof Method.Type
|
|||
export const Inputs = Schema.Record(Schema.String, Schema.String).annotate({ identifier: "Integration.Inputs" })
|
||||
export type Inputs = typeof Inputs.Type
|
||||
|
||||
export interface SearchCapability extends Schema.Schema.Type<typeof SearchCapability> {}
|
||||
export const SearchCapability = Schema.Struct({
|
||||
type: Schema.Literal("search"),
|
||||
connection: Schema.Literals(["optional", "required"]),
|
||||
selected: Schema.Boolean,
|
||||
}).annotate({ identifier: "Integration.SearchCapability" })
|
||||
|
||||
export const Capability = SearchCapability
|
||||
export type Capability = SearchCapability
|
||||
|
||||
const Updated = ephemeral({
|
||||
type: "integration.updated",
|
||||
schema: {},
|
||||
|
|
@ -96,6 +106,7 @@ export class Info extends Schema.Class<Info>("Integration.Info")({
|
|||
id: ID,
|
||||
name: Schema.String,
|
||||
methods: Schema.Array(Method),
|
||||
capabilities: Schema.Array(Capability),
|
||||
connections: Schema.Array(Connection.Info),
|
||||
}) {}
|
||||
|
||||
|
|
|
|||
26
packages/schema/src/search.ts
Normal file
26
packages/schema/src/search.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
export * as Search from "./search.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { IntegrationID } from "./integration-id.js"
|
||||
import { optional, PositiveInt } from "./schema.js"
|
||||
|
||||
export interface Input extends Schema.Schema.Type<typeof Input> {}
|
||||
export const Input = Schema.Struct({
|
||||
query: Schema.String,
|
||||
providerID: IntegrationID.pipe(optional),
|
||||
numResults: PositiveInt.check(Schema.isLessThanOrEqualTo(20)).pipe(optional),
|
||||
livecrawl: Schema.Literals(["fallback", "preferred"]).pipe(optional),
|
||||
type: Schema.Literals(["auto", "fast", "deep"]).pipe(optional),
|
||||
contextMaxCharacters: PositiveInt.check(Schema.isLessThanOrEqualTo(50_000)).pipe(optional),
|
||||
}).annotate({ identifier: "Search.Input" })
|
||||
|
||||
export interface ProviderOutput extends Schema.Schema.Type<typeof ProviderOutput> {}
|
||||
export const ProviderOutput = Schema.Struct({
|
||||
text: Schema.String,
|
||||
metadata: Schema.Json.pipe(optional),
|
||||
}).annotate({ identifier: "Search.ProviderOutput" })
|
||||
|
||||
export class Result extends Schema.Class<Result>("Search.Result")({
|
||||
providerID: IntegrationID,
|
||||
...ProviderOutput.fields,
|
||||
}) {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue