mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-31 13:18:36 +00:00
* fix(codex): cover side-question native hooks * fix(codex): enforce native approvals for app-server requests * fix(codex): preserve approval fallback after native relay noop * fix(codex): satisfy approval relay json typing * fix(codex): run approval relay in report mode * fix(codex): keep relay pre-tool decisions deny-only * fix(codex): remove dead relay approval branch * fix(codex): dedupe app-server relay approvals * fix(codex): fail closed on native relay rewrites * fix(codex): preserve side-question provider context * fix(codex): route side-question replies to origin * fix(codex): preserve native hook channel context * test(codex): align native relay rewrite assertion * fix(codex): align side-question hook config * fix(codex): route side-question approvals safely * test(codex): fix side-question hook typing * fix(codex): preserve side-question hook policy context * fix(codex): close native hook relay review gaps * fix(codex): keep dynamic tool hook channel context * fix(codex): preserve native finalize hook channel context * fix(codex): scope dynamic tool result hooks by channel * fix(codex): drop stale deadcode allowlist entry --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
73 lines
2.1 KiB
TypeScript
73 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildAgentHookContextChannelFields,
|
|
resolveAgentHookChannelId,
|
|
} from "./hook-agent-context.js";
|
|
|
|
describe("resolveAgentHookChannelId", () => {
|
|
it("derives the conversation id from channel session keys", () => {
|
|
expect(
|
|
resolveAgentHookChannelId({
|
|
sessionKey: "agent:main:discord:channel:1472750640760623226",
|
|
messageChannel: "discord",
|
|
messageProvider: "discord",
|
|
currentChannelId: "channel:1472750640760623226",
|
|
}),
|
|
).toBe("1472750640760623226");
|
|
});
|
|
|
|
it("uses target metadata when the session key is not a channel conversation", () => {
|
|
expect(
|
|
resolveAgentHookChannelId({
|
|
sessionKey: "agent:main:main",
|
|
messageProvider: "telegram",
|
|
currentChannelId: "telegram:-1003841603622",
|
|
}),
|
|
).toBe("-1003841603622");
|
|
});
|
|
|
|
it("uses message channel prefixes when provider is a narrower route label", () => {
|
|
expect(
|
|
resolveAgentHookChannelId({
|
|
sessionKey: "agent:main:main",
|
|
messageChannel: "discord",
|
|
messageProvider: "discord-voice",
|
|
currentChannelId: "discord:voice-room",
|
|
}),
|
|
).toBe("voice-room");
|
|
});
|
|
|
|
it("uses prefixed message targets before falling back to the provider", () => {
|
|
expect(
|
|
resolveAgentHookChannelId({
|
|
messageChannel: "channel:1472750640760623226",
|
|
messageProvider: "discord",
|
|
}),
|
|
).toBe("1472750640760623226");
|
|
});
|
|
|
|
it("falls back to legacy channel/provider values when no conversation id is available", () => {
|
|
expect(
|
|
resolveAgentHookChannelId({
|
|
messageChannel: "discord",
|
|
messageProvider: "discord",
|
|
}),
|
|
).toBe("discord");
|
|
});
|
|
});
|
|
|
|
describe("buildAgentHookContextChannelFields", () => {
|
|
it("keeps provider and conversation id separate", () => {
|
|
expect(
|
|
buildAgentHookContextChannelFields({
|
|
sessionKey: "agent:main:discord:channel:c1",
|
|
messageChannel: "discord",
|
|
messageProvider: "discord",
|
|
}),
|
|
).toEqual({
|
|
messageProvider: "discord",
|
|
channelId: "c1",
|
|
});
|
|
});
|
|
});
|