@@ -40,6 +40,7 @@ import { type ToolModule } from './server.toolsUser';
4040 * registered with the server.
4141 * @property urlRegex - Regular expression pattern for URL matching.
4242 * @property version - Version of the package.
43+ * @property xhrFetch - XHR and Fetch options.
4344 */
4445interface DefaultOptions < TLogOptions = LoggingOptions > {
4546 contextPath : string ;
@@ -73,6 +74,7 @@ interface DefaultOptions<TLogOptions = LoggingOptions> {
7374 toolModules : ToolModule | ToolModule [ ] ;
7475 urlRegex : RegExp ;
7576 version : string ;
77+ xhrFetch : XhrFetchOptions ;
7678}
7779
7880/**
@@ -153,13 +155,19 @@ interface LoggingSession extends LoggingOptions {
153155 readonly channelName : string ;
154156}
155157
158+ /**
159+ * Base stats options.
160+ */
156161type StatsOptions = {
157162 reportIntervalMs : {
158163 health : number ;
159164 transport : number ;
160165 }
161166} ;
162167
168+ /**
169+ * Stats channel names.
170+ */
163171type StatsChannels = {
164172 readonly health : string ;
165173 readonly session : string ;
@@ -179,6 +187,17 @@ interface StatsSession extends StatsOptions {
179187 channels : StatsChannels
180188}
181189
190+ /**
191+ * XHR and Fetch options.
192+ *
193+ * @interface XhrFetchOptions
194+ *
195+ * @property timeoutMs Timeout for XHR and Fetch requests (ms).
196+ */
197+ interface XhrFetchOptions {
198+ timeoutMs : number ;
199+ }
200+
182201/**
183202 * Base logging options.
184203 */
@@ -205,7 +224,7 @@ const HTTP_OPTIONS: HttpOptions = {
205224 */
206225const PLUGIN_HOST_OPTIONS : PluginHostOptions = {
207226 loadTimeoutMs : 5000 ,
208- invokeTimeoutMs : 10000 ,
227+ invokeTimeoutMs : 10_000 ,
209228 gracePeriodMs : 2000
210229} ;
211230
@@ -250,7 +269,7 @@ const TOOL_MEMO_OPTIONS = {
250269} ;
251270
252271/**
253- * Stats options.
272+ * Default stats options.
254273 */
255274const STATS_OPTIONS : StatsOptions = {
256275 reportIntervalMs : {
@@ -259,6 +278,13 @@ const STATS_OPTIONS: StatsOptions = {
259278 }
260279} ;
261280
281+ /**
282+ * Default XHR and Fetch options.
283+ */
284+ const XHR_FETCH_OPTIONS : XhrFetchOptions = {
285+ timeoutMs : 15_000
286+ } ;
287+
262288/**
263289 * Base logging channel name. Fixed to avoid user override.
264290 */
@@ -387,7 +413,8 @@ const DEFAULT_OPTIONS: DefaultOptions = {
387413 toolModules : [ ] ,
388414 separator : DEFAULT_SEPARATOR ,
389415 urlRegex : URL_REGEX ,
390- version : ( process . env . NODE_ENV === 'local' && '0.0.0' ) || packageJson . version
416+ version : ( process . env . NODE_ENV === 'local' && '0.0.0' ) || packageJson . version ,
417+ xhrFetch : XHR_FETCH_OPTIONS
391418} ;
392419
393420export {
@@ -412,5 +439,6 @@ export {
412439 type LoggingOptions ,
413440 type LoggingSession ,
414441 type PluginHostOptions ,
415- type StatsSession
442+ type StatsSession ,
443+ type XhrFetchOptions
416444} ;
0 commit comments