一键导入
ax-provider-eventbus
Use when modifying the event bus — in-process pub/sub, PostgreSQL pub/sub, or streaming event routing in src/providers/eventbus/
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when modifying the event bus — in-process pub/sub, PostgreSQL pub/sub, or streaming event routing in src/providers/eventbus/
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when modifying logging, error handling, or diagnostic messages — logger setup, transports, error diagnosis patterns in src/logger.ts and src/errors.ts
Use when modifying the trusted host process — server orchestration, message routing, IPC handler, request lifecycle, event streaming, file handling, plugin loading, or agent delegation in src/host/
Use when modifying the sandboxed agent process — runner, IPC client, local/IPC tools, tool catalog, prompt building, or identity loading in src/agent/
Use when modifying agent sandbox isolation -- Docker, Apple Container (macOS), or k8s providers in src/providers/sandbox/
Use when modifying IPC protocol between host and agent — schemas, actions, length-prefix framing, or Zod validation in ipc-schemas.ts and ipc-server.ts
AX project architecture and coding skills - use sub-skills for specific subsystems (agent, host, cli, providers, etc.)
| name | ax-provider-eventbus |
| description | Use when modifying the event bus — in-process pub/sub, PostgreSQL pub/sub, or streaming event routing in src/providers/eventbus/ |
The event bus provides real-time typed pub/sub for completion observability. Abstracts between in-process and PostgreSQL LISTEN/NOTIFY (for k8s). Components emit StreamEvents; listeners subscribe globally or per-request.
src/providers/eventbus/types.ts)| Method | Description |
|---|---|
emit(event: StreamEvent) | Publish an event to all matching listeners |
subscribe(listener: EventListener) | Global subscription; returns unsubscribe function |
subscribeRequest(requestId, listener) | Per-request subscription; returns unsubscribe |
listenerCount() | Number of active listeners |
close() | Tear down the bus and all subscriptions |
| Provider | File | Transport | Notes |
|---|---|---|---|
inprocess | inprocess.ts | In-memory | Wraps existing createEventBus(); no-op close() |
postgres | postgres.ts | PostgreSQL LISTEN/NOTIFY | Persistent pub/sub via PostgreSQL |
Provider map entries in src/host/provider-map.ts:
eventbus: {
inprocess: '../providers/eventbus/inprocess.js',
postgres: '../providers/eventbus/postgres.js',
}
createEventBus() utility function.close() is a no-op (listeners are garbage-collected with the process).events.global + events.{requestId}.natsConnectOptions('eventbus') from src/utils/nats.ts for consistent server URL, auth, and reconnect behavior across all NATS callers.create() is async (connects to NATS); in-process is sync — caller must handle both.natsConnectOptions() utility for server/auth configuration.LISTEN/NOTIFY for event routing with dual-channel pattern: events_global + events_{requestId}.DatabaseProvider (PostgreSQL instance).create() is async (connects to database).Adding a new event bus implementation:
src/providers/eventbus/<name>.ts implementing EventBusProvider.create(config: Config).PROVIDER_MAP in src/host/provider-map.ts.tests/providers/eventbus/<name>.test.ts.natsConnectOptions(): Never construct NATS connection options by hand. The src/utils/nats.ts helper centralizes server URL, auth (NATS_USER/NATS_PASS), and reconnect settings. All NATS callers (eventbus, IPC handler, LLM proxy, runner, bridge) use it.src/providers/eventbus/types.ts — Interface definitionssrc/providers/eventbus/inprocess.ts — In-process implementationsrc/providers/eventbus/postgres.ts — PostgreSQL LISTEN/NOTIFY implementationtests/providers/eventbus/inprocess.test.ts