@@ -29,9 +29,18 @@ type SearchConversationArgs = {
2929}
3030
3131type SearchResponse = {
32- results : SearchResult [ ]
33- cursor ?: string
32+ items : SearchResult [ ]
33+ nextCursorMark ?: string
3434 hasMore : boolean
35+ isPlanRestricted : boolean
36+ }
37+
38+ type SearchThreadResponse = {
39+ commentIds : number [ ]
40+ }
41+
42+ type SearchConversationResponse = {
43+ messageIds : number [ ]
3544}
3645
3746/**
@@ -94,7 +103,7 @@ export class SearchClient {
94103
95104 return {
96105 ...response . data ,
97- results : response . data . results . map ( ( result ) => SearchResultSchema . parse ( result ) ) ,
106+ items : response . data . items . map ( ( result ) => SearchResultSchema . parse ( result ) ) ,
98107 }
99108 }
100109
@@ -106,7 +115,7 @@ export class SearchClient {
106115 * @param args.threadId - The thread ID to search in.
107116 * @param args.limit - Optional limit on number of results returned.
108117 * @param args.cursor - Optional cursor for pagination.
109- * @returns Search results with pagination .
118+ * @returns Comment IDs that match the search query .
110119 *
111120 * @example
112121 * ```typescript
@@ -116,7 +125,7 @@ export class SearchClient {
116125 * })
117126 * ```
118127 */
119- async searchComments ( args : SearchThreadArgs ) : Promise < SearchResponse > {
128+ async searchThread ( args : SearchThreadArgs ) : Promise < SearchThreadResponse > {
120129 const params : Record < string , unknown > = {
121130 query : args . query ,
122131 thread_id : args . threadId ,
@@ -125,18 +134,15 @@ export class SearchClient {
125134 if ( args . limit ) params . limit = args . limit
126135 if ( args . cursor ) params . cursor = args . cursor
127136
128- const response = await request < SearchResponse > (
137+ const response = await request < SearchThreadResponse > (
129138 'GET' ,
130139 this . getBaseUri ( ) ,
131- `${ ENDPOINT_SEARCH } /comments ` ,
140+ `${ ENDPOINT_SEARCH } /thread ` ,
132141 this . apiToken ,
133142 params ,
134143 )
135144
136- return {
137- ...response . data ,
138- results : response . data . results . map ( ( result ) => SearchResultSchema . parse ( result ) ) ,
139- }
145+ return response . data
140146 }
141147
142148 /**
@@ -147,7 +153,7 @@ export class SearchClient {
147153 * @param args.conversationId - The conversation ID to search in.
148154 * @param args.limit - Optional limit on number of results returned.
149155 * @param args.cursor - Optional cursor for pagination.
150- * @returns Search results with pagination .
156+ * @returns Message IDs that match the search query .
151157 *
152158 * @example
153159 * ```typescript
@@ -157,7 +163,7 @@ export class SearchClient {
157163 * })
158164 * ```
159165 */
160- async searchMessages ( args : SearchConversationArgs ) : Promise < SearchResponse > {
166+ async searchConversation ( args : SearchConversationArgs ) : Promise < SearchConversationResponse > {
161167 const params : Record < string , unknown > = {
162168 query : args . query ,
163169 conversation_id : args . conversationId ,
@@ -166,17 +172,14 @@ export class SearchClient {
166172 if ( args . limit ) params . limit = args . limit
167173 if ( args . cursor ) params . cursor = args . cursor
168174
169- const response = await request < SearchResponse > (
175+ const response = await request < SearchConversationResponse > (
170176 'GET' ,
171177 this . getBaseUri ( ) ,
172- `${ ENDPOINT_SEARCH } /messages ` ,
178+ `${ ENDPOINT_SEARCH } /conversation ` ,
173179 this . apiToken ,
174180 params ,
175181 )
176182
177- return {
178- ...response . data ,
179- results : response . data . results . map ( ( result ) => SearchResultSchema . parse ( result ) ) ,
180- }
183+ return response . data
181184 }
182185}
0 commit comments