fix(types): Add EventStoreConfig type + fix NATS enum imports

This commit is contained in:
Claudia 2026-02-02 09:35:50 +01:00
parent 77dbafc77d
commit ba9f76c027
3 changed files with 12702 additions and 14 deletions

12668
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -207,6 +207,17 @@ export type GatewayNodesConfig = {
denyCommands?: string[]; denyCommands?: string[];
}; };
export type EventStoreConfig = {
/** Enable Event Store (NATS JetStream) integration. */
enabled?: boolean;
/** NATS server URL (default: nats://localhost:4222). */
natsUrl?: string;
/** JetStream stream name (default: openclaw-events). */
streamName?: string;
/** Subject prefix for events (default: openclaw.events). */
subjectPrefix?: string;
};
export type GatewayConfig = { export type GatewayConfig = {
/** Single multiplexed port for Gateway WS + HTTP (default: 18789). */ /** Single multiplexed port for Gateway WS + HTTP (default: 18789). */
port?: number; port?: number;
@ -235,6 +246,8 @@ export type GatewayConfig = {
tls?: GatewayTlsConfig; tls?: GatewayTlsConfig;
http?: GatewayHttpConfig; http?: GatewayHttpConfig;
nodes?: GatewayNodesConfig; nodes?: GatewayNodesConfig;
/** Event Store (NATS JetStream) configuration for persistent event logging. */
eventStore?: EventStoreConfig;
/** /**
* IPs of trusted reverse proxies (e.g. Traefik, nginx). When a connection * IPs of trusted reverse proxies (e.g. Traefik, nginx). When a connection
* arrives from one of these IPs, the Gateway trusts `x-forwarded-for` (or * arrives from one of these IPs, the Gateway trusts `x-forwarded-for` (or

View file

@ -9,7 +9,14 @@
* - Time-travel debugging * - Time-travel debugging
*/ */
import { connect, type NatsConnection, type JetStreamClient, StringCodec } from "nats"; import {
connect,
type NatsConnection,
type JetStreamClient,
StringCodec,
RetentionPolicy,
StorageType,
} from "nats";
import type { AgentEventPayload } from "./agent-events.js"; import type { AgentEventPayload } from "./agent-events.js";
import { onAgentEvent } from "./agent-events.js"; import { onAgentEvent } from "./agent-events.js";
@ -150,11 +157,11 @@ async function ensureStream(js: JetStreamClient, config: EventStoreConfig): Prom
await jsm.streams.add({ await jsm.streams.add({
name: config.streamName, name: config.streamName,
subjects: [`${config.subjectPrefix}.>`], subjects: [`${config.subjectPrefix}.>`],
retention: "limits" as const, retention: RetentionPolicy.Limits,
max_msgs: -1, max_msgs: -1,
max_bytes: -1, max_bytes: -1,
max_age: 0, // Never expire max_age: 0, // Never expire
storage: "file" as const, storage: StorageType.File,
num_replicas: 1, num_replicas: 1,
duplicate_window: 120_000_000_000, // 2 minutes in nanoseconds duplicate_window: 120_000_000_000, // 2 minutes in nanoseconds
}); });