@@ -83,6 +83,42 @@ export type LinkFilter = {
8383 limit ?: number ;
8484} ;
8585
86+ type SearchResultBase = {
87+ thread : { id : string ; title : string | null } ;
88+ priority : { id : string ; title : string | null } ;
89+ similarity : number ;
90+ } ;
91+
92+ export type NoteSearchResult = SearchResultBase & {
93+ type : 'note' ;
94+ id : string ;
95+ content : string | null ;
96+ } ;
97+
98+ export type LinkSearchResult = SearchResultBase & {
99+ type : 'link' ;
100+ id : string ;
101+ title : string | null ;
102+ sourceUrl : string | null ;
103+ content : string | null ;
104+ } ;
105+
106+ export type SearchResult = NoteSearchResult | LinkSearchResult ;
107+
108+ /** Default number of search results returned */
109+ export const SEARCH_DEFAULT_LIMIT = 10 ;
110+ /** Maximum number of search results allowed */
111+ export const SEARCH_MAX_LIMIT = 30 ;
112+
113+ export type SearchOptions = {
114+ /** Max results to return (default: 10, max: 30) */
115+ limit ?: number ;
116+ /** Minimum similarity score 0-1 (default: 0.3) */
117+ threshold ?: number ;
118+ /** Scope search to this priority + descendants (default: twist's installed priority). Must be within the twist's allowed scope. */
119+ priorityId ?: string ;
120+ } ;
121+
86122/**
87123 * Built-in tool for interacting with the core Plot data layer.
88124 *
@@ -197,6 +233,8 @@ export abstract class Plot extends ITool {
197233 contact ?: {
198234 access ?: ContactAccess ;
199235 } ;
236+ /** Enable semantic search across notes and links in the twist's priority scope. */
237+ search ?: true ;
200238 } ;
201239
202240 /**
@@ -518,4 +556,16 @@ export abstract class Plot extends ITool {
518556 */
519557 // eslint-disable-next-line @typescript-eslint/no-unused-vars
520558 abstract getLinks ( filter ?: LinkFilter ) : Promise < Array < { link : Link ; notes : Note [ ] } > > ;
559+
560+ /**
561+ * Searches notes and links using semantic similarity.
562+ *
563+ * Requires `search: true` in Plot options.
564+ *
565+ * @param query - The search query text
566+ * @param options - Optional search configuration
567+ * @returns Promise resolving to array of search results ordered by similarity
568+ */
569+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
570+ abstract search ( query : string , options ?: SearchOptions ) : Promise < SearchResult [ ] > ;
521571}
0 commit comments