@@ -39,45 +39,7 @@ vi.mock("openclaw/plugin-sdk/provider-auth-runtime", async (importOriginal) => {
3939 } ;
4040} ) ;
4141
42- vi . mock ( "openclaw/plugin-sdk/provider-web-search" , async ( importOriginal ) => {
43- const original = await importOriginal < typeof import ( "openclaw/plugin-sdk/provider-web-search" ) > ( ) ;
44- return {
45- ...original ,
46- postTrustedWebToolsJson : async (
47- params : {
48- url : string ;
49- apiKey : string ;
50- body : Record < string , unknown > ;
51- extraHeaders ?: Record < string , string > ;
52- signal ?: AbortSignal ;
53- } ,
54- parseResponse : ( response : Response ) => Promise < unknown > ,
55- ) => {
56- const response = await globalThis . fetch ( params . url , {
57- method : "POST" ,
58- headers : {
59- ...params . extraHeaders ,
60- Accept : "application/json" ,
61- Authorization : `Bearer ${ params . apiKey } ` ,
62- "Content-Type" : "application/json" ,
63- } ,
64- body : JSON . stringify ( params . body ) ,
65- ...( params . signal ? { signal : params . signal } : { } ) ,
66- } ) ;
67- if ( ! response . ok ) {
68- const detail =
69- typeof response . text === "function"
70- ? await response . text ( )
71- : response . statusText || String ( response . status ) ;
72- throw new Error ( `xAI API error (${ response . status } ): ${ detail || response . statusText } ` ) ;
73- }
74- return await parseResponse ( response ) ;
75- } ,
76- } ;
77- } ) ;
78-
7942const {
80- extractXaiWebSearchContent,
8143 resolveXaiInlineCitations,
8244 resolveXaiToolSearchConfig,
8345 resolveXaiWebSearchCredential,
@@ -879,71 +841,6 @@ describe("xai web search config resolution", () => {
879841 } ) ;
880842} ) ;
881843
882- describe ( "xai web search response parsing" , ( ) => {
883- it ( "extracts content from Responses API message blocks" , ( ) => {
884- const result = extractXaiWebSearchContent ( {
885- output : [
886- {
887- type : "message" ,
888- content : [ { type : "output_text" , text : "hello from output" } ] ,
889- } ,
890- ] ,
891- } ) ;
892- expect ( result . text ) . toBe ( "hello from output" ) ;
893- expect ( result . annotationCitations ) . toStrictEqual ( [ ] ) ;
894- } ) ;
895-
896- it ( "extracts url_citation annotations from content blocks" , ( ) => {
897- const result = extractXaiWebSearchContent ( {
898- output : [
899- {
900- type : "message" ,
901- content : [
902- {
903- type : "output_text" ,
904- text : "hello with citations" ,
905- annotations : [
906- { type : "url_citation" , url : "https://example.com/a" } ,
907- { type : "url_citation" , url : "https://example.com/b" } ,
908- { type : "url_citation" , url : "https://example.com/a" } ,
909- ] ,
910- } ,
911- ] ,
912- } ,
913- ] ,
914- } ) ;
915- expect ( result . text ) . toBe ( "hello with citations" ) ;
916- expect ( result . annotationCitations ) . toEqual ( [ "https://example.com/a" , "https://example.com/b" ] ) ;
917- } ) ;
918-
919- it ( "falls back to deprecated output_text" , ( ) => {
920- const result = extractXaiWebSearchContent ( { output_text : "hello from output_text" } ) ;
921- expect ( result . text ) . toBe ( "hello from output_text" ) ;
922- expect ( result . annotationCitations ) . toStrictEqual ( [ ] ) ;
923- } ) ;
924-
925- it ( "returns undefined text when no content found" , ( ) => {
926- const result = extractXaiWebSearchContent ( { } ) ;
927- expect ( result . text ) . toBeUndefined ( ) ;
928- expect ( result . annotationCitations ) . toStrictEqual ( [ ] ) ;
929- } ) ;
930-
931- it ( "extracts output_text blocks directly in output array" , ( ) => {
932- const result = extractXaiWebSearchContent ( {
933- output : [
934- { type : "web_search_call" } ,
935- {
936- type : "output_text" ,
937- text : "direct output text" ,
938- annotations : [ { type : "url_citation" , url : "https://example.com/direct" } ] ,
939- } ,
940- ] ,
941- } ) ;
942- expect ( result . text ) . toBe ( "direct output text" ) ;
943- expect ( result . annotationCitations ) . toEqual ( [ "https://example.com/direct" ] ) ;
944- } ) ;
945- } ) ;
946-
947844describe ( "xai provider models" , ( ) => {
948845 it ( "publishes only current selectable chat models newest first" , ( ) => {
949846 expect ( buildXaiCatalogModels ( ) . map ( ( model ) => model . id ) ) . toEqual ( [
0 commit comments