@sctg/openclaw-coach 0.1.0 → 2.0.0

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.
Files changed (61) hide show
  1. package/README.md +296 -66
  2. package/assets/fonts/Inter_400Regular.ttf +0 -0
  3. package/assets/fonts/Inter_600SemiBold.ttf +0 -0
  4. package/assets/fonts/LICENSE.txt +93 -0
  5. package/assets/logo.png +0 -0
  6. package/assets/logo.svg +62 -0
  7. package/dist/charts/build.d.ts +71 -0
  8. package/dist/charts/build.js +276 -0
  9. package/dist/charts/labels.d.ts +38 -0
  10. package/dist/charts/labels.js +73 -0
  11. package/dist/charts/render.d.ts +10 -0
  12. package/dist/charts/render.js +26 -0
  13. package/dist/charts/svg.d.ts +47 -0
  14. package/dist/charts/svg.js +92 -0
  15. package/dist/config.d.ts +25 -0
  16. package/dist/config.js +38 -0
  17. package/dist/dates.d.ts +22 -0
  18. package/dist/dates.js +71 -0
  19. package/dist/garmin/gc.d.ts +25 -0
  20. package/dist/garmin/gc.js +81 -0
  21. package/dist/garmin/normalize.d.ts +20 -0
  22. package/dist/garmin/normalize.js +132 -0
  23. package/dist/index.js +188 -163
  24. package/dist/profile.d.ts +4 -0
  25. package/dist/profile.js +43 -0
  26. package/dist/science/associations.d.ts +56 -0
  27. package/dist/science/associations.js +102 -0
  28. package/dist/science/healthspan.d.ts +25 -0
  29. package/dist/science/healthspan.js +89 -0
  30. package/dist/science/hrv.d.ts +61 -0
  31. package/dist/science/hrv.js +119 -0
  32. package/dist/science/load.d.ts +107 -0
  33. package/dist/science/load.js +228 -0
  34. package/dist/science/performance.d.ts +93 -0
  35. package/dist/science/performance.js +191 -0
  36. package/dist/science/readiness.d.ts +47 -0
  37. package/dist/science/readiness.js +97 -0
  38. package/dist/science/recovery.d.ts +74 -0
  39. package/dist/science/recovery.js +173 -0
  40. package/dist/science/sleep.d.ts +79 -0
  41. package/dist/science/sleep.js +165 -0
  42. package/dist/science/stats.d.ts +50 -0
  43. package/dist/science/stats.js +201 -0
  44. package/dist/science/strength.d.ts +47 -0
  45. package/dist/science/strength.js +120 -0
  46. package/dist/store.d.ts +36 -0
  47. package/dist/store.js +78 -0
  48. package/dist/sync.d.ts +36 -0
  49. package/dist/sync.js +145 -0
  50. package/dist/tools.d.ts +427 -0
  51. package/dist/tools.js +721 -0
  52. package/dist/types.d.ts +143 -0
  53. package/dist/types.js +2 -0
  54. package/docs/SCIENCE.md +717 -0
  55. package/examples/ATHLETE-fr.md +72 -0
  56. package/examples/ATHLETE.md +74 -0
  57. package/examples/PLAN-fr.md +55 -0
  58. package/examples/PLAN.md +55 -0
  59. package/openclaw.plugin.json +152 -5
  60. package/package.json +14 -3
  61. package/skills/coach/SKILL.md +283 -208
