@looply/core 0.5.38 → 0.5.43

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.
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ /**
3
+ * WHAT LOOPLY'S WATCHDOG FOUND AND DID, AS AUTORYN SHOWS IT.
4
+ *
5
+ * ─────────────────────────────────────────────────────────────────────────────
6
+ * On 2026-10-22 every stalled ticket was found by a person reading a PC's logs and the project's
7
+ * `.looply/state`, then fixed by hand or by a release: a hold kept on a verdict that no longer stood,
8
+ * a checkout an earlier run left dirty, every allowed AI account resting while other connected ones
9
+ * were refused by their owners' settings, a delivery no pass moved, a PC's Heroku login switched to
10
+ * another account. The daemon now looks every 15 minutes (`watchdog.ts` in the CLI), repairs what is
11
+ * safe to repair, and says the rest.
12
+ *
13
+ * This is the record it keeps — beside the project's state, and in the machine's feature report, so
14
+ * AutoRyn can show it per component. Each entry is one thing it did or said, in plain words: what it
15
+ * found, whether it fixed it, and — when it could not — what a person should do. Never a path to a
16
+ * person's own folder, a credential, or an email beyond what the PC's own tools already print.
17
+ *
18
+ * Pure: types and the one lenient reader both sides use.
19
+ * ─────────────────────────────────────────────────────────────────────────────
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.WATCHDOG_SENTENCE_MAX = exports.WATCHDOG_ACTIONS_MAX = exports.WATCHDOG_WAITING_MAX = exports.WATCHDOG_OUTCOMES = exports.WATCHDOG_AREAS = exports.WATCHDOG_STALLED_AFTER_MS = exports.WATCHDOG_EVERY_MS = void 0;
23
+ exports.cleanWatchdogReport = cleanWatchdogReport;
24
+ /** How often the watchdog looks. */
25
+ exports.WATCHDOG_EVERY_MS = 15 * 60_000;
26
+ /** A goal waiting this long is listed, and what cannot be fixed is said. Same as the ticket's stall. */
27
+ exports.WATCHDOG_STALLED_AFTER_MS = 60 * 60_000;
28
+ /** What an entry is about. */
29
+ exports.WATCHDOG_AREAS = [
30
+ /** A goal held for a machine fault (`environment-hold.json`). */
31
+ 'hold',
32
+ /** A goal waiting with no hold the ticket was told about. */
33
+ 'wait',
34
+ /** A checkout Looply made, left with changes in it. */
35
+ 'checkout',
36
+ /** The AI accounts a goal may use. */
37
+ 'accounts',
38
+ /** A delivered change no pass moves. */
39
+ 'delivery',
40
+ /** The PC's sign-in to a deploy target (Heroku). */
41
+ 'deploy_login',
42
+ ];
43
+ /**
44
+ * fixed the cause was gone or was repaired, and the goal or delivery moves again;
45
+ * alerted it could not be fixed here: the ticket says it, with the action (once per stall);
46
+ * noted worth knowing, nothing to do yet (a retry made, an account picture).
47
+ */
48
+ exports.WATCHDOG_OUTCOMES = ['fixed', 'alerted', 'noted'];
49
+ exports.WATCHDOG_WAITING_MAX = 20;
50
+ exports.WATCHDOG_ACTIONS_MAX = 30;
51
+ exports.WATCHDOG_SENTENCE_MAX = 300;
52
+ const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
53
+ const text = (v, max = exports.WATCHDOG_SENTENCE_MAX) => {
54
+ if (typeof v !== 'string')
55
+ return null;
56
+ const t = v.replace(/\s+/g, ' ').trim();
57
+ if (t === '')
58
+ return null;
59
+ return t.length > max ? `${t.slice(0, max - 1)}…` : t;
60
+ };
61
+ const iso = (v) => (typeof v === 'string' && v.length <= 40 && !Number.isNaN(Date.parse(v)) ? v : null);
62
+ const GOAL_ID = /^gol_[A-Za-z0-9]{6,40}$/;
63
+ const goalOf = (v) => (typeof v === 'string' && GOAL_ID.test(v) ? v : null);
64
+ const codeOf = (v) => (typeof v === 'string' && /^[a-z][a-z_-]{0,39}$/.test(v) ? v : null);
65
+ /**
66
+ * A report as a machine sent it, cleaned: anything malformed is dropped rather than refused, so a
67
+ * newer machine's extra fields never cost the rest of its feature report. Null when it is not one.
68
+ */
69
+ function cleanWatchdogReport(x) {
70
+ if (!isObj(x))
71
+ return null;
72
+ const at = iso(x['at']);
73
+ if (at === null)
74
+ return null;
75
+ const waiting = (Array.isArray(x['waiting']) ? x['waiting'] : [])
76
+ .filter(isObj)
77
+ .flatMap((w) => {
78
+ const goalId = goalOf(w['goalId']);
79
+ const since = iso(w['since']);
80
+ const reason = text(w['reason']);
81
+ return goalId === null || since === null || reason === null ? [] : [{ goalId, code: codeOf(w['code']), since, reason }];
82
+ })
83
+ .slice(0, exports.WATCHDOG_WAITING_MAX);
84
+ const actions = (Array.isArray(x['actions']) ? x['actions'] : [])
85
+ .filter(isObj)
86
+ .flatMap((a) => {
87
+ const when = iso(a['at']);
88
+ const area = a['area'];
89
+ const outcome = a['outcome'];
90
+ const said = text(a['said']);
91
+ if (when === null || said === null)
92
+ return [];
93
+ if (typeof area !== 'string' || !exports.WATCHDOG_AREAS.includes(area))
94
+ return [];
95
+ if (typeof outcome !== 'string' || !exports.WATCHDOG_OUTCOMES.includes(outcome))
96
+ return [];
97
+ return [{ at: when, area: area, outcome: outcome, goalId: goalOf(a['goalId']), code: codeOf(a['code']), said, todo: text(a['todo']) }];
98
+ })
99
+ .slice(-exports.WATCHDOG_ACTIONS_MAX);
100
+ return { at, waiting, actions };
101
+ }
102
+ //# sourceMappingURL=watchdog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watchdog.js","sourceRoot":"","sources":["../src/watchdog.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAsFH,kDA2BC;AA/GD,oCAAoC;AACvB,QAAA,iBAAiB,GAAG,EAAE,GAAG,MAAM,CAAC;AAC7C,wGAAwG;AAC3F,QAAA,yBAAyB,GAAG,EAAE,GAAG,MAAM,CAAC;AAErD,8BAA8B;AACjB,QAAA,cAAc,GAAG;IAC5B,iEAAiE;IACjE,MAAM;IACN,6DAA6D;IAC7D,MAAM;IACN,uDAAuD;IACvD,UAAU;IACV,sCAAsC;IACtC,UAAU;IACV,wCAAwC;IACxC,UAAU;IACV,oDAAoD;IACpD,cAAc;CACN,CAAC;AAGX;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,CAAC,OAAO,EAAE,SAAS,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looply/core",
3
- "version": "0.5.38",
3
+ "version": "0.5.43",
4
4
  "description": "Shared event schema, state machines and ledger projection for looply",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",