@a1hvdy/cc-openclaw 0.11.0 → 0.13.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.
Files changed (212) hide show
  1. package/dist/src/channels/telegram/event-reducer.js +3 -15
  2. package/dist/src/channels/telegram/event-reducer.js.map +1 -1
  3. package/dist/src/channels/telegram/format-helpers.d.ts +20 -0
  4. package/dist/src/channels/telegram/format-helpers.js +34 -0
  5. package/dist/src/channels/telegram/format-helpers.js.map +1 -0
  6. package/dist/src/channels/telegram/live-card.js +3 -21
  7. package/dist/src/channels/telegram/live-card.js.map +1 -1
  8. package/dist/src/channels/telegram/result-preview.d.ts +12 -0
  9. package/dist/src/channels/telegram/result-preview.js +48 -0
  10. package/dist/src/channels/telegram/result-preview.js.map +1 -0
  11. package/dist/src/channels/telegram/tool-tracker.d.ts +1 -2
  12. package/dist/src/channels/telegram/tool-tracker.js +11 -38
  13. package/dist/src/channels/telegram/tool-tracker.js.map +1 -1
  14. package/dist/src/cli/checks/bridge-wiring.d.ts +14 -0
  15. package/dist/src/cli/checks/bridge-wiring.js +64 -0
  16. package/dist/src/cli/checks/bridge-wiring.js.map +1 -0
  17. package/dist/src/cli/checks/config-schema.d.ts +11 -0
  18. package/dist/src/cli/checks/config-schema.js +51 -0
  19. package/dist/src/cli/checks/config-schema.js.map +1 -0
  20. package/dist/src/cli/checks/critical-openclaw-json-keys.d.ts +21 -0
  21. package/dist/src/cli/checks/critical-openclaw-json-keys.js +106 -0
  22. package/dist/src/cli/checks/critical-openclaw-json-keys.js.map +1 -0
  23. package/dist/src/cli/checks/install-path.d.ts +11 -0
  24. package/dist/src/cli/checks/install-path.js +89 -0
  25. package/dist/src/cli/checks/install-path.js.map +1 -0
  26. package/dist/src/cli/checks/patch-scaffold.d.ts +17 -0
  27. package/dist/src/cli/checks/patch-scaffold.js +56 -0
  28. package/dist/src/cli/checks/patch-scaffold.js.map +1 -0
  29. package/dist/src/cli/doctor.d.ts +5 -9
  30. package/dist/src/cli/doctor.js +28 -129
  31. package/dist/src/cli/doctor.js.map +1 -1
  32. package/dist/src/cli/index.js +2 -2
  33. package/dist/src/cli/index.js.map +1 -1
  34. package/dist/src/cli/migrate.d.ts +29 -0
  35. package/dist/src/cli/migrate.js +75 -0
  36. package/dist/src/cli/migrate.js.map +1 -0
  37. package/dist/src/config/drift-detector.d.ts +28 -0
  38. package/dist/src/config/drift-detector.js +75 -0
  39. package/dist/src/config/drift-detector.js.map +1 -0
  40. package/dist/src/config/loader.d.ts +8 -0
  41. package/dist/src/config/loader.js +69 -0
  42. package/dist/src/config/loader.js.map +1 -0
  43. package/dist/src/config/schema.d.ts +188 -0
  44. package/dist/src/config/schema.js +98 -0
  45. package/dist/src/config/schema.js.map +1 -0
  46. package/dist/src/council/build-agent-prompt.d.ts +11 -0
  47. package/dist/src/council/build-agent-prompt.js +96 -0
  48. package/dist/src/council/build-agent-prompt.js.map +1 -0
  49. package/dist/src/council/cleanup-worktrees.d.ts +10 -0
  50. package/dist/src/council/cleanup-worktrees.js +22 -0
  51. package/dist/src/council/cleanup-worktrees.js.map +1 -0
  52. package/dist/src/council/council.js +15 -186
  53. package/dist/src/council/council.js.map +1 -1
  54. package/dist/src/council/system-prompt.d.ts +16 -0
  55. package/dist/src/council/system-prompt.js +40 -0
  56. package/dist/src/council/system-prompt.js.map +1 -0
  57. package/dist/src/council/write-worktree-claude-md.d.ts +10 -0
  58. package/dist/src/council/write-worktree-claude-md.js +41 -0
  59. package/dist/src/council/write-worktree-claude-md.js.map +1 -0
  60. package/dist/src/engines/persistent-custom-session.js +3 -8
  61. package/dist/src/engines/persistent-custom-session.js.map +1 -1
  62. package/dist/src/engines/resolve-bin.d.ts +14 -0
  63. package/dist/src/engines/resolve-bin.js +18 -0
  64. package/dist/src/engines/resolve-bin.js.map +1 -0
  65. package/dist/src/lib/config-service.js +8 -0
  66. package/dist/src/lib/config-service.js.map +1 -1
  67. package/dist/src/lib/debounce.d.ts +12 -0
  68. package/dist/src/lib/debounce.js +23 -0
  69. package/dist/src/lib/debounce.js.map +1 -0
  70. package/dist/src/lib/domain-error.d.ts +59 -0
  71. package/dist/src/lib/domain-error.js +79 -0
  72. package/dist/src/lib/domain-error.js.map +1 -0
  73. package/dist/src/lib/json-array.d.ts +10 -0
  74. package/dist/src/lib/json-array.js +23 -0
  75. package/dist/src/lib/json-array.js.map +1 -0
  76. package/dist/src/lib/safe-upstream-probes.d.ts +25 -0
  77. package/dist/src/lib/safe-upstream-probes.js +42 -0
  78. package/dist/src/lib/safe-upstream-probes.js.map +1 -0
  79. package/dist/src/lib/spawn-async.d.ts +18 -0
  80. package/dist/src/lib/spawn-async.js +47 -0
  81. package/dist/src/lib/spawn-async.js.map +1 -0
  82. package/dist/src/lib/stale-pid-files.d.ts +17 -0
  83. package/dist/src/lib/stale-pid-files.js +40 -0
  84. package/dist/src/lib/stale-pid-files.js.map +1 -0
  85. package/dist/src/lifecycle/boot.d.ts +59 -0
  86. package/dist/src/lifecycle/boot.js +132 -0
  87. package/dist/src/lifecycle/boot.js.map +1 -0
  88. package/dist/src/lifecycle/patch-manifest.d.ts +82 -0
  89. package/dist/src/lifecycle/patch-manifest.js +126 -0
  90. package/dist/src/lifecycle/patch-manifest.js.map +1 -0
  91. package/dist/src/lifecycle/phase-import-upstream.d.ts +12 -0
  92. package/dist/src/lifecycle/phase-import-upstream.js +18 -0
  93. package/dist/src/lifecycle/phase-import-upstream.js.map +1 -0
  94. package/dist/src/lifecycle/phase-install-patches.d.ts +12 -0
  95. package/dist/src/lifecycle/phase-install-patches.js +31 -0
  96. package/dist/src/lifecycle/phase-install-patches.js.map +1 -0
  97. package/dist/src/lifecycle/phase-schedule-jobs.d.ts +12 -0
  98. package/dist/src/lifecycle/phase-schedule-jobs.js +15 -0
  99. package/dist/src/lifecycle/phase-schedule-jobs.js.map +1 -0
  100. package/dist/src/lifecycle/phase-start-server.d.ts +11 -0
  101. package/dist/src/lifecycle/phase-start-server.js +11 -0
  102. package/dist/src/lifecycle/phase-start-server.js.map +1 -0
  103. package/dist/src/lifecycle/phase-validate-config.d.ts +9 -0
  104. package/dist/src/lifecycle/phase-validate-config.js +25 -0
  105. package/dist/src/lifecycle/phase-validate-config.js.map +1 -0
  106. package/dist/src/lifecycle/phase-validate-upstream.d.ts +11 -0
  107. package/dist/src/lifecycle/phase-validate-upstream.js +16 -0
  108. package/dist/src/lifecycle/phase-validate-upstream.js.map +1 -0
  109. package/dist/src/lifecycle/phase-wire-handlers.d.ts +12 -0
  110. package/dist/src/lifecycle/phase-wire-handlers.js +16 -0
  111. package/dist/src/lifecycle/phase-wire-handlers.js.map +1 -0
  112. package/dist/src/observability/event-bus.d.ts +75 -0
  113. package/dist/src/observability/event-bus.js +63 -0
  114. package/dist/src/observability/event-bus.js.map +1 -0
  115. package/dist/src/observability/get-event-bus.d.ts +25 -0
  116. package/dist/src/observability/get-event-bus.js +34 -0
  117. package/dist/src/observability/get-event-bus.js.map +1 -0
  118. package/dist/src/observability/observability-service.d.ts +19 -0
  119. package/dist/src/observability/observability-service.js +24 -0
  120. package/dist/src/observability/observability-service.js.map +1 -0
  121. package/dist/src/observability/subscribers/metrics.d.ts +11 -0
  122. package/dist/src/observability/subscribers/metrics.js +21 -0
  123. package/dist/src/observability/subscribers/metrics.js.map +1 -0
  124. package/dist/src/observability/subscribers/session-capture.d.ts +15 -0
  125. package/dist/src/observability/subscribers/session-capture.js +25 -0
  126. package/dist/src/observability/subscribers/session-capture.js.map +1 -0
  127. package/dist/src/openai-compat/bridges/allowlist.d.ts +14 -5
  128. package/dist/src/openai-compat/bridges/allowlist.js +18 -7
  129. package/dist/src/openai-compat/bridges/allowlist.js.map +1 -1
  130. package/dist/src/openai-compat/bridges/openclaw-api-shim.d.ts +54 -0
  131. package/dist/src/openai-compat/bridges/openclaw-api-shim.js +45 -0
  132. package/dist/src/openai-compat/bridges/openclaw-api-shim.js.map +1 -0
  133. package/dist/src/openai-compat/openai-chunk-types.d.ts +35 -0
  134. package/dist/src/openai-compat/openai-chunk-types.js +9 -0
  135. package/dist/src/openai-compat/openai-chunk-types.js.map +1 -0
  136. package/dist/src/openai-compat/openai-compat.d.ts +2 -90
  137. package/dist/src/openai-compat/openai-compat.js +68 -68
  138. package/dist/src/openai-compat/openai-compat.js.map +1 -1
  139. package/dist/src/openai-compat/openai-types.d.ts +71 -0
  140. package/dist/src/openai-compat/openai-types.js +11 -0
  141. package/dist/src/openai-compat/openai-types.js.map +1 -0
  142. package/dist/src/openai-compat/parse-route-body.d.ts +24 -0
  143. package/dist/src/openai-compat/parse-route-body.js +45 -0
  144. package/dist/src/openai-compat/parse-route-body.js.map +1 -0
  145. package/dist/src/openai-compat/tts-rule.d.ts +20 -0
  146. package/dist/src/openai-compat/tts-rule.js +58 -0
  147. package/dist/src/openai-compat/tts-rule.js.map +1 -0
  148. package/dist/src/openai-compat/voice-recovery.js +0 -1
  149. package/dist/src/openai-compat/voice-recovery.js.map +1 -1
  150. package/dist/src/patches/cache-parity-registry.d.ts +20 -0
  151. package/dist/src/patches/cache-parity-registry.js +64 -0
  152. package/dist/src/patches/cache-parity-registry.js.map +1 -0
  153. package/dist/src/patches/claude-md-injection.d.ts +10 -0
  154. package/dist/src/patches/claude-md-injection.js +46 -0
  155. package/dist/src/patches/claude-md-injection.js.map +1 -0
  156. package/dist/src/patches/cwd-redirect.d.ts +10 -0
  157. package/dist/src/patches/cwd-redirect.js +51 -0
  158. package/dist/src/patches/cwd-redirect.js.map +1 -0
  159. package/dist/src/patches/embedded-server-route.d.ts +23 -0
  160. package/dist/src/patches/embedded-server-route.js +64 -0
  161. package/dist/src/patches/embedded-server-route.js.map +1 -0
  162. package/dist/src/patches/pricing-overrides.d.ts +10 -0
  163. package/dist/src/patches/pricing-overrides.js +55 -0
  164. package/dist/src/patches/pricing-overrides.js.map +1 -0
  165. package/dist/src/patches/resume-registry-restore.d.ts +11 -0
  166. package/dist/src/patches/resume-registry-restore.js +48 -0
  167. package/dist/src/patches/resume-registry-restore.js.map +1 -0
  168. package/dist/src/patches/session-pid-tracking.d.ts +10 -0
  169. package/dist/src/patches/session-pid-tracking.js +45 -0
  170. package/dist/src/patches/session-pid-tracking.js.map +1 -0
  171. package/dist/src/patches/sysprompt-strip.d.ts +46 -0
  172. package/dist/src/patches/sysprompt-strip.js +78 -0
  173. package/dist/src/patches/sysprompt-strip.js.map +1 -0
  174. package/dist/src/patches/sysprompt-strip.spec.d.ts +33 -0
  175. package/dist/src/patches/sysprompt-strip.spec.js +53 -0
  176. package/dist/src/patches/sysprompt-strip.spec.js.map +1 -0
  177. package/dist/src/patches/tools-restoration.d.ts +12 -0
  178. package/dist/src/patches/tools-restoration.js +43 -0
  179. package/dist/src/patches/tools-restoration.js.map +1 -0
  180. package/dist/src/persistence/migration-v0.d.ts +24 -0
  181. package/dist/src/persistence/migration-v0.js +142 -0
  182. package/dist/src/persistence/migration-v0.js.map +1 -0
  183. package/dist/src/persistence/session-registry.d.ts +57 -0
  184. package/dist/src/persistence/session-registry.js +58 -0
  185. package/dist/src/persistence/session-registry.js.map +1 -0
  186. package/dist/src/persistence/snapshot.d.ts +18 -0
  187. package/dist/src/persistence/snapshot.js +32 -0
  188. package/dist/src/persistence/snapshot.js.map +1 -0
  189. package/dist/src/persistence/wal.d.ts +17 -0
  190. package/dist/src/persistence/wal.js +32 -0
  191. package/dist/src/persistence/wal.js.map +1 -0
  192. package/dist/src/session/persisted-sessions.d.ts +26 -0
  193. package/dist/src/session/persisted-sessions.js +70 -0
  194. package/dist/src/session/persisted-sessions.js.map +1 -0
  195. package/dist/src/session/session-manager.d.ts +2 -11
  196. package/dist/src/session/session-manager.js +22 -66
  197. package/dist/src/session/session-manager.js.map +1 -1
  198. package/dist/src/session-bootstrap/boot-self-heal.d.ts +32 -0
  199. package/dist/src/session-bootstrap/boot-self-heal.js +54 -0
  200. package/dist/src/session-bootstrap/boot-self-heal.js.map +1 -0
  201. package/dist/src/session-bootstrap/cwd-patch.js +11 -87
  202. package/dist/src/session-bootstrap/cwd-patch.js.map +1 -1
  203. package/dist/src/session-bootstrap/resume-registry.d.ts +29 -0
  204. package/dist/src/session-bootstrap/resume-registry.js +58 -0
  205. package/dist/src/session-bootstrap/resume-registry.js.map +1 -0
  206. package/dist/src/session-bootstrap/session-hygiene.d.ts +23 -0
  207. package/dist/src/session-bootstrap/session-hygiene.js +41 -0
  208. package/dist/src/session-bootstrap/session-hygiene.js.map +1 -0
  209. package/dist/src/types/runtime-config.d.ts +11 -0
  210. package/dist/src/types/runtime-config.js +9 -0
  211. package/dist/src/types/runtime-config.js.map +1 -1
  212. package/package.json +1 -1
