@honor-claw/yoyo 2026.9.2-beta.2 → 2026.9.3-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.
- 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/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 +10 -8
- package/dist/core/hooks/prompt.mjs +1 -1
- package/dist/core/prompt/builder.mjs +10 -8
- package/dist/core/prompt/cron.mjs +19 -0
- package/dist/messaging/dispatchers/stream/controller.mjs +29 -29
- package/dist/messaging/dispatchers/stream/session.mjs +32 -32
- package/dist/messaging/inbound/context.mjs +2 -1
- 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/schemas.mjs +5 -1
- package/dist/tools/index.mjs +5 -3
- 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/mcptools/adjust_brightness.json +10 -10
- 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/screen_recorder.json +1 -1
- package/skills/yoyo-phone-control/mcptools/vibration_mode.json +1 -1
|
@@ -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 };
|
|
@@ -9,19 +9,20 @@ import { registerAuthHandler as o } from "./handlers/auth.mjs";
|
|
|
9
9
|
import { registerContextHandler as s } from "./handlers/context/handler.mjs";
|
|
10
10
|
import "./handlers/context/index.mjs";
|
|
11
11
|
import { registerPairingHandler as c } from "./handlers/pairing.mjs";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
12
|
+
import { registerPushInboundHandler as l } from "./handlers/push-inbound.mjs";
|
|
13
|
+
import { registerUserMessageHandler as u } from "./handlers/user-message.mjs";
|
|
14
|
+
import { summarizeServiceEvent as d } from "./log-summary.mjs";
|
|
15
|
+
import { V1Adapter as f } from "./protocol/v1-adapter.mjs";
|
|
16
|
+
import { V2Adapter as p } from "./protocol/v2-adapter.mjs";
|
|
16
17
|
import "./protocol/index.mjs";
|
|
17
|
-
import { UNEXPECTED_RAW_CODE_SEMANTICS as
|
|
18
|
-
import { CloudSocket as
|
|
19
|
-
import { CloudEventBus as
|
|
20
|
-
import { MessageHandler as
|
|
18
|
+
import { UNEXPECTED_RAW_CODE_SEMANTICS as m } from "./protocol/semantics.mjs";
|
|
19
|
+
import { CloudSocket as h } from "./transport/cloud-socket.mjs";
|
|
20
|
+
import { CloudEventBus as g } from "./transport/event-bus.mjs";
|
|
21
|
+
import { MessageHandler as _ } from "./transport/message-handler.mjs";
|
|
21
22
|
import "./transport/index.mjs";
|
|
22
|
-
import { buildCloudSocketConnectParams as
|
|
23
|
+
import { buildCloudSocketConnectParams as v } from "./utils.mjs";
|
|
23
24
|
//#region src/cloud-channel/channel.ts
|
|
24
|
-
var
|
|
25
|
+
var y = e("cloud-channel"), b = 3e4, x = "v2", S = class {
|
|
25
26
|
config;
|
|
26
27
|
cloudSocket;
|
|
27
28
|
gatewaySessions;
|
|
@@ -34,8 +35,8 @@ var v = e("cloud-channel"), y = 3e4, b = "v2", x = class {
|
|
|
34
35
|
businessPingTimer = new r("recurring");
|
|
35
36
|
constructor(e) {
|
|
36
37
|
this.config = e;
|
|
37
|
-
let t = new
|
|
38
|
-
this.protocol = e.protocol ??
|
|
38
|
+
let t = new g();
|
|
39
|
+
this.protocol = e.protocol ?? x, this.context = { accountId: e.accountId }, this.messageHandler = new _(t, this.context), this.adapter = C(this.protocol), this.cloudSocket = new h({
|
|
39
40
|
loadConnectParams: this.provideConnectParams,
|
|
40
41
|
onFrame: this.handleCloudFrame,
|
|
41
42
|
onOpen: this.handleCloudOpen,
|
|
@@ -47,78 +48,78 @@ var v = e("cloud-channel"), y = 3e4, b = "v2", x = class {
|
|
|
47
48
|
}), this.authorizationRefreshManager = new i({
|
|
48
49
|
accountId: e.accountId,
|
|
49
50
|
outbound: this.dispatcher
|
|
50
|
-
}), this.gatewaySessions = new n(this.dispatcher), c(this.gatewaySessions, t),
|
|
51
|
+
}), this.gatewaySessions = new n(this.dispatcher), c(this.gatewaySessions, t), u(this.gatewaySessions, t), s(this.dispatcher, t), o(this.authorizationRefreshManager, t), l(t);
|
|
51
52
|
}
|
|
52
53
|
start() {
|
|
53
|
-
|
|
54
|
+
y.info("starting connection"), this.cloudSocket.start();
|
|
54
55
|
}
|
|
55
56
|
destroy() {
|
|
56
|
-
|
|
57
|
+
y.info("closing connection"), this.businessPingTimer.stop(), this.authorizationRefreshManager.destroy(), this.gatewaySessions.closeAll(), this.dispatcher.destroy(), this.cloudSocket.stop();
|
|
57
58
|
}
|
|
58
59
|
getOutboundPort() {
|
|
59
60
|
return this.dispatcher;
|
|
60
61
|
}
|
|
61
62
|
provideConnectParams = async () => {
|
|
62
63
|
let e = await this.config.credentialProvider();
|
|
63
|
-
return e ?
|
|
64
|
+
return e ? v(e.token, this.protocol) : null;
|
|
64
65
|
};
|
|
65
66
|
handleCloudOpen = () => {
|
|
66
|
-
|
|
67
|
+
y.info("cloud connection established"), this.businessPingTimer.start(this.sendBusinessPing, b), this.authorizationRefreshManager.start(), this.config.onOpen?.();
|
|
67
68
|
};
|
|
68
69
|
handleCloudClose = () => {
|
|
69
|
-
|
|
70
|
+
y.info("cloud connection closed"), this.businessPingTimer.stop(), this.config.onClose?.();
|
|
70
71
|
};
|
|
71
72
|
sendBusinessPing = async () => {
|
|
72
73
|
await this.dispatcher.send({
|
|
73
74
|
to: t("yoyoclawservice"),
|
|
74
75
|
msgType: "pingMessage",
|
|
75
76
|
silent: !0
|
|
76
|
-
}) ||
|
|
77
|
+
}) || y.warn("failed to send pingMessage");
|
|
77
78
|
};
|
|
78
79
|
handleCloudFrame = (e) => {
|
|
79
80
|
let t;
|
|
80
81
|
try {
|
|
81
82
|
t = this.adapter.normalize(e);
|
|
82
83
|
} catch (e) {
|
|
83
|
-
|
|
84
|
+
y.error("protocol adapter failed", e);
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
86
87
|
switch (t.kind) {
|
|
87
88
|
case "SUCCESS": {
|
|
88
89
|
let e = t.serviceEvent;
|
|
89
90
|
if (e.payload.msgType === "pingMessage") {
|
|
90
|
-
|
|
91
|
+
y.debug("ignored inbound pingMessage", d(e));
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
y.debug("normalized cloud message", d(e)), this.dispatcher.consume(e), this.messageHandler.handleCloudMessage(e);
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
97
|
case "TARGET_OFFLINE":
|
|
97
|
-
|
|
98
|
+
y.info("remote device offline", { session: t.offlineSocketId }), this.gatewaySessions.closeSession(t.offlineSocketId);
|
|
98
99
|
return;
|
|
99
100
|
case "DEVICE_NOT_REGISTERED":
|
|
100
|
-
|
|
101
|
+
y.info("device not registered, notifying connection layer"), this.config.onError?.({ type: "device-not-registered" });
|
|
101
102
|
return;
|
|
102
103
|
case "TOKEN_EXPIRED":
|
|
103
|
-
|
|
104
|
+
y.warn("unauthorized by cloud, pausing refresh"), this.authorizationRefreshManager.pauseForUnauthorized();
|
|
104
105
|
return;
|
|
105
106
|
case "UNEXPECTED": {
|
|
106
|
-
let e =
|
|
107
|
-
e ?
|
|
107
|
+
let e = m[t.rawCode];
|
|
108
|
+
e ? y.warn(e, { rawCode: t.rawCode }) : y.warn("unexpected message", { rawCode: t.rawCode });
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
111
|
case "INVALID":
|
|
111
|
-
|
|
112
|
+
y.error("failed to parse message", t.error);
|
|
112
113
|
return;
|
|
113
|
-
default:
|
|
114
|
+
default: y.warn("non-success control code", { kind: t.kind });
|
|
114
115
|
}
|
|
115
116
|
};
|
|
116
117
|
handleSocketError = (e) => {
|
|
117
|
-
|
|
118
|
+
y.info("cloud socket error, notifying connection layer", { type: e.type }), this.config.onError?.(e);
|
|
118
119
|
};
|
|
119
120
|
};
|
|
120
|
-
function
|
|
121
|
-
return e === "v1" ? new
|
|
121
|
+
function C(e) {
|
|
122
|
+
return e === "v1" ? new f() : new p();
|
|
122
123
|
}
|
|
123
124
|
//#endregion
|
|
124
|
-
export {
|
|
125
|
+
export { S as ClawChannel };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { listCronJobsForChat as e, removeCronJob as t } from "../../../capabilities/cron/service.mjs";
|
|
2
|
+
import "../../../capabilities/cron/index.mjs";
|
|
3
|
+
//#region src/cloud-channel/handlers/context/cron.ts
|
|
4
|
+
var n = "cron.list", r = "cron.remove", i = async ({ event: t, accountId: n }) => {
|
|
5
|
+
let r = t.from.deviceId;
|
|
6
|
+
if (!r) return {
|
|
7
|
+
ok: !1,
|
|
8
|
+
error: "missing from.deviceId",
|
|
9
|
+
responsePayload: {
|
|
10
|
+
ok: !1,
|
|
11
|
+
error: "missing_from_device_id"
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
let i = await e(n, r);
|
|
15
|
+
return i.ok ? {
|
|
16
|
+
ok: !0,
|
|
17
|
+
responsePayload: {
|
|
18
|
+
ok: !0,
|
|
19
|
+
jobs: i.jobs
|
|
20
|
+
}
|
|
21
|
+
} : {
|
|
22
|
+
ok: !1,
|
|
23
|
+
error: i.error,
|
|
24
|
+
responsePayload: {
|
|
25
|
+
ok: !1,
|
|
26
|
+
error: i.error
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}, a = async ({ payload: e }) => {
|
|
30
|
+
let n = typeof e?.jobId == "string" ? e.jobId.trim() : "";
|
|
31
|
+
if (!n) return {
|
|
32
|
+
ok: !1,
|
|
33
|
+
error: "missing jobId",
|
|
34
|
+
responsePayload: {
|
|
35
|
+
ok: !1,
|
|
36
|
+
error: "missing_job_id"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
let r = await t(n);
|
|
40
|
+
return r.ok ? {
|
|
41
|
+
ok: !0,
|
|
42
|
+
responsePayload: {
|
|
43
|
+
ok: !0,
|
|
44
|
+
jobId: n,
|
|
45
|
+
removed: r.removed,
|
|
46
|
+
alreadyAbsent: !r.removed
|
|
47
|
+
}
|
|
48
|
+
} : {
|
|
49
|
+
ok: !1,
|
|
50
|
+
error: r.error,
|
|
51
|
+
responsePayload: {
|
|
52
|
+
ok: !1,
|
|
53
|
+
error: r.error
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { n as CRON_LIST_CONTEXT_NAME, r as CRON_REMOVE_CONTEXT_NAME, i as cronListFetchHandler, a as cronRemoveUpdateHandler };
|