diff --git a/extensions/line/index.test.ts b/extensions/line/index.test.ts new file mode 100644 index 00000000000..7687e4a6f2c --- /dev/null +++ b/extensions/line/index.test.ts @@ -0,0 +1,24 @@ +import path from "node:path"; +import { createJiti } from "jiti"; +import { describe, expect, it } from "vitest"; +import { + buildPluginLoaderJitiOptions, + resolvePluginSdkScopedAliasMap, +} from "../../src/plugins/sdk-alias.ts"; + +describe("line runtime api", () => { + it("loads the line runtime api through Jiti", () => { + const runtimeApiPath = path.join(process.cwd(), "extensions", "line", "runtime-api.ts"); + const jiti = createJiti(import.meta.url, { + ...buildPluginLoaderJitiOptions( + resolvePluginSdkScopedAliasMap({ modulePath: runtimeApiPath }), + ), + tryNative: false, + }); + + expect(jiti(runtimeApiPath)).toMatchObject({ + resolveLineAccount: expect.any(Function), + formatDocsLink: expect.any(Function), + }); + }); +}); diff --git a/extensions/line/runtime-api.ts b/extensions/line/runtime-api.ts index 53f1be0c51c..175c145b61f 100644 --- a/extensions/line/runtime-api.ts +++ b/extensions/line/runtime-api.ts @@ -1,12 +1,44 @@ // Private runtime barrel for the bundled LINE extension. // Keep this barrel thin and aligned with the local extension surface. +// Do not re-export ../../src/plugin-sdk/line here: that public barrel also +// re-exports setup-api, which creates a cycle for local line imports. -export * from "../../src/plugin-sdk/line.js"; -export { resolveExactLineGroupConfigKey } from "../../src/plugin-sdk/line-core.js"; +export type { + ChannelAccountSnapshot, + ChannelGatewayContext, + ChannelStatusIssue, + ChannelPlugin, + OpenClawConfig, + ReplyPayload, + OpenClawPluginApi, + PluginRuntime, + LineChannelData, + LineConfig, + ResolvedLineAccount, + CardAction, + ListItem, + ChannelSetupDmPolicy, + ChannelSetupWizard, +} from "../../src/plugin-sdk/line-core.js"; export { + DEFAULT_ACCOUNT_ID, + buildChannelConfigSchema, + buildComputedAccountStatusSnapshot, + buildTokenChannelStatusSummary, + clearAccountEntryFields, + createActionCard, + createImageCard, + createInfoCard, + createListCard, + createReceiptCard, formatDocsLink, + LineConfigSchema, + listLineAccountIds, + normalizeAccountId, + processLineMessage, + resolveDefaultLineAccountId, + resolveLineAccount, + resolveExactLineGroupConfigKey, setSetupChannelEnabled, splitSetupEntries, - type ChannelSetupDmPolicy, - type ChannelSetupWizard, } from "../../src/plugin-sdk/line-core.js"; diff --git a/extensions/line/src/channel.logout.test.ts b/extensions/line/src/channel.logout.test.ts index 0b3dd9a9517..f07fddfb87e 100644 --- a/extensions/line/src/channel.logout.test.ts +++ b/extensions/line/src/channel.logout.test.ts @@ -1,6 +1,8 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; +import type { OpenClawConfig } from "../../../src/config/config.js"; +import type { ResolvedLineAccount } from "../../../src/line/types.js"; +import type { PluginRuntime } from "../../../src/plugins/runtime/types.js"; import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; -import type { OpenClawConfig, PluginRuntime, ResolvedLineAccount } from "../api.js"; import { linePlugin } from "./channel.js"; import { setLineRuntime } from "./runtime.js"; diff --git a/extensions/line/src/channel.sendPayload.test.ts b/extensions/line/src/channel.sendPayload.test.ts index 470b582dfc6..4a80e61dc6b 100644 --- a/extensions/line/src/channel.sendPayload.test.ts +++ b/extensions/line/src/channel.sendPayload.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig, PluginRuntime } from "../api.js"; +import type { OpenClawConfig } from "../../../src/config/config.js"; +import type { PluginRuntime } from "../../../src/plugins/runtime/types.js"; import { linePlugin } from "./channel.js"; import { setLineRuntime } from "./runtime.js"; diff --git a/extensions/line/src/channel.startup.test.ts b/extensions/line/src/channel.startup.test.ts index 000b94ee471..73e82965f47 100644 --- a/extensions/line/src/channel.startup.test.ts +++ b/extensions/line/src/channel.startup.test.ts @@ -1,12 +1,12 @@ import { describe, expect, it, vi } from "vitest"; -import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; import type { - ChannelGatewayContext, ChannelAccountSnapshot, - OpenClawConfig, - PluginRuntime, - ResolvedLineAccount, -} from "../api.js"; + ChannelGatewayContext, +} from "../../../src/channels/plugins/types.js"; +import type { OpenClawConfig } from "../../../src/config/config.js"; +import type { ResolvedLineAccount } from "../../../src/line/types.js"; +import type { PluginRuntime } from "../../../src/plugins/runtime/types.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; import { linePlugin } from "./channel.js"; import { setLineRuntime } from "./runtime.js"; diff --git a/extensions/line/src/setup-surface.test.ts b/extensions/line/src/setup-surface.test.ts index b613a16bba4..d5303ef0842 100644 --- a/extensions/line/src/setup-surface.test.ts +++ b/extensions/line/src/setup-surface.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it, vi } from "vitest"; import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js"; +import type { OpenClawConfig } from "../../../src/config/config.js"; import { listLineAccountIds, resolveDefaultLineAccountId, @@ -10,7 +11,6 @@ import { createTestWizardPrompter, type WizardPrompter, } from "../../../test/helpers/extensions/setup-wizard.js"; -import type { OpenClawConfig } from "../api.js"; import { lineSetupAdapter, lineSetupWizard } from "./setup-surface.js"; const lineConfigureAdapter = buildChannelSetupWizardAdapterFromSetupWizard({ diff --git a/src/plugin-sdk/line-core.ts b/src/plugin-sdk/line-core.ts index 04b2950a50d..bb2adcc1181 100644 --- a/src/plugin-sdk/line-core.ts +++ b/src/plugin-sdk/line-core.ts @@ -1,5 +1,14 @@ +export type { + ChannelAccountSnapshot, + ChannelGatewayContext, + ChannelStatusIssue, +} from "../channels/plugins/types.js"; +export type { ChannelPlugin } from "../channels/plugins/types.plugin.js"; export type { OpenClawConfig } from "../config/config.js"; -export type { LineConfig } from "../line/types.js"; +export type { ReplyPayload } from "../auto-reply/types.js"; +export type { OpenClawPluginApi, PluginRuntime } from "./channel-plugin-common.js"; +export type { LineChannelData, LineConfig, ResolvedLineAccount } from "../line/types.js"; +export type { CardAction, ListItem } from "../line/flex-templates.js"; export { createTopLevelChannelDmPolicy, DEFAULT_ACCOUNT_ID, @@ -9,12 +18,25 @@ export { splitSetupEntries, } from "./setup.js"; export type { ChannelSetupAdapter, ChannelSetupDmPolicy, ChannelSetupWizard } from "./setup.js"; +export { buildChannelConfigSchema } from "./channel-plugin-common.js"; +export { + buildComputedAccountStatusSnapshot, + buildTokenChannelStatusSummary, +} from "./status-helpers.js"; +export { clearAccountEntryFields } from "../channels/plugins/config-helpers.js"; export { listLineAccountIds, normalizeAccountId, resolveDefaultLineAccountId, resolveLineAccount, } from "../line/accounts.js"; +export { + createActionCard, + createImageCard, + createInfoCard, + createListCard, + createReceiptCard, +} from "../line/flex-templates.js"; export { resolveExactLineGroupConfigKey } from "../line/group-keys.js"; -export type { ResolvedLineAccount } from "../line/types.js"; export { LineConfigSchema } from "../line/config-schema.js"; +export { processLineMessage } from "../line/markdown-to-line.js"; diff --git a/src/plugin-sdk/runtime-api-guardrails.test.ts b/src/plugin-sdk/runtime-api-guardrails.test.ts index 78a39d7ccb3..de49bb9285c 100644 --- a/src/plugin-sdk/runtime-api-guardrails.test.ts +++ b/src/plugin-sdk/runtime-api-guardrails.test.ts @@ -35,6 +35,10 @@ const RUNTIME_API_EXPORT_GUARDS: Record = { 'export { sendMessageIMessage } from "./src/send.js";', ], "extensions/googlechat/runtime-api.ts": ['export * from "../../src/plugin-sdk/googlechat.js";'], + "extensions/line/runtime-api.ts": [ + 'export type { ChannelAccountSnapshot, ChannelGatewayContext, ChannelStatusIssue, ChannelPlugin, OpenClawConfig, ReplyPayload, OpenClawPluginApi, PluginRuntime, LineChannelData, LineConfig, ResolvedLineAccount, CardAction, ListItem, ChannelSetupDmPolicy, ChannelSetupWizard } from "../../src/plugin-sdk/line-core.js";', + 'export { DEFAULT_ACCOUNT_ID, buildChannelConfigSchema, buildComputedAccountStatusSnapshot, buildTokenChannelStatusSummary, clearAccountEntryFields, createActionCard, createImageCard, createInfoCard, createListCard, createReceiptCard, formatDocsLink, LineConfigSchema, listLineAccountIds, normalizeAccountId, processLineMessage, resolveDefaultLineAccountId, resolveLineAccount, resolveExactLineGroupConfigKey, setSetupChannelEnabled, splitSetupEntries } from "../../src/plugin-sdk/line-core.js";', + ], "extensions/matrix/runtime-api.ts": [ 'export * from "./src/auth-precedence.js";', 'export * from "./helper-api.js";',