@noosphere/agent-core 0.2.0-alpha.2 → 0.2.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -194,6 +194,23 @@ interface CommitmentSuccessEvent {
194
194
  requestStartedEvent?: RequestStartedEvent;
195
195
  }
196
196
 
197
+ /**
198
+ * Connection state for EventMonitor
199
+ */
200
+ type ConnectionState = 'INIT' | 'WS_CONNECTING' | 'WS_ACTIVE' | 'WS_RECONNECTING' | 'HTTP_FALLBACK';
201
+ /**
202
+ * Connection configuration
203
+ */
204
+ interface ConnectionConfig {
205
+ /** WS connection timeout in ms (default: 10000) */
206
+ wsConnectTimeoutMs: number;
207
+ /** Max WS connection retries before HTTP fallback (default: 3) */
208
+ wsMaxConnectRetries: number;
209
+ /** Delay between WS connection retries in ms (default: 5000) */
210
+ wsConnectRetryDelayMs: number;
211
+ /** Interval for WS recovery attempts when in HTTP fallback (default: 60000) */
212
+ wsRecoveryIntervalMs: number;
213
+ }
197
214
  interface CheckpointData$1 {
198
215
  blockNumber: number;
199
216
  blockHash?: string;
@@ -202,6 +219,7 @@ interface CheckpointData$1 {
202
219
  interface EventMonitorOptions {
203
220
  loadCheckpoint?: () => CheckpointData$1 | undefined;
204
221
  saveCheckpoint?: (checkpoint: CheckpointData$1) => void;
222
+ connectionConfig?: Partial<ConnectionConfig>;
205
223
  }
206
224
  declare class EventMonitor extends EventEmitter {
207
225
  private config;
@@ -218,8 +236,48 @@ declare class EventMonitor extends EventEmitter {
218
236
  private heartbeatInterval;
219
237
  private lastEventTime;
220
238
  private checkpointCallbacks?;
239
+ private connectionState;
240
+ private connectionConfig;
241
+ private wsRecoveryInterval;
242
+ private pollingInterval;
221
243
  constructor(config: AgentConfig, routerAbi: any[], coordinatorAbi: any[], options?: EventMonitorOptions);
244
+ /**
245
+ * Get current connection state
246
+ */
247
+ getConnectionState(): ConnectionState;
248
+ /**
249
+ * Get connection mode string for health API
250
+ */
251
+ getConnectionMode(): 'websocket' | 'http_polling' | 'connecting';
222
252
  connect(): Promise<void>;
253
+ /**
254
+ * Connect via WebSocket with timeout
255
+ */
256
+ private connectWebSocketWithTimeout;
257
+ /**
258
+ * Connect via HTTP (fallback mode)
259
+ */
260
+ private connectHttp;
261
+ /**
262
+ * Initialize contract instances
263
+ */
264
+ private initializeContracts;
265
+ /**
266
+ * Start WS recovery loop when in HTTP fallback mode
267
+ */
268
+ private startWsRecoveryLoop;
269
+ /**
270
+ * Stop WS recovery loop
271
+ */
272
+ private stopWsRecoveryLoop;
273
+ /**
274
+ * Stop HTTP polling
275
+ */
276
+ private stopPolling;
277
+ /**
278
+ * Sleep helper
279
+ */
280
+ private sleep;
223
281
  start(): Promise<void>;
224
282
  private replayEvents;
225
283
  private startWebSocketListening;
@@ -609,6 +667,16 @@ declare class NoosphereAgent {
609
667
  * Get scheduler service (for advanced usage)
610
668
  */
611
669
  getScheduler(): SchedulerService;
670
+ /**
671
+ * Get current connection state
672
+ * @returns Connection state: 'INIT' | 'WS_CONNECTING' | 'WS_ACTIVE' | 'WS_RECONNECTING' | 'HTTP_FALLBACK'
673
+ */
674
+ getConnectionState(): string;
675
+ /**
676
+ * Get current connection mode
677
+ * @returns Connection mode: 'websocket' | 'http_polling' | 'connecting'
678
+ */
679
+ getConnectionMode(): 'websocket' | 'http_polling' | 'connecting';
612
680
  }
613
681
 
614
682
  /**
@@ -859,4 +927,4 @@ declare class PayloadResolver {
859
927
  deserialize(serialized: string): PayloadData;
860
928
  }
861
929
 
862
- export { type AgentConfig, type CheckpointData$1 as CheckpointData, type Commitment, type CommitmentSuccessCallbackEvent, type CommitmentSuccessEvent, CommitmentUtils, type ComputeDeliveredEvent, type ComputeSubscription, ConfigLoader, type ContainerConfig, type ContainerExecutionConfig, ContainerManager, type ContainerMetadata, EventMonitor, FulfillResult, NoosphereAgent, type NoosphereAgentConfig, PayloadResolver, type PayloadResolverConfig, PayloadScheme, PayloadUtils, type Payment, type ProofVerificationRequest, RequestIdUtils, type RequestStartedCallbackEvent, type RequestStartedEvent, type ResolvedPayload, type RetryableEvent, SchedulerService, type VerifierMetadata };
930
+ export { type AgentConfig, type CheckpointData$1 as CheckpointData, type Commitment, type CommitmentSuccessCallbackEvent, type CommitmentSuccessEvent, CommitmentUtils, type ComputeDeliveredEvent, type ComputeSubscription, ConfigLoader, type ConnectionConfig, type ConnectionState, type ContainerConfig, type ContainerExecutionConfig, ContainerManager, type ContainerMetadata, EventMonitor, type EventMonitorOptions, FulfillResult, NoosphereAgent, type NoosphereAgentConfig, PayloadResolver, type PayloadResolverConfig, PayloadScheme, PayloadUtils, type Payment, type ProofVerificationRequest, RequestIdUtils, type RequestStartedCallbackEvent, type RequestStartedEvent, type ResolvedPayload, type RetryableEvent, SchedulerService, type VerifierMetadata };
package/dist/index.d.ts CHANGED
@@ -194,6 +194,23 @@ interface CommitmentSuccessEvent {
194
194
  requestStartedEvent?: RequestStartedEvent;
195
195
  }
196
196
 
197
+ /**
198
+ * Connection state for EventMonitor
199
+ */
200
+ type ConnectionState = 'INIT' | 'WS_CONNECTING' | 'WS_ACTIVE' | 'WS_RECONNECTING' | 'HTTP_FALLBACK';
201
+ /**
202
+ * Connection configuration
203
+ */
204
+ interface ConnectionConfig {
205
+ /** WS connection timeout in ms (default: 10000) */
206
+ wsConnectTimeoutMs: number;
207
+ /** Max WS connection retries before HTTP fallback (default: 3) */
208
+ wsMaxConnectRetries: number;
209
+ /** Delay between WS connection retries in ms (default: 5000) */
210
+ wsConnectRetryDelayMs: number;
211
+ /** Interval for WS recovery attempts when in HTTP fallback (default: 60000) */
212
+ wsRecoveryIntervalMs: number;
213
+ }
197
214
  interface CheckpointData$1 {
198
215
  blockNumber: number;
199
216
  blockHash?: string;
@@ -202,6 +219,7 @@ interface CheckpointData$1 {
202
219
  interface EventMonitorOptions {
203
220
  loadCheckpoint?: () => CheckpointData$1 | undefined;
204
221
  saveCheckpoint?: (checkpoint: CheckpointData$1) => void;
222
+ connectionConfig?: Partial<ConnectionConfig>;
205
223
  }
206
224
  declare class EventMonitor extends EventEmitter {
207
225
  private config;
@@ -218,8 +236,48 @@ declare class EventMonitor extends EventEmitter {
218
236
  private heartbeatInterval;
219
237
  private lastEventTime;
220
238
  private checkpointCallbacks?;
239
+ private connectionState;
240
+ private connectionConfig;
241
+ private wsRecoveryInterval;
242
+ private pollingInterval;
221
243
  constructor(config: AgentConfig, routerAbi: any[], coordinatorAbi: any[], options?: EventMonitorOptions);
244
+ /**
245
+ * Get current connection state
246
+ */
247
+ getConnectionState(): ConnectionState;
248
+ /**
249
+ * Get connection mode string for health API
250
+ */
251
+ getConnectionMode(): 'websocket' | 'http_polling' | 'connecting';
222
252
  connect(): Promise<void>;
253
+ /**
254
+ * Connect via WebSocket with timeout
255
+ */
256
+ private connectWebSocketWithTimeout;
257
+ /**
258
+ * Connect via HTTP (fallback mode)
259
+ */
260
+ private connectHttp;
261
+ /**
262
+ * Initialize contract instances
263
+ */
264
+ private initializeContracts;
265
+ /**
266
+ * Start WS recovery loop when in HTTP fallback mode
267
+ */
268
+ private startWsRecoveryLoop;
269
+ /**
270
+ * Stop WS recovery loop
271
+ */
272
+ private stopWsRecoveryLoop;
273
+ /**
274
+ * Stop HTTP polling
275
+ */
276
+ private stopPolling;
277
+ /**
278
+ * Sleep helper
279
+ */
280
+ private sleep;
223
281
  start(): Promise<void>;
224
282
  private replayEvents;
225
283
  private startWebSocketListening;
@@ -609,6 +667,16 @@ declare class NoosphereAgent {
609
667
  * Get scheduler service (for advanced usage)
610
668
  */
611
669
  getScheduler(): SchedulerService;
670
+ /**
671
+ * Get current connection state
672
+ * @returns Connection state: 'INIT' | 'WS_CONNECTING' | 'WS_ACTIVE' | 'WS_RECONNECTING' | 'HTTP_FALLBACK'
673
+ */
674
+ getConnectionState(): string;
675
+ /**
676
+ * Get current connection mode
677
+ * @returns Connection mode: 'websocket' | 'http_polling' | 'connecting'
678
+ */
679
+ getConnectionMode(): 'websocket' | 'http_polling' | 'connecting';
612
680
  }
613
681
 
614
682
  /**
@@ -859,4 +927,4 @@ declare class PayloadResolver {
859
927
  deserialize(serialized: string): PayloadData;
860
928
  }
861
929
 
862
- export { type AgentConfig, type CheckpointData$1 as CheckpointData, type Commitment, type CommitmentSuccessCallbackEvent, type CommitmentSuccessEvent, CommitmentUtils, type ComputeDeliveredEvent, type ComputeSubscription, ConfigLoader, type ContainerConfig, type ContainerExecutionConfig, ContainerManager, type ContainerMetadata, EventMonitor, FulfillResult, NoosphereAgent, type NoosphereAgentConfig, PayloadResolver, type PayloadResolverConfig, PayloadScheme, PayloadUtils, type Payment, type ProofVerificationRequest, RequestIdUtils, type RequestStartedCallbackEvent, type RequestStartedEvent, type ResolvedPayload, type RetryableEvent, SchedulerService, type VerifierMetadata };
930
+ export { type AgentConfig, type CheckpointData$1 as CheckpointData, type Commitment, type CommitmentSuccessCallbackEvent, type CommitmentSuccessEvent, CommitmentUtils, type ComputeDeliveredEvent, type ComputeSubscription, ConfigLoader, type ConnectionConfig, type ConnectionState, type ContainerConfig, type ContainerExecutionConfig, ContainerManager, type ContainerMetadata, EventMonitor, type EventMonitorOptions, FulfillResult, NoosphereAgent, type NoosphereAgentConfig, PayloadResolver, type PayloadResolverConfig, PayloadScheme, PayloadUtils, type Payment, type ProofVerificationRequest, RequestIdUtils, type RequestStartedCallbackEvent, type RequestStartedEvent, type ResolvedPayload, type RetryableEvent, SchedulerService, type VerifierMetadata };