@lingyao037/openclaw-lingyao-cli 0.9.3 → 0.9.5

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/cli.mjs CHANGED
@@ -478,7 +478,52 @@ class LingyaoInstaller {
478
478
  }
479
479
 
480
480
  // HTTP helpers
481
+ hasProxyEnv() {
482
+ return Boolean(
483
+ process.env.HTTPS_PROXY ||
484
+ process.env.https_proxy ||
485
+ process.env.HTTP_PROXY ||
486
+ process.env.http_proxy ||
487
+ process.env.ALL_PROXY ||
488
+ process.env.all_proxy
489
+ );
490
+ }
491
+
492
+ curlJson(method, path, body = null) {
493
+ return new Promise((resolve, reject) => {
494
+ const url = `${LINGYAO_API}${path}`;
495
+ const args = ['-sS', '-X', method, url, '-H', 'Content-Type: application/json'];
496
+ if (this.gatewayToken) {
497
+ args.push('-H', `Authorization: Bearer ${this.gatewayToken}`);
498
+ }
499
+ if (body !== null) {
500
+ args.push('-d', JSON.stringify(body));
501
+ }
502
+
503
+ const child = spawn('curl', args, { stdio: ['ignore', 'pipe', 'pipe'], shell: false });
504
+ let stdout = '';
505
+ let stderr = '';
506
+ child.stdout.on('data', (chunk) => { stdout += chunk.toString(); });
507
+ child.stderr.on('data', (chunk) => { stderr += chunk.toString(); });
508
+ child.on('error', (error) => reject(error));
509
+ child.on('close', (code) => {
510
+ if (code !== 0) {
511
+ reject(new Error(stderr.trim() || `curl exited with code ${code}`));
512
+ return;
513
+ }
514
+ try {
515
+ resolve(JSON.parse(stdout));
516
+ } catch {
517
+ reject(new Error(`Invalid JSON: ${stdout}`));
518
+ }
519
+ });
520
+ });
521
+ }
522
+
481
523
  httpsPost(path, body) {
524
+ if (this.hasProxyEnv()) {
525
+ return this.curlJson('POST', path, body);
526
+ }
482
527
  return new Promise((resolve, reject) => {
483
528
  const data = JSON.stringify(body);
484
529
  const url = `${LINGYAO_API}${path}`;
@@ -504,6 +549,9 @@ class LingyaoInstaller {
504
549
  }
505
550
 
506
551
  httpsGet(path) {
552
+ if (this.hasProxyEnv()) {
553
+ return this.curlJson('GET', path, null);
554
+ }
507
555
  return new Promise((resolve, reject) => {
508
556
  const url = `${LINGYAO_API}${path}`;
509
557
  const req = https.get(url, { timeout: 10000 }, (res) => {
@@ -0,0 +1,80 @@
1
+ import { L as LingyaoRuntime, g as LingyaoAccount, c as DeviceToken, D as DeviceInfo } from './types-Zbv12l39.js';
2
+
3
+ /**
4
+ * Account storage and management
5
+ */
6
+ declare class AccountManager {
7
+ private runtime;
8
+ private accounts;
9
+ private pendingPairings;
10
+ constructor(runtime: LingyaoRuntime);
11
+ /**
12
+ * Initialize account manager from storage
13
+ */
14
+ initialize(): Promise<void>;
15
+ /**
16
+ * Get account by device ID
17
+ */
18
+ getAccount(deviceId: string): LingyaoAccount | undefined;
19
+ /**
20
+ * Get account by device token
21
+ */
22
+ getAccountByToken(token: string): LingyaoAccount | undefined;
23
+ /**
24
+ * Get all active accounts
25
+ */
26
+ getActiveAccounts(): LingyaoAccount[];
27
+ /**
28
+ * Create a new pairing session
29
+ */
30
+ createPairingSession(code: string, expiresAt: number): Promise<void>;
31
+ /**
32
+ * Get pairing session by code
33
+ */
34
+ getPairingSession(code: string): PairingSession | undefined;
35
+ /**
36
+ * Remove a pending pairing (e.g. expired or cancelled)
37
+ */
38
+ deletePendingPairing(code: string): Promise<void>;
39
+ /**
40
+ * Confirm pairing and create account
41
+ */
42
+ confirmPairing(pairingCode: string, deviceToken: DeviceToken, deviceInfo: DeviceInfo): Promise<LingyaoAccount | null>;
43
+ /**
44
+ * Update account's last seen timestamp
45
+ */
46
+ updateLastSeen(deviceId: string): Promise<void>;
47
+ /**
48
+ * Revoke an account
49
+ */
50
+ revokeAccount(deviceId: string): Promise<boolean>;
51
+ /**
52
+ * Manually add a device by deviceId (user-initiated pairing).
53
+ * No pairing code or deviceToken required — the user explicitly
54
+ * trusts this device from the OpenClaw CLI.
55
+ */
56
+ addDevice(deviceId: string, deviceInfo: DeviceInfo): Promise<LingyaoAccount>;
57
+ /**
58
+ * Refresh device token
59
+ */
60
+ refreshDeviceToken(deviceId: string, newToken: DeviceToken): Promise<boolean>;
61
+ /**
62
+ * Clean up expired accounts
63
+ */
64
+ cleanupExpired(): Promise<void>;
65
+ /**
66
+ * Save accounts to storage
67
+ */
68
+ private saveAccounts;
69
+ /**
70
+ * Save pending pairings to storage
71
+ */
72
+ private savePendingPairings;
73
+ }
74
+ interface PairingSession {
75
+ code: string;
76
+ createdAt: number;
77
+ expiresAt: number;
78
+ }
79
+
80
+ export { AccountManager as A };
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { L as LingyaoRuntime, H as HealthStatus, A as AccountManager } from './accounts-B9ijYIIu.js';
1
+ import { L as LingyaoRuntime, H as HealthStatus } from './types-Zbv12l39.js';
2
+ import { A as AccountManager } from './accounts-CzjBLXMH.js';
2
3
 
3
4
  /**
4
5
  * Probe status levels