Skip to content

Commit 9e1b524

Browse files
committed
fix: break mattermost runtime cycle
1 parent fcc9fd1 commit 9e1b524

23 files changed

Lines changed: 124 additions & 96 deletions

extensions/mattermost/api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
export { mattermostPlugin } from "./src/channel.js";
1+
// Keep this barrel helper-only so plugin-sdk facades do not pull the full
2+
// channel plugin (and its runtime state) into tests or other shared surfaces.
23
export { isMattermostSenderAllowed } from "./src/mattermost/monitor-auth.js";

extensions/mattermost/src/mattermost/accounts.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
12
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
23
import { resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
3-
import { createAccountListHelpers, type OpenClawConfig } from "../runtime-api.js";
44
import { normalizeResolvedSecretInputString, normalizeSecretInputString } from "../secret-input.js";
55
import type {
66
MattermostAccountConfig,
@@ -9,6 +9,7 @@ import type {
99
MattermostReplyToMode,
1010
} from "../types.js";
1111
import { normalizeMattermostBaseUrl } from "./client.js";
12+
import type { OpenClawConfig } from "./runtime-api.js";
1213

1314
export type MattermostTokenSource = "env" | "config" | "none";
1415
export type MattermostBaseUrlSource = "env" | "config" | "none";
@@ -30,11 +31,15 @@ export type ResolvedMattermostAccount = {
3031
blockStreamingCoalesce?: MattermostAccountConfig["blockStreamingCoalesce"];
3132
};
3233

33-
const {
34-
listAccountIds: listMattermostAccountIds,
35-
resolveDefaultAccountId: resolveDefaultMattermostAccountId,
36-
} = createAccountListHelpers("mattermost");
37-
export { listMattermostAccountIds, resolveDefaultMattermostAccountId };
34+
const mattermostAccountHelpers = createAccountListHelpers("mattermost");
35+
36+
export function listMattermostAccountIds(cfg: OpenClawConfig): string[] {
37+
return mattermostAccountHelpers.listAccountIds(cfg);
38+
}
39+
40+
export function resolveDefaultMattermostAccountId(cfg: OpenClawConfig): string {
41+
return mattermostAccountHelpers.resolveDefaultAccountId(cfg);
42+
}
3843

3944
function mergeMattermostAccountConfig(
4045
cfg: OpenClawConfig,

extensions/mattermost/src/mattermost/directory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { ChannelDirectoryEntry, OpenClawConfig, RuntimeEnv } from "../runtime-api.js";
21
import { listMattermostAccountIds, resolveMattermostAccount } from "./accounts.js";
32
import {
43
createMattermostClient,
@@ -7,6 +6,7 @@ import {
76
type MattermostClient,
87
type MattermostUser,
98
} from "./client.js";
9+
import type { ChannelDirectoryEntry, OpenClawConfig, RuntimeEnv } from "./runtime-api.js";
1010

1111
export type MattermostDirectoryParams = {
1212
cfg: OpenClawConfig;

extensions/mattermost/src/mattermost/interactions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { createHmac, timingSafeEqual } from "node:crypto";
22
import type { IncomingMessage, ServerResponse } from "node:http";
3-
import { isTrustedProxyAddress, resolveClientIp, type OpenClawConfig } from "../runtime-api.js";
43
import { getMattermostRuntime } from "../runtime.js";
54
import { updateMattermostPost, type MattermostClient, type MattermostPost } from "./client.js";
5+
import { isTrustedProxyAddress, resolveClientIp, type OpenClawConfig } from "./runtime-api.js";
66

77
const INTERACTION_MAX_BODY_BYTES = 64 * 1024;
88
const INTERACTION_BODY_TIMEOUT_MS = 10_000;

extensions/mattermost/src/mattermost/model-picker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { createHash } from "node:crypto";
2+
import type { MattermostInteractiveButtonInput } from "./interactions.js";
23
import {
34
loadSessionStore,
45
normalizeProviderId,
56
resolveStorePath,
67
resolveStoredModelOverride,
78
type ModelsProviderData,
89
type OpenClawConfig,
9-
} from "../runtime-api.js";
10-
import type { MattermostInteractiveButtonInput } from "./interactions.js";
10+
} from "./runtime-api.js";
1111

1212
const MATTERMOST_MODEL_PICKER_CONTEXT_KEY = "oc_model_picker";
1313
const MODELS_PAGE_SIZE = 8;

extensions/mattermost/src/mattermost/monitor-auth.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ const resolveAllowlistMatchSimple = vi.hoisted(() => vi.fn());
66
const resolveControlCommandGate = vi.hoisted(() => vi.fn());
77
const resolveEffectiveAllowFromLists = vi.hoisted(() => vi.fn());
88

9-
vi.mock("../runtime-api.js", () => ({
10-
evaluateSenderGroupAccessForPolicy,
11-
isDangerousNameMatchingEnabled,
12-
resolveAllowlistMatchSimple,
13-
resolveControlCommandGate,
14-
resolveEffectiveAllowFromLists,
15-
}));
9+
vi.mock("./runtime-api.js", async (importOriginal) => {
10+
const actual = await importOriginal<typeof import("./runtime-api.js")>();
11+
return {
12+
...actual,
13+
evaluateSenderGroupAccessForPolicy,
14+
isDangerousNameMatchingEnabled,
15+
resolveAllowlistMatchSimple,
16+
resolveControlCommandGate,
17+
resolveEffectiveAllowFromLists,
18+
};
19+
});
1620

1721
describe("mattermost monitor auth", () => {
1822
beforeEach(() => {

extensions/mattermost/src/mattermost/monitor-auth.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import type { OpenClawConfig } from "../runtime-api.js";
1+
import type { ResolvedMattermostAccount } from "./accounts.js";
2+
import type { MattermostChannel } from "./client.js";
3+
import type { OpenClawConfig } from "./runtime-api.js";
24
import {
35
evaluateSenderGroupAccessForPolicy,
46
isDangerousNameMatchingEnabled,
57
resolveAllowlistMatchSimple,
68
resolveControlCommandGate,
79
resolveEffectiveAllowFromLists,
8-
} from "../runtime-api.js";
9-
import type { ResolvedMattermostAccount } from "./accounts.js";
10-
import type { MattermostChannel } from "./client.js";
10+
} from "./runtime-api.js";
1111

1212
export function normalizeMattermostAllowEntry(entry: string): string {
1313
const trimmed = entry.trim();

extensions/mattermost/src/mattermost/monitor-gating.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ChatType, OpenClawConfig } from "../runtime-api.js";
1+
import type { ChatType, OpenClawConfig } from "./runtime-api.js";
22

33
export function mapMattermostChannelTypeToChatType(channelType?: string | null): ChatType {
44
if (!channelType) {

extensions/mattermost/src/mattermost/monitor-helpers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import {
2+
createDedupeCache,
23
formatInboundFromLabel as formatInboundFromLabelShared,
4+
rawDataToString,
35
resolveThreadSessionKeys as resolveThreadSessionKeysShared,
46
type OpenClawConfig,
5-
} from "../runtime-api.js";
6-
export { createDedupeCache, rawDataToString } from "../runtime-api.js";
7+
} from "./runtime-api.js";
8+
9+
export { createDedupeCache, rawDataToString };
710

811
export type ResponsePrefixContext = {
912
model?: string;

extensions/mattermost/src/mattermost/monitor-slash.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import {
2-
listSkillCommandsForAgents,
3-
parseStrictPositiveInteger,
4-
type OpenClawConfig,
5-
type RuntimeEnv,
6-
} from "../runtime-api.js";
71
import type { ResolvedMattermostAccount } from "./accounts.js";
82
import {
93
fetchMattermostUserTeams,
104
normalizeMattermostBaseUrl,
115
type MattermostClient,
126
} from "./client.js";
7+
import {
8+
listSkillCommandsForAgents,
9+
parseStrictPositiveInteger,
10+
type OpenClawConfig,
11+
type RuntimeEnv,
12+
} from "./runtime-api.js";
1313
import {
1414
DEFAULT_COMMAND_SPECS,
1515
isSlashCommandsEnabled,

0 commit comments

Comments
 (0)