openclaw-extension-typex 1.0.19 → 1.0.21

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.
@@ -0,0 +1,24 @@
1
+ type DirectoryEntry = {
2
+ kind: "user" | "group" | "channel";
3
+ id: string;
4
+ name?: string;
5
+ raw?: unknown;
6
+ };
7
+ export declare const typexDirectory: {
8
+ self: () => Promise<null>;
9
+ listPeers: ({ cfg, accountId, query, limit }: any) => Promise<DirectoryEntry[]>;
10
+ listGroups: ({ cfg, accountId, query, limit }: any) => Promise<{
11
+ kind: "group";
12
+ id: string;
13
+ name: string;
14
+ raw: any;
15
+ }[]>;
16
+ listPeersLive: (params: any) => Promise<DirectoryEntry[]>;
17
+ listGroupsLive: (params: any) => Promise<{
18
+ kind: "group";
19
+ id: string;
20
+ name: string;
21
+ raw: any;
22
+ }[]>;
23
+ };
24
+ export {};
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typexDirectory = void 0;
4
+ const account_id_1 = require("openclaw/plugin-sdk/account-id");
5
+ const client_js_1 = require("./client/client.js");
6
+ function normalizeQuery(value) {
7
+ return (value ?? "").trim().toLowerCase();
8
+ }
9
+ function normalizeNameKey(value) {
10
+ return normalizeQuery(value).replace(/\s+/g, "");
11
+ }
12
+ function resolveClient(accountId, cfg) {
13
+ const typexCfg = (cfg.channels?.["openclaw-extension-typex"] ?? {});
14
+ const client = (0, client_js_1.getTypeXClient)(accountId ?? undefined, { typexCfg });
15
+ return { client, typexCfg };
16
+ }
17
+ exports.typexDirectory = {
18
+ self: async () => null,
19
+ listPeers: async ({ cfg, accountId, query, limit }) => {
20
+ const { client, typexCfg } = resolveClient(accountId, cfg);
21
+ const resolvedAccountId = accountId ?? account_id_1.DEFAULT_ACCOUNT_ID;
22
+ const account = typexCfg.accounts?.[resolvedAccountId];
23
+ const allowFrom = account?.allowFrom ?? typexCfg.allowFrom ?? [];
24
+ const q = normalizeQuery(query);
25
+ const max = limit && limit > 0 ? limit : undefined;
26
+ const configPeers = Array.from(new Set(allowFrom
27
+ .map((entry) => String(entry).trim())
28
+ .filter((entry) => entry && entry !== "*")
29
+ .map((entry) => entry.replace(/^typex:/i, ""))))
30
+ .filter((id) => (!q ? true : id.toLowerCase().includes(q)))
31
+ .map((id) => ({ kind: "user", id: `user:${id}`, name: id }));
32
+ if (!q)
33
+ return configPeers.slice(0, max);
34
+ try {
35
+ if (client.mode === "bot")
36
+ return configPeers.slice(0, max);
37
+ const [feeds, contacts] = await Promise.all([
38
+ client.fetchFeedsByName(q),
39
+ client.fetchContactsByName(q),
40
+ ]);
41
+ const contactEntries = contacts.map((contact) => ({
42
+ kind: "user",
43
+ id: `user:${contact.friend_id ?? contact.id}`,
44
+ name: String(contact.name ?? contact.alias ?? contact.friend_id ?? contact.id),
45
+ raw: contact,
46
+ }));
47
+ const seenContactNames = new Set(contactEntries.map((entry) => normalizeNameKey(entry.name)));
48
+ const feedEntries = feeds
49
+ .filter((feed) => {
50
+ const feedName = normalizeNameKey(feed.name ?? "");
51
+ return feed.chat_id && (!feedName || !seenContactNames.has(feedName));
52
+ })
53
+ .map((feed) => ({
54
+ kind: "user",
55
+ id: `chat:${feed.chat_id}`,
56
+ name: String(feed.name ?? feed.chat_id),
57
+ raw: feed,
58
+ }));
59
+ const all = [...configPeers, ...contactEntries, ...feedEntries];
60
+ const unique = Array.from(new Map(all.map((entry) => [entry.id, entry])).values());
61
+ return unique.slice(0, max);
62
+ }
63
+ catch (error) {
64
+ console.error("Failed to fetch peers from TypeX directory", error);
65
+ return configPeers.slice(0, max);
66
+ }
67
+ },
68
+ listGroups: async ({ cfg, accountId, query, limit }) => {
69
+ const { client } = resolveClient(accountId, cfg);
70
+ const q = normalizeQuery(query);
71
+ const max = limit && limit > 0 ? limit : undefined;
72
+ if (!q || client.mode !== "user")
73
+ return [];
74
+ try {
75
+ const feeds = await client.fetchFeedsByName(q);
76
+ const groups = feeds
77
+ .filter((feed) => Boolean(feed.chat_id))
78
+ .map((feed) => ({
79
+ kind: "group",
80
+ id: `chat:${feed.chat_id}`,
81
+ name: String(feed.name ?? feed.chat_id),
82
+ raw: feed,
83
+ }))
84
+ .slice(0, max);
85
+ return groups;
86
+ }
87
+ catch (error) {
88
+ console.error("Failed to fetch groups from TypeX directory", error);
89
+ return [];
90
+ }
91
+ },
92
+ listPeersLive: async (params) => exports.typexDirectory.listPeers(params),
93
+ listGroupsLive: async (params) => exports.typexDirectory.listGroups(params),
94
+ };
package/dist/index.d.ts CHANGED
@@ -1,140 +1,188 @@
1
1
  import { normalizeTypeXTarget } from "./normalize.js";
