Plugins: scope SDK imports and harden Matrix routing

This commit is contained in:
Gustavo Madeira Santana
2026-03-09 00:54:57 -04:00
parent a2edb0ebfb
commit 86f18afafa
42 changed files with 775 additions and 203 deletions

View File

@@ -218,6 +218,28 @@ describe("pairing cli", () => {
});
});
it("forwards --account to approval notifications", async () => {
mockApprovedPairing();
await runPairing([
"pairing",
"approve",
"--channel",
"telegram",
"--account",
"yy",
"--notify",
"ABCDEFGH",
]);
expect(notifyPairingApproved).toHaveBeenCalledWith({
channelId: "telegram",
id: "123",
cfg: {},
accountId: "yy",
});
});
it("defaults approve to the sole available channel when only code is provided", async () => {
listPairingChannels.mockReturnValueOnce(["slack"]);
mockApprovedPairing();

View File

@@ -44,9 +44,9 @@ function parseChannel(raw: unknown, channels: PairingChannel[]): PairingChannel
throw new Error(`Invalid channel: ${value}`);
}
async function notifyApproved(channel: PairingChannel, id: string) {
async function notifyApproved(channel: PairingChannel, id: string, accountId?: string) {
const cfg = loadConfig();
await notifyPairingApproved({ channelId: channel, id, cfg });
await notifyPairingApproved({ channelId: channel, id, cfg, accountId });
}
export function registerPairingCli(program: Command) {
@@ -166,7 +166,7 @@ export function registerPairingCli(program: Command) {
if (!opts.notify) {
return;
}
await notifyApproved(channel, approved.id).catch((err) => {
await notifyApproved(channel, approved.id, accountId || undefined).catch((err) => {
defaultRuntime.log(theme.warn(`Failed to notify requester: ${String(err)}`));
});
});