openclaw-extension-typex 1.0.0 → 1.0.2

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.
@@ -94,12 +94,18 @@ class TypeXClient {
94
94
  }
95
95
  catch (e) {
96
96
  if (e instanceof Error) {
97
- prompter.note("Failed to stringify message content");
97
+ if (prompter)
98
+ prompter.note("Failed to stringify message content");
99
+ else
100
+ console.log("Failed to stringify message content");
98
101
  }
99
102
  finalContent = String(content);
100
103
  }
101
104
  }
102
- prompter.note(`TypeXClient sending message: content=${typeof finalContent === "string" ? finalContent : JSON.stringify(finalContent)}`);
105
+ if (prompter)
106
+ prompter.note(`TypeXClient sending message: content=${typeof finalContent === "string" ? finalContent : JSON.stringify(finalContent)}`);
107
+ else
108
+ console.log(`TypeXClient sending message: content=${typeof finalContent === "string" ? finalContent : JSON.stringify(finalContent)}`);
103
109
  try {
104
110
  const url = `${TYPEX_DOMAIN}/open/claw/send_message`;
105
111
  const response = await fetch(url, {
@@ -119,24 +125,35 @@ class TypeXClient {
119
125
  if (resJson.code !== 0) {
120
126
  throw new Error(`Send message failed: [${resJson.code}] ${resJson.message}`);
121
127
  }
122
- prompter.note("Message sent successfully", resJson.data);
128
+ if (prompter)
129
+ prompter.note("Message sent successfully", resJson.data);
130
+ else
131
+ console.log("Message sent successfully", JSON.stringify(resJson.data));
123
132
  return (resJson.data || {
124
133
  message_id: `msg_${Date.now()}`,
125
134
  });
126
135
  }
127
136
  catch (error) {
128
- prompter.note(`Error sending message to TypeX API: ${error}`);
137
+ if (prompter)
138
+ prompter.note(`Error sending message to TypeX API: ${error}`);
139
+ else
140
+ console.log(`Error sending message to TypeX API: ${error}`);
129
141
  throw error;
130
142
  }
131
143
  }
132
144
  async fetchMessages(pos) {
133
145
  if (!this.accessToken) {
134
- prompter.note("TypeXClient: No token, skipping fetch.");
146
+ if (prompter)
147
+ prompter.note("TypeXClient: No token, skipping fetch.");
148
+ else
149
+ console.log("TypeXClient: No token, skipping fetch.");
135
150
  return [];
136
151
  }
137
152
  try {
138
153
  const url = `${TYPEX_DOMAIN}/open/claw/message`;
139
- prompter.note(`Fetching messages from pos: ${pos}`);
154
+ if (prompter)
155
+ prompter.note(`Fetching messages from pos: ${pos}`);
156
+ // else console.log(`Fetching messages from pos: ${pos}`);
140
157
  const response = await fetch(url, {
141
158
  method: "POST",
142
159
  headers: {
@@ -147,7 +164,10 @@ class TypeXClient {
147
164
  });
148
165
  const resJson = await response.json();
149
166
  if (resJson.code !== 0) {
150
- prompter.note(`Fetch failed with code ${resJson.code}: ${resJson.message}`);
167
+ if (prompter)
168
+ prompter.note(`Fetch failed with code ${resJson.code}: ${resJson.message}`);
169
+ else
170
+ console.log(`Fetch failed with code ${resJson.code}: ${resJson.message}`);
151
171
  return [];
152
172
  }
153
173
  if (Array.isArray(resJson.data)) {
@@ -156,7 +176,10 @@ class TypeXClient {
156
176
  return [];
157
177
  }
158
178
  catch (e) {
159
- prompter.note(`Fetch messages network error: ${e}`);
179
+ if (prompter)
180
+ prompter.note(`Fetch messages network error: ${e}`);
181
+ else
182
+ console.log(`Fetch messages network error: ${e}`);
160
183
  return [];
161
184
  }
162
185
  }
@@ -69,7 +69,9 @@ async function monitorTypeXProvider(opts) {
69
69
  // --- Polling Loop ---
70
70
  while (!abortSignal.aborted) {
71
71
  try {
72
+ logger?.info(`[${accountObj.accountId}] Polling TypeX messages (pos: ${currentPos})...`);
72
73
  const messages = await client.fetchMessages(currentPos);
74
+ logger?.info(`[${accountObj.accountId}] Received ${messages?.length || 0} messages.`);
73
75
  if (messages && messages.length > 0) {
74
76
  for (const msg of messages) {
75
77
  // Dispatch to OpenClaw via processTypeXMessage
@@ -94,8 +96,8 @@ async function monitorTypeXProvider(opts) {
94
96
  break;
95
97
  }
96
98
  await new Promise((resolve) => setTimeout(resolve, 3000));
97
- logger?.info(`Stopping TypeX monitor...`);
98
99
  }
100
+ logger?.info(`Stopping TypeX monitor...`);
99
101
  }
100
102
  catch (e) {
101
103
  throw e;
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Global runtime reference for the TypeX plugin.
3
3
  */
4
- import type { PluginRuntime } from "openclaw/plugin-sdk";
5
- export declare function setTypeXRuntime(next: PluginRuntime): void;
6
- export declare function getTypeXRuntime(): PluginRuntime;
4
+ export declare function setTypeXRuntime(next: any): void;
5
+ export declare function getTypeXRuntime(): any;
package/dist/index.d.ts CHANGED
@@ -137,4 +137,4 @@ declare const plugin: {
137
137
  logSelfId: () => void;
138
138
  };
139
139
  };
140
- export default plugin;
140
+ export = plugin;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const plugin_js_1 = require("./plugin.js");
4
3
  const normalize_js_1 = require("./normalize.js");
4
+ const runtime_js_1 = require("./client/runtime.js");
5
5
  const plugin = {
6
6
  ...plugin_js_1.typexPlugin,
7
7
  messaging: {
@@ -12,7 +12,8 @@ const plugin = {
12
12
  },
13
13
  },
14
14
  register(api) {
15
+ (0, runtime_js_1.setTypeXRuntime)(api.runtime);
15
16
  api.registerChannel(plugin_js_1.typexPlugin);
16
17
  },
17
18
  };
18
- exports.default = plugin;
19
+ module.exports = plugin;
@@ -3,6 +3,9 @@
3
3
  "name": "openclaw-extension-typex",
4
4
  "version": "1.0.0",
5
5
  "description": "TypeX channel integration for OpenClaw",
6
+ "channels": [
7
+ "typex"
8
+ ],
6
9
  "entry": "dist/index.js",
7
10
  "configSchema": {
8
11
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-extension-typex",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "TypeX channel integration for OpenClaw",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",