2
- import { OpenClawPluginApi } from "openclaw/plugin-sdk";
3
- declare const plugin: {
4
- messaging: {
5
- normalizeTarget: typeof normalizeTypeXTarget;
6
- targetResolver: {
7
- looksLikeId: () => boolean;
8
- hint: string;
2
+ declare const _default: {
3
+ id: string;
4
+ name: string;
5
+ description: string;
6
+ configSchema: import("../node_modules/openclaw/dist/plugin-sdk/src/channels/plugins/types.plugin.js", { with: { "resolution-mode": "import" } }).ChannelConfigSchema;
7
+ register: (api: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawPluginApi) => void;
8
+ channelPlugin: {
9
+ messaging: {
10
+ normalizeTarget: typeof normalizeTypeXTarget;
11
+ targetResolver: {
12
+ looksLikeId: (raw: string) => boolean;
13
+ hint: string;
14
+ };
9
15
  };
10
- };
11
- register(api: OpenClawPluginApi): void;
12
- id: "openclaw-extension-typex";
13
- meta: {
14
16
  id: string;
15
- label: string;
16
- selectionLabel: string;
17
- detailLabel: string;
18
- docsPath: string;
19
- docsLabel: string;
20
- blurb: string;
21
- order: number;
22
- };
23
- onboarding: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).ChannelOnboardingAdapter;
24
- capabilities: {
25
- chatTypes: ("group" | "direct")[];
26
- media: true;
27
- reactions: false;
28
- threads: false;
29
- polls: false;
30
- nativeCommands: false;
31
- blockStreaming: false;
32
- };
33
- reload: {
34
- configPrefixes: string[];
35
- };
36
- outbound: any;
37
- configSchema: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).ChannelConfigSchema;
38
- config: {
39
- listAccountIds: (cfg: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).OpenClawConfig) => string[];
40
- resolveAccount: (cfg: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).OpenClawConfig, accountId: string | null | undefined) => {
41
- accountId: string;
42
- name: any;
43
- enabled: boolean;
44
- configured: boolean;
45
- tokenSource: string;
46
- config: any;
17
+ meta: {
18
+ id: string;
19
+ label: string;
20
+ selectionLabel: string;
21
+ detailLabel: string;
22
+ docsPath: string;
23
+ docsLabel: string;
24
+ blurb: string;
25
+ order: number;
26
+ showInSetup: boolean;
27
+ exposure: {
28
+ setup: boolean;
29
+ docs: boolean;
30
+ configured: boolean;
31
+ };
47
32
  };
48
- defaultAccountId: (cfg: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).OpenClawConfig) => string;
49
- setAccountEnabled: ({ cfg }: {
50
- cfg: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).OpenClawConfig;
51
- accountId: string;
52
- enabled: boolean;
53
- }) => import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).OpenClawConfig;
54
- deleteAccount: ({ cfg }: {
55
- cfg: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).OpenClawConfig;
56
- accountId: string;
57
- }) => import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).OpenClawConfig;
58
- isConfigured: (acc: any) => any;
59
- describeAccount: (acc: any) => {
60
- accountId: any;
61
- name: any;
62
- enabled: any;
63
- configured: any;
64
- tokenSource: any;
33
+ setupWizard: import("openclaw/plugin-sdk/setup", { with: { "resolution-mode": "import" } }).ChannelSetupWizardAdapter;
34
+ capabilities: {
35
+ chatTypes: ("group" | "direct")[];
36
+ media: true;
37
+ reactions: false;
38
+ threads: false;
39
+ polls: false;
40
+ nativeCommands: false;
41
+ blockStreaming: true;
65
42
  };
66
- resolveAllowFrom: () => never[];
67
- formatAllowFrom: () => never[];
68
- };
69
- gateway: {
70
- startAccount: (ctx: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).ChannelGatewayContext<any>) => Promise<void>;
71
- };
72
- security: {
73
- resolveDmPolicy: () => {
74
- policy: string;
75
- allowFrom: never[];
76
- policyPath: string;
77
- allowFromPath: string;
78
- approveHint: string;
79
- normalizeEntry: (s: string) => string;
43
+ agentPrompt: {
44
+ messageToolHints: () => string[];
80
45
  };
81
- };
82
- groups: {
83
- resolveRequireMention: ({ cfg, groupId }: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).ChannelGroupContext) => any;
84
- };
85
- directory: {
86
- self: () => Promise<null>;
87
- listPeers: () => Promise<never[]>;
88
- listGroups: () => Promise<never[]>;
89
- };
90
- status: {
91
- defaultRuntime: {
92
- accountId: string;
93
- running: false;
94
- lastStartAt: null;
95
- lastStopAt: null;
96
- lastError: null;
46
+ agentTools: ({ cfg }: {
47
+ cfg?: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig;
48
+ }) => import("openclaw/plugin-sdk/channel-contract", { with: { "resolution-mode": "import" } }).ChannelAgentTool[];
49
+ actions: import("openclaw/plugin-sdk/channel-contract", { with: { "resolution-mode": "import" } }).ChannelMessageActionAdapter;
50
+ reload: {
51
+ configPrefixes: string[];
52
+ };
53
+ outbound: any;
54
+ configSchema: import("../node_modules/openclaw/dist/plugin-sdk/src/channels/plugins/types.plugin.js", { with: { "resolution-mode": "import" } }).ChannelConfigSchema;
55
+ config: {
56
+ listAccountIds: (cfg: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig) => string[];
57
+ resolveAccount: (cfg: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig, accountId: string | null | undefined) => {
58
+ accountId: string;
59
+ name: any;
60
+ enabled: boolean;
61
+ configured: boolean;
62
+ tokenSource: string;
63
+ config: any;
64
+ };
65
+ defaultAccountId: (cfg: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig) => string;
66
+ setAccountEnabled: ({ cfg }: {
67
+ cfg: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig;
68
+ accountId: string;
69
+ enabled: boolean;
70
+ }) => import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig;
71
+ deleteAccount: ({ cfg }: {
72
+ cfg: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig;
73
+ accountId: string;
74
+ }) => import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig;
75
+ isConfigured: (acc: any) => any;
76
+ describeAccount: (acc: any) => {
77
+ accountId: any;
78
+ name: any;
79
+ enabled: any;
80
+ configured: any;
81
+ tokenSource: any;
82
+ };
83
+ resolveAllowFrom: ({ cfg, accountId }: {
84
+ cfg: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig;
85
+ accountId?: string | null;
86
+ }) => any;
87
+ formatAllowFrom: ({ allowFrom }: {
88
+ cfg: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig;
89
+ accountId?: string | null;
90
+ allowFrom: Array<string | number>;
91
+ }) => string[];
92
+ };
93
+ gateway: {
94
+ startAccount: (ctx: import("openclaw/plugin-sdk/channel-contract", { with: { "resolution-mode": "import" } }).ChannelGatewayContext<any>) => Promise<void>;
95
+ };
96
+ security: {
97
+ resolveDmPolicy: () => {
98
+ policy: string;
99
+ allowFrom: never[];
100
+ policyPath: string;
101
+ allowFromPath: string;
102
+ approveHint: string;
103
+ normalizeEntry: (s: string) => string;
104
+ };
105
+ };
106
+ groups: {
107
+ resolveRequireMention: ({ cfg, groupId }: import("openclaw/plugin-sdk/channel-contract", { with: { "resolution-mode": "import" } }).ChannelGroupContext) => any;
108
+ };
109
+ directory: {
110
+ self: () => Promise<null>;
111
+ listPeers: ({ cfg, accountId, query, limit }: any) => Promise<{
112
+ kind: "user" | "group" | "channel";
113
+ id: string;
114
+ name?: string;
115
+ raw?: unknown;
116
+ }[]>;
117
+ listGroups: ({ cfg, accountId, query, limit }: any) => Promise<{
118
+ kind: "group";
119
+ id: string;
120
+ name: string;
121
+ raw: any;
122
+ }[]>;
123
+ listPeersLive: (params: any) => Promise<{
124
+ kind: "user" | "group" | "channel";
125
+ id: string;
126
+ name?: string;
127
+ raw?: unknown;
128
+ }[]>;
129
+ listGroupsLive: (params: any) => Promise<{
130
+ kind: "group";
131
+ id: string;
132
+ name: string;
133
+ raw: any;
134
+ }[]>;
97
135
  };
98
- collectStatusIssues: () => never[];
99
- buildChannelSummary: ({ snapshot }: {
100
- account: any;
101
- cfg: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).OpenClawConfig;
102
- defaultAccountId: string;
103
- snapshot: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).ChannelAccountSnapshot;
104
- }) => Promise<{
105
- configured: boolean | undefined;
106
- tokenSource: string | undefined;
107
- running: boolean | undefined;
108
- lastStartAt: number | null | undefined;
109
- lastStopAt: number | null | undefined;
110
- lastError: string | null | undefined;
111
- probe: unknown;
112
- lastProbeAt: number | null | undefined;
113
- }>;
114
- probeAccount: () => Promise<{
115
- ok: boolean;
116
- timestamp: number;
117
- }>;
118
- buildAccountSnapshot: ({ account, runtime }: {
119
- account: any;
120
- cfg: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).OpenClawConfig;
121
- runtime?: import("openclaw/plugin-sdk", { with: { "resolution-mode": "import" } }).ChannelAccountSnapshot;
122
- probe?: unknown;
123
- audit?: unknown;
124
- }) => {
125
- accountId: any;
126
- name: any;
127
- enabled: any;
128
- configured: any;
129
- tokenSource: any;
130
- running: boolean;
131
- lastStartAt: number | null;
132
- lastStopAt: number | null;
133
- lastError: string | null;
134
- lastInboundAt: null;
135
- lastOutboundAt: null;
136
+ status: {
137
+ defaultRuntime: {
138
+ accountId: string;
139
+ running: false;
140
+ lastStartAt: null;
141
+ lastStopAt: null;
142
+ lastError: null;
143
+ };
144
+ collectStatusIssues: () => never[];
145
+ buildChannelSummary: ({ snapshot }: {
146
+ account: any;
147
+ cfg: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig;
148
+ defaultAccountId: string;
149
+ snapshot: import("openclaw/plugin-sdk/channel-contract", { with: { "resolution-mode": "import" } }).ChannelAccountSnapshot;
150
+ }) => Promise<{
151
+ configured: boolean | undefined;
152
+ tokenSource: string | undefined;
153
+ running: boolean | undefined;
154
+ lastStartAt: number | null | undefined;
155
+ lastStopAt: number | null | undefined;
156
+ lastError: string | null | undefined;
157
+ probe: unknown;
158
+ lastProbeAt: number | null | undefined;
159
+ }>;
160
+ probeAccount: () => Promise<{
161
+ ok: boolean;
162
+ timestamp: number;
163
+ }>;
164
+ buildAccountSnapshot: ({ account, runtime }: {
165
+ account: any;
166
+ cfg: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).OpenClawConfig;
167
+ runtime?: import("openclaw/plugin-sdk/channel-contract", { with: { "resolution-mode": "import" } }).ChannelAccountSnapshot;
168
+ probe?: unknown;
169
+ audit?: unknown;
170
+ }) => {
171
+ accountId: any;
172
+ name: any;
173
+ enabled: any;
174
+ configured: any;
175
+ tokenSource: any;
176
+ running: boolean;
177
+ lastStartAt: number | null;
178
+ lastStopAt: number | null;
179
+ lastError: string | null;
180
+ lastInboundAt: null;
181
+ lastOutboundAt: null;
182
+ };
183
+ logSelfId: () => void;
136
184
  };
