Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* Structured tool definitions compatible with Claude/OpenAI tool_use format.
* These define the computation tools available to the AI during workout generation,
* as well as the submit tools used to return final results.
*/
export interface ToolDefinition {
name: string;
description: string;
input_schema: {
type: 'object';
properties: Record<string, unknown>;
required: string[];
};
}
// ── Submit tool definitions ──────────────────────────────────
// These are the canonical submit tool schemas. Both the Anthropic provider and
// any Deno copies must import from here rather than defining their own copies.
const prescribedExerciseItems = {
type: 'object',
properties: {
id: { type: 'string', description: 'Unique identifier (short kebab-case)' },
exercise_id: { type: 'string', description: 'UUID of the exercise — must be an id returned by lookup_exercises; never invent this value' },
exercise_name: { type: 'string', description: 'Human-readable exercise name' },
order: { type: 'integer', description: 'Sequence order (1-based)' },
is_warmup: { type: 'boolean' },
is_backup: { type: 'boolean', description: 'True if this is a backup/alternative exercise' },
notes: { type: ['string', 'null'], description: 'Coaching cue or note' },
movement_patterns: {
type: 'array',
items: { type: 'string', enum: ['squat', 'hinge', 'push', 'pull'] },
},
sets: {
type: 'array',
items: {
type: 'object',
properties: {
target_weight_kg: { type: ['number', 'null'] },
target_reps: { type: 'integer' },
target_rpe: { type: ['number', 'null'] },
rest_seconds: { type: 'integer' },
},
required: ['target_weight_kg', 'target_reps', 'target_rpe', 'rest_seconds'],
},
},
},
required: ['id', 'exercise_id', 'exercise_name', 'order', 'is_warmup', 'is_backup', 'notes', 'movement_patterns', 'sets'],
} as const;
export const SUBMIT_WORKOUT_PLAN_TOOL: ToolDefinition = {
name: 'submit_workout_plan',
description:
'Submit the final generated workout plan. Call this when you are satisfied the workout meets all requirements.',
input_schema: {
type: 'object',
properties: {
prescribed_exercises: {
type: 'array',
description: 'The prescribed exercises for this session',
items: prescribedExerciseItems,
},
},
required: ['prescribed_exercises'],
},
};
export const SUBMIT_ADAPTED_WORKOUT_TOOL: ToolDefinition = {
name: 'submit_adapted_workout',
description: 'Submit the adapted workout with an explanation for the athlete.',
input_schema: {
type: 'object',
properties: {
prescribed_exercises: {
type: 'array',
description: 'The adapted exercise list',
items: prescribedExerciseItems,
},
explanation: {
type: 'string',
description: 'Brief explanation of the changes made, shown to the athlete',
},
},
required: ['prescribed_exercises', 'explanation'],
},
};
export const SUBMIT_REVIEW_QUESTIONS_TOOL: ToolDefinition = {
name: 'submit_review_questions',
description: 'Submit the generated review questions.',
input_schema: {
type: 'object',
properties: {
questions: {
type: 'array',
description: 'The review questions to present to the athlete',
items: {
type: 'object',
properties: {
question: { type: 'string', description: 'The question text' },
options: {
type: ['array', 'null'],
items: { type: 'string' },
description: 'Predefined options or null for open-ended',
},
kind: {
type: 'string',
enum: ['standard', 'profile_enrichment', 'goal_refinement'],
},
},
required: ['question', 'options', 'kind'],
},
},
},
required: ['questions'],
},
};
export const SUBMIT_NARRATIVE_TOOL: ToolDefinition = {
name: 'submit_narrative',
description: 'Submit the generated training narrative.',
input_schema: {
type: 'object',
properties: {
narrative: {
type: 'string',
description: 'The narrative text to display to the athlete',
},
},
required: ['narrative'],
},
};
// ── Computation tool definitions ─────────────────────────────
export const TOOL_DEFINITIONS: ToolDefinition[] = [
{
name: 'estimate_1rm',
description:
'Estimate one-rep max from a weight and rep count using the Epley formula. Use this to gauge an athlete\'s strength level for a given exercise.',
input_schema: {
type: 'object',
properties: {
weight_kg: { type: 'number', description: 'Weight lifted in kilograms' },
reps: { type: 'integer', description: 'Number of repetitions performed' },
},
required: ['weight_kg', 'reps'],
},
},
{
name: 'calculate_volume',
description:
'Calculate total training volume and per-movement-pattern breakdown from a list of logged sets. Volume = weight × reps for each set.',
input_schema: {
type: 'object',
properties: {
sets: {
type: 'array',
description: 'Array of set logs with weight, reps, and movement patterns',
items: {
type: 'object',
properties: {
actual_weight_kg: { type: ['number', 'null'], description: 'Weight used in kg' },
actual_reps: { type: ['integer', 'null'], description: 'Reps completed' },
skipped: { type: 'boolean', description: 'Whether the set was skipped' },
movement_patterns: {
type: 'array',
items: { type: 'string', enum: ['squat', 'hinge', 'push', 'pull'] },
description: 'Movement patterns for the exercise',
},
},
required: ['actual_weight_kg', 'actual_reps', 'skipped', 'movement_patterns'],
},
},
},
required: ['sets'],
},
},
{
name: 'estimate_workout_time',
description:
'Estimate total workout duration in minutes from prescribed exercises. Accounts for working time (reps × ~3s), rest periods, and transition time between exercises.',
input_schema: {
type: 'object',
properties: {
prescribed_exercises: {
type: 'array',
description: 'Array of prescribed exercises with sets and rest times',
items: {
type: 'object',
properties: {
is_backup: { type: 'boolean', description: 'Whether this is a backup exercise (excluded from time estimate)' },
sets: {
type: 'array',
items: {
type: 'object',
properties: {
target_reps: { type: 'integer', description: 'Target reps for this set' },
rest_seconds: { type: 'integer', description: 'Rest period after this set in seconds' },
},
required: ['target_reps', 'rest_seconds'],
},
},
},
required: ['is_backup', 'sets'],
},
},
},
required: ['prescribed_exercises'],
},
},
{
name: 'suggest_progression',
description:
'Suggest the next weight and rep target for an exercise based on previous set performance and target rep range. Considers athlete feeling to modulate progression.',
input_schema: {
type: 'object',
properties: {
previous_sets: {
type: 'array',
description: 'Previous set logs for this exercise',
items: {
type: 'object',
properties: {
actual_weight_kg: { type: ['number', 'null'], description: 'Weight used' },
actual_reps: { type: ['integer', 'null'], description: 'Reps completed' },
feeling: { type: 'string', enum: ['great', 'good', 'okay', 'hard', 'awful'], description: 'How the set felt' },
skipped: { type: 'boolean', description: 'Whether skipped' },
},
required: ['actual_weight_kg', 'actual_reps', 'feeling', 'skipped'],
},
},
target_rep_range: {
type: 'object',
properties: {
low: { type: 'integer', description: 'Lower bound of target rep range' },
high: { type: 'integer', description: 'Upper bound of target rep range' },
},
required: ['low', 'high'],
},
},
required: ['previous_sets', 'target_rep_range'],
},
},
{
name: 'validate_session',
description:
'Validate a generated workout against platform safety rules. Checks volume concentration per movement pattern and time vs time cap. Returns whether the workout is valid and any violations. Note: the platform additionally checks exercise library membership server-side; the AI invocation skips that check automatically.',
input_schema: {
type: 'object',
properties: {
session_type: { type: 'string', enum: ['strength', 'mobility', 'conditioning', 'hybrid'], description: 'Type of training session' },
time_cap_minutes: { type: 'integer', description: 'Maximum allowed session duration in minutes' },
prescribed_exercises: {
type: 'array',
description: 'Exercises prescribed for the session',
items: {
type: 'object',
properties: {
is_backup: { type: 'boolean' },
movement_patterns: {
type: 'array',
items: { type: 'string', enum: ['squat', 'hinge', 'push', 'pull'] },
},
sets: {
type: 'array',
items: {
type: 'object',
properties: {
target_reps: { type: 'integer' },
rest_seconds: { type: 'integer' },
},
required: ['target_reps', 'rest_seconds'],
},
},
},
required: ['is_backup', 'movement_patterns', 'sets'],
},
},
},
required: ['session_type', 'time_cap_minutes', 'prescribed_exercises'],
},
},
{
name: 'lookup_exercises',
description:
'Look up exercises from the library that match the given equipment and movement pattern. ' +
'Returns exercise rows including their id (uuid) — use these id values verbatim as exercise_id ' +
'in submit_workout_plan. ' +
'call this before building the workout plan; never invent exercise_id values. ' +
"lookups are scoped to the athlete's available_equipment.",
input_schema: {
type: 'object',
properties: {
available_equipment: {
type: 'array',
items: { type: 'string' },
description: 'uuids of equipment types available at this training location (from the session context)',
},
movement_pattern: {
type: 'string',
enum: ['squat', 'hinge', 'push', 'pull'],
description: 'movement pattern to filter by — make one call per pattern',
},
difficulty_tier: {
type: 'string',
enum: ['foundational', 'intermediate', 'advanced', 'specialist'],
description: 'optional: restrict to a specific difficulty tier',
},
readiness: {
type: 'array',
items: { type: 'string', enum: ['confident', 'familiar', 'unknown'] },
description: 'optional: filter by athlete familiarity readiness levels; omit for a broader list',
},
limit: {
type: 'integer',
description: 'maximum rows to return (default 20, hard cap 50)',
},
},
required: ['available_equipment', 'movement_pattern'],
},
},
];
|