@honor-claw/yoyo 2026.9.4-beta.5 → 2026.9.4-beta.6
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.
|
@@ -5,114 +5,151 @@ import { resolveChatIdFromTo as r } from "../../messaging/target/outbound.mjs";
|
|
|
5
5
|
import "../../messaging/target/index.mjs";
|
|
6
6
|
import { CronRunStatus as i } from "../../messaging/notification/types.mjs";
|
|
7
7
|
import "../../messaging/notification/index.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { sleep as a } from "../../utils/sleep.mjs";
|
|
9
|
+
import { resolveListTimezone as o } from "./timezone.mjs";
|
|
9
10
|
//#region src/capabilities/cron/service.ts
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
var s = t("cron"), c = 50, l = 300, u = 3, d;
|
|
12
|
+
function f(e) {
|
|
13
|
+
d = e, s.info("cron service handle updated", { available: e !== void 0 });
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
15
|
+
function p() {
|
|
16
|
+
d = void 0;
|
|
16
17
|
}
|
|
17
|
-
async function
|
|
18
|
+
async function m(t, r) {
|
|
18
19
|
let i = await n(t, r);
|
|
19
|
-
if (!i) return
|
|
20
|
+
if (!i) return s.info("cron list: request device has no chat mapping, empty result", {
|
|
20
21
|
accountId: t,
|
|
21
22
|
requestDeviceId: r
|
|
22
23
|
}), {
|
|
23
24
|
ok: !0,
|
|
24
25
|
jobs: [],
|
|
25
26
|
total: 0,
|
|
26
|
-
timezone:
|
|
27
|
+
timezone: o()
|
|
27
28
|
};
|
|
28
|
-
let
|
|
29
|
-
if (!
|
|
29
|
+
let a = d;
|
|
30
|
+
if (!a) return {
|
|
30
31
|
ok: !1,
|
|
31
32
|
error: "cron_unavailable"
|
|
32
33
|
};
|
|
33
|
-
let
|
|
34
|
+
let l;
|
|
34
35
|
try {
|
|
35
|
-
|
|
36
|
+
l = await a.list({ includeDisabled: !0 });
|
|
36
37
|
} catch (t) {
|
|
37
|
-
return
|
|
38
|
+
return s.error("cron list failed", t), {
|
|
38
39
|
ok: !1,
|
|
39
40
|
error: e(t)
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
|
-
let
|
|
43
|
-
for (let e of
|
|
44
|
-
if (!await
|
|
45
|
-
let n =
|
|
46
|
-
n &&
|
|
43
|
+
let u = [];
|
|
44
|
+
for (let e of l) {
|
|
45
|
+
if (!await b(e, t, i)) continue;
|
|
46
|
+
let n = x(e);
|
|
47
|
+
n && u.push(n);
|
|
47
48
|
}
|
|
48
|
-
return
|
|
49
|
+
return s.info("cron list for chat", {
|
|
49
50
|
accountId: t,
|
|
50
51
|
requestDeviceId: r,
|
|
51
52
|
requestChatId: i,
|
|
52
|
-
total:
|
|
53
|
-
owned:
|
|
54
|
-
returned: Math.min(
|
|
53
|
+
total: l.length,
|
|
54
|
+
owned: u.length,
|
|
55
|
+
returned: Math.min(u.length, c)
|
|
55
56
|
}), {
|
|
56
57
|
ok: !0,
|
|
57
|
-
jobs:
|
|
58
|
-
total:
|
|
59
|
-
timezone:
|
|
58
|
+
jobs: u.slice(0, c),
|
|
59
|
+
total: l.length,
|
|
60
|
+
timezone: o()
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
|
-
async function
|
|
63
|
-
let n =
|
|
63
|
+
async function h(t) {
|
|
64
|
+
let n = d;
|
|
64
65
|
if (n) try {
|
|
65
66
|
return (await n.list({ includeDisabled: !1 })).find((e) => e?.id === t);
|
|
66
67
|
} catch (n) {
|
|
67
|
-
|
|
68
|
+
s.warn("cron job lookup failed", {
|
|
68
69
|
jobId: t,
|
|
69
70
|
error: e(n)
|
|
70
71
|
});
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
async function
|
|
75
|
-
let
|
|
76
|
-
if (!
|
|
75
|
+
async function g(e) {
|
|
76
|
+
let t = d;
|
|
77
|
+
if (!t) return {
|
|
77
78
|
ok: !1,
|
|
78
79
|
error: "cron_unavailable"
|
|
79
80
|
};
|
|
81
|
+
let n = Date.now(), r = _(t, e).catch(() => void 0), i = v(t, e), a = await Promise.race([i, r.then(() => !0)]), o = a ? "polling" : "remove", c = await r;
|
|
82
|
+
r = void 0, i.catch(() => void 0);
|
|
83
|
+
let l = Date.now() - n;
|
|
84
|
+
return c === void 0 ? a ? (s.info("cron remove confirmed by store polling, skipping cleanup wait", {
|
|
85
|
+
jobId: e,
|
|
86
|
+
elapsedMs: l
|
|
87
|
+
}), {
|
|
88
|
+
ok: !0,
|
|
89
|
+
removed: !1
|
|
90
|
+
}) : (s.warn("cron remove unresolved: polling exhausted and upstream result absent", {
|
|
91
|
+
jobId: e,
|
|
92
|
+
elapsedMs: l
|
|
93
|
+
}), {
|
|
94
|
+
ok: !1,
|
|
95
|
+
error: "cron remove failed"
|
|
96
|
+
}) : (s.debug("cron remove settled by upstream result", {
|
|
97
|
+
jobId: e,
|
|
98
|
+
raceWinner: o,
|
|
99
|
+
elapsedMs: l,
|
|
100
|
+
ok: c.ok,
|
|
101
|
+
removed: c.ok ? c.removed : void 0
|
|
102
|
+
}), c);
|
|
103
|
+
}
|
|
104
|
+
async function _(t, n) {
|
|
80
105
|
try {
|
|
81
106
|
return {
|
|
82
107
|
ok: !0,
|
|
83
|
-
removed: (await
|
|
108
|
+
removed: (await t.remove(n))?.removed === !0
|
|
84
109
|
};
|
|
85
110
|
} catch (r) {
|
|
86
|
-
return await
|
|
87
|
-
jobId:
|
|
111
|
+
return await y(t, n) === !1 ? (s.warn("cron remove errored but job no longer exists, treated as success", {
|
|
112
|
+
jobId: n,
|
|
88
113
|
error: e(r)
|
|
89
114
|
}), {
|
|
90
115
|
ok: !0,
|
|
91
116
|
removed: !1
|
|
92
|
-
}) : (
|
|
117
|
+
}) : (s.error("cron remove failed", r, { jobId: n }), {
|
|
93
118
|
ok: !1,
|
|
94
119
|
error: e(r)
|
|
95
120
|
});
|
|
96
121
|
}
|
|
97
122
|
}
|
|
98
|
-
async function
|
|
123
|
+
async function v(e, t) {
|
|
124
|
+
for (let n = 1; n <= u; n++) {
|
|
125
|
+
await a(l);
|
|
126
|
+
let r = await y(e, t);
|
|
127
|
+
if (s.debug("cron remove polling probe", {
|
|
128
|
+
jobId: t,
|
|
129
|
+
attempt: n,
|
|
130
|
+
present: r
|
|
131
|
+
}), r === !1) return !0;
|
|
132
|
+
}
|
|
133
|
+
return !1;
|
|
134
|
+
}
|
|
135
|
+
async function y(t, n) {
|
|
99
136
|
try {
|
|
100
137
|
return (await t.list({ includeDisabled: !0 })).some((e) => e?.id === n);
|
|
101
138
|
} catch (t) {
|
|
102
|
-
|
|
139
|
+
s.warn("cron job presence lookup failed", {
|
|
103
140
|
jobId: n,
|
|
104
141
|
error: e(t)
|
|
105
142
|
});
|
|
106
143
|
return;
|
|
107
144
|
}
|
|
108
145
|
}
|
|
109
|
-
async function
|
|
146
|
+
async function b(e, t, n) {
|
|
110
147
|
let i = e.delivery?.to;
|
|
111
148
|
return typeof i != "string" || i.length === 0 ? !1 : await r(i, t) === n;
|
|
112
149
|
}
|
|
113
|
-
function
|
|
150
|
+
function x(e) {
|
|
114
151
|
if (e.enabled !== !0) return;
|
|
115
|
-
let t =
|
|
152
|
+
let t = S(e.schedule);
|
|
116
153
|
if (!t) return;
|
|
117
154
|
let n = e.state, r = n?.lastRunAtMs;
|
|
118
155
|
if (r != null) {
|
|
@@ -125,11 +162,11 @@ function g(e) {
|
|
|
125
162
|
...e.description ? { description: e.description } : {},
|
|
126
163
|
schedule: t,
|
|
127
164
|
nextRunAtMs: n?.nextRunAtMs ?? null,
|
|
128
|
-
...n?.lastRunStatus === void 0 ? {} : { lastRunStatus:
|
|
165
|
+
...n?.lastRunStatus === void 0 ? {} : { lastRunStatus: C(n.lastRunStatus) },
|
|
129
166
|
...r === void 0 ? {} : { lastRunAtMs: r }
|
|
130
167
|
};
|
|
131
168
|
}
|
|
132
|
-
function
|
|
169
|
+
function S(e) {
|
|
133
170
|
switch (e?.kind) {
|
|
134
171
|
case "cron": return {
|
|
135
172
|
kind: "cron",
|
|
@@ -149,7 +186,7 @@ function _(e) {
|
|
|
149
186
|
default: return;
|
|
150
187
|
}
|
|
151
188
|
}
|
|
152
|
-
function
|
|
189
|
+
function C(e) {
|
|
153
190
|
switch (e) {
|
|
154
191
|
case "ok": return i.Success;
|
|
155
192
|
case "error": return i.Failed;
|
|
@@ -157,4 +194,4 @@ function v(e) {
|
|
|
157
194
|
}
|
|
158
195
|
}
|
|
159
196
|
//#endregion
|
|
160
|
-
export {
|
|
197
|
+
export { f as captureCronService, h as findCronJobById, m as listCronJobsForChat, p as releaseCronService, g as removeCronJob };
|
|
@@ -66,7 +66,10 @@ function p(t) {
|
|
|
66
66
|
rawBody: n.content,
|
|
67
67
|
commandBody: n.content
|
|
68
68
|
},
|
|
69
|
-
access: {
|
|
69
|
+
access: {
|
|
70
|
+
commands: { authorized: !0 },
|
|
71
|
+
toolPolicy: { deny: ["ask_user", "secrets"] }
|
|
72
|
+
},
|
|
70
73
|
messageId: n.messageId,
|
|
71
74
|
...n.resources.length > 0 ? { media: n.resources.map((e) => ({ url: e.url })) } : {},
|
|
72
75
|
extra: { OwnerAllowFrom: [n.accountId, n.senderId] }
|