@a1hvdy/cc-openclaw 0.30.0 → 0.32.0
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/src/channels/telegram-mirror/card-renderer.js +9 -5
- package/dist/src/channels/telegram-mirror/commands.js +0 -8
- package/dist/src/channels/telegram-mirror/status-line.js +32 -2
- package/dist/src/constants.js +16 -2
- package/dist/src/engines/persistent-session.js +11 -0
- package/dist/src/lib/config.js +40 -0
- package/dist/src/openai-compat/non-streaming-handler.js +2 -2
- package/dist/src/openai-compat/streaming-handler.js +121 -9
- package/package.json +3 -2
- package/dist/src/channels/adapter.d.ts +0 -103
- package/dist/src/channels/telegram-mirror/askuser.d.ts +0 -107
- package/dist/src/channels/telegram-mirror/burst-accumulator.d.ts +0 -96
- package/dist/src/channels/telegram-mirror/callback-mapping.d.ts +0 -61
- package/dist/src/channels/telegram-mirror/card-renderer.d.ts +0 -68
- package/dist/src/channels/telegram-mirror/card-state.d.ts +0 -83
- package/dist/src/channels/telegram-mirror/commands.d.ts +0 -183
- package/dist/src/channels/telegram-mirror/compose-buffer.d.ts +0 -71
- package/dist/src/channels/telegram-mirror/cost-views.d.ts +0 -58
- package/dist/src/channels/telegram-mirror/failure/callback-data-overflow.d.ts +0 -21
- package/dist/src/channels/telegram-mirror/failure/gateway-down.d.ts +0 -15
- package/dist/src/channels/telegram-mirror/failure/in-flight-conflict.d.ts +0 -15
- package/dist/src/channels/telegram-mirror/failure/index.d.ts +0 -23
- package/dist/src/channels/telegram-mirror/failure/model-5xx.d.ts +0 -16
- package/dist/src/channels/telegram-mirror/failure/network-blip.d.ts +0 -17
- package/dist/src/channels/telegram-mirror/failure/pool-exhausted-fallback.d.ts +0 -15
- package/dist/src/channels/telegram-mirror/failure/rate-limit.d.ts +0 -16
- package/dist/src/channels/telegram-mirror/failure/returning-after-24h.d.ts +0 -14
- package/dist/src/channels/telegram-mirror/failure/types.d.ts +0 -30
- package/dist/src/channels/telegram-mirror/inbound-handler.d.ts +0 -73
- package/dist/src/channels/telegram-mirror/index.d.ts +0 -32
- package/dist/src/channels/telegram-mirror/plan-attachment.d.ts +0 -120
- package/dist/src/channels/telegram-mirror/quota-reader.d.ts +0 -42
- package/dist/src/channels/telegram-mirror/sessions-keyboard.d.ts +0 -84
- package/dist/src/channels/telegram-mirror/soak-log.d.ts +0 -99
- package/dist/src/channels/telegram-mirror/state-machine.d.ts +0 -113
- package/dist/src/channels/telegram-mirror/status-line.d.ts +0 -51
- package/dist/src/channels/telegram-mirror/sync-commands.d.ts +0 -100
- package/dist/src/channels/telegram-mirror/threshold-watcher.d.ts +0 -54
- package/dist/src/channels/telegram-mirror/turn-bridge.d.ts +0 -125
- package/dist/src/cli/checks/bridge-wiring.d.ts +0 -14
- package/dist/src/cli/checks/config-schema.d.ts +0 -11
- package/dist/src/cli/checks/critical-openclaw-json-keys.d.ts +0 -21
- package/dist/src/cli/checks/install-path.d.ts +0 -11
- package/dist/src/cli/checks/patch-scaffold.d.ts +0 -17
- package/dist/src/cli/doctor.d.ts +0 -20
- package/dist/src/cli/index.d.ts +0 -8
- package/dist/src/cli/migrate.d.ts +0 -29
- package/dist/src/command-router/cc-handler.d.ts +0 -67
- package/dist/src/command-router/index.d.ts +0 -2
- package/dist/src/command-router/launch-policy.d.ts +0 -92
- package/dist/src/command-router/resume-policy.d.ts +0 -18
- package/dist/src/command-router/turn-formatter.d.ts +0 -19
- package/dist/src/config/loader.d.ts +0 -8
- package/dist/src/config/schema.d.ts +0 -192
- package/dist/src/constants.d.ts +0 -191
- package/dist/src/council/build-agent-prompt.d.ts +0 -11
- package/dist/src/council/cleanup-worktrees.d.ts +0 -10
- package/dist/src/council/consensus.d.ts +0 -20
- package/dist/src/council/council.d.ts +0 -67
- package/dist/src/council/index.d.ts +0 -2
- package/dist/src/council/system-prompt.d.ts +0 -16
- package/dist/src/council/write-worktree-claude-md.d.ts +0 -10
- package/dist/src/engines/base-oneshot-session.d.ts +0 -87
- package/dist/src/engines/heartbeat-guard.d.ts +0 -93
- package/dist/src/engines/index.d.ts +0 -8
- package/dist/src/engines/persistent-codex-session.d.ts +0 -16
- package/dist/src/engines/persistent-cursor-session.d.ts +0 -21
- package/dist/src/engines/persistent-custom-session.d.ts +0 -78
- package/dist/src/engines/persistent-gemini-session.d.ts +0 -21
- package/dist/src/engines/persistent-session.d.ts +0 -95
- package/dist/src/engines/resolve-bin.d.ts +0 -14
- package/dist/src/engines/subprocess-pool.d.ts +0 -78
- package/dist/src/health/handler.d.ts +0 -39
- package/dist/src/health/index.d.ts +0 -1
- package/dist/src/health/metrics.d.ts +0 -52
- package/dist/src/index.d.ts +0 -57
- package/dist/src/lib/auto-recovery.d.ts +0 -43
- package/dist/src/lib/cache-parity-decide.d.ts +0 -64
- package/dist/src/lib/cache-parity.d.ts +0 -38
- package/dist/src/lib/cc-cli-scan.d.ts +0 -52
- package/dist/src/lib/circuit-breaker.d.ts +0 -21
- package/dist/src/lib/config-service.d.ts +0 -106
- package/dist/src/lib/config.d.ts +0 -136
- package/dist/src/lib/cost-rollup.d.ts +0 -36
- package/dist/src/lib/debounce.d.ts +0 -12
- package/dist/src/lib/debug-tap.d.ts +0 -13
- package/dist/src/lib/domain-error.d.ts +0 -59
- package/dist/src/lib/drift-detector.d.ts +0 -46
- package/dist/src/lib/env-overrides.d.ts +0 -47
- package/dist/src/lib/error-formatter.d.ts +0 -91
- package/dist/src/lib/error-renderer.d.ts +0 -20
- package/dist/src/lib/heartbeat-config.d.ts +0 -34
- package/dist/src/lib/heartbeat-workaround.d.ts +0 -44
- package/dist/src/lib/html-render.d.ts +0 -50
- package/dist/src/lib/http-agent.d.ts +0 -47
- package/dist/src/lib/index.d.ts +0 -7
- package/dist/src/lib/index.js +0 -10
- package/dist/src/lib/json-array.d.ts +0 -10
- package/dist/src/lib/markdown-to-mdv2.d.ts +0 -53
- package/dist/src/lib/markdown-v2.d.ts +0 -27
- package/dist/src/lib/perf/async-compact.d.ts +0 -26
- package/dist/src/lib/perf/direct-sdk.d.ts +0 -26
- package/dist/src/lib/perf/haiku-route.d.ts +0 -19
- package/dist/src/lib/perf/predictive-continuation.d.ts +0 -18
- package/dist/src/lib/perf/read-batch.d.ts +0 -33
- package/dist/src/lib/perf/skill-list-collapse.d.ts +0 -22
- package/dist/src/lib/perf/speculative-bubble.d.ts +0 -27
- package/dist/src/lib/perf/typing-prefetch.d.ts +0 -25
- package/dist/src/lib/probes.d.ts +0 -50
- package/dist/src/lib/register-guard.d.ts +0 -56
- package/dist/src/lib/req-shape-log.d.ts +0 -31
- package/dist/src/lib/safe-upstream-probes.d.ts +0 -25
- package/dist/src/lib/session-registry.d.ts +0 -66
- package/dist/src/lib/spawn-async.d.ts +0 -18
- package/dist/src/lib/status-tee-reader.d.ts +0 -29
- package/dist/src/lib/sysprompt-strip.d.ts +0 -53
- package/dist/src/lib/telegram-bot-api.d.ts +0 -146
- package/dist/src/lib/telemetry.d.ts +0 -38
- package/dist/src/lib/test-mode.d.ts +0 -26
- package/dist/src/lib/trajectory.d.ts +0 -44
- package/dist/src/lib/vendor-paths.d.ts +0 -12
- package/dist/src/lifecycle/boot.d.ts +0 -48
- package/dist/src/lifecycle/patch-manifest.d.ts +0 -82
- package/dist/src/lifecycle/phase-import-upstream.d.ts +0 -12
- package/dist/src/lifecycle/phase-install-patches.d.ts +0 -12
- package/dist/src/lifecycle/phase-schedule-jobs.d.ts +0 -12
- package/dist/src/lifecycle/phase-start-server.d.ts +0 -11
- package/dist/src/lifecycle/phase-validate-config.d.ts +0 -9
- package/dist/src/lifecycle/phase-validate-upstream.d.ts +0 -11
- package/dist/src/lifecycle/phase-wire-handlers.d.ts +0 -12
- package/dist/src/lifecycle/safe-restart.d.ts +0 -99
- package/dist/src/logger.d.ts +0 -14
- package/dist/src/mcp/bridge.d.ts +0 -21
- package/dist/src/mcp/index.d.ts +0 -2
- package/dist/src/models.d.ts +0 -68
- package/dist/src/observability/event-bus.d.ts +0 -86
- package/dist/src/observability/get-event-bus.d.ts +0 -25
- package/dist/src/observability/observability-service.d.ts +0 -19
- package/dist/src/observability/perf-telemetry.d.ts +0 -65
- package/dist/src/observability/subscribers/metrics.d.ts +0 -11
- package/dist/src/observability/subscribers/session-capture.d.ts +0 -15
- package/dist/src/openai-compat/autonomy-rule.d.ts +0 -26
- package/dist/src/openai-compat/bridges/allowlist.d.ts +0 -19
- package/dist/src/openai-compat/bridges/factory.d.ts +0 -30
- package/dist/src/openai-compat/bridges/media-bridge.d.ts +0 -34
- package/dist/src/openai-compat/bridges/openclaw-api-shim.d.ts +0 -54
- package/dist/src/openai-compat/bridges/openclaw-native-tools.d.ts +0 -61
- package/dist/src/openai-compat/bridges/openclaw-tool-registry.d.ts +0 -26
- package/dist/src/openai-compat/bridges/tts-media-bridge.d.ts +0 -19
- package/dist/src/openai-compat/chat-cwd.d.ts +0 -22
- package/dist/src/openai-compat/cli-stream-parser.d.ts +0 -134
- package/dist/src/openai-compat/index.d.ts +0 -1
- package/dist/src/openai-compat/message-extractor.d.ts +0 -84
- package/dist/src/openai-compat/mode-flags.d.ts +0 -34
- package/dist/src/openai-compat/non-streaming-handler.d.ts +0 -29
- package/dist/src/openai-compat/openai-chunk-types.d.ts +0 -35
- package/dist/src/openai-compat/openai-compat.d.ts +0 -49
- package/dist/src/openai-compat/openai-types.d.ts +0 -71
- package/dist/src/openai-compat/parse-route-body.d.ts +0 -24
- package/dist/src/openai-compat/prompts.d.ts +0 -47
- package/dist/src/openai-compat/request-coalescer.d.ts +0 -77
- package/dist/src/openai-compat/response-formatter.d.ts +0 -33
- package/dist/src/openai-compat/session-key-resolver.d.ts +0 -41
- package/dist/src/openai-compat/skill-resolver.d.ts +0 -59
- package/dist/src/openai-compat/sse-translator.d.ts +0 -51
- package/dist/src/openai-compat/status-reporter.d.ts +0 -30
- package/dist/src/openai-compat/streaming-handler.d.ts +0 -52
- package/dist/src/openai-compat/tool-calls-parser.d.ts +0 -34
- package/dist/src/openai-compat/tool-results-serializer.d.ts +0 -60
- package/dist/src/openai-compat/tts-rule.d.ts +0 -20
- package/dist/src/openai-compat/voice-recovery.d.ts +0 -56
- package/dist/src/patches/cache-parity-registry.d.ts +0 -103
- package/dist/src/patches/claude-md-injection.d.ts +0 -10
- package/dist/src/patches/cwd-redirect.d.ts +0 -10
- package/dist/src/patches/embedded-server-route.d.ts +0 -23
- package/dist/src/patches/pricing-overrides.d.ts +0 -10
- package/dist/src/patches/resume-registry-restore.d.ts +0 -11
- package/dist/src/patches/session-pid-tracking.d.ts +0 -10
- package/dist/src/patches/sysprompt-strip.d.ts +0 -46
- package/dist/src/patches/tools-restoration.d.ts +0 -12
- package/dist/src/persistence/migration-v0.d.ts +0 -24
- package/dist/src/persistence/session-registry.d.ts +0 -58
- package/dist/src/proxy/anthropic-adapter.d.ts +0 -136
- package/dist/src/proxy/handler.d.ts +0 -39
- package/dist/src/proxy/index.d.ts +0 -4
- package/dist/src/proxy/schema-cleaner.d.ts +0 -11
- package/dist/src/proxy/thought-cache.d.ts +0 -19
- package/dist/src/session/embedded-server.d.ts +0 -25
- package/dist/src/session/inbox-manager.d.ts +0 -38
- package/dist/src/session/index.d.ts +0 -3
- package/dist/src/session/persisted-sessions.d.ts +0 -50
- package/dist/src/session/session-manager.d.ts +0 -247
- package/dist/src/session/watchdogs.d.ts +0 -92
- package/dist/src/session-bootstrap/boot-self-heal.d.ts +0 -32
- package/dist/src/session-bootstrap/cwd-patch.d.ts +0 -50
- package/dist/src/session-bootstrap/index.d.ts +0 -3
- package/dist/src/session-bootstrap/resume-registry.d.ts +0 -27
- package/dist/src/session-bootstrap/session-hygiene.d.ts +0 -23
- package/dist/src/session-bootstrap/sysprompt-strip.d.ts +0 -24
- package/dist/src/session-bootstrap/think-conflict-resolver.d.ts +0 -32
- package/dist/src/types/route.d.ts +0 -11
- package/dist/src/types/runtime-config.d.ts +0 -208
- package/dist/src/types/sse.d.ts +0 -29
- package/dist/src/types/tool-bridge.d.ts +0 -82
- package/dist/src/types/upstream.d.ts +0 -580
- package/dist/src/types.d.ts +0 -498
- package/dist/src/validation.d.ts +0 -31
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* trajectory — append-only structured event log at
|
|
3
|
-
* `~/.openclaw/workspace/memory/cc-openclaw-trajectory.jsonl`.
|
|
4
|
-
*
|
|
5
|
-
* Every meaningful cc-openclaw event becomes a JSONL row. Schema:
|
|
6
|
-
* { ts, sessionId?, laptopId?, eventType, payload? }
|
|
7
|
-
*
|
|
8
|
-
* v0.4.0 ships 5 event types (session_start, session_end, request_in,
|
|
9
|
-
* response_complete, error). Future v0.4.x adds tool_use, tool_result,
|
|
10
|
-
* fallback_step, drift_warning, budget_event per event-vocabulary.md.
|
|
11
|
-
*
|
|
12
|
-
* Default OFF — set CC_OPENCLAW_TRAJECTORY=1 in env to opt in.
|
|
13
|
-
*
|
|
14
|
-
* Size-based rotation deferred to v0.4.x. v0.4.0 ships unbounded; if file
|
|
15
|
-
* exceeds 100 MB, run `gzip cc-openclaw-trajectory.jsonl && rm` manually.
|
|
16
|
-
*/
|
|
17
|
-
export type EventType = 'session_start' | 'session_end' | 'request_in' | 'response_complete' | 'tool_use' | 'tool_result' | 'fallback_step' | 'drift_warning' | 'budget_event' | 'error' | 'thinking_block' | 'session_stalled_killed' | 'runaway_loop_killed' | 'turn_complete' | 'session_died';
|
|
18
|
-
export interface TrajectoryEvent {
|
|
19
|
-
ts: string;
|
|
20
|
-
sessionId?: string;
|
|
21
|
-
laptopId?: string;
|
|
22
|
-
eventType: EventType;
|
|
23
|
-
payload?: Record<string, unknown>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Append a single event row to the trajectory log. No-op if disabled.
|
|
27
|
-
* Writes are sync to keep ordering deterministic; the file is opened+closed
|
|
28
|
-
* per write (acceptable for the expected ≤10/sec event rate). If higher
|
|
29
|
-
* throughput is needed in v0.4.x, swap to a buffered write stream.
|
|
30
|
-
*/
|
|
31
|
-
export declare function emit(eventType: EventType, payload?: Record<string, unknown>, sessionId?: string): void;
|
|
32
|
-
/**
|
|
33
|
-
* v0.14.0 — turn-trace probe. Emits a `turn_complete` event independent of
|
|
34
|
-
* the main trajectory gate so A1 can capture per-turn diagnostics
|
|
35
|
-
* (userPrompt → tools → output → backstop) without flipping on the full
|
|
36
|
-
* event firehose. Gated by CC_OPENCLAW_TURN_TRACE=1; also fires when the
|
|
37
|
-
* primary CC_OPENCLAW_TRAJECTORY gate is on (so trajectory consumers see
|
|
38
|
-
* turn_complete in the normal stream too).
|
|
39
|
-
*/
|
|
40
|
-
export declare function emitTurnTrace(payload: Record<string, unknown>, sessionId?: string): void;
|
|
41
|
-
/** Reset module state for tests (re-checks env, re-creates dir on next emit). */
|
|
42
|
-
export declare function _resetForTests(): void;
|
|
43
|
-
/** Read all events from current trajectory file. Test-only. */
|
|
44
|
-
export declare function _readAllForTests(): TrajectoryEvent[];
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Engine library file paths. Pre-v0.7.0 these pointed at `vendor/`; v0.7.0
|
|
3
|
-
* consolidation repointed them at the canonical `dist/src/` build output.
|
|
4
|
-
* The dist counterparts are byte-for-byte ahead-of-vendor in every file
|
|
5
|
-
* (vendor was always a stale snapshot), so this is an upgrade not a
|
|
6
|
-
* regression. The `vendor/` directory was deleted in v0.7.0.
|
|
7
|
-
*/
|
|
8
|
-
export declare const VENDOR_FILES: {
|
|
9
|
-
readonly sessionManager: string;
|
|
10
|
-
readonly embeddedServer: string;
|
|
11
|
-
readonly models: string;
|
|
12
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boot — 7-phase lifecycle orchestrator.
|
|
3
|
-
*
|
|
4
|
-
* Phase order (PRP §3.2 G6):
|
|
5
|
-
* 1. validate-config → ConfigSchema.parse(env + openclaw.json)
|
|
6
|
-
* 2. import-upstream → dynamic import("openclaw")
|
|
7
|
-
* 3. validate-upstream → PatchManifest.validate() — ALL probes; fail-loud
|
|
8
|
-
* 4. install-patches → PatchManifest.install() — atomic after probes pass
|
|
9
|
-
* 5. wire-handlers → EventBus subscribers wired BEFORE traffic
|
|
10
|
-
* 6. start-server → openai-compat HTTP listener up
|
|
11
|
-
* 7. schedule-jobs → registry snapshot + watchdog timers
|
|
12
|
-
* → ready → emit "boot.ready" event
|
|
13
|
-
*
|
|
14
|
-
* Every phase fails loud — no silent skip.
|
|
15
|
-
* <300 LOC target; dependencies injected to allow dry-running phases 1-3
|
|
16
|
-
* from `cc-openclaw doctor`.
|
|
17
|
-
*/
|
|
18
|
-
import { type Config } from '../config/schema.js';
|
|
19
|
-
import { type StartServerOptions } from './phase-start-server.js';
|
|
20
|
-
import { PatchManifest } from './patch-manifest.js';
|
|
21
|
-
import { EventBus } from '../observability/event-bus.js';
|
|
22
|
-
import { SessionRegistry } from '../persistence/session-registry.js';
|
|
23
|
-
export type BootPhase = 'validate-config' | 'import-upstream' | 'validate-upstream' | 'install-patches' | 'wire-handlers' | 'start-server' | 'schedule-jobs' | 'ready';
|
|
24
|
-
export interface BootOptions {
|
|
25
|
-
manifest?: PatchManifest;
|
|
26
|
-
bus?: EventBus;
|
|
27
|
-
registry?: SessionRegistry;
|
|
28
|
-
serverOptions?: StartServerOptions;
|
|
29
|
-
/**
|
|
30
|
-
* When true, stops after phase 3 (validate-upstream) without installing
|
|
31
|
-
* patches or starting the server. Used by `cc-openclaw doctor`.
|
|
32
|
-
*/
|
|
33
|
-
dryRun?: boolean;
|
|
34
|
-
}
|
|
35
|
-
export declare class Boot {
|
|
36
|
-
private readonly manifest;
|
|
37
|
-
private readonly bus;
|
|
38
|
-
private readonly registry;
|
|
39
|
-
private readonly serverOptions;
|
|
40
|
-
private readonly dryRun;
|
|
41
|
-
constructor(opts?: BootOptions);
|
|
42
|
-
/**
|
|
43
|
-
* Run all 7 phases (or phases 1-3 in dry-run mode).
|
|
44
|
-
* Throws BootPhaseError wrapping the underlying error with a phase key.
|
|
45
|
-
*/
|
|
46
|
-
run(): Promise<Config>;
|
|
47
|
-
private runPhase;
|
|
48
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PatchManifest — declarative registry for prototype-patch specs.
|
|
3
|
-
*
|
|
4
|
-
* Each PatchSpec declares:
|
|
5
|
-
* - expectedShape: synchronous probe (signature / property existence)
|
|
6
|
-
* - expectedBehavior: async runtime probe (tiny smoke test)
|
|
7
|
-
* - install / uninstall: the actual mutation
|
|
8
|
-
*
|
|
9
|
-
* Boot phase 3 calls validate() — runs ALL probes.
|
|
10
|
-
* If ANY fail, throws DriftError listing every failing spec.
|
|
11
|
-
* Boot is refused; nothing is installed. No silent no-ops.
|
|
12
|
-
*
|
|
13
|
-
* Boot phase 4 calls install() — installs ALL specs atomically
|
|
14
|
-
* (i.e. only after validate() has passed).
|
|
15
|
-
*/
|
|
16
|
-
export interface PatchSpec<T = unknown> {
|
|
17
|
-
/** Stable identifier used in drift reports and mutation tests. */
|
|
18
|
-
id: string;
|
|
19
|
-
/** e.g. "claude-code/dist/session/SessionManager" — informational */
|
|
20
|
-
targetModule: string;
|
|
21
|
-
/** e.g. "SessionManager.prototype.startSession" — informational */
|
|
22
|
-
targetSymbol: string;
|
|
23
|
-
/**
|
|
24
|
-
* Resolve the live target. Called once per probe + install operation.
|
|
25
|
-
* Each spec resolves its own target — different specs target different
|
|
26
|
-
* upstream symbols, so a single global target is the wrong abstraction.
|
|
27
|
-
*
|
|
28
|
-
* **Async-compatible** (since Phase E#3 architectural finding 2026-05-13):
|
|
29
|
-
* may return `T` directly OR a `Promise<T>`. ESM upstream packages with
|
|
30
|
-
* top-level await (e.g. `openclaw`) cannot be loaded via sync `require()`;
|
|
31
|
-
* they require `await import()`. PatchManifest awaits the return value
|
|
32
|
-
* uniformly. Per PRP §3.2 G1.
|
|
33
|
-
*/
|
|
34
|
-
resolve: () => T | Promise<T>;
|
|
35
|
-
/**
|
|
36
|
-
* Synchronous shape probe. Returns true when the symbol exists with the
|
|
37
|
-
* expected signature (property count, method name, etc.).
|
|
38
|
-
* Must NOT mutate the target.
|
|
39
|
-
*/
|
|
40
|
-
expectedShape: (target: T) => boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Async behavior probe. Returns true when a minimal smoke invocation
|
|
43
|
-
* demonstrates the expected behavior contract.
|
|
44
|
-
* Must NOT mutate the target; must be fast (<100ms).
|
|
45
|
-
*/
|
|
46
|
-
expectedBehavior: (target: T) => Promise<boolean>;
|
|
47
|
-
/**
|
|
48
|
-
* Apply the patch. Called only after validate() passes for all specs.
|
|
49
|
-
*/
|
|
50
|
-
install: (target: T) => void;
|
|
51
|
-
/**
|
|
52
|
-
* Revert the patch. Called on emergency rollback or unload.
|
|
53
|
-
*/
|
|
54
|
-
uninstall: (target: T) => void;
|
|
55
|
-
}
|
|
56
|
-
export declare class PatchManifest {
|
|
57
|
-
private readonly specs;
|
|
58
|
-
private installed;
|
|
59
|
-
/**
|
|
60
|
-
* Register a PatchSpec. Order of registration determines install order.
|
|
61
|
-
* Idempotent on same id — re-registering the same id is a no-op.
|
|
62
|
-
*/
|
|
63
|
-
register<T = unknown>(spec: PatchSpec<T>): void;
|
|
64
|
-
/**
|
|
65
|
-
* Boot phase 3: run ALL expectedShape + expectedBehavior probes.
|
|
66
|
-
* If any fail, throws DriftError listing ALL failures.
|
|
67
|
-
* Never installs on probe failure.
|
|
68
|
-
*/
|
|
69
|
-
validate(): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Boot phase 4: install ALL specs.
|
|
72
|
-
* Must only be called after validate() passes (enforced by Boot orchestrator).
|
|
73
|
-
*/
|
|
74
|
-
install(): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Emergency rollback — uninstalls in reverse registration order.
|
|
77
|
-
*/
|
|
78
|
-
uninstall(): Promise<void>;
|
|
79
|
-
get isInstalled(): boolean;
|
|
80
|
-
get size(): number;
|
|
81
|
-
ids(): string[];
|
|
82
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 2 — import-upstream
|
|
3
|
-
*
|
|
4
|
-
* Dynamically imports the "openclaw" package and returns its namespace as
|
|
5
|
-
* `unknown`. Zero `any`. The caller (boot.ts / phase 3) is responsible for
|
|
6
|
-
* narrowing the shape via PatchManifest.validate().
|
|
7
|
-
*
|
|
8
|
-
* Using a variable-held specifier prevents tsc from attempting static
|
|
9
|
-
* resolution of the peer-dependency at build time (same pattern as doctor.ts
|
|
10
|
-
* check_bridge_wiring).
|
|
11
|
-
*/
|
|
12
|
-
export declare function importUpstream(): Promise<unknown>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 4 — install-patches
|
|
3
|
-
*
|
|
4
|
-
* Calls manifest.install() atomically — only reached after phase 3
|
|
5
|
-
* (validate-upstream) passes. All probes have already confirmed the
|
|
6
|
-
* expected shape; install proceeds without further checks.
|
|
7
|
-
*
|
|
8
|
-
* On any install error, attempts manifest.uninstall() as best-effort rollback
|
|
9
|
-
* before re-throwing so boot fails loud.
|
|
10
|
-
*/
|
|
11
|
-
import type { PatchManifest } from './patch-manifest.js';
|
|
12
|
-
export declare function installPatches(manifest: PatchManifest, _upstreamNs: unknown): Promise<void>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 7 — schedule-jobs
|
|
3
|
-
*
|
|
4
|
-
* Sets up recurring background tasks (stub):
|
|
5
|
-
* - SessionRegistry.snapshot() on a configurable interval (default 5 min)
|
|
6
|
-
* - Stalled-session watchdog timer
|
|
7
|
-
* - Runaway-loop watchdog
|
|
8
|
-
*
|
|
9
|
-
* Phase E wires real timers here.
|
|
10
|
-
*/
|
|
11
|
-
import type { SessionRegistry } from '../persistence/session-registry.js';
|
|
12
|
-
export declare function scheduleJobs(_registry: SessionRegistry): void;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 6 — start-server
|
|
3
|
-
*
|
|
4
|
-
* Starts the openai-compat HTTP server (stub).
|
|
5
|
-
* Phase E wires the real server instantiation here.
|
|
6
|
-
*/
|
|
7
|
-
export interface StartServerOptions {
|
|
8
|
-
/** Port the openai-compat HTTP server listens on. Default: 18796. */
|
|
9
|
-
port?: number;
|
|
10
|
-
}
|
|
11
|
-
export declare function startServer(_opts?: StartServerOptions): Promise<void>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 1 — validate-config
|
|
3
|
-
*
|
|
4
|
-
* Calls ConfigSchema.parse(loadConfigSources()).
|
|
5
|
-
* Throws ConfigInvalid (wrapping zod issues) on failure.
|
|
6
|
-
* Boot refuses with a phase-keyed message.
|
|
7
|
-
*/
|
|
8
|
-
import { type Config } from '../config/schema.js';
|
|
9
|
-
export declare function validateConfig(): Config;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 3 — validate-upstream
|
|
3
|
-
*
|
|
4
|
-
* Runs PatchManifest.validate() against the imported upstream namespace.
|
|
5
|
-
* Re-throws validation failures as DriftError (already typed by PatchManifest).
|
|
6
|
-
*
|
|
7
|
-
* Boot refuses and surfaces a drift report if ANY probe fails.
|
|
8
|
-
* install() is NEVER called from this phase — that is phase 4.
|
|
9
|
-
*/
|
|
10
|
-
import type { PatchManifest } from './patch-manifest.js';
|
|
11
|
-
export declare function validateUpstream(manifest: PatchManifest, _upstreamNs: unknown): Promise<void>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 5 — wire-handlers
|
|
3
|
-
*
|
|
4
|
-
* Registers EventBus subscribers BEFORE the server starts accepting traffic
|
|
5
|
-
* (phase 6). This ordering closes the v0.6.0 subscription-vs-traffic race
|
|
6
|
-
* where SessionCaptureSubscriber missed early session events.
|
|
7
|
-
*
|
|
8
|
-
* Phase E wires the real subscribers (SessionCaptureSubscriber, MetricsSubscriber).
|
|
9
|
-
* This scaffold calls ObservabilityService.init(bus) which registers stubs.
|
|
10
|
-
*/
|
|
11
|
-
import type { EventBus } from '../observability/event-bus.js';
|
|
12
|
-
export declare function wireHandlers(bus: EventBus): void;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* safe-restart — in-process gateway restart that preserves the current
|
|
3
|
-
* Telegram session.
|
|
4
|
-
*
|
|
5
|
-
* Pre-Execution Decision (PRP_v2 §Pre-Execution Decisions, locked):
|
|
6
|
-
* Path: --safe-current-session flag (in-process).
|
|
7
|
-
* Rationale: avoids tmux zombie risk (Risk Register row 3); cleaner state
|
|
8
|
-
* model; tmux-detach remains available as a secondary path (v0.17 deferred).
|
|
9
|
-
*
|
|
10
|
-
* Usage (programmatic):
|
|
11
|
-
* const restart = new SafeRestart({ sessionId: 'my-session' });
|
|
12
|
-
* const result = await restart.run();
|
|
13
|
-
*
|
|
14
|
-
* Usage (CLI flag):
|
|
15
|
-
* cc-openclaw --safe-current-session [--session-id <id>]
|
|
16
|
-
* Parsed in src/cli/index.ts and forwarded here.
|
|
17
|
-
*
|
|
18
|
-
* Self-survival contract:
|
|
19
|
-
* When OpenClaw triggers a gateway restart while a Telegram session is
|
|
20
|
-
* active, the session must NOT fire a sub-agent "self-survival" turn. This
|
|
21
|
-
* module registers a SIGTERM handler that:
|
|
22
|
-
* 1. Flushes in-flight state (EventBus drain-wait up to FLUSH_TIMEOUT_MS).
|
|
23
|
-
* 2. Marks the named session as restart-pending in the session registry.
|
|
24
|
-
* 3. Emits a 'safe-restart.initiated' telemetry event.
|
|
25
|
-
* 4. Returns "in-process" — the gateway respawner picks this signal up and
|
|
26
|
-
* skips the self-survival sub-agent path.
|
|
27
|
-
*
|
|
28
|
-
* SecondaryPath — tmux-detach:
|
|
29
|
-
* See scripts/gateway-detach.sh. NOT the default per locked decision above.
|
|
30
|
-
* SafeRestart.run() returns { mode: 'not-implemented' } when forced into
|
|
31
|
-
* tmux-detach mode so callers handle it cleanly without crashing.
|
|
32
|
-
*/
|
|
33
|
-
import { EventBus } from '../observability/event-bus.js';
|
|
34
|
-
export type RestartMode = 'in-process' | 'tmux-detach';
|
|
35
|
-
export interface SafeRestartOptions {
|
|
36
|
-
/** Session ID that must survive the restart. */
|
|
37
|
-
sessionId: string;
|
|
38
|
-
/**
|
|
39
|
-
* Restart mode. Defaults to 'in-process' per locked PRP_v2 decision.
|
|
40
|
-
* 'tmux-detach' is a stub that returns { mode: 'not-implemented' }.
|
|
41
|
-
*/
|
|
42
|
-
mode?: RestartMode;
|
|
43
|
-
/** EventBus to emit telemetry events. If omitted, a private bus is used. */
|
|
44
|
-
bus?: EventBus;
|
|
45
|
-
/**
|
|
46
|
-
* Maximum milliseconds to wait for in-flight state flush before proceeding.
|
|
47
|
-
* Default: 2000.
|
|
48
|
-
*/
|
|
49
|
-
flushTimeoutMs?: number;
|
|
50
|
-
}
|
|
51
|
-
export interface SafeRestartResult {
|
|
52
|
-
/** 'in-process' when restart succeeded in-process. */
|
|
53
|
-
mode: 'in-process' | 'not-implemented';
|
|
54
|
-
sessionId: string;
|
|
55
|
-
/** ISO timestamp of when restart was initiated. */
|
|
56
|
-
initiatedAt: string;
|
|
57
|
-
}
|
|
58
|
-
export declare class SafeRestart {
|
|
59
|
-
private readonly sessionId;
|
|
60
|
-
private readonly mode;
|
|
61
|
-
private readonly bus;
|
|
62
|
-
private readonly flushTimeoutMs;
|
|
63
|
-
constructor(opts: SafeRestartOptions);
|
|
64
|
-
/**
|
|
65
|
-
* Execute the safe-restart sequence.
|
|
66
|
-
*
|
|
67
|
-
* In-process path:
|
|
68
|
-
* 1. Wait up to flushTimeoutMs for in-flight state to drain.
|
|
69
|
-
* 2. Emit 'safe-restart.initiated' telemetry.
|
|
70
|
-
* 3. Return { mode: 'in-process', ... }.
|
|
71
|
-
*
|
|
72
|
-
* Tmux-detach path:
|
|
73
|
-
* Returns { mode: 'not-implemented', ... } — deferred to v0.17.
|
|
74
|
-
* See scripts/gateway-detach.sh for the secondary path stub.
|
|
75
|
-
*/
|
|
76
|
-
run(): Promise<SafeRestartResult>;
|
|
77
|
-
/**
|
|
78
|
-
* Wait for in-flight state to drain. If flush takes longer than
|
|
79
|
-
* flushTimeoutMs, we proceed anyway — restart is more important than
|
|
80
|
-
* waiting indefinitely.
|
|
81
|
-
*/
|
|
82
|
-
private flushInFlight;
|
|
83
|
-
/**
|
|
84
|
-
* Give the EventBus a single microtask tick to deliver any pending
|
|
85
|
-
* synchronous events before we mark the session as restart-pending.
|
|
86
|
-
*/
|
|
87
|
-
private drainEventBus;
|
|
88
|
-
private emitTelemetry;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Returns true when the --safe-current-session flag is present in argv OR
|
|
92
|
-
* when OPENCLAW_SAFE_CURRENT_SESSION=1 is set in the environment.
|
|
93
|
-
* Used by src/cli/index.ts to decide whether to run the safe-restart path.
|
|
94
|
-
*/
|
|
95
|
-
export declare function isSafeCurrentSessionRequested(argv?: string[]): boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Parse --session-id <value> from argv. Returns undefined when not present.
|
|
98
|
-
*/
|
|
99
|
-
export declare function parseSessionIdFromArgv(argv?: string[]): string | undefined;
|
package/dist/src/logger.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structured logging interface with level control.
|
|
3
|
-
*
|
|
4
|
-
* Default implementation logs to console, filtered by OPENCLAW_LOG_LEVEL env var.
|
|
5
|
-
* Valid levels: debug, info, warn, error. Default: info.
|
|
6
|
-
*/
|
|
7
|
-
export interface Logger {
|
|
8
|
-
debug(msg: string, ...args: unknown[]): void;
|
|
9
|
-
info(msg: string, ...args: unknown[]): void;
|
|
10
|
-
warn(msg: string, ...args: unknown[]): void;
|
|
11
|
-
error(msg: string, ...args: unknown[]): void;
|
|
12
|
-
}
|
|
13
|
-
/** Create a console-backed logger with optional prefix and env-var level control. */
|
|
14
|
-
export declare function createConsoleLogger(prefix?: string): Logger;
|
package/dist/src/mcp/bridge.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface PluginApi {
|
|
2
|
-
on(event: string, handler: (...args: unknown[]) => unknown): void;
|
|
3
|
-
logger?: Console;
|
|
4
|
-
}
|
|
5
|
-
export declare class McpBridge {
|
|
6
|
-
private child;
|
|
7
|
-
start(): void;
|
|
8
|
-
stop(): Promise<void>;
|
|
9
|
-
isRunning(): boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Passive registration: validate the sidecar binary is present at the
|
|
13
|
-
* expected bundled path. No event hooks. No process spawning.
|
|
14
|
-
*
|
|
15
|
-
* Returns the resolved sidecar path so callers (or tests) can probe it.
|
|
16
|
-
*/
|
|
17
|
-
export declare function register(api: PluginApi): {
|
|
18
|
-
sidecarPath: string;
|
|
19
|
-
sidecarExists: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare function _resetRegisteredForTests(): void;
|
package/dist/src/mcp/index.d.ts
DELETED
package/dist/src/models.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized Model Registry — single source of truth for all model metadata.
|
|
3
|
-
*
|
|
4
|
-
* Every model definition lives here. All other files derive from this registry.
|
|
5
|
-
* To add a model: add one entry to MODELS[]. Everything else auto-generates.
|
|
6
|
-
*/
|
|
7
|
-
import type { EngineType } from './types.js';
|
|
8
|
-
export type ProviderName = 'anthropic' | 'openai' | 'google' | 'cursor' | 'custom';
|
|
9
|
-
export interface ModelPricing {
|
|
10
|
-
input: number;
|
|
11
|
-
output: number;
|
|
12
|
-
cached?: number;
|
|
13
|
-
}
|
|
14
|
-
interface ModelDef {
|
|
15
|
-
/** Canonical model ID, e.g. 'claude-opus-4-6' */
|
|
16
|
-
id: string;
|
|
17
|
-
/** Which CLI engine to use */
|
|
18
|
-
engine: EngineType;
|
|
19
|
-
/** Upstream provider for API routing */
|
|
20
|
-
provider: ProviderName;
|
|
21
|
-
/** Token pricing */
|
|
22
|
-
pricing: ModelPricing;
|
|
23
|
-
/** Short aliases that resolve to this model */
|
|
24
|
-
aliases?: string[];
|
|
25
|
-
/** Whether to expose in /v1/models (default: true) */
|
|
26
|
-
listed?: boolean;
|
|
27
|
-
/** Context window size in tokens */
|
|
28
|
-
contextWindow?: number;
|
|
29
|
-
}
|
|
30
|
-
/** Resolve alias → canonical id. Returns the input unchanged if not an alias. */
|
|
31
|
-
export declare function resolveAlias(alias: string): string;
|
|
32
|
-
/** Resolve model string to engine + canonical model. Pattern fallback for unknown models. */
|
|
33
|
-
export declare function resolveEngineAndModel(model: string): {
|
|
34
|
-
engine: EngineType;
|
|
35
|
-
model: string;
|
|
36
|
-
};
|
|
37
|
-
/** Resolve model string to provider + API model name. Used by proxy handler. */
|
|
38
|
-
export declare function resolveProvider(model: string): {
|
|
39
|
-
provider: ProviderName;
|
|
40
|
-
apiModel: string;
|
|
41
|
-
};
|
|
42
|
-
/** Get context window size for a model. Returns 200k default for unknown models. */
|
|
43
|
-
export declare function getContextWindow(model: string): number;
|
|
44
|
-
/** Get pricing for a model. Falls back to sonnet pricing for unknown models. */
|
|
45
|
-
export declare function getModelPricing(model?: string, defaultModel?: string): ModelPricing;
|
|
46
|
-
export declare function overrideModelPricing(overrides: Record<string, Partial<ModelPricing>>): void;
|
|
47
|
-
/** Reset all pricing overrides (for testing). */
|
|
48
|
-
export declare function _resetPricingOverrides(): void;
|
|
49
|
-
/** Get /v1/models list — auto-generated from registry. */
|
|
50
|
-
export declare function getModelList(): {
|
|
51
|
-
object: string;
|
|
52
|
-
data: Array<{
|
|
53
|
-
id: string;
|
|
54
|
-
object: string;
|
|
55
|
-
owned_by: string;
|
|
56
|
-
}>;
|
|
57
|
-
};
|
|
58
|
-
/** Get all model aliases as a Record (backward compat). */
|
|
59
|
-
export declare function getAliases(): Record<string, string>;
|
|
60
|
-
/** Check if a model string is a Gemini model. */
|
|
61
|
-
export declare function isGeminiModel(model: string): boolean;
|
|
62
|
-
/** Check if a model string is a Claude model. */
|
|
63
|
-
export declare function isClaudeModel(model: string): boolean;
|
|
64
|
-
/** Rough token estimate: ~4 chars per token. */
|
|
65
|
-
export declare function estimateTokens(text: string): number;
|
|
66
|
-
/** Resolve a model string to its full definition. Throws for unknown models. */
|
|
67
|
-
export declare function lookupModelStrict(idOrAlias: string): ModelDef;
|
|
68
|
-
export {};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EventBus — typed event emitter replacing all globalThis.__openclaw_* Maps.
|
|
3
|
-
*
|
|
4
|
-
* Contract (PRP §3.2 G4):
|
|
5
|
-
* - on<K>(event, listener) returns an unsubscribe function (no EventEmitter leak)
|
|
6
|
-
* - emit<K>(event, payload) is synchronous; delivery <1ms target
|
|
7
|
-
* - Subscribers wired in boot phase 5 BEFORE traffic (phase 6 start-server)
|
|
8
|
-
*
|
|
9
|
-
* EventMap keys use dot-notation: "session.started", "boot.ready", etc.
|
|
10
|
-
* Adding a new event requires only a type entry here — no subclass needed.
|
|
11
|
-
*/
|
|
12
|
-
import type { Config } from '../config/schema.js';
|
|
13
|
-
type SessionName = string & {
|
|
14
|
-
readonly __brand: 'SessionName';
|
|
15
|
-
};
|
|
16
|
-
export type EventMap = {
|
|
17
|
-
/** Emitted when a Claude CLI session subprocess starts. `pid` is `null`
|
|
18
|
-
* when the underlying ISession adapter doesn't expose a process id yet. */
|
|
19
|
-
'session.started': {
|
|
20
|
-
name: SessionName;
|
|
21
|
-
pid: number | null;
|
|
22
|
-
};
|
|
23
|
-
/** Emitted when a session subprocess exits cleanly. */
|
|
24
|
-
'session.completed': {
|
|
25
|
-
name: SessionName;
|
|
26
|
-
tokens: number;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Emitted when a session subprocess closes outside an explicit stop() —
|
|
30
|
-
* v0.14.1 root-cause observability for the stale-session class of bugs.
|
|
31
|
-
* `code` is the OS exit code (null when killed by signal). The reaper in
|
|
32
|
-
* SessionManager.sendMessage restarts the subprocess on the next turn.
|
|
33
|
-
*/
|
|
34
|
-
'session.died': {
|
|
35
|
-
name: SessionName;
|
|
36
|
-
code: number | null;
|
|
37
|
-
};
|
|
38
|
-
/** Emitted on every tool_use event within a session turn. */
|
|
39
|
-
'session.tool-use': {
|
|
40
|
-
name: SessionName;
|
|
41
|
-
tool: string;
|
|
42
|
-
input: unknown;
|
|
43
|
-
};
|
|
44
|
-
/** Emitted after PatchManifest.install() succeeds for a single spec. */
|
|
45
|
-
'patch.installed': {
|
|
46
|
-
id: string;
|
|
47
|
-
};
|
|
48
|
-
/** Emitted when a PatchSpec probe fails during validate-upstream. */
|
|
49
|
-
'patch.drift': {
|
|
50
|
-
id: string;
|
|
51
|
-
expected: string;
|
|
52
|
-
actual: string;
|
|
53
|
-
};
|
|
54
|
-
/** Emitted at the end of a successful 7-phase boot. */
|
|
55
|
-
'boot.ready': {
|
|
56
|
-
config: Config;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Emitted by cache-parity-registry when a namespace mismatch is detected
|
|
60
|
-
* and automatically self-recovered (task-005, v0.16).
|
|
61
|
-
* `namespace` is the mismatched key; `clearedBytes` is the size of the
|
|
62
|
-
* wiped local cache entry.
|
|
63
|
-
*/
|
|
64
|
-
'cache-parity.namespace-mismatch-recovered': {
|
|
65
|
-
namespace: string;
|
|
66
|
-
clearedBytes: number;
|
|
67
|
-
restartCycle: number;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
type Listener<K extends keyof EventMap> = (payload: EventMap[K]) => void;
|
|
71
|
-
export declare class EventBus {
|
|
72
|
-
private readonly listeners;
|
|
73
|
-
/**
|
|
74
|
-
* Subscribe to an event. Returns an unsubscribe function.
|
|
75
|
-
* Calling the returned function is idempotent.
|
|
76
|
-
*/
|
|
77
|
-
on<K extends keyof EventMap>(event: K, listener: Listener<K>): () => void;
|
|
78
|
-
/**
|
|
79
|
-
* Emit an event synchronously. All listeners receive the payload in
|
|
80
|
-
* registration order. Errors in listeners propagate to the caller.
|
|
81
|
-
*/
|
|
82
|
-
emit<K extends keyof EventMap>(event: K, payload: EventMap[K]): void;
|
|
83
|
-
/** Number of active listeners across all event keys. */
|
|
84
|
-
get listenerCount(): number;
|
|
85
|
-
}
|
|
86
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `getEventBus()` — process-wide singleton accessor for the EventBus.
|
|
3
|
-
*
|
|
4
|
-
* Phase E#5 (v0.12.0): the EventBus moves from scaffold to hot path. This
|
|
5
|
-
* module is the bootstrap seam: every hot-path callsite that emits a typed
|
|
6
|
-
* event imports this accessor instead of constructing its own EventBus.
|
|
7
|
-
*
|
|
8
|
-
* The singleton replaces the long-deprecated `globalThis.__openclaw_*` Map
|
|
9
|
-
* pattern. Listeners must be registered before traffic starts (boot phase 5
|
|
10
|
-
* per PRP §3.4); subscribers added later still work but may miss events
|
|
11
|
-
* fired during a race window.
|
|
12
|
-
*
|
|
13
|
-
* Test isolation: vitest unit tests can call `__resetEventBusForTests()` to
|
|
14
|
-
* drop all listeners between cases. Production code never calls it.
|
|
15
|
-
*/
|
|
16
|
-
import { EventBus } from './event-bus.js';
|
|
17
|
-
/**
|
|
18
|
-
* Returns the singleton EventBus. Lazy-initializes on first call.
|
|
19
|
-
*/
|
|
20
|
-
export declare function getEventBus(): EventBus;
|
|
21
|
-
/**
|
|
22
|
-
* Test-only helper. Drops the singleton so each test starts with zero
|
|
23
|
-
* listeners. Never call from production code.
|
|
24
|
-
*/
|
|
25
|
-
export declare function __resetEventBusForTests(): void;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObservabilityService — composes EventBus + all subscribers.
|
|
3
|
-
*
|
|
4
|
-
* init(bus) is called in boot phase 5 (wire-handlers) before the server
|
|
5
|
-
* starts accepting traffic. This ordering closes the subscription-vs-traffic
|
|
6
|
-
* race that existed prior to v0.6.0.
|
|
7
|
-
*
|
|
8
|
-
* Phase E wires real subscriber logic; stubs here keep build green.
|
|
9
|
-
*/
|
|
10
|
-
import type { EventBus } from './event-bus.js';
|
|
11
|
-
export declare class ObservabilityService {
|
|
12
|
-
private readonly sessionCapture;
|
|
13
|
-
private readonly metrics;
|
|
14
|
-
/**
|
|
15
|
-
* Register all subscribers against the provided bus.
|
|
16
|
-
* Must be called before traffic is accepted (boot phase 5).
|
|
17
|
-
*/
|
|
18
|
-
init(bus: EventBus): void;
|
|
19
|
-
}
|