@aidenhq/sdk 0.5.19 → 0.5.21
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/README.md +4 -0
- package/dist/src/schedule.js +13 -5
- package/dist/src/task-state-types.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,3 +26,7 @@ without a version bump (services import the published package, so an unpublished
|
|
|
26
26
|
A change to the SDK lands in two steps: the PR that changes it and bumps the version; then, once it is published, the PRs that
|
|
27
27
|
move each consumer's pin (`bun add --exact @aidenhq/sdk@X.Y.Z` in its folder). A consumer's PR never depends on an SDK change that
|
|
28
28
|
is not yet on npm.
|
|
29
|
+
|
|
30
|
+
Test the consumers before opening the SDK PR, so one release carries everything they need: `bun pm pack` here, then
|
|
31
|
+
`bun add ../../kernel/sdk/aidenhq-sdk-X.Y.Z.tgz` (the relative path to the tarball) in each consumer you change, run its tests, and
|
|
32
|
+
revert that dependency change and delete the tarball before committing (the copies `scripts/sync-shared.ts` writes still land with the SDK change).
|
package/dist/src/schedule.js
CHANGED
|
@@ -349,20 +349,28 @@ function editableEnglish(lines, fmt) {
|
|
|
349
349
|
const fields = lines.map((l) => (isRefusal(parseSchedule(l, fmt)) ? null : parseSchedule(l, fmt).crons)).flatMap((cs) => (cs?.length === 1 ? [cs[0].split(/\s+/)] : []));
|
|
350
350
|
if (fields.length !== lines.length)
|
|
351
351
|
return null;
|
|
352
|
-
|
|
352
|
+
// A day field by the dates it expands to, not its text: "01-07" is "1-7", and the order the caller wrote is not the parser's.
|
|
353
|
+
const dd = (f, i) => f === "*" ? "*" : (expand(f, i) ?? []).map(String).join(",");
|
|
354
|
+
const day = (f) => `${dd(f[2], 2)} ${dd(f[3], 3)} ${f[4] === "*" ? "*" : expandCronDay(f[4])?.join(",")}`;
|
|
353
355
|
if (fields.some((f) => day(f) !== day(fields[0])))
|
|
354
356
|
return null;
|
|
355
357
|
const times = [...new Set(lines.flatMap((l) => timesOf([l]) ?? []))].sort((a, b) => a - b);
|
|
356
|
-
const [, , dom, mon, dow] = fields[0];
|
|
358
|
+
const [, , dom = "*", mon = "*", dow = "*"] = fields[0];
|
|
357
359
|
const days = dow === "*" ? [0, 1, 2, 3, 4, 5, 6] : (expandCronDay(dow) ?? []);
|
|
360
|
+
// The first Monday is "the first Monday of every month", never "the 1st": a week of dates (1-7, 8-14, 15-21, 22-28) on one weekday
|
|
361
|
+
// is a weekday rule, by the dates the field expands to however it is spelled ("1-7", "1,2,3,4,5,6,7", "01-07").
|
|
362
|
+
const doms = expand(dom, 2) ?? [];
|
|
363
|
+
const week = doms.length === 7 && doms[0] <= 22 && (doms[0] - 1) % 7 === 0 && doms.every((d, i) => d === doms[0] + i) ? doms[0] : null;
|
|
364
|
+
const nthDay = week !== null && dow !== "*" && days.length === 1 ? `the ${NTH[(week - 1) / 7]} ${LONG[days[0]]} of every month` : null;
|
|
358
365
|
// A date ("every month on the 1st at 9:00 and 16:30") and a weekday set each read back; a no-day schedule is "every day".
|
|
359
|
-
const when =
|
|
366
|
+
const when = nthDay ?? (doms.length === 1 ? `every month on the ${ordinal(doms[0])}` : dom !== "*" ? null : mon !== "*" ? null : days.length === 7 ? "every day" : `on ${englishDays(days)}`);
|
|
360
367
|
if (!when)
|
|
361
368
|
return null;
|
|
362
369
|
const english = `${when} at ${times.map(h24).join(", ")}`;
|
|
363
370
|
const back = parseSchedule(english, fmt);
|
|
364
|
-
// The phrase must mean the same moments, whichever equivalent spelling the caller used
|
|
365
|
-
|
|
371
|
+
// The phrase must mean the same moments, whichever equivalent spelling the caller used: the day fields by the dates and days they
|
|
372
|
+
// expand to ("01-07" is "1-7"), never their text, so a leading zero doesn't make a schedule read back differently.
|
|
373
|
+
const signature = (cs) => cs.flatMap((c) => { const f = c.split(/\s+/); const d = f[4] === "*" ? ["*"] : (expandCronDay(f[4]) ?? []); return (timesOf([c]) ?? []).map((t) => `${dd(f[2], 2)} ${dd(f[3], 3)} ${d.join(",")}@${t}`); }).sort().join("|");
|
|
366
374
|
return !isRefusal(back) && signature(back.crons) === signature(lines) ? english : null;
|
|
367
375
|
}
|
|
368
376
|
/**
|
|
@@ -40,6 +40,8 @@ export type StateRow = TaskState & {
|
|
|
40
40
|
origin: string | null;
|
|
41
41
|
holder_name?: string;
|
|
42
42
|
holder_gone?: true;
|
|
43
|
+
/** When the task's last idle wake ended (bound, dropped or covered); with it the idle sweep re-fires a `history_expired` task whose own `since` never moves. */
|
|
44
|
+
swept_since?: string;
|
|
43
45
|
};
|
|
44
46
|
export type StateRead = {
|
|
45
47
|
as_of: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidenhq/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21",
|
|
4
4
|
"description": "The shared code of AidenHQ modules: contract types, engine IO, the caller check and fence, write executors, the reviewer side, the judges' models and call, the source writer and the vendor MCP pass-through.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|