137
- logSelfId: () => void;
138
185
  };
186
+ setChannelRuntime?: (runtime: import("openclaw/plugin-sdk/channel-core", { with: { "resolution-mode": "import" } }).PluginRuntime) => void;
139
187
  };
140
- export = plugin;
188
+ export default _default;
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const channel_core_1 = require("openclaw/plugin-sdk/channel-core");
2
4
  const plugin_js_1 = require("./plugin.js");
3
5
  const normalize_js_1 = require("./normalize.js");
4
6
  const runtime_js_1 = require("./client/runtime.js");
@@ -6,14 +8,13 @@ const plugin = {
6
8
  ...plugin_js_1.typexPlugin,
7
9
  messaging: {
8
10
  normalizeTarget: normalize_js_1.normalizeTypeXTarget,
9
- targetResolver: {
10
- looksLikeId: () => true,
11
- hint: "chat_id",
12
- },
13
- },
14
- register(api) {
15
- (0, runtime_js_1.setTypeXRuntime)(api.runtime);
16
- api.registerChannel(plugin_js_1.typexPlugin);
11
+ targetResolver: plugin_js_1.typexPlugin.messaging.targetResolver,
17
12
  },
18
13
  };
19
- module.exports = plugin;
14
+ exports.default = (0, channel_core_1.defineChannelPluginEntry)({
15
+ id: plugin.id,
16
+ name: plugin.meta.label,
17
+ description: plugin.meta.blurb,
18
+ plugin,
19
+ setRuntime: runtime_js_1.setTypeXRuntime,
20
+ });
package/dist/normalize.js CHANGED
@@ -2,7 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeTypeXTarget = normalizeTypeXTarget;
4
4
  function normalizeTypeXTarget(raw) {
5
- let normalized = raw.replace(/^typex:/i, "").trim();
6
- normalized = normalized.replace(/^(group|chat|user|dm):/i, "").trim();
5
+ const normalized = raw.replace(/^typex:/i, "").trim();
6
+ if (!normalized) {
7
+ return normalized;
8
+ }
9
+ if (/^dm:/i.test(normalized)) {
10
+ return `user:${normalized.slice(3).trim()}`;
11
+ }
7
12
  return normalized;
8
13
  }
@@ -1,2 +1,2 @@
1
- import type { ChannelOnboardingAdapter } from "openclaw/plugin-sdk";
2
- export declare const typexOnboardingAdapter: ChannelOnboardingAdapter;
1
+ import type { ChannelSetupWizardAdapter } from "openclaw/plugin-sdk/setup";
2
+ export declare const typexSetupWizard: ChannelSetupWizardAdapter;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.typexOnboardingAdapter = void 0;
6
+ exports.typexSetupWizard = void 0;
7
7
  const qrcode_terminal_1 = __importDefault(require("qrcode-terminal"));
8
8
  const accounts_js_1 = require("./client/accounts.js");
9
9
  const client_js_1 = require("./client/client.js");
@@ -19,7 +19,7 @@ function extractQrCodeId(qrcodeData) {
19
19
  return new URLSearchParams(queryOnly).get("qr_code_id") || "";
20
20
  }
21
21
  }
22
- exports.typexOnboardingAdapter = {
22
+ exports.typexSetupWizard = {
23
23
  channel: CHANNEL_ID,
24
24
  getStatus: async ({ cfg }) => {
25
25
  const accountId = (0, accounts_js_1.resolveDefaultTypeXAccountId)(cfg);