@thclouds/openclaw-channel-taidesk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +21 -7
- package/openclaw.plugin.json +7 -3
- package/package.json +5 -5
- package/src/channel.ts +9 -3
- package/src/compat.ts +51 -0
- package/setup-entry.ts +0 -5
package/index.ts
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
|
|
2
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
|
|
2
3
|
|
|
3
4
|
import { taideskPlugin } from "./src/channel.js";
|
|
5
|
+
import { assertHostCompatibility } from "./src/compat.js";
|
|
6
|
+
import { TaideskChannelConfigSchema } from "./src/config-schema.js";
|
|
4
7
|
import { setTaideskRuntime } from "./src/runtime.js";
|
|
5
8
|
|
|
6
9
|
export { taideskPlugin, setTaideskRuntime };
|
|
7
10
|
|
|
8
|
-
export default
|
|
11
|
+
export default {
|
|
9
12
|
id: "taidesk",
|
|
10
|
-
name: "Taidesk
|
|
11
|
-
description: "Taidesk
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
name: "Taidesk",
|
|
14
|
+
description: "Taidesk channel (MQTT inbound + HTTP webhook outbound)",
|
|
15
|
+
configSchema: buildChannelConfigSchema(TaideskChannelConfigSchema),
|
|
16
|
+
register(api: OpenClawPluginApi) {
|
|
17
|
+
assertHostCompatibility(api.runtime?.version);
|
|
18
|
+
|
|
19
|
+
if (api.runtime) {
|
|
20
|
+
setTaideskRuntime(api.runtime);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
api.registerChannel({ plugin: taideskPlugin });
|
|
24
|
+
|
|
25
|
+
const mode = (api as { registrationMode?: string }).registrationMode;
|
|
26
|
+
if (mode && mode !== "full") return;
|
|
27
|
+
},
|
|
28
|
+
};
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "taidesk",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"channels": ["taidesk"],
|
|
5
|
+
"configSchema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {}
|
|
9
|
+
}
|
|
6
10
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thclouds/openclaw-channel-taidesk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "OpenClaw Taidesk channel plugin (MQTT inbound + HTTP outbound)",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"author": "thclouds",
|
|
6
7
|
"type": "module",
|
|
7
|
-
"main": "index.ts",
|
|
8
8
|
"files": [
|
|
9
|
+
"src/",
|
|
9
10
|
"index.ts",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"openclaw.plugin.json"
|
|
11
|
+
"openclaw.plugin.json",
|
|
12
|
+
"README.md"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"type-check": "tsc -p tsconfig.json --noEmit",
|
package/src/channel.ts
CHANGED
|
@@ -2,9 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
|
|
3
3
|
import type { ChannelGatewayContext, ChannelPlugin } from "openclaw/plugin-sdk";
|
|
4
4
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/core";
|
|
5
|
-
import { buildChannelConfigSchema } from "openclaw/plugin-sdk/core";
|
|
6
5
|
|
|
7
|
-
import { TaideskChannelConfigSchema } from "./config-schema.js";
|
|
8
6
|
import {
|
|
9
7
|
applyTaideskAccountDefaults,
|
|
10
8
|
getTaideskConfig,
|
|
@@ -40,9 +38,17 @@ export const taideskPlugin: ChannelPlugin<ResolvedTaideskAccount> = {
|
|
|
40
38
|
label: "Taidesk",
|
|
41
39
|
selectionLabel: "Taidesk (MQTT)",
|
|
42
40
|
docsPath: "/channels/taidesk",
|
|
41
|
+
docsLabel: "Taidesk",
|
|
43
42
|
blurb: "Taidesk:MQTT 入站 `/open/{agentId}` + HTTP 出站",
|
|
43
|
+
order: 76,
|
|
44
|
+
},
|
|
45
|
+
configSchema: {
|
|
46
|
+
schema: {
|
|
47
|
+
type: "object",
|
|
48
|
+
additionalProperties: false,
|
|
49
|
+
properties: {},
|
|
50
|
+
},
|
|
44
51
|
},
|
|
45
|
-
configSchema: buildChannelConfigSchema(TaideskChannelConfigSchema),
|
|
46
52
|
reload: { configPrefixes: ["channels.taidesk"] },
|
|
47
53
|
capabilities: {
|
|
48
54
|
chatTypes: ["direct"],
|
package/src/compat.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw 宿主版本校验(日期版本 YYYY.M.DD,如 2026.3.22)。
|
|
3
|
+
* 对齐微信插件 openclaw-weixin 的 compat 行为,避免在过低版本主机上误加载。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const PLUGIN_VERSION = "0.1.1";
|
|
7
|
+
|
|
8
|
+
export const SUPPORTED_HOST_MIN = "2026.3.22";
|
|
9
|
+
|
|
10
|
+
export interface OpenClawVersion {
|
|
11
|
+
year: number;
|
|
12
|
+
month: number;
|
|
13
|
+
day: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function parseOpenClawVersion(version: string): OpenClawVersion | null {
|
|
17
|
+
const base = version.trim().split("-")[0];
|
|
18
|
+
const parts = base.split(".");
|
|
19
|
+
if (parts.length !== 3) return null;
|
|
20
|
+
const [year, month, day] = parts.map(Number);
|
|
21
|
+
if (Number.isNaN(year) || Number.isNaN(month) || Number.isNaN(day)) return null;
|
|
22
|
+
return { year, month, day };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function compareVersions(a: OpenClawVersion, b: OpenClawVersion): -1 | 0 | 1 {
|
|
26
|
+
for (const key of ["year", "month", "day"] as const) {
|
|
27
|
+
if (a[key] < b[key]) return -1;
|
|
28
|
+
if (a[key] > b[key]) return 1;
|
|
29
|
+
}
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isHostVersionSupported(hostVersion: string): boolean {
|
|
34
|
+
const host = parseOpenClawVersion(hostVersion);
|
|
35
|
+
if (!host) return false;
|
|
36
|
+
const min = parseOpenClawVersion(SUPPORTED_HOST_MIN)!;
|
|
37
|
+
return compareVersions(host, min) >= 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function assertHostCompatibility(hostVersion: string | undefined): void {
|
|
41
|
+
if (!hostVersion || hostVersion === "unknown") {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (isHostVersionSupported(hostVersion)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
throw new Error(
|
|
48
|
+
`@thclouds/openclaw-channel-taidesk@${PLUGIN_VERSION} requires OpenClaw >=${SUPPORTED_HOST_MIN}, ` +
|
|
49
|
+
`but found ${hostVersion}. Please upgrade OpenClaw.`,
|
|
50
|
+
);
|
|
51
|
+
}
|