mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:18:37 +00:00
fix: add runtime.events regression tests (#16044) (thanks @scifantastic)
This commit is contained in:
@@ -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.
|
- 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 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 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.
|
- 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.
|
- 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.
|
- 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.
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
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());
|
const runCommandWithTimeoutMock = vi.hoisted(() => vi.fn());
|
||||||
|
|
||||||
@@ -39,4 +41,10 @@ describe("plugin runtime command execution", () => {
|
|||||||
).rejects.toThrow("boom");
|
).rejects.toThrow("boom");
|
||||||
expect(runCommandWithTimeoutMock).toHaveBeenCalledWith(["echo", "hello"], { timeoutMs: 1000 });
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
35
src/sessions/transcript-events.test.ts
Normal file
35
src/sessions/transcript-events.test.ts
Normal file
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user