@@ -0,0 +1,11 @@
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>;
@@ -0,0 +1,16 @@
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
+ export async function validateUpstream(manifest, _upstreamNs) {
11
+ // upstreamNs is unused at this layer — each PatchSpec resolves its own
12
+ // target via PatchSpec.resolve(). The parameter is kept in the signature
13
+ // for boot.ts wiring symmetry.
14
+ await manifest.validate();
15
+ }
16
+ //# sourceMappingURL=phase-validate-upstream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase-validate-upstream.js","sourceRoot":"","sources":["../../../src/lifecycle/phase-validate-upstream.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAuB,EACvB,WAAoB;IAEpB,uEAAuE;IACvE,yEAAyE;IACzE,+BAA+B;IAC/B,MAAM,QAAQ,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,16 @@
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 { ObservabilityService } from '../observability/observability-service.js';
12
+ export function wireHandlers(bus) {
13
+ const svc = new ObservabilityService();
14
+ svc.init(bus);
15
+ }
16
+ //# sourceMappingURL=phase-wire-handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase-wire-handlers.js","sourceRoot":"","sources":["../../../src/lifecycle/phase-wire-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,MAAM,UAAU,YAAY,CAAC,GAAa;IACxC,MAAM,GAAG,GAAG,IAAI,oBAAoB,EAAE,CAAC;IACvC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChB,CAAC"}
@@ -0,0 +1,75 @@
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
+ /**
14
+ * EventBus payload-shape contract version. Bump on any breaking change to a
15
+ * payload (rename, narrow type, remove key). Subscribers may ignore events
16
+ * tagged with a version they don't understand.
17
+ *
18
+ * v0.13.0 introduces this constant. Adding new events to EventMap is NOT a
19
+ * breaking change and does not require a bump; modifying an existing event's
20
+ * payload shape IS breaking and requires a bump + migration plan.
21
+ */
22
+ export declare const EVENT_BUS_PROTOCOL_VERSION: "1";
23
+ type SessionName = string & {
24
+ readonly __brand: 'SessionName';
25
+ };
26
+ export type EventMap = {
27
+ /** Emitted when a Claude CLI session subprocess starts. `pid` is `null`
28
+ * when the underlying ISession adapter doesn't expose a process id yet. */
29
+ 'session.started': {
30
+ name: SessionName;
31
+ pid: number | null;
32
+ };
33
+ /** Emitted when a session subprocess exits cleanly. */
34
+ 'session.completed': {
35
+ name: SessionName;
36
+ tokens: number;
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
+ type Listener<K extends keyof EventMap> = (payload: EventMap[K]) => void;
60
+ export declare class EventBus {
61
+ private readonly listeners;
62
+ /**
63
+ * Subscribe to an event. Returns an unsubscribe function.
64
+ * Calling the returned function is idempotent.
65
+ */
66
+ on<K extends keyof EventMap>(event: K, listener: Listener<K>): () => void;
67
+ /**
68
+ * Emit an event synchronously. All listeners receive the payload in
69
+ * registration order. Errors in listeners propagate to the caller.
70
+ */
71
+ emit<K extends keyof EventMap>(event: K, payload: EventMap[K]): void;
72
+ /** Number of active listeners across all event keys. */
73
+ get listenerCount(): number;
74
+ }
75
+ export {};
@@ -0,0 +1,63 @@
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
+ // ── Protocol version ──────────────────────────────────────────────────────────
13
+ /**
14
+ * EventBus payload-shape contract version. Bump on any breaking change to a
15
+ * payload (rename, narrow type, remove key). Subscribers may ignore events
16
+ * tagged with a version they don't understand.
17
+ *
18
+ * v0.13.0 introduces this constant. Adding new events to EventMap is NOT a
19
+ * breaking change and does not require a bump; modifying an existing event's
20
+ * payload shape IS breaking and requires a bump + migration plan.
21
+ */
22
+ export const EVENT_BUS_PROTOCOL_VERSION = '1';
23
+ // ── EventBus class ────────────────────────────────────────────────────────────
24
+ export class EventBus {
25
+ listeners = new Map();
26
+ /**
27
+ * Subscribe to an event. Returns an unsubscribe function.
28
+ * Calling the returned function is idempotent.
29
+ */
30
+ on(event, listener) {
31
+ let set = this.listeners.get(event);
32
+ if (!set) {
33
+ set = new Set();
34
+ this.listeners.set(event, set);
35
+ }
36
+ // Cast: the Set stores Listener<keyof EventMap>; narrowed by K on emit.
37
+ set.add(listener);
38
+ return () => {
39
+ set.delete(listener);
40
+ };
41
+ }
42
+ /**
43
+ * Emit an event synchronously. All listeners receive the payload in
44
+ * registration order. Errors in listeners propagate to the caller.
45
+ */
46
+ emit(event, payload) {
47
+ const set = this.listeners.get(event);
48
+ if (!set)
49
+ return;
50
+ for (const listener of set) {
51
+ listener(payload);
52
+ }
53
+ }
54
+ /** Number of active listeners across all event keys. */
55
+ get listenerCount() {
56
+ let total = 0;
57
+ for (const set of this.listeners.values()) {
58
+ total += set.size;
59
+ }
60
+ return total;
61
+ }
62
+ }
63
+ //# sourceMappingURL=event-bus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../../src/observability/event-bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,iFAAiF;AAEjF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAY,CAAC;AA6BvD,iFAAiF;AAEjF,MAAM,OAAO,QAAQ;IACF,SAAS,GAAG,IAAI,GAAG,EAAiD,CAAC;IAEtF;;;OAGG;IACH,EAAE,CAA2B,KAAQ,EAAE,QAAqB;QAC1D,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;YAChB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACjC,CAAC;QACD,wEAAwE;QACvE,GAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAExC,OAAO,GAAG,EAAE;YACT,GAAwB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,IAAI,CAA2B,KAAQ,EAAE,OAAoB;QAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,GAAG;YAAE,OAAO;QACjB,KAAK,MAAM,QAAQ,IAAI,GAAG,EAAE,CAAC;YAC1B,QAAwB,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,wDAAwD;IACxD,IAAI,aAAa;QACf,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,KAAK,IAAI,GAAG,CAAC,IAAI,CAAC;QACpB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,25 @@
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;
@@ -0,0 +1,34 @@
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
+ let _instance = null;
18
+ /**
19
+ * Returns the singleton EventBus. Lazy-initializes on first call.
20
+ */
21
+ export function getEventBus() {
22
+ if (!_instance) {
23
+ _instance = new EventBus();
24
+ }
25
+ return _instance;
26
+ }
27
+ /**
28
+ * Test-only helper. Drops the singleton so each test starts with zero
29
+ * listeners. Never call from production code.
30
+ */
31
+ export function __resetEventBusForTests() {
32
+ _instance = null;
33
+ }
34
+ //# sourceMappingURL=get-event-bus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-event-bus.js","sourceRoot":"","sources":["../../../src/observability/get-event-bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,IAAI,SAAS,GAAoB,IAAI,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACrC,SAAS,GAAG,IAAI,CAAC;AACnB,CAAC"}
@@ -0,0 +1,19 @@
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
+ }
@@ -0,0 +1,24 @@
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 { SessionCaptureSubscriber } from './subscribers/session-capture.js';
11
+ import { MetricsSubscriber } from './subscribers/metrics.js';
12
+ export class ObservabilityService {
13
+ sessionCapture = new SessionCaptureSubscriber();
14
+ metrics = new MetricsSubscriber();
15
+ /**
16
+ * Register all subscribers against the provided bus.
17
+ * Must be called before traffic is accepted (boot phase 5).
18
+ */
19
+ init(bus) {
20
+ this.sessionCapture.register(bus);
21
+ this.metrics.register(bus);
22
+ }
23
+ }
24
+ //# sourceMappingURL=observability-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observability-service.js","sourceRoot":"","sources":["../../../src/observability/observability-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,OAAO,oBAAoB;IACd,cAAc,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAChD,OAAO,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAEnD;;;OAGG;IACH,IAAI,CAAC,GAAa;QAChB,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * MetricsSubscriber — collects per-session token and timing metrics.
3
+ *
4
+ * Replaces globalThis.__openclaw_perfMap (AS2).
5
+ * Phase E wires real aggregation and exposes metrics via /enhancer/metrics.
6
+ * Stub body here.
7
+ */
8
+ import type { EventBus } from '../event-bus.js';
9
+ export declare class MetricsSubscriber {
10
+ register(bus: EventBus): void;
11
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * MetricsSubscriber — collects per-session token and timing metrics.
3
+ *
4
+ * Replaces globalThis.__openclaw_perfMap (AS2).
5
+ * Phase E wires real aggregation and exposes metrics via /enhancer/metrics.
6
+ * Stub body here.
7
+ */
8
+ export class MetricsSubscriber {
9
+ register(bus) {
10
+ bus.on('session.completed', (_payload) => {
11
+ // Phase E: accumulate token counts, compute latency, update perfMap.
12
+ });
13
+ bus.on('patch.installed', (_payload) => {
14
+ // Phase E: record patch install time for cold-start budget tracking.
15
+ });
16
+ bus.on('patch.drift', (_payload) => {
17
+ // Phase E: emit warning to Telegram live-card or log file.
18
+ });
19
+ }
20
+ }
21
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../../src/observability/subscribers/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,iBAAiB;IAC5B,QAAQ,CAAC,GAAa;QACpB,GAAG,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,QAAQ,EAAE,EAAE;YACvC,qEAAqE;QACvE,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,EAAE;YACrC,qEAAqE;QACvE,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE;YACjC,2DAA2D;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * SessionCaptureSubscriber — replaces the 5s ultrareview poller (LP2).
3
+ *
4
+ * Wired in boot phase 5 (wire-handlers) BEFORE traffic starts.
5
+ * Phase E implements the real capture logic (writing to SessionRegistry WAL,
6
+ * updating live-card state, etc.). Stub body here.
7
+ */
8
+ import type { EventBus } from '../event-bus.js';
9
+ export declare class SessionCaptureSubscriber {
10
+ /**
11
+ * Register listeners on the bus. Returns nothing; unsubscribe handles
12
+ * are held internally (Phase E: stored for clean shutdown).
13
+ */
14
+ register(bus: EventBus): void;
15
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * SessionCaptureSubscriber — replaces the 5s ultrareview poller (LP2).
3
+ *
4
+ * Wired in boot phase 5 (wire-handlers) BEFORE traffic starts.
5
+ * Phase E implements the real capture logic (writing to SessionRegistry WAL,
6
+ * updating live-card state, etc.). Stub body here.
7
+ */
8
+ export class SessionCaptureSubscriber {
9
+ /**
10
+ * Register listeners on the bus. Returns nothing; unsubscribe handles
11
+ * are held internally (Phase E: stored for clean shutdown).
12
+ */
13
+ register(bus) {
14
+ bus.on('session.started', (_payload) => {
15
+ // Phase E: persist session start to SessionRegistry WAL.
16
+ });
17
+ bus.on('session.completed', (_payload) => {
18
+ // Phase E: finalize WAL entry, trigger snapshot if N-minute threshold met.
19
+ });
20
+ bus.on('session.tool-use', (_payload) => {
21
+ // Phase E: update live-card tool tracker, emit metrics.
22
+ });
23
+ }
24
+ }
25
+ //# sourceMappingURL=session-capture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-capture.js","sourceRoot":"","sources":["../../../../src/observability/subscribers/session-capture.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,wBAAwB;IACnC;;;OAGG;IACH,QAAQ,CAAC,GAAa;QACpB,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,EAAE;YACrC,yDAAyD;QAC3D,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,QAAQ,EAAE,EAAE;YACvC,2EAA2E;QAC7E,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,kBAAkB,EAAE,CAAC,QAAQ,EAAE,EAAE;YACtC,wDAAwD;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,10 +1,19 @@
1
1
  /**
2
- * v0.11.0 — OpenClaw native tool allowlist.
2
+ * OpenClaw native tool allowList — typed-config-driven (Phase E #1, Q1 resolution).
3
3
  *
4
- * Hard-coded for v0.11.0 soak. `image.send` and `file.upload` are reserved
5
- * but NOT active until v0.12.0. Flip will happen in allowlist.ts only — no
6
- * other file needs to change.
4
+ * Reads from `ConfigService.config.nativeToolsAllowList` when available;
5
+ * falls back to the v0.11.x hardcoded default when `ConfigService` is unset
6
+ * (tests, scripts run without a boot path). The hardcoded fallback is
7
+ * intentionally identical to what shipped at v0.11.0 so existing tests that
8
+ * import `OPENCLAW_TOOL_ALLOWLIST` keep passing without rewrite.
9
+ *
10
+ * Env override: `CC_OPENCLAW_NATIVE_TOOLS_ALLOWLIST="message.voice,message.image,..."`.
11
+ * Q1 expanded default ships at v1.0.0-rc1 alongside the `CC_OPENCLAW_NATIVE_TOOLS=1` flip.
12
+ */
13
+ /**
14
+ * v0.11.x default — kept exported for legacy callers and for the
15
+ * `ConfigService`-unset fallback path. New code should call `isAllowedTool`.
7
16
  */
8
17
  export declare const OPENCLAW_TOOL_ALLOWLIST: ReadonlySet<string>;
9
- /** Return true when `toolName` is in the v0.11.0 allowlist. */
18
+ /** Return true when `toolName` is in the active allowList. */
10
19
  export declare function isAllowedTool(toolName: string): boolean;
@@ -1,17 +1,28 @@
1
1
  /**
2
- * v0.11.0 — OpenClaw native tool allowlist.
2
+ * OpenClaw native tool allowList — typed-config-driven (Phase E #1, Q1 resolution).
3
3
  *
4
- * Hard-coded for v0.11.0 soak. `image.send` and `file.upload` are reserved
5
- * but NOT active until v0.12.0. Flip will happen in allowlist.ts only — no
6
- * other file needs to change.
4
+ * Reads from `ConfigService.config.nativeToolsAllowList` when available;
5
+ * falls back to the v0.11.x hardcoded default when `ConfigService` is unset
6
+ * (tests, scripts run without a boot path). The hardcoded fallback is
7
+ * intentionally identical to what shipped at v0.11.0 so existing tests that
8
+ * import `OPENCLAW_TOOL_ALLOWLIST` keep passing without rewrite.
9
+ *
10
+ * Env override: `CC_OPENCLAW_NATIVE_TOOLS_ALLOWLIST="message.voice,message.image,..."`.
11
+ * Q1 expanded default ships at v1.0.0-rc1 alongside the `CC_OPENCLAW_NATIVE_TOOLS=1` flip.
12
+ */
13
+ import { getConfigService } from '../../lib/config-service.js';
14
+ /**
15
+ * v0.11.x default — kept exported for legacy callers and for the
16
+ * `ConfigService`-unset fallback path. New code should call `isAllowedTool`.
7
17
  */
8
18
  export const OPENCLAW_TOOL_ALLOWLIST = new Set([
9
19
  'message.voice',
10
- // 'image.send', // reserved — v0.12.0
11
- // 'file.upload', // reserved — v0.12.0
12
20
  ]);
13
- /** Return true when `toolName` is in the v0.11.0 allowlist. */
21
+ /** Return true when `toolName` is in the active allowList. */
14
22
  export function isAllowedTool(toolName) {
23
+ const cfg = getConfigService();
24
+ if (cfg)
25
+ return cfg.config.nativeToolsAllowList.includes(toolName);
15
26
  return OPENCLAW_TOOL_ALLOWLIST.has(toolName);
16
27
  }
17
28
  //# sourceMappingURL=allowlist.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"allowlist.js","sourceRoot":"","sources":["../../../../src/openai-compat/bridges/allowlist.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC;IAClE,eAAe;IACf,wCAAwC;IACxC,wCAAwC;CACzC,CAAC,CAAC;AAEH,+DAA+D;AAC/D,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,OAAO,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC"}
1
+ {"version":3,"file":"allowlist.js","sourceRoot":"","sources":["../../../../src/openai-compat/bridges/allowlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC;IAClE,eAAe;CAChB,CAAC,CAAC;AAEH,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,MAAM,GAAG,GAAG,gBAAgB,EAAE,CAAC;IAC/B,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC,MAAM,CAAC,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnE,OAAO,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * OpenClawApiShim — typed subset of the OpenClaw plugin API surface.
3
+ *
4
+ * Q2 resolution: the upstream OpenClaw plugin API has no semver contract.
5
+ * Rather than depend on it directly, all native-tool calls go through this
6
+ * shim which exposes only the methods cc-openclaw needs.
7
+ *
8
+ * `validateShape(api)` runs at boot phase 3 (`validate-upstream`) and is
9
+ * registered as a `PatchSpec.expectedShape` probe. Failure → `DriftError`
10
+ * and boot refuses (per PatchManifest atomic-install contract).
11
+ *
12
+ * Phase D: types + probe shipped; `dispatch` stubbed and throws
13
+ * `NotImplemented` until Phase E wires the live OpenClaw `api.tool.dispatch`.
14
+ */
15
+ /**
16
+ * Inbound dispatch types for the v1.0.0 ToolBridge strategy. These are
17
+ * complementary to the existing `IToolBridge` at `src/types/tool-bridge.ts`
18
+ * (which handles outbound tools-to-CLI wiring). Phase E consolidates the
19
+ * two interfaces if a clean merge is possible.
20
+ */
21
+ export interface ToolUseCall {
22
+ readonly id: string;
23
+ readonly name: string;
24
+ readonly input: unknown;
25
+ }
26
+ export interface ToolUseResult {
27
+ readonly toolUseId: string;
28
+ readonly content: string;
29
+ readonly isError?: boolean;
30
+ }
31
+ /** Minimum surface area the shim requires from `openclaw.PluginApi`. */
32
+ export interface OpenClawApiSurface {
33
+ readonly tool: {
34
+ readonly dispatch: (name: string, input: unknown) => Promise<unknown>;
35
+ readonly list: () => ReadonlyArray<{
36
+ readonly name: string;
37
+ }>;
38
+ };
39
+ }
40
+ export declare class OpenClawApiShim {
41
+ private readonly api;
42
+ constructor(api: OpenClawApiSurface);
43
+ /**
44
+ * Phase 3 probe — returns true when `api.tool.dispatch` and `api.tool.list`
45
+ * exist as callable methods. Used as a `PatchSpec.expectedShape` probe.
46
+ */
47
+ static validateShape(api: unknown): boolean;
48
+ /**
49
+ * Dispatch a Claude `tool_use` event to OpenClaw's plugin API. Phase D stub.
50
+ */
51
+ dispatch(_call: ToolUseCall): Promise<ToolUseResult>;
52
+ /** Phase D helper — exposes the underlying surface for tests. */
53
+ getApi(): OpenClawApiSurface;
54
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * OpenClawApiShim — typed subset of the OpenClaw plugin API surface.
3
+ *
4
+ * Q2 resolution: the upstream OpenClaw plugin API has no semver contract.
5
+ * Rather than depend on it directly, all native-tool calls go through this
6
+ * shim which exposes only the methods cc-openclaw needs.
7
+ *
8
+ * `validateShape(api)` runs at boot phase 3 (`validate-upstream`) and is
9
+ * registered as a `PatchSpec.expectedShape` probe. Failure → `DriftError`
10
+ * and boot refuses (per PatchManifest atomic-install contract).
11
+ *
12
+ * Phase D: types + probe shipped; `dispatch` stubbed and throws
13
+ * `NotImplemented` until Phase E wires the live OpenClaw `api.tool.dispatch`.
14
+ */
15
+ import { NotImplemented } from '../../lib/domain-error.js';
16
+ export class OpenClawApiShim {
17
+ api;
18
+ constructor(api) {
19
+ this.api = api;
20
+ }
21
+ /**
22
+ * Phase 3 probe — returns true when `api.tool.dispatch` and `api.tool.list`
23
+ * exist as callable methods. Used as a `PatchSpec.expectedShape` probe.
24
+ */
25
+ static validateShape(api) {
26
+ if (typeof api !== 'object' || api === null)
27
+ return false;
28
+ const a = api;
29
+ if (typeof a.tool !== 'object' || a.tool === null)
30
+ return false;
31
+ const t = a.tool;
32
+ return typeof t.dispatch === 'function' && typeof t.list === 'function';
33
+ }
34
+ /**
35
+ * Dispatch a Claude `tool_use` event to OpenClaw's plugin API. Phase D stub.
36
+ */
37
+ async dispatch(_call) {
38
+ throw new NotImplemented('OpenClawApiShim.dispatch (Phase E wires api.tool.dispatch)');
39
+ }
40
+ /** Phase D helper — exposes the underlying surface for tests. */
41
+ getApi() {
42
+ return this.api;
43
+ }
44
+ }
45
+ //# sourceMappingURL=openclaw-api-shim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw-api-shim.js","sourceRoot":"","sources":["../../../../src/openai-compat/bridges/openclaw-api-shim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AA4B3D,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,GAAuB;QAAvB,QAAG,GAAH,GAAG,CAAoB;IAAG,CAAC;IAExD;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,GAAY;QAC/B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QAC1D,MAAM,CAAC,GAAG,GAA8B,CAAC;QACzC,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QAChE,MAAM,CAAC,GAAG,CAAC,CAAC,IAA+B,CAAC;QAC5C,OAAO,OAAO,CAAC,CAAC,QAAQ,KAAK,UAAU,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;IAC1E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,KAAkB;QAC/B,MAAM,IAAI,cAAc,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,iEAAiE;IACjE,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * OpenAI streaming chunk types.
3
+ *
4
+ * Extracted from `openai-compat.ts` 2026-05-13 to push that file under the
5
+ * 500-LOC ceiling. Single source of truth for the SSE chunk shape; also
6
+ * imported by `response-formatter.ts`, `types/route.ts`, `types/sse.ts`.
7
+ */
8
+ export interface OpenAIChatCompletionChunk {
9
+ id: string;
10
+ object: 'chat.completion.chunk';
11
+ created: number;
12
+ model: string;
13
+ choices: Array<{
14
+ index: number;
15
+ delta: {
16
+ role?: string;
17
+ content?: string | null;
18
+ tool_calls?: Array<{
19
+ index: number;
20
+ id?: string;
21
+ type?: 'function';
22
+ function?: {
23
+ name?: string;
24
+ arguments?: string;
25
+ };
26
+ }>;
27
+ };
28
+ finish_reason: string | null;
29
+ }>;
30
+ usage?: {
31
+ prompt_tokens: number;
32
+ completion_tokens: number;
33
+ total_tokens: number;
34
+ };
35
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * OpenAI streaming chunk types.
3
+ *
4
+ * Extracted from `openai-compat.ts` 2026-05-13 to push that file under the
5
+ * 500-LOC ceiling. Single source of truth for the SSE chunk shape; also
6
+ * imported by `response-formatter.ts`, `types/route.ts`, `types/sse.ts`.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=openai-chunk-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-chunk-types.js","sourceRoot":"","sources":["../../../src/openai-compat/openai-chunk-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}