diff --git a/CHANGELOG.md b/CHANGELOG.md index dd3e2222410..237f01245fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Docs: https://docs.openclaw.ai - Media understanding/audio echo: add optional `tools.media.audio.echoTranscript` + `echoFormat` to send a pre-agent transcript confirmation message to the originating chat, with echo disabled by default. (#32150) Thanks @AytuncYildizli. - Plugin runtime/STT: add `api.runtime.stt.transcribeAudioFile(...)` so extensions can transcribe local audio files through OpenClaw's configured media-understanding audio providers. (#22402) Thanks @benthecarman. - Plugin SDK/channel extensibility: expose `channelRuntime` on `ChannelGatewayContext` so external channel plugins can access shared runtime helpers (reply/routing/session/text/media/commands) without internal imports. (#25462) Thanks @guxiaobo. +- Plugin runtime/events: expose `runtime.events.onAgentEvent` and `runtime.events.onSessionTranscriptUpdate` for extension-side subscriptions, and isolate transcript-listener failures so one faulty listener cannot break the entire update fanout. (#16044) Thanks @scifantastic. - Sessions/Attachments: add inline file attachment support for `sessions_spawn` (subagent runtime only) with base64/utf8 encoding, transcript content redaction, lifecycle cleanup, and configurable limits via `tools.sessions_spawn.attachments`. (#16761) Thanks @napetrov. - Tools/PDF analysis: add a first-class `pdf` tool with native Anthropic and Google PDF provider support, extraction fallback for non-native models, configurable defaults (`agents.defaults.pdfModel`, `pdfMaxBytesMb`, `pdfMaxPages`), and docs/tests covering routing, validation, and registration. (#31319) Thanks @tyler6204. - Zalo Personal plugin (`@openclaw/zalouser`): rebuilt channel runtime to use native `zca-js` integration in-process, removing external CLI transport usage and keeping QR/login + send/listen flows fully inside OpenClaw. diff --git a/src/plugins/runtime/index.test.ts b/src/plugins/runtime/index.test.ts index 4ac4af5f076..ae40e463b6d 100644 --- a/src/plugins/runtime/index.test.ts +++ b/src/plugins/runtime/index.test.ts @@ -1,4 +1,6 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; +import { onAgentEvent } from "../../infra/agent-events.js"; +import { onSessionTranscriptUpdate } from "../../sessions/transcript-events.js"; const runCommandWithTimeoutMock = vi.hoisted(() => vi.fn()); @@ -39,4 +41,10 @@ describe("plugin runtime command execution", () => { ).rejects.toThrow("boom"); expect(runCommandWithTimeoutMock).toHaveBeenCalledWith(["echo", "hello"], { timeoutMs: 1000 }); }); + + it("exposes runtime.events listener registration helpers", () => { + const runtime = createPluginRuntime(); + expect(runtime.events.onAgentEvent).toBe(onAgentEvent); + expect(runtime.events.onSessionTranscriptUpdate).toBe(onSessionTranscriptUpdate); + }); }); diff --git a/src/sessions/transcript-events.test.ts b/src/sessions/transcript-events.test.ts new file mode 100644 index 00000000000..f9d8c7f3a99 --- /dev/null +++ b/src/sessions/transcript-events.test.ts @@ -0,0 +1,35 @@ +import { afterEach, describe, expect, it, vi } from "vitest"; +import { emitSessionTranscriptUpdate, onSessionTranscriptUpdate } from "./transcript-events.js"; + +const cleanup: Array<() => void> = []; + +afterEach(() => { + while (cleanup.length > 0) { + cleanup.pop()?.(); + } +}); + +describe("transcript events", () => { + it("emits trimmed session file updates", () => { + const listener = vi.fn(); + cleanup.push(onSessionTranscriptUpdate(listener)); + + emitSessionTranscriptUpdate(" /tmp/session.jsonl "); + + expect(listener).toHaveBeenCalledTimes(1); + expect(listener).toHaveBeenCalledWith({ sessionFile: "/tmp/session.jsonl" }); + }); + + it("continues notifying other listeners when one throws", () => { + const first = vi.fn(() => { + throw new Error("boom"); + }); + const second = vi.fn(); + cleanup.push(onSessionTranscriptUpdate(first)); + cleanup.push(onSessionTranscriptUpdate(second)); + + expect(() => emitSessionTranscriptUpdate("/tmp/session.jsonl")).not.toThrow(); + expect(first).toHaveBeenCalledTimes(1); + expect(second).toHaveBeenCalledTimes(1); + }); +});