mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
3f38621024
A trip can now turn a trip addon (lists, costs, documents, collab, road trip, tours) on or off for itself, whatever the instance switch says. No row in the new trip_addon_overrides table means the trip follows the instance; a row is the owner's choice. Going back to the instance setting deletes the row, and no addon data is touched either way. - GET/PUT /api/trips/:tripId/addons[/:addonId] (every member reads, the owner writes) and the MCP tools get_trip_addons and set_trip_addon, on the shared tripAddons contract; tripAddons:changed tells the members. - Every trip-scoped addon surface asks the trip: REST through TripAddonGuard, MCP through a per-call gate on the named or pinned trip, plugin RPC and events, the share link, the offline bundle, reminders, doc sync, the assistant (tools, keep_attached_file), booking costs, the trip summary prompt, and the cross-trip tour reads (library, Atlas stats, collection save). - Routes without a trip open while the addon is on in any of the user's trips. Switching an addon on that the instance has off ends the members' MCP sessions so they reconnect with its tools. - A copied trip takes its owner's choices along. Behaviour changes: an anonymous call to an addon route that is off now gets 401 instead of 404, and with an instance switch off the packing, todo and files plugin RPC methods, the files MCP tools, todo reminder mails, core plugin events, plugin view contributions, the share link's lists, costs and chat sections and the offline bundle's lists follow it.
45 lines
1.9 KiB
TypeScript
45 lines
1.9 KiB
TypeScript
import type { AssistantErrorCode } from '@trek/shared';
|
|
|
|
/**
|
|
* A file the user attaches in the trip chat is read by the server itself,
|
|
* not by the model: a booking file into bookings, a route file into tracks
|
|
* (P7). Each kind of file has its reader; AssistantService.attach runs it the
|
|
* same way for every kind: the read step as a call of its own, then one held
|
|
* change per thing the file holds, decided like any other change.
|
|
*/
|
|
|
|
/** One change a file proposes: the server's write it is held as, and its arguments. */
|
|
export interface FileProposal {
|
|
toolName: string;
|
|
/** What the change runs with, kept on the held call only. */
|
|
args: Record<string, unknown>;
|
|
/**
|
|
* What the message shows of the call where that is less than it runs with
|
|
* (a GPX text stays on the held call, out of the thread and the history).
|
|
*/
|
|
shownArgs?: Record<string, unknown>;
|
|
}
|
|
|
|
/** What reading a file found: the read step's answer, and the changes it proposes. */
|
|
export interface FileRead {
|
|
found: Record<string, unknown>;
|
|
proposals: FileProposal[];
|
|
}
|
|
|
|
export interface AttachedFileReader {
|
|
/** The name the read step goes by in the thread. */
|
|
readonly readTool: string;
|
|
/** The error a file that holds nothing to propose ends the answer with, unless the reader `acknowledges` it. */
|
|
readonly emptyCode: AssistantErrorCode;
|
|
/**
|
|
* The answer names the file and what was found in it in a line of its own,
|
|
* a file without anything says why, and chips offer what to do with it
|
|
* (assistant-attach-answer.ts); no answer ends on the error then.
|
|
*/
|
|
readonly acknowledges: boolean;
|
|
/** Refuses a file nobody here can read for this trip, before a turn begins. */
|
|
ensureReadable(userId: number, tripId: number, file: Express.Multer.File): Promise<void>;
|
|
/** What the file holds, at most a step's worth. Persists nothing. */
|
|
propose(userId: number, tripId: number, file: Express.Multer.File): Promise<FileRead>;
|
|
}
|