Skip to content

Commit ebf621f

Browse files
committed
refactor(tools): slim intervals_list_events payload, align error shape
Project events to {id, start_date_local, name, moving_time, icu_training_load} so the LLM sees identifiable workouts without workout_doc and other bloat. Rename delete error field message -> details to match the convention in intervals_create_workout.
1 parent fe1f4a8 commit ebf621f

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/agent/tools.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,13 @@ function createIntervalsTools(
329329
category: ["WORKOUT"],
330330
});
331331
if (!result.ok) return { error: result.error.kind };
332-
return result.value;
332+
return result.value.map((e) => ({
333+
id: e.id,
334+
start_date_local: e.start_date_local,
335+
name: e.name,
336+
moving_time: e.moving_time,
337+
icu_training_load: e.icu_training_load,
338+
}));
333339
},
334340
}),
335341

@@ -356,7 +362,7 @@ function createIntervalsTools(
356362
});
357363
if (!res.ok) {
358364
const body = await res.text().catch(() => "");
359-
return { error: `http_${res.status}`, message: body || res.statusText };
365+
return { error: `http_${res.status}`, details: body || res.statusText };
360366
}
361367
return { deleted: true };
362368
},

tests/helpers/mock-intervals.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ export function createMockIntervalsServer(options: MockIntervalsOptions = {}) {
355355
return HttpResponse.json({ id: eventId, ...body }, { status: 200 });
356356
}),
357357

358-
// GET /api/v1/athlete/:id/events — list scheduled events (filters created workouts
359-
// by optional oldest/newest query params; ignores category since we only emit WORKOUT)
358+
// GET /api/v1/athlete/:id/events — list scheduled events
360359
http.get("https://intervals.icu/api/v1/athlete/:id/events", ({ request }) => {
361360
const url = new URL(request.url);
362361
const oldest = url.searchParams.get("oldest");
@@ -372,8 +371,7 @@ export function createMockIntervalsServer(options: MockIntervalsOptions = {}) {
372371
return HttpResponse.json(filtered);
373372
}),
374373

375-
// DELETE /api/v1/athlete/:id/events/:eventId — delete scheduled event; honors
376-
// ?notBefore=YYYY-MM-DD by rejecting when the event's date is earlier.
374+
// DELETE /api/v1/athlete/:id/events/:eventId — delete scheduled event (honors ?notBefore)
377375
http.delete(
378376
"https://intervals.icu/api/v1/athlete/:id/events/:eventId",
379377
({ request, params }) => {

0 commit comments

Comments
 (0)