@anwenhappy2026/x-channel 0.1.0
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/README.md +183 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/setup-entry.d.ts +5 -0
- package/dist/setup-entry.d.ts.map +1 -0
- package/dist/setup-entry.js +4 -0
- package/dist/setup-entry.js.map +1 -0
- package/dist/src/channel.d.ts +22 -0
- package/dist/src/channel.d.ts.map +1 -0
- package/dist/src/channel.js +156 -0
- package/dist/src/channel.js.map +1 -0
- package/dist/src/gateway.d.ts +17 -0
- package/dist/src/gateway.d.ts.map +1 -0
- package/dist/src/gateway.js +314 -0
- package/dist/src/gateway.js.map +1 -0
- package/dist/src/http-handler.d.ts +4 -0
- package/dist/src/http-handler.d.ts.map +1 -0
- package/dist/src/http-handler.js +443 -0
- package/dist/src/http-handler.js.map +1 -0
- package/dist/src/runtime.d.ts +4 -0
- package/dist/src/runtime.d.ts.map +1 -0
- package/dist/src/runtime.js +11 -0
- package/dist/src/runtime.js.map +1 -0
- package/openclaw.plugin.json +90 -0
- package/package.json +65 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import { getXChannelRuntime } from "./runtime.js";
|
|
2
|
+
function info(log, message) {
|
|
3
|
+
log?.info?.(message);
|
|
4
|
+
}
|
|
5
|
+
function warn(log, message) {
|
|
6
|
+
log?.warn?.(message);
|
|
7
|
+
}
|
|
8
|
+
function logError(log, message) {
|
|
9
|
+
log?.error?.(message);
|
|
10
|
+
}
|
|
11
|
+
function sendJson(res, statusCode, payload) {
|
|
12
|
+
res.statusCode = statusCode;
|
|
13
|
+
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
14
|
+
res.end(JSON.stringify(payload));
|
|
15
|
+
}
|
|
16
|
+
function sendOpenAiError(res, statusCode, message, type = "invalid_request_error") {
|
|
17
|
+
sendJson(res, statusCode, {
|
|
18
|
+
error: {
|
|
19
|
+
message,
|
|
20
|
+
type,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function readRawBody(req) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const chunks = [];
|
|
27
|
+
req.on("data", (chunk) => {
|
|
28
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
|
|
29
|
+
});
|
|
30
|
+
req.on("error", reject);
|
|
31
|
+
req.on("end", () => resolve(Buffer.concat(chunks).toString("utf-8")));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function parseJsonBody(raw) {
|
|
35
|
+
if (!raw.trim()) {
|
|
36
|
+
throw new Error("Request body must be a JSON object.");
|
|
37
|
+
}
|
|
38
|
+
let parsed;
|
|
39
|
+
try {
|
|
40
|
+
parsed = JSON.parse(raw);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new Error("Request body must be valid JSON.");
|
|
44
|
+
}
|
|
45
|
+
if (!parsed || typeof parsed !== "object") {
|
|
46
|
+
throw new Error("Request body must be a JSON object.");
|
|
47
|
+
}
|
|
48
|
+
return parsed;
|
|
49
|
+
}
|
|
50
|
+
function extractMessageText(content) {
|
|
51
|
+
if (typeof content === "string") {
|
|
52
|
+
return content.trim();
|
|
53
|
+
}
|
|
54
|
+
if (!Array.isArray(content)) {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
const texts = [];
|
|
58
|
+
for (const part of content) {
|
|
59
|
+
if (!part || typeof part !== "object")
|
|
60
|
+
continue;
|
|
61
|
+
const record = part;
|
|
62
|
+
if (record.type !== "text" || typeof record.text !== "string")
|
|
63
|
+
continue;
|
|
64
|
+
const value = record.text.trim();
|
|
65
|
+
if (value) {
|
|
66
|
+
texts.push(value);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return texts.join("\n").trim();
|
|
70
|
+
}
|
|
71
|
+
function parseOpenAiChatRequest(raw) {
|
|
72
|
+
const body = parseJsonBody(raw);
|
|
73
|
+
let userText = "";
|
|
74
|
+
const directContent = extractMessageText(body.content);
|
|
75
|
+
if (directContent) {
|
|
76
|
+
userText = directContent;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const messages = body.messages;
|
|
80
|
+
if (Array.isArray(messages) && messages.length > 0) {
|
|
81
|
+
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
82
|
+
const item = messages[i];
|
|
83
|
+
if (!item || typeof item !== "object")
|
|
84
|
+
continue;
|
|
85
|
+
const msg = item;
|
|
86
|
+
const text = extractMessageText(msg.content);
|
|
87
|
+
if (!text)
|
|
88
|
+
continue;
|
|
89
|
+
const role = typeof msg.role === "string" ? msg.role : "";
|
|
90
|
+
if (role === "user") {
|
|
91
|
+
userText = text;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (!userText) {
|
|
95
|
+
userText = text;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const metadata = body.metadata && typeof body.metadata === "object"
|
|
101
|
+
? { ...body.metadata }
|
|
102
|
+
: {};
|
|
103
|
+
if (typeof body.model === "string" && body.model.trim()) {
|
|
104
|
+
metadata.model = body.model.trim();
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
model: typeof body.model === "string" ? body.model : undefined,
|
|
108
|
+
stream: body.stream === false ? false : true,
|
|
109
|
+
shouldDispatch: Boolean(userText),
|
|
110
|
+
inbound: {
|
|
111
|
+
text: userText,
|
|
112
|
+
userId: typeof body.user === "string" ? body.user : undefined,
|
|
113
|
+
accountId: typeof body.accountId === "string" ? body.accountId : undefined,
|
|
114
|
+
conversationId: typeof body.conversationId === "string" ? body.conversationId : undefined,
|
|
115
|
+
metadata,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function toInboundBody(input) {
|
|
120
|
+
if (!input || typeof input !== "object") {
|
|
121
|
+
throw new Error("Request body must be a JSON object.");
|
|
122
|
+
}
|
|
123
|
+
const body = input;
|
|
124
|
+
if (typeof body.text !== "string" || !body.text.trim()) {
|
|
125
|
+
throw new Error("`text` is required and must be a non-empty string.");
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
text: body.text,
|
|
129
|
+
userId: typeof body.userId === "string" ? body.userId : undefined,
|
|
130
|
+
accountId: typeof body.accountId === "string" ? body.accountId : undefined,
|
|
131
|
+
conversationId: typeof body.conversationId === "string" ? body.conversationId : undefined,
|
|
132
|
+
metadata: body.metadata && typeof body.metadata === "object"
|
|
133
|
+
? body.metadata
|
|
134
|
+
: undefined,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function replyTextFromDispatch(replies) {
|
|
138
|
+
return replies
|
|
139
|
+
.filter((reply) => reply.kind === "block" && typeof reply.text === "string")
|
|
140
|
+
.map((reply) => reply.text ?? "")
|
|
141
|
+
.join("");
|
|
142
|
+
}
|
|
143
|
+
function writeSse(res, payload) {
|
|
144
|
+
const data = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
145
|
+
res.write(`data: ${data}\n\n`);
|
|
146
|
+
}
|
|
147
|
+
function splitStreamText(text, maxChunkChars = 24) {
|
|
148
|
+
if (!text)
|
|
149
|
+
return [];
|
|
150
|
+
const chunks = [];
|
|
151
|
+
for (let i = 0; i < text.length; i += maxChunkChars) {
|
|
152
|
+
chunks.push(text.slice(i, i + maxChunkChars));
|
|
153
|
+
}
|
|
154
|
+
return chunks;
|
|
155
|
+
}
|
|
156
|
+
async function dispatchInboundMessage(cfg, account, body, metadataFrom, onChunk) {
|
|
157
|
+
const runtime = getXChannelRuntime();
|
|
158
|
+
const userId = body.userId ?? "http-test-user";
|
|
159
|
+
const accountId = body.accountId ?? account.accountId ?? "default";
|
|
160
|
+
const conversationId = body.conversationId ??
|
|
161
|
+
account.defaultConversationId ??
|
|
162
|
+
"http-test-conversation";
|
|
163
|
+
const route = runtime.channel.routing.resolveAgentRoute({
|
|
164
|
+
cfg,
|
|
165
|
+
channel: "x-channel",
|
|
166
|
+
accountId,
|
|
167
|
+
peer: { kind: "direct", id: userId },
|
|
168
|
+
});
|
|
169
|
+
const envelopeOptions = runtime.channel.reply.resolveEnvelopeFormatOptions(cfg);
|
|
170
|
+
const now = Date.now();
|
|
171
|
+
const fromAddress = `x-channel:user:${userId}`;
|
|
172
|
+
const bodyText = runtime.channel.reply.formatInboundEnvelope({
|
|
173
|
+
channel: "x-channel",
|
|
174
|
+
from: userId,
|
|
175
|
+
timestamp: now,
|
|
176
|
+
body: body.text,
|
|
177
|
+
chatType: "direct",
|
|
178
|
+
sender: { id: userId, name: userId },
|
|
179
|
+
envelope: envelopeOptions,
|
|
180
|
+
});
|
|
181
|
+
const ctxPayload = runtime.channel.reply.finalizeInboundContext({
|
|
182
|
+
Body: bodyText,
|
|
183
|
+
BodyForAgent: body.text,
|
|
184
|
+
RawBody: body.text,
|
|
185
|
+
CommandBody: body.text,
|
|
186
|
+
From: fromAddress,
|
|
187
|
+
To: fromAddress,
|
|
188
|
+
SessionKey: route.sessionKey,
|
|
189
|
+
AccountId: route.accountId,
|
|
190
|
+
ChatType: "direct",
|
|
191
|
+
SenderId: userId,
|
|
192
|
+
SenderName: userId,
|
|
193
|
+
Provider: "x-channel",
|
|
194
|
+
Surface: "x-channel",
|
|
195
|
+
MessageSid: `x-channel:${now}`,
|
|
196
|
+
Timestamp: now,
|
|
197
|
+
OriginatingChannel: "x-channel",
|
|
198
|
+
OriginatingTo: fromAddress,
|
|
199
|
+
ConversationId: conversationId,
|
|
200
|
+
});
|
|
201
|
+
const replies = [];
|
|
202
|
+
let chunkIndex = 0;
|
|
203
|
+
await runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
204
|
+
ctx: ctxPayload,
|
|
205
|
+
cfg,
|
|
206
|
+
replyOptions: {
|
|
207
|
+
disableBlockStreaming: false,
|
|
208
|
+
},
|
|
209
|
+
dispatcherOptions: {
|
|
210
|
+
deliver: async (payload, info) => {
|
|
211
|
+
if (info.kind === "tool")
|
|
212
|
+
return;
|
|
213
|
+
const chunk = { kind: info.kind, text: payload.text };
|
|
214
|
+
replies.push(chunk);
|
|
215
|
+
if (onChunk) {
|
|
216
|
+
await onChunk({ ...chunk, index: chunkIndex++ });
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
return {
|
|
222
|
+
accountId,
|
|
223
|
+
userId,
|
|
224
|
+
text: body.text,
|
|
225
|
+
conversationId,
|
|
226
|
+
metadata: { from: metadataFrom, ...(body.metadata ?? {}) },
|
|
227
|
+
replies,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function resolveAccount(cfg) {
|
|
231
|
+
const channels = (cfg.channels ?? {});
|
|
232
|
+
const section = channels["x-channel"] ?? {};
|
|
233
|
+
const wsSection = section.ws && typeof section.ws === "object"
|
|
234
|
+
? section.ws
|
|
235
|
+
: {};
|
|
236
|
+
const configuredPort = typeof section.port === "number"
|
|
237
|
+
? section.port
|
|
238
|
+
: typeof section.port === "string"
|
|
239
|
+
? Number(section.port)
|
|
240
|
+
: NaN;
|
|
241
|
+
const wsProtocols = Array.isArray(wsSection.protocols)
|
|
242
|
+
? wsSection.protocols.filter((v) => typeof v === "string")
|
|
243
|
+
: [];
|
|
244
|
+
const wsInitialRetryMs = typeof wsSection.initialRetryMs === "number" ? wsSection.initialRetryMs : 1000;
|
|
245
|
+
const wsMaxRetryMs = typeof wsSection.maxRetryMs === "number" ? wsSection.maxRetryMs : 30000;
|
|
246
|
+
const wsBackoffFactor = typeof wsSection.backoffFactor === "number" ? wsSection.backoffFactor : 2;
|
|
247
|
+
const wsMaxRetries = typeof wsSection.maxRetries === "number" ? wsSection.maxRetries : -1;
|
|
248
|
+
const wsConnectTimeoutMs = typeof wsSection.connectTimeoutMs === "number" ? wsSection.connectTimeoutMs : 10000;
|
|
249
|
+
return {
|
|
250
|
+
accountId: String(section.defaultAccountId ?? "default"),
|
|
251
|
+
defaultConversationId: typeof section.defaultConversationId === "string"
|
|
252
|
+
? section.defaultConversationId
|
|
253
|
+
: undefined,
|
|
254
|
+
host: typeof section.host === "string" ? section.host : "127.0.0.1",
|
|
255
|
+
port: Number.isFinite(configuredPort) ? configuredPort : 3000,
|
|
256
|
+
endpointPath: typeof section.endpointPath === "string"
|
|
257
|
+
? section.endpointPath
|
|
258
|
+
: "/v1/chat/completions",
|
|
259
|
+
ws: {
|
|
260
|
+
enabled: Boolean(wsSection.enabled),
|
|
261
|
+
url: typeof wsSection.url === "string" ? wsSection.url : undefined,
|
|
262
|
+
protocols: wsProtocols,
|
|
263
|
+
initialRetryMs: Math.max(200, wsInitialRetryMs),
|
|
264
|
+
maxRetryMs: Math.max(1000, wsMaxRetryMs),
|
|
265
|
+
backoffFactor: Math.max(1, wsBackoffFactor),
|
|
266
|
+
maxRetries: wsMaxRetries,
|
|
267
|
+
connectTimeoutMs: Math.max(1000, wsConnectTimeoutMs),
|
|
268
|
+
handshake: wsSection.handshake && typeof wsSection.handshake === "object"
|
|
269
|
+
? wsSection.handshake
|
|
270
|
+
: undefined,
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
export function createHttpHandler(api) {
|
|
275
|
+
return async (req, res) => {
|
|
276
|
+
const runtimeConfig = api.runtime.config;
|
|
277
|
+
const cfg = runtimeConfig &&
|
|
278
|
+
typeof runtimeConfig.get === "function"
|
|
279
|
+
? runtimeConfig.get()
|
|
280
|
+
: (runtimeConfig ?? {});
|
|
281
|
+
const account = resolveAccount(cfg);
|
|
282
|
+
const log = {
|
|
283
|
+
info: (msg) => console.log(`[x-channel-http] ${msg}`),
|
|
284
|
+
warn: (msg) => console.warn(`[x-channel-http] ${msg}`),
|
|
285
|
+
error: (msg) => console.error(`[x-channel-http] ${msg}`),
|
|
286
|
+
};
|
|
287
|
+
try {
|
|
288
|
+
if (!req.url) {
|
|
289
|
+
return sendOpenAiError(res, 404, "Not found.");
|
|
290
|
+
}
|
|
291
|
+
info(log, `http request: method=${(req.method ?? "GET").toUpperCase()} url=${req.url}`);
|
|
292
|
+
if ((req.method ?? "GET").toUpperCase() !== "POST") {
|
|
293
|
+
return sendOpenAiError(res, 405, "Method not allowed.");
|
|
294
|
+
}
|
|
295
|
+
const rawBody = await readRawBody(req);
|
|
296
|
+
info(log, `http raw body: ${rawBody || "<empty>"}`);
|
|
297
|
+
const request = parseOpenAiChatRequest(rawBody);
|
|
298
|
+
info(log, `http chat request: stream=${String(request.stream)} model=${request.model ?? "x-channel"} user=${request.inbound.userId ?? "http-test-user"} textLen=${request.inbound.text.length}`);
|
|
299
|
+
const created = Math.floor(Date.now() / 1000);
|
|
300
|
+
const responseId = `chatcmpl-${Date.now()}`;
|
|
301
|
+
const model = request.model ?? "x-channel";
|
|
302
|
+
if (request.stream) {
|
|
303
|
+
// Setup SSE headers
|
|
304
|
+
res.statusCode = 200;
|
|
305
|
+
res.setHeader("content-type", "text/event-stream; charset=utf-8");
|
|
306
|
+
res.setHeader("cache-control", "no-cache");
|
|
307
|
+
res.setHeader("connection", "keep-alive");
|
|
308
|
+
res.setHeader("x-accel-buffering", "no");
|
|
309
|
+
if (typeof res.flushHeaders === "function") {
|
|
310
|
+
res.flushHeaders();
|
|
311
|
+
}
|
|
312
|
+
if (!request.shouldDispatch) {
|
|
313
|
+
info(log, `skip dispatch: empty content`);
|
|
314
|
+
info(log, `http stream send: empty completion + [DONE]`);
|
|
315
|
+
writeSse(res, {
|
|
316
|
+
id: responseId,
|
|
317
|
+
object: "chat.completion.chunk",
|
|
318
|
+
created,
|
|
319
|
+
model,
|
|
320
|
+
choices: [
|
|
321
|
+
{
|
|
322
|
+
index: 0,
|
|
323
|
+
delta: {},
|
|
324
|
+
logprobs: null,
|
|
325
|
+
finish_reason: "stop",
|
|
326
|
+
},
|
|
327
|
+
],
|
|
328
|
+
});
|
|
329
|
+
writeSse(res, "[DONE]");
|
|
330
|
+
res.end();
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
writeSse(res, {
|
|
334
|
+
id: responseId,
|
|
335
|
+
object: "chat.completion.chunk",
|
|
336
|
+
created,
|
|
337
|
+
model,
|
|
338
|
+
choices: [
|
|
339
|
+
{
|
|
340
|
+
index: 0,
|
|
341
|
+
delta: { role: "assistant", content: "" },
|
|
342
|
+
logprobs: null,
|
|
343
|
+
finish_reason: null,
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
});
|
|
347
|
+
let streamClosed = false;
|
|
348
|
+
req.on("close", () => {
|
|
349
|
+
streamClosed = true;
|
|
350
|
+
info(log, `http stream closed by client`);
|
|
351
|
+
});
|
|
352
|
+
await dispatchInboundMessage(cfg, account, request.inbound, "http-gateway", (chunk) => {
|
|
353
|
+
if (streamClosed || chunk.kind !== "block")
|
|
354
|
+
return;
|
|
355
|
+
const parts = splitStreamText(chunk.text ?? "");
|
|
356
|
+
info(log, `http stream send: block chunk index=${chunk.index} parts=${parts.length}`);
|
|
357
|
+
for (const part of parts) {
|
|
358
|
+
writeSse(res, {
|
|
359
|
+
id: responseId,
|
|
360
|
+
object: "chat.completion.chunk",
|
|
361
|
+
created,
|
|
362
|
+
model,
|
|
363
|
+
choices: [
|
|
364
|
+
{
|
|
365
|
+
index: 0,
|
|
366
|
+
delta: { content: part },
|
|
367
|
+
logprobs: null,
|
|
368
|
+
finish_reason: null,
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
if (!streamClosed) {
|
|
375
|
+
info(log, `http stream send: finish + [DONE]`);
|
|
376
|
+
writeSse(res, {
|
|
377
|
+
id: responseId,
|
|
378
|
+
object: "chat.completion.chunk",
|
|
379
|
+
created,
|
|
380
|
+
model,
|
|
381
|
+
choices: [
|
|
382
|
+
{
|
|
383
|
+
index: 0,
|
|
384
|
+
delta: {},
|
|
385
|
+
logprobs: null,
|
|
386
|
+
finish_reason: "stop",
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
});
|
|
390
|
+
writeSse(res, "[DONE]");
|
|
391
|
+
res.end();
|
|
392
|
+
}
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
// Non-streaming response
|
|
396
|
+
if (!request.shouldDispatch) {
|
|
397
|
+
info(log, `skip dispatch: empty content`);
|
|
398
|
+
info(log, `http response: non-stream empty completion`);
|
|
399
|
+
return sendJson(res, 200, {
|
|
400
|
+
id: responseId,
|
|
401
|
+
object: "chat.completion",
|
|
402
|
+
created,
|
|
403
|
+
model,
|
|
404
|
+
choices: [
|
|
405
|
+
{
|
|
406
|
+
index: 0,
|
|
407
|
+
message: {
|
|
408
|
+
role: "assistant",
|
|
409
|
+
content: "",
|
|
410
|
+
},
|
|
411
|
+
finish_reason: "stop",
|
|
412
|
+
},
|
|
413
|
+
],
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
const dispatched = await dispatchInboundMessage(cfg, account, request.inbound, "http-gateway");
|
|
417
|
+
const content = replyTextFromDispatch(dispatched.replies);
|
|
418
|
+
info(log, `http response: non-stream completion contentLen=${content.length}`);
|
|
419
|
+
return sendJson(res, 200, {
|
|
420
|
+
id: responseId,
|
|
421
|
+
object: "chat.completion",
|
|
422
|
+
created,
|
|
423
|
+
model,
|
|
424
|
+
choices: [
|
|
425
|
+
{
|
|
426
|
+
index: 0,
|
|
427
|
+
message: {
|
|
428
|
+
role: "assistant",
|
|
429
|
+
content,
|
|
430
|
+
},
|
|
431
|
+
finish_reason: "stop",
|
|
432
|
+
},
|
|
433
|
+
],
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
const message = error instanceof Error ? error.message : "Unknown request error.";
|
|
438
|
+
logError(log, `${message}`);
|
|
439
|
+
return sendOpenAiError(res, 400, message);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
//# sourceMappingURL=http-handler.js.map
|
|
@@ -0,0 +1 @@
|
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ACL,CAAC;YAED,MAAM,UAAU,GAAG,MAAM,sBAAsB,CAC7C,GAAG,EACH,OAAO,EACP,OAAO,CAAC,OAAO,EACf,cAAc,CACf,CAAC;YACF,MAAM,OAAO,GAAG,qBAAqB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC1D,IAAI,CACF,GAAG,EACH,mDAAmD,OAAO,CAAC,MAAM,EAAE,CACpE,CAAC;YAEF,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE;gBACxB,EAAE,EAAE,UAAU;gBACd,MAAM,EAAE,iBAAiB;gBACzB,OAAO;gBACP,KAAK;gBACL,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,CAAC;wBACR,OAAO,EAAE;4BACP,IAAI,EAAE,WAAW;4BACjB,OAAO;yBACR;wBACD,aAAa,EAAE,MAAM;qBACtB;iBACF;aACF,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;YACpE,QAAQ,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;YAC5B,OAAO,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,aAAa,QAErD;AAED,wBAAgB,kBAAkB,IAAI,aAAa,CAKlD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
let runtime = null;
|
|
2
|
+
export function setXChannelRuntime(next) {
|
|
3
|
+
runtime = next;
|
|
4
|
+
}
|
|
5
|
+
export function getXChannelRuntime() {
|
|
6
|
+
if (!runtime) {
|
|
7
|
+
throw new Error("x-channel runtime not initialized");
|
|
8
|
+
}
|
|
9
|
+
return runtime;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAEA,IAAI,OAAO,GAAyB,IAAI,CAAC;AAEzC,MAAM,UAAU,kBAAkB,CAAC,IAAmB;IACpD,OAAO,GAAG,IAAI,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "x-channel",
|
|
3
|
+
"kind": "channel",
|
|
4
|
+
"name": "x-channel",
|
|
5
|
+
"description": "HTTP bridge channel with route integrated into OpenClaw server. Handles inbound messages at /v1/chat/completions and supports optional WebSocket client.",
|
|
6
|
+
"channels": ["x-channel"],
|
|
7
|
+
"configSchema": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": true,
|
|
10
|
+
"properties": {
|
|
11
|
+
"channels": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": true,
|
|
14
|
+
"properties": {
|
|
15
|
+
"x-channel": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"additionalProperties": true,
|
|
18
|
+
"properties": {
|
|
19
|
+
"defaultAccountId": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "Fallback account id for inbound test events."
|
|
22
|
+
},
|
|
23
|
+
"defaultConversationId": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Fallback conversation id for inbound test events."
|
|
26
|
+
},
|
|
27
|
+
"host": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "DEPRECATED: HTTP route now uses OpenClaw server. This config is no longer used."
|
|
30
|
+
},
|
|
31
|
+
"port": {
|
|
32
|
+
"type": "number",
|
|
33
|
+
"description": "DEPRECATED: HTTP route now uses OpenClaw server. This config is no longer used."
|
|
34
|
+
},
|
|
35
|
+
"endpointPath": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "DEPRECATED: Route is fixed at /v1/chat/completions on OpenClaw server."
|
|
38
|
+
},
|
|
39
|
+
"ws": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"description": "Optional outbound WebSocket client configuration.",
|
|
42
|
+
"additionalProperties": true,
|
|
43
|
+
"properties": {
|
|
44
|
+
"enabled": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"description": "Enable WebSocket client. Default: false"
|
|
47
|
+
},
|
|
48
|
+
"url": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "WebSocket server URL, e.g. ws://127.0.0.1:9001/ws"
|
|
51
|
+
},
|
|
52
|
+
"protocols": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"items": { "type": "string" },
|
|
55
|
+
"description": "Optional websocket subprotocols"
|
|
56
|
+
},
|
|
57
|
+
"initialRetryMs": {
|
|
58
|
+
"type": "number",
|
|
59
|
+
"description": "Initial reconnect delay in ms. Default: 1000"
|
|
60
|
+
},
|
|
61
|
+
"maxRetryMs": {
|
|
62
|
+
"type": "number",
|
|
63
|
+
"description": "Maximum reconnect delay in ms. Default: 30000"
|
|
64
|
+
},
|
|
65
|
+
"backoffFactor": {
|
|
66
|
+
"type": "number",
|
|
67
|
+
"description": "Exponential backoff factor. Default: 2"
|
|
68
|
+
},
|
|
69
|
+
"maxRetries": {
|
|
70
|
+
"type": "number",
|
|
71
|
+
"description": "Maximum reconnect attempts, -1 means unlimited. Default: -1"
|
|
72
|
+
},
|
|
73
|
+
"connectTimeoutMs": {
|
|
74
|
+
"type": "number",
|
|
75
|
+
"description": "Single connection timeout in ms. Default: 10000"
|
|
76
|
+
},
|
|
77
|
+
"handshake": {
|
|
78
|
+
"type": "object",
|
|
79
|
+
"description": "Optional handshake payload merged into initial ws handshake message.",
|
|
80
|
+
"additionalProperties": true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@anwenhappy2026/x-channel",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "HTTP bridge channel integrated with OpenClaw server at /v1/chat/completions",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"openclaw.plugin.json",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"watch": "tsc --watch",
|
|
17
|
+
"prepublishOnly": "npm run build",
|
|
18
|
+
"prepack": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"openclaw",
|
|
22
|
+
"plugin",
|
|
23
|
+
"channel",
|
|
24
|
+
"http",
|
|
25
|
+
"websocket",
|
|
26
|
+
"bridge"
|
|
27
|
+
],
|
|
28
|
+
"author": "",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": ""
|
|
33
|
+
},
|
|
34
|
+
"openclaw": {
|
|
35
|
+
"extensions": [
|
|
36
|
+
"./dist/index.js"
|
|
37
|
+
],
|
|
38
|
+
"setupEntry": "./dist/setup-entry.js",
|
|
39
|
+
"install": {
|
|
40
|
+
"npmSpec": "@anwenhappy2026/x-channel",
|
|
41
|
+
"localPath": "./extensions/x-channel",
|
|
42
|
+
"defaultChoice": "npm",
|
|
43
|
+
"allowInvalidConfigRecovery": true
|
|
44
|
+
},
|
|
45
|
+
"startup": {
|
|
46
|
+
"deferConfiguredChannelFullLoadUntilAfterListen": true
|
|
47
|
+
},
|
|
48
|
+
"channel": {
|
|
49
|
+
"id": "x-channel",
|
|
50
|
+
"label": "x-channel",
|
|
51
|
+
"blurb": "HTTP bridge channel integrated with OpenClaw server at /v1/chat/completions"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"openclaw": ">=2026.4.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"openclaw": "latest",
|
|
59
|
+
"@types/node": "^22.0.0",
|
|
60
|
+
"typescript": "^5.0.0"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=22.0.0"
|
|
64
|
+
}
|
|
65
|
+
}
|