mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 01:41:40 +00:00
Matrix: align plugin surfaces
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
"extensions": [
|
||||
"./index.ts"
|
||||
],
|
||||
"setupEntry": "./setup-entry.ts",
|
||||
"channel": {
|
||||
"id": "matrix",
|
||||
"label": "Matrix",
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import {
|
||||
listMatrixDirectoryGroupsLive as listMatrixDirectoryGroupsLiveImpl,
|
||||
listMatrixDirectoryPeersLive as listMatrixDirectoryPeersLiveImpl,
|
||||
} from "./directory-live.js";
|
||||
import { resolveMatrixAuth as resolveMatrixAuthImpl } from "./matrix/client.js";
|
||||
import { probeMatrix as probeMatrixImpl } from "./matrix/probe.js";
|
||||
import { sendMessageMatrix as sendMessageMatrixImpl } from "./matrix/send.js";
|
||||
import { matrixOutbound as matrixOutboundImpl } from "./outbound.js";
|
||||
import { resolveMatrixTargets as resolveMatrixTargetsImpl } from "./resolve-targets.js";
|
||||
export const matrixChannelRuntime = {
|
||||
listMatrixDirectoryGroupsLive: listMatrixDirectoryGroupsLiveImpl,
|
||||
listMatrixDirectoryPeersLive: listMatrixDirectoryPeersLiveImpl,
|
||||
resolveMatrixAuth: resolveMatrixAuthImpl,
|
||||
probeMatrix: probeMatrixImpl,
|
||||
sendMessageMatrix: sendMessageMatrixImpl,
|
||||
resolveMatrixTargets: resolveMatrixTargetsImpl,
|
||||
matrixOutbound: { ...matrixOutboundImpl },
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
export type { MatrixAuth } from "./client/types.js";
|
||||
export { isBunRuntime } from "./client/runtime.js";
|
||||
export { getMatrixScopedEnvVarNames } from "openclaw/plugin-sdk/matrix";
|
||||
export {
|
||||
getMatrixScopedEnvVarNames,
|
||||
hasReadyMatrixEnvAuth,
|
||||
resolveMatrixConfigForAccount,
|
||||
resolveScopedMatrixEnvConfig,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
getMatrixScopedEnvVarNames,
|
||||
isPrivateOrLoopbackHost,
|
||||
normalizeAccountId,
|
||||
normalizeOptionalAccountId,
|
||||
@@ -7,7 +8,6 @@ import {
|
||||
requiresExplicitMatrixDefaultAccount,
|
||||
resolveMatrixDefaultOrOnlyAccountId,
|
||||
} from "openclaw/plugin-sdk/matrix";
|
||||
import { getMatrixScopedEnvVarNames } from "../../../../../src/infra/matrix-env-vars.js";
|
||||
import { getMatrixRuntime } from "../../runtime.js";
|
||||
import type { CoreConfig } from "../../types.js";
|
||||
import {
|
||||
@@ -92,7 +92,7 @@ function resolveGlobalMatrixEnvConfig(env: NodeJS.ProcessEnv): MatrixEnvConfig {
|
||||
};
|
||||
}
|
||||
|
||||
export { getMatrixScopedEnvVarNames } from "../../../../../src/infra/matrix-env-vars.js";
|
||||
export { getMatrixScopedEnvVarNames } from "openclaw/plugin-sdk/matrix";
|
||||
|
||||
export function resolveScopedMatrixEnvConfig(
|
||||
accountId: string,
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
type ISyncResponse,
|
||||
type IStoredClientOpts,
|
||||
} from "matrix-js-sdk";
|
||||
import { createAsyncLock, writeJsonAtomic } from "../../../../../src/infra/json-files.js";
|
||||
import { writeJsonFileAtomically } from "openclaw/plugin-sdk/matrix";
|
||||
import { LogService } from "../sdk/logger.js";
|
||||
|
||||
const STORE_VERSION = 1;
|
||||
@@ -19,6 +19,23 @@ type PersistedMatrixSyncStore = {
|
||||
clientOptions?: IStoredClientOpts;
|
||||
};
|
||||
|
||||
function createAsyncLock() {
|
||||
let lock: Promise<void> = Promise.resolve();
|
||||
return async function withLock<T>(fn: () => Promise<T>): Promise<T> {
|
||||
const previous = lock;
|
||||
let release: (() => void) | undefined;
|
||||
lock = new Promise<void>((resolve) => {
|
||||
release = resolve;
|
||||
});
|
||||
await previous;
|
||||
try {
|
||||
return await fn();
|
||||
} finally {
|
||||
release?.();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
@@ -229,11 +246,7 @@ export class FileBackedMatrixSyncStore extends MemoryStore {
|
||||
};
|
||||
try {
|
||||
await this.persistLock(async () => {
|
||||
await writeJsonAtomic(this.storagePath, payload, {
|
||||
mode: 0o600,
|
||||
trailingNewline: true,
|
||||
ensureDirMode: 0o700,
|
||||
});
|
||||
await writeJsonFileAtomically(this.storagePath, payload);
|
||||
});
|
||||
} catch (err) {
|
||||
this.dirty = true;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { format } from "node:util";
|
||||
import { redactSensitiveText } from "../../../../../src/logging/redact.js";
|
||||
import type { RuntimeLogger } from "../../../../../src/plugins/runtime/types.js";
|
||||
import { redactSensitiveText, type RuntimeLogger } from "openclaw/plugin-sdk/matrix";
|
||||
import { getMatrixRuntime } from "../../runtime.js";
|
||||
|
||||
export type Logger = {
|
||||
|
||||
@@ -105,6 +105,7 @@ export {
|
||||
resolveMatrixCredentialsPath,
|
||||
resolveMatrixLegacyFlatStoragePaths,
|
||||
} from "../infra/matrix-storage-paths.js";
|
||||
export { getMatrixScopedEnvVarNames } from "../infra/matrix-env-vars.js";
|
||||
export {
|
||||
requiresExplicitMatrixDefaultAccount,
|
||||
resolveMatrixDefaultOrOnlyAccountId,
|
||||
@@ -147,6 +148,4 @@ export {
|
||||
buildProbeChannelStatusSummary,
|
||||
collectStatusIssuesFromLastError,
|
||||
} from "./status-helpers.js";
|
||||
export { matrixSetupWizard } from "../../extensions/matrix/api.js";
|
||||
export { matrixSetupAdapter } from "../../extensions/matrix/api.js";
|
||||
export type { GatewayRequestHandlerOptions } from "../gateway/server-methods/types.js";
|
||||
|
||||
@@ -260,8 +260,7 @@ describe("plugin-sdk subpath exports", () => {
|
||||
|
||||
it("keeps the newly added bundled plugin-sdk contracts available", async () => {
|
||||
expect(typeof bluebubblesSdk.parseFiniteNumber).toBe("function");
|
||||
expect(typeof matrixSdk.matrixSetupWizard).toBe("object");
|
||||
expect(typeof matrixSdk.matrixSetupAdapter).toBe("object");
|
||||
expect(typeof matrixSdk.getMatrixScopedEnvVarNames).toBe("function");
|
||||
expect(typeof mattermostSdk.parseStrictPositiveInteger).toBe("function");
|
||||
expect(typeof nextcloudTalkSdk.waitForAbortSignal).toBe("function");
|
||||
expect(typeof twitchSdk.DEFAULT_ACCOUNT_ID).toBe("string");
|
||||
|
||||
Reference in New Issue
Block a user