@@ -26,6 +26,12 @@ describe("mcp-activate-hint", () => {
2626 false ,
2727 ) ;
2828 expect ( isMcpNotActivated ( new Error ( "MCP不存在或未开通" ) ) ) . toBe ( false ) ;
29+ // Nested wrapper phrase must not match (anchored at start).
30+ expect (
31+ isMcpNotActivated (
32+ new BailianError ( "MCP error (-32000): MCP request failed: 404 Not Found - 未开通" ) ,
33+ ) ,
34+ ) . toBe ( false ) ;
2935 } ) ;
3036
3137 test ( "hint 含对应 server 的 MCP 广场深链" , ( ) => {
@@ -38,6 +44,36 @@ describe("mcp-activate-hint", () => {
3844 expect ( mcpActivateHint ( "WebSearch" ) ) . toMatch ( / S S E | S t r e a m a b l e H T T P / i) ;
3945 } ) ;
4046
47+ test ( "WebSearch + 405 streamableHttp 补重开通 hint" , ( ) => {
48+ const original = new BailianError (
49+ "MCP request failed: 405 Method Not Allowed - current mcp not support streamableHttp" ,
50+ ExitCode . GENERAL ,
51+ ) ;
52+ try {
53+ rethrowWithMcpActivateHint ( original , "WebSearch" ) ;
54+ expect . unreachable ( "should throw" ) ;
55+ } catch ( error ) {
56+ expect ( error ) . toBeInstanceOf ( BailianError ) ;
57+ const wrapped = error as BailianError ;
58+ expect ( wrapped . message ) . toBe ( original . message ) ;
59+ expect ( wrapped . hint ) . toMatch ( / S S E | S t r e a m a b l e H T T P | A c t i v a t e | r e - a c t i v a t e / i) ;
60+ expect ( wrapped . hint ) . toContain ( mcpMarketplaceDetailPage ( "WebSearch" ) ) ;
61+ }
62+ } ) ;
63+
64+ test ( "非 WebSearch 的 405 streamableHttp 不补 hint(由 fallback 处理)" , ( ) => {
65+ const original = new BailianError (
66+ "MCP request failed: 405 Method Not Allowed - current mcp not support streamableHttp" ,
67+ ExitCode . GENERAL ,
68+ ) ;
69+ try {
70+ rethrowWithMcpActivateHint ( original , "WebParser" ) ;
71+ expect . unreachable ( "should throw" ) ;
72+ } catch ( error ) {
73+ expect ( error ) . toBe ( original ) ;
74+ }
75+ } ) ;
76+
4177 test ( "rethrow 保留原 message,补 hint" , ( ) => {
4278 const serverCode = "market-cmapi00073529" ;
4379 const original = new BailianError (
0 commit comments