Matrix: move outbound session routing behind plugin boundary
This commit is contained in:
parent
fa896704d2
commit
d1d36da700
@ -1,4 +1,74 @@
|
||||
import { createAccountListHelpers as createAccountListHelpersFromSdk } from "openclaw/plugin-sdk/matrix";
|
||||
|
||||
export * from "openclaw/plugin-sdk/matrix";
|
||||
export const createAccountListHelpers = createAccountListHelpersFromSdk;
|
||||
export {
|
||||
GROUP_POLICY_BLOCKED_LABEL,
|
||||
MarkdownConfigSchema,
|
||||
PAIRING_APPROVED_MESSAGE,
|
||||
ToolPolicySchema,
|
||||
buildChannelConfigSchema,
|
||||
buildChannelKeyCandidates,
|
||||
buildProbeChannelStatusSummary,
|
||||
buildSecretInputSchema,
|
||||
collectStatusIssuesFromLastError,
|
||||
compileAllowlist,
|
||||
createActionGate,
|
||||
createReplyPrefixOptions,
|
||||
createScopedPairingAccess,
|
||||
createTypingCallbacks,
|
||||
dispatchReplyFromConfigWithSettledDispatcher,
|
||||
evaluateGroupRouteAccessForPolicy,
|
||||
fetchWithSsrFGuard,
|
||||
formatAllowlistMatchMeta,
|
||||
formatLocationText,
|
||||
hasConfiguredSecretInput,
|
||||
issuePairingChallenge,
|
||||
jsonResult,
|
||||
logInboundDrop,
|
||||
logTypingFailure,
|
||||
mergeAllowlist,
|
||||
normalizeResolvedSecretInputString,
|
||||
normalizeSecretInputString,
|
||||
normalizeStringEntries,
|
||||
readNumberParam,
|
||||
readReactionParams,
|
||||
readStoreAllowFromForDmPolicy,
|
||||
readStringParam,
|
||||
resolveAllowlistProviderRuntimeGroupPolicy,
|
||||
resolveChannelEntryMatch,
|
||||
resolveCompiledAllowlistMatch,
|
||||
resolveControlCommandGate,
|
||||
resolveDefaultGroupPolicy,
|
||||
resolveDmGroupAccessWithLists,
|
||||
resolveInboundSessionEnvelopeContext,
|
||||
resolveRuntimeEnv,
|
||||
resolveSenderScopedGroupPolicy,
|
||||
runPluginCommandWithTimeout,
|
||||
summarizeMapping,
|
||||
toLocationContext,
|
||||
warnMissingProviderGroupPolicyFallbackOnce,
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
} from "openclaw/plugin-sdk/matrix";
|
||||
export { createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
|
||||
export type {
|
||||
AllowlistMatch,
|
||||
BaseProbeResult,
|
||||
ChannelDirectoryEntry,
|
||||
ChannelGroupContext,
|
||||
ChannelMessageActionAdapter,
|
||||
ChannelMessageActionContext,
|
||||
ChannelMessageActionName,
|
||||
ChannelOutboundAdapter,
|
||||
ChannelPlugin,
|
||||
ChannelResolveKind,
|
||||
ChannelResolveResult,
|
||||
ChannelToolSend,
|
||||
DmPolicy,
|
||||
GroupPolicy,
|
||||
GroupToolPolicyConfig,
|
||||
MarkdownTableMode,
|
||||
NormalizedLocation,
|
||||
PluginRuntime,
|
||||
PollInput,
|
||||
ReplyPayload,
|
||||
RuntimeEnv,
|
||||
RuntimeLogger,
|
||||
SecretInput,
|
||||
} from "openclaw/plugin-sdk/matrix";
|
||||
|
||||
@ -32,6 +32,7 @@ import {
|
||||
} from "./matrix/accounts.js";
|
||||
import { normalizeMatrixAllowList, normalizeMatrixUserId } from "./matrix/monitor/allowlist.js";
|
||||
import { getMatrixRuntime } from "./runtime.js";
|
||||
import { resolveMatrixOutboundSessionRoute } from "./session-route.js";
|
||||
import { matrixSetupAdapter } from "./setup-core.js";
|
||||
import { matrixSetupWizard } from "./setup-surface.js";
|
||||
import type { CoreConfig } from "./types.js";
|
||||
@ -172,6 +173,7 @@ export const matrixPlugin: ChannelPlugin<ResolvedMatrixAccount> = {
|
||||
},
|
||||
messaging: {
|
||||
normalizeTarget: normalizeMatrixMessagingTarget,
|
||||
resolveOutboundSessionRoute: (params) => resolveMatrixOutboundSessionRoute(params),
|
||||
targetResolver: {
|
||||
looksLikeId: (raw) => {
|
||||
const trimmed = raw.trim();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
|
||||
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
||||
import { createAccountListHelpers } from "openclaw/plugin-sdk/matrix";
|
||||
import { hasConfiguredSecretInput } from "../secret-input.js";
|
||||
import type { CoreConfig, MatrixConfig } from "../types.js";
|
||||
import { resolveMatrixConfigForAccount } from "./client.js";
|
||||
|
||||
29
extensions/matrix/src/session-route.ts
Normal file
29
extensions/matrix/src/session-route.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import {
|
||||
buildChannelOutboundSessionRoute,
|
||||
stripChannelTargetPrefix,
|
||||
stripTargetKindPrefix,
|
||||
type ChannelOutboundSessionRouteParams,
|
||||
} from "openclaw/plugin-sdk/core";
|
||||
|
||||
export function resolveMatrixOutboundSessionRoute(params: ChannelOutboundSessionRouteParams) {
|
||||
const stripped = stripChannelTargetPrefix(params.target, "matrix");
|
||||
const isUser =
|
||||
params.resolvedTarget?.kind === "user" || stripped.startsWith("@") || /^user:/i.test(stripped);
|
||||
const rawId = stripTargetKindPrefix(stripped);
|
||||
if (!rawId) {
|
||||
return null;
|
||||
}
|
||||
return buildChannelOutboundSessionRoute({
|
||||
cfg: params.cfg,
|
||||
agentId: params.agentId,
|
||||
channel: "matrix",
|
||||
accountId: params.accountId,
|
||||
peer: {
|
||||
kind: isUser ? "direct" : "channel",
|
||||
id: rawId,
|
||||
},
|
||||
chatType: isUser ? "direct" : "channel",
|
||||
from: isUser ? `matrix:${rawId}` : `matrix:channel:${rawId}`,
|
||||
to: `room:${rawId}`,
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user