@lingyao037/openclaw-lingyao-cli 0.3.3 → 0.4.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/dist/{accounts-Bkwmg14Q.d.ts → accounts-AwHXj7VB.d.ts} +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/index.d.ts +265 -523
- package/dist/index.js +165 -63
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,62 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
defineChannelPluginEntry,
|
|
4
|
+
createChatChannelPlugin
|
|
5
|
+
} from "openclaw/plugin-sdk/core";
|
|
6
|
+
|
|
1
7
|
// src/runtime.ts
|
|
8
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, unlinkSync } from "fs";
|
|
9
|
+
import { join } from "path";
|
|
2
10
|
var globalRuntime = null;
|
|
3
11
|
function setRuntime(runtime) {
|
|
4
12
|
globalRuntime = runtime;
|
|
5
13
|
}
|
|
14
|
+
function adaptPluginRuntime(pr) {
|
|
15
|
+
const noop = (..._args) => {
|
|
16
|
+
};
|
|
17
|
+
const childLogger = pr.logging?.getChildLogger?.() ?? {
|
|
18
|
+
info: console.info.bind(console),
|
|
19
|
+
warn: console.warn.bind(console),
|
|
20
|
+
error: console.error.bind(console),
|
|
21
|
+
debug: noop
|
|
22
|
+
};
|
|
23
|
+
const stateDir = pr.state?.resolveStateDir?.() ?? join(process.cwd(), ".lingyao-data");
|
|
24
|
+
const storeDir = join(stateDir, "lingyao");
|
|
25
|
+
return {
|
|
26
|
+
config: { enabled: true },
|
|
27
|
+
logger: childLogger,
|
|
28
|
+
storage: {
|
|
29
|
+
async get(key) {
|
|
30
|
+
try {
|
|
31
|
+
const filePath = join(storeDir, `${key}.json`);
|
|
32
|
+
if (!existsSync(filePath)) return null;
|
|
33
|
+
const data = readFileSync(filePath, "utf-8");
|
|
34
|
+
return JSON.parse(data);
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
async set(key, value) {
|
|
40
|
+
if (!existsSync(storeDir)) {
|
|
41
|
+
mkdirSync(storeDir, { recursive: true });
|
|
42
|
+
}
|
|
43
|
+
const filePath = join(storeDir, `${key}.json`);
|
|
44
|
+
writeFileSync(filePath, JSON.stringify(value, null, 2), "utf-8");
|
|
45
|
+
},
|
|
46
|
+
async delete(key) {
|
|
47
|
+
const filePath = join(storeDir, `${key}.json`);
|
|
48
|
+
if (existsSync(filePath)) {
|
|
49
|
+
unlinkSync(filePath);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
tools: {
|
|
54
|
+
async call() {
|
|
55
|
+
throw new Error("Tool calls not available in SDK mode");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
6
60
|
|
|
7
61
|
// src/adapters/config.ts
|
|
8
62
|
function extractAccounts(cfg) {
|
|
@@ -34,16 +88,17 @@ function createConfigAdapter() {
|
|
|
34
88
|
}
|
|
35
89
|
return {
|
|
36
90
|
id: resolvedId,
|
|
91
|
+
accountId: resolvedId,
|
|
37
92
|
enabled: accountConfig?.enabled !== false,
|
|
38
93
|
dmPolicy: accountConfig?.dmPolicy ?? "paired",
|
|
39
|
-
allowFrom:
|
|
94
|
+
allowFrom: accountConfig?.allowFrom ?? [],
|
|
40
95
|
rawConfig: accountConfig
|
|
41
96
|
};
|
|
42
97
|
},
|
|
43
|
-
isConfigured(_account) {
|
|
98
|
+
isConfigured(_account, _cfg) {
|
|
44
99
|
return true;
|
|
45
100
|
},
|
|
46
|
-
isEnabled(account) {
|
|
101
|
+
isEnabled(account, _cfg) {
|
|
47
102
|
return account.enabled;
|
|
48
103
|
}
|
|
49
104
|
};
|
|
@@ -241,11 +296,10 @@ function createOutboundAdapter(getOrchestrator2) {
|
|
|
241
296
|
throw new Error("Orchestrator not initialized");
|
|
242
297
|
}
|
|
243
298
|
const accountId = ctx.accountId ?? "default";
|
|
244
|
-
const payload = ctx.payload;
|
|
245
299
|
const sent = orchestrator2.sendNotification(
|
|
246
300
|
accountId,
|
|
247
301
|
ctx.to,
|
|
248
|
-
payload
|
|
302
|
+
ctx.payload
|
|
249
303
|
);
|
|
250
304
|
if (!sent) {
|
|
251
305
|
throw new Error(
|
|
@@ -269,6 +323,20 @@ function createOutboundAdapter(getOrchestrator2) {
|
|
|
269
323
|
};
|
|
270
324
|
}
|
|
271
325
|
|
|
326
|
+
// src/adapters/setup.ts
|
|
327
|
+
import { createPatchedAccountSetupAdapter } from "openclaw/plugin-sdk/setup";
|
|
328
|
+
function createSetupAdapter() {
|
|
329
|
+
return createPatchedAccountSetupAdapter({
|
|
330
|
+
channelKey: "lingyao",
|
|
331
|
+
alwaysUseAccounts: true,
|
|
332
|
+
ensureChannelEnabled: true,
|
|
333
|
+
ensureAccountEnabled: true,
|
|
334
|
+
buildPatch() {
|
|
335
|
+
return {};
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
272
340
|
// src/orchestrator.ts
|
|
273
341
|
import { hostname } from "os";
|
|
274
342
|
|
|
@@ -346,7 +414,7 @@ var ServerHttpClient = class {
|
|
|
346
414
|
/**
|
|
347
415
|
* 注册 Gateway 到服务器
|
|
348
416
|
*/
|
|
349
|
-
async register(
|
|
417
|
+
async register(capabilities2 = {}) {
|
|
350
418
|
if (this.isConnecting) {
|
|
351
419
|
throw new Error("Registration already in progress");
|
|
352
420
|
}
|
|
@@ -361,7 +429,7 @@ var ServerHttpClient = class {
|
|
|
361
429
|
capabilities: {
|
|
362
430
|
websocket: false,
|
|
363
431
|
compression: false,
|
|
364
|
-
...
|
|
432
|
+
...capabilities2
|
|
365
433
|
}
|
|
366
434
|
}
|
|
367
435
|
);
|
|
@@ -3203,17 +3271,12 @@ function getOrchestrator() {
|
|
|
3203
3271
|
return orchestrator;
|
|
3204
3272
|
}
|
|
3205
3273
|
var configAdapter = createConfigAdapter();
|
|
3274
|
+
var setupAdapter = createSetupAdapter();
|
|
3206
3275
|
var messagingAdapter = createMessagingAdapter();
|
|
3207
3276
|
var gatewayAdapter = createGatewayAdapter(getOrchestrator);
|
|
3208
3277
|
var directoryAdapter = createDirectoryAdapter(getOrchestrator);
|
|
3209
3278
|
var outboundAdapter = createOutboundAdapter(getOrchestrator);
|
|
3210
3279
|
var statusAdapter = null;
|
|
3211
|
-
function getStatusAdapter(runtime) {
|
|
3212
|
-
if (!statusAdapter) {
|
|
3213
|
-
statusAdapter = createStatusAdapter(getOrchestrator, runtime);
|
|
3214
|
-
}
|
|
3215
|
-
return statusAdapter;
|
|
3216
|
-
}
|
|
3217
3280
|
var securityOptions = {
|
|
3218
3281
|
dm: {
|
|
3219
3282
|
channelKey: "lingyao",
|
|
@@ -3243,41 +3306,101 @@ var pairingOptions = {
|
|
|
3243
3306
|
}
|
|
3244
3307
|
}
|
|
3245
3308
|
};
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3309
|
+
var capabilities = {
|
|
3310
|
+
chatTypes: ["direct"],
|
|
3311
|
+
media: false,
|
|
3312
|
+
reactions: false,
|
|
3313
|
+
threads: false,
|
|
3314
|
+
polls: false,
|
|
3315
|
+
edit: false,
|
|
3316
|
+
unsend: false,
|
|
3317
|
+
reply: false,
|
|
3318
|
+
effects: false,
|
|
3319
|
+
groupManagement: false,
|
|
3320
|
+
nativeCommands: false,
|
|
3321
|
+
blockStreaming: true
|
|
3322
|
+
};
|
|
3323
|
+
var meta = {
|
|
3324
|
+
id: "lingyao",
|
|
3325
|
+
label: "\u7075\u723B",
|
|
3326
|
+
selectionLabel: "\u7075\u723B (HarmonyOS)",
|
|
3327
|
+
docsPath: "/channels/lingyao",
|
|
3328
|
+
docsLabel: "\u7075\u723B\u6587\u6863",
|
|
3329
|
+
blurb: "\u901A\u8FC7 lingyao.live \u670D\u52A1\u5668\u4E2D\u8F6C\u4E0E\u9E3F\u8499\u7075\u723B App \u53CC\u5411\u540C\u6B65\u65E5\u8BB0\u548C\u8BB0\u5FC6",
|
|
3330
|
+
order: 50,
|
|
3331
|
+
aliases: ["lingyao", "\u7075\u723B"]
|
|
3332
|
+
};
|
|
3333
|
+
function buildPlugin() {
|
|
3334
|
+
const composed = createChatChannelPlugin({
|
|
3335
|
+
base: {
|
|
3250
3336
|
id: "lingyao",
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
blurb: "\u901A\u8FC7 lingyao.live \u670D\u52A1\u5668\u4E2D\u8F6C\u4E0E\u9E3F\u8499\u7075\u723B App \u53CC\u5411\u540C\u6B65\u65E5\u8BB0\u548C\u8BB0\u5FC6",
|
|
3256
|
-
order: 50,
|
|
3257
|
-
aliases: ["lingyao", "\u7075\u723B"]
|
|
3258
|
-
},
|
|
3259
|
-
capabilities: {
|
|
3260
|
-
chatTypes: ["direct"],
|
|
3261
|
-
media: false,
|
|
3262
|
-
reactions: false,
|
|
3263
|
-
threads: false,
|
|
3264
|
-
polls: false,
|
|
3265
|
-
edit: false,
|
|
3266
|
-
unsend: false,
|
|
3267
|
-
reply: false,
|
|
3268
|
-
effects: false,
|
|
3269
|
-
groupManagement: false,
|
|
3270
|
-
nativeCommands: false,
|
|
3271
|
-
blockStreaming: true
|
|
3337
|
+
meta,
|
|
3338
|
+
capabilities,
|
|
3339
|
+
config: configAdapter,
|
|
3340
|
+
setup: setupAdapter
|
|
3272
3341
|
},
|
|
3273
|
-
|
|
3342
|
+
security: securityOptions,
|
|
3343
|
+
pairing: pairingOptions,
|
|
3344
|
+
outbound: outboundAdapter
|
|
3345
|
+
});
|
|
3346
|
+
return {
|
|
3347
|
+
...composed,
|
|
3274
3348
|
gateway: gatewayAdapter,
|
|
3275
|
-
|
|
3276
|
-
status: getStatusAdapter(runtime),
|
|
3349
|
+
status: statusAdapter ?? void 0,
|
|
3277
3350
|
directory: directoryAdapter,
|
|
3278
3351
|
messaging: messagingAdapter
|
|
3279
3352
|
};
|
|
3280
3353
|
}
|
|
3354
|
+
var index_default = defineChannelPluginEntry({
|
|
3355
|
+
id: "lingyao",
|
|
3356
|
+
name: "Lingyao",
|
|
3357
|
+
description: "Lingyao Channel Plugin - bidirectional sync via lingyao.live server relay",
|
|
3358
|
+
plugin: {
|
|
3359
|
+
get id() {
|
|
3360
|
+
return "lingyao";
|
|
3361
|
+
},
|
|
3362
|
+
get meta() {
|
|
3363
|
+
return buildPlugin().meta;
|
|
3364
|
+
},
|
|
3365
|
+
get capabilities() {
|
|
3366
|
+
return buildPlugin().capabilities;
|
|
3367
|
+
},
|
|
3368
|
+
get config() {
|
|
3369
|
+
return buildPlugin().config;
|
|
3370
|
+
},
|
|
3371
|
+
get setup() {
|
|
3372
|
+
return buildPlugin().setup;
|
|
3373
|
+
},
|
|
3374
|
+
get security() {
|
|
3375
|
+
return buildPlugin().security;
|
|
3376
|
+
},
|
|
3377
|
+
get pairing() {
|
|
3378
|
+
return buildPlugin().pairing;
|
|
3379
|
+
},
|
|
3380
|
+
get outbound() {
|
|
3381
|
+
return buildPlugin().outbound;
|
|
3382
|
+
},
|
|
3383
|
+
get gateway() {
|
|
3384
|
+
return buildPlugin().gateway;
|
|
3385
|
+
},
|
|
3386
|
+
get status() {
|
|
3387
|
+
if (!statusAdapter) return void 0;
|
|
3388
|
+
return statusAdapter;
|
|
3389
|
+
},
|
|
3390
|
+
get directory() {
|
|
3391
|
+
return buildPlugin().directory;
|
|
3392
|
+
},
|
|
3393
|
+
get messaging() {
|
|
3394
|
+
return buildPlugin().messaging;
|
|
3395
|
+
}
|
|
3396
|
+
},
|
|
3397
|
+
setRuntime(runtime) {
|
|
3398
|
+
const adapted = adaptPluginRuntime(runtime);
|
|
3399
|
+
setRuntime(adapted);
|
|
3400
|
+
orchestrator = new MultiAccountOrchestrator(adapted);
|
|
3401
|
+
statusAdapter = createStatusAdapter(getOrchestrator, adapted);
|
|
3402
|
+
}
|
|
3403
|
+
});
|
|
3281
3404
|
async function createPlugin(runtime, config = {}) {
|
|
3282
3405
|
const fullConfig = { ...getDefaultConfig(), ...config };
|
|
3283
3406
|
const validatedConfig = validateConfig(fullConfig);
|
|
@@ -3287,7 +3410,7 @@ async function createPlugin(runtime, config = {}) {
|
|
|
3287
3410
|
}
|
|
3288
3411
|
var pluginMetadata = {
|
|
3289
3412
|
name: "lingyao",
|
|
3290
|
-
version: "0.
|
|
3413
|
+
version: "0.4.0",
|
|
3291
3414
|
description: "Lingyao Channel Plugin - bidirectional sync via lingyao.live server relay",
|
|
3292
3415
|
type: "channel",
|
|
3293
3416
|
capabilities: {
|
|
@@ -3298,27 +3421,6 @@ var pluginMetadata = {
|
|
|
3298
3421
|
},
|
|
3299
3422
|
defaultConfig: getDefaultConfig()
|
|
3300
3423
|
};
|
|
3301
|
-
var pluginEntry = {
|
|
3302
|
-
id: "lingyao",
|
|
3303
|
-
name: "Lingyao",
|
|
3304
|
-
description: "Lingyao Channel Plugin - bidirectional sync via lingyao.live",
|
|
3305
|
-
setRuntime(runtime) {
|
|
3306
|
-
const rt = runtime;
|
|
3307
|
-
setRuntime(rt);
|
|
3308
|
-
orchestrator = new MultiAccountOrchestrator(rt);
|
|
3309
|
-
},
|
|
3310
|
-
get plugin() {
|
|
3311
|
-
const rt = orchestrator?.runtime;
|
|
3312
|
-
if (!rt) {
|
|
3313
|
-
throw new Error("Runtime not set. Call setRuntime() before accessing plugin.");
|
|
3314
|
-
}
|
|
3315
|
-
return buildPluginBase(rt);
|
|
3316
|
-
},
|
|
3317
|
-
// Security and pairing options for createChatChannelPlugin composition
|
|
3318
|
-
security: securityOptions,
|
|
3319
|
-
pairing: pairingOptions
|
|
3320
|
-
};
|
|
3321
|
-
var index_default = pluginEntry;
|
|
3322
3424
|
export {
|
|
3323
3425
|
LINGYAO_SERVER_URL,
|
|
3324
3426
|
LingyaoChannel,
|