mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 08:00:06 +00:00
feat(assistant): every MCP tool of TREK, the core first and the addons on request
The assistant offered 25 hand-picked tools. It now offers every tool the MCP registry holds, but a short denylist with a reason per tool (deleting the trip, share, invite and feed links, membership changes, fetching an address the model picks, documents to the provider, instance-wide categories and holidays). The scopes widen to every addon but trips:delete, the share scopes, file contents and plugins. - A tool annotated read-only runs at once, every other one waits as a change card; reads that fetch a planted address wait too. - A turn starts with the trip's core tools; use_addon_tools loads tours, road trip, journey, vacay, atlas, collections, trip chat, files, account or plugin tools for the rest of the turn. - A writing tool without a card of its own gets one from its arguments: add, change or remove, the part of TREK it works in, the trip's days, places and people named. - The boot check fails on a tool that shares, invites or publishes and is neither denied nor known to only take back.
This commit is contained in:
@@ -12,8 +12,10 @@ import {
|
||||
MapPinPlus,
|
||||
NotebookPen,
|
||||
PencilLine,
|
||||
Plus,
|
||||
StickyNote,
|
||||
Ticket,
|
||||
Trash2,
|
||||
TriangleAlert,
|
||||
Undo2,
|
||||
Wallet,
|
||||
@@ -83,6 +85,9 @@ const VERB_LOOK: Record<AssistantChangeVerbKey, { Icon: typeof Check; tone: Tone
|
||||
addReservation: { Icon: Ticket, tone: 'success' },
|
||||
importBooking: { Icon: Ticket, tone: 'success' },
|
||||
rememberNote: { Icon: NotebookPen, tone: 'info' },
|
||||
genericCreate: { Icon: Plus, tone: 'success' },
|
||||
genericUpdate: { Icon: PencilLine, tone: 'info' },
|
||||
genericRemove: { Icon: Trash2, tone: 'danger' },
|
||||
};
|
||||
|
||||
/** How a decided change reads: one quiet mark, its words in the tooltip. */
|
||||
@@ -125,7 +130,15 @@ function ChangeHead({ preview, struck = false }: { preview: AssistantChangePrevi
|
||||
if (!preview) return <span className="trek-skeleton inline-block h-4 w-40" aria-hidden="true" />;
|
||||
return (
|
||||
<span className="flex min-w-0 flex-col">
|
||||
<span className="text-caption text-content-muted">{t(`assistant.change.verb.${preview.verbKey}`)}</span>
|
||||
<span className="flex min-w-0 items-center gap-1.5 text-caption text-content-muted">
|
||||
<span className="truncate">{t(`assistant.change.verb.${preview.verbKey}`)}</span>
|
||||
{preview.domain && (
|
||||
// Where in TREK a change outside the trip plan lands: the vacation planner, the journal.
|
||||
<span className="flex-shrink-0 rounded-full bg-surface-secondary px-1.5 font-medium text-content-secondary">
|
||||
{t(`assistant.domain.${preview.domain}`)}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<bdi className={`truncate text-body font-semibold text-content ${struck ? 'line-through' : ''}`}>
|
||||
{preview.subject}
|
||||
</bdi>
|
||||
|
||||
@@ -41,6 +41,12 @@ const KEY_ORDER = Object.keys(KEY_FIELDS) as AssistantChangeLabelKey[];
|
||||
/** Fields that mean nothing written out. */
|
||||
const HIDDEN: ReadonlySet<AssistantChangeLabelKey> = new Set(['coordinates', 'position', 'icon', 'color', 'currency']);
|
||||
|
||||
/** What a row is called: its label, or for a tool's own argument the argument's name in words. */
|
||||
function labelOf(row: AssistantChangeRow, t: (key: string) => string): string {
|
||||
if (row.labelKey === 'field' && row.field) return row.field.replace(/_/g, ' ').replace(/([a-z])([A-Z])/g, '$1 $2');
|
||||
return t(CHANGE_LABELS[row.labelKey]?.labelKey ?? 'assistant.change.label.field');
|
||||
}
|
||||
|
||||
/** "#3" is how a day comes from the server; it reads as "Day 3". */
|
||||
function shown(row: AssistantChangeRow, value: string | null | undefined, dayWord: string): string {
|
||||
if (row.labelKey === 'day' && value && /^#\d+$/.test(value)) return `${dayWord} ${value.slice(1)}`;
|
||||
@@ -50,7 +56,7 @@ function shown(row: AssistantChangeRow, value: string | null | undefined, dayWor
|
||||
function Chip({ row }: { row: AssistantChangeRow }) {
|
||||
const { t } = useTranslation();
|
||||
const Icon = KEY_FIELDS[row.labelKey] ?? Tag;
|
||||
const label = t(CHANGE_LABELS[row.labelKey].labelKey);
|
||||
const label = labelOf(row, t);
|
||||
const dayWord = t('assistant.week.day');
|
||||
const changed = row.op !== 'add' && !!row.before;
|
||||
return (
|
||||
@@ -76,7 +82,7 @@ function DetailLine({ row }: { row: AssistantChangeRow }) {
|
||||
const changed = row.op !== 'add' && !!row.before;
|
||||
return (
|
||||
<div className="flex min-w-0 gap-2 text-caption">
|
||||
<span className="w-20 flex-shrink-0 truncate text-content-faint">{t(CHANGE_LABELS[row.labelKey].labelKey)}</span>
|
||||
<span className="w-24 flex-shrink-0 truncate text-content-faint">{labelOf(row, t)}</span>
|
||||
<span className="flex min-w-0 flex-1 items-center gap-1 text-content-secondary">
|
||||
{changed && (
|
||||
<>
|
||||
|
||||
@@ -249,6 +249,8 @@ export function undoLeftMs(applied: AssistantApplied | null, now: number): numbe
|
||||
|
||||
/** The label of each field a change row can show. A table, so every key is named where it is read. */
|
||||
export const CHANGE_LABELS: Record<AssistantChangeLabelKey, { labelKey: string }> = {
|
||||
// A tool's own argument: the row names it in `field`, this is only its fallback.
|
||||
field: { labelKey: 'assistant.change.label.field' },
|
||||
name: { labelKey: 'assistant.change.label.name' },
|
||||
description: { labelKey: 'assistant.change.label.description' },
|
||||
address: { labelKey: 'assistant.change.label.address' },
|
||||
|
||||
Reference in New Issue
Block a user