@lingyao037/openclaw-lingyao-cli 0.3.5 → 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/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,9 +88,10 @@ 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: Object.freeze(accountConfig?.allowFrom ?? []),
94
+ allowFrom: accountConfig?.allowFrom ?? [],
40
95
  rawConfig: accountConfig
41
96
  };
42
97
  },
@@ -268,6 +323,20 @@ function createOutboundAdapter(getOrchestrator2) {
268
323
  };
269
324
  }
270
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
+
271
340
  // src/orchestrator.ts
272
341
  import { hostname } from "os";
273
342
 
@@ -345,7 +414,7 @@ var ServerHttpClient = class {
345
414
  /**
346
415
  * 注册 Gateway 到服务器
347
416
  */
348
- async register(capabilities = {}) {
417
+ async register(capabilities2 = {}) {
349
418
  if (this.isConnecting) {
350
419
  throw new Error("Registration already in progress");
351
420
  }
@@ -360,7 +429,7 @@ var ServerHttpClient = class {
360
429
  capabilities: {
361
430
  websocket: false,
362
431
  compression: false,
363
- ...capabilities
432
+ ...capabilities2
364
433
  }
365
434
  }
366
435
  );
@@ -3202,17 +3271,12 @@ function getOrchestrator() {
3202
3271
  return orchestrator;
3203
3272
  }
3204
3273
  var configAdapter = createConfigAdapter();
3274
+ var setupAdapter = createSetupAdapter();
3205
3275
  var messagingAdapter = createMessagingAdapter();
3206
3276
  var gatewayAdapter = createGatewayAdapter(getOrchestrator);
3207
3277
  var directoryAdapter = createDirectoryAdapter(getOrchestrator);
3208
3278
  var outboundAdapter = createOutboundAdapter(getOrchestrator);
3209
3279
  var statusAdapter = null;
3210
- function getStatusAdapter(runtime) {
3211
- if (!statusAdapter) {
3212
- statusAdapter = createStatusAdapter(getOrchestrator, runtime);
3213
- }
3214
- return statusAdapter;
3215
- }
3216
3280
  var securityOptions = {
3217
3281
  dm: {
3218
3282
  channelKey: "lingyao",
@@ -3242,41 +3306,101 @@ var pairingOptions = {
3242
3306
  }
3243
3307
  }
3244
3308
  };
3245
- function buildPluginBase(runtime) {
3246
- return {
3247
- id: "lingyao",
3248
- meta: {
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: {
3249
3336
  id: "lingyao",
3250
- label: "\u7075\u723B",
3251
- selectionLabel: "\u7075\u723B (HarmonyOS)",
3252
- docsPath: "/channels/lingyao",
3253
- docsLabel: "\u7075\u723B\u6587\u6863",
3254
- 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",
3255
- order: 50,
3256
- aliases: ["lingyao", "\u7075\u723B"]
3257
- },
3258
- capabilities: {
3259
- chatTypes: ["direct"],
3260
- media: false,
3261
- reactions: false,
3262
- threads: false,
3263
- polls: false,
3264
- edit: false,
3265
- unsend: false,
3266
- reply: false,
3267
- effects: false,
3268
- groupManagement: false,
3269
- nativeCommands: false,
3270
- blockStreaming: true
3337
+ meta,
3338
+ capabilities,
3339
+ config: configAdapter,
3340
+ setup: setupAdapter
3271
3341
  },
3272
- config: configAdapter,
3342
+ security: securityOptions,
3343
+ pairing: pairingOptions,
3344
+ outbound: outboundAdapter
3345
+ });
3346
+ return {
3347
+ ...composed,
3273
3348
  gateway: gatewayAdapter,
3274
- outbound: outboundAdapter,
3275
- status: getStatusAdapter(runtime),
3349
+ status: statusAdapter ?? void 0,
3276
3350
  directory: directoryAdapter,
3277
3351
  messaging: messagingAdapter
3278
3352
  };
3279
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
+ });
3280
3404
  async function createPlugin(runtime, config = {}) {
3281
3405
  const fullConfig = { ...getDefaultConfig(), ...config };
3282
3406
  const validatedConfig = validateConfig(fullConfig);
@@ -3286,7 +3410,7 @@ async function createPlugin(runtime, config = {}) {
3286
3410
  }
3287
3411
  var pluginMetadata = {
3288
3412
  name: "lingyao",
3289
- version: "0.3.0",
3413
+ version: "0.4.0",
3290
3414
  description: "Lingyao Channel Plugin - bidirectional sync via lingyao.live server relay",
3291
3415
  type: "channel",
3292
3416
  capabilities: {
@@ -3297,27 +3421,6 @@ var pluginMetadata = {
3297
3421
  },
3298
3422
  defaultConfig: getDefaultConfig()
3299
3423
  };
3300
- var pluginEntry = {
3301
- id: "lingyao",
3302
- name: "Lingyao",
3303
- description: "Lingyao Channel Plugin - bidirectional sync via lingyao.live",
3304
- setRuntime(runtime) {
3305
- const rt = runtime;
3306
- setRuntime(rt);
3307
- orchestrator = new MultiAccountOrchestrator(rt);
3308
- },
3309
- get plugin() {
3310
- const rt = orchestrator?.runtime;
3311
- if (!rt) {
3312
- throw new Error("Runtime not set. Call setRuntime() before accessing plugin.");
3313
- }
3314
- return buildPluginBase(rt);
3315
- },
3316
- // Security and pairing options for createChatChannelPlugin composition
3317
- security: securityOptions,
3318
- pairing: pairingOptions
3319
- };
3320
- var index_default = pluginEntry;
3321
3424
  export {
3322
3425
  LINGYAO_SERVER_URL,
3323
3426
  LingyaoChannel,