@honor-claw/yoyo 2026.9.4-beta.5 → 2026.9.4-beta.7
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,165 @@ 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.then((e) => e ? "polling" : "polling-exhausted"), r.then(() => "remove")]);
|
|
82
|
+
if (a === "remove") {
|
|
83
|
+
let t = await r, i = Date.now() - n;
|
|
84
|
+
return t === void 0 ? (s.warn("cron remove unresolved: upstream result absent", {
|
|
85
|
+
jobId: e,
|
|
86
|
+
elapsedMs: i
|
|
87
|
+
}), {
|
|
88
|
+
ok: !1,
|
|
89
|
+
error: "cron remove failed"
|
|
90
|
+
}) : (s.debug("cron remove settled by upstream result", {
|
|
91
|
+
jobId: e,
|
|
92
|
+
elapsedMs: i,
|
|
93
|
+
ok: t.ok,
|
|
94
|
+
removed: t.ok ? t.removed : void 0
|
|
95
|
+
}), t);
|
|
96
|
+
}
|
|
97
|
+
return r.then((t) => {
|
|
98
|
+
s.info("cron remove late upstream outcome after returning", {
|
|
99
|
+
jobId: e,
|
|
100
|
+
winner: a,
|
|
101
|
+
ok: t?.ok,
|
|
102
|
+
removed: t?.ok ? t.removed : void 0
|
|
103
|
+
});
|
|
104
|
+
}), a === "polling" ? (s.info("cron remove confirmed by store polling, skipping cleanup wait", {
|
|
105
|
+
jobId: e,
|
|
106
|
+
elapsedMs: Date.now() - n
|
|
107
|
+
}), {
|
|
108
|
+
ok: !0,
|
|
109
|
+
removed: !0
|
|
110
|
+
}) : (s.warn("cron remove polling exhausted, returning without cleanup wait", {
|
|
111
|
+
jobId: e,
|
|
112
|
+
elapsedMs: Date.now() - n
|
|
113
|
+
}), {
|
|
114
|
+
ok: !0,
|
|
115
|
+
removed: !1
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
async function _(t, n) {
|
|
80
119
|
try {
|
|
81
120
|
return {
|
|
82
121
|
ok: !0,
|
|
83
|
-
removed: (await
|
|
122
|
+
removed: (await t.remove(n))?.removed === !0
|
|
84
123
|
};
|
|
85
124
|
} catch (r) {
|
|
86
|
-
return await
|
|
87
|
-
jobId:
|
|
125
|
+
return await y(t, n) === !1 ? (s.warn("cron remove errored but job no longer exists, treated as success", {
|
|
126
|
+
jobId: n,
|
|
88
127
|
error: e(r)
|
|
89
128
|
}), {
|
|
90
129
|
ok: !0,
|
|
91
130
|
removed: !1
|
|
92
|
-
}) : (
|
|
131
|
+
}) : (s.error("cron remove failed", r, { jobId: n }), {
|
|
93
132
|
ok: !1,
|
|
94
133
|
error: e(r)
|
|
95
134
|
});
|
|
96
135
|
}
|
|
97
136
|
}
|
|
98
|
-
async function
|
|
137
|
+
async function v(e, t) {
|
|
138
|
+
for (let n = 1; n <= u; n++) {
|
|
139
|
+
await a(l);
|
|
140
|
+
let r = await y(e, t);
|
|
141
|
+
if (s.debug("cron remove polling probe", {
|
|
142
|
+
jobId: t,
|
|
143
|
+
attempt: n,
|
|
144
|
+
present: r
|
|
145
|
+
}), r === !1) return !0;
|
|
146
|
+
}
|
|
147
|
+
return !1;
|
|
148
|
+
}
|
|
149
|
+
async function y(t, n) {
|
|
99
150
|
try {
|
|
100
151
|
return (await t.list({ includeDisabled: !0 })).some((e) => e?.id === n);
|
|
101
152
|
} catch (t) {
|
|
102
|
-
|
|
153
|
+
s.warn("cron job presence lookup failed", {
|
|
103
154
|
jobId: n,
|
|
104
155
|
error: e(t)
|
|
105
156
|
});
|
|
106
157
|
return;
|
|
107
158
|
}
|
|
108
159
|
}
|
|
109
|
-
async function
|
|
160
|
+
async function b(e, t, n) {
|
|
110
161
|
let i = e.delivery?.to;
|
|
111
162
|
return typeof i != "string" || i.length === 0 ? !1 : await r(i, t) === n;
|
|
112
163
|
}
|
|
113
|
-
function
|
|
164
|
+
function x(e) {
|
|
114
165
|
if (e.enabled !== !0) return;
|
|
115
|
-
let t =
|
|
166
|
+
let t = S(e.schedule);
|
|
116
167
|
if (!t) return;
|
|
117
168
|
let n = e.state, r = n?.lastRunAtMs;
|
|
118
169
|
if (r != null) {
|
|
@@ -125,11 +176,11 @@ function g(e) {
|
|
|
125
176
|
...e.description ? { description: e.description } : {},
|
|
126
177
|
schedule: t,
|
|
127
178
|
nextRunAtMs: n?.nextRunAtMs ?? null,
|
|
128
|
-
...n?.lastRunStatus === void 0 ? {} : { lastRunStatus:
|
|
179
|
+
...n?.lastRunStatus === void 0 ? {} : { lastRunStatus: C(n.lastRunStatus) },
|
|
129
180
|
...r === void 0 ? {} : { lastRunAtMs: r }
|
|
130
181
|
};
|
|
131
182
|
}
|
|
132
|
-
function
|
|
183
|
+
function S(e) {
|
|
133
184
|
switch (e?.kind) {
|
|
134
185
|
case "cron": return {
|
|
135
186
|
kind: "cron",
|
|
@@ -149,7 +200,7 @@ function _(e) {
|
|
|
149
200
|
default: return;
|
|
150
201
|
}
|
|
151
202
|
}
|
|
152
|
-
function
|
|
203
|
+
function C(e) {
|
|
153
204
|
switch (e) {
|
|
154
205
|
case "ok": return i.Success;
|
|
155
206
|
case "error": return i.Failed;
|
|
@@ -157,4 +208,4 @@ function v(e) {
|
|
|
157
208
|
}
|
|
158
209
|
}
|
|
159
210
|
//#endregion
|
|
160
|
-
export {
|
|
211
|
+
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] }
|