mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
feat(assistant): expenses, shares, wind, journey tracks and Dawarich checks as MCP tools
- list_budget_items lists a trip's expenses with their ids, payers and splits, page by page so no page is cut down on its way to a model; get_budget_per_person answers who paid and owes what. Both in a new budget-items.mcp.ts, checked like their REST twins. - get_wind_forecast reads the hourly wind, gusts and direction of a day. - get_journey_tracks lists a journey's GPX tracks; the line for drawing rides under a key the provider never receives. - The Dawarich wishlist scan and the countries the recordings suggest become tools, with their confirming writes, in DawarichAtlasMcp in the Atlas group; the shared time window check refuses alike on REST and MCP, and the model never sees when the user was last seen in a city. - The journal's map, tracks and recorded days load with the journey group instead of riding in the core of every step. - The prompt points at list_budget_items for expense ids (the trip summary never carried them) and names the shares and the wind tools; each new read has its own live step.
This commit is contained in:
@@ -9,6 +9,8 @@ import {
|
||||
budgetUpdateMembersRequestSchema,
|
||||
budgetToggleMemberPaidRequestSchema,
|
||||
budgetReorderItemsRequestSchema,
|
||||
budgetItemsPageSchema,
|
||||
BUDGET_ITEMS_PAGE_DEFAULT,
|
||||
COST_CATEGORIES,
|
||||
typeToCostCategory,
|
||||
} from './budget.schema';
|
||||
@@ -157,3 +159,15 @@ describe('budgetUnconvertedSchema', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('budgetItemsPageSchema', () => {
|
||||
it('takes no paging at all, or an offset and a limit of 1 to 100 whole expenses', () => {
|
||||
expect(budgetItemsPageSchema.safeParse({}).success).toBe(true);
|
||||
expect(budgetItemsPageSchema.safeParse({ offset: 0, limit: 1 }).success).toBe(true);
|
||||
expect(budgetItemsPageSchema.safeParse({ offset: 150, limit: 100 }).success).toBe(true);
|
||||
for (const page of [{ offset: -1 }, { offset: 1.5 }, { limit: 0 }, { limit: 101 }, { limit: '10' }]) {
|
||||
expect(budgetItemsPageSchema.safeParse(page).success, JSON.stringify(page)).toBe(false);
|
||||
}
|
||||
expect(BUDGET_ITEMS_PAGE_DEFAULT).toBe(50);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -421,3 +421,30 @@ export const budgetReorderCategoriesRequestSchema = z.object({
|
||||
orderedCategories: z.array(z.string()),
|
||||
});
|
||||
export type BudgetReorderCategoriesRequest = z.infer<typeof budgetReorderCategoriesRequestSchema>;
|
||||
|
||||
/** How many expenses one page of the MCP expense list holds when the caller does not say. */
|
||||
export const BUDGET_ITEMS_PAGE_DEFAULT = 50;
|
||||
const BUDGET_ITEMS_PAGE_MAX = 100;
|
||||
|
||||
/**
|
||||
* One page of the expense list an MCP client reads (list_budget_items): the
|
||||
* expenses in their list order from `offset`, at most `limit` of them. A
|
||||
* budget of a few hundred rows is too long for one answer to a model, so it
|
||||
* pages; the totals next to the page always cover the whole trip.
|
||||
*/
|
||||
export const budgetItemsPageSchema = z.object({
|
||||
offset: z
|
||||
.number()
|
||||
.int()
|
||||
.min(0)
|
||||
.optional()
|
||||
.describe('How many expenses to skip: the next_offset of the page before (default 0)'),
|
||||
limit: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(BUDGET_ITEMS_PAGE_MAX)
|
||||
.optional()
|
||||
.describe(`How many expenses at most (default ${BUDGET_ITEMS_PAGE_DEFAULT}, at most ${BUDGET_ITEMS_PAGE_MAX})`),
|
||||
});
|
||||
export type BudgetItemsPage = z.infer<typeof budgetItemsPageSchema>;
|
||||
|
||||
Reference in New Issue
Block a user