@honor-claw/yoyo 2026.9.2-beta.2 → 2026.9.3-alpha.2
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/capabilities/cloud-invoke/invoke.mjs +11 -11
- package/dist/capabilities/cron/delivery-capture.mjs +49 -0
- package/dist/capabilities/cron/events.mjs +93 -0
- package/dist/capabilities/cron/index.mjs +3 -0
- package/dist/capabilities/cron/service.mjs +140 -0
- package/dist/capabilities/node/device-target.mjs +49 -0
- package/dist/capabilities/node/index.mjs +1 -0
- package/dist/capabilities/node/invoke.mjs +4 -4
- package/dist/capabilities/node/list.mjs +9 -9
- package/dist/capabilities/remote-file/remote-file.mjs +11 -11
- package/dist/channel/lifecycle.mjs +1 -1
- package/dist/cli/login/impl.mjs +12 -11
- package/dist/cloud-channel/channel.mjs +34 -33
- package/dist/cloud-channel/handlers/context/cron.mjs +58 -0
- package/dist/cloud-channel/handlers/context/handler.mjs +56 -50
- package/dist/cloud-channel/handlers/push-inbound.mjs +8 -0
- package/dist/cloud-channel/protocol/v2-adapter.mjs +3 -1
- package/dist/command/help.mjs +9 -6
- package/dist/command/index.mjs +15 -12
- package/dist/command/mock/handler.mjs +92 -0
- package/dist/command/mock/help.mjs +10 -0
- package/dist/command/mock/index.mjs +3 -0
- package/dist/command/mock/parser.mjs +18 -0
- package/dist/command/parser.mjs +14 -10
- package/dist/core/hooks/cron-observer.mjs +26 -0
- package/dist/core/hooks/entry.mjs +8 -7
- package/dist/core/hooks/gateway-lifecycle.mjs +13 -10
- package/dist/core/hooks/prompt.mjs +1 -1
- package/dist/core/prompt/builder.mjs +12 -8
- package/dist/core/prompt/cron.mjs +19 -0
- package/dist/core/prompt/location.mjs +7 -0
- package/dist/diagnose/collectors/account.mjs +1 -1
- package/dist/honor-auth/browser/flow.mjs +13 -13
- package/dist/honor-auth/login/impl.mjs +4 -4
- package/dist/honor-auth/logout.mjs +7 -7
- package/dist/honor-auth/vault/legacy-migration.mjs +8 -8
- package/dist/messaging/dispatchers/stream/session.mjs +38 -38
- package/dist/messaging/inbound/context.mjs +19 -18
- package/dist/messaging/index.mjs +6 -0
- package/dist/messaging/notification/inbound.mjs +66 -0
- package/dist/messaging/notification/index.mjs +4 -0
- package/dist/messaging/notification/notify.mjs +28 -0
- package/dist/messaging/notification/outbox.mjs +148 -0
- package/dist/messaging/notification/types.mjs +6 -0
- package/dist/messaging/send/frame.mjs +36 -17
- package/dist/messaging/send/text.mjs +14 -16
- package/dist/messaging/target/address.mjs +14 -11
- package/dist/messaging/target/index.mjs +1 -0
- package/dist/messaging/target/outbound.mjs +20 -13
- package/dist/modules/configs/agent-defaults.mjs +15 -12
- package/dist/modules/configs/index.mjs +1 -0
- package/dist/modules/configs/owner-allow-from.mjs +53 -0
- package/dist/modules/configs/plugin-init.mjs +1 -1
- package/dist/modules/device/device-info.mjs +1 -1
- package/dist/provisioning/registration/register.mjs +8 -8
- package/dist/schemas.mjs +5 -1
- package/dist/tools/index.mjs +5 -3
- package/dist/tools/remote-file-upload/run.mjs +19 -19
- package/dist/tools/send-message/index.mjs +2 -0
- package/dist/tools/send-message/tool.mjs +71 -0
- package/dist/tools/send-message/types.mjs +8 -0
- package/openclaw.plugin.json +2 -1
- package/package.json +1 -1
- package/skills/yoyo-phone-control/SKILL.md +319 -0
- package/skills/yoyo-phone-control/mcptools/adjust_brightness.json +10 -10
- package/skills/yoyo-phone-control/mcptools/create_schedule.json +3 -3
- package/skills/yoyo-phone-control/mcptools/device_operation.json +2 -2
- package/skills/yoyo-phone-control/mcptools/memorySearch.json +100 -0
- package/skills/yoyo-phone-control/mcptools/modify_schedule.json +0 -8
- package/skills/yoyo-phone-control/mcptools/screen_recorder.json +1 -1
- package/skills/yoyo-phone-control/mcptools/search_message.json +21 -5
- package/skills/yoyo-phone-control/mcptools/vibration_mode.json +1 -1
- package/skills/yoyo-phone-control/mcptools/volume.json +12 -12
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { toErrorMessage as e } from "../../utils/error.mjs";
|
|
2
2
|
import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { createClawCloudClient as n } from "../../apis/claw-cloud.mjs";
|
|
4
|
+
import "../../apis/index.mjs";
|
|
5
|
+
import { HonorAccount as r } from "../../honor-auth/vault/impl.mjs";
|
|
5
6
|
import { loadDeviceInfo as i } from "../../modules/device/device-info.mjs";
|
|
6
7
|
import "../../modules/device/index.mjs";
|
|
7
8
|
import "../../honor-auth/vault/index.mjs";
|
|
8
|
-
import "../../apis/index.mjs";
|
|
9
9
|
import { ToolError as a } from "../../tools/error.mjs";
|
|
10
10
|
//#region src/capabilities/cloud-invoke/invoke.ts
|
|
11
11
|
var o = t("capabilities");
|
|
12
12
|
async function s(t) {
|
|
13
|
-
let s = await
|
|
13
|
+
let s = await r.fromUser().current();
|
|
14
14
|
if (!s?.token || !s.userId) throw o.error("cloud invoke skipped: no current user"), new a("unauthorized", "missing current user token");
|
|
15
15
|
let c;
|
|
16
16
|
try {
|
|
@@ -19,19 +19,19 @@ async function s(t) {
|
|
|
19
19
|
throw o.error("cloud invoke failed to get device info", e), new a("ctx missing", "failed to get device info", { cause: e });
|
|
20
20
|
}
|
|
21
21
|
try {
|
|
22
|
-
let e = await
|
|
22
|
+
let e = await n().invokeCloudTool(c, s, {
|
|
23
23
|
serviceId: t.toolId,
|
|
24
24
|
pluginParams: t.params ?? {},
|
|
25
25
|
...t.timeoutMs === void 0 ? {} : { timeoutMs: t.timeoutMs }
|
|
26
|
-
}),
|
|
26
|
+
}), r = e.data, i = e.status >= 200 && e.status < 300, l = r?.code === "0", u = r?.code === "ICS-500";
|
|
27
27
|
if (!i || !l && !u) throw o.error("cloud invoke response not ok", null, {
|
|
28
28
|
status: e.status,
|
|
29
|
-
code:
|
|
30
|
-
cnMessage:
|
|
31
|
-
cpErrorCode:
|
|
32
|
-
}), new a("api_failed", `code=${
|
|
29
|
+
code: r?.code,
|
|
30
|
+
cnMessage: r?.cnMessage,
|
|
31
|
+
cpErrorCode: r?.data?.cpErrorCode
|
|
32
|
+
}), new a("api_failed", `code=${r?.code ?? "-"} cpErrorCode=${r?.data?.cpErrorCode ?? "-"} message=${r?.cnMessage ?? "-"}`);
|
|
33
33
|
return {
|
|
34
|
-
...
|
|
34
|
+
...r.data === void 0 ? {} : { pluginResponse: r.data },
|
|
35
35
|
code: e.data.code,
|
|
36
36
|
cnMessage: e.data.cnMessage
|
|
37
37
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { clawLogger as e } from "../../utils/claw-logger.mjs";
|
|
2
|
+
import { resolveChatIdFromTo as t } from "../../messaging/target/outbound.mjs";
|
|
3
|
+
import "../../messaging/target/index.mjs";
|
|
4
|
+
import { findCronJobById as n } from "./service.mjs";
|
|
5
|
+
//#region src/capabilities/cron/delivery-capture.ts
|
|
6
|
+
var r = e("cron"), i = /* @__PURE__ */ new Map(), a = 360 * 60 * 1e3;
|
|
7
|
+
async function o(e) {
|
|
8
|
+
d();
|
|
9
|
+
let a = u((await n(e))?.delivery);
|
|
10
|
+
if (a === void 0) {
|
|
11
|
+
r.debug("cron job delivery capture missed", { jobId: e });
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
let o = await t(a);
|
|
15
|
+
if (o === void 0) {
|
|
16
|
+
r.debug("cron job delivery capture skipped: target not a yoyo chat", {
|
|
17
|
+
jobId: e,
|
|
18
|
+
to: a
|
|
19
|
+
});
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
i.set(e, {
|
|
23
|
+
chatId: o,
|
|
24
|
+
capturedAtMs: Date.now()
|
|
25
|
+
}), r.debug("cron job delivery captured", {
|
|
26
|
+
jobId: e,
|
|
27
|
+
chatId: o
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function s(e) {
|
|
31
|
+
let t = i.get(e);
|
|
32
|
+
if (t !== void 0) return i.delete(e), t.chatId;
|
|
33
|
+
}
|
|
34
|
+
function c(e) {
|
|
35
|
+
i.delete(e);
|
|
36
|
+
}
|
|
37
|
+
async function l(e) {
|
|
38
|
+
let r = u((await n(e))?.delivery);
|
|
39
|
+
if (r !== void 0) return t(r);
|
|
40
|
+
}
|
|
41
|
+
function u(e) {
|
|
42
|
+
if (!(typeof e?.to != "string" || e.to.length === 0 || e.mode === "none")) return e.to;
|
|
43
|
+
}
|
|
44
|
+
function d() {
|
|
45
|
+
let e = Date.now() - a;
|
|
46
|
+
for (let [t, n] of i) n.capturedAtMs < e && i.delete(t);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { o as captureCronJobDelivery, c as clearCapturedCronJobDelivery, l as findCronJobDeliveryChatId, s as takeCapturedCronJobDelivery };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { toErrorMessage as e } from "../../utils/error.mjs";
|
|
2
|
+
import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
3
|
+
import { uuid as n } from "../../utils/id.mjs";
|
|
4
|
+
import { buildChatTo as r, readChatIdFromSessionKey as i } from "../../messaging/target/address.mjs";
|
|
5
|
+
import { resolveOutboundTarget as a } from "../../messaging/target/outbound.mjs";
|
|
6
|
+
import "../../messaging/target/index.mjs";
|
|
7
|
+
import { pushNotification as o } from "../../messaging/notification/notify.mjs";
|
|
8
|
+
import { CronRunStatus as s } from "../../messaging/notification/types.mjs";
|
|
9
|
+
import "../../messaging/notification/index.mjs";
|
|
10
|
+
import { findCronJobDeliveryChatId as c } from "./delivery-capture.mjs";
|
|
11
|
+
import { stringifyValue as l } from "../../utils/stringify.mjs";
|
|
12
|
+
//#region src/capabilities/cron/events.ts
|
|
13
|
+
var u = t("cron");
|
|
14
|
+
async function d(t, n) {
|
|
15
|
+
try {
|
|
16
|
+
u.info("cron finished event received", {
|
|
17
|
+
jobId: t.jobId,
|
|
18
|
+
status: t.status,
|
|
19
|
+
name: t.job?.name,
|
|
20
|
+
runAtMs: t.runAtMs,
|
|
21
|
+
durationMs: t.durationMs,
|
|
22
|
+
sessionKey: t.sessionKey
|
|
23
|
+
});
|
|
24
|
+
let s = i(t.sessionKey), d = s ?? n ?? await c(t.jobId);
|
|
25
|
+
if (d === void 0) {
|
|
26
|
+
let e = {
|
|
27
|
+
jobId: t.jobId,
|
|
28
|
+
name: t.job?.name,
|
|
29
|
+
sessionKey: t.sessionKey ?? null,
|
|
30
|
+
sessionTarget: t.sessionTarget ?? null,
|
|
31
|
+
jobSessionTarget: t.job?.sessionTarget ?? null,
|
|
32
|
+
agentId: t.agentId ?? null,
|
|
33
|
+
sessionId: t.sessionId ?? null,
|
|
34
|
+
runId: t.runId ?? null
|
|
35
|
+
};
|
|
36
|
+
if (t.job?.payload?.kind === "heartbeat") {
|
|
37
|
+
u.debug("cron finished not routable: built-in heartbeat has no yoyo target, skip push", e);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
u.warn("cron finished event not routable: no yoyo session and no job delivery, skip push", e), u.debug("cron finished event raw payload", {
|
|
41
|
+
jobId: t.jobId,
|
|
42
|
+
raw: l(t)
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
let p;
|
|
47
|
+
try {
|
|
48
|
+
p = await a(r(d));
|
|
49
|
+
} catch (n) {
|
|
50
|
+
u.warn("cron finished event not routable: chatId unresolvable, skip push", {
|
|
51
|
+
jobId: t.jobId,
|
|
52
|
+
chatId: d,
|
|
53
|
+
error: e(n)
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
u.info("cron push target resolved", {
|
|
58
|
+
jobId: t.jobId,
|
|
59
|
+
chatId: d,
|
|
60
|
+
routedBy: s ? "sessionKey" : n === void 0 ? "listDelivery" : "capturedDelivery",
|
|
61
|
+
accountId: p.accountId,
|
|
62
|
+
deviceId: p.deviceId
|
|
63
|
+
});
|
|
64
|
+
let m = f(t), h = await o(p, m);
|
|
65
|
+
u.info("cron finished push dispatched", {
|
|
66
|
+
jobId: t.jobId,
|
|
67
|
+
notificationId: m.id,
|
|
68
|
+
realtimeSent: h !== null,
|
|
69
|
+
queued: h === null
|
|
70
|
+
});
|
|
71
|
+
} catch (e) {
|
|
72
|
+
u.error("failed to push cron finished event", e, { jobId: t.jobId });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function f(e) {
|
|
76
|
+
let t = e.status === "error", r = e.runAtMs != null && e.durationMs != null ? e.runAtMs + e.durationMs : Date.now();
|
|
77
|
+
return {
|
|
78
|
+
id: n(),
|
|
79
|
+
type: "cron",
|
|
80
|
+
severity: t ? "error" : "info",
|
|
81
|
+
occurredAt: r,
|
|
82
|
+
ack: !0,
|
|
83
|
+
cron: {
|
|
84
|
+
jobId: e.jobId,
|
|
85
|
+
name: e.job?.name ?? e.jobId,
|
|
86
|
+
status: t ? s.Failed : s.Success,
|
|
87
|
+
...e.summary === void 0 ? {} : { summary: e.summary },
|
|
88
|
+
...t && e.error ? { error: e.error } : {}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
export { d as pushCronFinishedEvent };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { toErrorMessage as e } from "../../utils/error.mjs";
|
|
2
|
+
import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
3
|
+
import { findChatId as n } from "../../messaging/target/chat-id-store.mjs";
|
|
4
|
+
import { resolveChatIdFromTo as r } from "../../messaging/target/outbound.mjs";
|
|
5
|
+
import "../../messaging/target/index.mjs";
|
|
6
|
+
import { CronRunStatus as i } from "../../messaging/notification/types.mjs";
|
|
7
|
+
import "../../messaging/notification/index.mjs";
|
|
8
|
+
//#region src/capabilities/cron/service.ts
|
|
9
|
+
var a = t("cron"), o = 50, s;
|
|
10
|
+
function c(e) {
|
|
11
|
+
s = e, a.info("cron service handle updated", { available: e !== void 0 });
|
|
12
|
+
}
|
|
13
|
+
function l() {
|
|
14
|
+
s = void 0;
|
|
15
|
+
}
|
|
16
|
+
async function u(t, r) {
|
|
17
|
+
let i = await n(t, r);
|
|
18
|
+
if (!i) return a.info("cron list: request device has no chat mapping, empty result", {
|
|
19
|
+
accountId: t,
|
|
20
|
+
requestDeviceId: r
|
|
21
|
+
}), {
|
|
22
|
+
ok: !0,
|
|
23
|
+
jobs: [],
|
|
24
|
+
total: 0
|
|
25
|
+
};
|
|
26
|
+
let c = s;
|
|
27
|
+
if (!c) return {
|
|
28
|
+
ok: !1,
|
|
29
|
+
error: "cron_unavailable"
|
|
30
|
+
};
|
|
31
|
+
let l;
|
|
32
|
+
try {
|
|
33
|
+
l = await c.list({ includeDisabled: !0 });
|
|
34
|
+
} catch (t) {
|
|
35
|
+
return a.error("cron list failed", t), {
|
|
36
|
+
ok: !1,
|
|
37
|
+
error: e(t)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
let u = [];
|
|
41
|
+
for (let e of l) {
|
|
42
|
+
if (!await p(e, t, i)) continue;
|
|
43
|
+
let n = m(e);
|
|
44
|
+
n && u.push(n);
|
|
45
|
+
}
|
|
46
|
+
return a.info("cron list for chat", {
|
|
47
|
+
accountId: t,
|
|
48
|
+
requestDeviceId: r,
|
|
49
|
+
requestChatId: i,
|
|
50
|
+
total: l.length,
|
|
51
|
+
owned: u.length,
|
|
52
|
+
returned: Math.min(u.length, o)
|
|
53
|
+
}), {
|
|
54
|
+
ok: !0,
|
|
55
|
+
jobs: u.slice(0, o),
|
|
56
|
+
total: l.length
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function d(t) {
|
|
60
|
+
let n = s;
|
|
61
|
+
if (n) try {
|
|
62
|
+
return (await n.list({ includeDisabled: !1 })).find((e) => e?.id === t);
|
|
63
|
+
} catch (n) {
|
|
64
|
+
a.warn("cron job lookup failed", {
|
|
65
|
+
jobId: t,
|
|
66
|
+
error: e(n)
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function f(t) {
|
|
72
|
+
let n = s;
|
|
73
|
+
if (!n) return {
|
|
74
|
+
ok: !1,
|
|
75
|
+
error: "cron_unavailable"
|
|
76
|
+
};
|
|
77
|
+
try {
|
|
78
|
+
return {
|
|
79
|
+
ok: !0,
|
|
80
|
+
removed: (await n.remove(t))?.removed === !0
|
|
81
|
+
};
|
|
82
|
+
} catch (n) {
|
|
83
|
+
return a.error("cron remove failed", n, { jobId: t }), {
|
|
84
|
+
ok: !1,
|
|
85
|
+
error: e(n)
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function p(e, t, n) {
|
|
90
|
+
let i = e.delivery?.to;
|
|
91
|
+
return typeof i != "string" || i.length === 0 ? !1 : await r(i, t) === n;
|
|
92
|
+
}
|
|
93
|
+
function m(e) {
|
|
94
|
+
if (e.enabled !== !0) return;
|
|
95
|
+
let t = h(e.schedule);
|
|
96
|
+
if (!t) return;
|
|
97
|
+
let n = e.state, r = n?.lastRunAtMs;
|
|
98
|
+
if (r != null) {
|
|
99
|
+
let e = n?.nextRunAtMs;
|
|
100
|
+
if (e == null || e <= r) return;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
jobId: e.id,
|
|
104
|
+
name: e.name ?? e.id,
|
|
105
|
+
...e.description ? { description: e.description } : {},
|
|
106
|
+
schedule: t,
|
|
107
|
+
nextRunAtMs: n?.nextRunAtMs ?? null,
|
|
108
|
+
...n?.lastRunStatus === void 0 ? {} : { lastRunStatus: g(n.lastRunStatus) },
|
|
109
|
+
...r === void 0 ? {} : { lastRunAtMs: r }
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function h(e) {
|
|
113
|
+
switch (e?.kind) {
|
|
114
|
+
case "cron": return {
|
|
115
|
+
kind: "cron",
|
|
116
|
+
...e.expr === void 0 ? {} : { expr: e.expr },
|
|
117
|
+
...e.tz === void 0 ? {} : { tz: e.tz },
|
|
118
|
+
...e.staggerMs === void 0 ? {} : { staggerMs: e.staggerMs }
|
|
119
|
+
};
|
|
120
|
+
case "at": return {
|
|
121
|
+
kind: "at",
|
|
122
|
+
...e.at === void 0 ? {} : { at: e.at }
|
|
123
|
+
};
|
|
124
|
+
case "every": return {
|
|
125
|
+
kind: "every",
|
|
126
|
+
...e.everyMs === void 0 ? {} : { everyMs: e.everyMs },
|
|
127
|
+
...e.anchorMs === void 0 ? {} : { anchorMs: e.anchorMs }
|
|
128
|
+
};
|
|
129
|
+
default: return;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function g(e) {
|
|
133
|
+
switch (e) {
|
|
134
|
+
case "ok": return i.Success;
|
|
135
|
+
case "error": return i.Failed;
|
|
136
|
+
case "skipped": return i.Skipped;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
export { c as captureCronService, d as findCronJobById, u as listCronJobsForChat, l as releaseCronService, f as removeCronJob };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { toErrorMessage as e } from "../../utils/error.mjs";
|
|
2
|
+
import { listNodeDevices as t } from "./list.mjs";
|
|
3
|
+
//#region src/capabilities/node/device-target.ts
|
|
4
|
+
function n(e) {
|
|
5
|
+
return (e ?? "").trim().toLowerCase();
|
|
6
|
+
}
|
|
7
|
+
function r(e) {
|
|
8
|
+
return e.map((e) => ({
|
|
9
|
+
deviceId: e.deviceId,
|
|
10
|
+
...e.deviceName ? { deviceName: e.deviceName } : {},
|
|
11
|
+
online: e.online
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
async function i(i) {
|
|
15
|
+
let a;
|
|
16
|
+
try {
|
|
17
|
+
a = (await t()).devices;
|
|
18
|
+
} catch (t) {
|
|
19
|
+
return {
|
|
20
|
+
ok: !1,
|
|
21
|
+
reason: "list_failed",
|
|
22
|
+
message: e(t)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
let o = i.trim().toLowerCase(), s = a.filter((e) => n(e.deviceName).length > 0), c = s.filter((e) => n(e.deviceName) === o);
|
|
26
|
+
if (c.length === 1) return {
|
|
27
|
+
ok: !0,
|
|
28
|
+
device: c[0]
|
|
29
|
+
};
|
|
30
|
+
if (c.length > 1) return {
|
|
31
|
+
ok: !1,
|
|
32
|
+
reason: "ambiguous_device_name",
|
|
33
|
+
candidates: r(c)
|
|
34
|
+
};
|
|
35
|
+
let l = s.filter((e) => n(e.deviceName).includes(o));
|
|
36
|
+
return l.length === 1 ? {
|
|
37
|
+
ok: !0,
|
|
38
|
+
device: l[0]
|
|
39
|
+
} : l.length > 1 ? {
|
|
40
|
+
ok: !1,
|
|
41
|
+
reason: "ambiguous_device_name",
|
|
42
|
+
candidates: r(l)
|
|
43
|
+
} : {
|
|
44
|
+
ok: !1,
|
|
45
|
+
reason: "device_not_found"
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { i as resolveDeviceTargetByName };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { clawLogger as e } from "../../utils/claw-logger.mjs";
|
|
2
2
|
import { buildEndpoint as t } from "../../cloud-channel/protocol/target.mjs";
|
|
3
3
|
import { resolveEnabledYoyoAccountId as n } from "../../modules/configs/channel.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { resolveOutboundTraceInfo as i } from "../../messaging/trace/tool-context.mjs";
|
|
4
|
+
import { resolveOutboundTraceInfo as r } from "../../messaging/trace/tool-context.mjs";
|
|
6
5
|
import "../../messaging/trace/index.mjs";
|
|
6
|
+
import { ClawClient as i } from "../../connection/registry.mjs";
|
|
7
7
|
//#region src/capabilities/node/invoke.ts
|
|
8
8
|
var a = e("capabilities");
|
|
9
9
|
async function o(e) {
|
|
10
|
-
let a =
|
|
10
|
+
let a = r(e.toolCallId), o = {
|
|
11
11
|
to: t("node", e.nodeId),
|
|
12
12
|
msgType: "nodeInvokeRequest",
|
|
13
13
|
data: { node: {
|
|
@@ -18,7 +18,7 @@ async function o(e) {
|
|
|
18
18
|
} },
|
|
19
19
|
...a ? { traceInfo: a } : {}
|
|
20
20
|
}, c = n();
|
|
21
|
-
return
|
|
21
|
+
return i.forAccount(c).request(o, {
|
|
22
22
|
timeoutMs: e.timeoutMs,
|
|
23
23
|
matchResult: s(e.toolCallId)
|
|
24
24
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { toErrorMessage as e } from "../../utils/error.mjs";
|
|
2
2
|
import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
3
|
+
import { isOKResponse as n } from "../../apis/helpers.mjs";
|
|
4
|
+
import { createClawCloudClient as r } from "../../apis/claw-cloud.mjs";
|
|
5
|
+
import "../../apis/index.mjs";
|
|
6
|
+
import { HonorAccount as i } from "../../honor-auth/vault/impl.mjs";
|
|
6
7
|
import { loadDeviceInfo as a } from "../../modules/device/device-info.mjs";
|
|
7
8
|
import "../../modules/device/index.mjs";
|
|
8
9
|
import "../../honor-auth/vault/index.mjs";
|
|
9
|
-
import "../../apis/index.mjs";
|
|
10
10
|
import { ToolError as o } from "../../tools/error.mjs";
|
|
11
11
|
import { DeviceStatus as s } from "../../types.mjs";
|
|
12
12
|
//#region src/capabilities/node/list.ts
|
|
@@ -21,7 +21,7 @@ function l(e) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
async function u(t) {
|
|
24
|
-
let s = await
|
|
24
|
+
let s = await i.fromUser().current();
|
|
25
25
|
if (!s?.token || !s.userId) throw c.error("node device list skipped: no current user"), new o("unauthorized", "missing current user token");
|
|
26
26
|
let u;
|
|
27
27
|
try {
|
|
@@ -30,8 +30,8 @@ async function u(t) {
|
|
|
30
30
|
throw c.error("node device list failed to get device info", e), new o("device_info", "failed to get device info", { cause: e });
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
|
-
let e = await
|
|
34
|
-
if (!
|
|
33
|
+
let e = await r().getDeviceList(u, s, { deviceIdList: t?.deviceIdList });
|
|
34
|
+
if (!n(e)) {
|
|
35
35
|
let t = e.data?.code, n = e.data?.cnMessage;
|
|
36
36
|
throw c.error("node device list response not ok", null, {
|
|
37
37
|
status: e.status,
|
|
@@ -39,8 +39,8 @@ async function u(t) {
|
|
|
39
39
|
cnMessage: n
|
|
40
40
|
}), new o("api_failed", `code=${t} message=${n}`);
|
|
41
41
|
}
|
|
42
|
-
let
|
|
43
|
-
return { devices: Array.isArray(
|
|
42
|
+
let i = e.data.data?.deviceList;
|
|
43
|
+
return { devices: Array.isArray(i) ? i.map(l) : [] };
|
|
44
44
|
} catch (t) {
|
|
45
45
|
throw t instanceof o ? t : (c.error("node device list failed", t), new o("network_error", e(t), { cause: t }));
|
|
46
46
|
}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { clawLogger as e } from "../../utils/claw-logger.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import { isClawResponseOk as t } from "../../apis/helpers.mjs";
|
|
3
|
+
import { createClawCloudClient as n } from "../../apis/claw-cloud.mjs";
|
|
4
|
+
import "../../apis/index.mjs";
|
|
5
|
+
import { HonorAccount as r } from "../../honor-auth/vault/impl.mjs";
|
|
5
6
|
import { loadDeviceInfo as i } from "../../modules/device/device-info.mjs";
|
|
6
7
|
import "../../modules/device/index.mjs";
|
|
7
8
|
import "../../honor-auth/vault/index.mjs";
|
|
8
|
-
import "../../apis/index.mjs";
|
|
9
9
|
import { ToolError as a } from "../../tools/error.mjs";
|
|
10
10
|
import { errorLogMeta as o, normalizeNetworkError as s, normalizeUploadLinkError as c } from "./normalize.mjs";
|
|
11
11
|
//#region src/capabilities/remote-file/remote-file.ts
|
|
12
12
|
var l = e("capabilities");
|
|
13
13
|
async function u() {
|
|
14
|
-
let e = await
|
|
14
|
+
let e = await r.fromUser().current();
|
|
15
15
|
if (!e?.token || !e.userId) throw l.error("remote file skipped: no current user"), new a("unauthorized", "missing current user token");
|
|
16
|
-
let
|
|
16
|
+
let t;
|
|
17
17
|
try {
|
|
18
|
-
|
|
18
|
+
t = await i();
|
|
19
19
|
} catch (e) {
|
|
20
20
|
throw l.error("remote file failed to get device info", e), new a("device_info", "failed to get device info", { cause: e });
|
|
21
21
|
}
|
|
22
22
|
return {
|
|
23
|
-
deviceInfo:
|
|
23
|
+
deviceInfo: t,
|
|
24
24
|
token: e.token,
|
|
25
25
|
userId: e.userId
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
async function d(e,
|
|
28
|
+
async function d(e, r) {
|
|
29
29
|
let { deviceInfo: i, token: d } = await u(), f = { token: d }, p;
|
|
30
30
|
try {
|
|
31
|
-
p = await
|
|
31
|
+
p = await n().getUploadLink(i, f, { fileList: e }, { signal: r });
|
|
32
32
|
} catch (t) {
|
|
33
33
|
throw t instanceof a ? t : (l.error("upload link request failed", t, {
|
|
34
34
|
fileCount: e.length,
|
|
35
35
|
...o(t)
|
|
36
36
|
}), s(t));
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
38
|
+
if (t(p)) {
|
|
39
39
|
let e = p.data.data;
|
|
40
40
|
return {
|
|
41
41
|
code: "OK",
|
|
@@ -2,9 +2,9 @@ import { clawLogger as e } from "../utils/claw-logger.mjs";
|
|
|
2
2
|
import { disposeAccountMessaging as t } from "../messaging/dispose.mjs";
|
|
3
3
|
import { loadConfig as n, saveConfig as r } from "../modules/configs/config-store.mjs";
|
|
4
4
|
import { resolveEnabledYoyoAccountId as i, setYoyoChannelAccountEnabled as a } from "../modules/configs/channel.mjs";
|
|
5
|
-
import "../modules/configs/index.mjs";
|
|
6
5
|
import { HonorAccount as o } from "../honor-auth/vault/impl.mjs";
|
|
7
6
|
import "../honor-auth/vault/index.mjs";
|
|
7
|
+
import "../modules/configs/index.mjs";
|
|
8
8
|
import "../messaging/index.mjs";
|
|
9
9
|
import { monitorAccount as s } from "../connection/monitor.mjs";
|
|
10
10
|
import "../connection/index.mjs";
|
package/dist/cli/login/impl.mjs
CHANGED
|
@@ -2,20 +2,21 @@ import { withCommandRuntime as e } from "../../core/runtime.mjs";
|
|
|
2
2
|
import { clawLogger as t } from "../../utils/claw-logger.mjs";
|
|
3
3
|
import { loadConfig as n, saveConfig as r } from "../../modules/configs/config-store.mjs";
|
|
4
4
|
import { patchYoyoChannelConfig as i, resolveEnabledYoyoAccountId as a, setAllYoyoChannelAccountsEnabled as o, setYoyoChannelAccountEnabled as s } from "../../modules/configs/channel.mjs";
|
|
5
|
+
import { refreshOwnerAllowFrom as c } from "../../modules/configs/owner-allow-from.mjs";
|
|
5
6
|
import "../../modules/configs/index.mjs";
|
|
6
|
-
import { performLogin as
|
|
7
|
+
import { performLogin as l } from "../../honor-auth/login/impl.mjs";
|
|
7
8
|
import "../../honor-auth/index.mjs";
|
|
8
9
|
//#region src/cli/login/impl.ts
|
|
9
|
-
var
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
let { token: e } =
|
|
13
|
-
|
|
14
|
-
let t = a(),
|
|
15
|
-
if (!
|
|
16
|
-
let
|
|
17
|
-
t && t ===
|
|
10
|
+
var u = t("login-cli");
|
|
11
|
+
function d(t, d) {
|
|
12
|
+
d.command("login").description("login to Honor and register devices").option("-u, --uid <userId>", "login with a specific user ID").option("--token <token>", "login with a specific token").action(async (d) => e(t.runtime, async () => {
|
|
13
|
+
let { token: e } = d;
|
|
14
|
+
u.debug("login CLI command called");
|
|
15
|
+
let t = a(), f = await l({ token: e });
|
|
16
|
+
if (!f) return;
|
|
17
|
+
let p = o((await c(n())).config, !1);
|
|
18
|
+
t && t === f.userId && await r(p), await r(i(s(p, f.userId, !0), { enabled: !0 })), console.log("✅ yoyo channel account enabled.");
|
|
18
19
|
}));
|
|
19
20
|
}
|
|
20
21
|
//#endregion
|
|
21
|
-
export {
|
|
22
|
+
export { d as registerLoginCommand };
|