@honor-claw/yoyo 1.6.0-beta.3 → 1.6.1-alpha.1
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.
|
@@ -3,6 +3,8 @@ import { getProxyUrl as t, shouldUseProxy as n } from "../utils/proxy.mjs";
|
|
|
3
3
|
import { ProxyAgent as r, request as i } from "undici";
|
|
4
4
|
//#region src/apis/http-client.ts
|
|
5
5
|
var a = class extends Error {
|
|
6
|
+
status;
|
|
7
|
+
data;
|
|
6
8
|
constructor(e, t, n) {
|
|
7
9
|
super(n), this.status = e, this.data = t, this.name = "HttpError";
|
|
8
10
|
}
|
|
@@ -10,14 +10,23 @@ import { STATE_FLAG as c, hasPersistedStateFlag as l, markPersistedStateFlag as
|
|
|
10
10
|
var d = "yoyo", f = /* @__PURE__ */ "alarm.create,alarm.delete,alarm.disable,alarm.enable,alarm.query,alarm.update,app.close,app.open,call.phone,call.search,capture-screenshot,contact.search,file-upload,hotspot,local-search,message.search,message.send,mobile-data,no-disturb,quiet-mode,ringing-mode,schedule.create,schedule.delete,schedule.search,schedule.update,screen-record,vibration-mode,volume.operate,wlan,bluetooth,location-service,nfc,usb-shared-network,eyecomfort,status-bar-show,brightness,autoscreen-onnotice,dark-mode,device-operation,camera,app.uninstall,audio-record,battery,gui.create,gui.pause,gui.terminate,mcp.tool.call,task_result_query".split(","), p = class {
|
|
11
11
|
loadConfig() {
|
|
12
12
|
try {
|
|
13
|
-
|
|
13
|
+
let e = t().config, n = e.current;
|
|
14
|
+
return typeof n == "function" ? structuredClone(n()) : structuredClone(e.loadConfig());
|
|
14
15
|
} catch (e) {
|
|
15
16
|
throw i(e, "Failed to load config");
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
async saveConfig(e) {
|
|
19
20
|
try {
|
|
20
|
-
|
|
21
|
+
let n = t().config, r = n.replaceConfigFile;
|
|
22
|
+
if (typeof r == "function") {
|
|
23
|
+
await r({
|
|
24
|
+
nextConfig: e,
|
|
25
|
+
afterWrite: { mode: "auto" }
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
await n.writeConfigFile(e);
|
|
21
30
|
} catch (e) {
|
|
22
31
|
throw i(e, "Failed to save config");
|
|
23
32
|
}
|
|
@@ -4,70 +4,68 @@ import { safeReadFile as n, safeWriteFile as r } from "../../utils/fs-safe.mjs";
|
|
|
4
4
|
import { resolveEffectiveHomeDir as i } from "../../utils/home-dir.mjs";
|
|
5
5
|
import a from "node:path";
|
|
6
6
|
//#region src/modules/configs/identity-persist.ts
|
|
7
|
-
var o =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function d() {
|
|
11
|
-
return a.join(s, c, l);
|
|
7
|
+
var o = ".openclaw", s = "yoyo", c = "identity.json", l = 6e4;
|
|
8
|
+
function u() {
|
|
9
|
+
return a.join(o, s, c);
|
|
12
10
|
}
|
|
13
|
-
async function
|
|
14
|
-
let r =
|
|
11
|
+
async function d(t) {
|
|
12
|
+
let r = u();
|
|
15
13
|
try {
|
|
16
14
|
let e = (await n({
|
|
17
15
|
rootDir: t,
|
|
18
16
|
relativePath: r,
|
|
19
17
|
maxBytes: 10 * 1024
|
|
20
18
|
})).buffer.toString("utf8"), i = JSON.parse(e);
|
|
21
|
-
return typeof i != "object" || !i ?
|
|
22
|
-
...
|
|
19
|
+
return typeof i != "object" || !i ? _() : {
|
|
20
|
+
..._(),
|
|
23
21
|
...i
|
|
24
22
|
};
|
|
25
23
|
} catch (t) {
|
|
26
24
|
return e(t, "[yoyo-identity] failed to read identity"), null;
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
|
-
async function
|
|
27
|
+
async function f() {
|
|
30
28
|
let e = i();
|
|
31
|
-
return e ? await
|
|
29
|
+
return e ? await d(e) || null : (t().warn("[yoyo-identity] failed to find home dir"), null);
|
|
32
30
|
}
|
|
33
|
-
async function
|
|
31
|
+
async function p(e) {
|
|
34
32
|
let n = i();
|
|
35
33
|
if (!n) return t().warn("[yoyo-identity] failed to find home dir"), null;
|
|
36
|
-
let a = await
|
|
34
|
+
let a = await d(n), o = {
|
|
37
35
|
...a,
|
|
38
|
-
version: a?.version ||
|
|
36
|
+
version: a?.version || 2
|
|
39
37
|
};
|
|
40
|
-
return e.legacyDeviceId && (
|
|
38
|
+
return e.legacyDeviceId && (o.legacyDeviceId = e.legacyDeviceId), e.deviceId && (o.deviceId = e.deviceId, o.publicKeyPem = e.publicKeyPem, o.privateKeyPem = e.privateKeyPem, o.createdAtMs = e.createdAtMs), e.version && (o.version = e.version), "gatewayAuthMd5" in e && (o.gatewayAuthMd5 = e.gatewayAuthMd5), "pluginVersionCode" in e && (o.pluginVersionCode = e.pluginVersionCode), "authorizationCache" in e && (o.authorizationCache = e.authorizationCache), await r({
|
|
41
39
|
rootDir: n,
|
|
42
|
-
relativePath:
|
|
43
|
-
data: JSON.stringify(
|
|
40
|
+
relativePath: u(),
|
|
41
|
+
data: JSON.stringify(o, null, 2),
|
|
44
42
|
encoding: "utf8",
|
|
45
43
|
mkdir: !0
|
|
46
|
-
}),
|
|
44
|
+
}), o;
|
|
47
45
|
}
|
|
48
|
-
function
|
|
46
|
+
function m(e) {
|
|
49
47
|
let t = typeof e == "number" ? e : typeof e == "string" && e.trim() ? Number(e) : 0;
|
|
50
|
-
return !Number.isFinite(t) || t <
|
|
48
|
+
return !Number.isFinite(t) || t < l ? 0 : Math.floor(t);
|
|
51
49
|
}
|
|
52
|
-
async function
|
|
53
|
-
let r = await
|
|
50
|
+
async function h(e, t, n = Date.now()) {
|
|
51
|
+
let r = await p({ authorizationCache: {
|
|
54
52
|
jwtToken: e,
|
|
55
53
|
receivedAtMs: n,
|
|
56
|
-
expireMs:
|
|
54
|
+
expireMs: m(t)
|
|
57
55
|
} });
|
|
58
56
|
if (!r) throw Error("failed to write authorization cache");
|
|
59
57
|
return r;
|
|
60
58
|
}
|
|
61
|
-
async function
|
|
62
|
-
let e = await
|
|
63
|
-
return t?.jwtToken ?
|
|
59
|
+
async function g() {
|
|
60
|
+
let e = await f(), t = e?.authorizationCache;
|
|
61
|
+
return t?.jwtToken ? p({ authorizationCache: {
|
|
64
62
|
jwtToken: void 0,
|
|
65
63
|
receivedAtMs: t.receivedAtMs,
|
|
66
|
-
expireMs:
|
|
64
|
+
expireMs: m(t.expireMs)
|
|
67
65
|
} }) : e;
|
|
68
66
|
}
|
|
69
|
-
function
|
|
70
|
-
return { version:
|
|
67
|
+
function _() {
|
|
68
|
+
return { version: 2 };
|
|
71
69
|
}
|
|
72
70
|
//#endregion
|
|
73
|
-
export {
|
|
71
|
+
export { h as cacheAuthorizationToken, g as clearCachedAuthorizationToken, f as getPersistedIdentity, m as parseAuthorizationExpireMs, p as updatePersistedIdentity };
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honor-claw/yoyo",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1-alpha.1",
|
|
4
4
|
"description": "OpenClaw Honor Yoyo connection plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "vite build",
|
|
28
28
|
"ci:check": "npx tsc --noEmit && npm run test:coverage",
|
|
29
|
+
"format": "oxfmt",
|
|
30
|
+
"format:fix": "oxfmt --write",
|
|
31
|
+
"lint": "oxlint src/",
|
|
32
|
+
"lint:fix": "oxlint --fix src/",
|
|
29
33
|
"publish:alpha": "npm run build && node scripts/publish.js --alpha",
|
|
30
34
|
"publish:beta": "npm run build && node scripts/publish.js",
|
|
31
35
|
"publish:latest": "npm run build && node scripts/publish.js --release",
|
|
@@ -49,6 +53,8 @@
|
|
|
49
53
|
"@types/node": "^25.0.10",
|
|
50
54
|
"@types/ws": "^8.5.13",
|
|
51
55
|
"@vitest/coverage-v8": "^2.1.8",
|
|
56
|
+
"oxfmt": "^0.55.0",
|
|
57
|
+
"oxlint": "^1.70.0",
|
|
52
58
|
"typescript": "^6.0.2",
|
|
53
59
|
"vite": "^8.0.10",
|
|
54
60
|
"vitest": "^2.1.8"
|