@@ -0,0 +1,427 @@
1
+ /**
2
+ * Tool handlers. Each one loads the local store, syncs it with Garmin when
3
+ * asked, runs the models and returns a compact JSON result. Handlers take their
4
+ * dependencies as arguments so that tests can inject a fake `gc` and clock.
5
+ */
6
+ import type { Lang } from "./charts/labels.ts";
7
+ import { type ThemeName } from "./charts/svg.ts";
8
+ import type { CoachConfig } from "./config.ts";
9
+ import type { GcRunner } from "./garmin/gc.ts";
10
+ import { type SyncReport } from "./sync.ts";
11
+ import type { JournalEntry } from "./types.ts";
12
+ export type Deps = {
13
+ config: CoachConfig;
14
+ gc: GcRunner;
15
+ now?: () => Date;
16
+ };
17
+ export declare class ToolInputError extends Error {
18
+ }
19
+ export declare function dailyBriefing(deps: Deps, params: {
20
+ date?: unknown;
21
+ sync?: boolean;
22
+ }): Promise<{
23
+ date: string;
24
+ data: {
25
+ coverage: {
26
+ windowDays: number;
27
+ daysWithHrv: number;
28
+ daysWithSleep: number;
29
+ daysWithRestingHr: number;
30
+ daysWithRespiration: number;
31
+ daysWithSpo2: number;
32
+ daysWithSkinTemp: number;
33
+ activities: number;
34
+ activitiesFrom: string | null;
35
+ lastSync: string | null;
36
+ journalEntries: number;
37
+ };
38
+ assessedDate: string;
39
+ isToday: boolean;
40
+ sync: string | {
41
+ fetchedDays: number;
42
+ fetchedActivities: number;
43
+ errors: Record<string, string>;
44
+ };
45
+ dayErrors: Record<string, string>;
46
+ };
47
+ readiness: import("./science/readiness.ts").ReadinessDecision;
48
+ recovery: {
49
+ status: import("./types.ts").DataStatus;
50
+ score: number | null;
51
+ band: import("./science/recovery.ts").RecoveryBand | null;
52
+ components: Record<string, {
53
+ z: number;
54
+ weight: number;
55
+ }>;
56
+ coverage: number;
57
+ notes: string[];
58
+ algorithm: import("./types.ts").AlgorithmTag;
59
+ };
60
+ signals: Record<"hrv" | "restingHr" | "respiration" | "skinTemp" | "spo2", import("./science/recovery.ts").SignalDeviation>;
61
+ hrv: import("./science/hrv.ts").HrvAnalysis;
62
+ sleep: import("./science/sleep.ts").SleepAnalysis;
63
+ earlyWarning: import("./science/recovery.ts").WarningAnalysis;
64
+ load: {
65
+ intensity28: import("./science/load.ts").IntensityDistribution | null;
66
+ status: import("./types.ts").DataStatus;
67
+ algorithm: import("./types.ts").AlgorithmTag;
68
+ unit: "TRIMP (Banister)";
69
+ historyDays: number;
70
+ today: import("./science/load.ts").LoadPoint | null;
71
+ rampPerWeek: number | null;
72
+ rampPctPerWeek: number | null;
73
+ last7: number | null;
74
+ previous7: number | null;
75
+ weekChangePct: number | null;
76
+ acuteChronicRatio: number | null;
77
+ monotony: number | null;
78
+ strain: number | null;
79
+ sessions7: number;
80
+ unscoredSessions28: number;
81
+ restDays7: number;
82
+ flags: string[];
83
+ notes: string[];
84
+ };
85
+ garmin: {
86
+ hrvStatus: string | null;
87
+ bodyBattery: {
88
+ high: number | null;
89
+ low: number | null;
90
+ charged: number | null;
91
+ drained: number | null;
92
+ sleepChange: number | null;
93
+ } | null;
94
+ stress: {
95
+ avg: number | null;
96
+ max: number | null;
97
+ } | null;
98
+ note: string;
99
+ };
100
+ activities: {
101
+ today: {
102
+ id: string;
103
+ date: string;
104
+ start: string | null;
105
+ type: string;
106
+ name: string | null;
107
+ durationMin: number | null;
108
+ distanceKm: number | null;
109
+ elevGainM: number | null;
110
+ avgHr: number | null;
111
+ maxHr: number | null;
112
+ pace: string | null;
113
+ gradeAdjustedPace: string | null;
114
+ load: number | null;
115
+ loadMethod: "zones" | "mean-hr" | null;
116
+ garminLoad: number | null;
117
+ aerobicTE: number | null;
118
+ anaerobicTE: number | null;
119
+ }[];
120
+ yesterday: {
121
+ id: string;
122
+ date: string;
123
+ start: string | null;
124
+ type: string;
125
+ name: string | null;
126
+ durationMin: number | null;
127
+ distanceKm: number | null;
128
+ elevGainM: number | null;
129
+ avgHr: number | null;
130
+ maxHr: number | null;
131
+ pace: string | null;
132
+ gradeAdjustedPace: string | null;
133
+ load: number | null;
134
+ loadMethod: "zones" | "mean-hr" | null;
135
+ garminLoad: number | null;
136
+ aerobicTE: number | null;
137
+ anaerobicTE: number | null;
138
+ }[];
139
+ };
140
+ journal: JournalEntry;
141
+ profile: {
142
+ sex: import("./types.ts").Sex | null;
143
+ hrMax: number | null;
144
+ hrMaxSource: "config" | "observed" | "age-formula" | null;
145
+ hrRest: number | null;
146
+ hrRestSource: "config" | "baseline" | null;
147
+ lthr: number | null;
148
+ lthrSource: "config" | "garmin" | null;
149
+ sleepNeedH: number;
150
+ sleepNeedSource: "config" | "default";
151
+ };
152
+ }>;
153
+ export declare function trends(deps: Deps, params: {
154
+ days?: number;
155
+ includeDaily?: boolean;
156
+ sync?: boolean;
157
+ }): Promise<Record<string, unknown>>;
158
+ export type PlannedSession = {
159
+ date: string;
160
+ load?: number;
161
+ durationMin?: number;
162
+ zone?: number;
163
+ };
164
+ export declare function trainingLoad(deps: Deps, params: {
165
+ plan?: PlannedSession[];
166
+ sync?: boolean;
167
+ }): Promise<Record<string, unknown>>;
168
+ export declare function activityDeepDive(deps: Deps, params: {
169
+ activityId?: unknown;
170
+ }): Promise<{
171
+ activityId: string;
172
+ errors: Record<string, string>;
173
+ note: string;
174
+ algorithm?: undefined;
175
+ summary?: undefined;
176
+ load?: undefined;
177
+ hrZones?: undefined;
178
+ decoupling?: undefined;
179
+ efficiency?: undefined;
180
+ splits?: undefined;
181
+ weather?: undefined;
182
+ deviceTemperatureC?: undefined;
183
+ flags?: undefined;
184
+ } | {
185
+ activityId: string;
186
+ algorithm: import("./types.ts").AlgorithmTag;
187
+ summary: {
188
+ id: string;
189
+ date: string;
190
+ start: string | null;
191
+ type: string;
192
+ name: string | null;
193
+ durationMin: number | null;
194
+ distanceKm: number | null;
195
+ elevGainM: number | null;
196
+ avgHr: number | null;
197
+ maxHr: number | null;
198
+ pace: string | null;
199
+ gradeAdjustedPace: string | null;
200
+ load: number | null;
201
+ loadMethod: "zones" | "mean-hr" | null;
202
+ garminLoad: number | null;
203
+ aerobicTE: number | null;
204
+ anaerobicTE: number | null;
205
+ };
206
+ load: import("./science/load.ts").SessionLoad;
207
+ hrZones: {
208
+ minutes: number[];
209
+ pct: number[];
210
+ floorsBpm: number[] | null;
211
+ } | null;
212
+ decoupling: import("./science/performance.ts").Decoupling | null;
213
+ efficiency: {
214
+ value: number;
215
+ unit: string;
216
+ note: string;
217
+ } | null;
218
+ splits: {
219
+ n: number;
220
+ km: number;
221
+ pace: string | null;
222
+ gradeAdjustedPace: string | null;
223
+ avgHr: number | null;
224
+ gainM: number | null;
225
+ lossM: number | null;
226
+ gradePct: number | null;
227
+ }[];
228
+ weather: {
229
+ temperatureC: number | null;
230
+ humidityPct: number | null;
231
+ conditions: {} | null;
232
+ unitAssumption: string;
233
+ } | null;
234
+ deviceTemperatureC: {
235
+ min: number | null;
236
+ max: number | null;
237
+ };
238
+ flags: string[];
239
+ errors: Record<string, string>;
240
+ note?: undefined;
241
+ }>;
242
+ export declare function zonesAndPaces(deps: Deps, params: {
243
+ raceDistanceM?: number;
244
+ raceTimeS?: number;
245
+ targetDistanceM?: number;
246
+ }): Promise<Record<string, unknown>>;
247
+ export declare function strengthAnalysis(deps: Deps, params: {
248
+ activityId?: unknown;
249
+ }): Promise<{
250
+ activityId: string;
251
+ error: import("./garmin/gc.ts").GcErrorCode;
252
+ message: string;
253
+ } | {
254
+ notes: string[];
255
+ exercises: import("./science/strength.ts").ExerciseSummary[];
256
+ totalSets: number;
257
+ totalVolumeKg: number | null;
258
+ setsByMuscleGroup: Record<string, number>;
259
+ unidentifiedSets: number;
260
+ activityId: string;
261
+ algorithm: import("./types.ts").AlgorithmTag;
262
+ error?: undefined;
263
+ message?: undefined;
264
+ }>;
265
+ export type JournalInput = {
266
+ date?: unknown;
267
+ tags?: Record<string, unknown>;
268
+ rpe?: number;
269
+ fatigue?: number;
270
+ soreness?: number;
271
+ mood?: number;
272
+ sleepQuality?: number;
273
+ stress?: number;
274
+ symptoms?: unknown;
275
+ notes?: unknown;
276
+ };
277
+ export declare function journalLog(deps: Deps, params: JournalInput): Promise<{
278
+ saved: JournalEntry;
279
+ entries: number;
280
+ }>;
281
+ export declare function journalInsights(deps: Deps, params: {
282
+ days?: number;
283
+ }): Promise<{
284
+ algorithm: import("./types.ts").AlgorithmTag;
285
+ associations: import("./science/associations.ts").Association[];
286
+ insufficient: Array<{
287
+ tag: string;
288
+ daysWith: number;
289
+ daysWithout: number;
290
+ }>;
291
+ caveats: string[];
292
+ windowDays: number;
293
+ journalDays: number;
294
+ wellness7: {
295
+ fatigue: number | null;
296
+ soreness: number | null;
297
+ mood: number | null;
298
+ sleepQuality: number | null;
299
+ stress: number | null;
300
+ scale: string;
301
+ };
302
+ }>;
303
+ export type WorkoutStep = {
304
+ type: string;
305
+ durationS: number;
306
+ target?: string;
307
+ };
308
+ export declare function workoutPush(deps: Deps, params: {
309
+ name?: unknown;
310
+ sport?: unknown;
311
+ steps?: unknown;
312
+ confirm?: boolean;
313
+ }): Promise<{
314
+ created: boolean;
315
+ preview: {
316
+ name: string;
317
+ sport: string;
318
+ totalMin: number;
319
+ steps: {
320
+ type: string;
321
+ duration: number;
322
+ target?: string;
323
+ }[];
324
+ estimatedLoad: number | null;
325
+ currentFitness: number | null;
326
+ };
327
+ message: string;
328
+ workoutId?: undefined;
329
+ error?: undefined;
330
+ } | {
331
+ created: boolean;
332
+ workoutId: {} | null;
333
+ preview: {
334
+ name: string;
335
+ sport: string;
336
+ totalMin: number;
337
+ steps: {
338
+ type: string;
339
+ duration: number;
340
+ target?: string;
341
+ }[];
342
+ estimatedLoad: number | null;
343
+ currentFitness: number | null;
344
+ };
345
+ message: string;
346
+ error?: undefined;
347
+ } | {
348
+ created: boolean;
349
+ preview: {
350
+ name: string;
351
+ sport: string;
352
+ totalMin: number;
353
+ steps: {
354
+ type: string;
355
+ duration: number;
356
+ target?: string;
357
+ }[];
358
+ estimatedLoad: number | null;
359
+ currentFitness: number | null;
360
+ };
361
+ error: "not_configured" | "auth" | "rate_limited" | "timeout" | "unsupported" | "connection" | "error";
362
+ message: string;
363
+ workoutId?: undefined;
364
+ }>;
365
+ export declare function dataStatus(deps: Deps, params: {
366
+ sync?: boolean;
367
+ }): Promise<{
368
+ date: string;
369
+ timezone: string;
370
+ dataDir: string;
371
+ sync: string | SyncReport;
372
+ coverage: {
373
+ windowDays: number;
374
+ daysWithHrv: number;
375
+ daysWithSleep: number;
376
+ daysWithRestingHr: number;
377
+ daysWithRespiration: number;
378
+ daysWithSpo2: number;
379
+ daysWithSkinTemp: number;
380
+ activities: number;
381
+ activitiesFrom: string | null;
382
+ lastSync: string | null;
383
+ journalEntries: number;
384
+ };
385
+ profile: {
386
+ sex: import("./types.ts").Sex | null;
387
+ hrMax: number | null;
388
+ hrMaxSource: "config" | "observed" | "age-formula" | null;
389
+ hrRest: number | null;
390
+ hrRestSource: "config" | "baseline" | null;
391
+ lthr: number | null;
392
+ lthrSource: "config" | "garmin" | null;
393
+ sleepNeedH: number;
394
+ sleepNeedSource: "config" | "default";
395
+ };
396
+ retentionDays: number;
397
+ advice: string[];
398
+ }>;
399
+ export declare const CHART_IDS: readonly ["recovery_gauge", "ceiling", "signals", "hrv_trend", "load_curve", "sleep_nights"];
400
+ export type ChartId = (typeof CHART_IDS)[number];
401
+ export declare function briefingCharts(deps: Deps, params: {
402
+ date?: unknown;
403
+ sync?: boolean;
404
+ charts?: string[];
405
+ lang?: string;
406
+ theme?: string;
407
+ }): Promise<{
408
+ date: string;
409
+ lang: Lang;
410
+ theme: ThemeName;
411
+ charts: {
412
+ id: ChartId;
413
+ path: string;
414
+ cid: string;
415
+ displayWidth: number;
416
+ displayHeight: number;
417
+ pixelWidth: number;
418
+ pixelHeight: number;
419
+ bytes: number;
420
+ alt: string;
421
+ }[];
422
+ skipped: {
423
+ id: ChartId;
424
+ reason: string;
425
+ }[];
426
+ usage: string;
427
+ }>;