diff --git a/config/knip.config.ts b/config/knip.config.ts index 2d2e75d03e7e..d5ad5385e26c 100644 --- a/config/knip.config.ts +++ b/config/knip.config.ts @@ -749,8 +749,6 @@ const config = { [`${BUNDLED_PLUGIN_ROOT_DIR}/kilocode`]: bundledPluginWorkspace(), [`${BUNDLED_PLUGIN_ROOT_DIR}/kimi-coding`]: bundledPluginWorkspace(), [`${BUNDLED_PLUGIN_ROOT_DIR}/matrix`]: bundledPluginWorkspace([ - // Native import wrapper shipped alongside the Matrix runtime bundle. - "src/plugin-entry.runtime.js!", // The monitor lazy-loads outbound behavior on inbound-only processes. "src/matrix/send.ts!", ]), diff --git a/extensions/matrix/src/approval-reactions.test.ts b/extensions/matrix/src/approval-reactions.test.ts index d95d505bb4f2..3f5b59865d9c 100644 --- a/extensions/matrix/src/approval-reactions.test.ts +++ b/extensions/matrix/src/approval-reactions.test.ts @@ -1,3 +1,4 @@ +import type { PluginRuntime } from "openclaw/plugin-sdk/plugin-runtime"; // Matrix tests cover approval reactions plugin behavior. import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; @@ -8,7 +9,6 @@ import { resolveMatrixApprovalReactionTargetWithPersistence as resolveMatrixApprovalReactionTargetWithPersistenceRaw, unregisterMatrixApprovalReactionTarget as unregisterMatrixApprovalReactionTargetRaw, } from "./approval-reactions.js"; -import type { PluginRuntime } from "./runtime-api.js"; import { setMatrixRuntime } from "./runtime.js"; const { clearRuntime: clearMatrixRuntime } = createPluginRuntimeStore({ diff --git a/extensions/matrix/src/cli-shared.ts b/extensions/matrix/src/cli-shared.ts index 9afb5a044dda..c7bbaca776c1 100644 --- a/extensions/matrix/src/cli-shared.ts +++ b/extensions/matrix/src/cli-shared.ts @@ -2,12 +2,12 @@ import { normalizeAccountId } from "openclaw/plugin-sdk/account-id"; import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; import { parseStrictInteger } from "openclaw/plugin-sdk/number-runtime"; import { readByteStreamWithLimit } from "openclaw/plugin-sdk/response-limit-runtime"; +import { formatZonedTimestamp } from "openclaw/plugin-sdk/time-runtime"; import { resolveMatrixRoomKeyBackupIssue } from "./matrix/backup-health.js"; import { resolveMatrixAuthContext } from "./matrix/client.js"; import { setMatrixSdkConsoleLogging, setMatrixSdkLogMode } from "./matrix/client/logging.js"; import type { MatrixOwnDeviceVerificationStatus, MatrixRoomKeyBackupStatus } from "./matrix/sdk.js"; import type { MatrixVerificationSummary } from "./matrix/sdk/verification-manager.js"; -import { formatZonedTimestamp } from "./runtime-api.js"; import { getMatrixRuntime } from "./runtime.js"; import type { CoreConfig } from "./types.js"; diff --git a/extensions/matrix/src/cli.test.ts b/extensions/matrix/src/cli.test.ts index 848484d2ace2..256d60df88d9 100644 --- a/extensions/matrix/src/cli.test.ts +++ b/extensions/matrix/src/cli.test.ts @@ -1,8 +1,8 @@ // Matrix tests cover cli plugin behavior. import { Command } from "commander"; +import { formatZonedTimestamp } from "openclaw/plugin-sdk/time-runtime"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { registerMatrixCli } from "./cli.js"; -import { formatZonedTimestamp } from "./runtime-api.js"; import type { CoreConfig } from "./types.js"; const bootstrapMatrixVerificationMock = vi.fn(); diff --git a/extensions/matrix/src/delivery-trace.test.ts b/extensions/matrix/src/delivery-trace.test.ts index b85e923e6f67..718294cd9d89 100644 --- a/extensions/matrix/src/delivery-trace.test.ts +++ b/extensions/matrix/src/delivery-trace.test.ts @@ -24,11 +24,13 @@ import { resolveInboundMentionDecision, } from "openclaw/plugin-sdk/channel-mention-gating"; import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime"; +import type { PluginRuntime } from "openclaw/plugin-sdk/plugin-runtime"; import { chunkMarkdownTextWithMode, resolveChunkMode, resolveTextChunkLimit, } from "openclaw/plugin-sdk/reply-chunking"; +import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime"; import { convertMarkdownTables } from "openclaw/plugin-sdk/text-chunking"; import { beforeAll, describe, it, vi } from "vitest"; import { @@ -36,7 +38,6 @@ import { createMatrixTextMessageEvent, } from "./matrix/monitor/handler.test-helpers.js"; import type { MatrixClient } from "./matrix/sdk.js"; -import type { PluginRuntime, ReplyPayload } from "./runtime-api.js"; import { installMatrixTestRuntime } from "./test-runtime.js"; const ROOM_ID = "!room:example.org"; diff --git a/extensions/matrix/src/directory-live.ts b/extensions/matrix/src/directory-live.ts index 22587a87391a..b5fb1c1e01ed 100644 --- a/extensions/matrix/src/directory-live.ts +++ b/extensions/matrix/src/directory-live.ts @@ -1,3 +1,4 @@ +import type { ChannelDirectoryEntry } from "openclaw/plugin-sdk/channel-contract"; // Matrix plugin module implements directory live behavior. import { normalizeLowercaseStringOrEmpty, @@ -6,7 +7,6 @@ import { import { resolveMatrixAuth } from "./matrix/client.js"; import { MatrixAuthedHttpClient } from "./matrix/sdk/http-client.js"; import { isMatrixQualifiedUserId, normalizeMatrixMessagingTarget } from "./matrix/target-ids.js"; -import type { ChannelDirectoryEntry } from "./runtime-api.js"; type MatrixUserResult = { user_id?: string; diff --git a/extensions/matrix/src/group-mentions.ts b/extensions/matrix/src/group-mentions.ts index 56bdefd72b16..d4809c8beb18 100644 --- a/extensions/matrix/src/group-mentions.ts +++ b/extensions/matrix/src/group-mentions.ts @@ -1,3 +1,4 @@ +import type { ChannelGroupContext } from "openclaw/plugin-sdk/channel-contract"; // Matrix plugin module implements group mentions behavior. import { resolveScopeRequireMention, @@ -7,7 +8,6 @@ import { import { resolveMatrixAccountConfig } from "./matrix/accounts.js"; import { buildMatrixRoomScopeTree, resolveMatrixRoomScopePath } from "./matrix/monitor/rooms.js"; import { normalizeMatrixResolvableTarget } from "./matrix/target-ids.js"; -import type { ChannelGroupContext } from "./runtime-api.js"; import type { CoreConfig } from "./types.js"; function resolveMatrixGroupScope(params: ChannelGroupContext) { diff --git a/extensions/matrix/src/matrix/actions/messages.test.ts b/extensions/matrix/src/matrix/actions/messages.test.ts index 3d1a07ca4ab7..cefc04f0465c 100644 --- a/extensions/matrix/src/matrix/actions/messages.test.ts +++ b/extensions/matrix/src/matrix/actions/messages.test.ts @@ -23,7 +23,7 @@ function installMatrixActionTestRuntime(): void { convertMarkdownTables: (text: string) => text, }, }, - } as unknown as import("../../runtime-api.js").PluginRuntime); + } as unknown as import("openclaw/plugin-sdk/plugin-runtime").PluginRuntime); } function createPollResponseEvent(): Record { diff --git a/extensions/matrix/src/matrix/client/config-runtime-api.ts b/extensions/matrix/src/matrix/client/config-runtime-api.ts deleted file mode 100644 index 2de990c9db6d..000000000000 --- a/extensions/matrix/src/matrix/client/config-runtime-api.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Matrix API module exposes the plugin public contract. -export { - DEFAULT_ACCOUNT_ID, - normalizeAccountId, - normalizeOptionalAccountId, -} from "openclaw/plugin-sdk/account-id"; -export { - isPrivateNetworkOptInEnabled, - ssrfPolicyFromDangerouslyAllowPrivateNetwork, -} from "openclaw/plugin-sdk/ssrf-runtime"; diff --git a/extensions/matrix/src/matrix/client/config.test.ts b/extensions/matrix/src/matrix/client/config.test.ts index 3aa1e2a922fb..c32107b5955b 100644 --- a/extensions/matrix/src/matrix/client/config.test.ts +++ b/extensions/matrix/src/matrix/client/config.test.ts @@ -1,7 +1,7 @@ +import type { LookupFn } from "openclaw/plugin-sdk/ssrf-runtime"; // Matrix tests cover config plugin behavior. import { beforeEach, describe, expect, it, vi } from "vitest"; import { getMatrixScopedEnvVarNames } from "../../env-vars.js"; -import type { LookupFn } from "../../runtime-api.js"; import { installMatrixTestRuntime } from "../../test-runtime.js"; import type { CoreConfig } from "../../types.js"; import { diff --git a/extensions/matrix/src/matrix/client/config.ts b/extensions/matrix/src/matrix/client/config.ts index c94899a1c136..90866c2d0607 100644 --- a/extensions/matrix/src/matrix/client/config.ts +++ b/extensions/matrix/src/matrix/client/config.ts @@ -1,4 +1,9 @@ // Matrix helper module supports config behavior. +import { + DEFAULT_ACCOUNT_ID, + normalizeAccountId, + normalizeOptionalAccountId, +} from "openclaw/plugin-sdk/account-id"; import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime"; import { resolveOptionalIntegerOption } from "openclaw/plugin-sdk/number-runtime"; @@ -10,6 +15,10 @@ import { normalizeResolvedSecretInputString, } from "openclaw/plugin-sdk/secret-input-runtime"; import type { PinnedDispatcherPolicy } from "openclaw/plugin-sdk/ssrf-dispatcher"; +import { + isPrivateNetworkOptInEnabled, + ssrfPolicyFromDangerouslyAllowPrivateNetwork, +} from "openclaw/plugin-sdk/ssrf-runtime"; import { requiresExplicitMatrixDefaultAccount, resolveMatrixDefaultOrOnlyAccountId, @@ -27,13 +36,6 @@ import { } from "../account-config.js"; import { resolveMatrixConfigFieldPath } from "../config-paths.js"; import type { MatrixStoredCredentials } from "../credentials-state.js"; -import { - DEFAULT_ACCOUNT_ID, - isPrivateNetworkOptInEnabled, - normalizeAccountId, - normalizeOptionalAccountId, - ssrfPolicyFromDangerouslyAllowPrivateNetwork, -} from "./config-runtime-api.js"; import { resolveGlobalMatrixEnvConfig, resolveScopedMatrixEnvConfig } from "./env-auth.js"; import { repairCurrentTokenStorageMetaDeviceId } from "./storage.js"; import type { MatrixAuth, MatrixResolvedConfig } from "./types.js"; diff --git a/extensions/matrix/src/matrix/client/types.ts b/extensions/matrix/src/matrix/client/types.ts index a8a0ebc638e5..fc342c58e7fc 100644 --- a/extensions/matrix/src/matrix/client/types.ts +++ b/extensions/matrix/src/matrix/client/types.ts @@ -1,6 +1,6 @@ // Matrix type declarations define plugin contracts. import type { PinnedDispatcherPolicy } from "openclaw/plugin-sdk/ssrf-dispatcher"; -import type { SsrFPolicy } from "../../runtime-api.js"; +import type { SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime"; export type MatrixResolvedConfig = { homeserver: string; diff --git a/extensions/matrix/src/matrix/draft-stream.test.ts b/extensions/matrix/src/matrix/draft-stream.test.ts index 52172a904475..330eeb2acf92 100644 --- a/extensions/matrix/src/matrix/draft-stream.test.ts +++ b/extensions/matrix/src/matrix/draft-stream.test.ts @@ -1,6 +1,6 @@ +import type { PluginRuntime } from "openclaw/plugin-sdk/plugin-runtime"; // Matrix tests cover draft stream plugin behavior. import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import type { PluginRuntime } from "../runtime-api.js"; const sendModuleMocks = vi.hoisted(() => { const loadConfigMock = vi.fn(() => ({})); diff --git a/extensions/matrix/src/matrix/monitor/events.ts b/extensions/matrix/src/matrix/monitor/events.ts index a4b7444a8c89..ec7af10ca66e 100644 --- a/extensions/matrix/src/matrix/monitor/events.ts +++ b/extensions/matrix/src/matrix/monitor/events.ts @@ -1,6 +1,6 @@ +import type { PluginRuntime, RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime"; // Matrix plugin module implements events behavior. import { normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime"; -import type { PluginRuntime, RuntimeLogger } from "../../runtime-api.js"; import type { CoreConfig } from "../../types.js"; import type { MatrixAuth } from "../client.js"; import { formatMatrixEncryptedEventDisabledWarning } from "../encryption-guidance.js"; diff --git a/extensions/matrix/src/matrix/monitor/handler.active-turn-steering.test.ts b/extensions/matrix/src/matrix/monitor/handler.active-turn-steering.test.ts index 9c5db646cfeb..6d355ebf023d 100644 --- a/extensions/matrix/src/matrix/monitor/handler.active-turn-steering.test.ts +++ b/extensions/matrix/src/matrix/monitor/handler.active-turn-steering.test.ts @@ -3,10 +3,10 @@ import { runChannelInboundEvent, type ChannelInboundEventRunnerParams, } from "openclaw/plugin-sdk/channel-inbound"; +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts"; import type { FinalizedMsgContext, GetReplyOptions } from "openclaw/plugin-sdk/reply-runtime"; import { useAutoCleanupTempDirTracker } from "openclaw/plugin-sdk/test-env"; import { afterEach, describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig } from "../../runtime-api.js"; import { installMatrixMonitorTestRuntime } from "../../test-runtime.js"; import type { MatrixMonitorHandlerParams } from "./handler-types.js"; import { diff --git a/extensions/matrix/src/matrix/monitor/handler.test-helpers.ts b/extensions/matrix/src/matrix/monitor/handler.test-helpers.ts index b6f3dcf8b28e..42e9a42faf97 100644 --- a/extensions/matrix/src/matrix/monitor/handler.test-helpers.ts +++ b/extensions/matrix/src/matrix/monitor/handler.test-helpers.ts @@ -3,9 +3,10 @@ import { buildChannelInboundEventContext, type PreparedInboundReply, } from "openclaw/plugin-sdk/channel-inbound"; +import type { RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime"; import { finalizeInboundContext as finalizeCoreInboundContext } from "openclaw/plugin-sdk/reply-runtime"; +import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime"; import { vi, type Mock } from "vitest"; -import type { RuntimeEnv, RuntimeLogger } from "../../runtime-api.js"; import type { MatrixConfig, MatrixRoomConfig, diff --git a/extensions/matrix/src/matrix/monitor/index.test-helpers.ts b/extensions/matrix/src/matrix/monitor/index.test-helpers.ts index 992a74368716..7827b250e2c7 100644 --- a/extensions/matrix/src/matrix/monitor/index.test-helpers.ts +++ b/extensions/matrix/src/matrix/monitor/index.test-helpers.ts @@ -1,5 +1,4 @@ import { vi } from "vitest"; -import { z } from "zod"; import type { MatrixRoomInfo } from "./room-info.js"; export type DirectRoomTrackerOptions = { @@ -223,73 +222,20 @@ vi.mock("openclaw/plugin-sdk/channel-runtime-context", () => ({ registerChannelRuntimeContext: hoisted.registerChannelRuntimeContext, })); -vi.mock("../../runtime-api.js", () => { - const normalizeAccountId = (value: string | null | undefined) => value?.trim() || "default"; - return { - DEFAULT_ACCOUNT_ID: "default", - GROUP_POLICY_BLOCKED_LABEL: { - room: "room", - }, - MarkdownConfigSchema: z.any().optional(), - PAIRING_APPROVED_MESSAGE: "paired", - ToolPolicySchema: z.any().optional(), - addAllowlistUserEntriesFromConfigEntry: vi.fn(), - buildChannelConfigSchema: (schema: unknown) => schema, - buildChannelKeyCandidates: (...keys: Array) => { - const seen = new Set(); - return keys - .map((key) => (typeof key === "string" ? key.trim() : "")) - .filter((key) => { - if (!key || seen.has(key)) { - return false; - } - seen.add(key); - return true; - }); - }, - buildProbeChannelStatusSummary: ( - snapshot: Record, - extra?: Record, - ) => ({ - ...snapshot, - ...extra, - }), - buildSecretInputSchema: () => z.string(), - chunkTextForOutbound: vi.fn((text: string) => [text]), - collectStatusIssuesFromLastError: () => [], - createActionGate: () => () => true, - createReplyPrefixOptions: () => ({}), - createTypingCallbacks: () => ({}), - formatDocsLink: (input: string) => input, - formatZonedTimestamp: () => "2026-03-27T00:00:00.000Z", - getAgentScopedMediaLocalRoots: () => [], - getSessionBindingService: () => ({}), - hasConfiguredSecretInput: (value: unknown) => Boolean(value), - mergeAllowlist: ({ existing, additions }: { existing: string[]; additions: string[] }) => [ - ...existing, - ...additions, - ], - normalizeAccountId, - normalizeOptionalAccountId: normalizeAccountId, - resolveThreadBindingIdleTimeoutMsForChannel: () => 24 * 60 * 60 * 1000, - resolveThreadBindingMaxAgeMsForChannel: () => 0, - resolveAllowlistProviderRuntimeGroupPolicy: () => ({ - groupPolicy: "allowlist", - providerMissingFallbackApplied: false, - }), - resolveDefaultGroupPolicy: () => "allowlist", - resolveOutboundSendDep: () => null, - resolveThreadBindingFarewellText: () => null, - resolveAckReaction: () => null, - readJsonFileWithFallback: vi.fn(), - readNumberParam: vi.fn(), - readReactionParams: vi.fn(), - readStringArrayParam: vi.fn(), - readStringParam: vi.fn(), - summarizeMapping: vi.fn(), - warnMissingProviderGroupPolicyFallbackOnce: vi.fn(), - }; -}); +vi.mock("openclaw/plugin-sdk/runtime-group-policy", () => ({ + GROUP_POLICY_BLOCKED_LABEL: { room: "room" }, + resolveAllowlistProviderRuntimeGroupPolicy: () => ({ + groupPolicy: "allowlist", + providerMissingFallbackApplied: false, + }), + resolveDefaultGroupPolicy: () => "allowlist", + warnMissingProviderGroupPolicyFallbackOnce: vi.fn(), +})); + +vi.mock("openclaw/plugin-sdk/thread-bindings-runtime", () => ({ + resolveThreadBindingIdleTimeoutMsForChannel: () => 24 * 60 * 60 * 1000, + resolveThreadBindingMaxAgeMsForChannel: () => 0, +})); vi.mock("../../resolve-targets.js", () => ({ resolveMatrixTargets: vi.fn(async () => []), diff --git a/extensions/matrix/src/matrix/monitor/index.ts b/extensions/matrix/src/matrix/monitor/index.ts index 63dfabc12f0f..060905a4632e 100644 --- a/extensions/matrix/src/matrix/monitor/index.ts +++ b/extensions/matrix/src/matrix/monitor/index.ts @@ -8,15 +8,17 @@ import { } from "openclaw/plugin-sdk/channel-outbound"; import { registerChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context"; import { resolveOptionalIntegerOption } from "openclaw/plugin-sdk/number-runtime"; +import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime"; import { GROUP_POLICY_BLOCKED_LABEL, - resolveThreadBindingIdleTimeoutMsForChannel, - resolveThreadBindingMaxAgeMsForChannel, resolveAllowlistProviderRuntimeGroupPolicy, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce, - type RuntimeEnv, -} from "../../runtime-api.js"; +} from "openclaw/plugin-sdk/runtime-group-policy"; +import { + resolveThreadBindingIdleTimeoutMsForChannel, + resolveThreadBindingMaxAgeMsForChannel, +} from "openclaw/plugin-sdk/thread-bindings-runtime"; import { getMatrixRuntime } from "../../runtime.js"; import type { CoreConfig, diff --git a/extensions/matrix/src/matrix/monitor/startup-verification.test.ts b/extensions/matrix/src/matrix/monitor/startup-verification.test.ts index 9f322b13fe06..1bdbcb27b742 100644 --- a/extensions/matrix/src/matrix/monitor/startup-verification.test.ts +++ b/extensions/matrix/src/matrix/monitor/startup-verification.test.ts @@ -2,13 +2,13 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; +import type { PluginRuntime } from "openclaw/plugin-sdk/plugin-runtime"; import type { OpenKeyedStoreOptions } from "openclaw/plugin-sdk/plugin-state-runtime"; import { createPluginStateKeyedStoreForTests, resetPluginStateStoreForTests, } from "openclaw/plugin-sdk/plugin-state-test-runtime"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import type { PluginRuntime } from "../../runtime-api.js"; import { setMatrixRuntime } from "../../runtime.js"; import { ensureMatrixStartupVerification } from "./startup-verification.js"; diff --git a/extensions/matrix/src/matrix/monitor/startup.ts b/extensions/matrix/src/matrix/monitor/startup.ts index ffc64e1cab17..dd9c9b1836a4 100644 --- a/extensions/matrix/src/matrix/monitor/startup.ts +++ b/extensions/matrix/src/matrix/monitor/startup.ts @@ -1,6 +1,6 @@ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime"; // Matrix plugin module implements startup behavior. -import type { RuntimeLogger } from "../../runtime-api.js"; +import type { RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime"; import type { CoreConfig, MatrixConfig } from "../../types.js"; import type { MatrixAuth } from "../client.js"; import type { MatrixClient } from "../sdk.js"; diff --git a/extensions/matrix/src/matrix/monitor/task-runner.ts b/extensions/matrix/src/matrix/monitor/task-runner.ts index 2ff1c6728ee8..a60f8ef0daf8 100644 --- a/extensions/matrix/src/matrix/monitor/task-runner.ts +++ b/extensions/matrix/src/matrix/monitor/task-runner.ts @@ -1,5 +1,5 @@ // Matrix plugin module implements task runner behavior. -import type { RuntimeLogger } from "../../runtime-api.js"; +import type { RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime"; export function createMatrixMonitorTaskRunner(params: { logger: RuntimeLogger; diff --git a/extensions/matrix/src/matrix/probe.ts b/extensions/matrix/src/matrix/probe.ts index 34524e5b9907..db5f080f21d5 100644 --- a/extensions/matrix/src/matrix/probe.ts +++ b/extensions/matrix/src/matrix/probe.ts @@ -1,10 +1,11 @@ +import type { BaseProbeResult } from "openclaw/plugin-sdk/channel-contract"; // Matrix plugin module implements probe behavior. import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime"; import type { PinnedDispatcherPolicy } from "openclaw/plugin-sdk/ssrf-dispatcher"; +import type { SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime"; import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime"; import { runChannelProbe } from "openclaw/plugin-sdk/text-utility-runtime"; -import type { SsrFPolicy, BaseProbeResult } from "../runtime-api.js"; import { isBunRuntime } from "./client/runtime.js"; const loadMatrixProbeRuntimeDeps = createLazyRuntimeModule(() => diff --git a/extensions/matrix/src/matrix/read-policy.ts b/extensions/matrix/src/matrix/read-policy.ts index 7f9aaf5cb492..a47e7f4ffe9d 100644 --- a/extensions/matrix/src/matrix/read-policy.ts +++ b/extensions/matrix/src/matrix/read-policy.ts @@ -1,10 +1,10 @@ import { normalizeAccountId } from "openclaw/plugin-sdk/account-id"; +import { ToolAuthorizationError } from "openclaw/plugin-sdk/channel-actions"; import type { ChannelMessageActionContext } from "openclaw/plugin-sdk/channel-contract"; import { resolveAllowlistProviderRuntimeGroupPolicy, resolveDefaultGroupPolicy, - ToolAuthorizationError, -} from "../runtime-api.js"; +} from "openclaw/plugin-sdk/runtime-group-policy"; import type { CoreConfig } from "../types.js"; import { resolveMatrixBaseConfig } from "./account-config.js"; import { resolveMatrixAccount } from "./accounts.js"; diff --git a/extensions/matrix/src/matrix/sdk/client-base.ts b/extensions/matrix/src/matrix/sdk/client-base.ts index 2ed5746f9950..1a58b565e1bd 100644 --- a/extensions/matrix/src/matrix/sdk/client-base.ts +++ b/extensions/matrix/src/matrix/sdk/client-base.ts @@ -10,7 +10,7 @@ import { VerificationMethod } from "matrix-js-sdk/lib/types.js"; import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue"; import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime"; import type { PinnedDispatcherPolicy } from "openclaw/plugin-sdk/ssrf-dispatcher"; -import type { SsrFPolicy } from "../../runtime-api.js"; +import type { SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime"; import { SqliteBackedMatrixSyncStore } from "../client/file-sync-store.js"; import { createMatrixJsSdkClientLogger } from "../client/logging.js"; import { createMatrixStartupAbortError, throwIfMatrixStartupAborted } from "../startup-abort.js"; diff --git a/extensions/matrix/src/matrix/sdk/http-client.ts b/extensions/matrix/src/matrix/sdk/http-client.ts index 0f7b8c05920a..a650f6ebc432 100644 --- a/extensions/matrix/src/matrix/sdk/http-client.ts +++ b/extensions/matrix/src/matrix/sdk/http-client.ts @@ -1,6 +1,6 @@ // Matrix plugin module implements http client behavior. import type { PinnedDispatcherPolicy } from "openclaw/plugin-sdk/ssrf-dispatcher"; -import type { SsrFPolicy } from "../../runtime-api.js"; +import type { SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime"; import { buildHttpError } from "./event-helpers.js"; import { type HttpMethod, type QueryParams, performMatrixRequest } from "./transport.js"; diff --git a/extensions/matrix/src/matrix/send.ts b/extensions/matrix/src/matrix/send.ts index 4769b6f16e4a..321f2ab6dc3f 100644 --- a/extensions/matrix/src/matrix/send.ts +++ b/extensions/matrix/src/matrix/send.ts @@ -4,7 +4,7 @@ import { type MessageReceiptPartKind, } from "openclaw/plugin-sdk/channel-outbound"; import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime"; -import type { PollInput } from "../runtime-api.js"; +import type { PollInput } from "openclaw/plugin-sdk/poll-runtime"; import type { CoreConfig } from "../types.js"; import { createMatrixPlannedEvents, diff --git a/extensions/matrix/src/onboarding.ts b/extensions/matrix/src/onboarding.ts index 6ade510c123b..5c9dfa4aca56 100644 --- a/extensions/matrix/src/onboarding.ts +++ b/extensions/matrix/src/onboarding.ts @@ -1,5 +1,6 @@ // Matrix setup module handles plugin onboarding behavior. import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id"; +import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime"; import { type ChannelSetupWizardAdapter, formatDocsLink, @@ -9,6 +10,7 @@ import { promptAccountId, promptChannelAccessConfig, splitSetupEntries, + type WizardPrompter, } from "openclaw/plugin-sdk/setup"; import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-policy"; import { @@ -33,7 +35,6 @@ import { import { updateMatrixAccountConfig } from "./matrix/config-update.js"; import { ensureMatrixSdkInstalled, isMatrixSdkAvailable } from "./matrix/deps.js"; import { isMatrixRoomId } from "./matrix/target-ids.js"; -import type { RuntimeEnv, WizardPrompter } from "./runtime-api.js"; import { moveSingleMatrixAccountConfigToNamedAccount } from "./setup-config.js"; import { createMatrixSetupDmPolicy } from "./setup-dm-policy.js"; import type { CoreConfig, MatrixConfig } from "./types.js"; diff --git a/extensions/matrix/src/outbound.ts b/extensions/matrix/src/outbound.ts index 74ba74670c08..fa75bd068075 100644 --- a/extensions/matrix/src/outbound.ts +++ b/extensions/matrix/src/outbound.ts @@ -1,7 +1,9 @@ +import type { ChannelOutboundAdapter } from "openclaw/plugin-sdk/channel-contract"; // Matrix plugin module implements outbound behavior. import { createMessageReceiptFromOutboundResults, createReplyToFanout, + resolveOutboundSendDep, } from "openclaw/plugin-sdk/channel-outbound"; import { attachChannelToResult } from "openclaw/plugin-sdk/channel-send-result"; import { @@ -14,13 +16,9 @@ import { } from "openclaw/plugin-sdk/reply-payload"; import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime"; import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime"; +import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking"; import { sendMessageMatrix, sendPollMatrix } from "./matrix/send.js"; import type { MatrixExtraContentFields } from "./matrix/send/types.js"; -import { - chunkTextForOutbound, - resolveOutboundSendDep, - type ChannelOutboundAdapter, -} from "./runtime-api.js"; const MATRIX_OPENCLAW_PRESENTATION_KEY = "com.openclaw.presentation" as const; const MATRIX_OPENCLAW_PRESENTATION_TYPE = "message.presentation" as const; diff --git a/extensions/matrix/src/plugin-entry.runtime.js b/extensions/matrix/src/plugin-entry.runtime.js deleted file mode 100644 index 9c54880f5931..000000000000 --- a/extensions/matrix/src/plugin-entry.runtime.js +++ /dev/null @@ -1,115 +0,0 @@ -// Thin ESM wrapper so native dynamic import() resolves in source-checkout mode -// while packaged dist builds resolve a distinct runtime entry that cannot loop -// back into this wrapper through the stable root runtime alias. -import fs from "node:fs"; -import path from "node:path"; -import { fileURLToPath, pathToFileURL } from "node:url"; - -const PLUGIN_ID = "matrix"; -const PLUGIN_ENTRY_RUNTIME_BASENAME = "plugin-entry.handlers.runtime"; -const NATIVE_RUNTIME_EXTENSIONS = [".js", ".mjs", ".cjs"]; - -function readPackageJson(packageRoot) { - try { - return JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8")); - } catch { - return null; - } -} - -function lowercaseStringOrEmptyWithoutTrim(value) { - return typeof value === "string" ? value.toLowerCase() : ""; -} - -function hasTrustedOpenClawRootIndicator(packageRoot, packageJson) { - const packageExports = packageJson?.exports ?? {}; - if (!Object.hasOwn(packageExports, "./plugin-sdk/core")) { - return false; - } - const hasCliEntryExport = Object.hasOwn(packageExports, "./cli-entry"); - const hasOpenClawBin = - (typeof packageJson?.bin === "string" && - lowercaseStringOrEmptyWithoutTrim(packageJson.bin).includes("openclaw")) || - (typeof packageJson?.bin === "object" && - packageJson.bin !== null && - typeof packageJson.bin.openclaw === "string"); - const hasOpenClawEntrypoint = fs.existsSync(path.join(packageRoot, "openclaw.mjs")); - return hasCliEntryExport || hasOpenClawBin || hasOpenClawEntrypoint; -} - -function findOpenClawPackageRoot(startDir) { - let cursor = path.resolve(startDir); - for (let i = 0; i < 12; i += 1) { - const pkg = readPackageJson(cursor); - if (pkg?.name === "openclaw" && hasTrustedOpenClawRootIndicator(cursor, pkg)) { - return { packageRoot: cursor, packageJson: pkg }; - } - const parent = path.dirname(cursor); - if (parent === cursor) { - break; - } - cursor = parent; - } - return null; -} - -function resolveExistingFile(basePath, extensions) { - for (const ext of extensions) { - const candidate = `${basePath}${ext}`; - if (fs.existsSync(candidate)) { - return candidate; - } - } - return null; -} - -function resolveBundledPluginRuntimeModulePath(moduleUrl, params) { - const modulePath = fileURLToPath(moduleUrl); - const moduleDir = path.dirname(modulePath); - const localCandidates = [ - path.join(moduleDir, "..", params.runtimeBasename), - path.join(moduleDir, "extensions", params.pluginId, params.runtimeBasename), - ]; - - for (const candidate of localCandidates) { - const resolved = resolveExistingFile(candidate, NATIVE_RUNTIME_EXTENSIONS); - if (resolved) { - return resolved; - } - } - - const location = findOpenClawPackageRoot(moduleDir); - if (location) { - const { packageRoot } = location; - const packageCandidates = [ - path.join(packageRoot, "extensions", params.pluginId, params.runtimeBasename), - path.join(packageRoot, "dist", "extensions", params.pluginId, params.runtimeBasename), - ]; - - for (const candidate of packageCandidates) { - const resolved = resolveExistingFile(candidate, NATIVE_RUNTIME_EXTENSIONS); - if (resolved) { - return resolved; - } - } - } - - throw new Error( - `Cannot resolve ${params.pluginId} plugin runtime module ${params.runtimeBasename} from ${modulePath}`, - ); -} - -async function loadRuntimeModule(modulePath) { - return import(pathToFileURL(modulePath).href); -} - -const mod = await loadRuntimeModule( - resolveBundledPluginRuntimeModulePath(import.meta.url, { - pluginId: PLUGIN_ID, - runtimeBasename: PLUGIN_ENTRY_RUNTIME_BASENAME, - }), -); -export const ensureMatrixCryptoRuntime = mod.ensureMatrixCryptoRuntime; -export const handleVerifyRecoveryKey = mod.handleVerifyRecoveryKey; -export const handleVerificationBootstrap = mod.handleVerificationBootstrap; -export const handleVerificationStatus = mod.handleVerificationStatus; diff --git a/extensions/matrix/src/plugin-entry.runtime.test.ts b/extensions/matrix/src/plugin-entry.runtime.test.ts deleted file mode 100644 index b90b0421d0be..000000000000 --- a/extensions/matrix/src/plugin-entry.runtime.test.ts +++ /dev/null @@ -1,135 +0,0 @@ -// Matrix tests cover plugin entry plugin behavior. -import fs from "node:fs"; -import os from "node:os"; -import path from "node:path"; -import { pathToFileURL } from "node:url"; -import { afterEach, expect, it } from "vitest"; - -const tempDirs: string[] = []; -const REPO_ROOT = process.cwd(); -const MATRIX_RUNTIME_WRAPPER_SOURCE = fs.readFileSync( - path.join(REPO_ROOT, "extensions", "matrix", "src", "plugin-entry.runtime.js"), - "utf8", -); -const PACKAGED_RUNTIME_STUB = [ - "export async function ensureMatrixCryptoRuntime() {}", - "export async function handleVerifyRecoveryKey() {}", - "export async function handleVerificationBootstrap() {}", - "export async function handleVerificationStatus() {}", - "", -].join("\n"); - -function makeFixtureRoot(prefix: string) { - const fixtureRoot = fs.mkdtempSync(path.join(os.tmpdir(), prefix)); - tempDirs.push(fixtureRoot); - return fixtureRoot; -} - -function writeFixtureFile(fixtureRoot: string, relativePath: string, value: string) { - const fullPath = path.join(fixtureRoot, relativePath); - fs.mkdirSync(path.dirname(fullPath), { recursive: true }); - fs.writeFileSync(fullPath, value, "utf8"); -} - -function writeOpenClawPackageFixture(fixtureRoot: string) { - writeFixtureFile( - fixtureRoot, - "package.json", - JSON.stringify( - { - name: "openclaw", - type: "module", - exports: { - "./plugin-sdk/core": "./dist/plugin-sdk/core.js", - }, - }, - null, - 2, - ) + "\n", - ); - writeFixtureFile(fixtureRoot, "openclaw.mjs", "export {};\n"); - writeFixtureFile(fixtureRoot, "dist/plugin-sdk/core.js", "export {};\n"); -} - -function writeSourceRuntimeWrapperFixture( - fixtureRoot: string, - options: { runtimeExtension?: ".js" | ".ts" } = {}, -) { - const runtimeExtension = options.runtimeExtension ?? ".js"; - writeFixtureFile( - fixtureRoot, - "extensions/matrix/src/plugin-entry.runtime.js", - MATRIX_RUNTIME_WRAPPER_SOURCE, - ); - writeFixtureFile( - fixtureRoot, - `extensions/matrix/plugin-entry.handlers.runtime${runtimeExtension}`, - PACKAGED_RUNTIME_STUB, - ); -} - -function importFixtureModule(fixtureRoot: string, relativePath: string) { - const wrapperUrl = pathToFileURL(path.join(fixtureRoot, relativePath)); - return import(`${wrapperUrl.href}?t=${Date.now()}`); -} - -function expectRuntimeWrapperExports(mod: unknown) { - const exports = mod as Record; - expect(exports.ensureMatrixCryptoRuntime).toBeTypeOf("function"); - expect(exports.handleVerifyRecoveryKey).toBeTypeOf("function"); - expect(exports.handleVerificationBootstrap).toBeTypeOf("function"); - expect(exports.handleVerificationStatus).toBeTypeOf("function"); -} - -afterEach(() => { - for (const dir of tempDirs.splice(0)) { - fs.rmSync(dir, { recursive: true, force: true }); - } -}); - -it("loads the source-checkout runtime wrapper through native ESM import", async () => { - const fixtureRoot = makeFixtureRoot(".tmp-matrix-source-runtime-"); - - writeOpenClawPackageFixture(fixtureRoot); - writeSourceRuntimeWrapperFixture(fixtureRoot); - - expectRuntimeWrapperExports( - await importFixtureModule(fixtureRoot, "extensions/matrix/src/plugin-entry.runtime.js"), - ); -}, 240_000); - -it("loads the packaged runtime wrapper without recursing through the stable root alias", async () => { - const fixtureRoot = makeFixtureRoot(".tmp-matrix-runtime-"); - - writeOpenClawPackageFixture(fixtureRoot); - writeFixtureFile( - fixtureRoot, - "dist/plugin-entry.runtime-C88YIa_v.js", - MATRIX_RUNTIME_WRAPPER_SOURCE, - ); - writeFixtureFile( - fixtureRoot, - "dist/plugin-entry.runtime.js", - 'export * from "./plugin-entry.runtime-C88YIa_v.js";\n', - ); - writeFixtureFile( - fixtureRoot, - "dist/extensions/matrix/plugin-entry.handlers.runtime.js", - PACKAGED_RUNTIME_STUB, - ); - - expectRuntimeWrapperExports( - await importFixtureModule(fixtureRoot, "dist/plugin-entry.runtime-C88YIa_v.js"), - ); -}, 240_000); - -it("does not load when only a TypeScript Matrix runtime shim exists", async () => { - const fixtureRoot = makeFixtureRoot(".tmp-matrix-runtime-ts-only-"); - - writeOpenClawPackageFixture(fixtureRoot); - writeSourceRuntimeWrapperFixture(fixtureRoot, { runtimeExtension: ".ts" }); - - await expect( - importFixtureModule(fixtureRoot, "extensions/matrix/src/plugin-entry.runtime.js"), - ).rejects.toThrow("Cannot resolve matrix plugin runtime module plugin-entry.handlers.runtime"); -}, 240_000); diff --git a/extensions/matrix/src/resolve-targets.ts b/extensions/matrix/src/resolve-targets.ts index ef2ef3387070..f313a69d8ec9 100644 --- a/extensions/matrix/src/resolve-targets.ts +++ b/extensions/matrix/src/resolve-targets.ts @@ -1,13 +1,13 @@ -// Matrix plugin module implements resolve targets behavior. -import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime"; -import { listMatrixDirectoryGroupsLive, listMatrixDirectoryPeersLive } from "./directory-live.js"; -import { isMatrixQualifiedUserId, normalizeMatrixMessagingTarget } from "./matrix/target-ids.js"; import type { ChannelDirectoryEntry, ChannelResolveKind, ChannelResolveResult, - RuntimeEnv, -} from "./runtime-api.js"; +} from "openclaw/plugin-sdk/channel-contract"; +import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime"; +// Matrix plugin module implements resolve targets behavior. +import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime"; +import { listMatrixDirectoryGroupsLive, listMatrixDirectoryPeersLive } from "./directory-live.js"; +import { isMatrixQualifiedUserId, normalizeMatrixMessagingTarget } from "./matrix/target-ids.js"; function normalizeLookupQuery(query: string): string { return normalizeOptionalLowercaseString(query) ?? ""; diff --git a/extensions/matrix/src/runtime-api.ts b/extensions/matrix/src/runtime-api.ts deleted file mode 100644 index e4c479b422a5..000000000000 --- a/extensions/matrix/src/runtime-api.ts +++ /dev/null @@ -1,107 +0,0 @@ -// Matrix API module exposes the plugin public contract. -export { - DEFAULT_ACCOUNT_ID, - normalizeAccountId, - normalizeOptionalAccountId, -} from "openclaw/plugin-sdk/account-id"; -export { - createActionGate, - jsonResult, - readNumberParam, - readPositiveIntegerParam, - readReactionParams, - readStringArrayParam, - readStringParam, - ToolAuthorizationError, -} from "openclaw/plugin-sdk/channel-actions"; -export { buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema"; -export type { ChannelPlugin } from "openclaw/plugin-sdk/channel-core"; -export type { - BaseProbeResult, - ChannelDirectoryEntry, - ChannelGroupContext, - ChannelMessageActionAdapter, - ChannelMessageActionContext, - ChannelMessageActionName, - ChannelMessageToolDiscovery, - ChannelOutboundAdapter, - ChannelResolveKind, - ChannelResolveResult, - ChannelToolSend, -} from "openclaw/plugin-sdk/channel-contract"; -export { - formatLocationText, - toLocationContext, - type NormalizedLocation, -} from "openclaw/plugin-sdk/channel-inbound"; -export { logInboundDrop } from "openclaw/plugin-sdk/channel-inbound"; -export { logTypingFailure } from "openclaw/plugin-sdk/channel-outbound"; -export { resolveAckReaction } from "openclaw/plugin-sdk/channel-feedback"; -export type { ChannelSetupInput } from "openclaw/plugin-sdk/setup"; -export type { - OpenClawConfig, - ContextVisibilityMode, - DmPolicy, - GroupPolicy, -} from "openclaw/plugin-sdk/config-contracts"; -export type { GroupToolPolicyConfig } from "openclaw/plugin-sdk/config-contracts"; -export type { WizardPrompter } from "openclaw/plugin-sdk/setup"; -export type { SecretInput } from "openclaw/plugin-sdk/secret-input"; -export { - GROUP_POLICY_BLOCKED_LABEL, - resolveAllowlistProviderRuntimeGroupPolicy, - resolveDefaultGroupPolicy, - warnMissingProviderGroupPolicyFallbackOnce, -} from "openclaw/plugin-sdk/runtime-group-policy"; -export { - addWildcardAllowFrom, - formatDocsLink, - hasConfiguredSecretInput, - mergeAllowFromEntries, - moveSingleAccountChannelSectionToDefaultAccount, - promptAccountId, - promptChannelAccessConfig, - splitSetupEntries, -} from "openclaw/plugin-sdk/setup"; -export type { RuntimeEnv } from "openclaw/plugin-sdk/runtime"; -export { - assertHttpUrlTargetsPrivateNetwork, - closeDispatcher, - createPinnedDispatcher, - isPrivateOrLoopbackHost, - resolvePinnedHostnameWithPolicy, - ssrfPolicyFromDangerouslyAllowPrivateNetwork, - type LookupFn, - type SsrFPolicy, -} from "openclaw/plugin-sdk/ssrf-runtime"; -export { - ensureConfiguredAcpBindingReady, - resolveConfiguredAcpBindingRecord, -} from "openclaw/plugin-sdk/acp-binding-runtime"; -export { - buildProbeChannelStatusSummary, - collectStatusIssuesFromLastError, - PAIRING_APPROVED_MESSAGE, -} from "openclaw/plugin-sdk/channel-status"; -export { - getSessionBindingService, - resolveThreadBindingIdleTimeoutMsForChannel, - resolveThreadBindingMaxAgeMsForChannel, -} from "openclaw/plugin-sdk/conversation-runtime"; -export { resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound"; -export { resolveAgentIdFromSessionKey } from "openclaw/plugin-sdk/routing"; -export { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking"; -export { createChannelMessageReplyPipeline } from "openclaw/plugin-sdk/channel-outbound"; -export { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media"; -export { normalizePollInput, type PollInput } from "openclaw/plugin-sdk/poll-runtime"; -export { writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store"; -export { - buildChannelKeyCandidates, - resolveChannelEntryMatch, -} from "openclaw/plugin-sdk/channel-targets"; -export { buildTimeoutAbortSignal } from "./matrix/sdk/timeout-abort-signal.js"; -export { formatZonedTimestamp } from "openclaw/plugin-sdk/time-runtime"; -export type { PluginRuntime, RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime"; -export type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime"; -// resolveMatrixAccountStringValues already comes from the Matrix API barrel. -// Re-exporting auth-precedence here makes TS source loaders define the export twice. diff --git a/extensions/matrix/src/runtime.ts b/extensions/matrix/src/runtime.ts index 86ddcdffb997..fd42d381865a 100644 --- a/extensions/matrix/src/runtime.ts +++ b/extensions/matrix/src/runtime.ts @@ -1,6 +1,6 @@ +import type { PluginRuntime } from "openclaw/plugin-sdk/plugin-runtime"; // Matrix plugin module implements runtime behavior. import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store"; -import type { PluginRuntime } from "./runtime-api.js"; const { setRuntime: setMatrixRuntime, diff --git a/extensions/matrix/src/session-route.test.ts b/extensions/matrix/src/session-route.test.ts index 1d8dcca9e88d..20acd633ca90 100644 --- a/extensions/matrix/src/session-route.test.ts +++ b/extensions/matrix/src/session-route.test.ts @@ -2,13 +2,13 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts"; import { normalizeSessionDeliveryState, upsertSessionEntry, } from "openclaw/plugin-sdk/session-store-runtime"; import type { SessionEntry } from "openclaw/plugin-sdk/session-store-runtime"; import { afterEach, describe, expect, it } from "vitest"; -import type { OpenClawConfig } from "./runtime-api.js"; import { resolveMatrixOutboundSessionRoute } from "./session-route.js"; const tempDirs = new Set(); diff --git a/extensions/matrix/src/setup-bootstrap.ts b/extensions/matrix/src/setup-bootstrap.ts index 15f27903b8b5..8450c5f05d8d 100644 --- a/extensions/matrix/src/setup-bootstrap.ts +++ b/extensions/matrix/src/setup-bootstrap.ts @@ -1,9 +1,9 @@ import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; +import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime"; // Matrix plugin module implements setup bootstrap behavior. import { hasExplicitMatrixAccountConfig } from "./matrix/account-config.js"; import { resolveMatrixAccountConfig } from "./matrix/accounts.js"; import { bootstrapMatrixVerification } from "./matrix/actions/verification.js"; -import type { RuntimeEnv } from "./runtime-api.js"; import type { CoreConfig } from "./types.js"; type MatrixSetupVerificationBootstrapResult = { diff --git a/extensions/matrix/src/test-runtime.ts b/extensions/matrix/src/test-runtime.ts index d8b8d63e0597..2cbb622ea999 100644 --- a/extensions/matrix/src/test-runtime.ts +++ b/extensions/matrix/src/test-runtime.ts @@ -5,6 +5,7 @@ import { implicitMentionKindWhen, resolveInboundMentionDecision, } from "openclaw/plugin-sdk/channel-mention-gating"; +import type { PluginRuntime } from "openclaw/plugin-sdk/plugin-runtime"; import type { OpenBlobStoreOptions, OpenKeyedStoreOptions, @@ -17,7 +18,6 @@ import { } from "openclaw/plugin-sdk/plugin-state-test-runtime"; import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path"; import { afterAll, vi } from "vitest"; -import type { PluginRuntime } from "./runtime-api.js"; import { setMatrixRuntime } from "./runtime.js"; const defaultStateDir = fs.realpathSync( diff --git a/extensions/matrix/src/tool-actions.ts b/extensions/matrix/src/tool-actions.ts index 13ea3f757730..ec40a384e56c 100644 --- a/extensions/matrix/src/tool-actions.ts +++ b/extensions/matrix/src/tool-actions.ts @@ -1,5 +1,13 @@ // Matrix plugin module implements tool actions behavior. import type { AgentToolResult } from "openclaw/plugin-sdk/agent-core"; +import { + createActionGate, + jsonResult, + readPositiveIntegerParam, + readReactionParams, + readStringArrayParam, + readStringParam, +} from "openclaw/plugin-sdk/channel-actions"; import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime"; import { resolveMatrixAccountConfig } from "./matrix/accounts.js"; import { @@ -39,14 +47,6 @@ import { withAuthorizedMatrixReadTarget, type MatrixReadContext } from "./matrix import type { MatrixClient } from "./matrix/sdk.js"; import { reactMatrixMessage } from "./matrix/send.js"; import { applyMatrixProfileUpdate } from "./profile-update.js"; -import { - createActionGate, - jsonResult, - readPositiveIntegerParam, - readReactionParams, - readStringArrayParam, - readStringParam, -} from "./runtime-api.js"; import type { CoreConfig } from "./types.js"; const messageActions = new Set(["sendMessage", "editMessage", "deleteMessage", "readMessages"]); diff --git a/extensions/matrix/src/types.ts b/extensions/matrix/src/types.ts index 3654b5ee7181..547f97c1994b 100644 --- a/extensions/matrix/src/types.ts +++ b/extensions/matrix/src/types.ts @@ -1,15 +1,13 @@ // Matrix type declarations define plugin contracts. import type { ChannelBotLoopProtectionConfig, - MentionPatternsPolicyConfig, -} from "openclaw/plugin-sdk/config-contracts"; -import type { ContextVisibilityMode, DmPolicy, GroupPolicy, + MentionPatternsPolicyConfig, OpenClawConfig, - SecretInput, -} from "./runtime-api.js"; +} from "openclaw/plugin-sdk/config-contracts"; +import type { SecretInput } from "openclaw/plugin-sdk/secret-input"; export type ReplyToMode = "off" | "first" | "all" | "batched"; diff --git a/src/channels/plugins/bundled.shape-guard.test.ts b/src/channels/plugins/bundled.shape-guard.test.ts index 011de067aa0d..6763acd424f6 100644 --- a/src/channels/plugins/bundled.shape-guard.test.ts +++ b/src/channels/plugins/bundled.shape-guard.test.ts @@ -1103,10 +1103,7 @@ describe("bundled channel entry shape guards", () => { }); it("keeps bundled hot runtime barrels off the broad core SDK surface", () => { - const offenders = [ - "extensions/googlechat/runtime-api.ts", - "extensions/matrix/src/runtime-api.ts", - ].filter((filePath) => + const offenders = ["extensions/googlechat/runtime-api.ts"].filter((filePath) => fs.readFileSync(path.resolve(filePath), "utf8").includes("openclaw/plugin-sdk/core"), ); diff --git a/test/scripts/check-deadcode-exports.test.ts b/test/scripts/check-deadcode-exports.test.ts index b51624e24b7f..70c847fc086c 100644 --- a/test/scripts/check-deadcode-exports.test.ts +++ b/test/scripts/check-deadcode-exports.test.ts @@ -241,9 +241,6 @@ describe("check-deadcode-exports", () => { ]), ); expect(knipConfig.workspaces["extensions/diffs"].entry).toContain("src/viewer-client.ts!"); - expect(knipConfig.workspaces["extensions/matrix"].entry).toContain( - "src/plugin-entry.runtime.js!", - ); expect(knipConfig.workspaces["extensions/mxc"].entry).toContain("src/mxc-spawn-launcher.mjs!"); expect(knipConfig.workspaces["extensions/qa-lab"].entry).toContain("src/ci-smoke-plan.ts!"); });