The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
feat(assistant): a card framework every addon package plugs into
Maurice3967ca279022
diff --git a/client/scripts/i18n-keys.mjs b/client/scripts/i18n-keys.mjsindex 57aab93fe..b991a9c00 100644--- a/client/scripts/i18n-keys.mjs+++ b/client/scripts/i18n-keys.mjs@@ -139,13 +139,6 @@ export const DYNAMIC_ALLOWED = ['memories.* key in en',}))),- {- file: 'components/Assistant/AssistantChangeCard.tsx',- template: 'assistant.tool.${tool}',- because:- 'tool is the MCP tool a change card is for; verbLabel shows assistant.tool.<tool> only where en names ' +- 'that tool, and the generic add, change or remove verb for every other tool',- },];const KEY_RE = /^[a-z][a-zA-Z0-9_]*(?:\.[a-zA-Z0-9_:-]+)+$/;diff --git a/client/src/api/assistant.ts b/client/src/api/assistant.tsindex e44534315..57ad95427 100644--- a/client/src/api/assistant.ts+++ b/client/src/api/assistant.ts@@ -19,6 +19,7 @@ import {type AssistantDecisionsRequest,type AssistantErrorCode,type AssistantShareRequest,+ type AssistantTakeProposalRequest,type AssistantThreadListResponse,type AssistantThreadResponse,type AssistantUndoResponse,@@ -122,6 +123,13 @@ export const assistantApi = {body: AssistantAddFoundPlaceRequest): Promise<AssistantAddFoundPlaceResponse> =>apiClient.post(`${tripBase(tripId)}/threads/${threadId}/found-places`, body).then((r) => r.data),+ // A proposal an answer showed as a card ("Plan this"): answers like a found place, with the message holding it.+ takeProposal: (+ tripId: number,+ threadId: number,+ body: AssistantTakeProposalRequest+ ): Promise<AssistantAddFoundPlaceResponse> =>+ apiClient.post(`${tripBase(tripId)}/threads/${threadId}/proposals`, body).then((r) => r.data),// An answer posted to the trip chat, marked as shared from the assistant; the client's socket id skips the echo.share: (tripId: number,diff --git a/client/src/components/Assistant/AssistantChangeCard.test.tsx b/client/src/components/Assistant/AssistantChangeCard.test.tsxindex 27db4bcd1..fb262ce4c 100644--- a/client/src/components/Assistant/AssistantChangeCard.test.tsx+++ b/client/src/components/Assistant/AssistantChangeCard.test.tsx@@ -65,6 +65,7 @@ const pending = (id: string, subject: string): ChangeItem => ({preview: preview(id, subject),applied: null,state: 'pending',+ card: null,});const onTheMap = (id: string, subject: string, effect = PANTHEON): ChangeItem => ({@@ -74,7 +75,7 @@ const onTheMap = (id: string, subject: string, effect = PANTHEON): ChangeItem =>function receipt(id: string, undoUntil: string | null): ChangeItem {const applied: AssistantApplied = { toolCallId: id, entity: 'place', ids: [9], dayId: 3, undoUntil };- return { toolCallId: id, preview: preview(id, 'Kinkaku-ji'), applied, state: 'applied' };+ return { toolCallId: id, preview: preview(id, 'Kinkaku-ji'), applied, state: 'applied', card: null };}function renderCard(items: ChangeItem[], view: Partial<AssistantView> = {}) {@@ -173,12 +174,12 @@ describe('AssistantChangeCard: the receipt', () => {it('FE-AI-CARD-005: an applied change shows on the map and can be undone until its window closes', () => {vi.useFakeTimers({ shouldAdvanceTime: true });vi.setSystemTime(new Date('2026-10-21T08:00:00.000Z'));- const onShowOnMap = vi.fn();- renderCard([receipt('c1', '2026-10-21T08:15:00.000Z')], { onShowOnMap });+ const onOpen = vi.fn();+ renderCard([receipt('c1', '2026-10-21T08:15:00.000Z')], { onOpen });expect(screen.getByRole('img', { name: 'Applied' })).toBeInTheDocument();fireEvent.click(screen.getByRole('button', { name: 'Show on map' }));- expect(onShowOnMap).toHaveBeenCalledWith(expect.objectContaining({ toolCallId: 'c1', dayId: 3 }));+ expect(onOpen).toHaveBeenCalledWith({ kind: 'map', placeId: 9, dayId: null });expect(screen.getByRole('button', { name: 'Undo' })).toBeInTheDocument();act(() => {@@ -259,12 +260,12 @@ describe('AssistantChangeCard: on the map', () => {it('FE-AI-CARD-011: on the phone the card hops to the map and frames what it would change', () => {plannerHere();- const onShowOnMap = vi.fn();- const first = renderCard([onTheMap('c1', 'Pantheon')], { onShowOnMap });+ const onOpen = vi.fn();+ const first = renderCard([onTheMap('c1', 'Pantheon')], { onOpen });expect(screen.queryByRole('button', { name: 'View on map' })).toBeNull();first.unmount();- renderCard([onTheMap('c1', 'Pantheon')], { variant: 'fullscreen', onShowOnMap });+ renderCard([onTheMap('c1', 'Pantheon')], { variant: 'fullscreen', onOpen });fireEvent.click(screen.getByRole('button', { name: 'View on map' }));expect(requestCamera).toHaveBeenCalledWith(TRIP,@@ -285,14 +286,14 @@ describe('AssistantChangeCard: the applied block', () => {it('FE-AI-CARD-012: before and after are there only for the block this session can compare, beside a map', () => {compare('c1');- const onShowOnMap = vi.fn();- const first = renderCard([receipt('c1', null), receipt('c2', null)], { onShowOnMap });+ const onOpen = vi.fn();+ const first = renderCard([receipt('c1', null), receipt('c2', null)], { onOpen });expect(screen.getByRole('button', { name: 'After' })).toHaveAttribute('aria-pressed', 'true');fireEvent.click(screen.getByRole('button', { name: 'Before' }));expect(setCompare).toHaveBeenCalledWith(TRIP, 'before');first.unmount();- const other = renderCard([receipt('c7', null), receipt('c8', null)], { onShowOnMap });+ const other = renderCard([receipt('c7', null), receipt('c8', null)], { onOpen });expect(screen.queryByRole('button', { name: 'Before' })).toBeNull();other.unmount();diff --git a/client/src/components/Assistant/AssistantChangeCard.tsx b/client/src/components/Assistant/AssistantChangeCard.tsxindex 5ed5e28ed..ddc631b81 100644--- a/client/src/components/Assistant/AssistantChangeCard.tsx+++ b/client/src/components/Assistant/AssistantChangeCard.tsx@@ -1,25 +1,4 @@-import type { AssistantApplied, AssistantChangePreview, AssistantChangeVerbKey } from '@trek/shared';-import {- CalendarArrowUp,- CalendarMinus,- CalendarPlus,- Check,- CircleSlash,- ListTodo,- LoaderCircle,- Luggage,- MapPin,- MapPinPlus,- NotebookPen,- PencilLine,- Plus,- StickyNote,- Ticket,- Trash2,- TriangleAlert,- Undo2,- Wallet,-} from 'lucide-react';+import { Check, LoaderCircle, MapPin, Undo2 } from 'lucide-react';import { type ReactNode, useEffect, useMemo, useState } from 'react';import { useTranslation } from '../../i18n';@@ -28,14 +7,15 @@ import { chatOf, useAssistantStore } from '../../store/assistantStore';import { useTripStore } from '../../store/tripStore';import { useToast } from '../shared/Toast';import { Tooltip } from '../shared/Tooltip';-import AssistantChangeFields from './AssistantChangeFields';import AssistantCompareSwitch from './AssistantCompareSwitch';import AssistantFitCheck from './AssistantFitCheck';import AssistantWeekOverview from './AssistantWeekOverview';-import { type ChangeItem, type ChangeState, undoLeftMs } from './assistantParts';+import { type ChangeItem, undoLeftMs } from './assistantParts';import { useAssistantView } from './assistantViewContext';+import { ChangeRows } from './cards/ChangeCardSlots';+import { ICON_BUTTON } from './cards/parts/assistantTones';+import { useChangeExclusions } from './cards/useChangeExclusions';import { changePoints, type DayChange } from './dayAfterModel';-import { useChangeHover } from './useChangeHover';import { useWeekDays } from './useWeekDays';/**@@ -49,7 +29,8 @@ import { useWeekDays } from './useWeekDays';* Every change wears its kind: a tinted tile with the icon of what it touches* and a badge naming the verb, in the tone of what happens (green adds, blue* changes, amber moves, red takes away). Its fields sit as badges holding a- * label badge, so a row of them reads at a glance.+ * label badge, so a row of them reads at a glance. The rows themselves, and a+ * change that carries a card of its own, are drawn in cards/ChangeCardSlots.** While it waits, the card shows the days it touches as they would read* afterwards, and each row lights its pin on the map (and the pin its row).@@ -57,106 +38,6 @@ import { useWeekDays } from './useWeekDays';* map, and taking the whole block back at once.*/-type Tone = 'success' | 'info' | 'warning' | 'danger';--const TILE: Record<Tone, string> = {- success: 'bg-success-soft text-success',- info: 'bg-info-soft text-info',- warning: 'bg-warning-soft text-warning',- danger: 'bg-danger-soft text-danger',-};--/** What each kind of change looks like. A table, so a new verb fails to compile until it has a look. */-const VERB_LOOK: Record<AssistantChangeVerbKey, { Icon: typeof Check; tone: Tone }> = {- addPlace: { Icon: MapPinPlus, tone: 'success' },- addPlaceToDay: { Icon: CalendarPlus, tone: 'success' },- updatePlace: { Icon: PencilLine, tone: 'info' },- assignPlace: { Icon: CalendarPlus, tone: 'success' },- moveAssignment: { Icon: CalendarArrowUp, tone: 'warning' },- removeFromDay: { Icon: CalendarMinus, tone: 'danger' },- addDayNote: { Icon: StickyNote, tone: 'success' },- updateDayNote: { Icon: StickyNote, tone: 'info' },- addPackingItem: { Icon: Luggage, tone: 'success' },- updatePackingItem: { Icon: Luggage, tone: 'info' },- addTodo: { Icon: ListTodo, tone: 'success' },- addBudgetItem: { Icon: Wallet, tone: 'success' },- updateBudgetItem: { Icon: Wallet, tone: 'info' },- addReservation: { Icon: Ticket, tone: 'success' },- importBooking: { Icon: Ticket, tone: 'success' },- rememberNote: { Icon: NotebookPen, tone: 'info' },- addTour: { Icon: MapPinPlus, tone: 'success' },- updateTour: { Icon: PencilLine, tone: 'info' },- importTour: { Icon: Plus, tone: 'success' },- 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. */-const RECEIPT: Record<Exclude<ChangeState, 'pending'>, { labelKey: string; Icon: typeof Check; tone: string }> = {- applying: { labelKey: 'assistant.change.applying', Icon: LoaderCircle, tone: 'text-content-muted' },- applied: { labelKey: 'assistant.change.applied', Icon: Check, tone: 'text-success' },- failed: { labelKey: 'assistant.change.failed', Icon: TriangleAlert, tone: 'text-danger' },- discarded: { labelKey: 'assistant.change.discarded', Icon: CircleSlash, tone: 'text-content-faint' },- expired: { labelKey: 'assistant.change.expired', Icon: CircleSlash, tone: 'text-content-faint' },-};--const ICON_BUTTON =- 'flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md text-content-muted transition-colors hover:bg-surface-hover hover:text-content disabled:opacity-50';--function KindTile({- verbKey,- size = 'md',- dimmed = false,-}: {- verbKey: AssistantChangeVerbKey | null;- size?: 'sm' | 'md';- dimmed?: boolean;-}) {- const box = size === 'sm' ? 'h-7 w-7 rounded-md' : 'h-8 w-8 rounded-lg';- if (!verbKey) return <span className={`trek-skeleton flex-shrink-0 ${box}`} aria-hidden="true" />;- const { Icon, tone } = VERB_LOOK[verbKey];- return (- <span- aria-hidden="true"- className={`flex flex-shrink-0 items-center justify-center ${box} ${dimmed ? 'bg-surface-secondary text-content-faint' : TILE[tone]}`}- >- <Icon size={size === 'sm' ? 14 : 16} strokeWidth={2.1} />- </span>- );-}--/** The key of a tool's own action name, for the tools TREK names one for. */-const toolKey = (tool: string) => `assistant.tool.${tool}`;--/** What the change does: the tool's own action where TREK names it, else add, change or remove. */-function verbLabel(preview: AssistantChangePreview, t: (key: string) => string): string {- const own = preview.tool ? toolKey(preview.tool) : null;- const named = own ? t(own) : null;- return named && named !== own ? named : t(`assistant.change.verb.${preview.verbKey}`);-}--function ChangeHead({ preview, struck = false }: { preview: AssistantChangePreview | null; struck?: boolean }) {- const { t } = useTranslation();- 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">- <bdi className={`truncate text-body font-semibold leading-tight text-content ${struck ? 'line-through' : ''}`}>- {preview.subject}- </bdi>- <span className="mt-0.5 flex min-w-0 items-center gap-2.5 text-caption text-content-faint">- <span className="truncate">{verbLabel(preview, t)}</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 text-content-secondary">- {t(`assistant.domain.${preview.domain}`)}- </span>- )}- </span>- </span>- );-}-/** The time now, ticking once more when the next undo window closes. */function useUndoClock(items: ChangeItem[]): number {const [now, setNow] = useState(() => Date.now());@@ -188,134 +69,6 @@ function dayChangesOf(items: readonly ChangeItem[], excluded: ReadonlySet<string);}-/** What an applied change can be shown as on the map; a kept note, a todo or an expense has no place there. */-const ON_MAP: ReadonlySet<AssistantApplied['entity']> = new Set(['place', 'assignment', 'day_note', 'reservation']);--function Receipt({- item,- undone,- canUndo,- onUndo,-}: {- item: ChangeItem;- undone: boolean;- canUndo: boolean;- onUndo: () => void;-}) {- const { t } = useTranslation();- const { onShowOnMap } = useAssistantView();- if (item.state === 'pending') return null;- const receipt = undone ? RECEIPT.discarded : RECEIPT[item.state];- const { Icon } = receipt;- const applied = item.state === 'applied' && !undone ? item.applied : null;- const mappable = applied !== null && ON_MAP.has(applied.entity);- const settled = item.state === 'discarded' || item.state === 'expired' || undone;- const statusLabel = t(undone ? 'assistant.change.undone' : receipt.labelKey);- return (- <div className="trek-assistant-enter flex items-center gap-2.5 py-1.5">- <KindTile verbKey={item.preview?.verbKey ?? null} size="sm" dimmed={settled} />- <div className={`min-w-0 flex-1 ${settled ? 'opacity-60' : ''}`}>- <ChangeHead preview={item.preview} struck={settled} />- </div>- {applied && mappable && onShowOnMap && (- <Tooltip label={t('assistant.change.showOnMap')} placement="top">- <button- type="button"- onClick={() => onShowOnMap(applied)}- aria-label={t('assistant.change.showOnMap')}- className={ICON_BUTTON}- >- <MapPin size={14} aria-hidden="true" />- </button>- </Tooltip>- )}- {canUndo && (- <Tooltip label={t('assistant.change.undo')} placement="top">- <button type="button" onClick={onUndo} aria-label={t('assistant.change.undo')} className={ICON_BUTTON}>- <Undo2 size={14} aria-hidden="true" />- </button>- </Tooltip>- )}- <Tooltip label={statusLabel} placement="top">- <span- role="img"- aria-label={statusLabel}- className={`flex h-7 w-5 items-center justify-center ${receipt.tone}`}- >- <Icon size={15} strokeWidth={2.4} className={item.state === 'applying' ? 'animate-spin' : ''} />- </span>- </Tooltip>- </div>- );-}--/**- * A change waiting for its decision, as a row of the planner's day list: the- * round choice in front (only when there is more than one to choose from),- * what it touches in bold, and a faint line saying what happens and when.- * Resting on it lights its pin on the map.- */-function PendingRow({- item,- excluded,- withChoice,- disabled,- onToggle,-}: {- item: ChangeItem;- excluded: boolean;- withChoice: boolean;- disabled: boolean;- onToggle: () => void;-}) {- const { t } = useTranslation();- const { tripId } = useAssistantView();- const { litFromMap, handlers } = useChangeHover(tripId, item.preview?.effect ? item.toolCallId : null);- const preview = item.preview;- return (- <div- {...handlers}- className={`-mx-1.5 flex items-center gap-2.5 rounded-[12px] px-1.5 py-2 transition-[opacity,background-color] ${- excluded ? 'opacity-50' : ''- } ${litFromMap ? 'bg-surface-hover' : 'hover:bg-surface-hover'}`}- >- {withChoice && (- <button- type="button"- onClick={onToggle}- disabled={disabled}- aria-pressed={!excluded}- aria-label={t('assistant.change.include')}- className={`grid h-[18px] w-[18px] flex-none place-items-center rounded-full outline-none transition-colors focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${- excluded ? 'border-[1.5px] border-edge bg-surface-card' : 'bg-accent'- }`}- >- {!excluded && <Check size={11} strokeWidth={3} aria-hidden="true" className="text-accent-text" />}- </button>- )}- <KindTile verbKey={preview?.verbKey ?? null} size="sm" dimmed={excluded} />- <div className="min-w-0 flex-1">- {preview ? (- <>- <bdi className="block truncate text-body font-semibold leading-tight text-content">{preview.subject}</bdi>- <span className="mt-1 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-caption text-content-faint">- <span className="me-0.5 min-w-0 truncate">{verbLabel(preview, t)}</span>- {preview.domain && (- <span className="flex-shrink-0 rounded-full bg-surface-secondary px-1.5 text-content-secondary">- {t(`assistant.domain.${preview.domain}`)}- </span>- )}- <AssistantChangeFields rows={preview.rows} />- </span>- </>- ) : (- <span className="trek-skeleton inline-block h-4 w-40" aria-hidden="true" />- )}- </div>- </div>- );-}-/** The card's head: what the card is, what can be done with it as a whole, and how many changes it holds. */function CardHead({ open, count, actions }: { open: boolean; count: number; actions?: ReactNode }) {const { t } = useTranslation();@@ -399,10 +152,10 @@ function HeadActions({changes: readonly DayChange[];undoable: readonly string[];}) {- const { tripId, variant, onShowOnMap } = useAssistantView();+ const { tripId, variant, onOpen } = useAssistantView();const here = useTripStore((s) => s.trip?.id === tripId);if (open) {- const toMap = variant === 'fullscreen' && !!onShowOnMap && here && changes.length > 0;+ const toMap = variant === 'fullscreen' && !!onOpen && here && changes.length > 0;return (<><AssistantFitCheck changes={changes} />@@ -412,7 +165,7 @@ function HeadActions({}return (<>- {onShowOnMap && <AssistantCompareSwitch tripId={tripId} blockKey={blockKeyOf(items.map((i) => i.toolCallId))} />}+ {onOpen && <AssistantCompareSwitch tripId={tripId} blockKey={blockKeyOf(items.map((i) => i.toolCallId))} />}{undoable.length >= 2 && <UndoAllButton toolCallIds={undoable} />}</>);@@ -426,7 +179,7 @@ export default function AssistantChangeCard({ items }: { items: ChangeItem[] })const undone = useAssistantStore((s) => chatOf(s, tripId).undone);const decide = useAssistantStore((s) => s.decide);const undo = useAssistantStore((s) => s.undo);- const [excluded, setExcluded] = useState<ReadonlySet<string>>(() => new Set());+ const [excluded, setExcluded] = useChangeExclusions(items);const now = useUndoClock(items);const pending = items.filter((i) => i.state === 'pending');@@ -489,30 +242,16 @@ export default function AssistantChangeCard({ items }: { items: ChangeItem[] }){t('assistant.week.showAll', { count: pending.length })}</button>)}- <div>- {items.map((item) =>- item.state === 'pending' ? (- folded ? null : (- <PendingRow- key={item.toolCallId}- item={item}- excluded={excluded.has(item.toolCallId)}- withChoice={pending.length > 1}- disabled={isRunning}- onToggle={() => toggle(item.toolCallId)}- />- )- ) : (- <Receipt- key={item.toolCallId}- item={item}- undone={!!undone[item.toolCallId]}- canUndo={undoable.includes(item.toolCallId)}- onUndo={() => void runUndo(item.toolCallId)}- />- )- )}- </div>+ <ChangeRows+ items={items}+ folded={folded}+ excluded={excluded}+ disabled={isRunning}+ undone={undone}+ undoable={undoable}+ onToggle={toggle}+ onUndo={(toolCallId) => void runUndo(toolCallId)}+ />{open && (<><p className="sr-only" role="status">diff --git a/client/src/components/Assistant/AssistantChangeFields.tsx b/client/src/components/Assistant/AssistantChangeFields.tsxindex 1dd8da2f6..0c8242b72 100644--- a/client/src/components/Assistant/AssistantChangeFields.tsx+++ b/client/src/components/Assistant/AssistantChangeFields.tsx@@ -1,6 +1,5 @@import type { AssistantChangeLabelKey, AssistantChangeRow } from '@trek/shared';import {- ArrowRight,CalendarClock,CalendarDays,Clock,@@ -14,7 +13,7 @@ import {} from 'lucide-react';import { useTranslation } from '../../i18n';-import { SoftPill } from '../Planner/planParts';+import { FactChange } from './cards/parts/CardFacts';/*** The few facts that tell a change apart at a glance, as badges on the line@@ -57,22 +56,14 @@ export default function AssistantChangeFields({ rows }: { rows: AssistantChangeRreturn (<>{facts.map((row, i) => {- const Icon = KEY_FIELDS[row.labelKey] ?? Tag;const changed = row.op !== 'add' && !!row.before;return (- <SoftPill+ <FactChangekey={`${row.labelKey}-${i}`}- className="max-w-full tabular-nums"- icon={<Icon size={10} strokeWidth={2.2} aria-hidden="true" className="flex-none text-content-faint" />}- >- {changed && (- <>- <bdi className="truncate text-content-faint line-through">{shown(row, row.before, dayWord)}</bdi>- <ArrowRight size={9} aria-hidden="true" className="flex-none text-content-faint rtl:-scale-x-100" />- </>- )}- <bdi className="truncate">{shown(row, row.after, dayWord)}</bdi>- </SoftPill>+ icon={KEY_FIELDS[row.labelKey] ?? Tag}+ before={changed ? shown(row, row.before, dayWord) : null}+ after={shown(row, row.after, dayWord)}+ />);})}</>diff --git a/client/src/components/Assistant/AssistantHost.test.tsx b/client/src/components/Assistant/AssistantHost.test.tsxindex 567cdd034..d74ac96f1 100644--- a/client/src/components/Assistant/AssistantHost.test.tsx+++ b/client/src/components/Assistant/AssistantHost.test.tsx@@ -1,10 +1,10 @@/**- * FE-AI-HOST-001 to FE-AI-HOST-005+ * FE-AI-HOST-001 to FE-AI-HOST-007*- * The desktop host follows the trip on screen and sends "Show on map" and a- * picked day to the planner through its links.+ * The desktop host follows the trip on screen and sends what the chat opens+ * (a spot on the map, a tab of the trip, another page) and a picked day to+ * the planner through its links.*/-import type { AssistantApplied } from '@trek/shared';import { useLocation } from 'react-router';import { afterEach, describe, expect, it, vi } from 'vitest';@@ -12,10 +12,11 @@ import { act, render, screen } from '../../../tests/helpers/render';import { useTripStore } from '../../store/tripStore';import type { Trip } from '../../types';import AssistantHost from './AssistantHost';+import type { EntityTarget } from './cards/cardTypes';interface WindowProps {trip: { id: number; title: string } | null;- onShowOnMap?: (applied: AssistantApplied) => void;+ onOpen?: (target: EntityTarget) => void;onFocusDay?: (dayId: number) => void;}const seen: { props: WindowProps | null } = { props: null };@@ -42,19 +43,12 @@ function renderAt(path: string) {);}-const applied = (entity: AssistantApplied['entity'], ids: number[], dayId: number | null): AssistantApplied => ({- toolCallId: 'c1',- entity,- ids,- dayId,- undoUntil: null,-});-const INITIAL = useTripStore.getState();afterEach(() => {useTripStore.setState(INITIAL, true);seen.props = null;+ sessionStorage.clear();});describe('AssistantHost', () => {@@ -73,13 +67,29 @@ describe('AssistantHost', () => {it('FE-AI-HOST-003: "Show on map" opens the planner on the place, or on the day', () => {renderAt('/trips/5/files');- act(() => seen.props?.onShowOnMap?.(applied('place', [7], 2)));+ act(() => seen.props?.onOpen?.({ kind: 'map', placeId: 7, dayId: null }));expect(screen.getByTestId('location')).toHaveTextContent('/trips/5?place=7');- act(() => seen.props?.onShowOnMap?.(applied('day_note', [9], 3)));+ act(() => seen.props?.onOpen?.({ kind: 'map', placeId: null, dayId: 3 }));expect(screen.getByTestId('location')).toHaveTextContent('/trips/5?day=3');});+ it('FE-AI-HOST-006: a tab of the trip opens as ?tab= with its params, a list tab remembers its own list first', () => {+ renderAt('/trips/5');+ act(() => seen.props?.onOpen?.({ kind: 'tab', tab: 'finanzplan', params: { expense: '7' } }));+ expect(screen.getByTestId('location')).toHaveTextContent('/trips/5?tab=finanzplan&expense=7');++ act(() => seen.props?.onOpen?.({ kind: 'tab', tab: 'listen', sub: 'todo' }));+ expect(screen.getByTestId('location')).toHaveTextContent('/trips/5?tab=listen');+ expect(sessionStorage.getItem('trip-lists-subtab-5')).toBe('todo');+ });++ it('FE-AI-HOST-007: another page is navigated to as it is', () => {+ renderAt('/trips/5');+ act(() => seen.props?.onOpen?.({ kind: 'page', path: '/atlas' }));+ expect(screen.getByTestId('location')).toHaveTextContent('/atlas');+ });+it('FE-AI-HOST-005: a day picked in the chat selects it in the planner', () => {renderAt('/trips/5');act(() => seen.props?.onFocusDay?.(12));diff --git a/client/src/components/Assistant/AssistantHost.tsx b/client/src/components/Assistant/AssistantHost.tsxindex 94f82efd9..b263f3f4e 100644--- a/client/src/components/Assistant/AssistantHost.tsx+++ b/client/src/components/Assistant/AssistantHost.tsx@@ -1,10 +1,11 @@-import type { AssistantApplied } from '@trek/shared';import { useCallback, useMemo } from 'react';import { useLocation, useMatch, useNavigate } from 'react-router';+import { rememberListsSubTab } from '../../hooks/useListsSubTab';import { useTripStore } from '../../store/tripStore';import AssistantWindow from './AssistantWindow';-import { showOnMapSearch } from './assistantShowOnMap';+import { plannerSearchOf } from './assistantShowOnMap';+import type { EntityTarget } from './cards/cardTypes';/** The trip a route under /trips/:id shows, or null anywhere else. */function useRouteTripId(): number | null {@@ -15,10 +16,12 @@ function useRouteTripId(): number | null {/*** The desktop assistant, mounted once above the routes so a conversation- * keeps going from page to page. Inside a trip it is about that trip; "Show- * on map" opens the planner on the change through its links (`?place=`,- * `?day=`), the same way a notification opens a place, and a day picked in- * the chat (its weather) selects that day the same way.+ * keeps going from page to page. Inside a trip it is about that trip; what a+ * card or an applied change opens goes through the planner's links: "Show on+ * map" opens the planner on the change (`?place=`, `?day=`), the same way a+ * notification opens a place, a tab of the trip opens as `?tab=` (a list's+ * own tab remembered first), and another page is simply navigated to. A day+ * picked in the chat (its weather) selects that day the same way.*/export default function AssistantHost() {const navigate = useNavigate();@@ -36,8 +39,20 @@ export default function AssistantHost() {},[navigate, pathname, tripId]);- const showOnMap = useCallback((applied: AssistantApplied) => openPlanner(showOnMapSearch(applied)), [openPlanner]);+ const open = useCallback(+ (target: EntityTarget) => {+ if (target.kind === 'page') {+ void navigate(target.path);+ return;+ }+ if (target.kind === 'tab' && target.tab === 'listen' && tripId !== null) {+ if (target.sub === 'packing' || target.sub === 'todo') rememberListsSubTab(tripId, target.sub);+ }+ openPlanner(plannerSearchOf(target));+ },+ [navigate, openPlanner, tripId]+ );const focusDay = useCallback((dayId: number) => openPlanner(`?day=${dayId}`), [openPlanner]);- return <AssistantWindow trip={trip} onShowOnMap={showOnMap} onFocusDay={focusDay} />;+ return <AssistantWindow trip={trip} onOpen={open} onFocusDay={focusDay} />;}diff --git a/client/src/components/Assistant/AssistantMessage.tsx b/client/src/components/Assistant/AssistantMessage.tsxindex a16a67283..d300f2efa 100644--- a/client/src/components/Assistant/AssistantMessage.tsx+++ b/client/src/components/Assistant/AssistantMessage.tsx@@ -16,14 +16,16 @@ import AssistantToolSteps from './AssistantToolSteps';import AssistantWeatherStrip from './AssistantWeatherStrip';import { messageBlocks } from './assistantParts';import { useAssistantView } from './assistantViewContext';+import AssistantCardBlock from './cards/AssistantCardBlock';import { useAssistantShare } from './useAssistantShare';/*** One message of the chat. The user's question sits on the end side in a* quiet accent bubble; the answer runs as plain text across the column, with- * its looked-up steps, the places and weather they found, and the proposed- * changes in between, and a copy and a share button that show on hover- * (always on the latest answer, and always on the phone, which has no hover).+ * its looked-up steps, the places and weather they found, the cards its+ * tools brought and the proposed changes in between, and a copy and a share+ * button that show on hover (always on the latest answer, and always on the+ * phone, which has no hover).*/const BAR_BUTTON =@@ -127,6 +129,7 @@ function Answer({ message }: { message: StoredMessage }) {return <AssistantPlaceStrip key={block.key} found={block.found} message={message} />;}if (block.kind === 'weather') return <AssistantWeatherStrip key={block.key} days={block.days} />;+ if (block.kind === 'cards') return <AssistantCardBlock key={block.key} block={block} message={message} />;return <AssistantChangeCard key={block.key} items={block.items} />;})}{/* Nothing below says the answer goes on: no words being written, no step running. */}diff --git a/client/src/components/Assistant/AssistantPlaceStrip.tsx b/client/src/components/Assistant/AssistantPlaceStrip.tsxindex da0acd3ae..50c02ae67 100644--- a/client/src/components/Assistant/AssistantPlaceStrip.tsx+++ b/client/src/components/Assistant/AssistantPlaceStrip.tsx@@ -1,132 +1,40 @@import type { AssistantMessage, AssistantPlaces } from '@trek/shared';-import { ChevronLeft, ChevronRight } from 'lucide-react';-import { useCallback, useEffect, useRef, useState } from 'react';import { useTranslation } from '../../i18n';import AssistantPlaceCard from './AssistantPlaceCard';import { suggestedFromStrip } from './assistantParts';-import { useAssistantView } from './assistantViewContext';+import CardStrip from './cards/parts/CardStrip';import { useAssistantPlaceStrip } from './useAssistantPlaceStrip';/** Cards the strip shows, every one the server sends; what it left out is counted on the tile at its end. */const SHOWN = 60;-// In the strip's head, never over a card: a press that ends a pixel off still lands on the arrow.-const ARROW =- 'grid h-7 w-7 place-items-center rounded-full bg-surface-card text-content-secondary shadow-sm ring-1 ring-edge-faint transition-colors hover:text-content disabled:cursor-default disabled:opacity-40 disabled:hover:text-content-secondary';--/** How far the strip has scrolled from either end, with the reading direction in mind. */-function edgesOf(el: HTMLElement): { start: boolean; end: boolean } {- // A right-to-left strip scrolls into negative numbers; the distance from the start is the same either way.- const from = Math.abs(el.scrollLeft);- return { start: from > 4, end: from + el.clientWidth < el.scrollWidth - 4 };-}-/**- * The places a search found, as one row of cards to swipe or scroll through:- * the next card peeks in, so the row says it goes on, and the edges fade- * where there is more. On the desktop a head over the row names it and holds- * two arrows that move it by whole cards, off while that way is the end. Every card the step found, then a- * tile counting what the server left out.+ * The places a search found, as one row of cards to swipe or scroll through+ * (the cards' strip: the next card peeks in, the edges fade where there is+ * more, and the desktop head names the row and pages it by whole cards).+ * Every card the step found, then a tile counting what the server left out.*/export default function AssistantPlaceStrip({ found, message }: { found: AssistantPlaces; message: AssistantMessage }) {const { t } = useTranslation();- const { variant } = useAssistantView();const strip = useAssistantPlaceStrip();- const listRef = useRef<HTMLUListElement>(null);- const [fade, setFade] = useState({ start: false, end: false });const rest = Math.max(0, found.places.length - SHOWN) + found.more;-- const measure = useCallback(() => {- const el = listRef.current;- if (!el) return;- const next = edgesOf(el);- setFade((prev) => (prev.start === next.start && prev.end === next.end ? prev : next));- }, []);-- useEffect(() => {- measure();- const el = listRef.current;- if (!el || typeof ResizeObserver === 'undefined') return;- const observer = new ResizeObserver(measure);- observer.observe(el);- return () => observer.disconnect();- }, [measure, found]);-- // The pin a card left on the map goes with the strip.- const { hover } = strip;- useEffect(() => () => hover(null), [hover]);-- /**- * Scrolls by as many whole cards as the view holds, towards the start (-1)- * or the end (1), so the row lands on a card edge instead of fighting its- * snap points half way; smoothly, unless motion is turned down.- */- const page = (towards: -1 | 1) => {- const el = listRef.current;- const card = el?.firstElementChild as HTMLElement | null;- if (!el || !card) return;- const gap = Number.parseFloat(getComputedStyle(el).columnGap) || 0;- const step = card.offsetWidth + gap;- const cards = Math.max(1, Math.floor((el.clientWidth - 32) / step));- const rtl = getComputedStyle(el).direction === 'rtl';- // Smooth through the strip's own scroll-behavior, which reduced motion turns off.- el.scrollBy((rtl ? -towards : towards) * cards * step, 0);- };-const total = found.places.length + found.more;return (- <section aria-label={t('assistant.place.strip')} className="-mx-4">- {variant === 'window' && (fade.start || fade.end) && (- // The cards are reachable by Tab; the arrows are for the pointer only.- <div className="mb-1.5 flex items-center gap-2 px-4">- <span className="min-w-0 flex-1 truncate text-caption font-medium text-content-muted">- {t('assistant.place.strip')}- <span className="ms-1.5 tabular-nums text-content-faint">{total}</span>- </span>- <button- type="button"- tabIndex={-1}- aria-hidden="true"- disabled={!fade.start}- onClick={() => page(-1)}- className={ARROW}- >- <ChevronLeft size={15} className="rtl:-scale-x-100" />- </button>- <button- type="button"- tabIndex={-1}- aria-hidden="true"- disabled={!fade.end}- onClick={() => page(1)}- className={ARROW}- >- <ChevronRight size={15} className="rtl:-scale-x-100" />- </button>- </div>+ <CardStrip label={t('assistant.place.strip')} count={total} watch={found}>+ {found.places.slice(0, SHOWN).map((place) => (+ <AssistantPlaceCard+ key={place.ref}+ place={place}+ strip={strip}+ suggested={suggestedFromStrip(message, place)}+ />+ ))}+ {rest > 0 && (+ <li className="flex w-24 flex-shrink-0 snap-start items-center justify-center rounded-2xl border border-dashed border-edge-faint px-2 text-center text-caption text-content-muted">+ {t('assistant.place.more', { count: rest })}+ </li>)}- <ul- ref={listRef}- onScroll={measure}- data-fade-start={fade.start || undefined}- data-fade-end={fade.end || undefined}- className="trek-assistant-strip flex snap-x snap-mandatory scroll-px-4 gap-2.5 overflow-x-auto overscroll-x-contain px-4 pb-2 pt-0.5 motion-safe:scroll-smooth"- >- {found.places.slice(0, SHOWN).map((place) => (- <AssistantPlaceCard- key={place.ref}- place={place}- strip={strip}- suggested={suggestedFromStrip(message, place)}- />- ))}- {rest > 0 && (- <li className="flex w-24 flex-shrink-0 snap-start items-center justify-center rounded-2xl border border-dashed border-edge-faint px-2 text-center text-caption text-content-muted">- {t('assistant.place.more', { count: rest })}- </li>- )}- </ul>- </section>+ </CardStrip>);}diff --git a/client/src/components/Assistant/AssistantPowerParts.test.tsx b/client/src/components/Assistant/AssistantPowerParts.test.tsxindex 16eb8b031..781313450 100644--- a/client/src/components/Assistant/AssistantPowerParts.test.tsx+++ b/client/src/components/Assistant/AssistantPowerParts.test.tsx@@ -153,6 +153,7 @@ describe('the week grid', () => {preview: preview(id, dayId),applied: null,state: 'pending',+ card: null,});it('FE-AI-POWER-005: from three days on the changes group by day, in trip order', () => {diff --git a/client/src/components/Assistant/AssistantSurface.tsx b/client/src/components/Assistant/AssistantSurface.tsxindex d08875041..8cb4cdecb 100644--- a/client/src/components/Assistant/AssistantSurface.tsx+++ b/client/src/components/Assistant/AssistantSurface.tsx@@ -22,7 +22,7 @@ export default function AssistantSurface({tripTitle,variant,density,- onShowOnMap,+ onOpen,onFocusDay,onRevealMap,}: AssistantSurfaceProps) {@@ -33,11 +33,11 @@ export default function AssistantSurface({tripId,variant,density: variant === 'fullscreen' ? ('compact' as const) : (density ?? 'roomy'),- onShowOnMap,+ onOpen,onFocusDay,onRevealMap,}),- [tripId, variant, density, onShowOnMap, onFocusDay, onRevealMap]+ [tripId, variant, density, onOpen, onFocusDay, onRevealMap]);return (<AssistantRuntimeProvider runtime={runtime}>diff --git a/client/src/components/Assistant/AssistantWindow.test.tsx b/client/src/components/Assistant/AssistantWindow.test.tsxindex 292512457..7db215fb7 100644--- a/client/src/components/Assistant/AssistantWindow.test.tsx+++ b/client/src/components/Assistant/AssistantWindow.test.tsx@@ -1,5 +1,5 @@/**- * FE-AI-WIN-001 to FE-AI-WIN-010+ * FE-AI-WIN-001 to FE-AI-WIN-011** The desktop window around the chat: when it shows at all, the button it* opens from, the trip picker outside a trip, closing that keeps the chat, and@@ -8,6 +8,7 @@* useDragResize's and has its own tests; here it is a fixed rect.*/import type { AiStatusResponse } from '@trek/shared';+import { useLocation } from 'react-router';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { act, fireEvent, render, screen, waitFor } from '../../../tests/helpers/render';@@ -15,6 +16,7 @@ import { tripRepo } from '../../repo/tripRepo';import { chatOf, useAssistantStore } from '../../store/assistantStore';import type { Trip } from '../../types';import AssistantWindow from './AssistantWindow';+import type { EntityTarget } from './cards/cardTypes';vi.mock('../../hooks/useDragResize', () => ({useDragResize: () => ({@@ -32,11 +34,13 @@ vi.mock('./AssistantSurfaceLazy', () => ({tripTitle,density,onFocusDay,+ onOpen,}: {tripId: number;tripTitle: string;density?: string;onFocusDay?: (dayId: number) => void;+ onOpen?: (target: EntityTarget) => void;}) => (<div><p>@@ -48,12 +52,30 @@ vi.mock('./AssistantSurfaceLazy', () => ({pick day</button>)}+ {onOpen && (+ <>+ <button type="button" onClick={() => onOpen({ kind: 'map', placeId: 7, dayId: null })}>+ open place+ </button>+ <button type="button" onClick={() => onOpen({ kind: 'tab', tab: 'finanzplan', params: { expense: '3' } })}>+ open tab+ </button>+ <button type="button" onClick={() => onOpen({ kind: 'page', path: '/atlas' })}>+ open page+ </button>+ </>+ )}<textarea aria-label="composer" /></div>),}));const TRIP = { id: 4, title: 'Kyoto' };++function Location() {+ const { pathname, search } = useLocation();+ return <output data-testid="location">{`${pathname}${search}`}</output>;+}const INITIAL = useAssistantStore.getState();const STATUS = { available: true, retention: { mode: 'days', days: 90 } } as AiStatusResponse;@@ -185,4 +207,34 @@ describe('AssistantWindow', () => {unmount();expect(useAssistantStore.getState().windowRect).toBeNull();});++ it('FE-AI-WIN-011: opens through the planner on screen, keeps a trip it leaves, and opens a picked trip itself', async () => {+ seed({ open: true, minimized: false });+ const onOpen = vi.fn();+ const onScreen = render(<AssistantWindow trip={TRIP} onOpen={onOpen} />);+ fireEvent.click(screen.getByRole('button', { name: 'open place' }));+ expect(onOpen).toHaveBeenCalledWith({ kind: 'map', placeId: 7, dayId: null });+ // Another page leaves the trip; the chat stays on it as if it had been picked.+ fireEvent.click(screen.getByRole('button', { name: 'open page' }));+ expect(onOpen).toHaveBeenLastCalledWith({ kind: 'page', path: '/atlas' });+ onScreen.rerender(<AssistantWindow trip={null} onOpen={onOpen} />);+ expect(screen.getByText('chat 4 Kyoto')).toBeInTheDocument();+ onScreen.unmount();++ seed({ open: true, minimized: false });+ render(+ <>+ <AssistantWindow trip={null} onOpen={onOpen} />+ <Location />+ </>+ );+ fireEvent.click(await screen.findByRole('button', { name: /Lisbon/ }));+ fireEvent.click(screen.getByRole('button', { name: 'open tab' }));+ expect(screen.getByTestId('location')).toHaveTextContent('/trips/9?tab=finanzplan&expense=3');+ fireEvent.click(screen.getByRole('button', { name: 'open place' }));+ expect(screen.getByTestId('location')).toHaveTextContent(/^\/trips\/9$/);+ fireEvent.click(screen.getByRole('button', { name: 'open page' }));+ expect(screen.getByTestId('location')).toHaveTextContent('/atlas');+ expect(onOpen).toHaveBeenCalledTimes(2);+ });});diff --git a/client/src/components/Assistant/AssistantWindow.tsx b/client/src/components/Assistant/AssistantWindow.tsxindex 6f1c6a39c..48b986ba9 100644--- a/client/src/components/Assistant/AssistantWindow.tsx+++ b/client/src/components/Assistant/AssistantWindow.tsx@@ -1,6 +1,5 @@import './assistant.css';-import type { AssistantApplied } from '@trek/shared';import { Sparkles, X } from 'lucide-react';import { type CSSProperties, type KeyboardEvent, useCallback, useEffect, useRef, useState } from 'react';import { useNavigate } from 'react-router';@@ -12,6 +11,8 @@ import AssistantHeader from './AssistantHeader';import AssistantLauncher, { LAUNCHER_INSET, LAUNCHER_SIZE } from './AssistantLauncher';import AssistantSurfaceLazy from './AssistantSurfaceLazy';import AssistantTripPicker from './AssistantTripPicker';+import { plannerSearchOf } from './assistantShowOnMap';+import type { EntityTarget } from './cards/cardTypes';import { useAssistantHotkey } from './useAssistantHotkey';import { useAssistantThread } from './useAssistantThread';@@ -39,8 +40,8 @@ interface WindowTrip {interface AssistantWindowProps {/** The trip on screen; null outside a trip, where the window asks which one first. */trip: WindowTrip | null;- /** Shows an applied change in the planner on screen. */- onShowOnMap?: (applied: AssistantApplied) => void;+ /** Opens what a card or an applied change points at, from the trip on screen. */+ onOpen?: (target: EntityTarget) => void;/** Selects a day in the planner on screen. */onFocusDay?: (dayId: number) => void;}@@ -101,12 +102,12 @@ function originFrom(rect: WindowRect, rtl: boolean): string {function ChatWindow({trip,hidden,- onShowOnMap,+ onOpen,onFocusDay,}: {trip: WindowTrip;hidden: boolean;- onShowOnMap?: (applied: AssistantApplied) => void;+ onOpen?: (target: EntityTarget) => void;onFocusDay?: (dayId: number) => void;}) {const { t } = useTranslation();@@ -209,7 +210,7 @@ function ChatWindow({tripTitle={trip.title}variant="window"density={width < ROOMY_WIDTH ? 'compact' : 'roomy'}- onShowOnMap={onShowOnMap}+ onOpen={onOpen}onFocusDay={onFocusDay}/></div>@@ -217,7 +218,7 @@ function ChatWindow({);}-export default function AssistantWindow({ trip, onShowOnMap, onFocusDay }: AssistantWindowProps) {+export default function AssistantWindow({ trip, onOpen, onFocusDay }: AssistantWindowProps) {const navigate = useNavigate();const available = useAssistantStore((s) => s.status?.available === true);const open = useAssistantStore((s) => s.window.open);@@ -239,23 +240,34 @@ export default function AssistantWindow({ trip, onShowOnMap, onFocusDay }: Assis}const current = trip ?? picked;- const showPicked = useCallback(() => {- if (picked) void navigate(`/trips/${picked.id}`);- }, [navigate, picked]);+ // A change in a trip the planner does not show is shown by opening that trip; a tab opens on it.+ const openPicked = useCallback(+ (target: EntityTarget) => {+ if (target.kind === 'page') void navigate(target.path);+ else if (picked) void navigate(`/trips/${picked.id}${target.kind === 'tab' ? plannerSearchOf(target) : ''}`);+ },+ [navigate, picked]+ );+ // Another page leaves the trip: the chat stays on it, as if it had been picked.+ const openOnScreen = useCallback(+ (target: EntityTarget) => {+ if (target.kind === 'page' && trip) setPicked(trip);+ onOpen?.(target);+ },+ [onOpen, trip]+ );if (!available) return null;if (!open) return trip ? <AssistantLauncher variant="floating" tripId={trip.id} /> : null;if (!current) return <PickerWindow onPick={setPicked} />;- // A change in a trip the planner does not show is shown by opening that trip.const onScreen = !!trip && current.id === trip.id;- const showOnMap = onScreen ? onShowOnMap : showPicked;return (<><ChatWindowtrip={current}hidden={minimized}- onShowOnMap={showOnMap}+ onOpen={onScreen ? onOpen && openOnScreen : openPicked}// Only the planner on screen has days to select.onFocusDay={onScreen ? onFocusDay : undefined}/>diff --git a/client/src/components/Assistant/assistantFollowUpRules.test.ts b/client/src/components/Assistant/assistantFollowUpRules.test.tsnew file mode 100644index 000000000..825837e25--- /dev/null+++ b/client/src/components/Assistant/assistantFollowUpRules.test.ts@@ -0,0 +1,44 @@+/**+ * FE-AI-FOLLOW-001 to FE-AI-FOLLOW-002+ *+ * The follow-ups a card offers under an answer that ends on it: the ones that+ * ask for a change only for someone who may make it, and the answer's own+ * when none is left for a reader.+ */+import type { AssistantMessage } from '@trek/shared';+import { afterEach, describe, expect, it } from 'vitest';++import { followUpsFor } from './assistantFollowUpRules';+import { CARD_LOOKS } from './cards/cardLooks';++const answer: AssistantMessage = {+ id: 'a1',+ role: 'assistant',+ status: 'complete',+ createdAt: '2026-10-22T08:00:00.000Z',+ parts: [+ { type: 'text', text: 'Here is your year.' },+ { type: 'tool-call', toolCallId: 'r1', toolName: 'get_vacay_plan', args: {}, result: {} },+ { type: 'data-trek-card', data: { toolCallId: 'r1', card: { kind: 'vacay' } } },+ ],+};++afterEach(() => {+ delete CARD_LOOKS.vacay.followUps;+});++describe('card follow-ups', () => {+ it('FE-AI-FOLLOW-001: a follow-up that asks for a change is offered only to someone who may make it', () => {+ CARD_LOOKS.vacay.followUps = [+ { id: 'planDays', labelKey: 'assistant.followUp.next', edits: true },+ { id: 'holidays', labelKey: 'assistant.followUp.more' },+ ];+ expect(followUpsFor(answer, true).map((f) => f.id)).toEqual(['planDays', 'holidays']);+ expect(followUpsFor(answer, false).map((f) => f.id)).toEqual(['holidays']);+ });++ it('FE-AI-FOLLOW-002: with no card follow-up left for a reader, the answer offers its own', () => {+ CARD_LOOKS.vacay.followUps = [{ id: 'planDays', labelKey: 'assistant.followUp.next', edits: true }];+ expect(followUpsFor(answer, false).map((f) => f.id)).toEqual(['more', 'next']);+ });+});diff --git a/client/src/components/Assistant/assistantFollowUpRules.ts b/client/src/components/Assistant/assistantFollowUpRules.tsindex c876a27ac..197e88e1c 100644--- a/client/src/components/Assistant/assistantFollowUpRules.ts+++ b/client/src/components/Assistant/assistantFollowUpRules.ts@@ -1,15 +1,21 @@import type { AssistantMessage } from '@trek/shared';+import { messageBlocks } from './assistantParts';+import { CARD_LOOKS } from './cards/cardLooks';+/*** The next questions an answer suggests, as one tap each: read from what the* answer holds, not asked from the model, so they cost nothing and come at- * once. Places found ask to narrow them, a plan asks to go on, a forecast asks- * for the other weather. Three at most; the first kind the answer holds wins.+ * once. Cards ask what their kind offers, places found ask to narrow them, a+ * plan asks to go on, a forecast asks for the other weather. Three at most;+ * the first kind the answer holds wins.*/export interface FollowUp {id: string;labelKey: string;+ /** Asks for a change, so only someone who may edit the trip is offered it. */+ edits?: boolean;}const PLACES: readonly FollowUp[] = [@@ -34,8 +40,23 @@ const GENERAL: readonly FollowUp[] = [{ id: 'next', labelKey: 'assistant.followUp.next' },];+/**+ * The follow-ups of the cards an answer ends on (past its closing words): what+ * the first card's kind offers, laid out as the chat lays it out, without the+ * ones that ask for a change when the user may not make one.+ */+function cardFollowUps(message: AssistantMessage, canEdit: boolean): readonly FollowUp[] {+ const blocks = messageBlocks(message, false).filter((block) => block.kind !== 'text');+ const last = blocks[blocks.length - 1];+ const kind = last?.kind === 'cards' ? last.entries[0]?.card.kind : undefined;+ const offered = kind ? (CARD_LOOKS[kind].followUps ?? []) : [];+ return canEdit ? offered : offered.filter((followUp) => !followUp.edits);+}+/** What an answer offers to ask next; changes are offered only to someone who may make them. */export function followUpsFor(message: AssistantMessage, canEdit: boolean): readonly FollowUp[] {+ const fromCards = cardFollowUps(message, canEdit);+ if (fromCards.length > 0) return fromCards;const types = new Set(message.parts.map((part) => part.type));if (canEdit && (types.has('data-trek-change') || types.has('data-trek-applied'))) return PLAN;if (types.has('data-trek-places')) return PLACES;diff --git a/client/src/components/Assistant/assistantModel.ts b/client/src/components/Assistant/assistantModel.tsindex aec0f687b..a11da5606 100644--- a/client/src/components/Assistant/assistantModel.ts+++ b/client/src/components/Assistant/assistantModel.ts@@ -1,12 +1,15 @@import type { ThreadMessageLike } from '@assistant-ui/react';import type { AiStatusResponse, AssistantErrorCode, AssistantMessage, AssistantMessagePart } from '@trek/shared';+import { STEP_LOOKS } from './cards/cardLooks';+/*** Pure helpers the assistant's views share, desktop window and phone screen* alike: the bridge from stored messages to @assistant-ui, what an error says- * and offers, how a reading tool is named while it runs, and which questions- * the empty chat suggests. No React, and only a type from @assistant-ui, so- * importing this keeps the chat runtime out of the chunk.+ * and offers, how a reading tool is named while it runs (the steps live in+ * the cards' look), and which questions the empty chat suggests. No React,+ * and only a type from @assistant-ui, so importing this keeps the chat+ * runtime out of the chunk.*/type LikePart = Exclude<ThreadMessageLike['content'], string>[number];@@ -144,47 +147,11 @@ export function connectionErrorOf(status: AiStatusResponse | null): AssistantErr// ── Tool steps ──────────────────────────────────────────────────────────────-/** `liveKey` names the step with the place or query it is at, `param` is the word that fills it. */-interface StepLook {- stepKey: string;- live?: { liveKey: string; param: 'place' | 'query' };-}--const STEPS: Partial<Record<string, StepLook>> = {- get_trip_summary: { stepKey: 'assistant.step.reading' },- list_places: { stepKey: 'assistant.step.reading' },- search_place: {- stepKey: 'assistant.step.searching',- live: { liveKey: 'assistant.step.searchingFor', param: 'query' },- },- search_pois: { stepKey: 'assistant.step.searching', live: { liveKey: 'assistant.step.nearbyAt', param: 'place' } },- get_place_details: { stepKey: 'assistant.step.details' },- search_nearby_places: {- stepKey: 'assistant.step.nearby',- live: { liveKey: 'assistant.step.nearbyAt', param: 'place' },- },- list_categories: { stepKey: 'assistant.step.categories' },- get_weather: { stepKey: 'assistant.step.weather', live: { liveKey: 'assistant.step.weatherAt', param: 'place' } },- list_todos: { stepKey: 'assistant.step.todos' },- get_settlement_summary: { stepKey: 'assistant.step.costs' },- list_budget_items: { stepKey: 'assistant.step.expenses' },- get_budget_per_person: { stepKey: 'assistant.step.shares' },- get_wind_forecast: { stepKey: 'assistant.step.wind' },- get_journey_tracks: { stepKey: 'assistant.step.tracks' },- scan_bucket_list_visits: { stepKey: 'assistant.step.bucketScan' },- suggest_atlas_countries: { stepKey: 'assistant.step.atlasCountries' },- propose_hike: {- stepKey: 'assistant.step.planningHike',- live: { liveKey: 'assistant.step.planningHikeTo', param: 'place' },- },- search_help: { stepKey: 'assistant.step.help' },- read_booking_file: { stepKey: 'assistant.step.readingBooking' },-};const WORKING = { stepKey: 'assistant.step.working' };/** How a reading tool is named while it runs: "Reading your plan", never the tool's name. */export function toolStepKey(toolName: string): string {- return STEPS[toolName]?.stepKey ?? WORKING.stepKey;+ return STEP_LOOKS[toolName]?.stepKey ?? WORKING.stepKey;}/**@@ -193,7 +160,7 @@ export function toolStepKey(toolName: string): string {* or the step has no such line.*/export function liveStepText(toolName: string, label: string | null): { key: string; params?: Record<string, string> } {- const live = STEPS[toolName]?.live;+ const live = STEP_LOOKS[toolName]?.live;if (!live || !label) return { key: toolStepKey(toolName) };return { key: live.liveKey, params: { [live.param]: label } };}diff --git a/client/src/components/Assistant/assistantParts.test.ts b/client/src/components/Assistant/assistantParts.test.tsindex ace1d1624..5611b3ef6 100644--- a/client/src/components/Assistant/assistantParts.test.ts+++ b/client/src/components/Assistant/assistantParts.test.ts@@ -1,9 +1,10 @@/**- * FE-AI-PARTS-001 to FE-AI-PARTS-014+ * FE-AI-PARTS-001 to FE-AI-PARTS-019** How an answer is laid out: text, the steps the assistant looked up, the- * places and the weather they found, and one card per batch of proposed- * changes, each change in the state its approval and receipt put it in.+ * places and the weather they found, the cards its tools brought, and one+ * card per batch of proposed changes, each change in the state its approval+ * and receipt put it in, with its own card.*/import {ASSISTANT_CHANGE_LABEL_KEYS,@@ -13,10 +14,18 @@ import {type AssistantMessage,type AssistantMessagePart,type AssistantWeatherDay,+ type TrekCard,} from '@trek/shared';import { describe, expect, it } from 'vitest';-import { CHANGE_LABELS, hasUndecided, messageBlocks, suggestedFromStrip, undoLeftMs } from './assistantParts';+import {+ CHANGE_LABELS,+ type CardRules,+ hasUndecided,+ messageBlocks,+ suggestedFromStrip,+ undoLeftMs,+} from './assistantParts';const AT = '2026-10-21T08:00:00.000Z';@@ -294,6 +303,94 @@ describe('messageBlocks: found places and weather', () => {});});+describe('messageBlocks: cards', () => {+ const ROUTE: TrekCard = { kind: 'tourRoute' };+ const LIST: TrekCard = { kind: 'tourList' };+ const card = (toolCallId: string, value: TrekCard | null): AssistantMessagePart => ({+ type: 'data-trek-card',+ data: { toolCallId, card: value },+ });++ it('FE-AI-PARTS-015: a read card joins the cards of its kind across steps, and the steps stay one row', () => {+ const blocks = messageBlocks(+ message([read('r1', {}), card('r1', LIST), read('r2', {}), card('r2', LIST), read('r3', {}), card('r3', ROUTE)]),+ false+ );+ expect(blocks.map((b) => b.kind)).toEqual(['steps', 'cards', 'cards']);+ expect(blocks[0]).toMatchObject({ steps: [{ toolCallId: 'r1' }, { toolCallId: 'r2' }, { toolCallId: 'r3' }] });+ expect(blocks[1]).toMatchObject({ group: 'tourList', entries: [{ toolCallId: 'r1' }, { toolCallId: 'r2' }] });+ expect(blocks[2]).toMatchObject({ group: 'tourRoute', entries: [{ toolCallId: 'r3', card: ROUTE }] });+ });++ it('FE-AI-PARTS-016: text between cards starts a new block; a card that did not read leaves nothing', () => {+ const blocks = messageBlocks(+ message([card('r1', LIST), { type: 'text', text: 'And more:' }, card('r2', LIST), card('r3', null)]),+ false+ );+ expect(blocks.map((b) => b.kind)).toEqual(['cards', 'text', 'cards']);+ expect(blocks[2]).toMatchObject({ entries: [{ toolCallId: 'r2' }] });+ });++ it('FE-AI-PARTS-017: a change carries its preview card until the applied card replaces it, and forms no block', () => {+ const held = { ...preview('w1'), card: ROUTE };+ const before = messageBlocks(message([write('w1'), { type: 'data-trek-change', data: held }]), false);+ expect(before).toHaveLength(1);+ expect(before[0]).toMatchObject({ kind: 'change', items: [{ toolCallId: 'w1', card: ROUTE }] });++ const after = messageBlocks(+ message([+ write('w1', { approved: true }, { result: {} }),+ { type: 'data-trek-change', data: held },+ { type: 'data-trek-applied', data: applied('w1') },+ card('w1', LIST),+ ]),+ false+ );+ expect(after.map((b) => b.kind)).toEqual(['change']);+ expect(after[0]).toMatchObject({ items: [{ toolCallId: 'w1', state: 'applied', card: LIST }] });++ const plain = messageBlocks(message([write('w2'), { type: 'data-trek-change', data: preview('w2') }]), false);+ expect(plain[0]).toMatchObject({ items: [{ card: null }] });+ });++ it('FE-AI-PARTS-018: the rules group cards, and a lookup card that served a change gives way to it', () => {+ const rules: CardRules = {+ group: () => 'tours',+ yieldsToChange: (answer, change) => answer.kind === 'tourList' && change.kind === 'tourRoute',+ };+ const parts: AssistantMessagePart[] = [+ card('r1', LIST),+ card('r2', ROUTE),+ write('w1'),+ { type: 'data-trek-change', data: { ...preview('w1'), card: ROUTE } },+ ];+ const blocks = messageBlocks(message(parts), false, rules);+ expect(blocks.map((b) => b.kind)).toEqual(['cards', 'change']);+ expect(blocks[0]).toMatchObject({ group: 'tours', entries: [{ toolCallId: 'r2' }] });++ // Without a change card nothing gives way; with the plain rules each kind is its own group.+ const plain = messageBlocks(message(parts.slice(0, 2)), false);+ expect(plain.map((b) => (b.kind === 'cards' ? b.group : b.kind))).toEqual(['tourList', 'tourRoute']);+ });++ it('FE-AI-PARTS-019: a block left with no card goes, and a step after the cards joins the steps before them', () => {+ const rules: CardRules = { group: (c) => c.kind, yieldsToChange: () => true };+ const blocks = messageBlocks(+ message([+ read('r1', {}),+ card('r1', LIST),+ read('r2', {}),+ write('w1'),+ { type: 'data-trek-change', data: { ...preview('w1'), card: ROUTE } },+ ]),+ false,+ rules+ );+ expect(blocks.map((b) => b.kind)).toEqual(['steps', 'change']);+ expect(blocks[0]).toMatchObject({ steps: [{ toolCallId: 'r1' }, { toolCallId: 'r2' }] });+ });+});+describe('hasUndecided', () => {it('FE-AI-PARTS-012: is true only while a change waits for the user', () => {expect(hasUndecided([message([write('w1')])])).toBe(true);diff --git a/client/src/components/Assistant/assistantParts.ts b/client/src/components/Assistant/assistantParts.tsindex 9b03c2f03..76b717014 100644--- a/client/src/components/Assistant/assistantParts.ts+++ b/client/src/components/Assistant/assistantParts.ts@@ -8,16 +8,21 @@ import type {AssistantMessagePart,AssistantPlaces,AssistantWeatherDay,+ TrekCard,} from '@trek/shared';+import { CARD_RULES } from './cards/cardLooks';+import type { CardEntry } from './cards/cardTypes';+/*** How an answer is laid out: its stored parts read as blocks. Text stays* text; the reading tools of a run sit together as one row of steps; the* changes the model proposes in one go sit together as one card, each with* its preview and, once applied, its receipt. The places a search found sit* as one strip, the newest search's, and the weather the steps looked up as- * one row of days. Pure, so the window and the phone screen lay an answer out- * the same way and a test can pin it.+ * one row of days. The cards of reading tools sit as blocks of their group; a+ * write's card rides on its change. Pure, so the window and the phone screen+ * lay an answer out the same way and a test can pin it.*//** Where the settings card for the user's own AI connection lives. */@@ -47,14 +52,26 @@ export interface ChangeItem {/** The receipt of an applied change. */applied: AssistantApplied | null;state: ChangeState;+ /** What the change does as a card: the applied one once it came, else the preview's; null without one. */+ card: TrekCard | null;}+/** The answer cards of one group, side by side. */+export type CardsBlock = { kind: 'cards'; key: string; group: string; entries: CardEntry[] };+type MessageBlock =| { kind: 'text'; key: string; text: string }| { kind: 'steps'; key: string; steps: ToolStep[] }| { kind: 'change'; key: string; items: ChangeItem[] }| { kind: 'places'; key: string; found: AssistantPlaces }- | { kind: 'weather'; key: string; days: AssistantWeatherDay[] };+ | { kind: 'weather'; key: string; days: AssistantWeatherDay[] }+ | CardsBlock;++/** How cards are laid out: the group each joins, and which ones give way to a change they served. */+export interface CardRules {+ group(card: TrekCard): string;+ yieldsToChange(answer: TrekCard, change: TrekCard): boolean;+}/** The change "+ Day 3" on a found place makes; the server holds it without a model turn. */const FOUND_PLACE_TOOL = 'add_found_place';@@ -126,16 +143,59 @@ function pushChange(blocks: MessageBlock[], item: ChangeItem, fromStrip: Readonlelse blocks.push({ kind: 'change', key: `change-${item.toolCallId}`, items: [item] });}-/** The steps block a new step joins: the last one, past any strip shown after it. */+/** The steps block a new step joins: the last one, past any strip or cards shown after it. */function openSteps(blocks: readonly MessageBlock[]): Extract<MessageBlock, { kind: 'steps' }> | null {for (let i = blocks.length - 1; i >= 0; i--) {const block = blocks[i];if (block?.kind === 'steps') return block;- if (block?.kind !== 'places' && block?.kind !== 'weather') return null;+ if (block?.kind !== 'places' && block?.kind !== 'weather' && block?.kind !== 'cards') return null;}return null;}+/** Adds an answer card to the last cards block of its group when only steps lie between them, or starts one. */+function pushCard(blocks: MessageBlock[], entry: CardEntry, group: string): void {+ for (let i = blocks.length - 1; i >= 0; i--) {+ const block = blocks[i];+ if (block?.kind === 'steps') continue;+ if (block?.kind === 'cards' && block.group === group) {+ block.entries.push(entry);+ return;+ }+ break;+ }+ blocks.push({ kind: 'cards', key: `cards-${entry.toolCallId}`, group, entries: [entry] });+}++/** The blocks without the answer cards that give way to one of the message's changes, and without emptied ones. */+function withoutYielded(blocks: MessageBlock[], rules: CardRules): MessageBlock[] {+ const changes = blocks.flatMap((b) => (b.kind === 'change' ? b.items.flatMap((i) => (i.card ? [i.card] : [])) : []));+ if (changes.length === 0) return blocks;+ return blocks.flatMap((block) => {+ if (block.kind !== 'cards') return [block];+ const entries = block.entries.filter((e) => !changes.some((change) => rules.yieldsToChange(e.card, change)));+ return entries.length > 0 ? [{ ...block, entries }] : [];+ });+}++/** The change a call holds, with its preview, receipt and card; null for a reading step. */+function changeItemOf(+ part: ToolCallPart,+ preview: AssistantChangePreview | null,+ receipts: ReadonlyMap<string, AssistantApplied>,+ cards: ReadonlyMap<string, TrekCard>+): ChangeItem | null {+ if (!part.approval && !preview) return null;+ const applied = receipts.get(part.toolCallId) ?? null;+ return {+ toolCallId: part.toolCallId,+ preview,+ applied,+ state: changeState(part, applied),+ card: cards.get(part.toolCallId) ?? preview?.card ?? null,+ };+}+function changeState(part: ToolCallPart, applied: AssistantApplied | null): ChangeState {const approval = part.approval;if (approval?.resolution) return 'expired';@@ -157,10 +217,21 @@ function changeState(part: ToolCallPart, applied: AssistantApplied | null): Chan* answer already holds; the weather of all steps joins* into one row where the first look sat. A strip does not split the steps* around it: a step after it joins the row of steps before it.+ *+ * A reading tool's card joins the cards block of its group (by `rules`, the+ * kinds' looks unless a test hands others) when only steps lie between them;+ * a card under a change's id is that change's and forms no block. Last,+ * answer cards that give way to one of the message's changes are left out.*/-export function messageBlocks(message: AssistantMessage, writing: boolean): MessageBlock[] {+export function messageBlocks(+ message: AssistantMessage,+ writing: boolean,+ rules: CardRules = CARD_RULES+): MessageBlock[] {const previews = new Map<string, AssistantChangePreview>();const receipts = new Map<string, AssistantApplied>();+ const cards = new Map<string, TrekCard>();+ const changeIds = new Set<string>();const effects: AssistantChangeEffect[] = [];// A place the user suggested from the strip stays on it, marked as suggested.const fromStrip = new Set(@@ -172,9 +243,12 @@ export function messageBlocks(message: AssistantMessage, writing: boolean): Messif (part.type === 'data-trek-change') {previews.set(part.data.toolCallId, part.data);if (part.data.effect && !fromStrip.has(part.data.toolCallId)) effects.push(part.data.effect);+ changeIds.add(part.data.toolCallId);} else if (part.type === 'data-trek-applied') receipts.set(part.data.toolCallId, part.data);else if (part.type === 'data-trek-places') lastPlaces = index;else if (part.type === 'data-trek-weather' && firstWeather < 0) firstWeather = index;+ else if (part.type === 'data-trek-card' && part.data.card) cards.set(part.data.toolCallId, part.data.card);+ else if (part.type === 'tool-call' && part.approval) changeIds.add(part.toolCallId);});const blocks: MessageBlock[] = [];@@ -193,11 +267,15 @@ export function messageBlocks(message: AssistantMessage, writing: boolean): Messblocks.push({ kind: 'weather', key: `weather-${index}`, days: weatherDays(message.parts) });return;}+ if (part.type === 'data-trek-card') {+ const { toolCallId, card } = part.data;+ // A card under a change's id is that change's; it rides on its row.+ if (card && !changeIds.has(toolCallId)) pushCard(blocks, { toolCallId, card }, rules.group(card));+ return;+ }if (part.type !== 'tool-call') return;- const preview = previews.get(part.toolCallId) ?? null;- if (part.approval || preview) {- const applied = receipts.get(part.toolCallId) ?? null;- const item: ChangeItem = { toolCallId: part.toolCallId, preview, applied, state: changeState(part, applied) };+ const item = changeItemOf(part, previews.get(part.toolCallId) ?? null, receipts, cards);+ if (item) {pushChange(blocks, item, fromStrip);return;}@@ -210,7 +288,7 @@ export function messageBlocks(message: AssistantMessage, writing: boolean): Messif (steps) steps.steps.push(step);else blocks.push({ kind: 'steps', key: `steps-${part.toolCallId}`, steps: [step] });});- return blocks;+ return withoutYielded(blocks, rules);}/**diff --git a/client/src/components/Assistant/assistantShare.ts b/client/src/components/Assistant/assistantShare.tsindex 6312867fc..2738d54a1 100644--- a/client/src/components/Assistant/assistantShare.ts+++ b/client/src/components/Assistant/assistantShare.ts@@ -1,6 +1,7 @@import type { AssistantMessage } from '@trek/shared';import { messageBlocks } from './assistantParts';+import { verbLookOf } from './cards/cardLooks';/*** What an answer says once it goes to the trip chat, which shows plain text:@@ -102,7 +103,8 @@ export function chatTextOf(message: AssistantMessage, opts: { includeChanges: boconst previews = blocks.flatMap((b) =>b.kind === 'change' ? b.items.flatMap((i) => (i.state === 'applied' && i.preview ? [i.preview] : [])) : []);- const lines = previews.map((p) => `✓ ${opts.t(`assistant.change.verb.${p.verbKey}`)}: ${p.subject}`);+ // Named by its verb, as the share text always was; a card never goes along (it may hold what is private).+ const lines = previews.map((p) => `✓ ${opts.t(verbLookOf(p.verbKey).labelKey)}: ${p.subject}`);const heading = opts.t('assistant.share.changesHeading');const changes = opts.includeChanges && lines.length > 0 ? [heading, ...lines].join('\n') : '';const full = [body, changes].filter(Boolean).join('\n\n');diff --git a/client/src/components/Assistant/assistantShowOnMap.test.ts b/client/src/components/Assistant/assistantShowOnMap.test.tsindex 3230c270a..3abeacae9 100644--- a/client/src/components/Assistant/assistantShowOnMap.test.ts+++ b/client/src/components/Assistant/assistantShowOnMap.test.ts@@ -1,6 +1,6 @@import type { AssistantApplied } from '@trek/shared';-import { showOnMapSearch, showOnMapTarget } from './assistantShowOnMap';+import { plannerSearchOf, showOnMapTarget } from './assistantShowOnMap';const applied = (entity: AssistantApplied['entity'], ids: number[], dayId: number | null): AssistantApplied => ({toolCallId: 'c1',@@ -10,19 +10,34 @@ const applied = (entity: AssistantApplied['entity'], ids: number[], dayId: numbeundoUntil: null,});+/** The planner's query for what "Show on map" points an applied change at. */+const searchOf = (change: AssistantApplied) => {+ const target = showOnMapTarget(change);+ return target ? plannerSearchOf({ kind: 'map', ...target }) : null;+};+describe('assistantShowOnMap', () => {it('FE-ASSIST-SHOW-001: a place goes to the place, even when it was put on a day', () => {expect(showOnMapTarget(applied('place', [7], 3))).toEqual({ placeId: 7, dayId: null });- expect(showOnMapSearch(applied('place', [7], 3))).toBe('?place=7');+ expect(searchOf(applied('place', [7], 3))).toBe('?place=7');+ });++ it('FE-ASSIST-SHOW-002: a stop, a note or a booking goes to its day', () => {+ expect(searchOf(applied('assignment', [41], 3))).toBe('?day=3');+ expect(searchOf(applied('day_note', [9], 4))).toBe('?day=4');+ expect(searchOf(applied('reservation', [5], 2))).toBe('?day=2');});- it('FE-ASSIST-SHOW-002: a stop or a note goes to its day', () => {- expect(showOnMapSearch(applied('assignment', [41], 3))).toBe('?day=3');- expect(showOnMapSearch(applied('day_note', [9], 4))).toBe('?day=4');+ it('FE-ASSIST-SHOW-003: no target where nothing shows on the map; a place without a spot opens the planner', () => {+ expect(showOnMapTarget(applied('packing', [2], null))).toBeNull();+ expect(showOnMapTarget(applied('tour', [2], 3))).toBeNull();+ expect(showOnMapTarget(applied('memory', [], null))).toBeNull();+ expect(searchOf(applied('place', [], null))).toBe('');});- it('FE-ASSIST-SHOW-003: a change with nowhere to point at opens the planner as it is', () => {- expect(showOnMapTarget(applied('packing', [2], null))).toEqual({ placeId: null, dayId: null });- expect(showOnMapSearch(applied('place', [], null))).toBe('');+ it('FE-ASSIST-SHOW-004: a tab of the trip goes as ?tab= with what the tab reads beside it', () => {+ const expense = plannerSearchOf({ kind: 'tab', tab: 'finanzplan', params: { expense: '7' } });+ expect(expense).toBe('?tab=finanzplan&expense=7');+ expect(plannerSearchOf({ kind: 'tab', tab: 'listen', sub: 'todo' })).toBe('?tab=listen');});});diff --git a/client/src/components/Assistant/assistantShowOnMap.ts b/client/src/components/Assistant/assistantShowOnMap.tsindex 348bff62e..5ce5abd57 100644--- a/client/src/components/Assistant/assistantShowOnMap.ts+++ b/client/src/components/Assistant/assistantShowOnMap.ts@@ -1,4 +1,7 @@-import type { AssistantApplied } from '@trek/shared';+import type { AssistantApplied, TrekCard } from '@trek/shared';++import { entityLookOf } from './cards/cardLooks';+import type { EntityTarget } from './cards/cardTypes';interface ShowOnMapTarget {/** The place the change made or changed. */@@ -7,16 +10,23 @@ interface ShowOnMapTarget {dayId: number | null;}-/** Where "Show on map" takes an applied change: the place when it is one, else its day; nothing for the rest. */-export function showOnMapTarget(applied: AssistantApplied): ShowOnMapTarget {- const placeId = applied.entity === 'place' ? (applied.ids[0] ?? null) : null;- return { placeId, dayId: placeId === null ? applied.dayId : null };+/**+ * Where "Show on map" takes an applied change, as its entity's look says: a+ * place shows itself, a stop or a note its day. Null for what has no place on+ * the map (a kept note, a to-do), which then shows no map button at all.+ */+export function showOnMapTarget(applied: AssistantApplied, card: TrekCard | null = null): ShowOnMapTarget | null {+ return entityLookOf(applied.entity).onMap?.(applied, card) ?? null;}-/** The planner's query for it: `?place=` opens the place, `?day=` selects the day. */-export function showOnMapSearch(applied: AssistantApplied): string {- const { placeId, dayId } = showOnMapTarget(applied);- if (placeId !== null) return `?place=${placeId}`;- if (dayId !== null) return `?day=${dayId}`;+/**+ * The planner's query for a target on the trip: `?place=` opens the place,+ * `?day=` selects the day, and a tab goes as `?tab=` with whatever the tab+ * reads beside it (`?tab=finanzplan&expense=7`).+ */+export function plannerSearchOf(target: Exclude<EntityTarget, { kind: 'page' }>): string {+ if (target.kind === 'tab') return `?${new URLSearchParams({ tab: target.tab, ...target.params }).toString()}`;+ if (target.placeId !== null) return `?place=${target.placeId}`;+ if (target.dayId !== null) return `?day=${target.dayId}`;return '';}diff --git a/client/src/components/Assistant/assistantViewContext.ts b/client/src/components/Assistant/assistantViewContext.tsindex b58ede09c..dbe8b5e35 100644--- a/client/src/components/Assistant/assistantViewContext.ts+++ b/client/src/components/Assistant/assistantViewContext.ts@@ -1,6 +1,7 @@-import type { AssistantApplied } from '@trek/shared';import { createContext, useContext } from 'react';+import type { EntityTarget } from './cards/cardTypes';+/** What the parts deep inside a chat need from whoever shows it. */export interface AssistantView {tripId: number;@@ -8,8 +9,12 @@ export interface AssistantView {variant: 'window' | 'fullscreen';/** How much room the chat has: a narrow window and the phone are 'compact'. */density?: 'compact' | 'roomy';- /** Shows an applied change in the planner; the button is left out where nothing can show it. */- onShowOnMap?: (applied: AssistantApplied) => void;+ /**+ * Opens what a card or an applied change points at: a spot on the plan's+ * map, a tab of the trip, another page. The buttons are left out where+ * nothing can open them.+ */+ onOpen?: (target: EntityTarget) => void;/** Selects a day in the planner, from its weather; left out where no planner can show it. */onFocusDay?: (dayId: number) => void;/** Brings the map into view where the chat covers it (the phone), before the map moves. */diff --git a/client/src/components/Assistant/cards/AssistantCardBlock.test.tsx b/client/src/components/Assistant/cards/AssistantCardBlock.test.tsxnew file mode 100644index 000000000..b5107ecbd--- /dev/null+++ b/client/src/components/Assistant/cards/AssistantCardBlock.test.tsx@@ -0,0 +1,74 @@+/**+ * FE-AI-CARDBLOCK-001 to FE-AI-CARDBLOCK-003+ *+ * A block of answer cards is drawn by its kind's view; a kind not drawn yet+ * shows nothing, and a card that throws is left out without the answer+ * around it.+ */+import type { AssistantMessage, TrekCard } from '@trek/shared';+import { afterEach, describe, expect, it, vi } from 'vitest';++import { render, screen } from '../../../../tests/helpers/render';+import type { CardsBlock } from '../assistantParts';+import AssistantCardBlock from './AssistantCardBlock';++vi.mock('./cardViews', async (importOriginal) => {+ const actual = await importOriginal<typeof import('./cardViews')>();+ const { createElement } = await import('react');+ const views = {+ ...actual.CARD_VIEWS,+ tourList: {+ Block: function Block({ cards }: { cards: readonly { toolCallId: string }[] }) {+ return createElement('p', null, `${cards.length} tour lists`);+ },+ },+ tourRoute: {+ Block: function Broken(): never {+ throw new Error('broken card');+ },+ },+ };+ return { ...actual, CARD_VIEWS: views, viewOf: (card: TrekCard) => views[card.kind] };+});++const MESSAGE: AssistantMessage = {+ id: 'm1',+ role: 'assistant',+ status: 'complete',+ createdAt: '2026-10-22T08:00:00.000Z',+ parts: [],+};++const block = (card: TrekCard, count = 1): CardsBlock => ({+ kind: 'cards',+ key: 'cards-r1',+ group: card.kind,+ entries: Array.from({ length: count }, (_, i) => ({ toolCallId: `r${i}`, card })),+});++afterEach(() => vi.restoreAllMocks());++describe('AssistantCardBlock', () => {+ it('FE-AI-CARDBLOCK-001: the kind draws the whole block', () => {+ render(<AssistantCardBlock block={block({ kind: 'tourList' }, 2)} message={MESSAGE} />);+ expect(screen.getByText('2 tour lists')).toBeInTheDocument();+ });++ it('FE-AI-CARDBLOCK-002: a kind not drawn yet shows nothing', () => {+ const { container } = render(<AssistantCardBlock block={block({ kind: 'vacay' })} message={MESSAGE} />);+ expect(container).toBeEmptyDOMElement();+ });++ it('FE-AI-CARDBLOCK-003: a card that throws is logged and left out', () => {+ const logged = vi.spyOn(console, 'error').mockImplementation(() => {});+ const { container } = render(+ <div>+ <AssistantCardBlock block={block({ kind: 'tourRoute' })} message={MESSAGE} />+ <span>the answer</span>+ </div>+ );+ expect(screen.getByText('the answer')).toBeInTheDocument();+ expect(container.querySelector('p')).toBeNull();+ expect(logged).toHaveBeenCalled();+ });+});diff --git a/client/src/components/Assistant/cards/AssistantCardBlock.tsx b/client/src/components/Assistant/cards/AssistantCardBlock.tsxnew file mode 100644index 000000000..7c42e94a6--- /dev/null+++ b/client/src/components/Assistant/cards/AssistantCardBlock.tsx@@ -0,0 +1,21 @@+import type { AssistantMessage } from '@trek/shared';++import type { CardsBlock } from '../assistantParts';+import { viewOf } from './cardViews';+import CardBoundary from './parts/CardBoundary';++/**+ * The answer cards of one group, drawn by their kind's `Block`. A kind with+ * no view yet draws nothing, and a card that throws is left out with the rest+ * of the answer still in place.+ */+export default function AssistantCardBlock({ block, message }: { block: CardsBlock; message: AssistantMessage }) {+ const first = block.entries[0];+ const Block = first ? viewOf(first.card).Block : undefined;+ if (!Block) return null;+ return (+ <CardBoundary>+ <Block cards={block.entries} message={message} />+ </CardBoundary>+ );+}diff --git a/client/src/components/Assistant/cards/ChangeCardSlots.test.tsx b/client/src/components/Assistant/cards/ChangeCardSlots.test.tsxnew file mode 100644index 000000000..06eef381b--- /dev/null+++ b/client/src/components/Assistant/cards/ChangeCardSlots.test.tsx@@ -0,0 +1,187 @@+/**+ * FE-AI-SLOTS-001 to FE-AI-SLOTS-006+ *+ * A change that carries a card is drawn through its kind's view: the slots+ * of a waiting row and of its receipt, a kind that draws its own subject, a+ * group around a run of rows of one kind, a run of waiting rows decided as+ * one, rows that start switched off, and slots that throw drawing what the+ * row shows without a card. The views here are test views.+ */+import type { AssistantApplied, AssistantChangePreview, TrekCard } from '@trek/shared';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { fireEvent, render, screen } from '../../../../tests/helpers/render';+import { chatOf, useAssistantStore } from '../../../store/assistantStore';+import AssistantChangeCard from '../AssistantChangeCard';+import type { ChangeItem } from '../assistantParts';+import { type AssistantView, AssistantViewContext } from '../assistantViewContext';++vi.mock('./cardViews', async (importOriginal) => {+ const actual = await importOriginal<typeof import('./cardViews')>();+ const { createElement } = await import('react');+ const words = (label: string) =>+ function Words() {+ return createElement('span', null, label);+ };+ const broken = function Broken(): never {+ throw new Error('broken view');+ };+ const views = {+ ...actual.CARD_VIEWS,+ tourRoute: {+ Lead: words('route lead'),+ Aside: words('route aside'),+ Facts: words('route facts'),+ Body: words('route body'),+ },+ tourList: {+ ownsSubject: true,+ Group: function Group({ items, place }: { items: readonly ChangeItem[]; place: string }) {+ return createElement('p', null, `${place} of ${items.length}`);+ },+ Run: function Run({+ items,+ excluded,+ onToggle,+ }: {+ items: readonly ChangeItem[];+ excluded: ReadonlySet<string>;+ onToggle: (id: string) => void;+ }) {+ return createElement(+ 'button',+ { type: 'button', onClick: () => onToggle(items[0]?.toolCallId ?? '') },+ `run of ${items.length}, ${excluded.size} off`+ );+ },+ runnable: (card: TrekCard) => card.kind === 'tourList',+ startsExcluded: () => true,+ },+ dayRoute: { Lead: broken, Aside: broken, Facts: broken, Body: broken, Run: broken },+ };+ return { ...actual, CARD_VIEWS: views, viewOf: (card: TrekCard) => views[card.kind] };+});++const TRIP = 4;+const INITIAL = useAssistantStore.getState();+const ROUTE: TrekCard = { kind: 'tourRoute' };+const LIST: TrekCard = { kind: 'tourList' };+const BROKEN: TrekCard = { kind: 'dayRoute' };++function preview(toolCallId: string, subject: string): AssistantChangePreview {+ return {+ toolCallId,+ verbKey: 'addTour',+ subject,+ rows: [{ op: 'change', labelKey: 'time', before: '09:00', after: '10:30' }],+ dayId: 3,+ placeIds: [],+ undoable: true,+ };+}++const pending = (id: string, subject: string, card: TrekCard | null): ChangeItem => ({+ toolCallId: id,+ preview: preview(id, subject),+ applied: null,+ state: 'pending',+ card,+});++function receipt(id: string, card: TrekCard): ChangeItem {+ const applied: AssistantApplied = { toolCallId: id, entity: 'place', ids: [9], dayId: 3, undoUntil: null };+ return { ...pending(id, 'Ridge walk', card), applied, state: 'applied' };+}++function renderCard(items: ChangeItem[], view: Partial<AssistantView> = {}) {+ const value: AssistantView = { tripId: TRIP, variant: 'window', ...view };+ return render(+ <AssistantViewContext.Provider value={value}>+ <AssistantChangeCard items={items} />+ </AssistantViewContext.Provider>+ );+}++const decide = vi.fn(async () => {});++beforeEach(() => {+ useAssistantStore.setState({+ decide,+ byTrip: { [TRIP]: { ...chatOf(useAssistantStore.getState(), TRIP), threadId: 1 } },+ });+});++afterEach(() => {+ useAssistantStore.setState(INITIAL, true);+ vi.clearAllMocks();+});++describe('ChangeCardSlots', () => {+ it('FE-AI-SLOTS-001: a waiting change with a card fills its row from the kind, in place of the verb tile and fields', () => {+ renderCard([pending('c1', 'Ridge walk', ROUTE)]);+ for (const slot of ['route lead', 'route aside', 'route facts', 'route body']) {+ expect(screen.getByText(slot)).toBeInTheDocument();+ }+ expect(screen.getByText('Ridge walk')).toBeInTheDocument();+ expect(screen.queryByText('10:30')).toBeNull();+ });++ it('FE-AI-SLOTS-002: a receipt keeps the slots, with the way to what it changed', () => {+ const onOpen = vi.fn();+ renderCard([receipt('c1', ROUTE)], { onOpen });+ for (const slot of ['route lead', 'route aside', 'route facts', 'route body']) {+ expect(screen.getByText(slot)).toBeInTheDocument();+ }+ fireEvent.click(screen.getByRole('button', { name: 'Show on map' }));+ expect(onOpen).toHaveBeenCalledWith({ kind: 'map', placeId: 9, dayId: null });+ });++ it('FE-AI-SLOTS-003: a kind that draws its subject hides it, and a group frames its run of rows', () => {+ renderCard([receipt('c1', LIST), receipt('c2', LIST), pending('c3', 'Plain change', null)]);+ expect(screen.queryByText('Ridge walk')).toBeNull();+ expect(screen.getByText('head of 2')).toBeInTheDocument();+ expect(screen.getByText('foot of 2')).toBeInTheDocument();+ expect(screen.getByText('Plain change')).toBeInTheDocument();+ });++ it('FE-AI-SLOTS-004: two or more waiting rows the kind can take together are one run; a lone one stays a row', () => {+ const first = renderCard([pending('c1', 'One', LIST), pending('c2', 'Two', LIST)]);+ expect(screen.getByRole('button', { name: /^run of 2/ })).toBeInTheDocument();+ first.unmount();++ renderCard([pending('c1', 'One', LIST), pending('c2', 'Two', ROUTE)]);+ expect(screen.queryByRole('button', { name: /^run of/ })).toBeNull();+ expect(screen.getAllByRole('button', { name: 'Include this change' })).toHaveLength(2);+ });++ it('FE-AI-SLOTS-005: rows the kind starts off are left off once, until the user switches them on', () => {+ const items = [pending('c1', 'One', LIST), pending('c2', 'Two', LIST)];+ const view = renderCard(items);+ expect(screen.getByRole('button', { name: 'run of 2, 2 off' })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: 'Apply 0' })).toBeDisabled();++ fireEvent.click(screen.getByRole('button', { name: 'run of 2, 2 off' }));+ view.rerender(+ <AssistantViewContext.Provider value={{ tripId: TRIP, variant: 'window' }}>+ <AssistantChangeCard items={[...items]} />+ </AssistantViewContext.Provider>+ );+ expect(screen.getByRole('button', { name: 'run of 2, 1 off' })).toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: 'Apply 1' }));+ expect(decide).toHaveBeenCalledWith(TRIP, [+ { toolCallId: 'c1', approved: true },+ { toolCallId: 'c2', approved: false },+ ]);+ });++ it('FE-AI-SLOTS-006: slots that throw draw the plain row: a run its rows, the facts the fields', () => {+ const logged = vi.spyOn(console, 'error').mockImplementation(() => {});+ renderCard([pending('c1', 'One', BROKEN), pending('c2', 'Two', BROKEN)]);+ expect(screen.getByText('One')).toBeInTheDocument();+ expect(screen.getByText('Two')).toBeInTheDocument();+ expect(screen.getAllByText('10:30')).toHaveLength(2);+ expect(screen.getAllByRole('button', { name: 'Include this change' })).toHaveLength(2);+ expect(logged).toHaveBeenCalled();+ logged.mockRestore();+ });+});diff --git a/client/src/components/Assistant/cards/ChangeCardSlots.tsx b/client/src/components/Assistant/cards/ChangeCardSlots.tsxnew file mode 100644index 000000000..a14993fb6--- /dev/null+++ b/client/src/components/Assistant/cards/ChangeCardSlots.tsx@@ -0,0 +1,357 @@+import type { AssistantChangePreview, TrekCardKind } from '@trek/shared';+import { Check, Undo2 } from 'lucide-react';+import type { ReactNode } from 'react';++import { useTranslation } from '../../../i18n';+import { Tooltip } from '../../shared/Tooltip';+import AssistantChangeFields from '../AssistantChangeFields';+import type { ChangeItem } from '../assistantParts';+import { useAssistantView } from '../assistantViewContext';+import { useChangeHover } from '../useChangeHover';+import { TOOL_LABELS, verbLookOf } from './cardLooks';+import type { CardView } from './cardTypes';+import { viewOf } from './cardViews';+import EntityActions from './EntityActions';+import { ICON_BUTTON, RECEIPT } from './parts/assistantTones';+import CardBoundary from './parts/CardBoundary';+import KindTile from './parts/KindTile';++/**+ * The rows of the change card: a change waiting for its decision, and the+ * receipt it turns into. A change that carries a card is drawn through its+ * kind's view, slot by slot (`Lead` in front, `Aside` at the end of the+ * subject line, `Facts` on the faint line, `Body` under it); a change+ * without one reads as it always has: the tile of its verb, its subject, and+ * the few fields that tell it apart. A slot that throws draws what the row+ * shows without a card, so one broken view never takes the chat down.+ */++type View = CardView<TrekCardKind>;++/** What the change does: the tool's own action where TREK names it, else add, change or remove. */+function verbLabel(preview: AssistantChangePreview, t: (key: string) => string): string {+ // Read as a string: a tool named like an object's own member (toString) has no label.+ const own = preview.tool ? TOOL_LABELS[preview.tool]?.labelKey : undefined;+ return t(typeof own === 'string' ? own : verbLookOf(preview.verbKey).labelKey);+}++/** The tile in front: the kind's own lead, else the verb's tile. */+function Lead({ item, view, dimmed }: { item: ChangeItem; view: View | null; dimmed: boolean }) {+ const look = item.preview ? verbLookOf(item.preview.verbKey) : null;+ const tile = <KindTile icon={look?.Icon ?? null} tone={look?.tone ?? 'info'} size="sm" dimmed={dimmed} />;+ const Own = view?.Lead;+ if (!Own || !item.card) return tile;+ return (+ <CardBoundary fallback={tile}>+ <Own card={item.card} item={item} />+ </CardBoundary>+ );+}++/** A slot of the kind's view, or nothing; `fallback` where it throws. */+function Slot({+ item,+ view,+ name,+ fallback = null,+}: {+ item: ChangeItem;+ view: View | null;+ name: 'Aside' | 'Facts' | 'Body';+ fallback?: ReactNode;+}) {+ const Own = view?.[name];+ if (!Own || !item.card) return null;+ return (+ <CardBoundary fallback={fallback}>+ <Own card={item.card} item={item} />+ </CardBoundary>+ );+}++/** The subject in bold, with the kind's aside at its end; only the aside where the kind draws the subject itself. */+function SubjectLine({+ subject,+ struck,+ aside,+ block = false,+}: {+ subject: string;+ struck: boolean;+ aside: ReactNode;+ block?: boolean;+}) {+ const text = (+ <bdi+ className={`${block ? 'block ' : ''}truncate text-body font-semibold leading-tight text-content ${struck ? 'line-through' : ''}`}+ >+ {subject}+ </bdi>+ );+ if (!aside) return text;+ return (+ <span className="flex min-w-0 items-center gap-2">+ <span className="min-w-0 flex-1 truncate">{text}</span>+ {aside}+ </span>+ );+}++/** Where in TREK a change outside the trip plan lands: the vacation planner, the journal. */+function DomainChip({ domain }: { domain: string | undefined }) {+ const { t } = useTranslation();+ if (!domain) return null;+ return (+ <span className="flex-shrink-0 rounded-full bg-surface-secondary px-1.5 text-content-secondary">+ {t(`assistant.domain.${domain}`)}+ </span>+ );+}++function ChangeHead({ item, view, struck }: { item: ChangeItem; view: View | null; struck: boolean }) {+ const { t } = useTranslation();+ const preview = item.preview;+ if (!preview) return <span className="trek-skeleton inline-block h-4 w-40" aria-hidden="true" />;+ const aside = <Slot item={item} view={view} name="Aside" />;+ return (+ <span className="flex min-w-0 flex-col">+ {view?.ownsSubject ? (+ aside+ ) : (+ <SubjectLine subject={preview.subject} struck={struck} aside={view?.Aside && aside} />+ )}+ <span className="mt-0.5 flex min-w-0 items-center gap-2.5 text-caption text-content-faint">+ <span className="truncate">{verbLabel(preview, t)}</span>+ <DomainChip domain={preview.domain} />+ <Slot item={item} view={view} name="Facts" />+ </span>+ </span>+ );+}++/** The kind's body under a row, faded with the row once the change is settled. */+function BodySlot({ item, view, settled }: { item: ChangeItem; view: View | null; settled: boolean }) {+ if (!view?.Body || !item.card) return null;+ return (+ <div className={`ps-[38px] pb-1.5 ${settled ? 'opacity-60' : ''}`}>+ <Slot item={item} view={view} name="Body" />+ </div>+ );+}++/** A decided change: its tile and head, the ways to what it changed, undo while it can, and its mark. */+function Receipt({+ item,+ undone,+ canUndo,+ onUndo,+}: {+ item: ChangeItem;+ undone: boolean;+ canUndo: boolean;+ onUndo: () => void;+}) {+ const { t } = useTranslation();+ if (item.state === 'pending') return null;+ const receipt = undone ? RECEIPT.discarded : RECEIPT[item.state];+ const { Icon } = receipt;+ const applied = item.state === 'applied' && !undone ? item.applied : null;+ const settled = item.state === 'discarded' || item.state === 'expired' || undone;+ const statusLabel = t(undone ? 'assistant.change.undone' : receipt.labelKey);+ const view = item.card ? viewOf(item.card) : null;+ return (+ <>+ <div className="trek-assistant-enter flex items-center gap-2.5 py-1.5">+ <Lead item={item} view={view} dimmed={settled} />+ <div className={`min-w-0 flex-1 ${settled ? 'opacity-60' : ''}`}>+ <ChangeHead item={item} view={view} struck={settled} />+ </div>+ {applied && <EntityActions applied={applied} card={item.card} />}+ {canUndo && (+ <Tooltip label={t('assistant.change.undo')} placement="top">+ <button type="button" onClick={onUndo} aria-label={t('assistant.change.undo')} className={ICON_BUTTON}>+ <Undo2 size={14} aria-hidden="true" />+ </button>+ </Tooltip>+ )}+ <Tooltip label={statusLabel} placement="top">+ <span+ role="img"+ aria-label={statusLabel}+ className={`flex h-7 w-5 items-center justify-center ${receipt.tone}`}+ >+ <Icon size={15} strokeWidth={2.4} className={item.state === 'applying' ? 'animate-spin' : ''} />+ </span>+ </Tooltip>+ </div>+ <BodySlot item={item} view={view} settled={settled} />+ </>+ );+}++/**+ * A change waiting for its decision, as a row of the planner's day list: the+ * round choice in front (only when there is more than one to choose from),+ * what it touches in bold, and a faint line saying what happens and when.+ * Resting on it lights its pin on the map.+ */+function PendingRow({+ item,+ excluded,+ withChoice,+ disabled,+ onToggle,+}: {+ item: ChangeItem;+ excluded: boolean;+ withChoice: boolean;+ disabled: boolean;+ onToggle: () => void;+}) {+ const { t } = useTranslation();+ const { tripId } = useAssistantView();+ const { litFromMap, handlers } = useChangeHover(tripId, item.preview?.effect ? item.toolCallId : null);+ const preview = item.preview;+ const view = item.card ? viewOf(item.card) : null;+ const aside = <Slot item={item} view={view} name="Aside" />;+ return (+ <>+ <div+ {...handlers}+ className={`-mx-1.5 flex items-center gap-2.5 rounded-[12px] px-1.5 py-2 transition-[opacity,background-color] ${+ excluded ? 'opacity-50' : ''+ } ${litFromMap ? 'bg-surface-hover' : 'hover:bg-surface-hover'}`}+ >+ {withChoice && (+ <button+ type="button"+ onClick={onToggle}+ disabled={disabled}+ aria-pressed={!excluded}+ aria-label={t('assistant.change.include')}+ className={`grid h-[18px] w-[18px] flex-none place-items-center rounded-full outline-none transition-colors focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${+ excluded ? 'border-[1.5px] border-edge bg-surface-card' : 'bg-accent'+ }`}+ >+ {!excluded && <Check size={11} strokeWidth={3} aria-hidden="true" className="text-accent-text" />}+ </button>+ )}+ <Lead item={item} view={view} dimmed={excluded} />+ <div className="min-w-0 flex-1">+ {preview ? (+ <>+ {view?.ownsSubject ? (+ aside+ ) : (+ <SubjectLine subject={preview.subject} struck={false} aside={view?.Aside && aside} block />+ )}+ <span className="mt-1 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-caption text-content-faint">+ <span className="me-0.5 min-w-0 truncate">{verbLabel(preview, t)}</span>+ <DomainChip domain={preview.domain} />+ {view?.Facts ? (+ <Slot item={item} view={view} name="Facts" fallback={<AssistantChangeFields rows={preview.rows} />} />+ ) : (+ <AssistantChangeFields rows={preview.rows} />+ )}+ </span>+ </>+ ) : (+ <span className="trek-skeleton inline-block h-4 w-40" aria-hidden="true" />+ )}+ </div>+ </div>+ <BodySlot item={item} view={view} settled={excluded} />+ </>+ );+}++interface RowsProps {+ items: readonly ChangeItem[];+ /** The waiting rows wait behind the week grid. */+ folded: boolean;+ excluded: ReadonlySet<string>;+ disabled: boolean;+ undone: Readonly<Record<string, true>>;+ undoable: readonly string[];+ onToggle: (toolCallId: string) => void;+ onUndo: (toolCallId: string) => void;+}++/** Consecutive changes of one kind of card; a change without a card stands alone. */+function runsOf(items: readonly ChangeItem[]): ChangeItem[][] {+ const runs: ChangeItem[][] = [];+ for (const item of items) {+ const last = runs[runs.length - 1];+ const kind = item.card?.kind;+ if (last && kind && last[0]?.card?.kind === kind) last.push(item);+ else runs.push([item]);+ }+ return runs;+}++/** Whether a row can join a `Run`: it waits, and its view takes it. */+function runnable(item: ChangeItem, view: View | null): boolean {+ if (item.state !== 'pending' || !item.card || !view?.Run) return false;+ return view.runnable ? view.runnable(item.card) : true;+}++/**+ * Every row of the card in order. A run of rows of one kind gets the kind's+ * `Group` before and after it, and two or more waiting rows its view can+ * take together are drawn as one `Run` instead.+ */+export function ChangeRows({ items, folded, excluded, disabled, undone, undoable, onToggle, onUndo }: RowsProps) {+ const pendingCount = items.filter((i) => i.state === 'pending').length;+ const row = (item: ChangeItem) =>+ item.state === 'pending' ? (+ folded ? null : (+ <PendingRow+ key={item.toolCallId}+ item={item}+ excluded={excluded.has(item.toolCallId)}+ withChoice={pendingCount > 1}+ disabled={disabled}+ onToggle={() => onToggle(item.toolCallId)}+ />+ )+ ) : (+ <Receipt+ key={item.toolCallId}+ item={item}+ undone={!!undone[item.toolCallId]}+ canUndo={undoable.includes(item.toolCallId)}+ onUndo={() => onUndo(item.toolCallId)}+ />+ );+ const rows = runsOf(items).flatMap((run) => {+ const first = run[0];+ const view = first?.card ? viewOf(first.card) : null;+ const Group = view?.Group;+ const Run = view?.Run;+ const body: ReactNode[] = [];+ for (let i = 0; i < run.length; i++) {+ let end = i;+ while (end < run.length && runnable(run[end] as ChangeItem, view)) end++;+ if (Run && end - i >= 2) {+ const taken = run.slice(i, end);+ if (!folded) {+ // A run that throws falls back to its rows one by one.+ body.push(+ <CardBoundary key={`run-${taken[0]?.toolCallId}`} fallback={taken.map(row)}>+ <Run items={taken} excluded={excluded} onToggle={onToggle} />+ </CardBoundary>+ );+ }+ i = end - 1;+ } else body.push(row(run[i] as ChangeItem));+ }+ if (!Group || !first) return body;+ const group = (place: 'head' | 'foot') => (+ <CardBoundary key={`${place}-${first.toolCallId}`}>+ <Group items={run} excluded={excluded} onToggle={onToggle} place={place} />+ </CardBoundary>+ );+ return [group('head'), ...body, group('foot')];+ });+ return <div>{rows}</div>;+}diff --git a/client/src/components/Assistant/cards/EntityActions.test.tsx b/client/src/components/Assistant/cards/EntityActions.test.tsxnew file mode 100644index 000000000..41f2b700a--- /dev/null+++ b/client/src/components/Assistant/cards/EntityActions.test.tsx@@ -0,0 +1,90 @@+/**+ * FE-AI-ENTITY-001 to FE-AI-ENTITY-004+ *+ * What a receipt offers for the thing it changed, read off the entity's+ * look: the map pin where the plan can show it, "Open" where it lives in+ * another part of TREK, and nothing where the shell cannot open anything.+ */+import type { AssistantApplied } from '@trek/shared';+import { describe, expect, it, vi } from 'vitest';++import { fireEvent, render, screen } from '../../../../tests/helpers/render';+import { type AssistantView, AssistantViewContext } from '../assistantViewContext';+import EntityActions from './EntityActions';++vi.mock('./cardLooks', async (importOriginal) => {+ const actual = await importOriginal<typeof import('./cardLooks')>();+ const looks = {+ ...actual.ENTITY_LOOK,+ tour: {+ ...actual.ENTITY_LOOK.tour,+ openLabelKey: 'assistant.change.viewOnMap',+ phoneOpenLabelKey: 'assistant.history.open',+ open: (applied: AssistantApplied) => ({+ kind: 'tab',+ tab: 'tour-planner',+ params: { tour: String(applied.ids[0]) },+ }),+ },+ budget: { ...actual.ENTITY_LOOK.budget, open: () => ({ kind: 'tab', tab: 'finanzplan' }) },+ };+ return { ...actual, ENTITY_LOOK: looks, entityLookOf: (entity: AssistantApplied['entity']) => looks[entity] };+});++const applied = (entity: AssistantApplied['entity'], ids: number[], dayId: number | null): AssistantApplied => ({+ toolCallId: 'c1',+ entity,+ ids,+ dayId,+ undoUntil: null,+});++function renderActions(change: AssistantApplied, view: Partial<AssistantView> = {}) {+ const value: AssistantView = { tripId: 4, variant: 'window', ...view };+ return render(+ <AssistantViewContext.Provider value={value}>+ <EntityActions applied={change} card={null} />+ </AssistantViewContext.Provider>+ );+}++describe('EntityActions', () => {+ it('FE-AI-ENTITY-001: a place shows itself on the map, a stop its day', () => {+ const onOpen = vi.fn();+ const first = renderActions(applied('place', [7], 2), { onOpen });+ fireEvent.click(screen.getByRole('button', { name: 'Show on map' }));+ expect(onOpen).toHaveBeenLastCalledWith({ kind: 'map', placeId: 7, dayId: null });+ first.unmount();++ renderActions(applied('assignment', [41], 3), { onOpen });+ fireEvent.click(screen.getByRole('button', { name: 'Show on map' }));+ expect(onOpen).toHaveBeenLastCalledWith({ kind: 'map', placeId: null, dayId: 3 });+ });++ it('FE-AI-ENTITY-002: nothing shows where the shell cannot open anything', () => {+ const { container } = renderActions(applied('place', [7], 2));+ expect(container).toBeEmptyDOMElement();+ });++ it('FE-AI-ENTITY-003: what has no place on the map gets no pin', () => {+ const { container } = renderActions(applied('packing', [2], null), { onOpen: vi.fn() });+ expect(container).toBeEmptyDOMElement();+ });++ it('FE-AI-ENTITY-004: "Open" goes where the entity lives, in its own words on the desktop and the phone', () => {+ const onOpen = vi.fn();+ const desktop = renderActions(applied('tour', [12], null), { onOpen });+ expect(screen.queryByRole('button', { name: 'Show on map' })).toBeNull();+ fireEvent.click(screen.getByRole('button', { name: 'View on map' }));+ expect(onOpen).toHaveBeenCalledWith({ kind: 'tab', tab: 'tour-planner', params: { tour: '12' } });+ desktop.unmount();++ const phone = renderActions(applied('tour', [12], null), { onOpen, variant: 'fullscreen' });+ expect(screen.getByRole('button', { name: 'Recent chats' })).toBeInTheDocument();+ phone.unmount();++ renderActions(applied('budget', [3], null), { onOpen });+ fireEvent.click(screen.getByRole('button', { name: 'Open' }));+ expect(onOpen).toHaveBeenLastCalledWith({ kind: 'tab', tab: 'finanzplan' });+ });+});diff --git a/client/src/components/Assistant/cards/EntityActions.tsx b/client/src/components/Assistant/cards/EntityActions.tsxnew file mode 100644index 000000000..0d0859098--- /dev/null+++ b/client/src/components/Assistant/cards/EntityActions.tsx@@ -0,0 +1,49 @@+import type { AssistantApplied, TrekCard } from '@trek/shared';+import { ArrowUpRight, MapPin } from 'lucide-react';++import { useTranslation } from '../../../i18n';+import { Tooltip } from '../../shared/Tooltip';+import { showOnMapTarget } from '../assistantShowOnMap';+import { useAssistantView } from '../assistantViewContext';+import { entityLookOf } from './cardLooks';+import { ICON_BUTTON } from './parts/assistantTones';++/**+ * What a receipt offers for the thing it changed, as its entity's look says:+ * the map pin where the plan's map can show it, and "Open" where it lives+ * somewhere else in TREK (a tab of the trip, another page). Neither shows+ * where the shell around the chat cannot open anything.+ */+export default function EntityActions({ applied, card }: { applied: AssistantApplied; card: TrekCard | null }) {+ const { t } = useTranslation();+ const { variant, onOpen } = useAssistantView();+ if (!onOpen) return null;+ const look = entityLookOf(applied.entity);+ const onMap = showOnMapTarget(applied, card);+ const open = look.open?.(applied, card) ?? null;+ const openKey = variant === 'fullscreen' ? (look.phoneOpenLabelKey ?? look.openLabelKey) : look.openLabelKey;+ const openLabel = openKey ? t(openKey) : t('assistant.card.common.open');+ return (+ <>+ {onMap && (+ <Tooltip label={t('assistant.change.showOnMap')} placement="top">+ <button+ type="button"+ onClick={() => onOpen({ kind: 'map', ...onMap })}+ aria-label={t('assistant.change.showOnMap')}+ className={ICON_BUTTON}+ >+ <MapPin size={14} aria-hidden="true" />+ </button>+ </Tooltip>+ )}+ {open && (+ <Tooltip label={openLabel} placement="top">+ <button type="button" onClick={() => onOpen(open)} aria-label={openLabel} className={ICON_BUTTON}>+ <ArrowUpRight size={14} aria-hidden="true" className="rtl:-scale-x-100" />+ </button>+ </Tooltip>+ )}+ </>+ );+}diff --git a/client/src/components/Assistant/cards/atlas/atlasLook.ts b/client/src/components/Assistant/cards/atlas/atlasLook.tsnew file mode 100644index 000000000..48494a346--- /dev/null+++ b/client/src/components/Assistant/cards/atlas/atlasLook.ts@@ -0,0 +1,20 @@+import type { PackLook } from '../cardTypes';++/**+ * What the atlas brings to the chat's pure look: the verbs, tool names and+ * steps it adds, what an applied change of its own opens, and the look of each+ * of its kinds. Empty until the atlas cards fill it. A look stays pure, icons+ * and literals only: the chat's main chunk reads every look, so whatever a look+ * imports ships with it.+ */+export const ATLAS_LOOK = {+ verbs: {},+ tools: {},+ steps: {},+ entities: {},+ cards: {+ atlasPassport: {},+ atlasCountry: {},+ atlasBucket: {},+ },+} satisfies PackLook<'atlasPassport' | 'atlasCountry' | 'atlasBucket'>;diff --git a/client/src/components/Assistant/cards/atlas/atlasViews.tsx b/client/src/components/Assistant/cards/atlas/atlasViews.tsxnew file mode 100644index 000000000..1d5551503--- /dev/null+++ b/client/src/components/Assistant/cards/atlas/atlasViews.tsx@@ -0,0 +1,14 @@+import { type CardView, PENDING_VIEW } from '../cardTypes';++/**+ * How the kinds of the atlas draw in the chat; each one draws nothing until its+ * cards are built. This file only maps each kind to its view: the components+ * live in sibling files, since a file that exports anything besides components+ * breaks fast refresh, and lint:warnings holds+ * react-refresh/only-export-components at zero for a new file.+ */+export const ATLAS_VIEWS = {+ atlasPassport: PENDING_VIEW,+ atlasCountry: PENDING_VIEW,+ atlasBucket: PENDING_VIEW,+} satisfies { [K in 'atlasPassport' | 'atlasCountry' | 'atlasBucket']: CardView<K> };diff --git a/client/src/components/Assistant/cards/booking/bookingLook.ts b/client/src/components/Assistant/cards/booking/bookingLook.tsnew file mode 100644index 000000000..a33104c6a--- /dev/null+++ b/client/src/components/Assistant/cards/booking/bookingLook.ts@@ -0,0 +1,23 @@+import { Ticket } from 'lucide-react';++import type { PackLook } from '../cardTypes';++/**+ * What the bookings bring to the chat's pure look: the verbs, tool names and+ * steps they add, what an applied change of theirs opens, and the look of each+ * of their kinds. Empty but for the booking entity until the booking cards fill+ * it. A look stays pure, icons and literals only: the chat's main chunk reads+ * every look, so whatever a look imports ships with it.+ */+export const BOOKING_LOOK = {+ verbs: {},+ tools: {},+ steps: {},+ entities: {+ // An applied booking shows on the map by its day, as before.+ reservation: { Icon: Ticket, onMap: (applied) => ({ placeId: null, dayId: applied.dayId }) },+ },+ cards: {+ booking: {},+ },+} satisfies PackLook<'booking'>;diff --git a/client/src/components/Assistant/cards/booking/bookingViews.tsx b/client/src/components/Assistant/cards/booking/bookingViews.tsxnew file mode 100644index 000000000..71feb9647--- /dev/null+++ b/client/src/components/Assistant/cards/booking/bookingViews.tsx@@ -0,0 +1,12 @@+import { type CardView, PENDING_VIEW } from '../cardTypes';++/**+ * How the kinds of the bookings draw in the chat; each one draws nothing until+ * its cards are built. This file only maps each kind to its view: the+ * components live in sibling files, since a file that exports anything besides+ * components breaks fast refresh, and lint:warnings holds+ * react-refresh/only-export-components at zero for a new file.+ */+export const BOOKING_VIEWS = {+ booking: PENDING_VIEW,+} satisfies { [K in 'booking']: CardView<K> };diff --git a/client/src/components/Assistant/cards/budget/budgetLook.ts b/client/src/components/Assistant/cards/budget/budgetLook.tsnew file mode 100644index 000000000..ad2670127--- /dev/null+++ b/client/src/components/Assistant/cards/budget/budgetLook.ts@@ -0,0 +1,25 @@+import { Wallet } from 'lucide-react';++import type { PackLook } from '../cardTypes';++/**+ * What the costs bring to the chat's pure look: the verbs, tool names and steps+ * they add, what an applied change of theirs opens, and the look of each of+ * their kinds. An applied expense has no way to open yet, as before. A look+ * stays pure, icons and literals only: the chat's main chunk reads every look,+ * so whatever a look imports ships with it.+ */+export const BUDGET_LOOK = {+ verbs: {},+ tools: {},+ steps: {},+ entities: {+ budget: { Icon: Wallet },+ },+ cards: {+ expenses: {},+ payments: {},+ settlement: {},+ costPerPerson: {},+ },+} satisfies PackLook<'expenses' | 'payments' | 'settlement' | 'costPerPerson'>;diff --git a/client/src/components/Assistant/cards/budget/budgetViews.tsx b/client/src/components/Assistant/cards/budget/budgetViews.tsxnew file mode 100644index 000000000..ac9d5c05f--- /dev/null+++ b/client/src/components/Assistant/cards/budget/budgetViews.tsx@@ -0,0 +1,15 @@+import { type CardView, PENDING_VIEW } from '../cardTypes';++/**+ * How the kinds of the costs draw in the chat; each one draws nothing until its+ * cards are built. This file only maps each kind to its view: the components+ * live in sibling files, since a file that exports anything besides components+ * breaks fast refresh, and lint:warnings holds+ * react-refresh/only-export-components at zero for a new file.+ */+export const BUDGET_VIEWS = {+ expenses: PENDING_VIEW,+ payments: PENDING_VIEW,+ settlement: PENDING_VIEW,+ costPerPerson: PENDING_VIEW,+} satisfies { [K in 'expenses' | 'payments' | 'settlement' | 'costPerPerson']: CardView<K> };diff --git a/client/src/components/Assistant/cards/cardLooks.test.ts b/client/src/components/Assistant/cards/cardLooks.test.tsnew file mode 100644index 000000000..67d0b0bf8--- /dev/null+++ b/client/src/components/Assistant/cards/cardLooks.test.ts@@ -0,0 +1,102 @@+/**+ * FE-AI-LOOK-001 to FE-AI-LOOK-007+ *+ * The chat's merged look: every verb, tool and kind has its row with a+ * literal key, applied changes open what they opened before the cards came,+ * every kind has a view, the shapes the map hooks of a kind fill, the+ * layout and map sides read through each kind's look, and a verb or entity+ * this build does not know looks like its generic one.+ */+import {+ ASSISTANT_CHANGE_VERB_KEYS,+ type AssistantApplied,+ type AssistantChangeVerbKey,+ type TrekCardKind,+ trekCardSchema,+} from '@trek/shared';+import { describe, expect, it } from 'vitest';++import type { GhostPoint, RouteLineSpec, RouteUse } from '../../../types/assistantMap';+import {+ CARD_LOOKS,+ CARD_MAP_LOOK,+ CARD_RULES,+ ENTITY_LOOK,+ STEP_LOOKS,+ TOOL_LABELS,+ VERB_LOOK,+ entityLookOf,+ verbLookOf,+} from './cardLooks';+import type { CardLook } from './cardTypes';+import { CARD_VIEWS } from './cardViews';++const KINDS = trekCardSchema.options.map((option) => option.shape.kind.value) as TrekCardKind[];++describe('cardLooks', () => {+ it('FE-AI-LOOK-001: every verb is named by its own key', () => {+ for (const verb of ASSISTANT_CHANGE_VERB_KEYS) {+ expect(VERB_LOOK[verb].labelKey).toBe(`assistant.change.verb.${verb}`);+ }+ });++ it('FE-AI-LOOK-002: every tool label and step is a key of its own namespace', () => {+ for (const [tool, look] of Object.entries(TOOL_LABELS)) expect(look?.labelKey).toBe(`assistant.tool.${tool}`);+ for (const look of Object.values(STEP_LOOKS)) expect(look?.stepKey).toMatch(/^assistant\.step\./);+ expect(STEP_LOOKS.get_trip_summary?.stepKey).toBe('assistant.step.reading');+ });++ it('FE-AI-LOOK-003: only a place, a stop, a note and a booking show on the map, as before the cards', () => {+ const onMap = Object.entries(ENTITY_LOOK).flatMap(([entity, look]) => (look.onMap ? [entity] : []));+ expect(onMap.sort()).toEqual(['assignment', 'day_note', 'place', 'reservation']);+ expect(Object.values(ENTITY_LOOK).every((look) => !look.open)).toBe(true);+ });++ it('FE-AI-LOOK-004: every kind has a look and a view; a pending view groups by kind and gives way to nothing', () => {+ expect(Object.keys(CARD_LOOKS).sort()).toEqual([...KINDS].sort());+ expect(Object.keys(CARD_VIEWS).sort()).toEqual([...KINDS].sort());+ expect(CARD_RULES.group({ kind: 'vacay' })).toBe('vacay');+ expect(CARD_RULES.yieldsToChange({ kind: 'expenses' }, { kind: 'payments' })).toBe(false);+ });++ it('FE-AI-LOOK-005: a kind draws its lines and points on the map through its look', () => {+ const look: CardLook<'dayRoute'> = {+ lines: (_card, use: RouteUse): RouteLineSpec[] => [+ { id: `day:${use}`, lines: [[[45.1, 7.2]]], color: 'var(--accent)', dashed: use !== 'pending' },+ ],+ ghosts: (): GhostPoint[] => [{ id: 'via', lat: 45.1, lng: 7.2, name: 'Col', variant: 'point' }],+ };+ expect(look.lines?.({ kind: 'dayRoute' }, 'before')).toEqual([+ { id: 'day:before', lines: [[[45.1, 7.2]]], color: 'var(--accent)', dashed: true },+ ]);+ expect(look.ghosts?.({ kind: 'dayRoute' })[0]?.variant).toBe('point');+ });++ it("FE-AI-LOOK-006: the layout rules and the map read a kind's look, nothing for one that says nothing", () => {+ const route = CARD_LOOKS.dayRoute;+ route.group = () => 'routes';+ route.yieldsToChange = (_answer, change) => change.kind === 'dayRoute';+ route.lines = (_card, use) => [{ id: `day:${use}`, lines: [], color: 'var(--accent)' }];+ try {+ expect(CARD_RULES.group({ kind: 'dayRoute' })).toBe('routes');+ expect(CARD_RULES.yieldsToChange({ kind: 'dayRoute' }, { kind: 'dayRoute' })).toBe(true);+ expect(CARD_MAP_LOOK.lines({ kind: 'dayRoute' }, 'look')).toEqual([+ { id: 'day:look', lines: [], color: 'var(--accent)' },+ ]);+ } finally {+ delete route.group;+ delete route.yieldsToChange;+ delete route.lines;+ }+ expect(CARD_MAP_LOOK.lines({ kind: 'dayRoute' }, 'look')).toEqual([]);+ expect(CARD_MAP_LOOK.ghosts({ kind: 'vacay' })).toEqual([]);+ expect(CARD_MAP_LOOK.hidesEffectGhost({ kind: 'vacay' })).toBe(false);+ });++ it('FE-AI-LOOK-007: a verb or entity only a newer server knows looks like a plain update or an other', () => {+ expect(verbLookOf('laterVerb' as AssistantChangeVerbKey)).toBe(VERB_LOOK.genericUpdate);+ expect(entityLookOf('later_entity' as AssistantApplied['entity'])).toBe(ENTITY_LOOK.other);+ expect(verbLookOf('addPlace')).toBe(VERB_LOOK.addPlace);+ expect(entityLookOf('place')).toBe(ENTITY_LOOK.place);+ });+});diff --git a/client/src/components/Assistant/cards/cardLooks.ts b/client/src/components/Assistant/cards/cardLooks.tsnew file mode 100644index 000000000..749e52af7--- /dev/null+++ b/client/src/components/Assistant/cards/cardLooks.ts@@ -0,0 +1,248 @@+import type { AssistantApplied, AssistantChangeVerbKey, TrekCard, TrekCardKind } from '@trek/shared';+import {+ CalendarArrowUp,+ CalendarDays,+ CalendarMinus,+ CalendarPlus,+ Circle,+ ListTodo,+ Luggage,+ MapPin,+ MapPinPlus,+ NotebookPen,+ PencilLine,+ Plus,+ StickyNote,+ Ticket,+ Trash2,+ Wallet,+} from 'lucide-react';++import type { CardMapLook } from '../../../types/assistantMap';+import type { CardRules } from '../assistantParts';+import { ATLAS_LOOK } from './atlas/atlasLook';+import { BOOKING_LOOK } from './booking/bookingLook';+import { BUDGET_LOOK } from './budget/budgetLook';+import type { CardLook, EntityLook, StepLook, VerbLook } from './cardTypes';+import { COLLAB_LOOK } from './collab/collabLook';+import { COLLECTION_LOOK } from './collection/collectionLook';+import { JOURNEY_LOOK } from './journey/journeyLook';+import { PACKING_LOOK } from './packing/packingLook';+import { ROADTRIP_LOOK } from './roadtrip/roadtripLook';+import { TOUR_LOOK } from './tour/tourLook';+import { VACAY_LOOK } from './vacay/vacayLook';++/**+ * The chat's whole pure look: the core rows (the trip plan's verbs, the tools+ * TREK names an action for, the reading steps, what an applied change opens)+ * with every part of TREK's own look merged in. No components here, so the+ * step names, the share text and the map read it without pulling in a card.+ *+ * Every label is a literal key, so the i18n check sees each one where it is+ * named instead of guessing at a template.+ */++/** What each kind of change looks like. A table, so a new verb fails to compile until it has a look. */+export const VERB_LOOK: Readonly<Record<AssistantChangeVerbKey, VerbLook>> = {+ addPlace: { Icon: MapPinPlus, tone: 'success', labelKey: 'assistant.change.verb.addPlace' },+ addPlaceToDay: { Icon: CalendarPlus, tone: 'success', labelKey: 'assistant.change.verb.addPlaceToDay' },+ updatePlace: { Icon: PencilLine, tone: 'info', labelKey: 'assistant.change.verb.updatePlace' },+ assignPlace: { Icon: CalendarPlus, tone: 'success', labelKey: 'assistant.change.verb.assignPlace' },+ moveAssignment: { Icon: CalendarArrowUp, tone: 'warning', labelKey: 'assistant.change.verb.moveAssignment' },+ removeFromDay: { Icon: CalendarMinus, tone: 'danger', labelKey: 'assistant.change.verb.removeFromDay' },+ addDayNote: { Icon: StickyNote, tone: 'success', labelKey: 'assistant.change.verb.addDayNote' },+ updateDayNote: { Icon: StickyNote, tone: 'info', labelKey: 'assistant.change.verb.updateDayNote' },+ addPackingItem: { Icon: Luggage, tone: 'success', labelKey: 'assistant.change.verb.addPackingItem' },+ updatePackingItem: { Icon: Luggage, tone: 'info', labelKey: 'assistant.change.verb.updatePackingItem' },+ addTodo: { Icon: ListTodo, tone: 'success', labelKey: 'assistant.change.verb.addTodo' },+ addBudgetItem: { Icon: Wallet, tone: 'success', labelKey: 'assistant.change.verb.addBudgetItem' },+ updateBudgetItem: { Icon: Wallet, tone: 'info', labelKey: 'assistant.change.verb.updateBudgetItem' },+ addReservation: { Icon: Ticket, tone: 'success', labelKey: 'assistant.change.verb.addReservation' },+ importBooking: { Icon: Ticket, tone: 'success', labelKey: 'assistant.change.verb.importBooking' },+ rememberNote: { Icon: NotebookPen, tone: 'info', labelKey: 'assistant.change.verb.rememberNote' },+ addTour: { Icon: MapPinPlus, tone: 'success', labelKey: 'assistant.change.verb.addTour' },+ updateTour: { Icon: PencilLine, tone: 'info', labelKey: 'assistant.change.verb.updateTour' },+ importTour: { Icon: Plus, tone: 'success', labelKey: 'assistant.change.verb.importTour' },+ genericCreate: { Icon: Plus, tone: 'success', labelKey: 'assistant.change.verb.genericCreate' },+ genericUpdate: { Icon: PencilLine, tone: 'info', labelKey: 'assistant.change.verb.genericUpdate' },+ genericRemove: { Icon: Trash2, tone: 'danger', labelKey: 'assistant.change.verb.genericRemove' },+ ...TOUR_LOOK.verbs,+ ...ROADTRIP_LOOK.verbs,+ ...BUDGET_LOOK.verbs,+ ...BOOKING_LOOK.verbs,+ ...COLLAB_LOOK.verbs,+ ...COLLECTION_LOOK.verbs,+ ...ATLAS_LOOK.verbs,+ ...VACAY_LOOK.verbs,+ ...JOURNEY_LOOK.verbs,+ ...PACKING_LOOK.verbs,+};++/** The tools TREK names an action of their own for; a change by any other tool is named by its verb. */+export const TOOL_LABELS: Readonly<Partial<Record<string, { labelKey: string }>>> = {+ reorder_day_assignments: { labelKey: 'assistant.tool.reorder_day_assignments' },+ update_assignment_time: { labelKey: 'assistant.tool.update_assignment_time' },+ update_assignment_notes: { labelKey: 'assistant.tool.update_assignment_notes' },+ set_leg_transport_mode: { labelKey: 'assistant.tool.set_leg_transport_mode' },+ set_assignment_end_day: { labelKey: 'assistant.tool.set_assignment_end_day' },+ clear_day_assignments: { labelKey: 'assistant.tool.clear_day_assignments' },+ set_assignment_participants: { labelKey: 'assistant.tool.set_assignment_participants' },+ create_day: { labelKey: 'assistant.tool.create_day' },+ update_day: { labelKey: 'assistant.tool.update_day' },+ delete_day: { labelKey: 'assistant.tool.delete_day' },+ reorder_days: { labelKey: 'assistant.tool.reorder_days' },+ delete_place: { labelKey: 'assistant.tool.delete_place' },+ rate_place: { labelKey: 'assistant.tool.rate_place' },+ bulk_update_places: { labelKey: 'assistant.tool.bulk_update_places' },+ delete_day_note: { labelKey: 'assistant.tool.delete_day_note' },+ toggle_packing_item: { labelKey: 'assistant.tool.toggle_packing_item' },+ delete_packing_item: { labelKey: 'assistant.tool.delete_packing_item' },+ update_todo: { labelKey: 'assistant.tool.update_todo' },+ toggle_todo: { labelKey: 'assistant.tool.toggle_todo' },+ delete_todo: { labelKey: 'assistant.tool.delete_todo' },+ delete_budget_item: { labelKey: 'assistant.tool.delete_budget_item' },+ update_reservation: { labelKey: 'assistant.tool.update_reservation' },+ delete_reservation: { labelKey: 'assistant.tool.delete_reservation' },+ create_accommodation: { labelKey: 'assistant.tool.create_accommodation' },+ create_transport: { labelKey: 'assistant.tool.create_transport' },+ toggle_vacay_entry: { labelKey: 'assistant.tool.toggle_vacay_entry' },+ mark_country_visited: { labelKey: 'assistant.tool.mark_country_visited' },+ confirm_bucket_list_visits: { labelKey: 'assistant.tool.confirm_bucket_list_visits' },+ clear_bucket_list_visit: { labelKey: 'assistant.tool.clear_bucket_list_visit' },+ accept_atlas_countries: { labelKey: 'assistant.tool.accept_atlas_countries' },+ send_collab_message: { labelKey: 'assistant.tool.send_collab_message' },+ ...TOUR_LOOK.tools,+ ...ROADTRIP_LOOK.tools,+ ...BUDGET_LOOK.tools,+ ...BOOKING_LOOK.tools,+ ...COLLAB_LOOK.tools,+ ...COLLECTION_LOOK.tools,+ ...ATLAS_LOOK.tools,+ ...VACAY_LOOK.tools,+ ...JOURNEY_LOOK.tools,+ ...PACKING_LOOK.tools,+};++/** How each reading tool is named while it runs; a tool not listed reads "Working on it". */+export const STEP_LOOKS: Readonly<Partial<Record<string, StepLook>>> = {+ get_trip_summary: { stepKey: 'assistant.step.reading' },+ list_places: { stepKey: 'assistant.step.reading' },+ search_place: {+ stepKey: 'assistant.step.searching',+ live: { liveKey: 'assistant.step.searchingFor', param: 'query' },+ },+ search_pois: { stepKey: 'assistant.step.searching', live: { liveKey: 'assistant.step.nearbyAt', param: 'place' } },+ get_place_details: { stepKey: 'assistant.step.details' },+ search_nearby_places: {+ stepKey: 'assistant.step.nearby',+ live: { liveKey: 'assistant.step.nearbyAt', param: 'place' },+ },+ list_categories: { stepKey: 'assistant.step.categories' },+ get_weather: { stepKey: 'assistant.step.weather', live: { liveKey: 'assistant.step.weatherAt', param: 'place' } },+ list_todos: { stepKey: 'assistant.step.todos' },+ get_settlement_summary: { stepKey: 'assistant.step.costs' },+ list_budget_items: { stepKey: 'assistant.step.expenses' },+ get_budget_per_person: { stepKey: 'assistant.step.shares' },+ get_wind_forecast: { stepKey: 'assistant.step.wind' },+ get_journey_tracks: { stepKey: 'assistant.step.tracks' },+ scan_bucket_list_visits: { stepKey: 'assistant.step.bucketScan' },+ suggest_atlas_countries: { stepKey: 'assistant.step.atlasCountries' },+ propose_hike: {+ stepKey: 'assistant.step.planningHike',+ live: { liveKey: 'assistant.step.planningHikeTo', param: 'place' },+ },+ search_help: { stepKey: 'assistant.step.help' },+ read_booking_file: { stepKey: 'assistant.step.readingBooking' },+ ...TOUR_LOOK.steps,+ ...ROADTRIP_LOOK.steps,+ ...BUDGET_LOOK.steps,+ ...BOOKING_LOOK.steps,+ ...COLLAB_LOOK.steps,+ ...COLLECTION_LOOK.steps,+ ...ATLAS_LOOK.steps,+ ...VACAY_LOOK.steps,+ ...JOURNEY_LOOK.steps,+ ...PACKING_LOOK.steps,+};++/** Shown on the map by its day: a stop or a note lives on one. */+const BY_DAY: EntityLook['onMap'] = (applied) => ({ placeId: null, dayId: applied.dayId });++/**+ * What an applied change touches and where it can be seen. A place shows+ * itself, a stop or a note its day; a kept note and the rest have no place on+ * the map. A table, so a new entity fails to compile until it has a row.+ */+export const ENTITY_LOOK: Readonly<Record<AssistantApplied['entity'], EntityLook>> = {+ place: {+ Icon: MapPin,+ onMap: (applied) => {+ const placeId = applied.ids[0] ?? null;+ return { placeId, dayId: placeId === null ? applied.dayId : null };+ },+ },+ assignment: { Icon: CalendarDays, onMap: BY_DAY },+ day_note: { Icon: StickyNote, onMap: BY_DAY },+ memory: { Icon: NotebookPen },+ other: { Icon: Circle },+ ...TOUR_LOOK.entities,+ ...ROADTRIP_LOOK.entities,+ ...BUDGET_LOOK.entities,+ ...BOOKING_LOOK.entities,+ ...COLLAB_LOOK.entities,+ ...COLLECTION_LOOK.entities,+ ...ATLAS_LOOK.entities,+ ...VACAY_LOOK.entities,+ ...JOURNEY_LOOK.entities,+ ...PACKING_LOOK.entities,+};++/**+ * The look of a verb or an entity as a stored or streamed change names it. A+ * newer server may name one this build has no row for (the shared schema+ * reads it as `genericUpdate` or `other`, but an older one did not), so an+ * unknown name looks like a plain update or a thing with nothing to open.+ */+export function verbLookOf(verbKey: AssistantChangeVerbKey): VerbLook {+ return VERB_LOOK[verbKey] ?? VERB_LOOK.genericUpdate;+}++export function entityLookOf(entity: AssistantApplied['entity']): EntityLook {+ return ENTITY_LOOK[entity] ?? ENTITY_LOOK.other;+}++/** The pure look of every kind of card. */+export const CARD_LOOKS: { readonly [K in TrekCardKind]: CardLook<K> } = {+ ...TOUR_LOOK.cards,+ ...ROADTRIP_LOOK.cards,+ ...BUDGET_LOOK.cards,+ ...BOOKING_LOOK.cards,+ ...COLLAB_LOOK.cards,+ ...COLLECTION_LOOK.cards,+ ...ATLAS_LOOK.cards,+ ...VACAY_LOOK.cards,+ ...JOURNEY_LOOK.cards,+ ...PACKING_LOOK.cards,+};++/** The look of the card in hand, typed for any kind. */+function lookOf(card: TrekCard): CardLook<TrekCardKind> {+ return CARD_LOOKS[card.kind] as CardLook<TrekCardKind>;+}++/**+ * How an answer lays its cards out: the group each joins, and which ones give+ * way to a change they served. The chat, the phone, the follow-ups and the+ * share text all read these, so none of them groups a card differently.+ */+export const CARD_RULES: CardRules = {+ group: (card) => lookOf(card).group?.(card) ?? card.kind,+ yieldsToChange: (answer, change) => lookOf(answer).yieldsToChange?.(answer, change) ?? false,+};++/** What the plan's map draws for a card through its kind's look; nothing for a kind that draws nothing. */+export const CARD_MAP_LOOK: CardMapLook = {+ lines: (card, use) => lookOf(card).lines?.(card, use) ?? [],+ ghosts: (card) => lookOf(card).ghosts?.(card) ?? [],+ hidesEffectGhost: (card) => lookOf(card).hidesEffectGhost?.(card) ?? false,+};diff --git a/client/src/components/Assistant/cards/cardTypes.ts b/client/src/components/Assistant/cards/cardTypes.tsnew file mode 100644index 000000000..80a52135f--- /dev/null+++ b/client/src/components/Assistant/cards/cardTypes.ts@@ -0,0 +1,121 @@+import type {+ AssistantApplied,+ AssistantChangeVerbKey,+ AssistantMessage,+ TrekCard,+ TrekCardKind,+ TrekCardOf,+} from '@trek/shared';+import type { LucideIcon } from 'lucide-react';+import type { ComponentType } from 'react';++import type { TripTabId } from '../../../constants/tripTabs';+import type { GhostPoint, RouteLineSpec, RouteUse } from '../../../types/assistantMap';+import type { FollowUp } from '../assistantFollowUpRules';+import type { ChangeItem } from '../assistantParts';+import type { Tone } from './parts/assistantTones';++/**+ * The shapes every part of TREK fills to bring its cards into the chat. A+ * part writes a pure look (`<pkg>Look.ts`: verbs, tool names, steps, what an+ * applied change opens, follow-ups, map lines) and its views+ * (`<pkg>Views.tsx`: the components); `cardLooks.ts` and `cardViews.ts` merge+ * them, and a table that misses a kind, a verb or an entity fails to compile.+ */++/** How a kind of change looks: its icon, its tone and the name of what it does. */+export interface VerbLook {+ Icon: LucideIcon;+ tone: Tone;+ labelKey: string;+}++/** `liveKey` names the step with the place or query it is at, `param` is the word that fills it. */+export interface StepLook {+ stepKey: string;+ live?: { liveKey: string; param: 'place' | 'query' };+}++/** Where a card or an applied change takes the user: a spot on the plan's map, a tab of the trip, another page. */+export type EntityTarget =+ | { kind: 'map'; placeId: number | null; dayId: number | null }+ | { kind: 'tab'; tab: TripTabId; sub?: string; params?: Record<string, string> }+ | { kind: 'page'; path: string };++/** What an applied change touches, and where it can be seen afterwards. */+export interface EntityLook {+ Icon: LucideIcon;+ openLabelKey?: string;+ phoneOpenLabelKey?: string;+ onMap?(applied: AssistantApplied, card: TrekCard | null): { placeId: number | null; dayId: number | null } | null;+ open?(applied: AssistantApplied, card: TrekCard | null): EntityTarget | null;+}++/**+ * The pure side of one kind: what it touches, what to ask next, how an answer+ * lays it out, and what the map draws for it (see types/assistantMap.ts). Pure,+ * so the chat, the follow-ups, the share text and the map read one layout.+ */+export interface CardLook<K extends TrekCardKind> {+ entity?(card: TrekCardOf<K>): AssistantApplied['entity'];+ followUps?: readonly FollowUp[];+ /** The group an answer card joins; the kind when left out. */+ group?(card: TrekCardOf<K>): string;+ /** Drops a lookup card next to the change it served. */+ yieldsToChange?(answer: TrekCardOf<K>, change: TrekCard): boolean;+ lines?(card: TrekCardOf<K>, use: RouteUse): RouteLineSpec[];+ ghosts?(card: TrekCardOf<K>): GhostPoint[];+ hidesEffectGhost?(card: TrekCardOf<K>): boolean;+}++/** One part of TREK's pure look, for the kinds `K` it owns. */+export interface PackLook<K extends TrekCardKind> {+ verbs: Partial<Record<AssistantChangeVerbKey, VerbLook>>;+ tools: Readonly<Record<string, { labelKey: string }>>;+ steps: Readonly<Record<string, StepLook>>;+ entities: Partial<Record<AssistantApplied['entity'], EntityLook>>;+ cards: { [P in K]: CardLook<P> };+}++/** One card of an answer, under the tool call it came from. */+export interface CardEntry {+ toolCallId: string;+ card: TrekCard;+}++/** What a change row's slot gets: the row's card and the row itself. */+interface CardSlotProps<K extends TrekCardKind> {+ card: TrekCardOf<K>;+ item: ChangeItem;+}++/** A run of change rows a view draws together. */+interface CardRunProps {+ items: readonly ChangeItem[];+ excluded: ReadonlySet<string>;+ onToggle(id: string): void;+}++/**+ * How one kind draws. `Block` draws a group of answer cards (grouped by the+ * kind's look); the slots fill a change row (`Lead` in front, `Aside` at the+ * end of the subject line, `Facts` on the faint line, `Body` under it);+ * `Group` heads or closes a run of rows of the kind, `Run` replaces two or+ * more waiting rows that can be decided as one. Every member is optional: an+ * empty view draws nothing, and one that throws draws its fallback instead.+ */+export interface CardView<K extends TrekCardKind> {+ Block?: ComponentType<{ cards: readonly CardEntry[]; message: AssistantMessage }>;+ Lead?: ComponentType<CardSlotProps<K>>;+ Aside?: ComponentType<CardSlotProps<K>>;+ Facts?: ComponentType<CardSlotProps<K>>;+ Body?: ComponentType<CardSlotProps<K>>;+ ownsSubject?: boolean;+ Group?: ComponentType<CardRunProps & { place: 'head' | 'foot' }>;+ Run?: ComponentType<CardRunProps>;+ runnable?(card: TrekCardOf<K>): boolean;+ startsExcluded?(card: TrekCardOf<K>): boolean;+}++/** The view of a kind not drawn yet: it renders nothing, so its cards are left out until a package fills it. */+export const PENDING_VIEW = {} satisfies CardView<TrekCardKind>;diff --git a/client/src/components/Assistant/cards/cardViews.ts b/client/src/components/Assistant/cards/cardViews.tsnew file mode 100644index 000000000..039e704e0--- /dev/null+++ b/client/src/components/Assistant/cards/cardViews.ts@@ -0,0 +1,37 @@+import type { TrekCard, TrekCardKind } from '@trek/shared';++import { ATLAS_VIEWS } from './atlas/atlasViews';+import { BOOKING_VIEWS } from './booking/bookingViews';+import { BUDGET_VIEWS } from './budget/budgetViews';+import type { CardView } from './cardTypes';+import { COLLAB_VIEWS } from './collab/collabViews';+import { COLLECTION_VIEWS } from './collection/collectionViews';+import { JOURNEY_VIEWS } from './journey/journeyViews';+import { PACKING_VIEWS } from './packing/packingViews';+import { ROADTRIP_VIEWS } from './roadtrip/roadtripViews';+import { TOUR_VIEWS } from './tour/tourViews';+import { VACAY_VIEWS } from './vacay/vacayViews';++/**+ * How every kind of card draws, merged from each part of TREK's views. A kind+ * without a view of its own yet has the pending one and draws nothing. This+ * module pulls in the card components, so only the chat's own chunk imports+ * it; the pure helpers, the layout rules among them, read the look instead.+ */+export const CARD_VIEWS: { readonly [K in TrekCardKind]: CardView<K> } = {+ ...TOUR_VIEWS,+ ...ROADTRIP_VIEWS,+ ...BUDGET_VIEWS,+ ...BOOKING_VIEWS,+ ...COLLAB_VIEWS,+ ...COLLECTION_VIEWS,+ ...ATLAS_VIEWS,+ ...VACAY_VIEWS,+ ...JOURNEY_VIEWS,+ ...PACKING_VIEWS,+};++/** The view of the card in hand, typed for any kind. */+export function viewOf(card: TrekCard): CardView<TrekCardKind> {+ return CARD_VIEWS[card.kind] as CardView<TrekCardKind>;+}diff --git a/client/src/components/Assistant/cards/collab/collabLook.ts b/client/src/components/Assistant/cards/collab/collabLook.tsnew file mode 100644index 000000000..af78e47ca--- /dev/null+++ b/client/src/components/Assistant/cards/collab/collabLook.ts@@ -0,0 +1,20 @@+import type { PackLook } from '../cardTypes';++/**+ * What the trip chat, polls and notes bring to the chat's pure look: the verbs,+ * tool names and steps they add, what an applied change of theirs opens, and+ * the look of each of their kinds. Empty until the collab cards fill it. A look+ * stays pure, icons and literals only: the chat's main chunk reads every look,+ * so whatever a look imports ships with it.+ */+export const COLLAB_LOOK = {+ verbs: {},+ tools: {},+ steps: {},+ entities: {},+ cards: {+ collabChat: {},+ collabPolls: {},+ collabNotes: {},+ },+} satisfies PackLook<'collabChat' | 'collabPolls' | 'collabNotes'>;diff --git a/client/src/components/Assistant/cards/collab/collabViews.tsx b/client/src/components/Assistant/cards/collab/collabViews.tsxnew file mode 100644index 000000000..e4619d8d0--- /dev/null+++ b/client/src/components/Assistant/cards/collab/collabViews.tsx@@ -0,0 +1,14 @@+import { type CardView, PENDING_VIEW } from '../cardTypes';++/**+ * How the kinds of the trip chat, polls and notes draw in the chat; each one+ * draws nothing until its cards are built. This file only maps each kind to its+ * view: the components live in sibling files, since a file that exports+ * anything besides components breaks fast refresh, and lint:warnings holds+ * react-refresh/only-export-components at zero for a new file.+ */+export const COLLAB_VIEWS = {+ collabChat: PENDING_VIEW,+ collabPolls: PENDING_VIEW,+ collabNotes: PENDING_VIEW,+} satisfies { [K in 'collabChat' | 'collabPolls' | 'collabNotes']: CardView<K> };diff --git a/client/src/components/Assistant/cards/collection/collectionLook.ts b/client/src/components/Assistant/cards/collection/collectionLook.tsnew file mode 100644index 000000000..41b814d53--- /dev/null+++ b/client/src/components/Assistant/cards/collection/collectionLook.ts@@ -0,0 +1,19 @@+import type { PackLook } from '../cardTypes';++/**+ * What the collections bring to the chat's pure look: the verbs, tool names and+ * steps they add, what an applied change of theirs opens, and the look of each+ * of their kinds. Empty until the collections cards fill it. A look stays pure,+ * icons and literals only: the chat's main chunk reads every look, so whatever+ * a look imports ships with it.+ */+export const COLLECTION_LOOK = {+ verbs: {},+ tools: {},+ steps: {},+ entities: {},+ cards: {+ collectionPlaces: {},+ collectionLists: {},+ },+} satisfies PackLook<'collectionPlaces' | 'collectionLists'>;diff --git a/client/src/components/Assistant/cards/collection/collectionViews.tsx b/client/src/components/Assistant/cards/collection/collectionViews.tsxnew file mode 100644index 000000000..5e9d34593--- /dev/null+++ b/client/src/components/Assistant/cards/collection/collectionViews.tsx@@ -0,0 +1,13 @@+import { type CardView, PENDING_VIEW } from '../cardTypes';++/**+ * How the kinds of the collections draw in the chat; each one draws nothing+ * until its cards are built. This file only maps each kind to its view: the+ * components live in sibling files, since a file that exports anything besides+ * components breaks fast refresh, and lint:warnings holds+ * react-refresh/only-export-components at zero for a new file.+ */+export const COLLECTION_VIEWS = {+ collectionPlaces: PENDING_VIEW,+ collectionLists: PENDING_VIEW,+} satisfies { [K in 'collectionPlaces' | 'collectionLists']: CardView<K> };diff --git a/client/src/components/Assistant/cards/journey/journeyLook.ts b/client/src/components/Assistant/cards/journey/journeyLook.tsnew file mode 100644index 000000000..928a58c50--- /dev/null+++ b/client/src/components/Assistant/cards/journey/journeyLook.ts@@ -0,0 +1,18 @@+import type { PackLook } from '../cardTypes';++/**+ * What the journeys bring to the chat's pure look: the verbs, tool names and+ * steps they add, what an applied change of theirs opens, and the look of each+ * of their kinds. Empty until the journey cards fill it. A look stays pure,+ * icons and literals only: the chat's main chunk reads every look, so whatever+ * a look imports ships with it.+ */+export const JOURNEY_LOOK = {+ verbs: {},+ tools: {},+ steps: {},+ entities: {},+ cards: {+ journeyEntries: {},+ },+} satisfies PackLook<'journeyEntries'>;diff --git a/client/src/components/Assistant/cards/journey/journeyViews.tsx b/client/src/components/Assistant/cards/journey/journeyViews.tsxnew file mode 100644index 000000000..c6641bc97--- /dev/null+++ b/client/src/components/Assistant/cards/journey/journeyViews.tsx@@ -0,0 +1,12 @@+import { type CardView, PENDING_VIEW } from '../cardTypes';++/**+ * How the kinds of the journeys draw in the chat; each one draws nothing until+ * its cards are built. This file only maps each kind to its view: the+ * components live in sibling files, since a file that exports anything besides+ * components breaks fast refresh, and lint:warnings holds+ * react-refresh/only-export-components at zero for a new file.+ */+export const JOURNEY_VIEWS = {+ journeyEntries: PENDING_VIEW,+} satisfies { [K in 'journeyEntries']: CardView<K> };diff --git a/client/src/components/Assistant/cards/packing/packingLook.ts b/client/src/components/Assistant/cards/packing/packingLook.tsnew file mode 100644index 000000000..b22119208--- /dev/null+++ b/client/src/components/Assistant/cards/packing/packingLook.ts@@ -0,0 +1,24 @@+import { ListTodo, Luggage } from 'lucide-react';++import type { PackLook } from '../cardTypes';++/**+ * What the packing lists and to-dos bring to the chat's pure look: the verbs,+ * tool names and steps they add, what an applied change of theirs opens, and+ * the look of each of their kinds. Applied items have no way to open yet, as+ * before. A look stays pure, icons and literals only: the chat's main chunk+ * reads every look, so whatever a look imports ships with it.+ */+export const PACKING_LOOK = {+ verbs: {},+ tools: {},+ steps: {},+ entities: {+ packing: { Icon: Luggage },+ todo: { Icon: ListTodo },+ },+ cards: {+ packingList: {},+ todoList: {},+ },+} satisfies PackLook<'packingList' | 'todoList'>;diff --git a/client/src/components/Assistant/cards/packing/packingViews.tsx b/client/src/components/Assistant/cards/packing/packingViews.tsxnew file mode 100644index 000000000..63c3d4575--- /dev/null+++ b/client/src/components/Assistant/cards/packing/packingViews.tsx@@ -0,0 +1,13 @@+import { type CardView, PENDING_VIEW } from '../cardTypes';++/**+ * How the kinds of the packing lists and to-dos draw in the chat; each one+ * draws nothing until its cards are built. This file only maps each kind to its+ * view: the components live in sibling files, since a file that exports+ * anything besides components breaks fast refresh, and lint:warnings holds+ * react-refresh/only-export-components at zero for a new file.+ */+export const PACKING_VIEWS = {+ packingList: PENDING_VIEW,+ todoList: PENDING_VIEW,+} satisfies { [K in 'packingList' | 'todoList']: CardView<K> };diff --git a/client/src/components/Assistant/cards/parts/CardBoundary.tsx b/client/src/components/Assistant/cards/parts/CardBoundary.tsxnew file mode 100644index 000000000..fde690767--- /dev/null+++ b/client/src/components/Assistant/cards/parts/CardBoundary.tsx@@ -0,0 +1,17 @@+import type { ReactNode } from 'react';++import ErrorBoundary from '../../../shared/ErrorBoundary';++/**+ * Around every card and every slot of a kind's view the chat draws: one that+ * throws while it renders is logged and drawn as its `fallback` (nothing,+ * unless the caller hands what the row shows without a card), and the answer+ * around it stays.+ */+export default function CardBoundary({ children, fallback = null }: { children: ReactNode; fallback?: ReactNode }) {+ return (+ <ErrorBoundary boundaryId="assistant-card" fallback={fallback}>+ {children}+ </ErrorBoundary>+ );+}diff --git a/client/src/components/Assistant/cards/parts/CardFacts.tsx b/client/src/components/Assistant/cards/parts/CardFacts.tsxnew file mode 100644index 000000000..ab6153a10--- /dev/null+++ b/client/src/components/Assistant/cards/parts/CardFacts.tsx@@ -0,0 +1,83 @@+import { ArrowRight, type LucideIcon } from 'lucide-react';+import type { ReactNode } from 'react';++import { useTranslation } from '../../../../i18n';+import { type PillTone, SoftPill } from '../../../Planner/planParts';++/**+ * The facts a card states in one wrapped line of small white badges, the way+ * the planner's rows do: a fact with its glyph, a value that changes from old+ * to new, what a change does to a row, and what no longer belongs to it.+ */++export function CardFacts({ children }: { children: ReactNode }) {+ return <span className="mt-1 flex flex-wrap items-center gap-1">{children}</span>;+}++/** A value that changes: the old one struck through, an arrow, the new one. Without `before`, only the value. */+export function FactChange({+ icon: Icon,+ before,+ after,+ tone = 'neutral',+}: {+ icon: LucideIcon;+ before: string | null;+ after: string;+ tone?: PillTone;+}) {+ return (+ <SoftPill+ tone={tone}+ className="max-w-full tabular-nums"+ icon={+ <Icon+ size={10}+ strokeWidth={2.2}+ aria-hidden="true"+ className={tone === 'neutral' ? 'flex-none text-content-faint' : 'flex-none'}+ />+ }+ >+ {before !== null && (+ <>+ <bdi className="truncate text-content-faint line-through">{before}</bdi>+ <ArrowRight size={9} aria-hidden="true" className="flex-none text-content-faint rtl:-scale-x-100" />+ </>+ )}+ <bdi className="truncate">{after}</bdi>+ </SoftPill>+ );+}++/** One fact with its glyph. */+export function Fact({ icon, tone, label }: { icon: LucideIcon; tone?: PillTone; label: string }) {+ return <FactChange icon={icon} tone={tone} before={null} after={label} />;+}++/** What a change does to a row of a card. A table, so each word is named where it is read. */+const CHANGE_MARK = {+ new: { labelKey: 'assistant.card.common.new', tone: 'success' },+ removed: { labelKey: 'assistant.card.common.removed', tone: 'danger' },+ changed: { labelKey: 'assistant.card.common.changed', tone: 'info' },+ willDelete: { labelKey: 'assistant.card.common.willDelete', tone: 'danger' },+} as const satisfies Record<string, { labelKey: string; tone: PillTone }>;++/** The mark of a row a change touches; nothing for a row it leaves alone (`none`, an answer's rows). */+export function ChangeMark({ change }: { change: keyof typeof CHANGE_MARK | 'none' }) {+ const { t } = useTranslation();+ if (change === 'none') return null;+ const mark = CHANGE_MARK[change];+ return <SoftPill tone={mark.tone}>{t(mark.labelKey)}</SoftPill>;+}++/** The names a change takes off a row (people, places), in one line. */+export function NoLonger({ names }: { names: readonly string[] }) {+ const { t } = useTranslation();+ if (names.length === 0) return null;+ return (+ <span className="text-caption text-content-muted">+ <bdi>{t('assistant.card.common.noLonger', { names: names.join(', ') })}</bdi>+ </span>+ );+}diff --git a/client/src/components/Assistant/cards/parts/CardFrame.tsx b/client/src/components/Assistant/cards/parts/CardFrame.tsxnew file mode 100644index 000000000..201412e8f--- /dev/null+++ b/client/src/components/Assistant/cards/parts/CardFrame.tsx@@ -0,0 +1,42 @@+import type { ReactNode } from 'react';++/**+ * The frame every answer card sits in, the same as the change card's: a+ * rounded card on the chat. A waiting change shows its frame dashed, a+ * removed one faded, a settled one (discarded, expired, undone) fainter+ * still. The chat card (a message in the trip chat) sits on the quieter+ * secondary surface.+ */++type FrameState = 'answer' | 'pending' | 'removed' | 'settled';++const STATE: Record<FrameState, string> = {+ answer: 'border-edge-faint',+ pending: 'border-dashed border-edge',+ removed: 'border-edge-faint opacity-60',+ settled: 'border-edge-faint opacity-50',+};++export default function CardFrame({+ label,+ state = 'answer',+ surface = 'card',+ children,+}: {+ /** What the card is, for a screen reader. */+ label: string;+ state?: FrameState;+ surface?: 'card' | 'secondary';+ children: ReactNode;+}) {+ return (+ <section+ aria-label={label}+ className={`trek-assistant-enter rounded-xl border px-3 pb-2 pt-2.5 shadow-card ${STATE[state]} ${+ surface === 'secondary' ? 'bg-surface-secondary' : 'bg-surface-card'+ }`}+ >+ {children}+ </section>+ );+}diff --git a/client/src/components/Assistant/cards/parts/CardHeader.tsx b/client/src/components/Assistant/cards/parts/CardHeader.tsxnew file mode 100644index 000000000..cf69eab0e--- /dev/null+++ b/client/src/components/Assistant/cards/parts/CardHeader.tsx@@ -0,0 +1,43 @@+import type { LucideIcon } from 'lucide-react';+import type { ReactNode } from 'react';++import { WhiteBadge } from '../../../Planner/planParts';+import type { Tone } from './assistantTones';+import KindTile from './KindTile';++/**+ * The head of an answer card: its tile, what it is about (wrapping to two+ * lines at most, the whole title in its tooltip), how many it holds, one+ * quiet line of context under it, and its actions at the end.+ */+export default function CardHeader({+ icon,+ tone,+ title,+ count,+ meta,+ actions,+}: {+ icon: LucideIcon;+ tone: Tone;+ title: string;+ count?: number;+ meta?: ReactNode;+ actions?: ReactNode;+}) {+ return (+ <div className="flex items-start gap-2.5">+ <KindTile icon={icon} tone={tone} size="sm" />+ <div className="min-w-0 flex-1">+ <div className="flex min-w-0 items-center gap-1.5">+ <bdi title={title} className="line-clamp-2 text-body font-semibold leading-tight text-content">+ {title}+ </bdi>+ {count !== undefined && <WhiteBadge>{count}</WhiteBadge>}+ </div>+ {meta && <div className="mt-0.5 text-caption text-content-muted">{meta}</div>}+ </div>+ {actions && <div className="flex flex-none items-center gap-1">{actions}</div>}+ </div>+ );+}diff --git a/client/src/components/Assistant/cards/parts/CardOpen.tsx b/client/src/components/Assistant/cards/parts/CardOpen.tsxnew file mode 100644index 000000000..0570721ac--- /dev/null+++ b/client/src/components/Assistant/cards/parts/CardOpen.tsx@@ -0,0 +1,51 @@+import { ArrowUpRight } from 'lucide-react';++import { useTranslation } from '../../../../i18n';+import { Tooltip } from '../../../shared/Tooltip';+import { useAssistantView } from '../../assistantViewContext';+import type { EntityTarget } from '../cardTypes';++/**+ * The ways out of a card into TREK: "Open" to where the card's things live,+ * and a day to show in the plan. Both go through the shell's one way of+ * opening things, and neither shows where the shell cannot open anything.+ */++/** "Open" (or the card's own words) as a quiet text button; taller on the phone. */+export function CardOpenButton({ target, labelKey }: { target: EntityTarget; labelKey?: string }) {+ const { t } = useTranslation();+ const { variant, onOpen } = useAssistantView();+ if (!onOpen) return null;+ return (+ <button+ type="button"+ onClick={() => onOpen(target)}+ className={`inline-flex flex-none items-center gap-1 rounded-full px-2 text-caption text-content-secondary transition-colors hover:bg-surface-hover hover:text-content ${+ variant === 'fullscreen' ? 'h-10' : 'h-7'+ }`}+ >+ {labelKey ? t(labelKey) : t('assistant.card.common.open')}+ <ArrowUpRight size={12} aria-hidden="true" className="rtl:-scale-x-100" />+ </button>+ );+}++/** A day named on a card, as a button that shows it in the plan. */+export function CardDayButton({ dayId, label }: { dayId: number; label: string }) {+ const { t } = useTranslation();+ const { onOpen } = useAssistantView();+ if (!onOpen) return <bdi className="text-caption text-content-secondary">{label}</bdi>;+ const hint = t('assistant.card.common.showDay');+ return (+ <Tooltip label={hint} placement="top">+ <button+ type="button"+ onClick={() => onOpen({ kind: 'map', placeId: null, dayId })}+ aria-label={`${label}: ${hint}`}+ className="rounded-full px-1 text-caption text-content-secondary underline-offset-2 hover:text-content hover:underline"+ >+ <bdi>{label}</bdi>+ </button>+ </Tooltip>+ );+}diff --git a/client/src/components/Assistant/cards/parts/CardParts.test.tsx b/client/src/components/Assistant/cards/parts/CardParts.test.tsxnew file mode 100644index 000000000..e74abd670--- /dev/null+++ b/client/src/components/Assistant/cards/parts/CardParts.test.tsx@@ -0,0 +1,193 @@+/**+ * FE-AI-CARDPART-001 to FE-AI-CARDPART-009+ *+ * The pieces every card is built from: its tile, frame and head, its facts+ * and change marks, its rows and the way to the rest, its "Open" and day+ * buttons, the people on it, and the boundary that leaves a broken card out.+ */+import type { CardPerson } from '@trek/shared';+import { CalendarDays, Route } from 'lucide-react';+import type { ReactNode } from 'react';+import { afterEach, describe, expect, it, vi } from 'vitest';++import { buildUser } from '../../../../../tests/helpers/factories';+import { fireEvent, render, screen } from '../../../../../tests/helpers/render';+import { useAuthStore } from '../../../../store/authStore';+import { type AssistantView, AssistantViewContext } from '../../assistantViewContext';+import CardBoundary from './CardBoundary';+import { CardFacts, ChangeMark, Fact, FactChange, NoLonger } from './CardFacts';+import CardFrame from './CardFrame';+import CardHeader from './CardHeader';+import { CardDayButton, CardOpenButton } from './CardOpen';+import { PeopleStack, PersonFace } from './CardPeople';+import { CardMore, CardRow, CardRows } from './CardRows';+import KindTile from './KindTile';++const AUTH = useAuthStore.getState();++function inView(ui: ReactNode, view: Partial<AssistantView> = {}) {+ const value: AssistantView = { tripId: 4, variant: 'window', ...view };+ return render(<AssistantViewContext.Provider value={value}>{ui}</AssistantViewContext.Provider>);+}++afterEach(() => {+ useAuthStore.setState(AUTH, true);+ vi.restoreAllMocks();+});++describe('card parts', () => {+ it('FE-AI-CARDPART-001: the tile wears its tone, fades when dimmed and waits as a placeholder without an icon', () => {+ const { container, rerender } = render(<KindTile icon={Route} tone="success" size="xs" />);+ expect(container.firstElementChild).toHaveClass('bg-success-soft', 'ring-2');+ rerender(<KindTile icon={Route} tone="danger" dimmed />);+ expect(container.firstElementChild).toHaveClass('bg-surface-secondary', 'h-8');+ rerender(<KindTile icon={null} tone="info" size="sm" />);+ expect(container.firstElementChild).toHaveClass('trek-skeleton', 'h-7');+ });++ it('FE-AI-CARDPART-002: the frame names the card and says its state; the head titles, counts and acts', () => {+ render(+ <CardFrame label="Tours" state="pending" surface="secondary">+ <CardHeader+ icon={Route}+ tone="info"+ title="Three ways up"+ count={3}+ meta="Day 2"+ actions={<button type="button">act</button>}+ />+ </CardFrame>+ );+ const frame = screen.getByRole('region', { name: 'Tours' });+ expect(frame).toHaveClass('border-dashed', 'bg-surface-secondary');+ expect(screen.getByText('Three ways up')).toHaveAttribute('title', 'Three ways up');+ expect(screen.getByText('3')).toBeInTheDocument();+ expect(screen.getByText('Day 2')).toBeInTheDocument();+ expect(screen.getByRole('button', { name: 'act' })).toBeInTheDocument();+ });++ it('FE-AI-CARDPART-003: facts read old to new, change marks name what happens, and a list says who is gone', () => {+ render(+ <CardFacts>+ <Fact icon={CalendarDays} label="Day 3" />+ <FactChange icon={CalendarDays} tone="warning" before="09:00" after="10:30" />+ <ChangeMark change="new" />+ <ChangeMark change="willDelete" />+ <ChangeMark change="none" />+ <NoLonger names={['Ana', 'Ben']} />+ <NoLonger names={[]} />+ </CardFacts>+ );+ expect(screen.getByText('Day 3')).toBeInTheDocument();+ expect(screen.getByText('09:00')).toHaveClass('line-through');+ expect(screen.getByText('10:30')).toBeInTheDocument();+ expect(screen.getByText('New')).toBeInTheDocument();+ expect(screen.getByText('Will be deleted')).toBeInTheDocument();+ expect(screen.getByText('No longer: Ana, Ben')).toBeInTheDocument();+ });++ it('FE-AI-CARDPART-004: a row that leads somewhere is a button and lights the map while the pointer rests on it', () => {+ const onActivate = vi.fn();+ const onHover = vi.fn();+ inView(+ <CardRows>+ <CardRow title="Col du Galibier" aside="12 km" lit onActivate={onActivate} onHover={onHover} />+ <CardRow title="Quiet row" />+ </CardRows>,+ { variant: 'fullscreen' }+ );+ const row = screen.getByRole('button', { name: /Col du Galibier/ });+ expect(row).toHaveClass('bg-surface-hover', 'min-h-11');+ fireEvent.mouseEnter(row);+ fireEvent.mouseLeave(row);+ expect(onHover.mock.calls).toEqual([[true], [false]]);+ fireEvent.click(row);+ expect(onActivate).toHaveBeenCalled();+ expect(screen.getByText('Quiet row').closest('button')).toBeNull();+ });++ it('FE-AI-CARDPART-005: "N more" opens where the rest lives, and is plain words where nothing can open it', () => {+ const onOpen = vi.fn();+ const target = { kind: 'tab', tab: 'finanzplan' } as const;+ const first = inView(<CardMore count={4} target={target} />, { onOpen });+ fireEvent.click(screen.getByRole('button', { name: '4 more' }));+ expect(onOpen).toHaveBeenCalledWith(target);+ first.unmount();++ const second = inView(<CardMore count={1} labelKey="assistant.place.more" target={target} />);+ expect(screen.queryByRole('button')).toBeNull();+ expect(screen.getByText('1 more')).toBeInTheDocument();+ second.unmount();++ const { container } = inView(<CardMore count={0} target={target} />, { onOpen });+ expect(container).toBeEmptyDOMElement();+ });++ it('FE-AI-CARDPART-006: "Open" and a day go through the shell, taller on the phone, and stay out without a shell', () => {+ const onOpen = vi.fn();+ const first = inView(+ <>+ <CardOpenButton target={{ kind: 'page', path: '/atlas' }} />+ <CardDayButton dayId={8} label="Day 2" />+ </>,+ { onOpen, variant: 'fullscreen' }+ );+ fireEvent.click(screen.getByRole('button', { name: 'Open' }));+ expect(onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/atlas' });+ expect(screen.getByRole('button', { name: 'Open' })).toHaveClass('h-10');+ fireEvent.click(screen.getByRole('button', { name: 'Day 2: Show this day in the plan' }));+ expect(onOpen).toHaveBeenLastCalledWith({ kind: 'map', placeId: null, dayId: 8 });+ first.unmount();++ inView(+ <>+ <CardOpenButton target={{ kind: 'page', path: '/atlas' }} labelKey="assistant.change.viewOnMap" />+ <CardDayButton dayId={8} label="Day 2" />+ </>+ );+ expect(screen.queryByRole('button')).toBeNull();+ expect(screen.getByText('Day 2')).toBeInTheDocument();+ });++ it('FE-AI-CARDPART-007: the signed-in user reads as You, a picture comes from TREK only, the rest is counted', () => {+ useAuthStore.setState({ user: buildUser({ id: 1 }) });+ const people: CardPerson[] = [+ { id: 1, name: 'Ana', avatarKey: 'ana.png' },+ { id: 2, name: 'Ben', avatarKey: null },+ { id: 3, name: 'Cleo', avatarKey: null },+ { id: 4, name: 'Dan', avatarKey: null },+ ];+ const { container } = render(+ <>+ <PersonFace person={people[0] as CardPerson} size={24} />+ <PeopleStack people={people} max={2} />+ </>+ );+ expect(screen.getByRole('img', { name: 'You' })).toBeInTheDocument();+ expect(container.querySelector('img')?.getAttribute('src')).toBe('/uploads/avatars/ana.png');+ expect(screen.getByRole('img', { name: 'You, Ben, Cleo, Dan' })).toBeInTheDocument();+ expect(screen.getByText('+2')).toBeInTheDocument();+ expect(screen.getByText('B')).toBeInTheDocument();+ });++ it('FE-AI-CARDPART-008: nobody on a card draws nothing', () => {+ const { container } = render(<PeopleStack people={[]} />);+ expect(container).toBeEmptyDOMElement();+ });++ it('FE-AI-CARDPART-009: a card that throws is left out and the rest stays', () => {+ vi.spyOn(console, 'error').mockImplementation(() => {});+ function Broken(): never {+ throw new Error('broken');+ }+ render(+ <div>+ <CardBoundary>+ <Broken />+ </CardBoundary>+ <span>still here</span>+ </div>+ );+ expect(screen.getByText('still here')).toBeInTheDocument();+ });+});diff --git a/client/src/components/Assistant/cards/parts/CardPeople.tsx b/client/src/components/Assistant/cards/parts/CardPeople.tsxnew file mode 100644index 000000000..03f1b75ff--- /dev/null+++ b/client/src/components/Assistant/cards/parts/CardPeople.tsx@@ -0,0 +1,61 @@+import type { CardPerson } from '@trek/shared';++import { useTranslation } from '../../../../i18n';+import { avatarSrc } from '../../../../utils/avatarSrc';+import { TravelerAvatar } from '../../../Planner/bookings/bookingParts';+import { Tooltip } from '../../../shared/Tooltip';+import { useViewerId } from './useViewerId';++/**+ * People on a card, as the bookings show travellers: a round face with the+ * picture TREK stores for them, else the first letter. A card carries a+ * stored file name only, never an address, so a picture from a sign-in+ * provider shows the letter. The signed-in user reads as "You".+ */++const FACE = { 14: 'h-3.5 w-3.5', 20: 'h-5 w-5', 24: 'h-6 w-6' } as const;++/** A person's name as the card says it: "You" for the signed-in user. */+function useNameOf(): (person: CardPerson) => string {+ const { t } = useTranslation();+ const viewerId = useViewerId();+ const you = t('assistant.card.common.you');+ return (person) => (person.id === viewerId ? you : person.name);+}++export function PersonFace({ person, size = 20 }: { person: CardPerson; size?: keyof typeof FACE }) {+ const nameOf = useNameOf();+ const name = nameOf(person);+ return (+ <span role="img" aria-label={name} title={name} className="inline-flex flex-none">+ <TravelerAvatar src={avatarSrc(person.avatarKey)} name={person.name} className={FACE[size]} />+ </span>+ );+}++/** A few faces stacked, the rest counted, every name in the tooltip and for screen readers. */+export function PeopleStack({ people, max = 3 }: { people: readonly CardPerson[]; max?: number }) {+ const nameOf = useNameOf();+ if (people.length === 0) return null;+ const names = people.map(nameOf).join(', ');+ return (+ <Tooltip label={names}>+ <span role="img" aria-label={names} className="flex items-center">+ {people.slice(0, max).map((person, i) => (+ <TravelerAvatar+ key={person.id}+ src={avatarSrc(person.avatarKey)}+ name={person.name}+ className="h-5 w-5 border-2 border-surface-card"+ style={{ marginInlineStart: i ? -6 : 0 }}+ />+ ))}+ {people.length > max && (+ <span className="ms-1 text-caption font-semibold tabular-nums text-content-faint">+ +{people.length - max}+ </span>+ )}+ </span>+ </Tooltip>+ );+}diff --git a/client/src/components/Assistant/cards/parts/CardRows.tsx b/client/src/components/Assistant/cards/parts/CardRows.tsxnew file mode 100644index 000000000..2e754c143--- /dev/null+++ b/client/src/components/Assistant/cards/parts/CardRows.tsx@@ -0,0 +1,89 @@+import type { ReactNode } from 'react';++import { useTranslation } from '../../../../i18n';+import { useAssistantView } from '../../assistantViewContext';+import type { EntityTarget } from '../cardTypes';++/**+ * The rows of an answer card, like the planner's day list: a lead in front,+ * the name in bold, an aside at the end (an amount, a time) and its facts on+ * the line under it. A row that leads somewhere is a button; resting on it+ * can light its spot on the map. What a card leaves out is counted at the end+ * as a way to where it all lives, never unfolded in the chat.+ */++export function CardRows({ children }: { children: ReactNode }) {+ return <ul className="m-0 flex list-none flex-col p-0">{children}</ul>;+}++export function CardRow({+ lead,+ title,+ aside,+ facts,+ onActivate,+ onHover,+ lit = false,+}: {+ lead?: ReactNode;+ title: ReactNode;+ aside?: ReactNode;+ facts?: ReactNode;+ onActivate?: () => void;+ onHover?: (on: boolean) => void;+ lit?: boolean;+}) {+ const { variant } = useAssistantView();+ const look = `-mx-1.5 flex w-full gap-2.5 rounded-[12px] px-1.5 py-2 text-start transition-colors hover:bg-surface-hover ${+ variant === 'fullscreen' ? 'min-h-11' : ''+ } ${lit ? 'bg-surface-hover' : ''}`;+ const body = (+ <>+ {lead}+ <span className="min-w-0 flex-1">+ <span className="block text-body font-semibold leading-tight text-content">{title}</span>+ {facts}+ </span>+ {aside && <span className="flex-none text-caption tabular-nums text-content-secondary">{aside}</span>}+ </>+ );+ const hover = onHover+ ? {+ onMouseEnter: () => onHover(true),+ onMouseLeave: () => onHover(false),+ onFocus: () => onHover(true),+ onBlur: () => onHover(false),+ }+ : {};+ return (+ <li>+ {onActivate ? (+ <button type="button" onClick={onActivate} className={look} {...hover}>+ {body}+ </button>+ ) : (+ <div className={look} {...hover}>+ {body}+ </div>+ )}+ </li>+ );+}++/** "3 more" at the end of a card: a text button to where the rest lives, or plain words where nothing can open it. */+export function CardMore({ count, labelKey, target }: { count: number; labelKey?: string; target: EntityTarget }) {+ const { t } = useTranslation();+ const { onOpen } = useAssistantView();+ if (count <= 0) return null;+ const label = labelKey ? t(labelKey, { count }) : t('assistant.card.common.more', { count });+ if (!onOpen) return <p className="m-0 px-1.5 py-1 text-caption text-content-muted">{label}</p>;+ return (+ <button+ type="button"+ onClick={() => onOpen(target)}+ className="rounded-lg px-1.5 py-1 text-caption font-medium text-content-muted transition-colors hover:bg-surface-hover hover:text-content"+ >+ {label}+ </button>+ );+}diff --git a/client/src/components/Assistant/cards/parts/CardStrip.tsx b/client/src/components/Assistant/cards/parts/CardStrip.tsxnew file mode 100644index 000000000..32f52503c--- /dev/null+++ b/client/src/components/Assistant/cards/parts/CardStrip.tsx@@ -0,0 +1,74 @@+import { ChevronLeft, ChevronRight } from 'lucide-react';+import type { ReactNode } from 'react';++import { useAssistantView } from '../../assistantViewContext';+import { useCardStrip } from './useCardStrip';++// In the strip's head, never over a card: a press that ends a pixel off still lands on the arrow.+const ARROW =+ 'grid h-7 w-7 place-items-center rounded-full bg-surface-card text-content-secondary shadow-sm ring-1 ring-edge-faint transition-colors hover:text-content disabled:cursor-default disabled:opacity-40 disabled:hover:text-content-secondary';++/**+ * A row of cards to swipe or scroll through, running out to the chat's+ * edges: the next card peeks in, so the row says it goes on, and the edges+ * fade where there is more. In the desktop window a head over the row names+ * it, counts it and holds two arrows that move it by whole cards, off while+ * that way is the end. `children` are the cards, each an `li`.+ */+export default function CardStrip({+ label,+ count,+ watch,+ children,+}: {+ label: string;+ count: number;+ /** What the strip shows; a change measures it again. */+ watch: unknown;+ children: ReactNode;+}) {+ const { variant } = useAssistantView();+ const { listRef, fade, measure, page } = useCardStrip(watch);+ return (+ <section aria-label={label} className="-mx-4">+ {variant === 'window' && (fade.start || fade.end) && (+ // The cards are reachable by Tab; the arrows are for the pointer only.+ <div className="mb-1.5 flex items-center gap-2 px-4">+ <span className="min-w-0 flex-1 truncate text-caption font-medium text-content-muted">+ {label}+ <span className="ms-1.5 tabular-nums text-content-faint">{count}</span>+ </span>+ <button+ type="button"+ tabIndex={-1}+ aria-hidden="true"+ disabled={!fade.start}+ onClick={() => page(-1)}+ className={ARROW}+ >+ <ChevronLeft size={15} className="rtl:-scale-x-100" />+ </button>+ <button+ type="button"+ tabIndex={-1}+ aria-hidden="true"+ disabled={!fade.end}+ onClick={() => page(1)}+ className={ARROW}+ >+ <ChevronRight size={15} className="rtl:-scale-x-100" />+ </button>+ </div>+ )}+ <ul+ ref={listRef}+ onScroll={measure}+ data-fade-start={fade.start || undefined}+ data-fade-end={fade.end || undefined}+ className="trek-assistant-strip flex snap-x snap-mandatory scroll-px-4 gap-2.5 overflow-x-auto overscroll-x-contain px-4 pb-2 pt-0.5 motion-safe:scroll-smooth"+ >+ {children}+ </ul>+ </section>+ );+}diff --git a/client/src/components/Assistant/cards/parts/KindTile.tsx b/client/src/components/Assistant/cards/parts/KindTile.tsxnew file mode 100644index 000000000..c4402b876--- /dev/null+++ b/client/src/components/Assistant/cards/parts/KindTile.tsx@@ -0,0 +1,41 @@+import type { LucideIcon } from 'lucide-react';++import { TILE, type Tone } from './assistantTones';++/**+ * The tinted tile a change or a card wears: the icon of what it touches in+ * the tone of what happens. `xs` is the small badge on a corner (an avatar,+ * a photo), `sm` sits in front of a row, `md` heads a card. Without an icon+ * yet (the preview has not arrived) it shows as a placeholder.+ */++const BOX = {+ xs: 'h-3.5 w-3.5 rounded-full ring-2 ring-surface-card',+ sm: 'h-7 w-7 rounded-md',+ md: 'h-8 w-8 rounded-lg',+} as const;++const GLYPH = { xs: 9, sm: 14, md: 16 } as const;++export default function KindTile({+ icon: Icon,+ tone,+ size = 'md',+ dimmed = false,+}: {+ icon: LucideIcon | null;+ tone: Tone;+ size?: 'xs' | 'sm' | 'md';+ dimmed?: boolean;+}) {+ const box = BOX[size];+ if (!Icon) return <span className={`trek-skeleton flex-shrink-0 ${box}`} aria-hidden="true" />;+ return (+ <span+ aria-hidden="true"+ className={`flex flex-shrink-0 items-center justify-center ${box} ${dimmed ? 'bg-surface-secondary text-content-faint' : TILE[tone]}`}+ >+ <Icon size={GLYPH[size]} strokeWidth={2.1} />+ </span>+ );+}diff --git a/client/src/components/Assistant/cards/parts/RouteSketch.test.tsx b/client/src/components/Assistant/cards/parts/RouteSketch.test.tsxnew file mode 100644index 000000000..9e03b25a7--- /dev/null+++ b/client/src/components/Assistant/cards/parts/RouteSketch.test.tsx@@ -0,0 +1,76 @@+/**+ * FE-AI-SKETCH-001 to FE-AI-SKETCH-004+ *+ * The small route drawing: framed by everything it holds in Web Mercator, a+ * lone point centred, nothing without a point, and a button when it shows+ * the route on the map.+ */+import { describe, expect, it, vi } from 'vitest';++import { fireEvent, render, screen } from '../../../../../tests/helpers/render';+import RouteSketch from './RouteSketch';+import { linePoints, mercatorY, sketchFrame, type SketchLine, type SketchMark } from './routeSketchModel';++const LINE: SketchLine = {+ id: 'day-1',+ points: [+ [45.0, 7.0],+ [45.2, 7.4],+ ],+ color: 'var(--accent)',+ casing: 'var(--bg-card)',+};+const MARKS: SketchMark[] = [+ { id: 's1', lat: 45.0, lng: 7.0, shape: 'stop' },+ { id: 'v1', lat: 45.1, lng: 7.2, shape: 'via', state: 'pending', hot: true },+ { id: 'c1', lat: 45.2, lng: 7.4, shape: 'service', color: 'var(--warning)' },+ { id: 'n1', lat: 45.15, lng: 7.3, shape: 'new', state: 'removed' },+];++describe('routeSketchModel', () => {+ it('FE-AI-SKETCH-001: projects like the map, inside the box with room around it, north up', () => {+ expect(mercatorY(0)).toBeCloseTo(0);+ expect(mercatorY(89)).toBe(mercatorY(85));+ const frame = sketchFrame([LINE], []);+ if (!frame) throw new Error('no frame');+ expect(frame.width).toBe(1000);+ const [x0, y0] = frame.project(45.0, 7.0);+ const [x1, y1] = frame.project(45.2, 7.4);+ expect(x0).toBeGreaterThan(0);+ expect(x1).toBeLessThan(frame.width);+ expect(y1).toBeLessThan(y0);+ expect(y0).toBeLessThan(frame.height);+ expect(linePoints(frame, LINE.points).split(' ')).toHaveLength(2);+ });++ it('FE-AI-SKETCH-002: one point sits in the middle, and no point gives no frame', () => {+ const frame = sketchFrame([], [{ id: 'a', lat: 45, lng: 7, shape: 'stop' }]);+ expect(frame?.project(45, 7)).toEqual([500, (frame?.height ?? 0) / 2]);+ expect(sketchFrame([], [])).toBeNull();+ });+});++describe('RouteSketch', () => {+ it('FE-AI-SKETCH-003: draws each line twice (casing and core) and every mark, as one picture', () => {+ const { container } = render(+ <RouteSketch lines={[{ ...LINE, dashed: true, dim: true }]} marks={MARKS} height={96} ariaLabel="Day 1" />+ );+ expect(screen.getByRole('img', { name: 'Day 1' })).toBeInTheDocument();+ expect(container.querySelectorAll('polyline')).toHaveLength(2);+ expect(container.querySelector('rect')).not.toBeNull();+ expect(container.querySelectorAll('circle')).toHaveLength(4);+ });++ it('FE-AI-SKETCH-004: with a way to the map it is a button, and nothing is drawn without a point', () => {+ const onActivate = vi.fn();+ const first = render(+ <RouteSketch lines={[LINE]} marks={[]} height={96} ariaLabel="Day 1" onActivate={onActivate} />+ );+ fireEvent.click(screen.getByRole('button', { name: 'Day 1' }));+ expect(onActivate).toHaveBeenCalled();+ first.unmount();++ const { container } = render(<RouteSketch lines={[]} marks={[]} height={96} ariaLabel="Nothing" />);+ expect(container).toBeEmptyDOMElement();+ });+});diff --git a/client/src/components/Assistant/cards/parts/RouteSketch.tsx b/client/src/components/Assistant/cards/parts/RouteSketch.tsxnew file mode 100644index 000000000..f7194d9da--- /dev/null+++ b/client/src/components/Assistant/cards/parts/RouteSketch.tsx@@ -0,0 +1,122 @@+import { linePoints, sketchFrame, type SketchLine, type SketchMark } from './routeSketchModel';++/**+ * A route drawn small, without tiles or a network: the lines and stops of a+ * drive or a hike projected as the map projects them, on the quiet secondary+ * surface. Lines keep their width however the box scales; marks are sized+ * for a card a little wider than the phone. The sketch is geographic, so it+ * reads the same in both directions of text. With `onActivate` it is a+ * button (show it on the map).+ */++/** The card width the marks are sized for: a stop stays about three pixels across in a card this wide. */+const CARD_WIDTH = 360;++function Mark({ mark, x, y, unit }: { mark: SketchMark; x: number; y: number; unit: number }) {+ const dashed = mark.state === 'pending' ? `${2 * unit} ${2 * unit}` : undefined;+ const stroke = mark.state === 'removed' ? 'var(--text-faint)' : 'var(--text-muted)';+ return (+ <g>+ {mark.hot && <circle cx={x} cy={y} r={6 * unit} fill="none" stroke="var(--accent)" strokeWidth={unit} />}+ {mark.shape === 'via' ? (+ <rect+ x={x - 3.5 * unit}+ y={y - 3.5 * unit}+ width={7 * unit}+ height={7 * unit}+ transform={`rotate(45 ${x} ${y})`}+ fill="var(--accent)"+ strokeDasharray={dashed}+ />+ ) : (+ <circle+ cx={x}+ cy={y}+ r={(mark.shape === 'service' ? 4 : 3) * unit}+ fill={mark.shape === 'service' ? (mark.color ?? 'var(--text-muted)') : 'var(--bg-card)'}+ stroke={mark.shape === 'new' ? 'var(--accent)' : stroke}+ strokeWidth={unit}+ strokeDasharray={mark.shape === 'new' ? `${2 * unit} ${2 * unit}` : dashed}+ />+ )}+ </g>+ );+}++export default function RouteSketch({+ lines,+ marks,+ height,+ ariaLabel,+ onActivate,+}: {+ lines: readonly SketchLine[];+ marks: readonly SketchMark[];+ /** The box's height in pixels; its width is the card's. */+ height: number;+ ariaLabel: string;+ onActivate?: () => void;+}) {+ const frame = sketchFrame(lines, marks);+ if (!frame) return null;+ const svg = (+ <svg+ role={onActivate ? undefined : 'img'}+ aria-label={onActivate ? undefined : ariaLabel}+ aria-hidden={onActivate ? true : undefined}+ viewBox={`0 0 ${frame.width} ${frame.height}`}+ preserveAspectRatio="xMidYMid meet"+ className="block h-full w-full"+ >+ {lines.map((line) => {+ const points = linePoints(frame, line.points);+ return (+ <g key={line.id} opacity={line.dim ? 0.4 : 1}>+ <polyline+ points={points}+ fill="none"+ stroke={line.casing}+ strokeWidth={4.5}+ strokeLinecap="round"+ strokeLinejoin="round"+ vectorEffect="non-scaling-stroke"+ />+ <polyline+ points={points}+ fill="none"+ stroke={line.color}+ strokeWidth={2.5}+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeDasharray={line.dashed ? '5 4' : undefined}+ vectorEffect="non-scaling-stroke"+ />+ </g>+ );+ })}+ {marks.map((mark) => {+ const [x, y] = frame.project(mark.lat, mark.lng);+ return <Mark key={mark.id} mark={mark} x={x} y={y} unit={frame.width / CARD_WIDTH} />;+ })}+ </svg>+ );+ const box = 'block w-full overflow-hidden rounded-xl bg-surface-secondary ring-1 ring-inset ring-edge-faint';+ if (!onActivate) {+ return (+ <div className={box} style={{ height }}>+ {svg}+ </div>+ );+ }+ return (+ <button+ type="button"+ onClick={onActivate}+ aria-label={ariaLabel}+ className={`${box} transition-shadow hover:ring-edge focus-visible:ring-2 focus-visible:ring-accent`}+ style={{ height }}+ >+ {svg}+ </button>+ );+}diff --git a/client/src/components/Assistant/cards/parts/assistantTones.ts b/client/src/components/Assistant/cards/parts/assistantTones.tsnew file mode 100644index 000000000..98af77859--- /dev/null+++ b/client/src/components/Assistant/cards/parts/assistantTones.ts@@ -0,0 +1,31 @@+import { Check, CircleSlash, LoaderCircle, type LucideIcon, TriangleAlert } from 'lucide-react';++import type { ChangeState } from '../../assistantParts';++/**+ * The tones a card speaks in, soft ones only: green adds, blue changes, amber+ * moves or warns, red takes away. Every tile, badge and mark of the cards+ * takes its colour from here, so a kind never invents its own.+ */+export type Tone = 'success' | 'info' | 'warning' | 'danger';++/** A tinted tile in a tone: the soft background with the strong colour on top. */+export const TILE: Record<Tone, string> = {+ success: 'bg-success-soft text-success',+ info: 'bg-info-soft text-info',+ warning: 'bg-warning-soft text-warning',+ danger: 'bg-danger-soft text-danger',+};++/** How a decided change reads: one quiet mark, its words in the tooltip. */+export const RECEIPT: Record<Exclude<ChangeState, 'pending'>, { labelKey: string; Icon: LucideIcon; tone: string }> = {+ applying: { labelKey: 'assistant.change.applying', Icon: LoaderCircle, tone: 'text-content-muted' },+ applied: { labelKey: 'assistant.change.applied', Icon: Check, tone: 'text-success' },+ failed: { labelKey: 'assistant.change.failed', Icon: TriangleAlert, tone: 'text-danger' },+ discarded: { labelKey: 'assistant.change.discarded', Icon: CircleSlash, tone: 'text-content-faint' },+ expired: { labelKey: 'assistant.change.expired', Icon: CircleSlash, tone: 'text-content-faint' },+};++/** A quiet square icon button on a card row or head. */+export const ICON_BUTTON =+ 'flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md text-content-muted transition-colors hover:bg-surface-hover hover:text-content disabled:opacity-50';diff --git a/client/src/components/Assistant/cards/parts/cardHooks.test.tsx b/client/src/components/Assistant/cards/parts/cardHooks.test.tsxnew file mode 100644index 000000000..8f0aace87--- /dev/null+++ b/client/src/components/Assistant/cards/parts/cardHooks.test.tsx@@ -0,0 +1,90 @@+/**+ * FE-AI-CARDHOOK-001 to FE-AI-CARDHOOK-004+ *+ * The hooks a card leans on: how it writes numbers for this user, its part+ * of the map (a pin while resting, a pan on a click, the pin gone with the+ * card), and who is signed in.+ */+import { renderHook } from '@testing-library/react';+import type { ReactNode } from 'react';+import { afterEach, describe, expect, it, vi } from 'vitest';++import { buildUser } from '../../../../../tests/helpers/factories';+import { TranslationProvider } from '../../../../i18n/TranslationContext';+import { useAssistantStore } from '../../../../store/assistantStore';+import { useAuthStore } from '../../../../store/authStore';+import { useSettingsStore } from '../../../../store/settingsStore';+import { AssistantViewContext } from '../../assistantViewContext';+import { useCardFormat } from './useCardFormat';+import { useCardPoint } from './useCardPoint';+import { useViewerId } from './useViewerId';++const ASSISTANT = useAssistantStore.getState();+const AUTH = useAuthStore.getState();+const SETTINGS = useSettingsStore.getState();++const onRevealMap = vi.fn();++function wrapper({ children }: { children: ReactNode }) {+ return (+ <TranslationProvider>+ <AssistantViewContext.Provider value={{ tripId: 4, variant: 'fullscreen', onRevealMap }}>+ {children}+ </AssistantViewContext.Provider>+ </TranslationProvider>+ );+}++afterEach(() => {+ useAssistantStore.setState(ASSISTANT, true);+ useAuthStore.setState(AUTH, true);+ useSettingsStore.setState(SETTINGS, true);+ vi.clearAllMocks();+});++describe('card hooks', () => {+ it('FE-AI-CARDHOOK-001: numbers follow the user: clock setting, units, money in its currency, minutes as hours', () => {+ useSettingsStore.setState({ settings: { ...SETTINGS.settings, time_format: '12h', distance_unit: 'imperial' } });+ const { result } = renderHook(() => useCardFormat(), { wrapper });+ const format = result.current;+ expect(format.clock('14:30')).toBe('2:30 PM');+ expect(format.distance(10)).toBe('6.2 mi');+ expect(format.elevation(100)).toBe('328 ft');+ expect(format.money({ amount: 12.5, currency: 'USD' })).toBe('$12.50');+ expect(format.minutes(45)).toMatch(/45/);+ expect(format.minutes(120)).toMatch(/^2/);+ expect(format.minutes(135)).toMatch(/2.*15/);+ expect(format.count(1200)).toMatch(/1.?200/);+ expect(format.date('2026-10-22')).toMatch(/22/);+ });++ it('FE-AI-CARDHOOK-002: resting on a spot pins it, a click steps the chat aside and pans there', () => {+ const setPreviewPin = vi.fn();+ const requestCamera = vi.fn();+ useAssistantStore.setState({ setPreviewPin, requestCamera });+ const { result } = renderHook(() => useCardPoint(), { wrapper });+ result.current.hover({ ref: 'r1:0', lat: 45, lng: 7, name: 'Col', placeId: 9 });+ const pin = { tripId: 4, ref: 'r1:0', lat: 45, lng: 7, name: 'Col', placeId: 9 };+ expect(setPreviewPin).toHaveBeenLastCalledWith(pin);+ result.current.hover(null);+ expect(setPreviewPin).toHaveBeenLastCalledWith(null);+ result.current.show({ lat: 45, lng: 7 });+ expect(onRevealMap).toHaveBeenCalled();+ expect(requestCamera).toHaveBeenCalledWith(4, [[45, 7]], 'pan', 'user');+ });++ it('FE-AI-CARDHOOK-003: the pin goes with the card', () => {+ const setPreviewPin = vi.fn();+ useAssistantStore.setState({ setPreviewPin });+ const { unmount } = renderHook(() => useCardPoint(), { wrapper });+ unmount();+ expect(setPreviewPin).toHaveBeenLastCalledWith(null);+ });++ it('FE-AI-CARDHOOK-004: the viewer is the signed-in user, or nobody', () => {+ useAuthStore.setState({ user: buildUser({ id: 7 }) });+ expect(renderHook(() => useViewerId()).result.current).toBe(7);+ useAuthStore.setState({ user: null });+ expect(renderHook(() => useViewerId()).result.current).toBeNull();+ });+});diff --git a/client/src/components/Assistant/cards/parts/routeSketchModel.ts b/client/src/components/Assistant/cards/parts/routeSketchModel.tsnew file mode 100644index 000000000..0777c249b--- /dev/null+++ b/client/src/components/Assistant/cards/parts/routeSketchModel.ts@@ -0,0 +1,88 @@+/**+ * The geometry of a route sketch: lines and marks projected the way the map+ * projects them (Web Mercator), framed by everything they hold with a little+ * room around it, in a box 1000 units wide. Pure, so the sketch and a test+ * read the same numbers. Points are `[lat, lng]`.+ */++/** One line to draw: a day of a drive, a way of a hike. Colours are CSS values the caller made safe. */+export interface SketchLine {+ id: string;+ points: readonly (readonly [number, number])[];+ color: string;+ casing: string;+ dashed?: boolean;+ dim?: boolean;+}++/** One mark on the sketch: a stop, a service stop, a via the route passes, a stop a change adds. */+export interface SketchMark {+ id: string;+ lat: number;+ lng: number;+ shape: 'stop' | 'service' | 'via' | 'new';+ color?: string;+ state?: 'pending' | 'removed';+ hot?: boolean;+}++/** The width of the sketch's box in its own units; its height follows the route's shape. */+const SKETCH_WIDTH = 1000;+/** The room around everything, as a share of the longer side. */+const PADDING = 0.08;+/** The box of a sketch with a single point, which has no shape of its own. */+const POINT_HEIGHT = 400;+/** The tallest box a narrow route gets, so a line running north does not turn into a needle. */+const MAX_HEIGHT = 2000;++const RAD = Math.PI / 180;++/** Web Mercator's y for a latitude, in the units of a longitude in radians. */+export function mercatorY(lat: number): number {+ const clamped = Math.max(-85, Math.min(85, lat));+ return Math.log(Math.tan(Math.PI / 4 + (clamped * RAD) / 2));+}++interface SketchFrame {+ width: number;+ height: number;+ /** A point's place in the box: `x` to the east, `y` down. */+ project(lat: number, lng: number): [number, number];+}++/** The frame of everything a sketch draws, or null when it holds no point at all. */+export function sketchFrame(lines: readonly SketchLine[], marks: readonly SketchMark[]): SketchFrame | null {+ const points: [number, number][] = [+ ...lines.flatMap((line) => line.points.map(([lat, lng]): [number, number] => [lng * RAD, mercatorY(lat)])),+ ...marks.map((mark): [number, number] => [mark.lng * RAD, mercatorY(mark.lat)]),+ ];+ if (points.length === 0) return null;+ const xs = points.map(([x]) => x);+ const ys = points.map(([, y]) => y);+ const minX = Math.min(...xs);+ const maxY = Math.max(...ys);+ const spanX = Math.max(...xs) - minX;+ const spanY = maxY - Math.min(...ys);+ const side = Math.max(spanX, spanY);+ if (side === 0) {+ return { width: SKETCH_WIDTH, height: POINT_HEIGHT, project: () => [SKETCH_WIDTH / 2, POINT_HEIGHT / 2] };+ }+ const pad = side * PADDING;+ const scale = SKETCH_WIDTH / (spanX + 2 * pad);+ const height = Math.min(MAX_HEIGHT, Math.round((spanY + 2 * pad) * scale));+ return {+ width: SKETCH_WIDTH,+ height,+ project: (lat, lng) => [(lng * RAD - minX + pad) * scale, (maxY - mercatorY(lat) + pad) * scale],+ };+}++/** A line as an SVG `points` list in the frame, rounded to a tenth of a unit. */+export function linePoints(frame: SketchFrame, points: SketchLine['points']): string {+ return points+ .map(([lat, lng]) => {+ const [x, y] = frame.project(lat, lng);+ return `${Math.round(x * 10) / 10},${Math.round(y * 10) / 10}`;+ })+ .join(' ');+}diff --git a/client/src/components/Assistant/cards/parts/useCardFormat.ts b/client/src/components/Assistant/cards/parts/useCardFormat.tsnew file mode 100644index 000000000..6432efc7b--- /dev/null+++ b/client/src/components/Assistant/cards/parts/useCardFormat.ts@@ -0,0 +1,42 @@+import type { CardMoney } from '@trek/shared';+import { useMemo } from 'react';++import { useTranslation } from '../../../../i18n';+import { useSettingsStore } from '../../../../store/settingsStore';+import { formatClockTime, formatDate, formatMoney } from '../../../../utils/formatters';+import { formatDistance, formatElevation } from '../../../../utils/units';++/**+ * How a card writes its numbers, the way the rest of TREK does for this+ * user: dates in their language, clock times in their 12 or 24 hour setting,+ * money in its currency's own convention, distances and heights in their+ * units. A card hands these to its words as `{value}`, never a raw number.+ */+export function useCardFormat() {+ const { locale } = useTranslation();+ const twelveHour = useSettingsStore((s) => s.settings.time_format === '12h');+ const unit = useSettingsStore((s) => s.settings.distance_unit ?? 'metric');+ return useMemo(() => {+ const number = new Intl.NumberFormat(locale);+ const hours = new Intl.NumberFormat(locale, { style: 'unit', unit: 'hour', unitDisplay: 'narrow' });+ const mins = new Intl.NumberFormat(locale, { style: 'unit', unit: 'minute', unitDisplay: 'narrow' });+ return {+ /** "Sat 12 Oct" from `YYYY-MM-DD`, the year only when it is not this one. */+ date: (value: string) => formatDate(value, locale) ?? value,+ /** "14:30" or "2:30 PM" from `HH:MM`. */+ clock: (value: string) => formatClockTime(value, twelveHour),+ money: (value: CardMoney) => formatMoney(value.amount, value.currency, locale),+ distance: (km: number) => formatDistance(km, unit),+ elevation: (meters: number) => formatElevation(meters, unit),+ /** "2h 15min" from minutes, the hours left out below one. */+ minutes: (value: number) => {+ const total = Math.max(0, Math.round(value));+ const h = Math.floor(total / 60);+ const m = total % 60;+ if (h === 0) return mins.format(m);+ return m === 0 ? hours.format(h) : `${hours.format(h)} ${mins.format(m)}`;+ },+ count: (value: number) => number.format(value),+ };+ }, [locale, twelveHour, unit]);+}diff --git a/client/src/components/Assistant/cards/parts/useCardPoint.ts b/client/src/components/Assistant/cards/parts/useCardPoint.tsnew file mode 100644index 000000000..6539102a1--- /dev/null+++ b/client/src/components/Assistant/cards/parts/useCardPoint.ts@@ -0,0 +1,47 @@+import { useCallback, useEffect } from 'react';++import { useAssistantStore } from '../../../../store/assistantStore';+import { useAssistantView } from '../../assistantViewContext';++/** A spot a card points at: its own key, where it is and its name; `placeId` when it is a place of the trip. */+interface CardPoint {+ ref: string;+ lat: number;+ lng: number;+ name: string;+ placeId?: number;+}++/**+ * A card's part of the map: while the pointer rests on a row its spot shows+ * as a pin (a place of the trip pulses its own pin), and a click moves the+ * map there, after the chat stepped aside where it covers the map (the+ * phone). The pin goes when the card does.+ */+export function useCardPoint() {+ const { tripId, onRevealMap } = useAssistantView();+ const requestCamera = useAssistantStore((s) => s.requestCamera);+ const setPreviewPin = useAssistantStore((s) => s.setPreviewPin);++ // Stable, so a card can take the pin away when it goes.+ const hover = useCallback(+ (point: CardPoint | null) => {+ if (point) setPreviewPin({ tripId, ...point });+ else setPreviewPin(null);+ },+ [tripId, setPreviewPin]+ );++ /** Shows the spot on the map; on the phone the chat steps aside first. */+ const show = useCallback(+ (point: { lat: number; lng: number }) => {+ onRevealMap?.();+ requestCamera(tripId, [[point.lat, point.lng]], 'pan', 'user');+ },+ [tripId, onRevealMap, requestCamera]+ );++ useEffect(() => () => setPreviewPin(null), [setPreviewPin]);++ return { hover, show };+}diff --git a/client/src/components/Assistant/cards/parts/useCardStrip.ts b/client/src/components/Assistant/cards/parts/useCardStrip.tsnew file mode 100644index 000000000..f5dd5e33e--- /dev/null+++ b/client/src/components/Assistant/cards/parts/useCardStrip.ts@@ -0,0 +1,54 @@+import { useCallback, useEffect, useRef, useState } from 'react';++/** How far the strip has scrolled from either end, with the reading direction in mind. */+function edgesOf(el: HTMLElement): { start: boolean; end: boolean } {+ // A right-to-left strip scrolls into negative numbers; the distance from the start is the same either way.+ const from = Math.abs(el.scrollLeft);+ return { start: from > 4, end: from + el.clientWidth < el.scrollWidth - 4 };+}++/**+ * What a strip of cards needs to scroll well: whether there is more towards+ * either end (the edges fade there), measured again when it scrolls, when it+ * changes size and when `watch` (its content) changes, and paging by whole+ * cards.+ */+export function useCardStrip(watch: unknown) {+ const listRef = useRef<HTMLUListElement>(null);+ const [fade, setFade] = useState({ start: false, end: false });++ const measure = useCallback(() => {+ const el = listRef.current;+ if (!el) return;+ const next = edgesOf(el);+ setFade((prev) => (prev.start === next.start && prev.end === next.end ? prev : next));+ }, []);++ useEffect(() => {+ measure();+ const el = listRef.current;+ if (!el || typeof ResizeObserver === 'undefined') return;+ const observer = new ResizeObserver(measure);+ observer.observe(el);+ return () => observer.disconnect();+ }, [measure, watch]);++ /**+ * Scrolls by as many whole cards as the view holds, towards the start (-1)+ * or the end (1), so the row lands on a card edge instead of fighting its+ * snap points half way; smoothly, unless motion is turned down.+ */+ const page = (towards: -1 | 1) => {+ const el = listRef.current;+ const card = el?.firstElementChild as HTMLElement | null;+ if (!el || !card) return;+ const gap = Number.parseFloat(getComputedStyle(el).columnGap) || 0;+ const step = card.offsetWidth + gap;+ const cards = Math.max(1, Math.floor((el.clientWidth - 32) / step));+ const rtl = getComputedStyle(el).direction === 'rtl';+ // Smooth through the strip's own scroll-behavior, which reduced motion turns off.+ el.scrollBy((rtl ? -towards : towards) * cards * step, 0);+ };++ return { listRef, fade, measure, page };+}diff --git a/client/src/components/Assistant/cards/parts/useViewerId.ts b/client/src/components/Assistant/cards/parts/useViewerId.tsnew file mode 100644index 000000000..92beb045b--- /dev/null+++ b/client/src/components/Assistant/cards/parts/useViewerId.ts@@ -0,0 +1,6 @@+import { useAuthStore } from '../../../../store/authStore';++/** The signed-in user's id, which a card compares its people with; cards never say "me" themselves. */+export function useViewerId(): number | null {+ return useAuthStore((s) => s.user?.id ?? null);+}diff --git a/client/src/components/Assistant/cards/roadtrip/roadtripLook.ts b/client/src/components/Assistant/cards/roadtrip/roadtripLook.tsnew file mode 100644index 000000000..dbead6d7f--- /dev/null+++ b/client/src/components/Assistant/cards/roadtrip/roadtripLook.ts@@ -0,0 +1,22 @@+import type { PackLook } from '../cardTypes';++/**+ * What the road trip brings to the chat's pure look: the verbs, tool names and+ * steps it adds, what an applied change of its own opens, and the look of each+ * of its kinds. Empty until the road trip cards fill it. A look stays pure,+ * icons and literals only: the chat's main chunk reads every look, so whatever+ * a look imports ships with it.+ */+export const ROADTRIP_LOOK = {+ verbs: {},+ tools: {},+ steps: {},+ entities: {},+ cards: {+ roadtrip: {},+ corridor: {},+ charging: {},+ transit: {},+ dayRoute: {},+ },+} satisfies PackLook<'roadtrip' | 'corridor' | 'charging' | 'transit' | 'dayRoute'>;diff --git a/client/src/components/Assistant/cards/roadtrip/roadtripViews.tsx b/client/src/components/Assistant/cards/roadtrip/roadtripViews.tsxnew file mode 100644index 000000000..364fdedec--- /dev/null+++ b/client/src/components/Assistant/cards/roadtrip/roadtripViews.tsx@@ -0,0 +1,16 @@+import { type CardView, PENDING_VIEW } from '../cardTypes';++/**+ * How the kinds of the road trip draw in the chat; each one draws nothing until+ * its cards are built. This file only maps each kind to its view: the+ * components live in sibling files, since a file that exports anything besides+ * components breaks fast refresh, and lint:warnings holds+ * react-refresh/only-export-components at zero for a new file.+ */+export const ROADTRIP_VIEWS = {+ roadtrip: PENDING_VIEW,+ corridor: PENDING_VIEW,+ charging: PENDING_VIEW,+ transit: PENDING_VIEW,+ dayRoute: PENDING_VIEW,+} satisfies { [K in 'roadtrip' | 'corridor' | 'charging' | 'transit' | 'dayRoute']: CardView<K> };diff --git a/client/src/components/Assistant/cards/tour/tourLook.ts b/client/src/components/Assistant/cards/tour/tourLook.tsnew file mode 100644index 000000000..7573facc3--- /dev/null+++ b/client/src/components/Assistant/cards/tour/tourLook.ts@@ -0,0 +1,23 @@+import { Route } from 'lucide-react';++import type { PackLook } from '../cardTypes';++/**+ * What the tours bring to the chat's pure look: the verbs, tool names and steps+ * they add, what an applied change of theirs opens, and the look of each of+ * their kinds. An applied tour has no way to open yet, as before. A look stays+ * pure, icons and literals only: the chat's main chunk reads every look, so+ * whatever a look imports ships with it.+ */+export const TOUR_LOOK = {+ verbs: {},+ tools: {},+ steps: {},+ entities: {+ tour: { Icon: Route },+ },+ cards: {+ tourRoute: {},+ tourList: {},+ },+} satisfies PackLook<'tourRoute' | 'tourList'>;diff --git a/client/src/components/Assistant/cards/tour/tourViews.tsx b/client/src/components/Assistant/cards/tour/tourViews.tsxnew file mode 100644index 000000000..622505eff--- /dev/null+++ b/client/src/components/Assistant/cards/tour/tourViews.tsx@@ -0,0 +1,13 @@+import { type CardView, PENDING_VIEW } from '../cardTypes';++/**+ * How the kinds of the tours draw in the chat; each one draws nothing until its+ * cards are built. This file only maps each kind to its view: the components+ * live in sibling files, since a file that exports anything besides components+ * breaks fast refresh, and lint:warnings holds+ * react-refresh/only-export-components at zero for a new file.+ */+export const TOUR_VIEWS = {+ tourRoute: PENDING_VIEW,+ tourList: PENDING_VIEW,+} satisfies { [K in 'tourRoute' | 'tourList']: CardView<K> };diff --git a/client/src/components/Assistant/cards/useChangeExclusions.ts b/client/src/components/Assistant/cards/useChangeExclusions.tsnew file mode 100644index 000000000..9ba4ae1fa--- /dev/null+++ b/client/src/components/Assistant/cards/useChangeExclusions.ts@@ -0,0 +1,35 @@+import { type Dispatch, type SetStateAction, useState } from 'react';++import type { ChangeItem } from '../assistantParts';+import { viewOf } from './cardViews';++/** The waiting changes whose view leaves them off at first, among those not seen yet. */+function startingOff(items: readonly ChangeItem[], seen: ReadonlySet<string>): string[] {+ return items.flatMap((item) =>+ item.state === 'pending' && item.card && !seen.has(item.toolCallId) && viewOf(item.card).startsExcluded?.(item.card)+ ? [item.toolCallId]+ : []+ );+}++/** The changes whose preview has arrived: from then on the user's choice is theirs alone. */+const arrived = (items: readonly ChangeItem[]) => items.flatMap((item) => (item.preview ? [item.toolCallId] : []));++/**+ * The changes the user left off on a card. A change whose view says it+ * starts off (an optional extra the user opts into) is left off once, when+ * its preview arrives; after that only the user switches it.+ */+export function useChangeExclusions(+ items: readonly ChangeItem[]+): [ReadonlySet<string>, Dispatch<SetStateAction<ReadonlySet<string>>>] {+ const [excluded, setExcluded] = useState<ReadonlySet<string>>(() => new Set(startingOff(items, new Set())));+ const [seen, setSeen] = useState<ReadonlySet<string>>(() => new Set(arrived(items)));+ const fresh = arrived(items).filter((id) => !seen.has(id));+ if (fresh.length > 0) {+ const off = startingOff(items, seen);+ setSeen(new Set([...seen, ...fresh]));+ if (off.length > 0) setExcluded((prev) => new Set([...prev, ...off]));+ }+ return [excluded, setExcluded];+}diff --git a/client/src/components/Assistant/cards/vacay/vacayLook.ts b/client/src/components/Assistant/cards/vacay/vacayLook.tsnew file mode 100644index 000000000..da3d1de6f--- /dev/null+++ b/client/src/components/Assistant/cards/vacay/vacayLook.ts@@ -0,0 +1,18 @@+import type { PackLook } from '../cardTypes';++/**+ * What the vacation planner brings to the chat's pure look: the verbs, tool+ * names and steps it adds, what an applied change of its own opens, and the+ * look of each of its kinds. Empty until the vacation cards fill it. A look+ * stays pure, icons and literals only: the chat's main chunk reads every look,+ * so whatever a look imports ships with it.+ */+export const VACAY_LOOK = {+ verbs: {},+ tools: {},+ steps: {},+ entities: {},+ cards: {+ vacay: {},+ },+} satisfies PackLook<'vacay'>;diff --git a/client/src/components/Assistant/cards/vacay/vacayViews.tsx b/client/src/components/Assistant/cards/vacay/vacayViews.tsxnew file mode 100644index 000000000..25b445e6c--- /dev/null+++ b/client/src/components/Assistant/cards/vacay/vacayViews.tsx@@ -0,0 +1,12 @@+import { type CardView, PENDING_VIEW } from '../cardTypes';++/**+ * How the kinds of the vacation planner draw in the chat; each one draws+ * nothing until its cards are built. This file only maps each kind to its view:+ * the components live in sibling files, since a file that exports anything+ * besides components breaks fast refresh, and lint:warnings holds+ * react-refresh/only-export-components at zero for a new file.+ */+export const VACAY_VIEWS = {+ vacay: PENDING_VIEW,+} satisfies { [K in 'vacay']: CardView<K> };diff --git a/client/src/components/Assistant/useAssistantPlaceStrip.ts b/client/src/components/Assistant/useAssistantPlaceStrip.tsindex b03bbb08b..f88cf8325 100644--- a/client/src/components/Assistant/useAssistantPlaceStrip.ts+++ b/client/src/components/Assistant/useAssistantPlaceStrip.ts@@ -15,6 +15,7 @@ import { safeHexColor } from '../../utils/safeColor';import { formatDistance } from '../../utils/units';import { hasUndecided } from './assistantParts';import { useAssistantView } from './assistantViewContext';+import { useCardPoint } from './cards/parts/useCardPoint';/** A day a found place can be suggested for, named the way the day list names it. */interface StripDay {@@ -64,7 +65,7 @@ function lastSpot(stops: readonly Assignment[] | undefined): { lat: number; lng:*/export function useAssistantPlaceStrip() {const { t, locale } = useTranslation();- const { tripId, onRevealMap } = useAssistantView();+ const { tripId } = useAssistantView();const { offline } = useNetworkMode();const can = useCanDo();const unit = useSettingsStore((s) => s.settings.distance_unit ?? 'metric');@@ -91,8 +92,7 @@ export function useAssistantPlaceStrip() {}));const addFoundPlace = useAssistantStore((s) => s.addFoundPlace);- const requestCamera = useAssistantStore((s) => s.requestCamera);- const setPreviewPin = useAssistantStore((s) => s.setPreviewPin);+ const point = useCardPoint();const [adding, setAdding] = useState<string | null>(null);const stripDays = useMemo(@@ -137,18 +137,14 @@ export function useAssistantPlaceStrip() {};/** Shows the place on the map; on the phone the chat steps aside first. */- const show = (place: AssistantFoundPlace) => {- onRevealMap?.();- requestCamera(tripId, [[place.lat, place.lng]], 'pan', 'user');- };+ const show = point.show;- // Stable, so the strip can take the pin away when it goes.+ // The pin goes with the strip: the card point takes it away when it unmounts.+ const { hover: hoverPoint } = point;const hover = useCallback(- (place: AssistantFoundPlace | null) => {- if (place) setPreviewPin({ tripId, ref: place.ref, lat: place.lat, lng: place.lng, name: place.name });- else setPreviewPin(null);- },- [tripId, setPreviewPin]+ (place: AssistantFoundPlace | null) =>+ hoverPoint(place ? { ref: place.ref, lat: place.lat, lng: place.lng, name: place.name } : null),+ [hoverPoint]);return {diff --git a/client/src/components/Planner/bookings/bookingParts.tsx b/client/src/components/Planner/bookings/bookingParts.tsxindex 6cf7776c6..54bd1fa6b 100644--- a/client/src/components/Planner/bookings/bookingParts.tsx+++ b/client/src/components/Planner/bookings/bookingParts.tsx@@ -232,6 +232,18 @@ export function RoundAction({ label, onClick, children, danger = false }: { labe)}+/**+ * A traveller's round face: the picture where there is one, else the first+ * letter of the name on the accent. Sized and ringed by the caller.+ */+export function TravelerAvatar({ src, name, className = '', style }: { src: string | null; name?: string | null; className?: string; style?: CSSProperties }) {+ return (+ <span className={`grid flex-none place-items-center overflow-hidden rounded-full bg-accent font-bold text-accent-text ${className}`} style={{ ...fs(9), ...style }}>+ {src ? <img src={src} alt="" className="h-full w-full object-cover" /> : name?.[0]?.toUpperCase()}+ </span>+ )+}+/** Who a booking is for, as the phone shows them: avatar and name in a soft chip. */export function TravelerChips({ travelers }: { travelers: ReservationTraveler[] }) {if (travelers.length === 0) return null@@ -241,9 +253,7 @@ export function TravelerChips({ travelers }: { travelers: ReservationTraveler[]const src = tv.avatar_url || avatarSrc(tv.avatar)return (<span key={tv.user_id} className={`${BOX} flex items-center gap-1.5 rounded-full py-[3px] ps-[3px] pe-2.5`}>- <span className="grid h-5 w-5 flex-none place-items-center overflow-hidden rounded-full bg-accent font-bold text-accent-text" style={fs(9)}>- {src ? <img src={src} alt="" className="h-full w-full object-cover" /> : tv.username?.[0]?.toUpperCase()}- </span>+ <TravelerAvatar src={src} name={tv.username} className="h-5 w-5" /><span className="truncate font-semibold text-content" style={fs(12, 'body')}>{tv.username}</span>{!!tv.is_guest && <GuestBadge size="xs" customTooltip />}</span>@@ -263,9 +273,7 @@ export function TravelerStack({ travelers, max = 3 }: { travelers: ReservationTr{travelers.slice(0, max).map((tv, i) => {const src = tv.avatar_url || avatarSrc(tv.avatar)return (- <span key={tv.user_id} className="grid h-[22px] w-[22px] flex-none place-items-center overflow-hidden rounded-full border-2 border-surface-card bg-accent font-bold text-accent-text" style={{ ...fs(9), marginInlineStart: i ? -7 : 0 }}>- {src ? <img src={src} alt="" className="h-full w-full object-cover" /> : tv.username?.[0]?.toUpperCase()}- </span>+ <TravelerAvatar key={tv.user_id} src={src} name={tv.username} className="h-[22px] w-[22px] border-2 border-surface-card" style={{ marginInlineStart: i ? -7 : 0 }} />)})}{travelers.length > max && <span className="ms-1 font-geist font-semibold text-content-faint" style={fs(10.5)}>+{travelers.length - max}</span>}diff --git a/client/src/components/Planner/planParts.tsx b/client/src/components/Planner/planParts.tsxindex 136aa5766..8dc146858 100644--- a/client/src/components/Planner/planParts.tsx+++ b/client/src/components/Planner/planParts.tsx@@ -105,7 +105,7 @@ export function TimePill({ children, className = '', quiet = false }: { childrenreturn <WhiteBadge className={className} quiet={quiet} icon={<Clock size={10} strokeWidth={2.2} className="flex-none text-content-faint" />}>{children}</WhiteBadge>}-type PillTone = 'neutral' | 'success' | 'warning' | 'danger' | 'info' | 'accent'+export type PillTone = 'neutral' | 'success' | 'warning' | 'danger' | 'info' | 'accent'// White badges on whatever tint the row has; the tone only colours the words and the icon.const PILL_TONES: Record<PillTone, string> = {diff --git a/client/src/mobile/screens/trip/assistant/MAssistantScreen.tsx b/client/src/mobile/screens/trip/assistant/MAssistantScreen.tsxindex 3a9346429..f605bc916 100644--- a/client/src/mobile/screens/trip/assistant/MAssistantScreen.tsx+++ b/client/src/mobile/screens/trip/assistant/MAssistantScreen.tsx@@ -1,4 +1,3 @@-import type { AssistantApplied } from '@trek/shared';import {ChevronLeft,Ellipsis,@@ -12,13 +11,13 @@ import {Trash2,} from 'lucide-react';import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';-import { useNavigate } from 'react-router';+import { useNavigate, useSearchParams } from 'react-router';import AssistantCompareSwitch from '../../../../components/Assistant/AssistantCompareSwitch';import AssistantMemoryDialog from '../../../../components/Assistant/AssistantMemoryDialog';import AssistantSurfaceLazy from '../../../../components/Assistant/AssistantSurfaceLazy';import { AI_SETTINGS_PATH } from '../../../../components/Assistant/assistantParts';-import { showOnMapTarget } from '../../../../components/Assistant/assistantShowOnMap';+import type { EntityTarget } from '../../../../components/Assistant/cards/cardTypes';import { useAssistantHintsSetting } from '../../../../components/Assistant/useAssistantHints';import { useAssistantLiveStep } from '../../../../components/Assistant/useAssistantLiveStep';import { useAssistantThread } from '../../../../components/Assistant/useAssistantThread';@@ -71,10 +70,10 @@ function useBackCloses(open: boolean, onClose: () => void): void {}, [open]);}-/** The ways the chat hands the screen to the map. */+/** The ways the chat hands the screen to the map, a tab of the trip or another page. */interface MapHops {- /** "Show on map" on an applied change: the change is selected there. */- showOnMap: (applied: AssistantApplied) => void;+ /** What a card or an applied change points at: selected on the map, a tab opened, a page navigated to. */+ open: (target: EntityTarget) => void;/** A day picked in the chat (its weather): the day is selected. */focusDay: (dayId: number) => void;/** Before the map moves to something the chat points at, such as a found place. */@@ -84,21 +83,52 @@ interface MapHops {/*** Whatever the chat shows on the map, the chat steps aside to a pill and the* map comes up on the plan tab, then the change or the day is selected there.- * Read through a ref, so the chat does not re-render with every render of the- * trip screen.+ * A tab of the trip opens the same way, on its own sub-tab where it has one,+ * with what it reads beside it in the URL; another page leaves the trip, and+ * the chat closes with it. Read through a ref, so the chat does not re-render+ * with every render of the trip screen.*/function useMapHops({ planner, shell }: MTripSheetsProps): MapHops {+ const navigate = useNavigate();+ const [, setSearchParams] = useSearchParams();const setMinimized = useAssistantStore((s) => s.setMinimized);+ const close = useAssistantStore((s) => s.close);const reveal = () => {setMinimized(true);if (shell.trTab !== 'plan') shell.setTrTab('plan');if (shell.view !== 'map') shell.toggleView();};- const show = (applied: AssistantApplied) => {- const { placeId, dayId } = showOnMapTarget(applied);+ const toTab = ({ tab, sub, params }: Extract<EntityTarget, { kind: 'tab' }>) => {+ setMinimized(true);+ shell.setTrTab(tab);+ if (tab === 'listen' && (sub === 'packing' || sub === 'todo')) shell.setListsTab(sub);+ if (tab === 'collab' && (sub === 'chat' || sub === 'notes' || sub === 'links' || sub === 'polls')) {+ shell.setCollabTab(sub);+ }+ const entries = Object.entries(params ?? {});+ if (entries.length > 0) {+ setSearchParams(+ (current) => {+ for (const [key, value] of entries) current.set(key, value);+ return current;+ },+ { replace: true }+ );+ }+ };+ const show = (target: EntityTarget) => {+ if (target.kind === 'page') {+ close();+ void navigate(target.path);+ return;+ }+ if (target.kind === 'tab') {+ toTab(target);+ return;+ }reveal();- if (dayId !== null) planner.handleSelectDay(dayId, false);- if (placeId !== null) planner.setSelectedPlaceId(placeId);+ if (target.dayId !== null) planner.handleSelectDay(target.dayId, false);+ if (target.placeId !== null) planner.setSelectedPlaceId(target.placeId);};const focus = (dayId: number) => {reveal();@@ -108,10 +138,10 @@ function useMapHops({ planner, shell }: MTripSheetsProps): MapHops {useLayoutEffect(() => {latest.current = { reveal, show, focus };});- const showOnMap = useCallback((applied: AssistantApplied) => latest.current.show(applied), []);+ const open = useCallback((target: EntityTarget) => latest.current.show(target), []);const focusDay = useCallback((dayId: number) => latest.current.focus(dayId), []);const revealMap = useCallback(() => latest.current.reveal(), []);- return useMemo(() => ({ showOnMap, focusDay, revealMap }), [showOnMap, focusDay, revealMap]);+ return useMemo(() => ({ open, focusDay, revealMap }), [open, focusDay, revealMap]);}interface ScreenProps {@@ -251,7 +281,7 @@ function AssistantScreen({ tripId, tripTitle, hidden, hops }: ScreenProps) {tripId={tripId}tripTitle={tripTitle}variant="fullscreen"- onShowOnMap={hops.showOnMap}+ onOpen={hops.open}onFocusDay={hops.focusDay}onRevealMap={hops.revealMap}/>diff --git a/client/src/pages/tripPlanner/deepLinks/deepLinkTypes.ts b/client/src/pages/tripPlanner/deepLinks/deepLinkTypes.tsnew file mode 100644index 000000000..9fd13c4a4--- /dev/null+++ b/client/src/pages/tripPlanner/deepLinks/deepLinkTypes.ts@@ -0,0 +1,15 @@+import type { PlannerSearchParams } from '../plannerTypes';+import type { useTourWorkspace } from '../useTourWorkspace';+import type { useTripPlanner } from '../useTripPlanner';++/**+ * What a part of TREK's deep link into the planner gets: the planner, the+ * tour workspace and the URL's query, so a link the chat opened (`?tour=`,+ * `?booking=`, `?stop=`) can be taken once and dropped.+ */+export interface DeepLinkProps {+ planner: ReturnType<typeof useTripPlanner>;+ workspace: ReturnType<typeof useTourWorkspace>;+ searchParams: PlannerSearchParams[0];+ setSearchParams: PlannerSearchParams[1];+}diff --git a/client/src/pages/tripPlanner/deepLinks/useBookingDeepLink.ts b/client/src/pages/tripPlanner/deepLinks/useBookingDeepLink.tsnew file mode 100644index 000000000..d98ad2b75--- /dev/null+++ b/client/src/pages/tripPlanner/deepLinks/useBookingDeepLink.ts@@ -0,0 +1,9 @@+import type { DeepLinkProps } from './deepLinkTypes';++/**+ * Where the bookings open a booking the chat points at. Nothing yet: the booking cards+ * fill it in, and until then the planner keeps its own links.+ */+export function useBookingDeepLink(_links: DeepLinkProps): void {+ // Filled in by the booking cards.+}diff --git a/client/src/pages/tripPlanner/deepLinks/useRoadtripDeepLink.ts b/client/src/pages/tripPlanner/deepLinks/useRoadtripDeepLink.tsnew file mode 100644index 000000000..f2c8dec4d--- /dev/null+++ b/client/src/pages/tripPlanner/deepLinks/useRoadtripDeepLink.ts@@ -0,0 +1,9 @@+import type { DeepLinkProps } from './deepLinkTypes';++/**+ * Where the road trip opens a stop or a day the chat points at. Nothing yet: the road trip cards+ * fill it in, and until then the planner keeps its own links.+ */+export function useRoadtripDeepLink(_links: DeepLinkProps): void {+ // Filled in by the road trip cards.+}diff --git a/client/src/pages/tripPlanner/deepLinks/useTourDeepLink.ts b/client/src/pages/tripPlanner/deepLinks/useTourDeepLink.tsnew file mode 100644index 000000000..4105d06fd--- /dev/null+++ b/client/src/pages/tripPlanner/deepLinks/useTourDeepLink.ts@@ -0,0 +1,9 @@+import type { DeepLinkProps } from './deepLinkTypes';++/**+ * Where the tours open a tour the chat points at (`?tour=`). Nothing yet: the tour cards+ * fill it in, and until then the planner keeps its own links.+ */+export function useTourDeepLink(_links: DeepLinkProps): void {+ // Filled in by the tour cards.+}diff --git a/client/src/pages/tripPlanner/useAssistantDeepLink.test.ts b/client/src/pages/tripPlanner/useAssistantDeepLink.test.tsindex 53b4c8e6c..8e4013b4d 100644--- a/client/src/pages/tripPlanner/useAssistantDeepLink.test.ts+++ b/client/src/pages/tripPlanner/useAssistantDeepLink.test.ts@@ -3,7 +3,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest';import { useAssistantStore } from '../../store/assistantStore';import type { Day } from '../../types';-import { useAssistantDeepLink } from './useAssistantDeepLink';+import { useAssistantDeepLink, useAssistantTabLink } from './useAssistantDeepLink';const day = (id: number, tripId = 5) => ({ id, trip_id: tripId }) as Day;@@ -59,3 +59,33 @@ describe('useAssistantDeepLink', () => {expect(useAssistantStore.getState().window.open).toBe(false);});});++describe('useAssistantTabLink', () => {+ function setupTab(query: string, activeTab: string) {+ const searchParams = new URLSearchParams(query);+ const setSearchParams = vi.fn((update: (params: URLSearchParams) => URLSearchParams) => update(searchParams));+ const selectTab = vi.fn();+ renderHook(() =>+ useAssistantTabLink({ searchParams, setSearchParams: setSearchParams as never, activeTab, selectTab })+ );+ return { searchParams, setSearchParams, selectTab };+ }++ it('FE-PLANNER-ASSISTLINK-005: a ?tab= the chat opens while the planner is open switches the tab, once', () => {+ const { searchParams, selectTab } = setupTab('tab=finanzplan&expense=7', 'plan');+ expect(selectTab).toHaveBeenCalledWith('finanzplan');+ expect(searchParams.has('tab')).toBe(false);+ // What the tab reads beside it stays for the tab to take.+ expect(searchParams.get('expense')).toBe('7');+ });++ it('FE-PLANNER-ASSISTLINK-006: the tab on screen is not switched again; a tab it cannot open is left alone', () => {+ const same = setupTab('tab=finanzplan', 'finanzplan');+ expect(same.selectTab).not.toHaveBeenCalled();+ expect(same.searchParams.has('tab')).toBe(false);++ const unknown = setupTab('tab=nowhere', 'plan');+ expect(unknown.selectTab).not.toHaveBeenCalled();+ expect(unknown.setSearchParams).not.toHaveBeenCalled();+ });+});diff --git a/client/src/pages/tripPlanner/useAssistantDeepLink.ts b/client/src/pages/tripPlanner/useAssistantDeepLink.tsindex 8d5046c3d..46187dde6 100644--- a/client/src/pages/tripPlanner/useAssistantDeepLink.ts+++ b/client/src/pages/tripPlanner/useAssistantDeepLink.ts@@ -1,5 +1,6 @@import { useEffect } from 'react';+import { isDeepLinkableTripTab } from '../../constants/tripTabs';import { useAssistantStore } from '../../store/assistantStore';import type { Day } from '../../types';import type { PlannerSearchParams } from './plannerTypes';@@ -50,3 +51,41 @@ export function useAssistantDeepLink({);}, [openRequested, requestedDay, known, dayDone, selectDay, setSearchParams]);}++interface AssistantTabLinkOptions {+ searchParams: PlannerSearchParams[0];+ setSearchParams: PlannerSearchParams[1];+ /** The tab on screen. */+ activeTab: string;+ /** Switches the planner's tab the way its tab bar does. */+ selectTab: (tabId: string) => void;+}++/**+ * `?tab=<id>` while the planner is already open: what a card in the chat+ * opens in another tab of this trip (`?tab=finanzplan&expense=7`). The+ * planner reads the tab once when it opens; this takes a later one live,+ * once, and then drops it from the URL. What the tab reads beside it stays+ * for that tab to take.+ */+export function useAssistantTabLink({+ searchParams,+ setSearchParams,+ activeTab,+ selectTab,+}: AssistantTabLinkOptions): void {+ const requested = searchParams.get('tab');+ const linkable = requested !== null && isDeepLinkableTripTab(requested);++ useEffect(() => {+ if (!linkable || requested === null) return;+ if (requested !== activeTab) selectTab(requested);+ setSearchParams(+ (params) => {+ params.delete('tab');+ return params;+ },+ { replace: true }+ );+ }, [linkable, requested, activeTab, selectTab, setSearchParams]);+}diff --git a/client/src/pages/tripPlanner/useAssistantEntityLinks.test.tsx b/client/src/pages/tripPlanner/useAssistantEntityLinks.test.tsxnew file mode 100644index 000000000..571b3b0e5--- /dev/null+++ b/client/src/pages/tripPlanner/useAssistantEntityLinks.test.tsx@@ -0,0 +1,45 @@+/**+ * FE-PLANNER-ENTITYLINK-001 to FE-PLANNER-ENTITYLINK-002+ *+ * The links the chat opens the planner with while it is on screen: another+ * tab of the trip switches there and leaves the URL, and the parts' own links+ * (tours, bookings, road trip) take nothing yet.+ */+import { renderHook } from '@testing-library/react';+import type { ReactNode } from 'react';+import { MemoryRouter, useLocation } from 'react-router';+import { describe, expect, it, vi } from 'vitest';++import { useAssistantEntityLinks } from './useAssistantEntityLinks';++type Options = Parameters<typeof useAssistantEntityLinks>[0];++function setup(path: string) {+ const planner = { activeTab: 'plan', handleTabChange: vi.fn() } as unknown as Options['planner'];+ const workspace = {} as Options['workspace'];+ const wrapper = ({ children }: { children: ReactNode }) => (+ <MemoryRouter initialEntries={[path]}>{children}</MemoryRouter>+ );+ const hook = renderHook(+ () => {+ useAssistantEntityLinks({ planner, workspace });+ return useLocation();+ },+ { wrapper }+ );+ return { planner, hook };+}++describe('useAssistantEntityLinks', () => {+ it('FE-PLANNER-ENTITYLINK-001: another tab switches there and leaves the URL, what it reads stays', () => {+ const { planner, hook } = setup('/trips/5?tab=finanzplan&expense=7');+ expect(planner.handleTabChange).toHaveBeenCalledWith('finanzplan');+ expect(hook.result.current.search).toBe('?expense=7');+ });++ it("FE-PLANNER-ENTITYLINK-002: the parts' own links take nothing yet, and nothing switches without a tab", () => {+ const { planner, hook } = setup('/trips/5?tour=12');+ expect(planner.handleTabChange).not.toHaveBeenCalled();+ expect(hook.result.current.search).toBe('?tour=12');+ });+});diff --git a/client/src/pages/tripPlanner/useAssistantEntityLinks.ts b/client/src/pages/tripPlanner/useAssistantEntityLinks.tsnew file mode 100644index 000000000..50a144c4a--- /dev/null+++ b/client/src/pages/tripPlanner/useAssistantEntityLinks.ts@@ -0,0 +1,33 @@+import { useSearchParams } from 'react-router';++import { useBookingDeepLink } from './deepLinks/useBookingDeepLink';+import { useRoadtripDeepLink } from './deepLinks/useRoadtripDeepLink';+import { useTourDeepLink } from './deepLinks/useTourDeepLink';+import { useAssistantTabLink } from './useAssistantDeepLink';+import type { useTourWorkspace } from './useTourWorkspace';+import type { useTripPlanner } from './useTripPlanner';++interface AssistantEntityLinkOptions {+ planner: ReturnType<typeof useTripPlanner>;+ workspace: ReturnType<typeof useTourWorkspace>;+}++/**+ * The links the chat opens the planner with while it is already on screen:+ * another tab of the trip (`?tab=`), and what each part of TREK opens in its+ * own tab (a tour, a booking, a stop of the road trip). Each is taken once+ * and then leaves the URL.+ */+export function useAssistantEntityLinks({ planner, workspace }: AssistantEntityLinkOptions): void {+ const [searchParams, setSearchParams] = useSearchParams();+ useAssistantTabLink({+ searchParams,+ setSearchParams,+ activeTab: planner.activeTab,+ selectTab: planner.handleTabChange,+ });+ const links = { planner, workspace, searchParams, setSearchParams };+ useTourDeepLink(links);+ useBookingDeepLink(links);+ useRoadtripDeepLink(links);+}diff --git a/client/src/pages/tripPlanner/useTripPlannerPage.ts b/client/src/pages/tripPlanner/useTripPlannerPage.tsindex ecb2d1dbc..ccffbbc3e 100644--- a/client/src/pages/tripPlanner/useTripPlannerPage.ts+++ b/client/src/pages/tripPlanner/useTripPlannerPage.ts@@ -11,6 +11,7 @@ import { usePlanMapViewport } from '../../hooks/usePlanMapViewport'import { usePaddleObstacleStore } from '../../store/paddleObstacleStore'import { useHighlightedRoute } from '../../components/Tours/bike/useHighlightedRoute'import { useLegVariantLines } from '../../components/Tours/planner/legVariantPaint'+import { useAssistantEntityLinks } from './useAssistantEntityLinks'import { useMapLocationSearch } from './useMapLocationSearch'import { usePlannerFocusPoints } from './usePlannerFocusPoints'import { useTripPlanner } from './useTripPlanner'@@ -33,8 +34,11 @@ export function useTripPlannerPage() {const canPlaceEdit = can('place_edit', trip)const canDayEdit = can('day_edit', trip)+ const workspace = useTourWorkspace(planner, canPlaceEdit, canDayEdit)const { tourPlanner, viewImportedTour, tourGpxImport, wandererBrowser, tourConversion, recordedTrack, trackPaddlePlan, paddleChecklist, skiClassification, tourDetailActions } =- useTourWorkspace(planner, canPlaceEdit, canDayEdit)+ workspace+ // What the chat opens in another tab of this trip, and in each part's own tab.+ useAssistantEntityLinks({ planner, workspace })const tourDetailOpenerRef = useRef<{ placeId: number; element: HTMLElement } | null>(null)const { focusPoints, lastPlanMapViewportRef } = usePlannerFocusPoints(activeTab, places, tourPlanner, wandererBrowser)diff --git a/client/src/repo/assistantRepo.foundPlaces.test.ts b/client/src/repo/assistantRepo.foundPlaces.test.tsindex 1b818ab13..11f91d569 100644--- a/client/src/repo/assistantRepo.foundPlaces.test.ts+++ b/client/src/repo/assistantRepo.foundPlaces.test.ts@@ -1,9 +1,10 @@/**- * FE-AI-REPO-FOUND-001 to 002+ * FE-AI-REPO-FOUND-001 to 004*- * "+ Day N" on a found place: the repo posts the place's handle and the day,- * parses the message the server answers with, and like every assistant call- * sends nothing while offline.+ * "+ Day N" on a found place, and "Plan this" on a card: the repo posts the+ * handle (the place, or the call whose card it was), parses the message the+ * server answers with, and like every assistant call sends nothing while+ * offline.*/import type { AssistantAddFoundPlaceResponse } from '@trek/shared';import { http, HttpResponse } from 'msw';@@ -52,3 +53,26 @@ describe('assistantRepo.addFoundPlace', () => {expect(call).not.toHaveBeenCalled();});});++describe('assistantRepo.takeProposal', () => {+ const PROPOSAL = { locale: 'en', timeZone: 'UTC', toolCallId: 'read-3' };++ it('FE-AI-REPO-FOUND-003: posts the call whose card it was, and parses the message it gets back', async () => {+ let sent: unknown = null;+ server.use(+ http.post('/api/trips/4/assistant/threads/7/proposals', async ({ request }) => {+ sent = await request.json();+ return HttpResponse.json(ANSWER);+ })+ );+ await expect(assistantRepo.takeProposal(4, 7, PROPOSAL)).resolves.toEqual(ANSWER);+ expect(sent).toEqual(PROPOSAL);+ });++ it('FE-AI-REPO-FOUND-004: refuses before a request while offline', async () => {+ setForcedOffline(true);+ const call = vi.spyOn(assistantApi, 'takeProposal');+ await expect(assistantRepo.takeProposal(4, 7, PROPOSAL)).rejects.toBeInstanceOf(OnlineOnlyError);+ expect(call).not.toHaveBeenCalled();+ });+});diff --git a/client/src/repo/assistantRepo.ts b/client/src/repo/assistantRepo.tsindex e958e6f9c..26d73a27c 100644--- a/client/src/repo/assistantRepo.ts+++ b/client/src/repo/assistantRepo.ts@@ -7,6 +7,7 @@ import {type AssistantChatRequest,type AssistantDecisionsRequest,type AssistantShareRequest,+ type AssistantTakeProposalRequest,} from '@trek/shared';import { assistantApi } from '../api/assistant';import { requireOnline } from './onlineOnly';@@ -78,6 +79,12 @@ export const assistantRepo = {return assistantAddFoundPlaceResponseSchema.parse(await assistantApi.addFoundPlace(tripId, threadId, body));},+ /** A proposal an answer showed as a card ("Plan this"), held as a change; no model runs for it. */+ async takeProposal(tripId: number, threadId: number, body: AssistantTakeProposalRequest) {+ requireOnline();+ return assistantAddFoundPlaceResponseSchema.parse(await assistantApi.takeProposal(tripId, threadId, body));+ },+/*** An answer posted to the trip chat, as the preview showed it. Online only* like the rest: a chat message sent later would land out of order betweendiff --git a/client/src/store/assistantMessages.cards.test.ts b/client/src/store/assistantMessages.cards.test.tsindex 3b18eb6fd..b222847c4 100644--- a/client/src/store/assistantMessages.cards.test.ts+++ b/client/src/store/assistantMessages.cards.test.ts@@ -1,12 +1,13 @@/**- * FE-AI-MSG-CARDS-001 to 002+ * FE-AI-MSG-CARDS-001 to 005** The places and the weather a step found are stored parts of the answer,* like a change card: they land in the message being written, and a chunk* sent again for the same search step replaces its part instead of adding a- * second strip.+ * second strip. A tool's card lands the same way, except an applied write's,+ * which joins the change that proposed it.*/-import type { AssistantMessage, AssistantPlaces } from '@trek/shared';+import type { AssistantMessage, AssistantPlaces, TrekCard } from '@trek/shared';import { describe, expect, it } from 'vitest';import { applyChunk } from './assistantMessages';@@ -69,4 +70,45 @@ describe('assistantMessages: cards in an answer', () => {);expect(messages[0]?.parts.map((p) => p.type)).toEqual(['data-trek-weather']);});++ const ROUTE: TrekCard = { kind: 'tourRoute' };+ const LIST: TrekCard = { kind: 'tourList' };+ const cardsOf = (message: AssistantMessage | undefined) =>+ message?.parts.flatMap((p) => (p.type === 'data-trek-card' ? [p.data] : [])) ?? [];++ it('FE-AI-MSG-CARDS-003: a read card lands in the answer, replaced when sent again; a null card is skipped', () => {+ let messages = started();+ messages = applyChunk(messages, { type: 'data-trek-card', data: { toolCallId: 'r1', card: ROUTE } }, NOW);+ messages = applyChunk(messages, { type: 'data-trek-card', data: { toolCallId: 'r1', card: LIST } }, NOW);+ messages = applyChunk(messages, { type: 'data-trek-card', data: { toolCallId: 'r2', card: null } }, NOW);+ expect(cardsOf(messages[0])).toEqual([{ toolCallId: 'r1', card: LIST }]);+ });++ it('FE-AI-MSG-CARDS-004: in the decisions stream an applied card joins the message that proposed the change', () => {+ const proposing: AssistantMessage = {+ id: 'msg-1',+ role: 'assistant',+ status: 'awaiting_approval',+ createdAt: NOW(),+ parts: [{ type: 'tool-call', toolCallId: 'w1', toolName: 'create_hike', args: {}, approval: { id: 'w1' } }],+ };+ let messages = applyChunk([proposing], { type: 'start', messageId: 'msg-2' }, NOW);+ messages = applyChunk(messages, { type: 'data-trek-card', data: { toolCallId: 'w1', card: ROUTE } }, NOW);+ expect(cardsOf(messages[0])).toEqual([{ toolCallId: 'w1', card: ROUTE }]);+ expect(cardsOf(messages[1])).toEqual([]);+ });++ it('FE-AI-MSG-CARDS-005: a card under a call that holds no change stays in the message being written', () => {+ const earlier: AssistantMessage = {+ id: 'msg-1',+ role: 'assistant',+ status: 'complete',+ createdAt: NOW(),+ parts: [{ type: 'tool-call', toolCallId: 'r1', toolName: 'list_tours', args: {} }],+ };+ let messages = applyChunk([earlier], { type: 'start', messageId: 'msg-2' }, NOW);+ messages = applyChunk(messages, { type: 'data-trek-card', data: { toolCallId: 'r1', card: LIST } }, NOW);+ expect(cardsOf(messages[0])).toEqual([]);+ expect(cardsOf(messages[1])).toEqual([{ toolCallId: 'r1', card: LIST }]);+ });});diff --git a/client/src/store/assistantMessages.ts b/client/src/store/assistantMessages.tsindex bace7d241..b324dc178 100644--- a/client/src/store/assistantMessages.ts+++ b/client/src/store/assistantMessages.ts@@ -1,5 +1,6 @@import type {AssistantApplied,+ AssistantCard,AssistantDecision,AssistantMessage,AssistantMessagePart,@@ -62,6 +63,8 @@ export function applyChunk(]);case 'data-trek-weather':return withCurrent(messages, now, (parts) => [...parts, { type: 'data-trek-weather', data: chunk.data }]);+ case 'data-trek-card':+ return chunk.data.card ? placeCard(messages, now, chunk.data) : messages;case 'finish':return withStatus(messages, (m) =>m.status === 'error' ? m.status : m.parts.some(isAwaitingDecision) ? 'awaiting_approval' : 'complete'@@ -205,6 +208,31 @@ function upsertCall(return withCurrent(messages, now, (parts) => [...parts, edit({ type: 'tool-call', toolCallId, toolName, args: {} })]);}+/**+ * Puts a card where it belongs: an applied write's next to the change that+ * proposed it (an earlier message, when the decisions stream sends it), a+ * read's into the message being written. A repeated card for the same call+ * replaces the one before.+ */+function placeCard(messages: AssistantMessage[], now: () => string, data: AssistantCard): AssistantMessage[] {+ const card: AssistantMessagePart = { type: 'data-trek-card', data };+ const keep = (parts: AssistantMessagePart[]) => [+ ...parts.filter((p) => !(p.type === 'data-trek-card' && p.data.toolCallId === data.toolCallId)),+ card,+ ];+ const at = findChange(messages, data.toolCallId);+ if (at < 0) return withCurrent(messages, now, keep);+ return messages.map((m, i) => (i === at ? { ...m, parts: keep(m.parts) } : m));+}++/** The message holding the change a call proposed, or -1. */+function findChange(messages: readonly AssistantMessage[], toolCallId: string): number {+ for (let i = messages.length - 1; i >= 0; i--) {+ if (messages[i]?.parts.some((p) => p.type === 'tool-call' && p.toolCallId === toolCallId && p.approval)) return i;+ }+ return -1;+}+/** Puts the receipt of an applied change next to its call, so the card and its receipt stay together. */function placeApplied(messages: AssistantMessage[], now: () => string, data: AssistantApplied): AssistantMessage[] {const receipt: AssistantMessagePart = { type: 'data-trek-applied', data };diff --git a/client/src/store/assistantStore.cards.test.ts b/client/src/store/assistantStore.cards.test.tsnew file mode 100644index 000000000..e9b3d2ac3--- /dev/null+++ b/client/src/store/assistantStore.cards.test.ts@@ -0,0 +1,102 @@+/**+ * FE-AI-STORE-CARDS-001 to FE-AI-STORE-CARDS-004+ *+ * What the store keeps for the cards: the spot of a route the card and the+ * map share, a line a card asks the map to draw, the route the phone peeks+ * at, the way picked per block, all gone when the chat closes or changes;+ * and "Plan this", which joins the held change to the answer it belongs to.+ */+import type { AssistantMessage } from '@trek/shared';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { assistantRepo } from '../repo/assistantRepo';+import { chatOf, useAssistantStore } from './assistantStore';++const TRIP = 4;+const INITIAL = useAssistantStore.getState();+const store = () => useAssistantStore.getState();+const focus = { distanceMeters: 1200, elevationMeters: 840, lat: 45.1, lng: 7.2, sampleIndex: 12 };++const answer = (parts: AssistantMessage['parts']): AssistantMessage => ({+ id: 'msg-1',+ role: 'assistant',+ status: 'complete',+ createdAt: '2026-10-22T08:00:00.000Z',+ parts,+});++function seedThread(messages: AssistantMessage[] = []) {+ useAssistantStore.setState({ byTrip: { [TRIP]: { ...chatOf(store(), TRIP), threadId: 7, messages } } });+}++beforeEach(() => useAssistantStore.setState(INITIAL, true));+afterEach(() => vi.restoreAllMocks());++describe('assistantStore: cards', () => {+ it('FE-AI-STORE-CARDS-001: a route spot changes only when it moves, and a line only when it is another one', () => {+ const seen = vi.fn();+ const stop = useAssistantStore.subscribe(seen);+ store().setRouteFocus({ tripId: TRIP, ref: 'r1', focus, source: 'card' });+ store().setRouteFocus({ tripId: TRIP, ref: 'r1', focus: { ...focus }, source: 'card' });+ expect(seen).toHaveBeenCalledTimes(1);+ store().setRouteFocus({ tripId: TRIP, ref: 'r1', focus: { ...focus, sampleIndex: 13 }, source: 'map' });+ expect(store().routeFocus?.source).toBe('map');++ const line = { tripId: TRIP, ref: 'day-2', lines: [[[45, 7] as [number, number]]], color: 'var(--accent)' };+ store().setRoutePreview(line);+ store().setRoutePreview({ ...line });+ store().setRoutePreview(null);+ store().setRoutePreview(null);+ expect(seen).toHaveBeenCalledTimes(4);+ expect(store().routePreview).toBeNull();+ stop();+ });++ it('FE-AI-STORE-CARDS-002: the way picked is kept per block of the chat', () => {+ seedThread();+ store().pick(TRIP, 'block-1', 'r2');+ store().pick(TRIP, 'block-2', 'r5');+ store().pick(TRIP, 'block-1', 'r3');+ expect(chatOf(store(), TRIP).picks).toEqual({ 'block-1': 'r3', 'block-2': 'r5' });+ });++ it('FE-AI-STORE-CARDS-003: closing, a new chat and another thread leave the map without the cards', async () => {+ const fill = () => {+ store().setRouteFocus({ tripId: TRIP, ref: 'r1', focus, source: 'card' });+ store().setRoutePreview({ tripId: TRIP, ref: 'day-2', lines: [], color: 'var(--accent)' });+ store().setRoutePeek({ tripId: TRIP, toolCallId: 'r1' });+ };+ const empty = () => ({ focus: store().routeFocus, line: store().routePreview, peek: store().routePeek });+ const none = { focus: null, line: null, peek: null };+ fill();+ expect(store().routePeek).toEqual({ tripId: TRIP, toolCallId: 'r1' });+ store().close();+ expect(empty()).toEqual(none);++ fill();+ store().newThread(TRIP);+ expect(empty()).toEqual(none);++ fill();+ vi.spyOn(assistantRepo, 'thread').mockResolvedValueOnce({ messages: [] } as never);+ const opening = store().openThread(TRIP, 9);+ expect(empty()).toEqual(none);+ await opening;+ });++ it('FE-AI-STORE-CARDS-004: "Plan this" joins the held change to its answer, and says why when it cannot', async () => {+ seedThread([answer([{ type: 'text', text: 'Three ways up.' }])]);+ const held = answer([+ { type: 'text', text: 'Three ways up.' },+ { type: 'tool-call', toolCallId: 'w1', toolName: 'create_hike', args: {}, approval: { id: 'w1' } },+ ]);+ const take = vi.spyOn(assistantRepo, 'takeProposal').mockResolvedValueOnce({ message: held });+ await store().takeProposal(TRIP, 'r1');+ expect(take).toHaveBeenCalledWith(TRIP, 7, expect.objectContaining({ toolCallId: 'r1' }));+ expect(chatOf(store(), TRIP).messages).toEqual([held]);++ vi.spyOn(assistantRepo, 'takeProposal').mockRejectedValueOnce({ response: { status: 429 } });+ await store().takeProposal(TRIP, 'r1');+ expect(chatOf(store(), TRIP).error).toBe('too_many_requests');+ });+});diff --git a/client/src/store/assistantStore.ts b/client/src/store/assistantStore.tsindex bd0cdce51..dad3b228d 100644--- a/client/src/store/assistantStore.ts+++ b/client/src/store/assistantStore.ts@@ -20,6 +20,7 @@ import { assistantRepo } from '../repo/assistantRepo';import { OnlineOnlyError } from '../repo/onlineOnly';import type { Assignment } from '../types';import { randomId } from '../utils/randomId';+import type { RouteProfileFocus } from '../utils/routeGeometry';import {blockDays,blockKeyOf,@@ -74,6 +75,8 @@ interface AssistantTripChat {compare: AssistantCompare | null;/** The days, places and bookings named with @ in the draft. */mentions: AssistantMentionItem[];+ /** The way picked among the ways a block of cards offers, by block. */+ picks: Record<string, string>;}/** A mention as the composer picked it, with the label it wrote into the text. */@@ -122,8 +125,17 @@ interface AssistantState {mapLink: { tripId: number; hoveredId: string | null; source: AssistantMapSource } | null;/** The latest request to move the map; `seq` tells a new one from the same points asked again. */camera: { tripId: number; seq: number; points: LatLng[]; mode: 'fit' | 'pan'; why: 'user' | 'auto' } | null;- /** A found place the pointer rests on, drawn on the map until it leaves. */- preview: { tripId: number; ref: string; lat: number; lng: number; name: string } | null;+ /**+ * A spot a card points at (a found place, a row), drawn on the map until+ * the pointer leaves; a place of the trip pulses its own pin instead.+ */+ preview: { tripId: number; ref: string; lat: number; lng: number; name: string; placeId?: number } | null;+ /** The point of a route a card and the map both show, from the card's profile or from the line on the map. */+ routeFocus: { tripId: number; ref: string; focus: RouteProfileFocus; source: 'card' | 'map' } | null;+ /** A line a card asks the map to draw while the pointer rests on it (a day of a drive, a saved tour). */+ routePreview: { tripId: number; ref: string; lines: LatLng[][]; color: string } | null;+ /** The route card the phone shows over the map. */+ routePeek: { tripId: number; toolCallId: string } | null;/** Where the floating window sits after its last move or resize, for the map to frame around it. */windowRect: WindowRect | null;/** The part of the planner's map on screen, sent with a question so "here" means it. */@@ -173,6 +185,14 @@ interface AssistantState {setPreviewPin: (preview: AssistantState['preview']) => void;setWindowRect: (rect: WindowRect | null) => void;setMapView: (mapView: AssistantState['mapView']) => void;++ setRouteFocus: (routeFocus: AssistantState['routeFocus']) => void;+ setRoutePreview: (routePreview: AssistantState['routePreview']) => void;+ setRoutePeek: (routePeek: AssistantState['routePeek']) => void;+ /** Picks one of the ways a block of cards offers. */+ pick: (tripId: number, blockKey: string, toolCallId: string) => void;+ /** Takes a proposal an answer showed as a card ("Plan this"); the server holds it as a change to decide. */+ takeProposal: (tripId: number, toolCallId: string) => Promise<void>;}const NO_LIVE: AssistantTripChat['live'] = { activity: null };@@ -192,8 +212,12 @@ const EMPTY_CHAT: AssistantTripChat = {undone: {},compare: null,mentions: [],+ picks: {},};+/** What the map shows for the cards of a chat, cleared when the chat closes or changes. */+const NO_ROUTE = { routeFocus: null, routePreview: null, routePeek: null } as const;+/** A trip's chat as the store holds it, or the empty one; stable, so a selector can return it. */export function chatOf(state: Pick<AssistantState, 'byTrip'>, tripId: number): AssistantTripChat {return state.byTrip[tripId] ?? EMPTY_CHAT;@@ -462,6 +486,7 @@ function shellActions(ctx: Ctx) {window: { open: false, minimized: false },mapLink: null,preview: null,+ ...NO_ROUTE,byTrip: backToAfter(s.byTrip),})),// Closed or minimized opens it; open closes it.@@ -487,6 +512,7 @@ function threadActions(ctx: Ctx) {const openThread = async (tripId: number, threadId: number) => {if (chat(ctx, tripId).isRunning) return;+ ctx.set(NO_ROUTE);patch(ctx, tripId, { threadId, loading: true, error: null, unsent: null });try {const { messages } = await assistantRepo.thread(tripId, threadId);@@ -510,6 +536,7 @@ function threadActions(ctx: Ctx) {const newThread = (tripId: number) => {chat(ctx, tripId).abort?.abort();+ ctx.set(NO_ROUTE);// The block a comparison belonged to leaves the screen with its thread.patch(ctx, tripId, {threadId: null,@@ -619,25 +646,43 @@ function compareActions(ctx: Ctx) {const points = [...dayPoints(compare.snapshot, days), ...dayPoints(useTripStore.getState().assignments, days)];requestCameraOn(ctx, tripId, points, 'fit', 'user');},- addFoundPlace: async (tripId: number, ref: string, dayId: number) => {- const threadId = chat(ctx, tripId).threadId;- if (chat(ctx, tripId).isRunning || threadId === null) return;- try {- const { message } = await assistantRepo.addFoundPlace(tripId, threadId, { ...clientContext(), ref, dayId });- const c = chat(ctx, tripId);- // The thread may have changed while the server answered. The server sends back the whole answer the- // card joined, under that answer's id, so it replaces the message it already holds.- if (c.threadId !== threadId) return;- const known = c.messages.some((m) => m.id === message.id);- const messages = known ? c.messages.map((m) => (m.id === message.id ? message : m)) : [...c.messages, message];- patch(ctx, tripId, { messages, error: null });- } catch (err) {- patch(ctx, tripId, { error: errorCodeOf(err) });- }- },+ addFoundPlace: (tripId: number, ref: string, dayId: number) =>+ holdWithoutTurn(ctx, tripId, (threadId) =>+ assistantRepo.addFoundPlace(tripId, threadId, { ...clientContext(), ref, dayId })+ ),+ takeProposal: (tripId: number, toolCallId: string) =>+ holdWithoutTurn(ctx, tripId, (threadId) =>+ assistantRepo.takeProposal(tripId, threadId, { ...clientContext(), toolCallId })+ ),};}+/**+ * A change the server holds without a model turn (a found place for a day, a+ * proposal a card showed), joined to the answer it belongs to. The server+ * sends back that whole answer under its id, so it replaces the message the+ * chat already holds.+ */+async function holdWithoutTurn(+ ctx: Ctx,+ tripId: number,+ hold: (threadId: number) => Promise<{ message: AssistantMessage }>+): Promise<void> {+ const threadId = chat(ctx, tripId).threadId;+ if (chat(ctx, tripId).isRunning || threadId === null) return;+ try {+ const { message } = await hold(threadId);+ const c = chat(ctx, tripId);+ // The thread may have changed while the server answered.+ if (c.threadId !== threadId) return;+ const known = c.messages.some((m) => m.id === message.id);+ const messages = known ? c.messages.map((m) => (m.id === message.id ? message : m)) : [...c.messages, message];+ patch(ctx, tripId, { messages, error: null });+ } catch (err) {+ patch(ctx, tripId, { error: errorCodeOf(err) });+ }+}+function requestCameraOn(ctx: Ctx, tripId: number, points: LatLng[], mode: 'fit' | 'pan', why: 'user' | 'auto') {if (points.length === 0) return;const seq = (ctx.get().camera?.seq ?? 0) + 1;@@ -665,6 +710,35 @@ function mapActions(ctx: Ctx) {};}+/** Whether two route focuses point at the same spot of the same route from the same side. */+function sameFocus(a: AssistantState['routeFocus'], b: AssistantState['routeFocus']): boolean {+ if (a === null || b === null) return a === b;+ return (+ a.tripId === b.tripId &&+ a.ref === b.ref &&+ a.source === b.source &&+ a.focus.sampleIndex === b.focus.sampleIndex &&+ a.focus.distanceMeters === b.focus.distanceMeters+ );+}++function routeActions(ctx: Ctx) {+ return {+ // Scrubbing repeats the same spot; only a change reaches the subscribers.+ setRouteFocus: (routeFocus: AssistantState['routeFocus']) => {+ if (!sameFocus(ctx.get().routeFocus, routeFocus)) ctx.set({ routeFocus });+ },+ setRoutePreview: (routePreview: AssistantState['routePreview']) => {+ const current = ctx.get().routePreview;+ if (current?.tripId === routePreview?.tripId && current?.ref === routePreview?.ref) return;+ ctx.set({ routePreview });+ },+ setRoutePeek: (routePeek: AssistantState['routePeek']) => ctx.set({ routePeek }),+ pick: (tripId: number, blockKey: string, toolCallId: string) =>+ patch(ctx, tripId, { picks: { ...chat(ctx, tripId).picks, [blockKey]: toolCallId } }),+ };+}+function turnActions(ctx: Ctx) {const retry = async (tripId: number) => {const c = chat(ctx, tripId);@@ -728,10 +802,12 @@ export const useAssistantStore = create<AssistantState>((set, get) => {preview: null,windowRect: null,mapView: null,+ ...NO_ROUTE,...shellActions(ctx),...threadActions(ctx),...turnActions(ctx),...compareActions(ctx),...mapActions(ctx),+ ...routeActions(ctx),};});diff --git a/client/src/types/assistantMap.ts b/client/src/types/assistantMap.tsnew file mode 100644index 000000000..e0f1df349--- /dev/null+++ b/client/src/types/assistantMap.ts@@ -0,0 +1,41 @@+import type { TrekCard } from '@trek/shared';++/**+ * What an assistant card asks the plan's map to draw, in the shapes the map+ * layers read. These sit below the views, so the store's map model and the+ * planner's map hooks share them with the cards' looks+ * (components/Assistant/cards/cardTypes.ts) without importing a view.+ */++/** Which lines of a card the plan's map draws: a waiting change, an answer to look at, the way it was before. */+export type RouteUse = 'pending' | 'look' | 'before';++/** A line a card asks the plan's map to draw beside the plan: points as `[lat, lng]`, colours as CSS values. */+export interface RouteLineSpec {+ id: string;+ lines: [number, number][][];+ color: string;+ casing?: string;+ dashed?: boolean;+ dim?: boolean;+}++/** A spot a card asks the plan's map to mark: a pin for a stop, a small point for a via. */+export interface GhostPoint {+ id: string;+ lat: number;+ lng: number;+ name: string;+ variant?: 'pin' | 'point';+}++/**+ * The map's side of every card's look, for the card in hand. A store may not+ * import a view, so the store's map model takes this as a parameter and the+ * planner's map hook hands it `CARD_MAP_LOOK` from the looks.+ */+export interface CardMapLook {+ lines(card: TrekCard, use: RouteUse): RouteLineSpec[];+ ghosts(card: TrekCard): GhostPoint[];+ hidesEffectGhost(card: TrekCard): boolean;+}diff --git a/client/tests/unit/mobile/trip/MAssistantScreen.test.tsx b/client/tests/unit/mobile/trip/MAssistantScreen.test.tsxindex ef2c32067..3032ec8ec 100644--- a/client/tests/unit/mobile/trip/MAssistantScreen.test.tsx+++ b/client/tests/unit/mobile/trip/MAssistantScreen.test.tsx@@ -1,19 +1,21 @@-import type { AiStatusResponse, AssistantApplied } from '@trek/shared';+import type { AiStatusResponse } from '@trek/shared';+import { useLocation } from 'react-router';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import type { EntityTarget } from '../../../../src/components/Assistant/cards/cardTypes';import MAssistantScreen from '../../../../src/mobile/screens/trip/assistant/MAssistantScreen';import { chatOf, useAssistantStore } from '../../../../src/store/assistantStore';import { buildPlanner, buildShell } from '../../../helpers/mobileTrip';import { act, cleanup, fireEvent, render, screen } from '../../../helpers/render';-// FE-MOB-ASSIST-001 to FE-MOB-ASSIST-011+// FE-MOB-ASSIST-001 to FE-MOB-ASSIST-014//// The phone's full-screen chat around the shared chat surface, which is// replaced here: what is tested is the frame, the header and the way to the// map and back.const surface = vi.hoisted(() => ({- onShowOnMap: null as ((applied: AssistantApplied) => void) | null,+ onOpen: null as ((target: EntityTarget) => void) | null,onFocusDay: null as ((dayId: number) => void) | null,onRevealMap: null as (() => void) | null,}));@@ -32,11 +34,11 @@ const thread = vi.hoisted(() => ({vi.mock('../../../../src/components/Assistant/AssistantSurfaceLazy', () => ({default: (props: {- onShowOnMap?: (applied: AssistantApplied) => void;+ onOpen?: (target: EntityTarget) => void;onFocusDay?: (dayId: number) => void;onRevealMap?: () => void;}) => {- surface.onShowOnMap = props.onShowOnMap ?? null;+ surface.onOpen = props.onOpen ?? null;surface.onFocusDay = props.onFocusDay ?? null;surface.onRevealMap = props.onRevealMap ?? null;return <div data-testid="chat-surface" />;@@ -50,10 +52,21 @@ vi.mock('../../../../src/components/Assistant/useAssistantThread', () => ({const INITIAL = useAssistantStore.getState();const STATUS = { available: true, retention: { mode: 'days', days: 90 } } as AiStatusResponse;-function renderScreen(plannerOverrides = {}, shellOverrides = {}) {+function Location() {+ const { pathname, search } = useLocation();+ return <output data-testid="location">{`${pathname}${search}`}</output>;+}++function renderScreen(plannerOverrides = {}, shellOverrides = {}, { withLocation = false } = {}) {const planner = buildPlanner(plannerOverrides);const shell = buildShell(shellOverrides);- const view = render(<MAssistantScreen planner={planner} shell={shell} />);+ const view = render(+ <>+ <MAssistantScreen planner={planner} shell={shell} />+ {withLocation && <Location />}+ </>,+ { initialEntries: ['/trips/1'] }+ );return { planner, shell, ...view };}@@ -123,7 +136,7 @@ describe('MAssistantScreen', () => {it('FE-MOB-ASSIST-007: "Show on map" steps aside for the map, and the pill brings the chat back as it was', () => {const { planner, shell } = renderScreen({}, { trTab: 'listen', view: 'plan' });- act(() => surface.onShowOnMap?.({ toolCallId: 'c1', entity: 'place', ids: [42], dayId: 2, undoUntil: null }));+ act(() => surface.onOpen?.({ kind: 'map', placeId: 42, dayId: null }));expect(useAssistantStore.getState().window).toEqual({ open: true, minimized: true });expect(shell.setTrTab).toHaveBeenCalledWith('plan');@@ -195,6 +208,39 @@ describe('MAssistantScreen', () => {expect(screen.getByRole('button', { name: 'After' })).toHaveAttribute('aria-pressed', 'true');});+ it('FE-MOB-ASSIST-012: a day on the map is selected there after the chat stepped aside', () => {+ const { planner, shell } = renderScreen({}, { trTab: 'plan', view: 'plan' });+ act(() => surface.onOpen?.({ kind: 'map', placeId: null, dayId: 5 }));+ expect(useAssistantStore.getState().window.minimized).toBe(true);+ expect(shell.toggleView).toHaveBeenCalled();+ expect(planner.handleSelectDay).toHaveBeenCalledWith(5, false);+ expect(planner.setSelectedPlaceId).not.toHaveBeenCalled();+ });++ it('FE-MOB-ASSIST-013: a tab opens on its own list or chat part, with what it reads in the URL', () => {+ const { shell } = renderScreen({}, { trTab: 'plan', view: 'map' }, { withLocation: true });+ act(() => surface.onOpen?.({ kind: 'tab', tab: 'listen', sub: 'todo', params: { todo: '4' } }));+ expect(useAssistantStore.getState().window.minimized).toBe(true);+ expect(shell.setTrTab).toHaveBeenCalledWith('listen');+ expect(shell.setListsTab).toHaveBeenCalledWith('todo');+ expect(shell.toggleView).not.toHaveBeenCalled();+ expect(screen.getByTestId('location')).toHaveTextContent('/trips/1?todo=4');++ act(() => surface.onOpen?.({ kind: 'tab', tab: 'collab', sub: 'polls' }));+ expect(shell.setTrTab).toHaveBeenLastCalledWith('collab');+ expect(shell.setCollabTab).toHaveBeenCalledWith('polls');+ // A sub-tab a tab does not have is left alone.+ act(() => surface.onOpen?.({ kind: 'tab', tab: 'collab', sub: 'packing' }));+ expect(shell.setCollabTab).toHaveBeenCalledTimes(1);+ });++ it('FE-MOB-ASSIST-014: another page leaves the trip, and the chat closes with it', () => {+ renderScreen({}, {}, { withLocation: true });+ act(() => surface.onOpen?.({ kind: 'page', path: '/atlas' }));+ expect(useAssistantStore.getState().window.open).toBe(false);+ expect(screen.getByTestId('location')).toHaveTextContent('/atlas');+ });+it('FE-MOB-ASSIST-008: the back gesture closes the chat instead of leaving the trip', () => {renderScreen();expect(window.history.state).toMatchObject({ trekAssistant: true });diff --git a/server/src/db/json-columns.ts b/server/src/db/json-columns.tsindex 8fd7c6dc4..0e6003f15 100644--- a/server/src/db/json-columns.ts+++ b/server/src/db/json-columns.ts@@ -3,7 +3,9 @@ import {FERRATAS_RESULT_CAP,dawarichTrackSegmentSchema,assistantChangePreviewSchema,- assistantMessagePartSchema,+ assistantChangePreviewWriteSchema,+ assistantMessagePartWriteSchema,+ assistantStoredPartsSchema,ferrataSchema,hikingPreferencesSchema,obstacleSnapshotSchema,@@ -335,12 +337,24 @@ export const JOURNEY_RECORDED_DAY_SEGMENTS: JsonColumn<DawarichTrackSegment[]> =/*** The parts of an assistant message as the client renders them: text, tool- * calls with their results and approvals, change previews and receipts. A- * broken row reads as an empty message and is logged.+ * calls with their results and approvals, change previews, receipts and+ * cards. A data part this build does not know (one a later build wrote) is+ * dropped on read, not the message, and a later verb, entity or card kind+ * reads as its generic stand-in; any other broken row reads as an empty+ * message and is logged. A row this build rewrites (a decision, a cancel)+ * is written back as it was read, so what only a later build knew is gone+ * from it for good: a rollback costs those cards, never the conversation.*/export const ASSISTANT_MESSAGE_PARTS: JsonColumn<AssistantMessagePart[]> = {column: 'assistant_messages.parts',- schema: z.array(assistantMessagePartSchema),+ schema: assistantStoredPartsSchema,+ fallback: () => [],+};++/** The same column as it is written: strictly, so a part this build cannot describe is a bug in the writer. */+export const ASSISTANT_MESSAGE_PARTS_WRITE: JsonColumn<AssistantMessagePart[]> = {+ column: ASSISTANT_MESSAGE_PARTS.column,+ schema: z.array(assistantMessagePartWriteSchema),fallback: () => [],};@@ -370,13 +384,20 @@ export const ASSISTANT_TOOL_ARGS: JsonColumn<Record<string, unknown>> = {fallback: () => ({}),};-/** The change card of a proposed change. A broken row reads as none. */+/** The change card of a proposed change. A broken row reads as none, a later verb or card kind as its stand-in. */export const ASSISTANT_TOOL_PREVIEW: JsonColumn<AssistantChangePreview | null> = {column: 'assistant_tool_calls.preview',schema: assistantChangePreviewSchema.nullable(),fallback: () => null,};+/** The same column as it is written: strictly, like the message parts. */+export const ASSISTANT_TOOL_PREVIEW_WRITE: JsonColumn<AssistantChangePreview | null> = {+ column: ASSISTANT_TOOL_PREVIEW.column,+ schema: assistantChangePreviewWriteSchema.nullable(),+ fallback: () => null,+};+/** What an executed change answered, the tool's own result. A broken row reads as none, which offers no undo. */export const ASSISTANT_TOOL_RESULT: JsonColumn<unknown> = {column: 'assistant_tool_calls.result',diff --git a/server/src/nest/airports/airports.module.ts b/server/src/nest/airports/airports.module.tsindex 99105365e..ad7c84d9c 100644--- a/server/src/nest/airports/airports.module.ts+++ b/server/src/nest/airports/airports.module.ts@@ -19,5 +19,7 @@ import { Module } from '@nestjs/common';imports: [MikroOrmModule.forFeature([Reservations, ReservationEndpoints]), SchedulingModule],controllers: [AirportsController],providers: [AirportsService, AirportsMcp],+ // The assistant's cards name an airport by its code (AssistantModule).+ exports: [AirportsService],})export class AirportsModule {}diff --git a/server/src/nest/assistant/assistant-agent.ts b/server/src/nest/assistant/assistant-agent.tsindex 7eb805fa5..7258a5084 100644--- a/server/src/nest/assistant/assistant-agent.ts+++ b/server/src/nest/assistant/assistant-agent.ts@@ -9,15 +9,18 @@ import {import { activityOf, foundPlacesOf, googleIdsOf, weatherDayOf, weatherOf } from './assistant-cards.helpers';import type { TripCard } from './assistant-context';import { outputText } from './assistant-history';-import { toolOutputForProvider } from './assistant-redact';-import { MAX_READS_PER_STEP, MAX_STEPS, MAX_WRITES_PER_STEP } from './assistant-tools.constants';+import { toolOutputForProvider } from './assistant-output';+import { MAX_CARDS_PER_STEP, MAX_READS_PER_STEP, MAX_STEPS, MAX_WRITES_PER_STEP } from './assistant-tools.constants';import type { AssistantToolKind, ToolRun } from './assistant-tools.service';+import type { AnswerInput } from './cards/card-types';+import { answerCardOf } from './cards/registry';import type { UiStreamWriter } from './ui-stream.writer';import type {AssistantChangePreview,AssistantErrorCode,AssistantMessagePart,AssistantWeatherDay,+ TrekCard,} from '@trek/shared';type ToolArgs = Record<string, unknown>;@@ -66,6 +69,8 @@ export interface AgentDeps {card: TripCard;/** Today in the user's time zone (`YYYY-MM-DD`). */today: string;+ /** The card a read's answer shows; the registry's (`answerCardOf`) unless a test hands in its own. */+ answerCard?: (tool: string, input: AnswerInput) => TrekCard | null;}export interface AgentInput {@@ -96,8 +101,13 @@ interface StepParts {weather: AssistantWeatherDay[];/** The google place ids the turn has seen so far; a search adds what it found. */knownPlaceIds: Set<string>;+ /** The answer cards the step has shown; past MAX_CARDS_PER_STEP a read shows none. */+ cards: number;}+/** The longest call id a card is kept under; a read under a longer one shows no card. */+const MAX_CARD_CALL_ID = 64;+const UNKNOWN_PLACE_ID ='Unknown place id. Use a google place id from the trip card or from a search result of this turn; ' +'if you have none, call search_place first.';@@ -132,8 +142,9 @@ const GO_ON =/*** Runs a read at once and records it: where it looks (streamed only), its- * call and answer, and the cards its answer makes. The cards are built from- * the tool's own answer, the parts the provider sees from the redacted one.+ * call and answer, and the cards its answer makes (its package's card first,+ * then the places strip). The cards are built from the tool's own answer, the+ * parts the provider sees from the redacted one.*/async function runRead(deps: AgentDeps,@@ -158,6 +169,12 @@ async function runRead(...(run.ok ? {} : { isError: true }),});if (!run.ok) return;+ const input = { toolCallId: id, args, value: run.value, card: deps.card, today: deps.today };+ const card = id.length <= MAX_CARD_CALL_ID ? (deps.answerCard ?? answerCardOf)(name, input) : null;+ if (card && step.cards++ < MAX_CARDS_PER_STEP) {+ w.card({ toolCallId: id, card });+ step.parts.push({ type: 'data-trek-card', data: { toolCallId: id, card } });+ }for (const placeId of googleIdsOf(name, run.value)) step.knownPlaceIds.add(placeId);const places = foundPlacesOf(name, id, run.value, deps.card, deps.today);if (places) {@@ -370,7 +387,7 @@ async function runStep(turn: Turn, step: number): Promise<AgentOutcome | null> {}const calls = received.map((call) => ({ ...call, id: uniqueCallId(call, input.usedCallIds, deps.newId) }));- const collected: StepParts = { parts, weather: [], knownPlaceIds: turn.knownPlaceIds };+ const collected: StepParts = { parts, weather: [], knownPlaceIds: turn.knownPlaceIds, cards: 0 };const held = await runCalls(turn, calls, collected);// One weather strip per step, whatever the step held: it is told before the changes.const weather = weatherOf(collected.weather);diff --git a/server/src/nest/assistant/assistant-cards.helpers.ts b/server/src/nest/assistant/assistant-cards.helpers.tsindex 8f5d3d2a9..8ce4663a8 100644--- a/server/src/nest/assistant/assistant-cards.helpers.ts+++ b/server/src/nest/assistant/assistant-cards.helpers.ts@@ -1,6 +1,6 @@import type { CardPlace, TripCard } from './assistant-context';-import { redactForProvider } from './assistant-redact';-import { dayLabel, type PreviewContext } from './tool-call-preview.helpers';+import { clipped, finite, isLat, isLng, recordOf, type Row } from './cards/card-values';+import { dayLabel } from './cards/preview-format';import {haversineMetres,kindOfResult,@@ -26,8 +26,6 @@ import {* a photo is asked for by a key, through TREK's own photo route.*/-type Row = Record<string, unknown>;-/** Places a search shows as cards; `more` counts the rest. */const PLACES_SHOWN = 20;const MAX_NAME_CHARS = 120;@@ -57,30 +55,6 @@ const PLACE_LISTS: Readonly<Record<string, 'places' | 'pois'>> = {search_pois: 'pois',};-function recordOf(value: unknown): Row {- return value && typeof value === 'object' && !Array.isArray(value) ? (value as Row) : {};-}--function finite(value: unknown): number | null {- return typeof value === 'number' && Number.isFinite(value) ? value : null;-}--function isLat(value: number | null): value is number {- return value !== null && Math.abs(value) <= 90;-}--function isLng(value: number | null): value is number {- return value !== null && Math.abs(value) <= 180;-}--/** A text as a card may show it: on one line, masked like a provider answer, and cut to `max`. */-function clipped(value: unknown, max: number): string | null {- if (typeof value !== 'string') return null;- const line = String(redactForProvider(value.replace(/\s+/g, ' ').trim()));- if (line === '') return null;- return line.length > max ? `${line.slice(0, max - 1)}…` : line;-}-/** Whether the trip runs today, the only time a source's "open now" means anything for it. */function tripRunsOn(card: TripCard, today: string): boolean {return !!card.startDate && !!card.endDate && card.startDate <= today && today <= card.endDate;@@ -285,7 +259,11 @@ export function activityOf(toolName: string, toolCallId: string, args: Row, card}/** What a mention is called in the trip; null when the trip holds no such thing. */-function mentionLabel(ctx: PreviewContext, kind: AssistantMention['kind'], id: number): string | null {+function mentionLabel(+ ctx: { card: TripCard; locale: string },+ kind: AssistantMention['kind'],+ id: number,+): string | null {if (kind === 'day') return ctx.card.days.some((day) => day.id === id) ? dayLabel(ctx, id) : null;if (kind === 'place') return ctx.card.places.get(id)?.name ?? null;return ctx.card.reservations.get(id)?.title ?? null;@@ -303,7 +281,7 @@ export function mentionItems(): AssistantMentions['items'] {const items: AssistantMentions['items'] = [];const seen = new Set<string>();- const ctx = { card, categories: new Map<number, string>(), locale };+ const ctx = { card, locale };for (const { kind, id } of mentions) {const label = mentionLabel(ctx, kind, id);const shown = clipped(label, MAX_NAME_CHARS);diff --git a/server/src/nest/assistant/assistant-context.ts b/server/src/nest/assistant/assistant-context.tsindex 803cc65a8..cd8a0b945 100644--- a/server/src/nest/assistant/assistant-context.ts+++ b/server/src/nest/assistant/assistant-context.ts@@ -1,3 +1,4 @@+import { fileKeyOf } from './cards/card-values';import type { AssistantFocus, AssistantMention } from '@trek/shared';/**@@ -58,8 +59,16 @@ interface CardPackingItem {packedQuantity: number | null;}+/** A trip member: the name the trip shows, and the stored file of their picture (none for one on another host). */+interface CardMember {+ name: string;+ avatarKey: string | null;+}+export interface TripCard {tripId: number;+ /** The user the turn runs for; a card compares people with it instead of carrying "me". */+ viewerId: number;title: string;startDate: string | null;endDate: string | null;@@ -69,11 +78,17 @@ export interface TripCard {assignments: Map<number, { dayId: number; placeId: number }>;notes: Map<number, CardNote>;packing: Map<number, CardPackingItem>;- members: Map<number, string>;+ members: Map<number, CardMember>;reservations: Map<number, CardBooking>;focus: AssistantFocus | null;/** What the user named with `@` in the message, as sent; checked against the card when it is rendered. */mentions: readonly AssistantMention[];+ /**+ * The raw answers the card was built from. A package that needs more of the+ * trip than the card holds reads it from here, in its own file (memoised per+ * card), rather than growing the card for every part of TREK.+ */+ sources: { summary: unknown; places: unknown };}/** Places a day lists by name on the card; the rest are counted. */@@ -132,6 +147,7 @@ function placeOf(row: Row): CardPlace | null {*/export function buildTripCard(tripId: number,+ viewerId: number,summary: unknown,placeList: unknown,focus: AssistantFocus | null,@@ -141,6 +157,7 @@ export function buildTripCard(const trip = recordOf(root.trip);const card: TripCard = {tripId,+ viewerId,title: str(trip.title) ?? '',startDate: str(trip.start_date),endDate: str(trip.end_date),@@ -154,6 +171,7 @@ export function buildTripCard(reservations: new Map(),focus,mentions,+ sources: { summary, places: placeList },};for (const row of rowsOf(recordOf(placeList).places)) {const place = placeOf(row);@@ -208,7 +226,8 @@ export function buildTripCard(const members = recordOf(root.members);for (const member of [recordOf(members.owner), ...rowsOf(members.collaborators)]) {const id = num(member.id);- if (id !== null) card.members.set(id, str(member.username) ?? `#${id}`);+ if (id === null) continue;+ card.members.set(id, { name: str(member.username) ?? `#${id}`, avatarKey: fileKeyOf(member.avatar_url) });}return card;}diff --git a/server/src/nest/assistant/assistant-found-places.service.ts b/server/src/nest/assistant/assistant-found-places.service.tsindex c9b00be5f..04bbac44e 100644--- a/server/src/nest/assistant/assistant-found-places.service.ts+++ b/server/src/nest/assistant/assistant-found-places.service.ts@@ -1,7 +1,11 @@import { AssistantMessages } from '../../db/entities/AssistantMessages.entity';import { AssistantThreads } from '../../db/entities/AssistantThreads.entity';import { AssistantToolCalls } from '../../db/entities/AssistantToolCalls.entity';-import { ASSISTANT_MESSAGE_PARTS, ASSISTANT_TOOL_ARGS, ASSISTANT_TOOL_PREVIEW } from '../../db/json-columns';+import {+ ASSISTANT_MESSAGE_PARTS_WRITE,+ ASSISTANT_TOOL_ARGS,+ ASSISTANT_TOOL_PREVIEW_WRITE,+} from '../../db/json-columns';import type {AssistantMessageRow,AssistantMessagesRepository,@@ -16,12 +20,19 @@ import { encodeJson } from '../../utils/json-column';import { aiRefusal } from '../ai-connections/ai-connections.constants';import { RateLimitService } from '../common/rate-limit.service';import { UnitOfWork } from '../database/unit-of-work';-import { buildTripCard, categoriesFrom, type CardCategory, type CardPlace, type TripCard } from './assistant-context';+import {+ buildTripCard,+ categoriesFrom,+ todayIn,+ type CardCategory,+ type CardPlace,+ type TripCard,+} from './assistant-context';import { partsOf, toThreadMessages } from './assistant-history';import { AssistantStreamRegistry } from './assistant-stream.registry';import { ADD_FOUND_PLACE_TOOL, TURNS_PER_MINUTE } from './assistant-tools.constants';import { AssistantToolsService } from './assistant-tools.service';-import { describeToolCall } from './tool-call-preview.helpers';+import { AssistantCardContext } from './cards/card-context';import { InjectRepository } from '@mikro-orm/nestjs';import { Injectable } from '@nestjs/common';import {@@ -111,6 +122,7 @@ export class AssistantFoundPlacesService {private readonly rateLimit: RateLimitService,private readonly streams: AssistantStreamRegistry,private readonly uow: UnitOfWork,+ private readonly cardContext: AssistantCardContext,) {}/**@@ -161,7 +173,10 @@ export class AssistantFoundPlacesService {const id = randomUUID();const args = suggestionArgs(place, req.dayId, card, categories);const names = new Map(categories.map((category): [number, string] => [category.id, category.name]));- const preview = describeToolCall(ADD_FOUND_PLACE_TOOL, id, args, { card, categories: names, locale: req.locale });+ const ctx = this.cardContext.contextOf(card, names, req.locale, todayIn(req.timeZone, new Date()));+ const [{ preview }] = await this.cardContext.describeProposed(userId, tripId, ctx, [+ { id, toolName: ADD_FOUND_PLACE_TOOL, args },+ ]);const parts: AssistantMessagePart[] = [{ type: 'tool-call', toolCallId: id, toolName: ADD_FOUND_PLACE_TOOL, args, approval: { id } },{ type: 'data-trek-change', data: preview },@@ -171,7 +186,7 @@ export class AssistantFoundPlacesService {const messageId = await this.messages.append({threadId,role: 'assistant',- parts: encodeJson(ASSISTANT_MESSAGE_PARTS, parts),+ parts: encodeJson(ASSISTANT_MESSAGE_PARTS_WRITE, parts),providerState: null,status: 'awaiting_approval',model: null,@@ -185,7 +200,7 @@ export class AssistantFoundPlacesService {providerCallId: `found_${id}`,toolName: ADD_FOUND_PLACE_TOOL,args: encodeJson(ASSISTANT_TOOL_ARGS, args),- preview: encodeJson(ASSISTANT_TOOL_PREVIEW, preview),+ preview: encodeJson(ASSISTANT_TOOL_PREVIEW_WRITE, preview),createdAt: now,},]);@@ -201,7 +216,7 @@ export class AssistantFoundPlacesService {const places = await session.read('list_places');const listed = await session.read('list_categories');return {- card: buildTripCard(tripId, summary.ok ? summary.value : null, places.ok ? places.value : null, null),+ card: buildTripCard(tripId, userId, summary.ok ? summary.value : null, places.ok ? places.value : null, null),categories: categoriesFrom(listed.ok ? listed.value : null),};} finally {diff --git a/server/src/nest/assistant/assistant-history.ts b/server/src/nest/assistant/assistant-history.tsindex 4c05f40c5..d33bf17b5 100644--- a/server/src/nest/assistant/assistant-history.ts+++ b/server/src/nest/assistant/assistant-history.ts@@ -4,7 +4,7 @@ import type { AssistantToolCallRow } from '../../db/repositories/AssistantToolCaimport { parseDbTimestamp, utcSuffix } from '../../db/types';import { decodeJson } from '../../utils/json-column';import type { AiChatMessage, AiToolCall } from '../ai-connections/ai-chat-client.interface';-import { fitToSize } from './assistant-redact';+import { fitToSize } from './assistant-output';import {ADD_FOUND_PLACE_TOOL,APPROVAL_TTL_MS,diff --git a/server/src/nest/assistant/assistant-output.ts b/server/src/nest/assistant/assistant-output.tsnew file mode 100644index 000000000..1919ac0e7--- /dev/null+++ b/server/src/nest/assistant/assistant-output.ts@@ -0,0 +1,148 @@+import { redactForProvider } from './assistant-redact';+import { MAX_TOOL_OUTPUT_CHARS } from './assistant-tools.constants';+import { PROJECTIONS, refuseCoreOverlap } from './cards/registry';++/**+ * A tool's answer as the provider gets it: projected to what the model plans+ * with (the core's projections here, a package's from its cards), redacted+ * (assistant-redact.ts), and cut down until it fits. The client is shown the+ * same, so a stored or streamed answer never carries more than the model saw.+ */++type Json = unknown;++/** Longest string kept whole; a longer one keeps its start. */+const MAX_STRING_CHARS = 4_000;++/** Array lengths tried, longest first, until the answer fits. */+const ARRAY_CAPS = [100, 50, 20, 10, 5, 2, 1];++function isRecord(value: Json): value is Record<string, unknown> {+ return value !== null && typeof value === 'object' && !Array.isArray(value);+}++function pick(row: Json, keys: readonly string[]): Record<string, unknown> | null {+ if (!isRecord(row)) return null;+ const out: Record<string, unknown> = {};+ for (const key of keys) if (row[key] !== undefined) out[key] = row[key];+ return out;+}++function pickAll(rows: Json, keys: readonly string[]): Record<string, unknown>[] {+ return Array.isArray(rows) ? rows.map((row) => pick(row, keys)).filter((row) => row !== null) : [];+}++const ASSIGNMENT_KEYS = ['id', 'place_id', 'order_index', 'assignment_time', 'assignment_end_time', 'notes'] as const;+const PLACE_KEYS = ['name', 'address', 'lat', 'lng', 'category_id', 'place_time', 'end_time'] as const;++function projectDay(day: Json): Record<string, unknown> | null {+ if (!isRecord(day)) return null;+ return {+ ...pick(day, ['id', 'day_number', 'date', 'title']),+ assignments: (Array.isArray(day.assignments) ? day.assignments : [])+ .filter(isRecord)+ .map((assignment) => ({ ...pick(assignment, ASSIGNMENT_KEYS), place: pick(assignment.place, PLACE_KEYS) })),+ notes: pickAll(day.notes, ['id', 'text', 'time', 'icon']),+ };+}++/**+ * `get_trip_summary` as the model gets it: the plan (days with their places+ * and notes, stays, bookings, the packing and to-do lists), without the+ * members' contact details, the shared notes or the budget rows, which have+ * tools of their own.+ */+function projectTripSummary(summary: Json): Json {+ if (!isRecord(summary)) return summary;+ const members = isRecord(summary.members) ? summary.members : {};+ const people = [members.owner, ...(Array.isArray(members.collaborators) ? members.collaborators : [])];+ const packing = isRecord(summary.packing) ? summary.packing : {};+ return {+ trip: pick(summary.trip, ['id', 'title', 'description', 'start_date', 'end_date', 'currency']),+ members: pickAll(people, ['id', 'username']),+ days: (Array.isArray(summary.days) ? summary.days : []).map(projectDay).filter((day) => day !== null),+ accommodations: pickAll(summary.accommodations, [+ 'id',+ 'place_id',+ 'start_day_id',+ 'end_day_id',+ 'check_in',+ 'check_out',+ ]),+ reservations: pickAll(summary.reservations, [+ 'id',+ 'title',+ 'type',+ 'status',+ 'reservation_time',+ 'reservation_end_time',+ 'location',+ 'day_id',+ 'end_day_id',+ 'place_id',+ 'assignment_id',+ ]),+ packing: pickAll(packing.items, ['id', 'name', 'category', 'checked', 'quantity', 'packed_quantity']),+ todos: pickAll(summary.todos, ['id', 'name', 'category', 'checked', 'due_date', 'priority', 'assigned_user_id']),+ };+}++/**+ * `suggest_atlas_countries` as the model gets it: each country with its+ * cities and the minutes spent in them, without when the user was last seen+ * in each city. The model offers countries to mark; a time per city would+ * hand the provider a dated trail of the user's whereabouts for nothing it+ * plans with.+ */+function projectAtlasSuggestions(value: Json): Json {+ if (!isRecord(value) || !Array.isArray(value.countries)) return value;+ return {+ ...value,+ countries: value.countries.map((country) =>+ isRecord(country) ? { ...country, cities: pickAll(country.cities, ['name', 'minutes']) } : country,+ ),+ };+}++/** The core's projections; the packages' come from their cards (`project`), never for the same tool. */+const CORE_PROJECTIONS: Readonly<Record<string, (value: Json) => Json>> = {+ get_trip_summary: projectTripSummary,+ suggest_atlas_countries: projectAtlasSuggestions,+};+refuseCoreOverlap('project', Object.keys(CORE_PROJECTIONS));++function shrink(value: Json, cap: number, cut: { done: boolean }): Json {+ if (typeof value === 'string' && value.length > MAX_STRING_CHARS) {+ cut.done = true;+ return `${value.slice(0, MAX_STRING_CHARS)}…`;+ }+ if (Array.isArray(value)) {+ if (value.length > cap) cut.done = true;+ return value.slice(0, cap).map((item) => shrink(item, cap, cut));+ }+ if (!isRecord(value)) return value;+ return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, shrink(inner, cap, cut)]));+}++/**+ * The value cut down until its JSON fits `maxChars`: long strings keep their+ * start, arrays their first entries, and the answer says it was cut+ * (`truncated: true`), so the model knows to narrow its question rather than+ * read a list as complete. Never a cut through the middle of the JSON.+ */+export function fitToSize(value: Json, maxChars = MAX_TOOL_OUTPUT_CHARS): Json {+ if (JSON.stringify(value).length <= maxChars) return value;+ for (const cap of ARRAY_CAPS) {+ const cut = { done: false };+ const shrunk = shrink(value, cap, cut);+ const marked = isRecord(shrunk) ? { ...shrunk, truncated: true } : { items: shrunk, truncated: true };+ if (JSON.stringify(marked).length <= maxChars) return marked;+ }+ return { truncated: true, note: 'The answer was too large. Ask for less at once.' };+}++/** A tool's answer as the provider and the client see it: projected, redacted and cut to size. */+export function toolOutputForProvider(toolName: string, value: Json, maxChars = MAX_TOOL_OUTPUT_CHARS): Json {+ const project = CORE_PROJECTIONS[toolName] ?? PROJECTIONS[toolName];+ return fitToSize(redactForProvider(project ? project(value) : value), maxChars);+}diff --git a/server/src/nest/assistant/assistant-redact.ts b/server/src/nest/assistant/assistant-redact.tsindex 7ddb64b64..1d0296800 100644--- a/server/src/nest/assistant/assistant-redact.ts+++ b/server/src/nest/assistant/assistant-redact.ts@@ -1,10 +1,9 @@-import { MAX_TOOL_OUTPUT_CHARS } from './assistant-tools.constants';-/*** What a tool answer may carry to the provider. The model plans the trip; it* has no use for anyone's e-mail address, a booking's confirmation code or a* phone number, so those are hidden, and the bulky fields (pictures inlined as- * data URLs, route geometry) are dropped before the answer is cut to size.+ * data URLs, route geometry) are dropped before the answer is cut to size+ * (assistant-output.ts). The cards mask their texts with it too.*/const HIDDEN = '[hidden]';@@ -13,16 +12,10 @@ const HIDDEN = '[hidden]';const SECRET_KEYS = new Set(['email', 'confirmation_number', 'confirmation', 'phone', 'feed_token', 'password']);/** Keys that cost a lot and tell the model nothing it plans with. */-const DROPPED_KEY = /^(image_url|cover_image|avatar|avatar_url|metadata)$|geometry/;+const DROPPED_KEY = /^(image_url|cover_image|avatar|avatar_url|metadata|place_image|trip_cover)$|geometry/;const EMAIL = /[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g;-/** Longest string kept whole; a longer one keeps its start. */-const MAX_STRING_CHARS = 4_000;--/** Array lengths tried, longest first, until the answer fits. */-const ARRAY_CAPS = [100, 50, 20, 10, 5, 2, 1];-type Json = unknown;function isRecord(value: Json): value is Record<string, unknown> {@@ -41,127 +34,3 @@ export function redactForProvider(value: Json): Json {}return out;}--function pick(row: Json, keys: readonly string[]): Record<string, unknown> | null {- if (!isRecord(row)) return null;- const out: Record<string, unknown> = {};- for (const key of keys) if (row[key] !== undefined) out[key] = row[key];- return out;-}--function pickAll(rows: Json, keys: readonly string[]): Record<string, unknown>[] {- return Array.isArray(rows) ? rows.map((row) => pick(row, keys)).filter((row) => row !== null) : [];-}--const ASSIGNMENT_KEYS = ['id', 'place_id', 'order_index', 'assignment_time', 'assignment_end_time', 'notes'] as const;-const PLACE_KEYS = ['name', 'address', 'lat', 'lng', 'category_id', 'place_time', 'end_time'] as const;--function projectDay(day: Json): Record<string, unknown> | null {- if (!isRecord(day)) return null;- return {- ...pick(day, ['id', 'day_number', 'date', 'title']),- assignments: (Array.isArray(day.assignments) ? day.assignments : [])- .filter(isRecord)- .map((assignment) => ({ ...pick(assignment, ASSIGNMENT_KEYS), place: pick(assignment.place, PLACE_KEYS) })),- notes: pickAll(day.notes, ['id', 'text', 'time', 'icon']),- };-}--/**- * `get_trip_summary` as the model gets it: the plan (days with their places- * and notes, stays, bookings, the packing and to-do lists), without the- * members' contact details, the shared notes or the budget rows, which have- * tools of their own.- */-function projectTripSummary(summary: Json): Json {- if (!isRecord(summary)) return summary;- const members = isRecord(summary.members) ? summary.members : {};- const people = [members.owner, ...(Array.isArray(members.collaborators) ? members.collaborators : [])];- const packing = isRecord(summary.packing) ? summary.packing : {};- return {- trip: pick(summary.trip, ['id', 'title', 'description', 'start_date', 'end_date', 'currency']),- members: pickAll(people, ['id', 'username']),- days: (Array.isArray(summary.days) ? summary.days : []).map(projectDay).filter((day) => day !== null),- accommodations: pickAll(summary.accommodations, [- 'id',- 'place_id',- 'start_day_id',- 'end_day_id',- 'check_in',- 'check_out',- ]),- reservations: pickAll(summary.reservations, [- 'id',- 'title',- 'type',- 'status',- 'reservation_time',- 'reservation_end_time',- 'location',- 'day_id',- 'end_day_id',- 'place_id',- 'assignment_id',- ]),- packing: pickAll(packing.items, ['id', 'name', 'category', 'checked', 'quantity', 'packed_quantity']),- todos: pickAll(summary.todos, ['id', 'name', 'category', 'checked', 'due_date', 'priority', 'assigned_user_id']),- };-}--/**- * `suggest_atlas_countries` as the model gets it: each country with its- * cities and the minutes spent in them, without when the user was last seen- * in each city. The model offers countries to mark; a time per city would- * hand the provider a dated trail of the user's whereabouts for nothing it- * plans with.- */-function projectAtlasSuggestions(value: Json): Json {- if (!isRecord(value) || !Array.isArray(value.countries)) return value;- return {- ...value,- countries: value.countries.map((country) =>- isRecord(country) ? { ...country, cities: pickAll(country.cities, ['name', 'minutes']) } : country,- ),- };-}--const PROJECTIONS: Readonly<Record<string, (value: Json) => Json>> = {- get_trip_summary: projectTripSummary,- suggest_atlas_countries: projectAtlasSuggestions,-};--function shrink(value: Json, cap: number, cut: { done: boolean }): Json {- if (typeof value === 'string' && value.length > MAX_STRING_CHARS) {- cut.done = true;- return `${value.slice(0, MAX_STRING_CHARS)}…`;- }- if (Array.isArray(value)) {- if (value.length > cap) cut.done = true;- return value.slice(0, cap).map((item) => shrink(item, cap, cut));- }- if (!isRecord(value)) return value;- return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, shrink(inner, cap, cut)]));-}--/**- * The value cut down until its JSON fits `maxChars`: long strings keep their- * start, arrays their first entries, and the answer says it was cut- * (`truncated: true`), so the model knows to narrow its question rather than- * read a list as complete. Never a cut through the middle of the JSON.- */-export function fitToSize(value: Json, maxChars = MAX_TOOL_OUTPUT_CHARS): Json {- if (JSON.stringify(value).length <= maxChars) return value;- for (const cap of ARRAY_CAPS) {- const cut = { done: false };- const shrunk = shrink(value, cap, cut);- const marked = isRecord(shrunk) ? { ...shrunk, truncated: true } : { items: shrunk, truncated: true };- if (JSON.stringify(marked).length <= maxChars) return marked;- }- return { truncated: true, note: 'The answer was too large. Ask for less at once.' };-}--/** A tool's answer as the provider and the client see it: projected, redacted and cut to size. */-export function toolOutputForProvider(toolName: string, value: Json, maxChars = MAX_TOOL_OUTPUT_CHARS): Json {- const project = PROJECTIONS[toolName];- return fitToSize(redactForProvider(project ? project(value) : value), maxChars);-}diff --git a/server/src/nest/assistant/assistant-tool-offer.ts b/server/src/nest/assistant/assistant-tool-offer.tsindex 97b7e606b..fae00af68 100644--- a/server/src/nest/assistant/assistant-tool-offer.ts+++ b/server/src/nest/assistant/assistant-tool-offer.ts@@ -1,5 +1,6 @@import type { McpRegistryListing } from '../../nest-mcp';import type { AiToolSpec } from '../ai-connections/ai-chat-client.interface';+import { PACKAGE_HELD_READS, PACKAGE_TOOL_CONTROLLERS } from './cards/registry';/*** Which of TREK's MCP tools the assistant is offered, and how. Every tool the@@ -81,11 +82,15 @@ const SHARE_LIKE_SAFE: ReadonlySet<string> = new Set([]);const SHARE_LIKE = /share|invite|feed/;-/** Read-only tools that still wait for the user: they fetch an address that came from the web or a message. */+/**+ * Read-only tools that still wait for the user: they fetch an address that+ * came from the web or a message. The packages add theirs in their cards.+ */export const HELD_READS: ReadonlySet<string> = new Set(['resolve_maps_url','preview_google_maps_route','preview_google_maps_walk',+ ...PACKAGE_HELD_READS,]);export function isOfferedTool(name: string): boolean {@@ -103,12 +108,15 @@ export function checkDenylist(names: Iterable<string>): string[] {return problems;}+type ToolGroups = Readonly<Record<string, { about: string; controllers: readonly string[] }>>;+/*** The tool groups a turn can load, by the MCP controller that registers the* tools, each with the words the model reads to pick it. A controller not- * listed here belongs to the core, which every step offers.+ * listed here, nor added by a package (`toolControllers` in its cards),+ * belongs to the core, which every step offers.*/-export const ASSISTANT_TOOL_GROUPS: Readonly<Record<string, { about: string; controllers: readonly string[] }>> = {+const CORE_TOOL_GROUPS: ToolGroups = {tours: {about:'Tours: hikes, bike tours, city walks, paddling and ski routes; plan, create, change and export them ' +@@ -184,6 +192,29 @@ export const ASSISTANT_TOOL_GROUPS: Readonly<Record<string, { about: string; con},};+/**+ * The groups with the controllers the packages added to them. A package that+ * names a group this file does not know, or a controller a group lists+ * already, stops the server at load.+ */+export function withPackageControllers(+ core: ToolGroups,+ added: Readonly<Record<string, readonly string[]>>,+): ToolGroups {+ const groups = Object.fromEntries(Object.entries(core).map(([group, value]) => [group, { ...value }]));+ const listed = new Set(Object.values(core).flatMap((group) => group.controllers));+ for (const [group, controllers] of Object.entries(added)) {+ const known = groups[group];+ if (!known) throw new Error(`Assistant tool groups: no group "${group}" for ${controllers.join(', ')}`);+ const twice = controllers.find((controller) => listed.has(controller));+ if (twice) throw new Error(`Assistant tool groups: controller "${twice}" is listed already`);+ known.controllers = [...known.controllers, ...controllers];+ }+ return groups;+}++export const ASSISTANT_TOOL_GROUPS = withPackageControllers(CORE_TOOL_GROUPS, PACKAGE_TOOL_CONTROLLERS);+const GROUP_OF_CONTROLLER = new Map(Object.entries(ASSISTANT_TOOL_GROUPS).flatMap(([group, { controllers }]) =>controllers.map((controller) => [controller, group] as const),diff --git a/server/src/nest/assistant/assistant-tools.constants.ts b/server/src/nest/assistant/assistant-tools.constants.tsindex cd7a35887..b88a47b90 100644--- a/server/src/nest/assistant/assistant-tools.constants.ts+++ b/server/src/nest/assistant/assistant-tools.constants.ts@@ -1,3 +1,5 @@+import type { ToolUndo } from './cards/card-types';+import { argId, idIn } from './cards/card-values';import type { AssistantApplied, AssistantChangeVerbKey } from '@trek/shared';/**@@ -13,6 +15,9 @@ export const MAX_WRITES_PER_STEP = 50;/** Lookups one step may run; the rest come back to the model as an error (searches bill the instance's maps key). */export const MAX_READS_PER_STEP = 30;+/** Answer cards one step shows; the reads past it answer the model as usual, without a card. */+export const MAX_CARDS_PER_STEP = 12;+/** What a tool answer may cost the conversation, as JSON text, after it was cut down to its structure. */export const MAX_TOOL_OUTPUT_CHARS = 40_000;@@ -70,18 +75,19 @@ export const ASSISTANT_SCOPES: readonly string[] = [* applied. A `quiet` one is decided without a model turn after it: the user* proposed it, so there is nothing for the model to carry on with.*/-interface AssistantWriteTool {+export interface AssistantWriteTool {verbKey: AssistantChangeVerbKey;entity: AssistantApplied['entity'];quiet?: boolean;}/**- * The writing tools with a change card of their own: its verb and what it- * touches once applied. Every other writing tool is held as a card too, one- * built from its arguments (tool-call-generic.helpers.ts).+ * The core writing tools with a change card of their own: its verb and what+ * it touches once applied. The packages add theirs (cards/registry.ts merges+ * them into ASSISTANT_WRITE_TOOLS). Every other writing tool is held as a card+ * too, one built from its arguments (tool-call-generic.helpers.ts).*/-export const ASSISTANT_WRITE_TOOLS: Readonly<Record<string, AssistantWriteTool>> = {+export const CORE_WRITE_TOOLS: Readonly<Record<string, AssistantWriteTool>> = {create_place: { verbKey: 'addPlace', entity: 'place' },create_and_assign_place: { verbKey: 'addPlaceToDay', entity: 'place' },update_place: { verbKey: 'updatePlace', entity: 'place' },@@ -96,11 +102,6 @@ export const ASSISTANT_WRITE_TOOLS: Readonly<Record<string, AssistantWriteTool>>create_budget_item: { verbKey: 'addBudgetItem', entity: 'budget' },update_budget_item: { verbKey: 'updateBudgetItem', entity: 'budget' },create_reservation: { verbKey: 'addReservation', entity: 'reservation' },- // A tour is a place with a route: its id is its place's.- create_hike: { verbKey: 'addTour', entity: 'tour' },- create_city_walk: { verbKey: 'addTour', entity: 'tour' },- update_tour: { verbKey: 'updateTour', entity: 'tour' },- import_tour_gpx: { verbKey: 'importTour', entity: 'tour' },};/**@@ -179,9 +180,9 @@ export const PINNED_ARG = 'tripId';* (place details stay on the cheap lookup, which the instance pays for);* `stripped` ones are taken away (a picture URL would be loaded by every* member's browser, a tracking pixel the model could plant). Neither appears- * in the schema the model sees.+ * in the schema the model sees. The packages add theirs (ASSISTANT_ARG_POLICY).*/-export const ASSISTANT_ARG_POLICY: Readonly<+export const CORE_ARG_POLICY: Readonly<Record<string, { forced?: Readonly<Record<string, unknown>>; stripped?: readonly string[] }>> = {get_place_details: { forced: { expand: false, refresh: false } },@@ -192,49 +193,16 @@ export const ASSISTANT_ARG_POLICY: Readonly<update_trip: { stripped: ['cover_image'] },};-type ToolArgs = Record<string, unknown>;--function idIn(value: unknown, key: string): number | null {- const record = value && typeof value === 'object' ? (value as Record<string, unknown>)[key] : undefined;- const id = record && typeof record === 'object' ? (record as Record<string, unknown>).id : undefined;- return typeof id === 'number' && Number.isInteger(id) && id > 0 ? id : null;-}--/** The place id of a tour a create answered with (`{ tour: { place_id } }`). */-function tourIdIn(value: unknown): number | null {- const tour = value && typeof value === 'object' ? (value as Record<string, unknown>).tour : undefined;- const id = tour && typeof tour === 'object' ? (tour as Record<string, unknown>).place_id : undefined;- return typeof id === 'number' && Number.isInteger(id) && id > 0 ? id : null;-}--function argId(args: ToolArgs, key: string): number | null {- const id = args[key];- return typeof id === 'number' && Number.isInteger(id) && id > 0 ? id : null;-}-/*** The way back from an applied change, for the server only: the tool that* removes what the change created, and its arguments, from the arguments the* change ran with and the result it gave. Null when the result does not name* what was created, which offers no undo. The model is never offered these* tools, except the removal it may also propose itself; they run in a session- * of their own that holds nothing else.+ * of their own that holds nothing else. The packages add theirs+ * (ASSISTANT_UNDO_MAP).*/-interface AssistantUndo {- tool: string;- args: (args: ToolArgs, result: unknown) => ToolArgs | null;-}--/** A created tour taken back with its place, which takes its route and points along. */-const DELETE_CREATED_TOUR: AssistantUndo = {- tool: 'delete_place',- args: (_args, result) => {- const placeId = tourIdIn(result);- return placeId ? { placeId } : null;- },-};--export const ASSISTANT_UNDO_MAP: Readonly<Record<string, AssistantUndo>> = {+export const CORE_UNDO_MAP: Readonly<Record<string, ToolUndo>> = {create_place: {tool: 'delete_place',args: (_args, result) => {@@ -286,6 +254,4 @@ export const ASSISTANT_UNDO_MAP: Readonly<Record<string, AssistantUndo>> = {return itemId ? { itemId } : null;},},- create_hike: DELETE_CREATED_TOUR,- create_city_walk: DELETE_CREATED_TOUR,};diff --git a/server/src/nest/assistant/assistant-tools.service.ts b/server/src/nest/assistant/assistant-tools.service.tsindex 1e090830d..62b014818 100644--- a/server/src/nest/assistant/assistant-tools.service.ts+++ b/server/src/nest/assistant/assistant-tools.service.ts@@ -13,15 +13,15 @@ import {USE_TOOLS_SPEC,USE_TOOLS_TOOL,} from './assistant-tool-offer';+import { ASSISTANT_SCOPES, ASSISTANT_SERVER_TOOLS, PINNED_ARG, REMEMBER_TOOL } from './assistant-tools.constants';+import type { ToolCards } from './cards/card-types';import {ASSISTANT_ARG_POLICY,- ASSISTANT_SCOPES,- ASSISTANT_SERVER_TOOLS,ASSISTANT_UNDO_MAP,ASSISTANT_WRITE_TOOLS,- PINNED_ARG,- REMEMBER_TOOL,-} from './assistant-tools.constants';+ PACKAGE_HELD_READS,+ TOOL_CARDS,+} from './cards/registry';import { MikroORM } from '@mikro-orm/core';import { Client } from '@modelcontextprotocol/sdk/client/index';import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory';@@ -57,21 +57,51 @@ interface ListedTool {/** A turn's session offers every tool (the core first, the rest by group); an undo's holds its one target. */type SessionMode = 'turn' | 'undo';+/**+ * The tools the packages' undo checks read. A package's `reads` names its+ * tools whatever the arguments, so asking with none shows which they are.+ */+function undoReadTools(cards: Readonly<Record<string, ToolCards>>): string[] {+ return Object.values(cards).flatMap((entry) => {+ try {+ return (entry.undo?.reads?.({}, {}) ?? []).map((read) => read.tool);+ } catch {+ return [];+ }+ });+}+/*** What is wrong with the tool catalog the assistant relies on, given what the- * registry holds: a tool with a card of its own or an undo target that no- * longer exists, a sharing tool the denylist missed, or a tool named like one- * of the server's own steps. Empty when all is well.+ * registry holds: a tool with a card of its own, a package's cards for a tool,+ * an undo target, an undo read or a package's held read that no longer+ * exists, a sharing tool the denylist missed, or a tool named like one of the+ * server's own steps. Empty when all is well.*/-export function checkToolCatalog(listing: readonly McpRegistryListing[]): string[] {+export function checkToolCatalog(+ listing: readonly McpRegistryListing[],+ cards: Readonly<Record<string, ToolCards>> = TOOL_CARDS,+ heldReads: Iterable<string> = PACKAGE_HELD_READS,+): string[] {const tools = new Set(listing.filter((entry) => entry.kind === 'tool').map((entry) => entry.name));const problems: string[] = [];for (const name of Object.keys(ASSISTANT_WRITE_TOOLS)) {if (!tools.has(name)) problems.push(`tool "${name}" with a card of its own is not registered`);}+ for (const name of Object.keys(cards)) {+ if (!tools.has(name) && !ASSISTANT_SERVER_TOOLS.has(name)) {+ problems.push(`tool "${name}" with cards of a package is neither registered nor the server's own`);+ }+ }for (const undo of Object.values(ASSISTANT_UNDO_MAP)) {if (!tools.has(undo.tool)) problems.push(`undo tool "${undo.tool}" is not registered`);}+ for (const name of undoReadTools(cards)) {+ if (!tools.has(name)) problems.push(`undo read "${name}" is not registered`);+ }+ for (const name of heldReads) {+ if (!tools.has(name)) problems.push(`held read "${name}" of a package is not registered`);+ }// The server's own steps are told apart from tool calls by name alone.for (const name of [...ASSISTANT_SERVER_TOOLS, USE_TOOLS_TOOL]) {if (tools.has(name)) problems.push(`"${name}" is the server's own step`);diff --git a/server/src/nest/assistant/assistant-undo.helpers.ts b/server/src/nest/assistant/assistant-undo.helpers.tsindex 9490e0680..4eda832cf 100644--- a/server/src/nest/assistant/assistant-undo.helpers.ts+++ b/server/src/nest/assistant/assistant-undo.helpers.ts@@ -1,100 +1,42 @@+import type { AssistantToolSession } from './assistant-tools.service';+import type { ToolArgs, UndoSnapshot } from './cards/card-types';+import { readKey, recordOf, type Row } from './cards/card-values';+import { TOOL_CARDS, undoReadsOf } from './cards/registry';+import {+ byId,+ placeUnchanged,+ rowsOf,+ same,+ snapshotAssignments,+ snapshotDays,+ STABLE_FIELDS,+} from './cards/undo-snapshot';+/*** Whether an applied change may still be taken back: what it created must be* as it was then. An undo removes the created row with everything that hangs* off it, so a place someone planned on another day since, or booked, or* linked an expense to, is not removed by an undo the user meant for the bare* place. The trip is read as the tools answer it (`get_trip_summary` raw, and- * `list_places` for places).+ * `list_places` for places), plus the reads a package's undo asks for.*/-type Row = Record<string, unknown>;--export interface TripSnapshot {- summary: unknown;- places: unknown;-}--function recordOf(value: unknown): Row {- return value && typeof value === 'object' && !Array.isArray(value) ? (value as Row) : {};-}--function rowsOf(value: unknown): Row[] {- return Array.isArray(value) ? value.map(recordOf) : [];-}--/** The fields that say a row is still the one that was created; a field either side lacks is not compared. */-const STABLE_FIELDS = {- place: ['name', 'updated_at', 'lat', 'lng', 'address', 'category_id', 'description', 'notes'],- assignment: ['day_id', 'place_id'],- note: ['text', 'time', 'icon', 'color'],- packing: ['name', 'updated_at', 'checked', 'quantity', 'category'],- todo: ['name', 'checked', 'due_date', 'description', 'priority', 'assigned_user_id', 'category'],- budget: ['name', 'total_price', 'currency', 'category', 'note', 'expense_date'],-} as const;+/** The trip as an undo reads it; the package reads are left out where none were made. */+export type TripSnapshot = Omit<UndoSnapshot, 'reads'> & { reads?: UndoSnapshot['reads'] };-function same(created: Row, current: Row | undefined, fields: readonly string[]): boolean {- if (!current) return false;- return fields.every((field) => !(field in created) || !(field in current) || created[field] === current[field]);-}--function byId(rows: Row[], id: unknown): Row | undefined {- return rows.find((row) => row.id === id);-}--function days(snapshot: TripSnapshot): Row[] {- return rowsOf(recordOf(snapshot.summary).days);-}--function assignments(snapshot: TripSnapshot): Row[] {- return days(snapshot).flatMap((day) => rowsOf(day.assignments));-}+/** The trip reads every undo makes before it checks. */+const TRIP_READS = ['get_trip_summary', 'list_places'] as const;-/** A created place, unchanged and still only where the change put it: on no other day, in no booking or expense. */-function placeUnchanged(result: Row, snapshot: TripSnapshot): boolean {- const created = recordOf(result.place);- const current = byId(rowsOf(recordOf(snapshot.places).places), created.id);- if (!same(created, current, STABLE_FIELDS.place)) return false;- const ownAssignment = recordOf(result.assignment).id;- const plannedElsewhere = assignments(snapshot).some((a) => a.place_id === created.id && a.id !== ownAssignment);- const summary = recordOf(snapshot.summary);- const referenced = [- ...rowsOf(summary.reservations),- ...rowsOf(summary.accommodations),- ...rowsOf(recordOf(summary.budget).items),- ].some((row) => row.place_id === created.id);- return !plannedElsewhere && !referenced;-}--/**- * A created tour, unchanged and on no day: its place still has the name and- * description it was created with, has not been written since it was made,- * and nothing plans, books or pays for it. Every write of a tour's route or- * name (a change over MCP, the planner's save, a rename) stamps its place's- * `updated_at`, which the create left equal to `created_at`; the revision is- * not in the snapshot. A tour planned on a day since is kept too.- */-function tourUnchanged(result: Row, snapshot: TripSnapshot): boolean {- const tour = recordOf(result.tour);- const current = byId(rowsOf(recordOf(snapshot.places).places), tour.place_id);- const untouched = typeof current?.created_at === 'string' && current.updated_at === current.created_at;- return (- untouched &&- placeUnchanged({ place: { id: tour.place_id, name: tour.name, description: tour.description ?? null } }, snapshot)- );-}--const CHECKS: Readonly<Record<string, (result: Row, snapshot: TripSnapshot) => boolean>> = {+const CORE_CHECKS: Readonly<Record<string, (result: Row, snapshot: UndoSnapshot) => boolean>> = {create_place: placeUnchanged,create_and_assign_place: placeUnchanged,- create_hike: tourUnchanged,- create_city_walk: tourUnchanged,assign_place_to_day: (result, snapshot) => {const created = recordOf(result.assignment);- return same(created, byId(assignments(snapshot), created.id), STABLE_FIELDS.assignment);+ return same(created, byId(snapshotAssignments(snapshot), created.id), STABLE_FIELDS.assignment);},create_day_note: (result, snapshot) => {const created = recordOf(result.note);- const notes = days(snapshot).flatMap((day) => rowsOf(day.notes));+ const notes = snapshotDays(snapshot).flatMap((day) => rowsOf(day.notes));return same(created, byId(notes, created.id), STABLE_FIELDS.note);},create_packing_item: (result, snapshot) => {@@ -113,8 +55,47 @@ const CHECKS: Readonly<Record<string, (result: Row, snapshot: TripSnapshot) => b},};+/**+ * The core checks and each package's `undo.unchanged`, which the registry+ * guards (one that throws reads as changed) and keeps off the core's tools.+ */+const CHECKS: Readonly<Record<string, (result: Row, snapshot: UndoSnapshot) => boolean>> = {+ ...CORE_CHECKS,+ ...Object.fromEntries(+ Object.entries(TOOL_CARDS).flatMap(([tool, cards]) => {+ const undo = cards.undo;+ return undo ? [[tool, (result: Row, snapshot: UndoSnapshot) => undo.unchanged(result, snapshot)]] : [];+ }),+ ),+};+/** True when the change `toolName` made (its stored `result`) is still as it left it. */export function unchangedSinceApplied(toolName: string, result: unknown, snapshot: TripSnapshot): boolean {const check = CHECKS[toolName];- return !!check && check(recordOf(result), snapshot);+ return !!check && check(recordOf(result), { ...snapshot, reads: snapshot.reads ?? new Map() });+}++/** The tools an undo's session holds: the removing tool, the trip reads and what the change's package reads. */+export function undoTargetsOf(undoTool: string, toolName: string, args: ToolArgs, result: unknown): Set<string> {+ return new Set([undoTool, ...TRIP_READS, ...undoReadsOf(toolName, args, result).map((read) => read.tool)]);+}++/** The trip as the undo checks it, read through the undo's session; null when a trip read failed. */+export async function undoSnapshotOf(+ session: Pick<AssistantToolSession, 'read'>,+ toolName: string,+ args: ToolArgs,+ result: unknown,+ reads = undoReadsOf(toolName, args, result),+): Promise<UndoSnapshot | null> {+ const summary = await session.read('get_trip_summary');+ const places = await session.read('list_places');+ if (!summary.ok || !places.ok) return null;+ const extra = await Promise.all(+ reads.map(async (read): Promise<[string, unknown]> => {+ const run = await session.read(read.tool, read.args);+ return [readKey(read.tool, read.args), run.ok ? run.value : null];+ }),+ );+ return { summary: summary.value, places: places.value, reads: new Map(extra) };}diff --git a/server/src/nest/assistant/assistant.module.ts b/server/src/nest/assistant/assistant.module.tsindex ca5a02607..f006ee8d6 100644--- a/server/src/nest/assistant/assistant.module.ts+++ b/server/src/nest/assistant/assistant.module.ts@@ -3,6 +3,7 @@ import { AssistantThreads } from '../../db/entities/AssistantThreads.entity';import { AssistantToolCalls } from '../../db/entities/AssistantToolCalls.entity';import { AddonsModule } from '../addons/addons.module';import { AiConnectionsModule } from '../ai-connections/ai-connections.module';+import { AirportsModule } from '../airports/airports.module';import { AuditModule } from '../audit/audit.module';import { BookingImportModule } from '../booking-import/booking-import.module';import { CollabModule } from '../collab/collab.module';@@ -21,6 +22,7 @@ import { AssistantStreamRegistry, InMemoryAssistantStreamRegistry } from './assiimport { AssistantToolsService } from './assistant-tools.service';import { AssistantController } from './assistant.controller';import { AssistantService } from './assistant.service';+import { AssistantCardContext } from './cards/card-context';import { MikroOrmModule } from '@mikro-orm/nestjs';import { Module } from '@nestjs/common';@@ -29,13 +31,15 @@ import { Module } from '@nestjs/common';* model the user's connection reaches (AiConnectionsModule), working the trip* through the MCP tools of the global registry. A file attached in the chat* is read through the booking import, and an answer shared in the trip's- * chat is posted through the collab chat. Its conversations are kept per user- * and trip and swept by the retention job.+ * chat is posted through the collab chat. A card names an airport through the+ * airports' data. Its conversations are kept per user and trip and swept by+ * the retention job.*/@Module({imports: [AddonsModule,AiConnectionsModule,+ AirportsModule,AuditModule,BookingImportModule,CollabModule,@@ -57,6 +61,7 @@ import { Module } from '@nestjs/common';AssistantFoundPlacesService,AssistantShareService,AssistantRetentionJob,+ AssistantCardContext,{ provide: AssistantStreamRegistry, useClass: InMemoryAssistantStreamRegistry },],})diff --git a/server/src/nest/assistant/assistant.prompt.ts b/server/src/nest/assistant/assistant.prompt.tsindex 7129d9ce0..5ed9e99a6 100644--- a/server/src/nest/assistant/assistant.prompt.ts+++ b/server/src/nest/assistant/assistant.prompt.ts@@ -1,3 +1,5 @@+import { CARD_PROMPT_LINES } from './cards/registry';+/*** The assistant's standing instructions. They stay the same for every turn* of a conversation (the provider caches them); what changes from turn to@@ -33,7 +35,10 @@ How you work:- For the wind on a day (a paddle, a sail, a ridge walk), use get_wind_forecast: it has the gusts and the direction hour by hour.- If the request is unclear, ask one short question instead of guessing.`;+/** The instructions with the packages' lines about their cards, built once so the provider's cache holds. */+const STANDING = INSTRUCTIONS + CARD_PROMPT_LINES.map((line) => `\n- ${line}`).join('');+/** The standing instructions, telling the model which language to answer in. */export function systemPrompt(language: string): string {- return INSTRUCTIONS.replace('{language}', language);+ return STANDING.replace('{language}', language);}diff --git a/server/src/nest/assistant/assistant.service.ts b/server/src/nest/assistant/assistant.service.tsindex 730694034..a9426dac4 100644--- a/server/src/nest/assistant/assistant.service.ts+++ b/server/src/nest/assistant/assistant.service.ts@@ -2,10 +2,11 @@ import { AssistantMessages } from '../../db/entities/AssistantMessages.entity';import { AssistantThreads } from '../../db/entities/AssistantThreads.entity';import { AssistantToolCalls } from '../../db/entities/AssistantToolCalls.entity';import {- ASSISTANT_MESSAGE_PARTS,+ ASSISTANT_MESSAGE_PARTS_WRITE,ASSISTANT_PROVIDER_STATE,ASSISTANT_TOOL_ARGS,ASSISTANT_TOOL_PREVIEW,+ ASSISTANT_TOOL_PREVIEW_WRITE,ASSISTANT_TOOL_RESULT,} from '../../db/json-columns';import type {@@ -34,18 +35,17 @@ import { SettingsService } from '../settings/settings.service';import { runAgentLoop, type AgentStore, type HeldCall, type StepRecord } from './assistant-agent';import { AssistantBookingImportService } from './assistant-booking-import.service';import { mentionItems } from './assistant-cards.helpers';-import { buildTripCard, categoriesFrom, languageName, todayIn, turnContext, type TripCard } from './assistant-context';+import { buildTripCard, languageName, todayIn, turnContext, type TripCard } from './assistant-context';import { DISCARDED, NOT_RUN, type Outcome, withCancelled, withOutcomes } from './assistant-decisions.helpers';import { messageIdOf, outputText, partsOf, toChatHistory, toThreadMessages } from './assistant-history';import { rememberForTrip } from './assistant-memory';-import { toolOutputForProvider } from './assistant-redact';+import { toolOutputForProvider } from './assistant-output';import { AssistantStreamRegistry } from './assistant-stream.registry';import { titleFrom } from './assistant-title';import {ADD_FOUND_PLACE_TOOL,APPROVAL_TTL_MS,ASSISTANT_SERVER_WRITE_TOOLS,- ASSISTANT_UNDO_MAP,foundPlaceArgs,IMPORT_BOOKING_TOOL,READ_BOOKING_FILE_TOOL,@@ -55,9 +55,11 @@ import {writeToolOf,} from './assistant-tools.constants';import { AssistantToolsService, type AssistantToolSession, type ToolRun } from './assistant-tools.service';-import { unchangedSinceApplied } from './assistant-undo.helpers';+import { unchangedSinceApplied, undoSnapshotOf, undoTargetsOf } from './assistant-undo.helpers';import { systemPrompt } from './assistant.prompt';-import { appliedChange, describeToolCall } from './tool-call-preview.helpers';+import { AssistantCardContext } from './cards/card-context';+import { ASSISTANT_UNDO_MAP } from './cards/registry';+import { appliedChange } from './tool-call-preview.helpers';import { UiStreamWriter } from './ui-stream.writer';import { MikroORM } from '@mikro-orm/core';import { InjectRepository } from '@mikro-orm/nestjs';@@ -65,6 +67,7 @@ import { Injectable } from '@nestjs/common';import type {AssistantAttachmentRequest,AssistantChatRequest,+ AssistantClientCtx,AssistantDecision,AssistantDecisionsRequest,AssistantFocus,@@ -133,7 +136,7 @@ function summaryOf(thread: AssistantThreadRow): AssistantThreadSummary {}function encodeParts(parts: AssistantMessagePart[]): string {- return encodeJson(ASSISTANT_MESSAGE_PARTS, parts);+ return encodeJson(ASSISTANT_MESSAGE_PARTS_WRITE, parts);}const threadNotFound = () => aiRefusal('not_found', 'Conversation not found');@@ -166,6 +169,7 @@ export class AssistantService {private readonly streams: AssistantStreamRegistry,private readonly uow: UnitOfWork,private readonly orm: MikroORM,+ private readonly cardContext: AssistantCardContext,) {}async listThreads(userId: number, tripId: number): Promise<AssistantThreadListResponse> {@@ -265,7 +269,8 @@ export class AssistantService {if (begun.created) w.thread(begun.threadId, begun.title);const stopKeepalive = armKeepalive(stream);try {- const turn = { userId, tripId, threadId: begun.threadId, rowId: begun.rowId, locale: req.locale, name };+ const { locale, timeZone } = req;+ const turn = { userId, tripId, threadId: begun.threadId, rowId: begun.rowId, locale, timeZone, name };await this.proposeBookings(turn, file, w, signal);} catch (err) {const reason = err instanceof Error ? err.message : String(err);@@ -416,19 +421,13 @@ export class AssistantService {const tool = writeToolOf(call.tool_name, args);const undo = ASSISTANT_UNDO_MAP[tool];const result = decodeJson(ASSISTANT_TOOL_RESULT, call.result, `tool call ${call.id}`);- const undoArgs = undo && call.state === 'executed' ? undo.args(args, result) : null;+ const preview = decodeJson(ASSISTANT_TOOL_PREVIEW, call.preview, `tool call ${call.id}`);+ const undoArgs = undo && call.state === 'executed' ? undo.args(args, result, preview) : null;if (!undo || !undoArgs) throw stale();- const session = await this.tools.open(userId, tripId, new Set([undo.tool, 'get_trip_summary', 'list_places']));+ const session = await this.tools.open(userId, tripId, undoTargetsOf(undo.tool, tool, args, result));try {- const summary = await session.read('get_trip_summary');- const places = await session.read('list_places');- if (- !summary.ok ||- !places.ok ||- !unchangedSinceApplied(tool, result, { summary: summary.value, places: places.value })- ) {- throw stale();- }+ const snapshot = await undoSnapshotOf(session, tool, args, result);+ if (!snapshot || !unchangedSinceApplied(tool, result, snapshot)) throw stale();if (!(await this.toolCalls.claimUndo(call.id, userId, dbNow()))) throw stale();const run = await session.call(undo.tool, undoArgs);if (!run.ok) {@@ -530,7 +529,7 @@ export class AssistantService {* transaction of its own.*/private async proposeBookings(- turn: { userId: number; tripId: number; threadId: number; rowId: number; locale: string; name: string },+ turn: { userId: number; tripId: number; threadId: number; rowId: number; name: string } & AssistantClientCtx,file: Express.Multer.File,w: UiStreamWriter,signal: AbortSignal,@@ -574,18 +573,14 @@ export class AssistantService {return;}const card = await this.tripCardOf(turn.userId, turn.tripId);- const ctx = { card, categories: new Map<number, string>(), locale: turn.locale };- const held: HeldCall[] = items.map((item) => {- const id = randomUUID();- const args = item as Record<string, unknown>;- return {- id,- providerCallId: `import_${id}`,- toolName: IMPORT_BOOKING_TOOL,- args,- preview: describeToolCall(IMPORT_BOOKING_TOOL, id, args, ctx),- };- });+ const ctx = this.cardContext.contextOf(card, new Map(), turn.locale, todayIn(turn.timeZone, new Date()));+ const proposed = items.map((item) => ({+ id: randomUUID(),+ toolName: IMPORT_BOOKING_TOOL,+ args: item as Record<string, unknown>,+ }));+ const described = await this.cardContext.describeProposed(turn.userId, turn.tripId, ctx, proposed);+ const held: HeldCall[] = described.map((change) => ({ ...change, providerCallId: `import_${change.id}` }));const parts: AssistantMessagePart[] = [readPart(found),...held.map((change): AssistantMessagePart => ({@@ -613,7 +608,7 @@ export class AssistantService {try {const summary = await session.read('get_trip_summary');const places = await session.read('list_places');- return buildTripCard(tripId, summary.ok ? summary.value : null, places.ok ? places.value : null, null);+ return buildTripCard(tripId, userId, summary.ok ? summary.value : null, places.ok ? places.value : null, null);} finally {await session.close();}@@ -714,7 +709,8 @@ export class AssistantService {const args = decodeJson(ASSISTANT_TOOL_ARGS, call.args, `tool call ${call.id}`);const ran = await run(call.tool_name, args);const output = toolOutputForProvider(call.tool_name, ran.value);- const undoable = ran.ok && !!ASSISTANT_UNDO_MAP[writeToolOf(call.tool_name, args)]?.args(args, ran.value);+ const preview = decodeJson(ASSISTANT_TOOL_PREVIEW, call.preview, `tool call ${call.id}`);+ const undoable = ran.ok && !!ASSISTANT_UNDO_MAP[writeToolOf(call.tool_name, args)]?.args(args, ran.value, preview);const undoUntil = undoable ? dbNow(new Date(Date.now() + UNDO_WINDOW_MS)) : null;await this.inContext(() =>this.toolCalls.recordOutcome(@@ -731,7 +727,6 @@ export class AssistantService {return;}w.toolOutput(call.id, output);- const preview = decodeJson(ASSISTANT_TOOL_PREVIEW, call.preview, `tool call ${call.id}`);const applied = appliedChange(call.tool_name,call.id,@@ -744,6 +739,7 @@ export class AssistantService {w.applied(applied);receipts.push({ type: 'data-trek-applied', data: applied });}+ this.cardContext.receipt(w, receipts, call, args, ran.value, preview);}/**@@ -832,21 +828,17 @@ export class AssistantService {const providerIds = new Map([...calls.values()].map((call) => [call.id, call.provider_call_id]));const history = toChatHistory(rows, providerIds);const prefs = await this.inContext(() => this.settings.getUserSettings(spec.userId));- let categories: Map<number, string> | null = null;+ const today = todayIn(spec.timeZone, new Date());const outcome = await runAgentLoop({client: this.chatClients.create(spec.connection),tools: session,store: this.stepStore(spec),- describe: async (toolName, toolCallId, args) => {- categories ??= await this.categoriesOf(session);- const hintOf = (name: string) => session.hintOf(name);- return describeToolCall(toolName, toolCallId, args, { card, categories, locale: spec.locale, hintOf });- },+ describe: this.cardContext.forTurn(session, card, spec.locale, today).describe,newId: randomUUID,quota: spec.quota,card,- today: todayIn(spec.timeZone, new Date()),+ today,},{system: systemPrompt(languageName(spec.locale)),@@ -890,13 +882,7 @@ export class AssistantService {const summary = await session.read('get_trip_summary');const places = await session.read('list_places');const [found, listed] = [summary.ok ? summary.value : null, places.ok ? places.value : null];- return buildTripCard(spec.tripId, found, listed, spec.focus, spec.mentions);- }-- private async categoriesOf(session: AssistantToolSession): Promise<Map<number, string>> {- const run = await session.read('list_categories');- const categories = categoriesFrom(run.ok ? run.value : null);- return new Map(categories.map((category): [number, string] => [category.id, category.name]));+ return buildTripCard(spec.tripId, spec.userId, found, listed, spec.focus, spec.mentions);}/**@@ -973,7 +959,7 @@ export class AssistantService {providerCallId: change.providerCallId,toolName: change.toolName,args: encodeJson(ASSISTANT_TOOL_ARGS, change.args),- preview: encodeJson(ASSISTANT_TOOL_PREVIEW, change.preview),+ preview: encodeJson(ASSISTANT_TOOL_PREVIEW_WRITE, change.preview),createdAt,};}diff --git a/server/src/nest/assistant/cards/applied-cards.ts b/server/src/nest/assistant/cards/applied-cards.tsnew file mode 100644index 000000000..32f4ba395--- /dev/null+++ b/server/src/nest/assistant/cards/applied-cards.ts@@ -0,0 +1,33 @@+import { writeToolOf } from '../assistant-tools.constants';+import type { UiStreamWriter } from '../ui-stream.writer';+import type { ToolArgs } from './card-types';+import { appliedCardOf } from './registry';+import type { AssistantChangePreview, AssistantMessagePart, TrekCard } from '@trek/shared';++/** Builds the card of an applied change of `tool`; null when the tool has none. */+type AppliedCardBuilder = (+ tool: string,+ input: { args: ToolArgs; result: unknown; preview: AssistantChangePreview | null },+) => TrekCard | null;++/**+ * The card of an applied change, streamed and kept beside its receipt under+ * the write's own id, so the client puts it in place of the preview card. Its+ * builder gets no trip card (the decisions run before the turn reads one): it+ * builds on the stored preview card and the tool's raw answer.+ */+export function receiptCard(+ w: Pick<UiStreamWriter, 'card'>,+ receipts: AssistantMessagePart[],+ call: { id: string; tool_name: string },+ args: ToolArgs,+ result: unknown,+ preview: AssistantChangePreview | null,+ build: AppliedCardBuilder = appliedCardOf,+): void {+ const card = build(writeToolOf(call.tool_name, args), { args, result, preview });+ if (!card) return;+ const data = { toolCallId: call.id, card };+ w.card(data);+ receipts.push({ type: 'data-trek-card', data });+}diff --git a/server/src/nest/assistant/cards/atlas/index.ts b/server/src/nest/assistant/cards/atlas/index.tsnew file mode 100644index 000000000..7ce009986--- /dev/null+++ b/server/src/nest/assistant/cards/atlas/index.ts@@ -0,0 +1,4 @@+import type { DomainCards } from '../card-types';++/** The cards of the atlas: countries, regions and the bucket list. None yet: this package fills them in. */+export const ATLAS_CARDS: DomainCards = { id: 'atlas', tools: {} };diff --git a/server/src/nest/assistant/cards/booking/index.ts b/server/src/nest/assistant/cards/booking/index.tsnew file mode 100644index 000000000..fbdf9d053--- /dev/null+++ b/server/src/nest/assistant/cards/booking/index.ts@@ -0,0 +1,4 @@+import type { DomainCards } from '../card-types';++/** The cards of the bookings: flights, trains, stays and other reservations. None yet: this package fills them in. */+export const BOOKING_CARDS: DomainCards = { id: 'booking', tools: {} };diff --git a/server/src/nest/assistant/cards/budget/index.ts b/server/src/nest/assistant/cards/budget/index.tsnew file mode 100644index 000000000..8a45a950e--- /dev/null+++ b/server/src/nest/assistant/cards/budget/index.ts@@ -0,0 +1,4 @@+import type { DomainCards } from '../card-types';++/** The cards of the budget: expenses, payments and who settles with whom. None yet: this package fills them in. */+export const BUDGET_CARDS: DomainCards = { id: 'budget', tools: {} };diff --git a/server/src/nest/assistant/cards/card-context.ts b/server/src/nest/assistant/cards/card-context.tsnew file mode 100644index 000000000..c35df2dab--- /dev/null+++ b/server/src/nest/assistant/cards/card-context.ts@@ -0,0 +1,182 @@+import { AirportsService } from '../../airports/airports.service';+import { logWarn } from '../../audit/audit-log.logger';+import { categoriesFrom, type TripCard } from '../assistant-context';+import { writeToolOf } from '../assistant-tools.constants';+import { AssistantToolsService, type AssistantToolSession } from '../assistant-tools.service';+import { describeToolCall } from '../tool-call-preview.helpers';+import type { UiStreamWriter } from '../ui-stream.writer';+import { receiptCard } from './applied-cards';+import type { CardAirport, CardReader, PreviewContext, ToolArgs, ToolCards } from './card-types';+import { readKey } from './card-values';+import { appliedCardOf, TOOL_CARDS } from './registry';+import { Injectable } from '@nestjs/common';+import type { AssistantChangePreview, AssistantMessagePart, TrekCard } from '@trek/shared';++/** Reads one held change's lookup may make; the ones past it read as null. */+export const MAX_CARD_READS = 4;++/** What the turn's reads go through: the session, unaudited. */+type ReadSession = Pick<AssistantToolSession, 'read'>;++/** A change the server proposes itself, before its card is written. */+interface ProposedCall {+ id: string;+ toolName: string;+ args: ToolArgs;+}++/** A turn's describer of held calls, as the agent loop asks for it. */+interface TurnCards {+ describe(tool: string, toolCallId: string, args: ToolArgs): Promise<AssistantChangePreview>;+}++/**+ * Reads through the session, each tool and set of arguments once per turn:+ * the second card that asks for the same read gets the first one's answer.+ * A read that failed reads as null.+ */+export function memoisedReader(session: ReadSession): (tool: string, args?: ToolArgs) => Promise<unknown> {+ const memo = new Map<string, Promise<unknown>>();+ return (tool, args = {}) => {+ const key = readKey(tool, args);+ let read = memo.get(key);+ if (!read) {+ read = session.read(tool, args).then(+ (run) => (run.ok ? run.value : null),+ () => null,+ );+ memo.set(key, read);+ }+ return read;+ };+}++/**+ * The reader one held change's lookup gets: the turn's, cut off after+ * MAX_CARD_READS reads. A read the memo answers counts too, so a lookup asks+ * at most that often whatever the turn read before it.+ */+function cappedReader(read: CardReader, tool: string): CardReader {+ let left = MAX_CARD_READS;+ return (name, args) => {+ if (left <= 0) {+ logWarn(`[assistant] the lookup of ${tool} asked for more than ${MAX_CARD_READS} reads`);+ return Promise.resolve(null);+ }+ left -= 1;+ return read(name, args);+ };+}++/** What a package's lookup found for a held call, or null when it has none or it failed. */+export async function loadFor(+ tool: string,+ args: ToolArgs,+ read: CardReader,+ registry: Readonly<Record<string, ToolCards>> = TOOL_CARDS,+): Promise<unknown> {+ const cards = registry[tool];+ if (!cards?.load) return null;+ try {+ return (await cards.load(args, cappedReader(read, tool))) ?? null;+ } catch (err) {+ logWarn(`[assistant] the lookup of ${tool} failed: ${err instanceof Error ? err.message : String(err)}`);+ return null;+ }+}++/**+ * What the assistant makes its cards with beyond the tool's own answer: the+ * context a change card is written in (the trip card, the categories, the+ * user's locale and day, the airports), the lookups a package's card makes+ * before it is shown, and the card of an applied change.+ */+@Injectable()+export class AssistantCardContext {+ constructor(+ private readonly airports: AirportsService,+ private readonly tools: AssistantToolsService,+ ) {}++ /**+ * The describer of one turn's held calls. The categories are read once,+ * when the first change needs them; a package's lookup reads through the+ * turn's memo, at most MAX_CARD_READS reads per change.+ */+ forTurn(session: ReadSession & Pick<AssistantToolSession, 'hintOf'>, card: TripCard, locale: string, today: string) {+ const read = memoisedReader(session);+ const hintOf = (name: string) => session.hintOf(name);+ let categories: Promise<ReadonlyMap<number, string>> | null = null;+ const turn: TurnCards = {+ describe: async (tool, toolCallId, args) => {+ categories ??= read('list_categories').then(+ (value) => new Map(categoriesFrom(value).map((category): [number, string] => [category.id, category.name])),+ );+ const ctx = this.contextOf(card, await categories, locale, today, hintOf);+ const loaded = await loadFor(writeToolOf(tool, args), args, read);+ return describeToolCall(tool, toolCallId, args, ctx, loaded);+ },+ };+ return turn;+ }++ /** The context a change card is written in, for a change the server proposes without a turn. */+ contextOf(+ card: TripCard,+ categories: ReadonlyMap<number, string>,+ locale: string,+ today: string,+ hintOf?: PreviewContext['hintOf'],+ ): PreviewContext {+ return { card, categories, locale, today, ...(hintOf ? { hintOf } : {}), airport: (code) => this.airport(code) };+ }++ /**+ * The change cards of changes the server proposes without a turn (a booking+ * from a file, a found place), each with what its package looked up. A+ * session for the lookups is opened only when one of the tools has a lookup.+ */+ async describeProposed<C extends ProposedCall>(+ userId: number,+ tripId: number,+ ctx: PreviewContext,+ calls: readonly C[],+ registry: Readonly<Record<string, ToolCards>> = TOOL_CARDS,+ ): Promise<Array<C & { preview: AssistantChangePreview }>> {+ const looksUp = calls.some((call) => !!registry[writeToolOf(call.toolName, call.args)]?.load);+ const session = looksUp ? await this.tools.open(userId, tripId) : null;+ try {+ const read: CardReader = session ? memoisedReader(session) : () => Promise.resolve(null);+ return await Promise.all(+ calls.map(async (call) => {+ const loaded = await loadFor(writeToolOf(call.toolName, call.args), call.args, read, registry);+ return { ...call, preview: describeToolCall(call.toolName, call.id, call.args, ctx, loaded) };+ }),+ );+ } finally {+ await session?.close();+ }+ }++ /** The card of an applied change beside its receipt, streamed and kept on the proposing message. */+ receipt(+ w: Pick<UiStreamWriter, 'card'>,+ receipts: AssistantMessagePart[],+ call: { id: string; tool_name: string },+ args: ToolArgs,+ result: unknown,+ preview: AssistantChangePreview | null,+ ): void {+ receiptCard(w, receipts, call, args, result, preview, (tool, input) => this.appliedCard(tool, input));+ }++ /** The guarded applied card of `tool`; the e2e suite stubs it here. */+ appliedCard(tool: string, input: Parameters<typeof appliedCardOf>[1]): TrekCard | null {+ return appliedCardOf(tool, input);+ }++ private airport(code: string): CardAirport | null {+ const found = /^[A-Za-z]{3}$/.test(code) ? this.airports.findByIata(code.toUpperCase()) : null;+ return found ? { city: found.city || found.name, lat: found.lat, lng: found.lng, tz: found.tz } : null;+ }+}diff --git a/server/src/nest/assistant/cards/card-types.ts b/server/src/nest/assistant/cards/card-types.tsnew file mode 100644index 000000000..33e6de720--- /dev/null+++ b/server/src/nest/assistant/cards/card-types.ts@@ -0,0 +1,144 @@+import type { TripCard } from '../assistant-context';+import type { AssistantWriteTool } from '../assistant-tools.constants';+import type { ToolHint } from '../assistant-tools.service';+import type { Rows } from './preview-format';+import type { AssistantChangeEffect, AssistantChangePreview, AssistantChangeVerbKey, TrekCard } from '@trek/shared';++/**+ * What a part of TREK hands the assistant for its tools: one `ToolCards`+ * entry per tool, gathered per package in `cards/<pkg>/index.ts` and merged+ * by `registry.ts`. Types only, so any file may import them.+ */++export type ToolArgs = Record<string, unknown>;++/** The packages that bring cards of their own, one folder each. */+type CardPackageId =+ 'tour' | 'roadtrip' | 'budget' | 'booking' | 'collab' | 'collection' | 'atlas' | 'vacay' | 'journey' | 'packing';++/**+ * A read a card may make while a change is described: unaudited, made once+ * per turn for the same tool and arguments, null on any failure.+ */+export type CardReader = (tool: string, args?: ToolArgs) => Promise<unknown>;++/** An airport as a card names it, by its IATA code. */+export interface CardAirport {+ city: string;+ lat: number;+ lng: number;+ tz: string;+}++/** What a change card is written with. */+export interface PreviewContext {+ card: TripCard;+ categories: ReadonlyMap<number, string>;+ locale: string;+ /** Today in the user's time zone (`YYYY-MM-DD`). */+ today: string;+ /** What a tool without a card of its own says about itself, for the card built from its arguments. */+ hintOf?: (tool: string) => ToolHint | null;+ airport: (code: string) => CardAirport | null;+}++/**+ * A change described in plain words. `verbKey`, `tool` and `domain` override+ * what the tool's `write` entry and the generic card would say: a verb that+ * depends on the arguments, the tool's own label, the part of TREK it works in.+ */+export interface Described {+ subject: string;+ rows: Rows;+ dayId: number | null;+ placeIds: number[];+ verbKey?: AssistantChangeVerbKey;+ tool?: string;+ domain?: string;+}++/** What an answer card is built from: a read that ran, with its raw value (never the redacted one). */+export interface AnswerInput {+ toolCallId: string;+ args: ToolArgs;+ value: unknown;+ card: TripCard;+ today: string;+}++/**+ * What an undo is checked against: the trip as `get_trip_summary` and+ * `list_places` answer it, and the reads the change's `undo.reads` asked for,+ * by `readKey(tool, args)` (null for one that failed).+ */+export interface UndoSnapshot {+ summary: unknown;+ places: unknown;+ reads: ReadonlyMap<string, unknown>;+}++/** The way back from an applied change: the removing tool and its arguments, null when there is none. */+export interface ToolUndo {+ tool: string;+ args(args: ToolArgs, result: unknown, preview: AssistantChangePreview | null): ToolArgs | null;+}++/**+ * Everything a package says about one tool. Every member is optional and+ * written as a method, so a `ToolCards<X>` fits where a `ToolCards` is asked.+ * A builder that throws, returns a card the union refuses or one past+ * MAX_CARD_CHARS gives no card (logged), never a broken turn; any other+ * member that throws is logged and read as saying nothing (registry.ts).+ */+export interface ToolCards<L = unknown> {+ /** A curated change card: its verb and what the applied change touches. */+ write?: AssistantWriteTool;+ /** Arguments the model never chooses: `forced` ones are set, `stripped` ones taken away. */+ argPolicy?: { forced?: ToolArgs; stripped?: readonly string[] };+ /** The answer as the provider gets it, before redaction and fitting. */+ project?(value: unknown): unknown;+ /** The card a read shows beside the answer; only for a read that ran well. */+ answer?(input: AnswerInput): TrekCard | null;+ /** What describing a held call needs beyond the trip card: at most four reads, null on failure. */+ load?(args: ToolArgs, read: CardReader): Promise<L | null>;+ /** The change card's words; must give a valid card for `{}` arguments too. */+ describe?(ctx: PreviewContext, args: ToolArgs, loaded: L | null): Described;+ /** What the change does to the day plan, for the map and the day's timeline. */+ effect?(ctx: PreviewContext, args: ToolArgs, loaded: L | null): AssistantChangeEffect | null;+ /** The card a held call shows inside its change card. */+ change?(ctx: PreviewContext, args: ToolArgs, loaded: L | null): TrekCard | null;+ /** The card of the applied change, from the stored preview card and the tool's raw answer. */+ applied?(input: { args: ToolArgs; result: unknown; preview: AssistantChangePreview | null }): TrekCard | null;+ /** The ids the receipt names, when the answer does not name them under the usual keys. */+ appliedIds?(args: ToolArgs, result: unknown): number[];+ /** The way back, with what it reads first and how it tells that nothing changed since. */+ undo?: ToolUndo & {+ /**+ * Reads the undo makes before it checks; every tool named here must be+ * registered. The boot check asks with empty arguments and result, so the+ * tools it names may not depend on them (their arguments may).+ */+ reads?(args: ToolArgs, result: unknown): ReadonlyArray<{ tool: string; args: ToolArgs }>;+ unchanged(result: unknown, snapshot: UndoSnapshot): boolean;+ };+ /** The name of an id argument the trip card cannot name, for the generic card. */+ nameArg?(key: string, value: number, card: TripCard): string | null;+}++/** One package's cards. */+export interface DomainCards {+ readonly id: CardPackageId;+ readonly tools: Readonly<Record<string, ToolCards>>;+ /** At most two lines for the standing instructions, added once at load so the prompt cache stays stable. */+ readonly prompt?: readonly string[];+ /** Tool groups whose `placeId` arguments are no trip places (collections, atlas). */+ readonly foreignIdGroups?: readonly string[];+ /**+ * MCP controllers the package added, by the tool group they load with (a+ * key of ASSISTANT_TOOL_GROUPS); a controller listed nowhere is offered on+ * every step as part of the core.+ */+ readonly toolControllers?: Readonly<Record<string, readonly string[]>>;+ /** Read-only tools that still wait for the user: they fetch an address that came from the web or a message. */+ readonly heldReads?: readonly string[];+}diff --git a/server/src/nest/assistant/cards/card-values.ts b/server/src/nest/assistant/cards/card-values.tsnew file mode 100644index 000000000..fb396cc0e--- /dev/null+++ b/server/src/nest/assistant/cards/card-values.ts@@ -0,0 +1,134 @@+import type { TripCard } from '../assistant-context';+import { redactForProvider } from '../assistant-redact';+import { cardFileKeySchema, type CardPerson } from '@trek/shared';++/**+ * The readers every card is built with. They take a tool's own answer or a+ * call's arguments as they come, trust no shape, and give null for what is+ * not there. Text from a RESULT is masked like a provider answer (`clipped`,+ * `blockText` with `mask`), so an e-mail address in a name or a note never+ * reaches a card; text from ARGS is only cut, since it is what will be stored.+ */++export type Row = Record<string, unknown>;++export function recordOf(value: unknown): Row {+ return value && typeof value === 'object' && !Array.isArray(value) ? (value as Row) : {};+}++export function finite(value: unknown): number | null {+ return typeof value === 'number' && Number.isFinite(value) ? value : null;+}++export function isLat(value: number | null): value is number {+ return value !== null && Math.abs(value) <= 90;+}++export function isLng(value: number | null): value is number {+ return value !== null && Math.abs(value) <= 180;+}++function cut(text: string, max: number): string {+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;+}++/** A text as a card may show it: on one line, masked like a provider answer, and cut to `max`. */+export function clipped(value: unknown, max: number): string | null {+ if (typeof value !== 'string') return null;+ const line = String(redactForProvider(value.replace(/\s+/g, ' ').trim()));+ return line === '' ? null : cut(line, max);+}++/**+ * A longer text (a note, a message) with its line breaks kept: spaces run+ * together, at most one empty line between paragraphs, cut to `max`. Masked+ * when it comes from a result.+ */+export function blockText(value: unknown, max: number, { mask }: { mask: boolean }): string | null {+ if (typeof value !== 'string') return null;+ const lines = value+ .replace(/\r\n?/g, '\n')+ .split('\n')+ .map((line) => line.replace(/[^\S\n]+/g, ' ').trim());+ const text = lines+ .join('\n')+ .replace(/\n{3,}/g, '\n\n')+ .trim();+ const shown = mask ? String(redactForProvider(text)) : text;+ return shown === '' ? null : cut(shown, max);+}++function positiveId(value: unknown): number | null {+ return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : null;+}++/** The id of the row an answer names under `key` (`{ place: { id } }`). */+export function idIn(value: unknown, key: string): number | null {+ return positiveId(recordOf(recordOf(value)[key]).id);+}++/** An argument read as an id. */+export function argId(args: Row, key: string): number | null {+ return positiveId(args[key]);+}++const CLOCK = /^(?:\d{4}-\d{2}-\d{2}[T ])?([01]?\d|2[0-3]):([0-5]\d)(?::[0-5]\d(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/;++/** A time of day as `HH:MM`, from a clock (`9:30`, `09:30:00`) or the clock of a date and time as written. */+export function clockOf(value: unknown): string | null {+ if (typeof value !== 'string') return null;+ const match = CLOCK.exec(value.trim());+ return match ? `${match[1].padStart(2, '0')}:${match[2]}` : null;+}++const ZONED = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})$/;++/**+ * A moment as `YYYY-MM-DDTHH:MM:SSZ`, from a date and time that names its+ * zone. One without a zone is a local time and no moment, so it gives null.+ */+export function instantOf(value: unknown): string | null {+ if (typeof value !== 'string' || !ZONED.test(value.trim())) return null;+ const ms = Date.parse(value.trim());+ return Number.isNaN(ms) ? null : `${new Date(ms).toISOString().slice(0, 19)}Z`;+}++/** A colour the data carries, `#rrggbb`; anything else gives null. */+export function hexOrNull(value: unknown): string | null {+ return typeof value === 'string' && /^#[0-9a-fA-F]{6}$/.test(value) ? value : null;+}++/**+ * The stored file name behind one of TREK's own upload paths+ * (`/uploads/<dir>/<file>`), for the client to build the path again. Anything+ * else, a picture on another host among them, gives null.+ */+export function fileKeyOf(raw: unknown): string | null {+ if (typeof raw !== 'string') return null;+ const match = /^\/uploads\/[\w-]+\/([^/?#]+)$/.exec(raw);+ return match && cardFileKeySchema.safeParse(match[1]).success ? match[1] : null;+}++/** A trip member as a card shows them, from the trip card; null for someone not in the trip. */+export function personOf(card: TripCard, id: number): CardPerson | null {+ const member = card.members.get(id);+ const name = member ? clipped(member.name, 80) : null;+ return member && name ? { id, name, avatarKey: member.avatarKey } : null;+}++/** JSON with the keys of every object in order, so the same arguments always give the same text. */+export function canonicalJson(value: unknown): string {+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`;+ if (value && typeof value === 'object') {+ const entries = Object.entries(value as Row)+ .filter(([, inner]) => inner !== undefined)+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));+ return `{${entries.map(([key, inner]) => `${JSON.stringify(key)}:${canonicalJson(inner)}`).join(',')}}`;+ }+ return JSON.stringify(value) ?? 'null';+}++/** How one read is named: its tool and its arguments, the same for the same read whatever the key order. */+export function readKey(tool: string, args: Row = {}): string {+ return `${tool} ${canonicalJson(args)}`;+}diff --git a/server/src/nest/assistant/cards/collab/index.ts b/server/src/nest/assistant/cards/collab/index.tsnew file mode 100644index 000000000..51adf51c0--- /dev/null+++ b/server/src/nest/assistant/cards/collab/index.ts@@ -0,0 +1,4 @@+import type { DomainCards } from '../card-types';++/** The cards of the trip chat: messages, polls and shared notes. None yet: this package fills them in. */+export const COLLAB_CARDS: DomainCards = { id: 'collab', tools: {} };diff --git a/server/src/nest/assistant/cards/collection/index.ts b/server/src/nest/assistant/cards/collection/index.tsnew file mode 100644index 000000000..2574988f2--- /dev/null+++ b/server/src/nest/assistant/cards/collection/index.ts@@ -0,0 +1,4 @@+import type { DomainCards } from '../card-types';++/** The cards of the collections and their places. None yet: this package fills them in. */+export const COLLECTION_CARDS: DomainCards = { id: 'collection', tools: {} };diff --git a/server/src/nest/assistant/cards/journey/index.ts b/server/src/nest/assistant/cards/journey/index.tsnew file mode 100644index 000000000..97ab4e8a6--- /dev/null+++ b/server/src/nest/assistant/cards/journey/index.ts@@ -0,0 +1,4 @@+import type { DomainCards } from '../card-types';++/** The cards of the travel journal. None yet: this package fills them in. */+export const JOURNEY_CARDS: DomainCards = { id: 'journey', tools: {} };diff --git a/server/src/nest/assistant/cards/packing/index.ts b/server/src/nest/assistant/cards/packing/index.tsnew file mode 100644index 000000000..1d093a456--- /dev/null+++ b/server/src/nest/assistant/cards/packing/index.ts@@ -0,0 +1,4 @@+import type { DomainCards } from '../card-types';++/** The cards of packing lists and to-dos. None yet: this package fills them in. */+export const PACKING_CARDS: DomainCards = { id: 'packing', tools: {} };diff --git a/server/src/nest/assistant/cards/preview-format.ts b/server/src/nest/assistant/cards/preview-format.tsnew file mode 100644index 000000000..960458ff1--- /dev/null+++ b/server/src/nest/assistant/cards/preview-format.ts@@ -0,0 +1,115 @@+import type { PreviewContext } from './card-types';+import type { AssistantChangeLabelKey, AssistantChangeRow } from '@trek/shared';++/**+ * How a change card writes what it shows: a value cut to what a row holds,+ * an argument read as an id, dates and amounts in the user's locale, days,+ * places, people and categories by their names. Shared by the core cards+ * (tool-call-preview.helpers.ts) and every package's own.+ */++type Args = Record<string, unknown>;++/** What naming a day or a place needs of the context. */+type Naming = Pick<PreviewContext, 'card' | 'locale'>;++/** Longest value a row shows; URLs keep their start, so the host stays visible. */+const MAX_VALUE_CHARS = 160;++const CHECKED = '✓';+export const UNCHECKED = '✗';++export function clip(value: string): string {+ const line = value.replace(/\s+/g, ' ').trim();+ return line.length > MAX_VALUE_CHARS ? `${line.slice(0, MAX_VALUE_CHARS - 1)}…` : line;+}++export function id(args: Args, key: string): number | null {+ const value = args[key];+ return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : null;+}++export function text(value: unknown): string {+ if (value === null || value === undefined) return '';+ if (typeof value === 'boolean') return value ? CHECKED : UNCHECKED;+ return clip(String(value));+}++export class Rows {+ readonly rows: AssistantChangeRow[] = [];++ add(labelKey: AssistantChangeLabelKey, after: string): this {+ if (after !== '') this.rows.push({ op: 'add', labelKey, before: null, after });+ return this;+ }++ change(labelKey: AssistantChangeLabelKey, before: string | null, after: string): this {+ this.rows.push({ op: 'change', labelKey, before: before || null, after });+ return this;+ }++ move(labelKey: AssistantChangeLabelKey, before: string, after: string): this {+ this.rows.push({ op: 'move', labelKey, before: before || null, after });+ return this;+ }+}++/** A locale Intl accepts, the user's when it can. */+export function localeOf(ctx: Pick<PreviewContext, 'locale'>): string {+ try {+ return Intl.getCanonicalLocales(ctx.locale)[0] ?? 'en';+ } catch {+ return 'en';+ }+}++export function formatDate(ctx: Pick<PreviewContext, 'locale'>, isoDate: string): string {+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(isoDate);+ if (!match) return isoDate;+ const date = new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])));+ return new Intl.DateTimeFormat(localeOf(ctx), {+ weekday: 'short',+ day: 'numeric',+ month: 'short',+ timeZone: 'UTC',+ }).format(date);+}++export function formatDateTime(ctx: Pick<PreviewContext, 'locale'>, value: string): string {+ const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(value);+ return match ? `${formatDate(ctx, match[1])}, ${match[2]}` : value;+}++/** A day as the planner names it: its date (and title), or its title, or its number. */+export function dayLabel(ctx: Naming, dayId: number | null): string {+ if (dayId === null) return '';+ const day = ctx.card.days.find((d) => d.id === dayId);+ if (!day) return `#${dayId}`;+ if (day.date) return day.title ? `${formatDate(ctx, day.date)}, ${day.title}` : formatDate(ctx, day.date);+ return day.title ?? `#${day.number}`;+}++export function placeName(ctx: Pick<PreviewContext, 'card'>, placeId: number | null): string {+ if (placeId === null) return '';+ return ctx.card.places.get(placeId)?.name ?? `#${placeId}`;+}++export function money(ctx: Pick<PreviewContext, 'locale'>, amount: number, currency: string | null): string {+ if (currency) {+ try {+ return new Intl.NumberFormat(localeOf(ctx), { style: 'currency', currency }).format(amount);+ } catch {+ return `${amount} ${currency}`;+ }+ }+ return new Intl.NumberFormat(localeOf(ctx)).format(amount);+}++export function memberNames(ctx: Pick<PreviewContext, 'card'>, ids: unknown): string {+ if (!Array.isArray(ids)) return '';+ return clip(ids.map((memberId) => ctx.card.members.get(Number(memberId))?.name ?? `#${String(memberId)}`).join(', '));+}++export function categoryName(ctx: Pick<PreviewContext, 'categories'>, categoryId: number | null): string {+ return categoryId === null ? '' : (ctx.categories.get(categoryId) ?? `#${categoryId}`);+}diff --git a/server/src/nest/assistant/cards/registry.ts b/server/src/nest/assistant/cards/registry.tsnew file mode 100644index 000000000..5adba726b--- /dev/null+++ b/server/src/nest/assistant/cards/registry.ts@@ -0,0 +1,350 @@+import { logWarn } from '../../audit/audit-log.logger';+import type { TripCard } from '../assistant-context';+import {+ ASSISTANT_SERVER_WRITE_TOOLS,+ CORE_ARG_POLICY,+ CORE_UNDO_MAP,+ CORE_WRITE_TOOLS,+ type AssistantWriteTool,+} from '../assistant-tools.constants';+import { ATLAS_CARDS } from './atlas';+import { BOOKING_CARDS } from './booking';+import { BUDGET_CARDS } from './budget';+import type {+ AnswerInput,+ Described,+ DomainCards,+ PreviewContext,+ ToolArgs,+ ToolCards,+ ToolUndo,+ UndoSnapshot,+} from './card-types';+import { COLLAB_CARDS } from './collab';+import { COLLECTION_CARDS } from './collection';+import { JOURNEY_CARDS } from './journey';+import { PACKING_CARDS } from './packing';+import { ROADTRIP_CARDS } from './roadtrip';+import { TOUR_CARDS } from './tour';+import { VACAY_CARDS } from './vacay';+import { idSchema, MAX_CARD_CHARS, trekCardSchema, type AssistantChangePreview, type TrekCard } from '@trek/shared';++import type { ZodType } from 'zod';++/**+ * Every package's cards, merged by tool name, and the calls the assistant+ * makes on them. A package claims the fields of the tools it knows; two+ * packages claiming one field of one tool, a package taking over a core+ * table's entry, or a describer without a verb stop the server at load,+ * before a turn could pick one of them at random. Every hook a package hands+ * in is guarded: one that throws is logged and says nothing, never a broken+ * turn, decision or undo.+ */++/** The packages, in the order their prompt lines are told. */+export const DOMAINS: readonly DomainCards[] = [+ TOUR_CARDS,+ ROADTRIP_CARDS,+ BUDGET_CARDS,+ BOOKING_CARDS,+ COLLAB_CARDS,+ COLLECTION_CARDS,+ ATLAS_CARDS,+ VACAY_CARDS,+ JOURNEY_CARDS,+ PACKING_CARDS,+];++/** Prompt lines one package may add. */+const MAX_PROMPT_LINES = 2;++type Undo = NonNullable<ToolCards['undo']>;+type UndoReads = ReadonlyArray<{ tool: string; args: ToolArgs }>;++/** The registry the assistant reads, merged from the packages. */+interface MergedCards {+ tools: Readonly<Record<string, ToolCards>>;+ writes: Readonly<Record<string, AssistantWriteTool>>;+ undo: Readonly<Record<string, ToolUndo>>;+ argPolicy: Readonly<Record<string, NonNullable<ToolCards['argPolicy']>>>;+ projections: Readonly<Record<string, (value: unknown) => unknown>>;+ promptLines: readonly string[];+ foreignIdGroups: ReadonlySet<string>;+ toolControllers: Readonly<Record<string, readonly string[]>>;+ heldReads: ReadonlySet<string>;+}++/** The core's own tables a package may not take an entry of. */+interface CoreTables {+ writes: Readonly<Record<string, unknown>>;+ undo: Readonly<Record<string, unknown>>;+ argPolicy: Readonly<Record<string, unknown>>;+}++const CORE: CoreTables = {+ writes: { ...CORE_WRITE_TOOLS, ...ASSISTANT_SERVER_WRITE_TOOLS },+ undo: CORE_UNDO_MAP,+ argPolicy: CORE_ARG_POLICY,+};++/** One field of every tool that has it, by tool name. */+function fieldOf<T>(tools: Readonly<Record<string, ToolCards>>, read: (cards: ToolCards) => T | undefined) {+ const found: Record<string, T> = {};+ for (const [tool, cards] of Object.entries(tools)) {+ const value = read(cards);+ if (value !== undefined) found[tool] = value;+ }+ return found;+}++function reason(err: unknown): string {+ return err instanceof Error ? err.message : String(err);+}++/** `run`, or `fallback` and a log line when it throws. */+function safely<T>(tool: string, what: string, fallback: T, run: () => T): T {+ try {+ return run();+ } catch (err) {+ logWarn(`[assistant] the ${what} of ${tool} failed: ${reason(err)}`);+ return fallback;+ }+}++function guardUndo(tool: string, undo: Undo): Undo {+ return {+ tool: undo.tool,+ args: (args: ToolArgs, result: unknown, preview: AssistantChangePreview | null) =>+ safely(tool, 'undo arguments', null, () => undo.args(args, result, preview)),+ ...(undo.reads+ ? {+ reads: (args: ToolArgs, result: unknown) =>+ safely<UndoReads>(tool, 'undo reads', [], () => undo.reads?.(args, result) ?? []),+ }+ : {}),+ unchanged: (result: unknown, snapshot: UndoSnapshot) =>+ safely(tool, 'undo check', false, () => undo.unchanged(result, snapshot)),+ };+}++/**+ * A package's entry with the hooks a turn, a decision or an undo calls+ * outside the card guard wrapped: one that throws is logged and reads as+ * saying nothing (the answer as it came, no effect, no ids, no way back,+ * "changed since"), never a broken turn or a write left unrecorded. Ids that+ * are no row ids are left out. The describer has its own guard, `describedOf`,+ * since the generic card stands in for it.+ */+function guardTool(tool: string, cards: ToolCards): ToolCards {+ return {+ ...cards,+ ...(cards.project+ ? { project: (value: unknown) => safely(tool, 'projection', value, () => cards.project?.(value)) }+ : {}),+ ...(cards.effect+ ? {+ effect: (ctx: PreviewContext, args: ToolArgs, loaded: unknown) =>+ safely(tool, 'effect', null, () => cards.effect?.(ctx, args, loaded) ?? null),+ }+ : {}),+ ...(cards.appliedIds+ ? {+ appliedIds: (args: ToolArgs, result: unknown) =>+ safely<number[]>(tool, 'applied ids', [], () =>+ (cards.appliedIds?.(args, result) ?? []).filter((value) => idSchema.safeParse(value).success),+ ),+ }+ : {}),+ ...(cards.nameArg+ ? {+ nameArg: (key: string, value: number, card: TripCard) =>+ safely(tool, `name of ${key}`, null, () => cards.nameArg?.(key, value, card) ?? null),+ }+ : {}),+ ...(cards.undo ? { undo: guardUndo(tool, cards.undo) } : {}),+ };+}++/** Merges the packages' cards, refusing every overlap at load. */+export function mergeDomains(domains: readonly DomainCards[], core: CoreTables = CORE): MergedCards {+ const tools: Record<string, ToolCards> = {};+ const owners = new Map<string, string>();+ const ids = new Set<string>();+ for (const domain of domains) {+ if (ids.has(domain.id)) throw new Error(`Assistant cards: package "${domain.id}" is registered twice`);+ ids.add(domain.id);+ if ((domain.prompt ?? []).length > MAX_PROMPT_LINES) {+ throw new Error(`Assistant cards: package "${domain.id}" adds more than ${MAX_PROMPT_LINES} prompt lines`);+ }+ for (const [tool, cards] of Object.entries(domain.tools)) {+ for (const field of Object.keys(cards)) {+ const owner = owners.get(`${tool}.${field}`);+ if (owner) throw new Error(`Assistant cards: "${field}" of "${tool}" is claimed by ${owner} and ${domain.id}`);+ owners.set(`${tool}.${field}`, domain.id);+ }+ tools[tool] = { ...tools[tool], ...guardTool(tool, cards) };+ }+ }+ for (const [field, table] of [+ ['write', core.writes],+ ['undo', core.undo],+ ['argPolicy', core.argPolicy],+ ] as const) {+ refuseCoreOverlap(field, Object.keys(table), tools);+ }+ // A curated card is a verb with its words: one without the other is half a card.+ for (const [tool, cards] of Object.entries(tools)) {+ if (!cards.describe !== !cards.write) {+ throw new Error(`Assistant cards: "${tool}" needs both a write entry and a describer, or neither`);+ }+ }+ return {+ tools,+ writes: { ...CORE_WRITE_TOOLS, ...fieldOf(tools, (cards) => cards.write) },+ undo: { ...CORE_UNDO_MAP, ...fieldOf(tools, (cards): ToolUndo | undefined => cards.undo) },+ argPolicy: { ...CORE_ARG_POLICY, ...fieldOf(tools, (cards) => cards.argPolicy) },+ projections: fieldOf(tools, (cards) =>+ cards.project ? (value: unknown): unknown => cards.project?.(value) : undefined,+ ),+ promptLines: domains.flatMap((domain) => domain.prompt ?? []),+ foreignIdGroups: new Set(domains.flatMap((domain) => domain.foreignIdGroups ?? [])),+ toolControllers: controllersOf(domains),+ heldReads: new Set(domains.flatMap((domain) => domain.heldReads ?? [])),+ };+}++/** The controllers the packages add, by tool group; one controller in two places is refused. */+function controllersOf(domains: readonly DomainCards[]): Record<string, string[]> {+ const groups: Record<string, string[]> = {};+ const seen = new Set<string>();+ for (const domain of domains) {+ for (const [group, controllers] of Object.entries(domain.toolControllers ?? {})) {+ for (const controller of controllers) {+ if (seen.has(controller)) throw new Error(`Assistant cards: controller "${controller}" is listed twice`);+ seen.add(controller);+ (groups[group] ??= []).push(controller);+ }+ }+ }+ return groups;+}++/**+ * Refuses a package entry for `field` on a tool the core already covers with+ * its own table (`names`): the core describers and effects, projections and+ * the like, which live beside the files that read them.+ */+export function refuseCoreOverlap(+ field: keyof ToolCards,+ names: Iterable<string>,+ tools: Readonly<Record<string, ToolCards>> = TOOL_CARDS,+): void {+ for (const name of names) {+ if (tools[name]?.[field] !== undefined) {+ throw new Error(`Assistant cards: "${field}" of "${name}" is the core's own`);+ }+ }+}++const MERGED = mergeDomains(DOMAINS);++export const TOOL_CARDS = MERGED.tools;+/** Every writing tool with a card of its own: the core's and the packages'. */+export const ASSISTANT_WRITE_TOOLS = MERGED.writes;+export const ASSISTANT_UNDO_MAP = MERGED.undo;+export const ASSISTANT_ARG_POLICY = MERGED.argPolicy;+/** The packages' provider projections; the core's live in assistant-output.ts. */+export const PROJECTIONS = MERGED.projections;+/** The packages' lines for the standing instructions, in package order. */+export const CARD_PROMPT_LINES = MERGED.promptLines;+/** Tool groups whose place ids are no trip places. */+export const FOREIGN_ID_GROUPS = MERGED.foreignIdGroups;+/** The MCP controllers the packages add to the tool groups (assistant-tool-offer.ts merges them). */+export const PACKAGE_TOOL_CONTROLLERS = MERGED.toolControllers;+/** The packages' read-only tools that wait for the user like a change. */+export const PACKAGE_HELD_READS = MERGED.heldReads;++/** How a card is checked before it goes out: the union, and the most its JSON may weigh. */+export interface CardCheck {+ schema: ZodType<TrekCard>;+ maxChars: number;+}++const UNION_CHECK: CardCheck = { schema: trekCardSchema, maxChars: MAX_CARD_CHARS };++/** The card checked against the union and the size cap; null, and a log line, for anything wrong. */+function checked(tool: string, what: string, check: CardCheck, build: () => TrekCard | null): TrekCard | null {+ let card: TrekCard | null;+ try {+ card = build();+ } catch (err) {+ logWarn(`[assistant] the ${what} card of ${tool} failed: ${reason(err)}`);+ return null;+ }+ if (!card) return null;+ const parsed = check.schema.safeParse(card);+ if (!parsed.success) {+ const issue = parsed.error.issues[0];+ logWarn(+ `[assistant] the ${what} card of ${tool} does not fit its kind: ${issue?.path.join('.')} ${issue?.message}`,+ );+ return null;+ }+ const size = JSON.stringify(parsed.data).length;+ if (size > check.maxChars) {+ logWarn(`[assistant] the ${what} card of ${tool} is too large (${size} characters)`);+ return null;+ }+ return parsed.data;+}++/** The guarded calls over one registry; a builder that throws or misbuilds gives no card, never a broken turn. */+export function guardedCards(tools: Readonly<Record<string, ToolCards>>, check: CardCheck = UNION_CHECK) {+ return {+ answerCardOf(tool: string, input: AnswerInput): TrekCard | null {+ const cards = tools[tool];+ return cards?.answer ? checked(tool, 'answer', check, () => cards.answer?.(input) ?? null) : null;+ },+ changeCardOf(tool: string, ctx: PreviewContext, args: ToolArgs, loaded: unknown): TrekCard | null {+ const cards = tools[tool];+ return cards?.change ? checked(tool, 'change', check, () => cards.change?.(ctx, args, loaded) ?? null) : null;+ },+ appliedCardOf(+ tool: string,+ input: { args: ToolArgs; result: unknown; preview: AssistantChangePreview | null },+ ): TrekCard | null {+ const cards = tools[tool];+ return cards?.applied ? checked(tool, 'applied', check, () => cards.applied?.(input) ?? null) : null;+ },+ };+}++const GUARDED = guardedCards(TOOL_CARDS);+export const answerCardOf = GUARDED.answerCardOf;+export const changeCardOf = GUARDED.changeCardOf;+export const appliedCardOf = GUARDED.appliedCardOf;++/** What a package calls an id argument the trip card cannot name; null when it has no name for it. */+export function nameArgOf(tool: string, key: string, value: number, card: TripCard): string | null {+ return TOOL_CARDS[tool]?.nameArg?.(key, value, card) ?? null;+}++/** The reads an undo of `tool` makes before its check; none when its package asks for none or fails to say. */+export function undoReadsOf(+ tool: string,+ args: ToolArgs,+ result: unknown,+): UndoReads {+ return TOOL_CARDS[tool]?.undo?.reads?.(args, result) ?? [];+}++/**+ * The words of a package's change card for `tool`; null when it has no+ * describer, or a log line and null when its describer throws, so the card+ * built from the arguments stands in.+ */+export function describedOf(tool: string, ctx: PreviewContext, args: ToolArgs, loaded: unknown): Described | null {+ const cards = TOOL_CARDS[tool];+ if (!cards?.describe) return null;+ return safely(tool, 'describer', null, () => cards.describe?.(ctx, args, loaded) ?? null);+}diff --git a/server/src/nest/assistant/cards/roadtrip/index.ts b/server/src/nest/assistant/cards/roadtrip/index.tsnew file mode 100644index 000000000..a83fc9492--- /dev/null+++ b/server/src/nest/assistant/cards/roadtrip/index.ts@@ -0,0 +1,4 @@+import type { DomainCards } from '../card-types';++/** The cards of the road trip, its drives, charging and transit. None yet: this package fills them in. */+export const ROADTRIP_CARDS: DomainCards = { id: 'roadtrip', tools: {} };diff --git a/server/src/nest/assistant/cards/tour/index.ts b/server/src/nest/assistant/cards/tour/index.tsnew file mode 100644index 000000000..f63e47b2b--- /dev/null+++ b/server/src/nest/assistant/cards/tour/index.ts@@ -0,0 +1,25 @@+import type { DomainCards } from '../card-types';+import { TOUR_DESCRIBERS } from './tour-describe';+import { DELETE_CREATED_TOUR } from './tour-undo';++/**+ * The tours in the assistant chat. A tour is a place with a route: its id is+ * its place's, so a created one is taken back by deleting that place.+ */+export const TOUR_CARDS: DomainCards = {+ id: 'tour',+ tools: {+ create_hike: {+ write: { verbKey: 'addTour', entity: 'tour' },+ describe: TOUR_DESCRIBERS.create_hike,+ undo: DELETE_CREATED_TOUR,+ },+ create_city_walk: {+ write: { verbKey: 'addTour', entity: 'tour' },+ describe: TOUR_DESCRIBERS.create_city_walk,+ undo: DELETE_CREATED_TOUR,+ },+ update_tour: { write: { verbKey: 'updateTour', entity: 'tour' }, describe: TOUR_DESCRIBERS.update_tour },+ import_tour_gpx: { write: { verbKey: 'importTour', entity: 'tour' }, describe: TOUR_DESCRIBERS.import_tour_gpx },+ },+};diff --git a/server/src/nest/assistant/tour-call-preview.helpers.ts b/server/src/nest/assistant/cards/tour/tour-describe.tssimilarity index 90%rename from server/src/nest/assistant/tour-call-preview.helpers.tsrename to server/src/nest/assistant/cards/tour/tour-describe.tsindex b417e9b1d..0c6399d7e 100644--- a/server/src/nest/assistant/tour-call-preview.helpers.ts+++ b/server/src/nest/assistant/cards/tour/tour-describe.ts@@ -1,5 +1,6 @@-import { clip, id, Rows, text } from './preview-rows.helpers';-import type { Describer, PreviewContext } from './tool-call-preview.helpers';+import type { Described, PreviewContext, ToolArgs } from '../card-types';+import { recordOf } from '../card-values';+import { clip, id, Rows, text } from '../preview-format';import { TOURS_MAX_HIKING_DIFFICULTY } from '@trek/shared';/**@@ -9,12 +10,6 @@ import { TOURS_MAX_HIKING_DIFFICULTY } from '@trek/shared';* grade (T1 to T6), a planned time in hours and minutes.*/-type Args = Record<string, unknown>;--function recordOf(value: unknown): Args {- return value && typeof value === 'object' && !Array.isArray(value) ? (value as Args) : {};-}-/** A point's name: its own, else the name of the trip's place it stands for. */function pointName(ctx: PreviewContext, point: unknown): string {const record = recordOf(point);@@ -56,7 +51,7 @@ function gpxName(gpx: unknown): string {return close < 0 ? '' : text(gpx.slice(open + '<name>'.length, close));}-export const TOUR_DESCRIBERS: Readonly<Record<string, Describer>> = {+export const TOUR_DESCRIBERS = {create_hike: (ctx, args) => {const rows = new Rows().add('route', routeOf(ctx, args.waypoints, args.round_trip))@@ -91,4 +86,4 @@ export const TOUR_DESCRIBERS: Readonly<Record<string, Describer>> = {const rows = new Rows().add('type', text(args.tour_type));return { subject: text(args.file_name) || gpxName(args.gpx) || 'GPX', rows, dayId: null, placeIds: [] };},-};+} satisfies Readonly<Record<string, (ctx: PreviewContext, args: ToolArgs) => Described>>;diff --git a/server/src/nest/assistant/cards/tour/tour-undo.ts b/server/src/nest/assistant/cards/tour/tour-undo.tsnew file mode 100644index 000000000..42ff4eb8d--- /dev/null+++ b/server/src/nest/assistant/cards/tour/tour-undo.ts@@ -0,0 +1,37 @@+import type { ToolCards, UndoSnapshot } from '../card-types';+import { recordOf } from '../card-values';+import { byId, placeUnchanged, snapshotPlaces } from '../undo-snapshot';++/** The place id of a tour a create answered with (`{ tour: { place_id } }`). */+function tourIdIn(value: unknown): number | null {+ const id = recordOf(recordOf(value).tour).place_id;+ return typeof id === 'number' && Number.isInteger(id) && id > 0 ? id : null;+}++/**+ * A created tour, unchanged and on no day: its place still has the name and+ * description it was created with, has not been written since it was made,+ * and nothing plans, books or pays for it. Every write of a tour's route or+ * name (a change over MCP, the planner's save, a rename) stamps its place's+ * `updated_at`, which the create left equal to `created_at`; the revision is+ * not in the snapshot. A tour planned on a day since is kept too.+ */+function tourUnchanged(result: unknown, snapshot: UndoSnapshot): boolean {+ const tour = recordOf(recordOf(result).tour);+ const current = byId(snapshotPlaces(snapshot), tour.place_id);+ const untouched = typeof current?.created_at === 'string' && current.updated_at === current.created_at;+ return (+ untouched &&+ placeUnchanged({ place: { id: tour.place_id, name: tour.name, description: tour.description ?? null } }, snapshot)+ );+}++/** A created tour taken back with its place, which takes its route and points along. */+export const DELETE_CREATED_TOUR: NonNullable<ToolCards['undo']> = {+ tool: 'delete_place',+ args: (_args, result) => {+ const placeId = tourIdIn(result);+ return placeId ? { placeId } : null;+ },+ unchanged: tourUnchanged,+};diff --git a/server/src/nest/assistant/cards/undo-snapshot.ts b/server/src/nest/assistant/cards/undo-snapshot.tsnew file mode 100644index 000000000..31a23f73a--- /dev/null+++ b/server/src/nest/assistant/cards/undo-snapshot.ts@@ -0,0 +1,66 @@+import type { UndoSnapshot } from './card-types';+import { recordOf, type Row } from './card-values';++/**+ * The pieces an undo check reads the trip with, for the core checks+ * (assistant-undo.helpers.ts) and every package's own `undo.unchanged`. An+ * undo removes the created row with everything that hangs off it, so a check+ * holds that row to what the change created and asks whether anything else+ * has come to depend on it since.+ */++type TripReads = Pick<UndoSnapshot, 'summary' | 'places'>;++export function rowsOf(value: unknown): Row[] {+ return Array.isArray(value) ? value.map(recordOf) : [];+}++/** The fields that say a row is still the one that was created; a field either side lacks is not compared. */+export const STABLE_FIELDS = {+ place: ['name', 'updated_at', 'lat', 'lng', 'address', 'category_id', 'description', 'notes'],+ assignment: ['day_id', 'place_id'],+ note: ['text', 'time', 'icon', 'color'],+ packing: ['name', 'updated_at', 'checked', 'quantity', 'category'],+ todo: ['name', 'checked', 'due_date', 'description', 'priority', 'assigned_user_id', 'category'],+ budget: ['name', 'total_price', 'currency', 'category', 'note', 'expense_date'],+} as const;++export function same(created: Row, current: Row | undefined, fields: readonly string[]): boolean {+ if (!current) return false;+ return fields.every((field) => !(field in created) || !(field in current) || created[field] === current[field]);+}++export function byId(rows: Row[], id: unknown): Row | undefined {+ return rows.find((row) => row.id === id);+}++export function snapshotDays(snapshot: TripReads): Row[] {+ return rowsOf(recordOf(snapshot.summary).days);+}++export function snapshotAssignments(snapshot: TripReads): Row[] {+ return snapshotDays(snapshot).flatMap((day) => rowsOf(day.assignments));+}++/** The trip's places as `list_places` answered. */+export function snapshotPlaces(snapshot: TripReads): Row[] {+ return rowsOf(recordOf(snapshot.places).places);+}++/** A created place, unchanged and still only where the change put it: on no other day, in no booking or expense. */+export function placeUnchanged(result: Row, snapshot: TripReads): boolean {+ const created = recordOf(result.place);+ const current = byId(snapshotPlaces(snapshot), created.id);+ if (!same(created, current, STABLE_FIELDS.place)) return false;+ const ownAssignment = recordOf(result.assignment).id;+ const plannedElsewhere = snapshotAssignments(snapshot).some(+ (a) => a.place_id === created.id && a.id !== ownAssignment,+ );+ const summary = recordOf(snapshot.summary);+ const referenced = [+ ...rowsOf(summary.reservations),+ ...rowsOf(summary.accommodations),+ ...rowsOf(recordOf(summary.budget).items),+ ].some((row) => row.place_id === created.id);+ return !plannedElsewhere && !referenced;+}diff --git a/server/src/nest/assistant/cards/vacay/index.ts b/server/src/nest/assistant/cards/vacay/index.tsnew file mode 100644index 000000000..bbcfb04c8--- /dev/null+++ b/server/src/nest/assistant/cards/vacay/index.ts@@ -0,0 +1,4 @@+import type { DomainCards } from '../card-types';++/** The cards of the vacation planner. None yet: this package fills them in. */+export const VACAY_CARDS: DomainCards = { id: 'vacay', tools: {} };diff --git a/server/src/nest/assistant/preview-rows.helpers.ts b/server/src/nest/assistant/preview-rows.helpers.tsdeleted file mode 100644index a0be4dcfc..000000000--- a/server/src/nest/assistant/preview-rows.helpers.ts+++ /dev/null@@ -1,51 +0,0 @@-import type { AssistantChangeLabelKey, AssistantChangeRow } from '@trek/shared';--/**- * The pieces every change card is written with: a value cut to what a row- * shows, an argument read as an id, and the rows themselves. Shared by the- * cards of the trip's own tools (tool-call-preview.helpers.ts) and of the- * tours (tour-call-preview.helpers.ts).- */--type Args = Record<string, unknown>;--/** Longest value a row shows; URLs keep their start, so the host stays visible. */-const MAX_VALUE_CHARS = 160;--const CHECKED = '✓';-export const UNCHECKED = '✗';--export function clip(value: string): string {- const line = value.replace(/\s+/g, ' ').trim();- return line.length > MAX_VALUE_CHARS ? `${line.slice(0, MAX_VALUE_CHARS - 1)}…` : line;-}--export function id(args: Args, key: string): number | null {- const value = args[key];- return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : null;-}--export function text(value: unknown): string {- if (value === null || value === undefined) return '';- if (typeof value === 'boolean') return value ? CHECKED : UNCHECKED;- return clip(String(value));-}--export class Rows {- readonly rows: AssistantChangeRow[] = [];-- add(labelKey: AssistantChangeLabelKey, after: string): this {- if (after !== '') this.rows.push({ op: 'add', labelKey, before: null, after });- return this;- }-- change(labelKey: AssistantChangeLabelKey, before: string | null, after: string): this {- this.rows.push({ op: 'change', labelKey, before: before || null, after });- return this;- }-- move(labelKey: AssistantChangeLabelKey, before: string, after: string): this {- this.rows.push({ op: 'move', labelKey, before: before || null, after });- return this;- }-}diff --git a/server/src/nest/assistant/tool-call-generic.helpers.ts b/server/src/nest/assistant/tool-call-generic.helpers.tsindex daaa72768..5c9a8e4ef 100644--- a/server/src/nest/assistant/tool-call-generic.helpers.ts+++ b/server/src/nest/assistant/tool-call-generic.helpers.ts@@ -1,5 +1,6 @@import type { TripCard } from './assistant-context';import type { ToolHint } from './assistant-tools.service';+import { FOREIGN_ID_GROUPS, nameArgOf } from './cards/registry';import type {AssistantChangeLabelKey,AssistantChangePreview,@@ -15,11 +16,21 @@ import type {* the labels the other cards use (time, end, notes, day …), with ids named and* lists of ids read as the names in their order. The verb comes from what the* tool says it does; the client names the tool's action where it knows it. It- * is never undoable: only the tools with a matching removal are.+ * is never undoable: only the tools with a matching removal are. A package+ * names the ids the trip card cannot (`nameArg`), and the place ids of a tool+ * that works outside the trip (a collection's, the atlas') are never read as+ * the trip's places.*/type Args = Record<string, unknown>;+/** What naming one tool's arguments needs: the trip, the tool, and whether its place ids are the trip's. */+interface Naming {+ card: TripCard;+ toolName: string;+ foreign: boolean;+}+const MAX_ROWS = 12;const MAX_VALUE_CHARS = 160;const NAME_KEYS = ['name', 'title', 'text', 'label', 'question', 'content', 'region', 'country_code'] as const;@@ -98,35 +109,37 @@ function dayName(card: TripCard, dayId: number): string | null {}/** What one id argument names in the trip: a place, a day, a note, a booking, an item, a person. */-function nameOf(card: TripCard, key: string, value: number, toolName: string): string | null {+function nameOf({ card, toolName, foreign }: Naming, key: string, value: number): string | null {+ const named = nameArgOf(toolName, key, value, card);+ if (named !== null) return named;const k = key.toLowerCase().replace(/_/g, '');if (k === 'assignmentid') {const assignment = card.assignments.get(value);return assignment ? (card.places.get(assignment.placeId)?.name ?? null) : null;}- if (k === 'placeid' || k === 'sourceplaceid') return card.places.get(value)?.name ?? null;+ if (k === 'placeid' || k === 'sourceplaceid') return foreign ? null : (card.places.get(value)?.name ?? null);if (k === 'dayid' || k === 'enddayid' || k === 'startdayid') return dayName(card, value);if (k === 'noteid') return card.notes.get(value)?.text ?? null;if (k === 'reservationid' || k === 'accommodationid') return card.reservations.get(value)?.title ?? null;if (k === 'itemid' && toolName.includes('packing')) return card.packing.get(value)?.name ?? null;- if (k === 'userid' || k === 'memberid' || k === 'assigneduserid') return card.members.get(value) ?? null;+ if (k === 'userid' || k === 'memberid' || k === 'assigneduserid') return card.members.get(value)?.name ?? null;return null;}/** An id list in its order, named where the card knows the ids (a new order of a day's places). */-function namesOf(card: TripCard, key: string, values: unknown[], toolName: string): string | null {+function namesOf(naming: Naming, key: string, values: unknown[]): string | null {const singular = key.replace(/(Ids|_ids)$/, (m) => (m === 'Ids' ? 'Id' : '_id'));- const names = values.map((v) => (typeof v === 'number' ? nameOf(card, singular, v, toolName) : null));+ const names = values.map((v) => (typeof v === 'number' ? nameOf(naming, singular, v) : null));return names.some((n) => n === null) ? null : names.join(', ');}-function valueText(card: TripCard, key: string, value: unknown, toolName: string): string {+function valueText(naming: Naming, key: string, value: unknown): string {if (typeof value === 'number') {- const name = nameOf(card, key, value, toolName);+ const name = nameOf(naming, key, value);if (name) return clip(name);}if (Array.isArray(value)) {- const names = namesOf(card, key, value, toolName);+ const names = namesOf(naming, key, value);if (names) return clip(names);return clip(value.map((item) => (typeof item === 'object' ? JSON.stringify(item) : String(item))).join(', '));}@@ -136,31 +149,31 @@ function valueText(card: TripCard, key: string, value: unknown, toolName: string}/** The subject: what the tool is given a name for, else the first thing of the trip it works on. */-function subjectOf(card: TripCard, args: Args, toolName: string): { text: string; key: string | null } {+function subjectOf(naming: Naming, args: Args): { text: string; key: string | null } {const named = NAME_KEYS.find((key) => typeof args[key] === 'string' && (args[key] as string).trim());if (named) return { text: String(args[named]), key: named };const order = ['assignmentId', 'placeId', 'noteId', 'reservationId', 'itemId', 'dayId', 'day_id'];for (const key of order) {const value = args[key];- const name = typeof value === 'number' ? nameOf(card, key, value, toolName) : null;+ const name = typeof value === 'number' ? nameOf(naming, key, value) : null;if (name) return { text: name, key };}const list = Object.entries(args).find(([key, value]) => /(Ids|_ids)$/.test(key) && Array.isArray(value));if (list) {- const names = namesOf(card, list[0], list[1] as unknown[], toolName);+ const names = namesOf(naming, list[0], list[1] as unknown[]);if (names) return { text: names, key: list[0] };}- return { text: humanToolName(toolName), key: null };+ return { text: humanToolName(naming.toolName), key: null };}-function rowOf(card: TripCard, key: string, value: unknown, toolName: string): AssistantChangeRow {+function rowOf(naming: Naming, key: string, value: unknown): AssistantChangeRow {const labelKey = LABEL_OF[key] ?? 'field';return {op: 'add',labelKey,...(labelKey === 'field' ? { field: key.slice(0, 60) } : {}),before: null,- after: valueText(card, key, value, toolName),+ after: valueText(naming, key, value),};}@@ -171,12 +184,13 @@ export function describeGeneric(card: TripCard,hint: ToolHint | null,): AssistantChangePreview {- const subject = subjectOf(card, args, toolName);+ const naming: Naming = { card, toolName, foreign: !!hint?.group && FOREIGN_ID_GROUPS.has(hint.group) };+ const subject = subjectOf(naming, args);const rows = Object.entries(args).filter(([key]) => key !== subject.key && !HIDDEN_KEYS.has(key)).filter(([, value]) => value !== undefined && value !== null && value !== '').slice(0, MAX_ROWS)- .map(([key, value]) => rowOf(card, key, value, toolName));+ .map(([key, value]) => rowOf(naming, key, value));const dayArg = args.dayId ?? args.day_id;const assignment = typeof args.assignmentId === 'number' ? card.assignments.get(args.assignmentId) : undefined;const dayId = typeof dayArg === 'number' ? dayArg : (assignment?.dayId ?? null);@@ -187,7 +201,7 @@ export function describeGeneric(subject: clip(subject.text),rows,dayId: dayId !== null && card.days.some((d) => d.id === dayId) ? dayId : null,- placeIds: placeId !== null && card.places.has(placeId) ? [placeId] : [],+ placeIds: placeId !== null && !naming.foreign && card.places.has(placeId) ? [placeId] : [],undoable: false,effect: null,tool: toolName,diff --git a/server/src/nest/assistant/tool-call-preview.helpers.ts b/server/src/nest/assistant/tool-call-preview.helpers.tsindex 1937d1b6a..6ecd10189 100644--- a/server/src/nest/assistant/tool-call-preview.helpers.ts+++ b/server/src/nest/assistant/tool-call-preview.helpers.ts@@ -1,17 +1,36 @@-import type { CardPlace, TripCard } from './assistant-context';+import type { CardPlace } from './assistant-context';import { noteOf } from './assistant-memory';import {ASSISTANT_SERVER_WRITE_TOOLS,- ASSISTANT_UNDO_MAP,- ASSISTANT_WRITE_TOOLS,IMPORT_BOOKING_TOOL,REMEMBER_TOOL,writeToolOf,} from './assistant-tools.constants';-import type { ToolHint } from './assistant-tools.service';-import { clip, id, Rows, text, UNCHECKED } from './preview-rows.helpers';+import type { Described, PreviewContext } from './cards/card-types';+import {+ categoryName,+ clip,+ dayLabel,+ formatDate,+ formatDateTime,+ id,+ localeOf,+ memberNames,+ money,+ placeName,+ Rows,+ text,+ UNCHECKED,+} from './cards/preview-format';+import {+ ASSISTANT_UNDO_MAP,+ ASSISTANT_WRITE_TOOLS,+ changeCardOf,+ describedOf,+ refuseCoreOverlap,+ TOOL_CARDS,+} from './cards/registry';import { describeGeneric } from './tool-call-generic.helpers';-import { TOUR_DESCRIBERS } from './tour-call-preview.helpers';import type {AssistantApplied,AssistantChangeEffect,@@ -23,76 +42,18 @@ import type {* The change card of a held tool call: what it does and to what, in plain* words. Days, places, categories and people are named instead of numbered,* dates and amounts are written in the user's locale, and an update shows- * what the field held before.+ * what the field held before. A package's cards (cards/registry.ts) add the+ * describers, effects and drawn cards of their tools.*/type Args = Record<string, unknown>;-export interface PreviewContext {- card: TripCard;- categories: ReadonlyMap<number, string>;- locale: string;- /** What a tool without a card of its own says about itself, for the card built from its arguments. */- hintOf?: (toolName: string) => ToolHint | null;-}-const MAX_ROWS = 12;function has(args: Args, key: string): boolean {return args[key] !== undefined;}-/** A locale Intl accepts, the user's when it can. */-function localeOf(ctx: PreviewContext): string {- try {- return Intl.getCanonicalLocales(ctx.locale)[0] ?? 'en';- } catch {- return 'en';- }-}--function formatDate(ctx: PreviewContext, isoDate: string): string {- const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(isoDate);- if (!match) return isoDate;- const date = new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])));- return new Intl.DateTimeFormat(localeOf(ctx), {- weekday: 'short',- day: 'numeric',- month: 'short',- timeZone: 'UTC',- }).format(date);-}--function formatDateTime(ctx: PreviewContext, value: string): string {- const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(value);- return match ? `${formatDate(ctx, match[1])}, ${match[2]}` : value;-}--/** A day as the planner names it: its date (and title), or its title, or its number. */-export function dayLabel(ctx: PreviewContext, dayId: number | null): string {- if (dayId === null) return '';- const day = ctx.card.days.find((d) => d.id === dayId);- if (!day) return `#${dayId}`;- if (day.date) return day.title ? `${formatDate(ctx, day.date)}, ${day.title}` : formatDate(ctx, day.date);- return day.title ?? `#${day.number}`;-}--function placeName(ctx: PreviewContext, placeId: number | null): string {- if (placeId === null) return '';- return ctx.card.places.get(placeId)?.name ?? `#${placeId}`;-}--function money(ctx: PreviewContext, amount: number, currency: string | null): string {- if (currency) {- try {- return new Intl.NumberFormat(localeOf(ctx), { style: 'currency', currency }).format(amount);- } catch {- return `${amount} ${currency}`;- }- }- return new Intl.NumberFormat(localeOf(ctx)).format(amount);-}-function openingHours(ctx: PreviewContext, value: unknown): string {if (!Array.isArray(value)) return '';const weekday = new Intl.DateTimeFormat(localeOf(ctx), { weekday: 'short', timeZone: 'UTC' });@@ -107,20 +68,11 @@ function openingHours(ctx: PreviewContext, value: unknown): string {);}-function memberNames(ctx: PreviewContext, ids: unknown): string {- if (!Array.isArray(ids)) return '';- return clip(ids.map((memberId) => ctx.card.members.get(Number(memberId)) ?? `#${String(memberId)}`).join(', '));-}-function coordinates(args: Args): string {const { lat, lng } = args;return typeof lat === 'number' && typeof lng === 'number' ? `${lat.toFixed(5)}, ${lng.toFixed(5)}` : '';}-function categoryName(ctx: PreviewContext, categoryId: number | null): string {- return categoryId === null ? '' : (ctx.categories.get(categoryId) ?? `#${categoryId}`);-}-/** The fields a new place carries, shared by both ways of creating one. */function newPlaceRows(ctx: PreviewContext, args: Args, rows: Rows, notesKey: string): void {rows@@ -227,14 +179,7 @@ function describeBooking(ctx: PreviewContext, args: Args): Described {return { subject: text(args.title), rows, dayId, placeIds: [] };}-interface Described {- subject: string;- rows: Rows;- dayId: number | null;- placeIds: number[];-}--export type Describer = (ctx: PreviewContext, args: Args) => Described;+type Describer = (ctx: PreviewContext, args: Args) => Described;/** Who shares an expense: the uneven split's members, else the equal one's. */function splitOf(args: Args): unknown {@@ -391,7 +336,6 @@ const DESCRIBERS: Readonly<Record<string, Describer>> = {};},[IMPORT_BOOKING_TOOL]: describeBooking,- ...TOUR_DESCRIBERS,};/** A held write of the model's tools or of the server's own (a booking from a file). */@@ -445,34 +389,52 @@ const EFFECTS: Readonly<Record<string, (ctx: PreviewContext, args: Args) => Assi},};+// A tool's words and its effect come from the core or from its package, never from both.+refuseCoreOverlap('describe', Object.keys(DESCRIBERS));+refuseCoreOverlap('effect', Object.keys(EFFECTS));+/*** The change card for a held call of one of the writing tools, or of a* change the server proposed itself (a booking from a file, a found place).* `args` are the arguments as stored (the trip id is not among them). A found- * place reads as the tool it runs through.+ * place reads as the tool it runs through. `loaded` is what the tool's+ * package looked up for it (card-context.ts), null when it looked up nothing.*/export function describeToolCall(toolName: string,toolCallId: string,args: Args,ctx: PreviewContext,+ loaded: unknown = null,): AssistantChangePreview {const runs = writeToolOf(toolName, args);const tool = writeTool(runs);- const describe = DESCRIBERS[runs];+ const cards = TOOL_CARDS[runs];+ const describe: ((c: PreviewContext, a: Args) => Described | null) | undefined = cards?.describe+ ? (c, a) => describedOf(runs, c, a, loaded)+ : DESCRIBERS[runs];// The server's own steps all have a card; one without is a call that names no real tool.if (tool && !describe) throw new Error(`No change card for tool "${toolName}"`);- if (!tool || !describe) return describeGeneric(runs, toolCallId, args, ctx.card, ctx.hintOf?.(runs) ?? null);- const described = describe(ctx, args);+ const card = changeCardOf(runs, ctx, args, loaded);+ const drawn = card ? { card } : {};+ // A package describer that failed gives way to the card built from the arguments.+ const described = tool && describe ? describe(ctx, args) : null;+ if (!tool || !described) {+ return { ...describeGeneric(runs, toolCallId, args, ctx.card, ctx.hintOf?.(runs) ?? null), ...drawn };+ }+ const planned = cards?.effect ? cards.effect(ctx, args, loaded) : EFFECTS[runs]?.(ctx, args);return {toolCallId,- verbKey: tool.verbKey,+ verbKey: described.verbKey ?? tool.verbKey,subject: clip(described.subject),rows: described.rows.rows.slice(0, MAX_ROWS),dayId: described.dayId,placeIds: described.placeIds,undoable: runs in ASSISTANT_UNDO_MAP,- effect: EFFECTS[runs]?.(ctx, args) ?? null,+ effect: planned ?? null,+ ...(described.tool ? { tool: described.tool } : {}),+ ...(described.domain ? { domain: described.domain } : {}),+ ...drawn,};}@@ -525,8 +487,10 @@ export function appliedChange(undoUntil: string | null,): AssistantApplied | null {// A tool without a card of its own touched something the client has no view for.- const tool = writeTool(writeToolOf(toolName, args)) ?? { entity: 'other' as const };- const created = createdIds(result);+ const runs = writeToolOf(toolName, args);+ const tool = writeTool(runs) ?? { entity: 'other' as const };+ const own = TOOL_CARDS[runs]?.appliedIds?.(args, result) ?? [];+ const created = own.length > 0 ? own : createdIds(result);const named = ARG_KEYS.map((key) => id(args, key)).filter((value): value is number => value !== null);return {toolCallId,diff --git a/server/src/nest/assistant/ui-stream.writer.ts b/server/src/nest/assistant/ui-stream.writer.tsindex 83f8934f0..6d146cc2d 100644--- a/server/src/nest/assistant/ui-stream.writer.ts+++ b/server/src/nest/assistant/ui-stream.writer.ts@@ -3,6 +3,7 @@ import {UI_STREAM_DONE,type AssistantActivity,type AssistantApplied,+ type AssistantCard,type AssistantChangePreview,type AssistantErrorCode,type AssistantPlaces,@@ -96,6 +97,11 @@ export class UiStreamWriter {this.send({ type: 'data-trek-weather', data: weather });}+ /** The card of one tool call: a read's beside the answer, an applied write's beside its receipt. */+ card(data: AssistantCard): void {+ this.send({ type: 'data-trek-card', data });+ }+/** Where a step that is about to run looks; only streamed, the message never keeps it. */activity(activity: AssistantActivity): void {this.endText();diff --git a/server/tests/e2e/assistant.e2e.test.ts b/server/tests/e2e/assistant.e2e.test.tsindex 3ae73c430..96eca3990 100644--- a/server/tests/e2e/assistant.e2e.test.ts+++ b/server/tests/e2e/assistant.e2e.test.ts@@ -17,6 +17,7 @@* shared in the trip chat.*/import { buildApp } from '../../src/bootstrap';+import { AssistantMessages } from '../../src/db/entities/AssistantMessages.entity';import { AssistantThreads } from '../../src/db/entities/AssistantThreads.entity';import { AssistantToolCalls } from '../../src/db/entities/AssistantToolCalls.entity';import { CollabMessages } from '../../src/db/entities/CollabMessages.entity';@@ -26,6 +27,7 @@ import { Reservations } from '../../src/db/entities/Reservations.entity';import { Trips } from '../../src/db/entities/Trips.entity';import { TURNS_PER_MINUTE } from '../../src/nest/assistant/assistant-tools.constants';import { AssistantToolsService } from '../../src/nest/assistant/assistant-tools.service';+import { AssistantCardContext } from '../../src/nest/assistant/cards/card-context';import { BookingImportService } from '../../src/nest/booking-import/booking-import.service';import { MapsService } from '../../src/nest/maps/maps.service';import { PermissionsService } from '../../src/nest/permissions/permissions.service';@@ -40,7 +42,7 @@ import { resetRateLimits } from '../helpers/test-db';import { sessionCookie } from './harness';import { MikroORM } from '@mikro-orm/core';import type { INestApplication } from '@nestjs/common';-import type { AssistantMessagePart, UiStreamChunk } from '@trek/shared';+import { storedTrekCardSchema, type AssistantMessagePart, type TrekCard, type UiStreamChunk } from '@trek/shared';import { createServer, type IncomingMessage, type Server as HttpServer, type ServerResponse } from 'node:http';import type { AddressInfo } from 'node:net';@@ -949,11 +951,12 @@ describe('Trip assistant e2e', () => {origin: 'assistant',user_id: t.userId,});+ // The asking tab is not left out: it never put the message into its own chat.expect(broadcasts.broadcast).toHaveBeenCalledWith(String(t.tripId),'collab:message:created',{ message: expect.objectContaining({ origin: 'assistant' }) },- 'sock-1',+ undefined,);const listed = await get(`/api/trips/${t.tripId}/collab/messages`, t.userId);expect(listed.body.messages).toEqual([@@ -977,4 +980,61 @@ describe('Trip assistant e2e', () => {}expect(await countRows(orm, CollabMessages, { trip: t.tripId })).toBe(1);});++ it('ASTE2E-022: an applied change keeps its card on the proposing message; a card or part this build does not know reads as nothing', async () => {+ const t = await travelerWithTrip();+ const { turn, toolCallId, threadId } = await proposePlace(t, 'Sanjusangen-do');+ const proposing = Number(ofType(turn.chunks, 'start')[0].messageId.slice('msg-'.length));+ const built = { kind: 'tourRoute' } as TrekCard;+ const applied = vi.spyOn(nestApp.get(AssistantCardContext), 'appliedCard').mockReturnValue(built);+ provider.script = [say('Added it.')];+ try {+ const decided = await post(`${t.base}/threads/${threadId}/decisions`, t.userId, {+ ...CTX,+ decisions: [{ toolCallId, approved: true }],+ });+ expect(applied).toHaveBeenCalledWith(+ 'create_place',+ expect.objectContaining({ args: { name: 'Sanjusangen-do' } }),+ );+ const types = decided.chunks.map((chunk) => chunk.type);+ expect(types.indexOf('data-trek-card')).toBeGreaterThan(types.indexOf('data-trek-applied'));+ expect(ofType(decided.chunks, 'data-trek-card')[0].data.toolCallId).toBe(toolCallId);+ } finally {+ applied.mockRestore();+ }++ const stored = await findRow(orm, AssistantMessages, { id: proposing });+ const parts = JSON.parse(stored?.parts ?? '[]') as Array<{ type: string; data?: { toolCallId?: string } }>;+ expect(parts.filter((part) => part.type === 'data-trek-card').map((part) => part.data?.toolCallId)).toEqual([+ toolCallId,+ ]);+ const cardOf = (messages: Array<{ parts: AssistantMessagePart[] }>, id: string) =>+ messages+ .flatMap((message) => message.parts)+ .find((part) => part.type === 'data-trek-card' && part.data.toolCallId === id);+ const shown = await get(`${t.base}/threads/${threadId}`, t.userId);+ expect(shown.status).toBe(200);+ expect(cardOf(shown.body.messages, toolCallId)).toEqual({+ type: 'data-trek-card',+ data: { toolCallId, card: storedTrekCardSchema.parse(built) },+ });++ // A later build's part and kind, as a rolled back server finds them in the row.+ const later = [+ ...parts,+ { type: 'data-trek-book-page', data: { page: 3 } },+ { type: 'data-trek-card', data: { toolCallId: 'call_later', card: { kind: 'bookPage', page: 3 } } },+ ];+ await updateRows(orm, AssistantMessages, { id: proposing }, { parts: JSON.stringify(later) });+ const tolerant = await get(`${t.base}/threads/${threadId}`, t.userId);+ expect(tolerant.status).toBe(200);+ const kept = (tolerant.body.messages as Array<{ parts: AssistantMessagePart[] }>).flatMap((m) => m.parts);+ expect(kept.map((part) => part.type)).not.toContain('data-trek-book-page');+ expect(kept.map((part) => part.type)).toContain('data-trek-change');+ expect(cardOf(tolerant.body.messages, 'call_later')).toEqual({+ type: 'data-trek-card',+ data: { toolCallId: 'call_later', card: null },+ });+ });});diff --git a/server/tests/unit/nest/assistant/assistant-agent.test.ts b/server/tests/unit/nest/assistant/assistant-agent.test.tsindex 0df6980a6..36c9a67f5 100644--- a/server/tests/unit/nest/assistant/assistant-agent.test.ts+++ b/server/tests/unit/nest/assistant/assistant-agent.test.ts@@ -19,14 +19,16 @@ import {} from '../../../../src/nest/assistant/assistant-agent';import { buildTripCard } from '../../../../src/nest/assistant/assistant-context';import {+ MAX_CARDS_PER_STEP,MAX_READS_PER_STEP,MAX_STEPS,MAX_WRITES_PER_STEP,} from '../../../../src/nest/assistant/assistant-tools.constants';import type { AssistantToolKind } from '../../../../src/nest/assistant/assistant-tools.service';+import type { AnswerInput } from '../../../../src/nest/assistant/cards/card-types';import { UiStreamWriter } from '../../../../src/nest/assistant/ui-stream.writer';import type { SseStream } from '../../../../src/nest/common/sse-stream';-import type { AssistantChangePreview, UiStreamChunk } from '@trek/shared';+import type { AssistantChangePreview, TrekCard, UiStreamChunk } from '@trek/shared';import { describe, expect, it, vi } from 'vitest';@@ -136,7 +138,7 @@ function setup(steps: Step[], overrides: Partial<AgentDeps> = {}) {describe: vi.fn(async (_name: string, id: string) => preview(id)),newId: () => `id-${++ids}`,quota: null,- card: buildTripCard(1, { days: [{ id: 41, day_number: 1, date: '2026-06-11' }] }, null, null),+ card: buildTripCard(1, 7, { days: [{ id: 41, day_number: 1, date: '2026-06-11' }] }, null, null),today: '2026-01-05',...overrides,};@@ -487,7 +489,7 @@ describe('runAgentLoop', () => {it('ASTAGT-015: a details lookup runs only for a google id from the card or a search of this turn', async () => {const places = { places: [{ id: 9, name: 'Nishiki', google_place_id: 'ChIJn' }] };- const card = buildTripCard(1, { days: [] }, places, null);+ const card = buildTripCard(1, 7, { days: [] }, places, null);const details = (id: string, placeId: string) => ({type: 'tool-call' as const,call: { id, name: 'get_place_details', args: { placeId } },@@ -556,4 +558,69 @@ describe('runAgentLoop', () => {{ role: 'user', text: expect.stringContaining('cut off') },]);});++ describe('answer cards', () => {+ /** A card as a package would build it; its fields do not matter to the loop. */+ const CARD = { kind: 'tourList' } as TrekCard;+ const read = (id: string) => ({ type: 'tool-call' as const, call: { id, name: 'list_places', args: {} } });++ it('ASTAGT-019: a read card follows its answer in the stream and its call in the step, built from the raw value', async () => {+ const raw = { places: [{ id: 5, name: 'Kinkaku-ji', email: '[email protected]' }] };+ const answerCard = vi.fn((_tool: string, _input: AnswerInput) => CARD);+ const t = setup([[read('c1')], [{ type: 'text-delta', delta: 'Done.' }]], { answerCard });+ t.tools.call.mockImplementation(async () => ({ ok: true, value: raw }));+ await runAgentLoop(t.deps, t.input, t.writer, new AbortController().signal);+ expect(answerCard).toHaveBeenCalledWith('list_places', {+ toolCallId: 'c1',+ args: {},+ value: raw,+ card: t.deps.card,+ today: '2026-01-05',+ });+ expect(types(t.chunks).slice(0, 6)).toEqual([+ 'start-step',+ 'tool-input-start',+ 'tool-input-available',+ 'tool-output-available',+ 'data-trek-card',+ 'finish-step',+ ]);+ expect(t.chunks[4]).toEqual({ type: 'data-trek-card', data: { toolCallId: 'c1', card: CARD } });+ const [call, card] = t.memory.saved[0].step.parts;+ expect(card).toEqual({ type: 'data-trek-card', data: { toolCallId: 'c1', card: CARD } });+ expect(JSON.stringify(call)).not.toContain('[email protected]');+ expect(JSON.stringify(t.requests[1].messages)).not.toContain('[email protected]');+ });++ it('ASTAGT-020: a failed read makes no card, and a step shows at most twelve', async () => {+ const answerCard = vi.fn(() => CARD);+ const calls = Array.from({ length: MAX_CARDS_PER_STEP + 2 }, (_, i) => read(`c${i}`));+ const failing = { type: 'tool-call' as const, call: { id: 'bad', name: 'search_place', args: { query: 'x' } } };+ const t = setup([[...calls, failing]], { answerCard });+ t.tools.call.mockImplementation(async (name: string) =>+ name === 'search_place' ? { ok: false, value: 'Place search failed.' } : { ok: true, value: ANSWERS[name] },+ );+ await runAgentLoop(t.deps, t.input, t.writer, new AbortController().signal);+ expect(answerCard).toHaveBeenCalledTimes(MAX_CARDS_PER_STEP + 2);+ expect(types(t.chunks).filter((type) => type === 'data-trek-card')).toHaveLength(MAX_CARDS_PER_STEP);+ const parts = t.memory.saved[0].step.parts;+ expect(parts.filter((part) => part.type === 'data-trek-card')).toHaveLength(MAX_CARDS_PER_STEP);+ expect(parts.filter((part) => part.type === 'tool-call')).toHaveLength(MAX_CARDS_PER_STEP + 3);+ });++ it('ASTAGT-021: no card for a builder that gives none or a call id past 64 characters', async () => {+ const long = `toolu_${'x'.repeat(64)}`;+ const answerCard = vi.fn((_tool: string, input: AnswerInput) => (input.toolCallId === 'none' ? null : CARD));+ const t = setup([[read(long), read('none')]], { answerCard });+ await runAgentLoop(t.deps, t.input, t.writer, new AbortController().signal);+ expect(answerCard).toHaveBeenCalledTimes(1);+ expect(types(t.chunks)).not.toContain('data-trek-card');+ });++ it('ASTAGT-022: without a builder of its own the loop asks the registry, where no core tool has an answer card', async () => {+ const t = setup([[read('c1')], [{ type: 'text-delta', delta: 'Done.' }]]);+ await runAgentLoop(t.deps, t.input, t.writer, new AbortController().signal);+ expect(t.memory.saved[0].step.parts.map((part) => part.type)).toEqual(['tool-call']);+ });+ });});diff --git a/server/tests/unit/nest/assistant/assistant-cards.helpers.test.ts b/server/tests/unit/nest/assistant/assistant-cards.helpers.test.tsindex 502dc2725..b24133ed3 100644--- a/server/tests/unit/nest/assistant/assistant-cards.helpers.test.ts+++ b/server/tests/unit/nest/assistant/assistant-cards.helpers.test.ts@@ -19,6 +19,7 @@ import { describe, expect, it } from 'vitest';const card = buildTripCard(1,+ 7,{trip: { title: 'Kyoto', start_date: '2026-06-11', end_date: '2026-06-13' },days: [@@ -86,7 +87,7 @@ describe('foundPlacesOf', () => {const value = { places: [{ name: 'Cafe', lat: 35, lng: 135, open_now: false, types: ['cafe'] }] };expect(foundPlacesOf('search_place', 'c', value, card, '2026-06-11')?.places[0].openNow).toBe(false);expect(foundPlacesOf('search_place', 'c', value, card, '2026-10-21')?.places[0].openNow).toBeNull();- const undated = buildTripCard(1, { trip: { title: 'T' } }, null, null);+ const undated = buildTripCard(1, 7, { trip: { title: 'T' } }, null, null);expect(foundPlacesOf('search_place', 'c', value, undated, '2026-06-11')?.places[0].openNow).toBeNull();});diff --git a/server/tests/unit/nest/assistant/assistant-context.test.ts b/server/tests/unit/nest/assistant/assistant-context.test.tsindex 75f564dd1..2f0e6113b 100644--- a/server/tests/unit/nest/assistant/assistant-context.test.ts+++ b/server/tests/unit/nest/assistant/assistant-context.test.ts@@ -45,6 +45,7 @@ describe('buildTripCard', () => {it('ASTCTX-030: knows the source ids of places and the bookings with their day', () => {const card = buildTripCard(1,+ 7,{...SUMMARY,reservations: [{ id: 71, title: 'Gion Corner', day_id: 31 }, { id: 72, day_id: null }, { title: 'no id' }],@@ -69,7 +70,7 @@ describe('buildTripCard', () => {{ id: 73, title: 'Bus' },],};- const card = buildTripCard(1, summary, PLACES, { dayId: 32, placeIds: [12] }, [+ const card = buildTripCard(1, 7, summary, PLACES, { dayId: 32, placeIds: [12] }, [{ kind: 'place', id: 14 },{ kind: 'place', id: 12 },{ kind: 'place', id: 999 },@@ -93,7 +94,7 @@ describe('buildTripCard', () => {].join('\n'),);expect(text).not.toMatch(/place 999|day 99\b|booking 98/);- const unknownOnly = buildTripCard(1, SUMMARY, PLACES, null, [{ kind: 'place', id: 999 }]);+ const unknownOnly = buildTripCard(1, 7, SUMMARY, PLACES, null, [{ kind: 'place', id: 999 }]);expect(renderTripCard(unknownOnly)).not.toContain('The user names');});@@ -115,7 +116,7 @@ describe('buildTripCard', () => {});it('ASTCTX-001: reads days, places, assignments, notes, packing and members', () => {- const card = buildTripCard(1, SUMMARY, PLACES, null);+ const card = buildTripCard(1, 7, SUMMARY, PLACES, null);expect(card).toMatchObject({ tripId: 1, title: 'Kyoto in June', currency: 'JPY', startDate: '2026-06-11' });expect(card.days).toEqual([{ id: 31, number: 1, date: '2026-06-11', title: 'Arrival', placeIds: [12] },@@ -133,24 +134,44 @@ describe('buildTripCard', () => {});expect(card.packing.get(51)).toMatchObject({ name: 'Umbrella', weight: 300 });expect([...card.members.entries()]).toEqual([- [7, 'mia'],- [8, 'jon'],+ [7, { name: 'mia', avatarKey: null }],+ [8, { name: 'jon', avatarKey: null }],]);});+ it('ASTCTX-003: knows who asks, the members by their stored pictures, and the answers it was built from', () => {+ const summary = {+ ...SUMMARY,+ members: {+ owner: { id: 7, username: 'mia', avatar_url: '/uploads/avatars/mia-1.png' },+ collaborators: [+ { id: 8, username: 'jon', avatar_url: 'https://lh3.example.test/jon.png' },+ { id: 9, username: 'ana', avatar_url: '/uploads/avatars/../../secret' },+ ],+ },+ };+ const card = buildTripCard(1, 8, summary, PLACES, null);+ expect(card.viewerId).toBe(8);+ expect(card.members.get(7)).toEqual({ name: 'mia', avatarKey: 'mia-1.png' });+ expect(card.members.get(8)).toEqual({ name: 'jon', avatarKey: null });+ expect(card.members.get(9)).toEqual({ name: 'ana', avatarKey: null });+ expect(card.sources).toEqual({ summary, places: PLACES });+ });+it('ASTCTX-002: a tool that answered with an error leaves an emptier card, not a broken one', () => {- const card = buildTripCard(5, 'Trip not found or access denied.', null, null);+ const card = buildTripCard(5, 7, 'Trip not found or access denied.', null, null);expect(card).toMatchObject({ tripId: 5, title: '', days: [] });expect(card.places.size).toBe(0);expect(- buildTripCard(5, { days: [{ id: 'x' }, null, { id: 3, assignments: [{ id: 1 }] }] }, { places: 'no' }, null).days,+ buildTripCard(5, 7, { days: [{ id: 'x' }, null, { id: 3, assignments: [{ id: 1 }] }] }, { places: 'no' }, null)+ .days,).toEqual([{ id: 3, number: 1, date: null, title: null, placeIds: [] }]);});});describe('renderTripCard', () => {it('ASTCTX-010: lists the days with their places and ids, the unscheduled places and the focus', () => {- const text = renderTripCard(buildTripCard(1, SUMMARY, PLACES, { dayId: 32, placeIds: [14, 999] }));+ const text = renderTripCard(buildTripCard(1, 7, SUMMARY, PLACES, { dayId: 32, placeIds: [14, 999] }));expect(text).toContain('Trip: Kyoto in June');expect(text).toContain('Dates: 2026-06-11 to 2026-06-12');expect(text).toContain('31 | 2026-06-11 | Arrival | Nishiki Market (12)');@@ -164,7 +185,7 @@ describe('renderTripCard', () => {it('ASTCTX-011: a trip without days says so, and long lists are counted, not listed', () => {const many = { places: Array.from({ length: 205 }, (_, i) => ({ id: i + 1, name: `P${i + 1}` })) };- const text = renderTripCard(buildTripCard(1, { trip: { title: 'T' } }, many, null));+ const text = renderTripCard(buildTripCard(1, 7, { trip: { title: 'T' } }, many, null));expect(text).toContain('(no days yet)');expect(text).toContain('and 5 more');});@@ -177,22 +198,22 @@ describe('renderTripCard', () => {{ id: 15, name: 'Kansai Airport', lat: 34.434, lng: 135.244 },],};- const text = renderTripCard(buildTripCard(1, SUMMARY, places, { placeIds: [12] }));+ const text = renderTripCard(buildTripCard(1, 7, SUMMARY, places, { placeIds: [12] }));expect(text).toContain('Around: 34.9670, 135.7640');expect(text).toContain('Nishiki Market (12, google ChIJn)');expect(text).toContain('- place 12: Nishiki Market (at 35.0050, 135.7640; google place id ChIJn)');- expect(renderTripCard(buildTripCard(1, SUMMARY, PLACES, null))).not.toContain('Around:');+ expect(renderTripCard(buildTripCard(1, 7, SUMMARY, PLACES, null))).not.toContain('Around:');});it('ASTCTX-013: the part of the map on screen tells "here", a view of a whole country does not', () => {const view = { south: 35.6, west: 139.7, north: 35.72, east: 139.82 };- const text = renderTripCard(buildTripCard(1, SUMMARY, PLACES, { view }));+ const text = renderTripCard(buildTripCard(1, 7, SUMMARY, PLACES, { view }));expect(text).toContain("The map on the user's screen shows south 35.6000, west 139.7000, north 35.7200, east 139.8200.",);expect(text).toContain('"here", "nearby" or "around" means this area');const country = { south: 30, west: 129, north: 45, east: 146 };- expect(renderTripCard(buildTripCard(1, SUMMARY, PLACES, { view: country }))).not.toContain('on the user');+ expect(renderTripCard(buildTripCard(1, 7, SUMMARY, PLACES, { view: country }))).not.toContain('on the user');});});@@ -211,7 +232,7 @@ describe('the turn context', () => {});it('ASTCTX-022: carries the date, the units the user prefers and the card', () => {- const card = buildTripCard(1, SUMMARY, PLACES, null);+ const card = buildTripCard(1, 7, SUMMARY, PLACES, null);const context = turnContext(card, 'Asia/Tokyo', new Date('2026-06-11T23:30:00Z'), {temperature_unit: 'fahrenheit',distance_unit: 'metric',@@ -224,7 +245,7 @@ describe('the turn context', () => {});it("ASTCTX-023: the trip notes of this trip come along as preferences, never another trip's", () => {- const card = buildTripCard(1, SUMMARY, PLACES, null);+ const card = buildTripCard(1, 7, SUMMARY, PLACES, null);const prefs = { assistant_memory: { '1': ' Vegetarian, no museums. ', '2': 'Other trip' } };const context = turnContext(card, 'UTC', new Date(), prefs);expect(context).toContain('<trip_notes>\nVegetarian, no museums.\n</trip_notes>');@@ -234,7 +255,7 @@ describe('the turn context', () => {});it('ASTCTX-024: cost estimates are asked for unless the user turned them off', () => {- const card = buildTripCard(1, SUMMARY, PLACES, null);+ const card = buildTripCard(1, 7, SUMMARY, PLACES, null);expect(turnContext(card, 'UTC', new Date(), {})).toContain('create_budget_item');expect(turnContext(card, 'UTC', new Date(), { assistant_cost_estimates: false })).not.toContain('create_budget_item',diff --git a/server/tests/unit/nest/assistant/assistant-found-places.service.test.ts b/server/tests/unit/nest/assistant/assistant-found-places.service.test.tsindex 968582222..fb0738747 100644--- a/server/tests/unit/nest/assistant/assistant-found-places.service.test.ts+++ b/server/tests/unit/nest/assistant/assistant-found-places.service.test.ts@@ -5,15 +5,17 @@* suggestion is held as a change card in one transaction, refused while a turn* runs, while another change waits, or past the per-minute limit.*- * Replaced: the trip tools (what the trip reads as), the rate limit and the- * stream registry.+ * Replaced: the trip tools (what the trip reads as), the rate limit, the+ * stream registry and the airports.*/import { AssistantMessages } from '../../../../src/db/entities/AssistantMessages.entity';import { AssistantThreads } from '../../../../src/db/entities/AssistantThreads.entity';import { AssistantToolCalls } from '../../../../src/db/entities/AssistantToolCalls.entity';+import { AirportsService } from '../../../../src/nest/airports/airports.service';import { AssistantFoundPlacesService } from '../../../../src/nest/assistant/assistant-found-places.service';import { AssistantStreamRegistry } from '../../../../src/nest/assistant/assistant-stream.registry';import { AssistantToolsService } from '../../../../src/nest/assistant/assistant-tools.service';+import { AssistantCardContext } from '../../../../src/nest/assistant/cards/card-context';import { RateLimitService } from '../../../../src/nest/common/rate-limit.service';import { UnitOfWork } from '../../../../src/nest/database/unit-of-work';import { createSnapshotTestDb } from '../../../helpers/db-mock';@@ -53,6 +55,8 @@ beforeAll(async () => {imports: [MikroOrmModule.forFeature([AssistantThreads, AssistantMessages, AssistantToolCalls])],providers: [AssistantFoundPlacesService,+ AssistantCardContext,+ { provide: AirportsService, useValue: { findByIata: () => null } },{ provide: AssistantToolsService, useValue: tools },{ provide: RateLimitService, useValue: rateLimit },{ provide: AssistantStreamRegistry, useValue: streams },diff --git a/server/tests/unit/nest/assistant/assistant-redact.test.ts b/server/tests/unit/nest/assistant/assistant-redact.test.tsindex 101586f5a..4f2f0ae47 100644--- a/server/tests/unit/nest/assistant/assistant-redact.test.ts+++ b/server/tests/unit/nest/assistant/assistant-redact.test.ts@@ -4,7 +4,8 @@* plan, and anything too large cut down along its structure, never through* the middle of the JSON.*/-import { fitToSize, redactForProvider, toolOutputForProvider } from '../../../../src/nest/assistant/assistant-redact';+import { fitToSize, toolOutputForProvider } from '../../../../src/nest/assistant/assistant-output';+import { redactForProvider } from '../../../../src/nest/assistant/assistant-redact';import { describe, expect, it } from 'vitest';@@ -27,6 +28,15 @@ describe('redactForProvider', () => {reservations: [{ confirmation_number: '[hidden]', title: 'Dinner' }, { confirmation_number: null }],});});++ it("ASTRED-002: drops a booked place's picture and the trip's cover, wherever they sit", () => {+ expect(+ redactForProvider({+ reservations: [{ title: 'Ryokan', place_image: '/uploads/places/ryokan.jpg' }],+ trip: { title: 'Kyoto', trip_cover: '/uploads/covers/kyoto.jpg' },+ }),+ ).toEqual({ reservations: [{ title: 'Ryokan' }], trip: { title: 'Kyoto' } });+ });});describe('fitToSize', () => {diff --git a/server/tests/unit/nest/assistant/assistant-tools.service.test.ts b/server/tests/unit/nest/assistant/assistant-tools.service.test.tsindex 403cc095b..5b8874eec 100644--- a/server/tests/unit/nest/assistant/assistant-tools.service.test.ts+++ b/server/tests/unit/nest/assistant/assistant-tools.service.test.ts@@ -16,13 +16,9 @@ import {groupOf,isOfferedTool,} from '../../../../src/nest/assistant/assistant-tool-offer';-import {- ASSISTANT_ARG_POLICY,- ASSISTANT_SCOPES,- ASSISTANT_SERVER_TOOLS,- ASSISTANT_WRITE_TOOLS,-} from '../../../../src/nest/assistant/assistant-tools.constants';+import { ASSISTANT_SCOPES, ASSISTANT_SERVER_TOOLS } from '../../../../src/nest/assistant/assistant-tools.constants';import { AssistantToolsService, checkToolCatalog } from '../../../../src/nest/assistant/assistant-tools.service';+import { ASSISTANT_ARG_POLICY, ASSISTANT_WRITE_TOOLS } from '../../../../src/nest/assistant/cards/registry';import { withRequestContext } from '../../../../src/nest/database/request-context';import { makePlace } from '../../../helpers/factories/places';import { findRows } from '../../../helpers/factories/rows';@@ -98,6 +94,37 @@ describe('the assistant tool catalog', () => {]);});+ it('ASTTOOL-018: names a package entry for a tool that does not exist, and an undo read that is not registered', () => {+ const entry = (name: string) => ({ kind: 'tool' as const, name, className: 'X', methodName: 'y' });+ expect(checkToolCatalog([])).toContain(+ 'tool "create_hike" with cards of a package is neither registered nor the server\'s own',+ );+ const cards = {+ list_vacay: { answer: () => null },+ take_vacay: {+ undo: {+ tool: 'delete_place',+ args: () => null,+ reads: () => [{ tool: 'get_vacay_plan', args: {} }],+ unchanged: () => true,+ },+ },+ add_found_place: { appliedIds: () => [] },+ };+ const problems = checkToolCatalog([entry('take_vacay')], cards);+ expect(problems).toContain('tool "list_vacay" with cards of a package is neither registered nor the server\'s own');+ expect(problems).toContain('undo read "get_vacay_plan" is not registered');+ expect(problems.join()).not.toContain('"add_found_place" with cards');+ expect(problems.join()).not.toContain('"take_vacay" with cards');+ });++ it('ASTTOOL-019: names a held read of a package that is not registered', () => {+ const entry = (name: string) => ({ kind: 'tool' as const, name, className: 'X', methodName: 'y' });+ const problems = checkToolCatalog([entry('fetch_corridor')], {}, ['fetch_corridor', 'fetch_tolls']);+ expect(problems).toContain('held read "fetch_tolls" of a package is not registered');+ expect(problems.join()).not.toContain('"fetch_corridor"');+ });+it("ASTTOOL-006: the server's own steps are no MCP tools", () => {for (const name of ASSISTANT_SERVER_TOOLS) expect(listed.has(name), name).toBe(false);});diff --git a/server/tests/unit/nest/assistant/assistant-undo.helpers.test.ts b/server/tests/unit/nest/assistant/assistant-undo.helpers.test.tsindex c9f3eb31b..790683bfe 100644--- a/server/tests/unit/nest/assistant/assistant-undo.helpers.test.ts+++ b/server/tests/unit/nest/assistant/assistant-undo.helpers.test.ts@@ -2,10 +2,16 @@* The undo guard: an applied change is taken back only while what it created* is as it left it, and, for a place, still only where the change put it.*/-import { ASSISTANT_UNDO_MAP } from '../../../../src/nest/assistant/assistant-tools.constants';-import { unchangedSinceApplied, type TripSnapshot } from '../../../../src/nest/assistant/assistant-undo.helpers';+import {+ unchangedSinceApplied,+ undoSnapshotOf,+ undoTargetsOf,+ type TripSnapshot,+} from '../../../../src/nest/assistant/assistant-undo.helpers';+import { readKey } from '../../../../src/nest/assistant/cards/card-values';+import { ASSISTANT_UNDO_MAP } from '../../../../src/nest/assistant/cards/registry';-import { describe, expect, it } from 'vitest';+import { describe, expect, it, vi } from 'vitest';const PLACE = { id: 9, name: 'Kinkaku-ji', updated_at: '2026-10-21 10:00:00', lat: 35, lng: 135 };@@ -103,22 +109,22 @@ describe('unchangedSinceApplied', () => {describe('ASSISTANT_UNDO_MAP', () => {it('ASTUND-010: builds the counter-call from the change and its answer, or none', () => {- expect(ASSISTANT_UNDO_MAP.create_place.args({}, { place: { id: 9 } })).toEqual({ placeId: 9 });- expect(ASSISTANT_UNDO_MAP.create_and_assign_place.args({}, { place: { id: 9 } })).toEqual({ placeId: 9 });- expect(ASSISTANT_UNDO_MAP.assign_place_to_day.args({ dayId: 31 }, { assignment: { id: 301 } })).toEqual({+ expect(ASSISTANT_UNDO_MAP.create_place.args({}, { place: { id: 9 } }, null)).toEqual({ placeId: 9 });+ expect(ASSISTANT_UNDO_MAP.create_and_assign_place.args({}, { place: { id: 9 } }, null)).toEqual({ placeId: 9 });+ expect(ASSISTANT_UNDO_MAP.assign_place_to_day.args({ dayId: 31 }, { assignment: { id: 301 } }, null)).toEqual({dayId: 31,assignmentId: 301,});- expect(ASSISTANT_UNDO_MAP.create_day_note.args({ dayId: 31 }, { note: { id: 41 } })).toEqual({+ expect(ASSISTANT_UNDO_MAP.create_day_note.args({ dayId: 31 }, { note: { id: 41 } }, null)).toEqual({dayId: 31,noteId: 41,});- expect(ASSISTANT_UNDO_MAP.create_packing_item.args({}, { item: { id: 51 } })).toEqual({ itemId: 51 });- expect(ASSISTANT_UNDO_MAP.create_todo.args({}, { item: { id: 61 } })).toEqual({ itemId: 61 });- expect(ASSISTANT_UNDO_MAP.create_budget_item.args({}, { item: { id: 71 } })).toEqual({ itemId: 71 });- expect(ASSISTANT_UNDO_MAP.create_place.args({}, 'Place not found.')).toBeNull();- expect(ASSISTANT_UNDO_MAP.assign_place_to_day.args({}, { assignment: { id: 301 } })).toBeNull();- expect(ASSISTANT_UNDO_MAP.create_day_note.args({ dayId: 31 }, { note: { id: 0 } })).toBeNull();+ expect(ASSISTANT_UNDO_MAP.create_packing_item.args({}, { item: { id: 51 } }, null)).toEqual({ itemId: 51 });+ expect(ASSISTANT_UNDO_MAP.create_todo.args({}, { item: { id: 61 } }, null)).toEqual({ itemId: 61 });+ expect(ASSISTANT_UNDO_MAP.create_budget_item.args({}, { item: { id: 71 } }, null)).toEqual({ itemId: 71 });+ expect(ASSISTANT_UNDO_MAP.create_place.args({}, 'Place not found.', null)).toBeNull();+ expect(ASSISTANT_UNDO_MAP.assign_place_to_day.args({}, { assignment: { id: 301 } }, null)).toBeNull();+ expect(ASSISTANT_UNDO_MAP.create_day_note.args({ dayId: 31 }, { note: { id: 0 } }, null)).toBeNull();});});@@ -177,10 +183,47 @@ describe('a created tour', () => {it('ASTUND-011: is taken back by deleting its place, named in the answer', () => {for (const tool of ['create_hike', 'create_city_walk']) {expect(ASSISTANT_UNDO_MAP[tool].tool).toBe('delete_place');- expect(ASSISTANT_UNDO_MAP[tool].args({}, created)).toEqual({ placeId: 64 });- expect(ASSISTANT_UNDO_MAP[tool].args({}, { tour: { place_id: 0 } })).toBeNull();- expect(ASSISTANT_UNDO_MAP[tool].args({}, { tour: 'odd' })).toBeNull();- expect(ASSISTANT_UNDO_MAP[tool].args({}, 'Tour not found.')).toBeNull();+ expect(ASSISTANT_UNDO_MAP[tool].args({}, created, null)).toEqual({ placeId: 64 });+ expect(ASSISTANT_UNDO_MAP[tool].args({}, { tour: { place_id: 0 } }, null)).toBeNull();+ expect(ASSISTANT_UNDO_MAP[tool].args({}, { tour: 'odd' }, null)).toBeNull();+ expect(ASSISTANT_UNDO_MAP[tool].args({}, 'Tour not found.', null)).toBeNull();}});});++describe('the undo session', () => {+ const session = (failing: string[] = []) => ({+ read: vi.fn(async (name: string, args: Record<string, unknown> = {}) =>+ failing.includes(name) ? { ok: false, value: 'Not allowed.' } : { ok: true, value: { name, args } },+ ),+ });++ it('ASTUND-020: holds the removing tool and the trip reads, and reads the trip before the check', async () => {+ expect([...undoTargetsOf('delete_place', 'create_hike', {}, {})]).toEqual([+ 'delete_place',+ 'get_trip_summary',+ 'list_places',+ ]);+ const snap = await undoSnapshotOf(session(), 'create_place', {}, {});+ expect(snap).toEqual({+ summary: { name: 'get_trip_summary', args: {} },+ places: { name: 'list_places', args: {} },+ reads: new Map(),+ });+ expect(await undoSnapshotOf(session(['list_places']), 'create_place', {}, {})).toBeNull();+ });++ it('ASTUND-021: keeps what a package reads by tool and arguments, a failed read as null', async () => {+ const reads = [+ { tool: 'get_vacay_plan', args: { year: 2026 } },+ { tool: 'list_vacay_entries', args: {} },+ ];+ const snap = await undoSnapshotOf(session(['list_vacay_entries']), 'toggle_vacay', {}, {}, reads);+ expect(snap?.reads.get(readKey('get_vacay_plan', { year: 2026 }))).toEqual({+ name: 'get_vacay_plan',+ args: { year: 2026 },+ });+ expect(snap?.reads.get(readKey('list_vacay_entries'))).toBeNull();+ expect(snap?.reads.size).toBe(2);+ });+});diff --git a/server/tests/unit/nest/assistant/cards/card-context.test.ts b/server/tests/unit/nest/assistant/cards/card-context.test.tsnew file mode 100644index 000000000..d707b855b--- /dev/null+++ b/server/tests/unit/nest/assistant/cards/card-context.test.ts@@ -0,0 +1,189 @@+/**+ * What the change cards are made with beyond the tool's own answer: the+ * turn's reads, each made once and cut off after four per change, the+ * categories read once a turn, the airports by their codes, the lookups of+ * a change the server proposes itself, and the card of an applied change+ * through the guarded registry.+ */+import { AirportsService } from '../../../../../src/nest/airports/airports.service';+import { buildTripCard } from '../../../../../src/nest/assistant/assistant-context';+import type { AssistantToolsService, ToolRun } from '../../../../../src/nest/assistant/assistant-tools.service';+import {+ AssistantCardContext,+ loadFor,+ MAX_CARD_READS,+ memoisedReader,+} from '../../../../../src/nest/assistant/cards/card-context';+import type { ToolCards } from '../../../../../src/nest/assistant/cards/card-types';+import type { AssistantMessagePart, TrekCard } from '@trek/shared';++import { beforeEach, describe, expect, it, vi } from 'vitest';++const logMock = vi.hoisted(() => ({ logInfo: vi.fn(), logError: vi.fn(), logWarn: vi.fn(), logDebug: vi.fn() }));+vi.mock('../../../../../src/nest/audit/audit-log.logger', () => logMock);++beforeEach(() => vi.clearAllMocks());++/** A session that answers every read with its tool and arguments, or fails the ones named. */+function session(failing: readonly string[] = []) {+ return {+ read: vi.fn(async (name: string, args: Record<string, unknown> = {}): Promise<ToolRun> =>+ failing.includes(name) ? { ok: false, value: 'Not allowed.' } : { ok: true, value: { name, args } },+ ),+ hintOf: vi.fn(() => ({ destructive: false, creates: true, group: 'vacay' })),+ };+}++const airports = {+ findByIata: vi.fn((code: string) =>+ code === 'MUC'+ ? { iata: 'MUC', name: 'Munich', city: 'München', lat: 48.35, lng: 11.79, tz: 'Europe/Berlin' }+ : null,+ ),+};+const opened = { ...session(), close: vi.fn(async () => undefined) };+const tools = { open: vi.fn(async () => opened) };+const context = new AssistantCardContext(+ airports as unknown as AirportsService,+ tools as unknown as AssistantToolsService,+);+const card = buildTripCard(1, 7, { trip: { title: 'Bavaria' }, days: [{ id: 31, day_number: 1 }] }, null, null);++describe('memoisedReader', () => {+ it('ASTCCX-001: reads a tool and its arguments once, whatever their key order', async () => {+ const s = session();+ const read = memoisedReader(s);+ const first = await read('get_vacay_plan', { year: 2026, userId: 7 });+ const again = await read('get_vacay_plan', { userId: 7, year: 2026 });+ await read('get_vacay_plan', { year: 2027, userId: 7 });+ expect(again).toBe(first);+ expect(first).toEqual({ name: 'get_vacay_plan', args: { year: 2026, userId: 7 } });+ expect(s.read).toHaveBeenCalledTimes(2);+ });++ it('ASTCCX-002: a read that failed or threw reads as null', async () => {+ const s = session(['list_budget_items']);+ const read = memoisedReader(s);+ expect(await read('list_budget_items')).toBeNull();+ s.read.mockRejectedValueOnce(new Error('closed'));+ expect(await read('get_trip_summary')).toBeNull();+ });+});++describe('loadFor', () => {+ it('ASTCCX-010: a lookup gets at most four reads; the ones past it read as null and are logged', async () => {+ const seen: unknown[] = [];+ const cards: Record<string, ToolCards> = {+ plan_days: {+ load: async (_args, read) => {+ for (const year of [2021, 2022, 2023, 2024, 2025]) seen.push(await read('get_vacay_plan', { year }));+ return seen.length;+ },+ },+ };+ const s = session();+ expect(await loadFor('plan_days', {}, memoisedReader(s), cards)).toBe(5);+ expect(s.read).toHaveBeenCalledTimes(MAX_CARD_READS);+ expect(seen.at(-1)).toBeNull();+ expect(String(logMock.logWarn.mock.calls[0]?.[0])).toContain('more than 4 reads');+ });++ it('ASTCCX-011: a lookup that throws gives null; a tool without one reads nothing', async () => {+ const cards: Record<string, ToolCards> = {+ broken: {+ load: () => {+ throw new Error('bad shape');+ },+ },+ };+ const s = session();+ expect(await loadFor('broken', {}, memoisedReader(s), cards)).toBeNull();+ expect(String(logMock.logWarn.mock.calls[0]?.[0])).toContain('the lookup of broken failed: bad shape');+ expect(await loadFor('create_place', {}, memoisedReader(s))).toBeNull();+ expect(s.read).not.toHaveBeenCalled();+ });+});++describe('AssistantCardContext', () => {+ it('ASTCCX-020: a turn reads the categories once, when the first change needs them', async () => {+ const s = session();+ s.read.mockImplementation(async (name: string) =>+ name === 'list_categories'+ ? { ok: true, value: { categories: [{ id: 2, name: 'Food', icon: null }] } }+ : { ok: false, value: 'no' },+ );+ const turn = context.forTurn(s, card, 'en', '2026-06-01');+ expect(s.read).not.toHaveBeenCalled();+ const first = await turn.describe('create_place', 'w1', { name: 'Hofbräuhaus', category_id: 2 });+ const second = await turn.describe('create_place', 'w2', { name: 'Viktualienmarkt', category_id: 2 });+ expect(first.rows).toContainEqual({ op: 'add', labelKey: 'category', before: null, after: 'Food' });+ expect(second.toolCallId).toBe('w2');+ expect(s.read).toHaveBeenCalledTimes(1);+ });++ it('ASTCCX-021: a tool without a card of its own is described from its arguments and its hint', async () => {+ const s = session();+ const preview = await context.forTurn(s, card, 'en', '2026-06-01').describe('set_vacay_days', 'w1', { days: 3 });+ expect(preview).toMatchObject({ verbKey: 'genericCreate', tool: 'set_vacay_days', domain: 'vacay' });+ expect(s.hintOf).toHaveBeenCalledWith('set_vacay_days');+ });++ it('ASTCCX-022: names an airport by its code, any case, and nothing for what is no code', () => {+ const ctx = context.contextOf(card, new Map(), 'en', '2026-06-01');+ expect(ctx.airport('muc')).toEqual({ city: 'München', lat: 48.35, lng: 11.79, tz: 'Europe/Berlin' });+ expect(ctx.airport('XXX')).toBeNull();+ expect(ctx.airport('Munich')).toBeNull();+ expect(airports.findByIata).toHaveBeenCalledTimes(2);+ expect(ctx).not.toHaveProperty('hintOf');+ });++ it('ASTCCX-024: a proposed change without a lookup is described without opening a session', async () => {+ const ctx = context.contextOf(card, new Map(), 'en', '2026-06-01');+ const [change] = await context.describeProposed(7, 1, ctx, [{ id: 'p1', toolName: 'create_place', args: {} }]);+ expect(change).toMatchObject({ id: 'p1', toolName: 'create_place', preview: { toolCallId: 'p1' } });+ expect(tools.open).not.toHaveBeenCalled();+ });++ it('ASTCCX-025: proposed changes with a lookup share one session and its memo, closed after', async () => {+ const ctx = context.contextOf(card, new Map(), 'en', '2026-06-01');+ const looked: unknown[] = [];+ const cards: Record<string, ToolCards> = {+ import_booking: {+ load: async (_args, read) => {+ looked.push(await read('list_reservations'));+ return null;+ },+ },+ };+ const calls = [+ { id: 'p1', toolName: 'import_booking', args: {} },+ { id: 'p2', toolName: 'import_booking', args: {} },+ ];+ const changes = await context.describeProposed(7, 1, ctx, calls, cards);+ expect(changes.map((change) => change.preview.toolCallId)).toEqual(['p1', 'p2']);+ expect(tools.open).toHaveBeenCalledTimes(1);+ expect(tools.open).toHaveBeenCalledWith(7, 1);+ expect(opened.read).toHaveBeenCalledTimes(1);+ expect(looked).toEqual([+ { name: 'list_reservations', args: {} },+ { name: 'list_reservations', args: {} },+ ]);+ expect(opened.close).toHaveBeenCalledTimes(1);+ });++ it('ASTCCX-023: the receipt of an applied change carries the card its builder gave', () => {+ const built = { kind: 'tourRoute' } as TrekCard;+ const applied = vi.spyOn(context, 'appliedCard').mockReturnValue(built);+ const w = { card: vi.fn() };+ const receipts: AssistantMessagePart[] = [];+ context.receipt(w, receipts, { id: 'w1', tool_name: 'create_hike' }, { name: 'Lake' }, { tour: {} }, null);+ expect(applied).toHaveBeenCalledWith('create_hike', {+ args: { name: 'Lake' },+ result: { tour: {} },+ preview: null,+ });+ expect(receipts).toEqual([{ type: 'data-trek-card', data: { toolCallId: 'w1', card: built } }]);+ applied.mockRestore();+ expect(context.appliedCard('create_place', { args: {}, result: {}, preview: null })).toBeNull();+ });+});diff --git a/server/tests/unit/nest/assistant/cards/card-values.test.ts b/server/tests/unit/nest/assistant/cards/card-values.test.tsnew file mode 100644index 000000000..190eb4dd6--- /dev/null+++ b/server/tests/unit/nest/assistant/cards/card-values.test.ts@@ -0,0 +1,102 @@+/**+ * The readers every card is built with: text masked when it comes from an+ * answer, cut to its bound, line breaks kept where a note needs them; ids,+ * clocks, moments, colours and stored file names read without trusting the+ * shape; people named from the trip card; reads named the same whatever the+ * key order of their arguments.+ */+import { buildTripCard } from '../../../../../src/nest/assistant/assistant-context';+import {+ argId,+ blockText,+ canonicalJson,+ clipped,+ clockOf,+ fileKeyOf,+ hexOrNull,+ idIn,+ instantOf,+ personOf,+ readKey,+} from '../../../../../src/nest/assistant/cards/card-values';++import { describe, expect, it } from 'vitest';++describe('card values', () => {+ it('ASTCVL-001: one line of text is masked, trimmed and cut', () => {+ expect(clipped(' Write to [email protected]\nsoon ', 80)).toBe('Write to [hidden] soon');+ expect(clipped('abcdef', 4)).toBe('abc…');+ expect(clipped(' ', 4)).toBeNull();+ expect(clipped(7, 4)).toBeNull();+ });++ it('ASTCVL-002: a longer text keeps its paragraphs, masked only when it comes from an answer', () => {+ const note = 'Bring cash.\r\n\r\n\r\n\r\nAsk [email protected]\t at the desk. ';+ expect(blockText(note, 200, { mask: true })).toBe('Bring cash.\n\nAsk [hidden] at the desk.');+ expect(blockText(note, 200, { mask: false })).toBe('Bring cash.\n\nAsk [email protected] at the desk.');+ expect(blockText('one\ntwo three', 8, { mask: false })).toBe('one\ntwo…');+ expect(blockText('\n \n', 8, { mask: false })).toBeNull();+ expect(blockText(null, 8, { mask: true })).toBeNull();+ });++ it('ASTCVL-003: ids are positive integers, read from an answer or the arguments', () => {+ expect(idIn({ place: { id: 4 } }, 'place')).toBe(4);+ expect(idIn({ place: { id: '4' } }, 'place')).toBeNull();+ expect(idIn(null, 'place')).toBeNull();+ expect(argId({ dayId: 3, noteId: 0, itemId: 1.5 }, 'dayId')).toBe(3);+ expect(argId({ noteId: 0 }, 'noteId')).toBeNull();+ expect(argId({ itemId: 1.5 }, 'itemId')).toBeNull();+ });++ it('ASTCVL-004: a clock is HH:MM, from a time or the time of a date and time as written', () => {+ expect(clockOf('9:30')).toBe('09:30');+ expect(clockOf('09:30:00')).toBe('09:30');+ expect(clockOf('2026-06-11T18:05:00+02:00')).toBe('18:05');+ expect(clockOf('2026-06-11 07:45')).toBe('07:45');+ expect(clockOf('24:00')).toBeNull();+ expect(clockOf('noon')).toBeNull();+ });++ it('ASTCVL-005: a moment needs its zone and is written in UTC to the second', () => {+ expect(instantOf('2026-06-11T18:05:30.250+02:00')).toBe('2026-06-11T16:05:30Z');+ expect(instantOf('2026-06-11T18:05Z')).toBe('2026-06-11T18:05:00Z');+ expect(instantOf('2026-06-11T18:05:00')).toBeNull();+ expect(instantOf('2026-06-11')).toBeNull();+ expect(instantOf(1_700_000_000)).toBeNull();+ });++ it('ASTCVL-006: a colour is #rrggbb, a stored file name comes only from one of TREK own upload paths', () => {+ expect(hexOrNull('#1a2B3c')).toBe('#1a2B3c');+ expect(hexOrNull('red')).toBeNull();+ expect(hexOrNull('#123')).toBeNull();+ expect(fileKeyOf('/uploads/avatars/a1b2-c3.png')).toBe('a1b2-c3.png');+ expect(fileKeyOf('/uploads/places/x.jpg?v=2')).toBeNull();+ expect(fileKeyOf('https://lh3.example.test/a.png')).toBeNull();+ expect(fileKeyOf('/uploads/avatars/../secret')).toBeNull();+ expect(fileKeyOf('/uploads/avatars/..hidden')).toBeNull();+ expect(fileKeyOf('a.png')).toBeNull();+ });++ it('ASTCVL-007: a person is a trip member by id, named as the trip names them', () => {+ const summary = {+ members: {+ owner: { id: 7, username: '[email protected]', avatar_url: '/uploads/avatars/mia.png' },+ collaborators: [{ id: 8, username: 'jon' }],+ },+ };+ const card = buildTripCard(1, 8, summary, null, null);+ expect(personOf(card, 7)).toEqual({ id: 7, name: '[hidden]', avatarKey: 'mia.png' });+ expect(personOf(card, 8)).toEqual({ id: 8, name: 'jon', avatarKey: null });+ expect(personOf(card, 9)).toBeNull();+ });++ it('ASTCVL-008: a read is named by its tool and its arguments, in any key order', () => {+ expect(canonicalJson({ b: [2, { d: 1, c: null }], a: 'x', skip: undefined })).toBe(+ '{"a":"x","b":[2,{"c":null,"d":1}]}',+ );+ expect(readKey('get_vacay_plan', { year: 2026, userId: 7 })).toBe(+ readKey('get_vacay_plan', { userId: 7, year: 2026 }),+ );+ expect(readKey('list_places')).toBe('list_places {}');+ });+});diff --git a/server/tests/unit/nest/assistant/cards/registry-guards.test.ts b/server/tests/unit/nest/assistant/cards/registry-guards.test.tsnew file mode 100644index 000000000..a9da905f2--- /dev/null+++ b/server/tests/unit/nest/assistant/cards/registry-guards.test.ts@@ -0,0 +1,87 @@+/**+ * A package hook that throws never breaks a turn, a decision or an undo: the+ * registry wraps each one at load, and the place that calls it falls back to+ * what a tool without the hook gets. One package is replaced by a probe whose+ * every hook throws, so these cases run through the live call sites.+ */+import { buildTripCard } from '../../../../../src/nest/assistant/assistant-context';+import { toolOutputForProvider } from '../../../../../src/nest/assistant/assistant-output';+import { unchangedSinceApplied } from '../../../../../src/nest/assistant/assistant-undo.helpers';+import type { PreviewContext } from '../../../../../src/nest/assistant/cards/card-types';+import {+ ASSISTANT_UNDO_MAP,+ describedOf,+ nameArgOf,+ TOOL_CARDS,+ undoReadsOf,+} from '../../../../../src/nest/assistant/cards/registry';+import { appliedChange, describeToolCall } from '../../../../../src/nest/assistant/tool-call-preview.helpers';++import { beforeEach, describe, expect, it, vi } from 'vitest';++const logMock = vi.hoisted(() => ({ logInfo: vi.fn(), logError: vi.fn(), logWarn: vi.fn(), logDebug: vi.fn() }));+vi.mock('../../../../../src/nest/audit/audit-log.logger', () => logMock);++vi.mock('../../../../../src/nest/assistant/cards/vacay', () => {+ const boom = (): never => {+ throw new Error('boom');+ };+ return {+ VACAY_CARDS: {+ id: 'vacay',+ tools: {+ plan_probe: {+ write: { verbKey: 'genericCreate', entity: 'other' },+ describe: boom,+ effect: boom,+ project: boom,+ appliedIds: boom,+ nameArg: boom,+ undo: { tool: 'delete_probe', args: boom, reads: boom, unchanged: boom },+ },+ list_probe: { appliedIds: () => [3, 0, -1, 2.5, 'x'] },+ },+ },+ };+});++beforeEach(() => vi.clearAllMocks());++const card = buildTripCard(1, 7, { trip: { title: 'Alps' } }, null, null);+const ctx: PreviewContext = { card, categories: new Map(), locale: 'en', today: '2026-06-01', airport: () => null };+const logged = () => logMock.logWarn.mock.calls.map(([line]) => String(line));++describe('the guarded package hooks', () => {+ it('ASTREG-030: a describer that throws gives way to the card built from the arguments', () => {+ const preview = describeToolCall('plan_probe', 'c1', { name: 'Lake' }, ctx);+ expect(preview).toMatchObject({ toolCallId: 'c1', tool: 'plan_probe' });+ expect(logged()[0]).toContain('the describer of plan_probe failed: boom');+ expect(describedOf('create_place', ctx, {}, null)).toBeNull();+ expect(TOOL_CARDS.plan_probe?.effect?.(ctx, {}, null)).toBeNull();+ });++ it('ASTREG-031: ids that throw fall back to the answer, and ids that are no row ids are left out', () => {+ const applied = appliedChange('plan_probe', 'c1', {}, { place: { id: 9 } }, null, null);+ expect(applied).toMatchObject({ entity: 'other', ids: [9] });+ expect(appliedChange('list_probe', 'c2', {}, {}, null, null)?.ids).toEqual([3]);+ expect(logged()[0]).toContain('the applied ids of plan_probe failed: boom');+ });++ it('ASTREG-032: an undo whose hooks throw has no way back and reads as changed since', () => {+ expect(ASSISTANT_UNDO_MAP.plan_probe?.args({}, {}, null)).toBeNull();+ expect(undoReadsOf('plan_probe', {}, {})).toEqual([]);+ expect(unchangedSinceApplied('plan_probe', {}, { summary: {}, places: {} })).toBe(false);+ expect(nameArgOf('plan_probe', 'probeId', 1, card)).toBeNull();+ expect(logged()).toEqual([+ expect.stringContaining('the undo arguments of plan_probe failed'),+ expect.stringContaining('the undo reads of plan_probe failed'),+ expect.stringContaining('the undo check of plan_probe failed'),+ expect.stringContaining('the name of probeId of plan_probe failed'),+ ]);+ });++ it('ASTREG-033: a projection that throws hands the provider the answer as it came', () => {+ expect(toolOutputForProvider('plan_probe', { days: 3 })).toEqual({ days: 3 });+ expect(logged()[0]).toContain('the projection of plan_probe failed: boom');+ });+});diff --git a/server/tests/unit/nest/assistant/cards/registry.test.ts b/server/tests/unit/nest/assistant/cards/registry.test.tsnew file mode 100644index 000000000..ebdb8380b--- /dev/null+++ b/server/tests/unit/nest/assistant/cards/registry.test.ts@@ -0,0 +1,225 @@+/**+ * The cards registry: the packages' entries merged by tool name, every overlap+ * refused at load, and the guarded card calls that give no card, never a+ * broken turn, for a builder that throws, misbuilds or builds too much. The+ * receipt card of an applied change rides on the same guard.+ */+import { buildTripCard } from '../../../../../src/nest/assistant/assistant-context';+import { withPackageControllers } from '../../../../../src/nest/assistant/assistant-tool-offer';+import { CORE_WRITE_TOOLS } from '../../../../../src/nest/assistant/assistant-tools.constants';+import { receiptCard } from '../../../../../src/nest/assistant/cards/applied-cards';+import type { DomainCards, PreviewContext, ToolCards } from '../../../../../src/nest/assistant/cards/card-types';+import { Rows } from '../../../../../src/nest/assistant/cards/preview-format';+import {+ answerCardOf,+ ASSISTANT_UNDO_MAP,+ ASSISTANT_WRITE_TOOLS,+ CARD_PROMPT_LINES,+ DOMAINS,+ guardedCards,+ mergeDomains,+ nameArgOf,+ refuseCoreOverlap,+ TOOL_CARDS,+ undoReadsOf,+ type CardCheck,+} from '../../../../../src/nest/assistant/cards/registry';+import type { AssistantMessagePart, TrekCard } from '@trek/shared';++import { beforeEach, describe, expect, it, vi } from 'vitest';+import { z, type ZodType } from 'zod';++const logMock = vi.hoisted(() => ({ logInfo: vi.fn(), logError: vi.fn(), logWarn: vi.fn(), logDebug: vi.fn() }));+vi.mock('../../../../../src/nest/audit/audit-log.logger', () => logMock);++beforeEach(() => vi.clearAllMocks());++const card = buildTripCard(1, 7, { trip: { title: 'Alps' } }, null, null);+const ctx: PreviewContext = { card, categories: new Map(), locale: 'en', today: '2026-06-01', airport: () => null };++/**+ * A stand-in for the card union with one kind of its own, so these cases hold+ * whatever fields the packages give their kinds.+ */+const PROBE: CardCheck = {+ schema: z.object({ kind: z.literal('probe'), title: z.string().max(12) }) as unknown as ZodType<TrekCard>,+ maxChars: 60,+};+const probe = (title: string) => ({ kind: 'probe', title }) as unknown as TrekCard;++const domain = (id: DomainCards['id'], tools: Record<string, ToolCards>, extra: Partial<DomainCards> = {}) => ({+ id,+ tools,+ ...extra,+});+const described = () => ({ subject: 'x', rows: new Rows(), dayId: null, placeIds: [] });++describe('mergeDomains', () => {+ it('ASTREG-001: the live registry holds every package once, the core tables and the tours they brought', () => {+ expect(new Set(DOMAINS.map((d) => d.id)).size).toBe(10);+ for (const name of Object.keys(CORE_WRITE_TOOLS)) expect(ASSISTANT_WRITE_TOOLS[name]).toBe(CORE_WRITE_TOOLS[name]);+ expect(ASSISTANT_WRITE_TOOLS.create_hike).toEqual({ verbKey: 'addTour', entity: 'tour' });+ expect(ASSISTANT_UNDO_MAP.create_city_walk?.tool).toBe('delete_place');+ expect(ASSISTANT_UNDO_MAP.create_city_walk?.args({}, { tour: { place_id: 9 } }, null)).toEqual({ placeId: 9 });+ expect(TOOL_CARDS.update_tour?.undo).toBeUndefined();+ expect(CARD_PROMPT_LINES).toEqual([]);+ });++ it('ASTREG-002: two packages may fill different fields of one tool, never the same one', () => {+ const answer = () => null;+ const merged = mergeDomains([+ domain('tour', { list_tours: { answer } }),+ domain('packing', { list_tours: { appliedIds: () => [1] } }),+ ]);+ expect(Object.keys(merged.tools.list_tours ?? {})).toEqual(['answer', 'appliedIds']);+ expect(() =>+ mergeDomains([domain('tour', { list_tours: { answer } }), domain('packing', { list_tours: { answer } })]),+ ).toThrow('"answer" of "list_tours" is claimed by tour and packing');+ });++ it("ASTREG-003: a package never takes the core's entry of a tool, nor half a curated card", () => {+ const write = { verbKey: 'genericCreate', entity: 'other' } as const;+ expect(() => mergeDomains([domain('budget', { create_place: { write, describe: described } })])).toThrow(+ '"write" of "create_place" is the core\'s own',+ );+ expect(() => mergeDomains([domain('budget', { import_booking: { write, describe: described } })])).toThrow(+ '"write" of "import_booking"',+ );+ const undo = { tool: 'delete_todo', args: () => null, unchanged: () => true };+ expect(() => mergeDomains([domain('packing', { create_todo: { undo } })])).toThrow('"undo" of "create_todo"');+ expect(() => mergeDomains([domain('tour', { update_place: { argPolicy: { stripped: ['x'] } } })])).toThrow(+ '"argPolicy" of "update_place"',+ );+ expect(() => mergeDomains([domain('vacay', { set_vacay: { describe: described } })])).toThrow(+ 'needs both a write entry and a describer',+ );+ expect(() => mergeDomains([domain('vacay', { set_vacay: { write } })])).toThrow('needs both');+ });++ it('ASTREG-004: a package comes once, with at most two prompt lines; its lines, groups and projections are gathered', () => {+ expect(() => mergeDomains([domain('atlas', {}), domain('atlas', {})])).toThrow('registered twice');+ expect(() => mergeDomains([domain('atlas', {}, { prompt: ['a', 'b', 'c'] })])).toThrow('more than 2 prompt lines');+ const merged = mergeDomains([+ domain(+ 'collection',+ { list_collection: { project: (value) => ({ kept: value }) } },+ {+ prompt: ['Collections are drawn as cards.'],+ foreignIdGroups: ['collections'],+ },+ ),+ domain('atlas', {}, { prompt: ['The atlas too.'], foreignIdGroups: ['atlas'] }),+ ]);+ expect(merged.promptLines).toEqual(['Collections are drawn as cards.', 'The atlas too.']);+ expect([...merged.foreignIdGroups]).toEqual(['collections', 'atlas']);+ expect(merged.projections.list_collection?.(3)).toEqual({ kept: 3 });+ });++ it("ASTREG-005: the core's describers, effects and projections refuse a package's entry for their tool", () => {+ const tools: Record<string, ToolCards> = { create_place: { effect: () => null } };+ expect(() => refuseCoreOverlap('effect', ['create_place'], tools)).toThrow('"effect" of "create_place"');+ expect(() => refuseCoreOverlap('describe', ['create_place'], tools)).not.toThrow();+ });++ it('ASTREG-006: the controllers and held reads of the packages are gathered, a controller only once', () => {+ const merged = mergeDomains([+ domain('roadtrip', {}, { toolControllers: { roadtrip: ['CorridorMcp'] }, heldReads: ['fetch_corridor'] }),+ domain('budget', {}, { toolControllers: { roadtrip: ['TollMcp'], files: ['ReceiptMcp'] } }),+ ]);+ expect(merged.toolControllers).toEqual({ roadtrip: ['CorridorMcp', 'TollMcp'], files: ['ReceiptMcp'] });+ expect([...merged.heldReads]).toEqual(['fetch_corridor']);+ expect(() =>+ mergeDomains([+ domain('roadtrip', {}, { toolControllers: { roadtrip: ['CorridorMcp'] } }),+ domain('budget', {}, { toolControllers: { files: ['CorridorMcp'] } }),+ ]),+ ).toThrow('controller "CorridorMcp" is listed twice');+ });++ it('ASTREG-007: a package adds controllers to a known tool group, never to a new one or twice', () => {+ const core = { roadtrip: { about: 'Road trips.', controllers: ['RoadtripMcp'] } };+ expect(withPackageControllers(core, { roadtrip: ['CorridorMcp'] }).roadtrip?.controllers).toEqual([+ 'RoadtripMcp',+ 'CorridorMcp',+ ]);+ expect(core.roadtrip.controllers).toEqual(['RoadtripMcp']);+ expect(() => withPackageControllers(core, { trains: ['RailMcp'] })).toThrow('no group "trains"');+ expect(() => withPackageControllers(core, { roadtrip: ['RoadtripMcp'] })).toThrow(+ '"RoadtripMcp" is listed already',+ );+ });+});++describe('the guarded card calls', () => {+ const answerInput = { toolCallId: 'c1', args: {}, value: {}, card, today: '2026-06-01' };++ it('ASTREG-010: a card that fits its kind comes through as the union reads it', () => {+ const calls = guardedCards(+ { find: { answer: () => ({ ...probe('Lake'), extra: 1 }) as unknown as TrekCard } },+ PROBE,+ );+ expect(calls.answerCardOf('find', answerInput)).toEqual({ kind: 'probe', title: 'Lake' });+ expect(calls.answerCardOf('other', answerInput)).toBeNull();+ expect(logMock.logWarn).not.toHaveBeenCalled();+ });++ it('ASTREG-011: a builder that throws, misbuilds or builds past the size cap gives null and a log line', () => {+ const calls = guardedCards(+ {+ thrown: {+ answer: () => {+ throw new Error('boom');+ },+ },+ misbuilt: { change: () => probe('A title far too long') },+ heavy: { applied: () => probe('x'.repeat(12)) },+ },+ { ...PROBE, maxChars: 30 },+ );+ expect(calls.answerCardOf('thrown', answerInput)).toBeNull();+ expect(calls.changeCardOf('misbuilt', ctx, {}, null)).toBeNull();+ expect(calls.appliedCardOf('heavy', { args: {}, result: {}, preview: null })).toBeNull();+ const lines = logMock.logWarn.mock.calls.map(([line]) => String(line));+ expect(lines[0]).toContain('the answer card of thrown failed: boom');+ expect(lines[1]).toContain('the change card of misbuilt does not fit its kind: title');+ expect(lines[2]).toContain('the applied card of heavy is too large');+ });++ it('ASTREG-012: the live calls check against the card union itself', () => {+ expect(answerCardOf('list_places', answerInput)).toBeNull();+ const unknown = guardedCards({ list_places: { answer: () => ({ kind: 'bookPage' }) as unknown as TrekCard } });+ expect(unknown.answerCardOf('list_places', answerInput)).toBeNull();+ expect(String(logMock.logWarn.mock.calls[0]?.[0])).toContain('does not fit its kind');+ });++ it('ASTREG-013: a package names no id and reads nothing for an undo unless it says so', () => {+ expect(nameArgOf('create_hike', 'placeId', 3, card)).toBeNull();+ expect(undoReadsOf('create_hike', {}, {})).toEqual([]);+ expect(undoReadsOf('no_such_tool', {}, {})).toEqual([]);+ });+});++describe('receiptCard', () => {+ it('ASTREG-020: streams and keeps the applied card under the write id, for the tool a found place runs as', () => {+ const w = { card: vi.fn() };+ const receipts: AssistantMessagePart[] = [];+ const build = vi.fn(() => probe('Lake'));+ const args = { via: 'create_and_assign_place', dayId: 3, name: 'Lake' };+ receiptCard(w, receipts, { id: 'w1', tool_name: 'add_found_place' }, args, { place: { id: 4 } }, null, build);+ expect(build).toHaveBeenCalledWith('create_and_assign_place', {+ args,+ result: { place: { id: 4 } },+ preview: null,+ });+ expect(w.card).toHaveBeenCalledWith({ toolCallId: 'w1', card: probe('Lake') });+ expect(receipts).toEqual([{ type: 'data-trek-card', data: { toolCallId: 'w1', card: probe('Lake') } }]);+ });++ it('ASTREG-021: adds nothing when the tool has no applied card', () => {+ const w = { card: vi.fn() };+ const receipts: AssistantMessagePart[] = [];+ receiptCard(w, receipts, { id: 'w1', tool_name: 'create_place' }, {}, {}, null);+ expect(w.card).not.toHaveBeenCalled();+ expect(receipts).toEqual([]);+ });+});diff --git a/server/tests/unit/nest/assistant/tool-call-preview.helpers.test.ts b/server/tests/unit/nest/assistant/tool-call-preview.helpers.test.tsindex fa14b0ecb..76754a47a 100644--- a/server/tests/unit/nest/assistant/tool-call-preview.helpers.test.ts+++ b/server/tests/unit/nest/assistant/tool-call-preview.helpers.test.ts@@ -3,19 +3,18 @@* locale, the value before a change, and the receipt of an applied change.*/import { buildTripCard } from '../../../../src/nest/assistant/assistant-context';-import { ASSISTANT_WRITE_TOOLS } from '../../../../src/nest/assistant/assistant-tools.constants';-import {- appliedChange,- dayLabel,- describeToolCall,- type PreviewContext,-} from '../../../../src/nest/assistant/tool-call-preview.helpers';-import { assistantChangePreviewSchema } from '@trek/shared';+import type { AssistantWriteTool } from '../../../../src/nest/assistant/assistant-tools.constants';+import type { PreviewContext, ToolCards } from '../../../../src/nest/assistant/cards/card-types';+import { dayLabel, Rows } from '../../../../src/nest/assistant/cards/preview-format';+import { ASSISTANT_WRITE_TOOLS, FOREIGN_ID_GROUPS, TOOL_CARDS } from '../../../../src/nest/assistant/cards/registry';+import { appliedChange, describeToolCall } from '../../../../src/nest/assistant/tool-call-preview.helpers';+import { assistantChangePreviewSchema, trekCardSchema, type TrekCard } from '@trek/shared';import { describe, expect, it } from 'vitest';const card = buildTripCard(1,+ 7,{trip: { title: 'Kyoto', currency: 'EUR' },members: { owner: { id: 7, username: 'mia' }, collaborators: [{ id: 8, username: 'jon' }] },@@ -56,6 +55,8 @@ const ctx: PreviewContext = {[3, 'Sights'],]),locale: 'en-GB',+ today: '2026-06-01',+ airport: () => null,};const describe_ = (name: string, args: Record<string, unknown>) => describeToolCall(name, 'tc-1', args, ctx);@@ -515,4 +516,105 @@ describe('the cards of tours', () => {ids: [],});});++ /**+ * Lends a tool package cards for one case, the way a package's index adds+ * them, and takes them back after it.+ */+ function withCards<T>(tool: string, cards: ToolCards, write: AssistantWriteTool | null, run: () => T): T {+ const tools = TOOL_CARDS as Record<string, ToolCards>;+ const writes = ASSISTANT_WRITE_TOOLS as Record<string, AssistantWriteTool>;+ const [before, writeBefore] = [tools[tool], writes[tool]];+ tools[tool] = { ...before, ...cards };+ if (write) writes[tool] = write;+ try {+ return run();+ } finally {+ if (before) tools[tool] = before;+ else Reflect.deleteProperty(tools, tool);+ if (writeBefore) writes[tool] = writeBefore;+ else Reflect.deleteProperty(writes, tool);+ }+ }++ it("ASTPRV-028: a package's describer speaks for its tool with its lookup, its overrides and its effect", () => {+ const cards: ToolCards<string> = {+ describe: (_ctx, args, loaded) => ({+ subject: `${String(args.name)} (${loaded ?? 'none'})`,+ rows: new Rows().add('day', 'Fri'),+ dayId: 32,+ placeIds: [],+ verbKey: 'genericUpdate',+ tool: 'plan_vacay_days',+ domain: 'vacay',+ }),+ effect: (_ctx, _args, loaded) =>+ loaded ? { kind: 'add', dayId: 32, fromDayId: null, placeId: 12, assignmentId: null, place: null } : null,+ };+ const preview = withCards('plan_vacay_days', cards, { verbKey: 'genericCreate', entity: 'other' }, () =>+ describeToolCall('plan_vacay_days', 'tc-30', { name: 'Summer' }, ctx, 'plan'),+ );+ expect(preview).toMatchObject({+ verbKey: 'genericUpdate',+ subject: 'Summer (plan)',+ tool: 'plan_vacay_days',+ domain: 'vacay',+ dayId: 32,+ undoable: false,+ effect: { kind: 'add', dayId: 32, placeId: 12 },+ });+ expect(assistantChangePreviewSchema.safeParse(preview).success).toBe(true);+ });++ it('ASTPRV-029: a change card rides on a curated and on a generic card; one its kind refuses stays out', () => {+ const built = { kind: 'tourRoute' } as TrekCard;+ const drawn = trekCardSchema.safeParse(built).success ? { card: built } : {};+ const curated = withCards('create_place', { change: () => built }, null, () =>+ describe_('create_place', { name: 'Kinkaku-ji' }),+ );+ expect(curated).toMatchObject({ verbKey: 'addPlace', subject: 'Kinkaku-ji', ...drawn });+ const generic = withCards('set_vacay_days', { change: () => built }, null, () =>+ describe_('set_vacay_days', { days: 3 }),+ );+ expect(generic).toMatchObject({ tool: 'set_vacay_days', ...drawn });+ const refused = withCards(+ 'set_vacay_days',+ { change: () => ({ kind: 'bookPage' }) as unknown as TrekCard },+ null,+ () => describe_('set_vacay_days', { days: 3 }),+ );+ expect(refused).not.toHaveProperty('card');+ expect(describe_('create_place', { name: 'Kinkaku-ji' })).not.toHaveProperty('card');+ });++ it("ASTPRV-030: a package's applied ids name the receipt before the answer's usual keys", () => {+ const applied = withCards('create_place', { appliedIds: (_args, result) => [Number(result)] }, null, () =>+ appliedChange('create_place', 'tc', {}, 77, null, null),+ );+ expect(applied).toMatchObject({ entity: 'place', ids: [77] });+ expect(appliedChange('create_place', 'tc', {}, { place: { id: 5 } }, null, null)).toMatchObject({ ids: [5] });+ });++ it('ASTPRV-031: a package names its ids first; a place id of a tool outside the trip is no trip place', () => {+ const groups = FOREIGN_ID_GROUPS as Set<string>;+ const saved = { ...ctx, hintOf: () => ({ destructive: false, creates: true, group: 'collections' }) };+ const add = () => describeToolCall('add_collection_place', 'tc-31', { placeId: 12 }, saved);+ // Place 12 is the trip's Nishiki Market until the collections say their ids are their own.+ expect(add()).toMatchObject({ subject: 'Nishiki Market', placeIds: [12], domain: 'collections' });+ groups.add('collections');+ try {+ const outside = add();+ expect(outside).toMatchObject({ subject: 'add collection place', placeIds: [] });+ expect(outside.rows).toEqual([{ op: 'add', labelKey: 'field', field: 'placeId', before: null, after: '12' }]);+ const named = withCards(+ 'add_collection_place',+ { nameArg: (key, value) => (key === 'placeId' ? `Saved place ${value}` : null) },+ null,+ add,+ );+ expect(named).toMatchObject({ subject: 'Saved place 12', rows: [], placeIds: [] });+ } finally {+ groups.delete('collections');+ }+ });});diff --git a/server/tests/unit/nest/assistant/ui-stream.writer.test.ts b/server/tests/unit/nest/assistant/ui-stream.writer.test.tsindex 4b7ef76bb..37b0b02de 100644--- a/server/tests/unit/nest/assistant/ui-stream.writer.test.ts+++ b/server/tests/unit/nest/assistant/ui-stream.writer.test.ts@@ -6,7 +6,7 @@*/import { UiStreamWriter } from '../../../../src/nest/assistant/ui-stream.writer';import type { SseStream } from '../../../../src/nest/common/sse-stream';-import { uiStreamChunkSchema, UI_STREAM_DONE } from '@trek/shared';+import { uiStreamChunkSchema, UI_STREAM_DONE, type TrekCard } from '@trek/shared';import { readFileSync } from 'node:fs';import { resolve } from 'node:path';@@ -16,6 +16,13 @@ const FIXTURE = readFileSync(resolve(__dirname, '../../../../../shared/src/assistant/__fixtures__/ui-stream.v1.txt'),'utf8',);+const CARDS_FIXTURE = readFileSync(+ resolve(__dirname, '../../../../../shared/src/assistant/__fixtures__/ui-stream.cards.v1.txt'),+ 'utf8',+);++/** A card as a package builds it; the writer passes it on as it is, whatever its fields. */+const cardOf = (kind: string) => ({ kind }) as TrekCard;function memoryStream(): SseStream & { text: () => string; ended: boolean } {let out = '';@@ -156,6 +163,7 @@ describe('UiStreamWriter', () => {{ dayId: 4, date: '2026-06-11', main: 'Drizzle', tempMax: 19, tempMin: null, rainPct: 80, kind: 'forecast' },],});+ w.card({ toolCallId: 'call_2', card: cardOf('tourList') });const chunks = stream.text().split('\n\n')@@ -168,7 +176,45 @@ describe('UiStreamWriter', () => {'data-trek-activity','data-trek-places','data-trek-weather',+ 'data-trek-card',]);expect(chunks[3]).toMatchObject({ transient: true, data: { label: 'Trastevere' } });+ expect(chunks[6]).toMatchObject({ data: { toolCallId: 'call_2' } });+ expect(chunks[6]).not.toHaveProperty('transient');+ });++ it('ASTWRT-006: writes the shared cards fixture byte for byte: a receipt card, a read card, a held change card', () => {+ const applied = '7c1e2d3a-0b4f-4e8a-9d6c-1f2e3a4b5c6d';+ const held = '9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d';+ const stream = memoryStream();+ const w = new UiStreamWriter(stream);+ w.start('msg-12');+ w.toolOutput(applied, { tour: { place_id: 77, name: 'Ridge walk' } });+ w.applied({ toolCallId: applied, entity: 'tour', ids: [77], dayId: 32, undoUntil: '2026-06-11T09:15:00Z' });+ w.card({ toolCallId: applied, card: cardOf('tourRoute') });+ w.startStep();+ w.toolInput('toolu_02', 'list_tours', {});+ w.toolOutput('toolu_02', { tours: [{ place_id: 77, name: 'Ridge walk' }] });+ w.card({ toolCallId: 'toolu_02', card: cardOf('tourList') });+ w.finishStep();+ w.startStep();+ w.text('The ridge walk is on Friday now. ');+ w.text('A lake loop would fit on Saturday.');+ w.toolInput(held, 'create_hike', { name: 'Lake loop', round_trip: true });+ w.approvalRequest(held);+ w.change({+ toolCallId: held,+ verbKey: 'addTour',+ subject: 'Lake loop',+ rows: [{ op: 'add', labelKey: 'route', before: null, after: 'Car park → Lake → Car park' }],+ dayId: null,+ placeIds: [],+ undoable: true,+ card: cardOf('tourRoute'),+ });+ w.quota(4, 50);+ w.finish('tool-calls');+ w.close();+ expect(stream.text()).toBe(CARDS_FIXTURE);});});diff --git a/server/tests/unit/nest/dawarich-atlas.mcp.test.ts b/server/tests/unit/nest/dawarich-atlas.mcp.test.tsindex 466f3dab3..c5177c503 100644--- a/server/tests/unit/nest/dawarich-atlas.mcp.test.ts+++ b/server/tests/unit/nest/dawarich-atlas.mcp.test.ts@@ -17,7 +17,7 @@ import { trekMcpErrorMapper } from '../../../src/mcp/nest-mcp-policy';import { errorResult, type McpContext, type McpTextResult, type ToolOptions } from '../../../src/nest-mcp';import { getEntry, type ClassRef } from '../../../src/nest-mcp/metadata';import { AddonsService } from '../../../src/nest/addons/addons.service';-import { toolOutputForProvider } from '../../../src/nest/assistant/assistant-redact';+import { toolOutputForProvider } from '../../../src/nest/assistant/assistant-output';import { DomainError } from '../../../src/nest/common/domain-error';import { DawarichAtlasMcp } from '../../../src/nest/integrations/dawarich-atlas.mcp';import { DawarichSuggestionsService } from '../../../src/nest/integrations/dawarich-suggestions.service';diff --git a/server/tests/unit/nest/journey-tracks.mcp.test.ts b/server/tests/unit/nest/journey-tracks.mcp.test.tsindex a541fc3bd..e85c4fbfd 100644--- a/server/tests/unit/nest/journey-tracks.mcp.test.ts+++ b/server/tests/unit/nest/journey-tracks.mcp.test.ts@@ -12,7 +12,7 @@ import type { McpContext } from '../../../src/nest-mcp';import { getEntry, type ClassRef } from '../../../src/nest-mcp/metadata';import { AddonsModule } from '../../../src/nest/addons/addons.module';import { AddonsService } from '../../../src/nest/addons/addons.service';-import { toolOutputForProvider } from '../../../src/nest/assistant/assistant-redact';+import { toolOutputForProvider } from '../../../src/nest/assistant/assistant-output';import { JourneyDomainModule } from '../../../src/nest/journey/journey-domain.module';import { JourneyDomainService } from '../../../src/nest/journey/journey-domain.service';import { JourneyTracksMcp } from '../../../src/nest/journey/journey-tracks.mcp';diff --git a/server/tests/unit/utils/json-column.test.ts b/server/tests/unit/utils/json-column.test.tsindex be83459a1..6ca2dcd98 100644--- a/server/tests/unit/utils/json-column.test.ts+++ b/server/tests/unit/utils/json-column.test.ts@@ -1,4 +1,8 @@import {+ ASSISTANT_MESSAGE_PARTS,+ ASSISTANT_MESSAGE_PARTS_WRITE,+ ASSISTANT_TOOL_PREVIEW,+ ASSISTANT_TOOL_PREVIEW_WRITE,COLLAB_POLL_OPTIONS,JOURNEY_ENTRY_PROS_CONS,JOURNEY_ENTRY_TAGS,@@ -156,4 +160,48 @@ describe('the declared columns', () => {expect(decodeJson(TOUR_CHANGE_STEP_BEFORE, '{"waypoints":"none"}')).toBeNull();expect(decodeJson(TOUR_CHANGE_STEP_BEFORE, '{bad')).toBeNull();});++ it('JSONCOL-035: an assistant message drops a data part or card a later build wrote, never the message', () => {+ const text = { type: 'text', text: 'Here is the walk.' };+ const stored = JSON.stringify([+ text,+ { type: 'data-trek-book-page', data: { page: 3 } },+ { type: 'data-trek-card', data: { toolCallId: 'c1', card: { kind: 'bookPage' } } },+ ]);+ expect(decodeJson(ASSISTANT_MESSAGE_PARTS, stored)).toEqual([+ text,+ { type: 'data-trek-card', data: { toolCallId: 'c1', card: null } },+ ]);+ expect(logMock.logWarn).not.toHaveBeenCalled();+ expect(decodeJson(ASSISTANT_MESSAGE_PARTS, '[{"type":"text","text":5}]', 'message 9')).toEqual([]);+ expect(logMock.logWarn).toHaveBeenCalledTimes(1);+ });++ it('JSONCOL-036: an assistant message is written strictly: a part this build cannot describe is refused', () => {+ const parts = [{ type: 'data-trek-card' as const, data: { toolCallId: 'c1', card: null } }];+ expect(JSON.parse(encodeJson(ASSISTANT_MESSAGE_PARTS_WRITE, parts))).toEqual(parts);+ const unknown = [{ type: 'data-trek-book-page', data: {} }] as unknown as typeof parts;+ expect(() => encodeJson(ASSISTANT_MESSAGE_PARTS_WRITE, unknown)).toThrow();+ const misbuilt = [{ type: 'data-trek-card', data: { toolCallId: 'c1', card: { kind: 'bookPage' } } }];+ expect(() => encodeJson(ASSISTANT_MESSAGE_PARTS_WRITE, misbuilt as unknown as typeof parts)).toThrow();+ expect(ASSISTANT_MESSAGE_PARTS_WRITE.column).toBe(ASSISTANT_MESSAGE_PARTS.column);+ });++ it('JSONCOL-037: a stored change card reads a later verb as a plain update, and is written strictly', () => {+ const preview = {+ toolCallId: 'c1',+ verbKey: 'addPlace' as const,+ subject: 'Lake',+ rows: [],+ dayId: null,+ placeIds: [],+ undoable: false,+ };+ const later = JSON.stringify({ ...preview, verbKey: 'laterVerb' });+ expect(decodeJson(ASSISTANT_TOOL_PREVIEW, later)).toEqual({ ...preview, verbKey: 'genericUpdate' });+ expect(JSON.parse(encodeJson(ASSISTANT_TOOL_PREVIEW_WRITE, preview))).toEqual(preview);+ const misbuilt = { ...preview, verbKey: 'laterVerb' } as unknown as typeof preview;+ expect(() => encodeJson(ASSISTANT_TOOL_PREVIEW_WRITE, misbuilt)).toThrow();+ expect(ASSISTANT_TOOL_PREVIEW_WRITE.column).toBe(ASSISTANT_TOOL_PREVIEW.column);+ });});diff --git a/shared/src/assistant/__fixtures__/ui-stream.cards.v1.txt b/shared/src/assistant/__fixtures__/ui-stream.cards.v1.txtnew file mode 100644index 000000000..3652f077f--- /dev/null+++ b/shared/src/assistant/__fixtures__/ui-stream.cards.v1.txt@@ -0,0 +1,44 @@+data: {"type":"start","messageId":"msg-12"}++data: {"type":"tool-output-available","toolCallId":"7c1e2d3a-0b4f-4e8a-9d6c-1f2e3a4b5c6d","output":{"tour":{"place_id":77,"name":"Ridge walk"}}}++data: {"type":"data-trek-applied","data":{"toolCallId":"7c1e2d3a-0b4f-4e8a-9d6c-1f2e3a4b5c6d","entity":"tour","ids":[77],"dayId":32,"undoUntil":"2026-06-11T09:15:00Z"}}++data: {"type":"data-trek-card","data":{"toolCallId":"7c1e2d3a-0b4f-4e8a-9d6c-1f2e3a4b5c6d","card":{"kind":"tourRoute"}}}++data: {"type":"start-step"}++data: {"type":"tool-input-start","toolCallId":"toolu_02","toolName":"list_tours"}++data: {"type":"tool-input-available","toolCallId":"toolu_02","toolName":"list_tours","input":{}}++data: {"type":"tool-output-available","toolCallId":"toolu_02","output":{"tours":[{"place_id":77,"name":"Ridge walk"}]}}++data: {"type":"data-trek-card","data":{"toolCallId":"toolu_02","card":{"kind":"tourList"}}}++data: {"type":"finish-step"}++data: {"type":"start-step"}++data: {"type":"text-start","id":"txt-0"}++data: {"type":"text-delta","id":"txt-0","delta":"The ridge walk is on Friday now. "}++data: {"type":"text-delta","id":"txt-0","delta":"A lake loop would fit on Saturday."}++data: {"type":"text-end","id":"txt-0"}++data: {"type":"tool-input-start","toolCallId":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d","toolName":"create_hike"}++data: {"type":"tool-input-available","toolCallId":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d","toolName":"create_hike","input":{"name":"Lake loop","round_trip":true}}++data: {"type":"tool-approval-request","approvalId":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d","toolCallId":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"}++data: {"type":"data-trek-change","data":{"toolCallId":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d","verbKey":"addTour","subject":"Lake loop","rows":[{"op":"add","labelKey":"route","before":null,"after":"Car park → Lake → Car park"}],"dayId":null,"placeIds":[],"undoable":true,"card":{"kind":"tourRoute"}}}++data: {"type":"data-trek-quota","data":{"used":4,"limit":50}}++data: {"type":"finish","finishReason":"tool-calls"}++data: [DONE]+diff --git a/shared/src/assistant/assistant.schema.spec.ts b/shared/src/assistant/assistant.schema.spec.tsindex 616030d1d..3f67e5fa1 100644--- a/shared/src/assistant/assistant.schema.spec.ts+++ b/shared/src/assistant/assistant.schema.spec.ts@@ -5,6 +5,7 @@ import {assistantAddFoundPlaceResponseSchema,assistantAttachmentRequestSchema,assistantChangePreviewSchema,+ assistantChangePreviewWriteSchema,assistantChatRequestSchema,assistantDecisionsRequestSchema,assistantFoundPlaceSchema,@@ -122,7 +123,13 @@ describe('assistantChangePreviewSchema', () => {expect(assistantChangePreviewSchema.safeParse({ ...preview, rows: [{ ...preview.rows[0], labelKey: 'evil' }] }).success,).toBe(false);- expect(assistantChangePreviewSchema.safeParse({ ...preview, verbKey: 'deleteTrip' }).success).toBe(false);+ expect(assistantChangePreviewWriteSchema.safeParse({ ...preview, verbKey: 'deleteTrip' }).success).toBe(false);+ });++ it('reads a verb a later build added as a plain update, and writes none it does not know', () => {+ expect(assistantChangePreviewSchema.parse({ ...preview, verbKey: 'laterVerb' }).verbKey).toBe('genericUpdate');+ expect(assistantChangePreviewWriteSchema.parse(preview).verbKey).toBe('addPlace');+ expect(assistantChangePreviewWriteSchema.safeParse({ ...preview, card: { kind: 'nope' } }).success).toBe(false);});it('holds at most twelve rows', () => {diff --git a/shared/src/assistant/assistant.schema.ts b/shared/src/assistant/assistant.schema.tsindex 6e7e9292b..8a98bdd1d 100644--- a/shared/src/assistant/assistant.schema.ts+++ b/shared/src/assistant/assistant.schema.ts@@ -1,4 +1,31 @@import { idParamSchema, idSchema } from '../common/primitives.schema';+import {+ assistantCardSchema,+ assistantCardWriteSchema,+ ATLAS_APPLIED_ENTITIES,+ ATLAS_VERB_KEYS,+ BOOKING_APPLIED_ENTITIES,+ BOOKING_VERB_KEYS,+ BUDGET_APPLIED_ENTITIES,+ BUDGET_VERB_KEYS,+ COLLAB_APPLIED_ENTITIES,+ COLLAB_VERB_KEYS,+ COLLECTION_APPLIED_ENTITIES,+ COLLECTION_VERB_KEYS,+ JOURNEY_APPLIED_ENTITIES,+ JOURNEY_VERB_KEYS,+ PACKING_APPLIED_ENTITIES,+ PACKING_VERB_KEYS,+ ROADTRIP_APPLIED_ENTITIES,+ ROADTRIP_VERB_KEYS,+ storedTrekCardSchema,+ TOUR_APPLIED_ENTITIES,+ TOUR_VERB_KEYS,+ trekCardSchema,+ VACAY_APPLIED_ENTITIES,+ VACAY_VERB_KEYS,+ type AssistantCard,+} from './cards';import { z } from 'zod';@@ -48,9 +75,10 @@ export type AssistantErrorCode = z.infer<typeof assistantErrorCodeSchema>;/*** What a change does, one per writing tool. The client labels the card with- * `assistant.change.verb.<key>`.+ * `assistant.change.verb.<key>`. These are the core verbs; each part of TREK+ * adds its own in its cards contract (`cards/<pkg>.contract.ts`).*/-export const ASSISTANT_CHANGE_VERB_KEYS = [+export const CORE_VERB_KEYS = ['addPlace','addPlaceToDay','updatePlace',@@ -76,6 +104,19 @@ export const ASSISTANT_CHANGE_VERB_KEYS = ['genericUpdate','genericRemove',] as const;+export const ASSISTANT_CHANGE_VERB_KEYS = [+ ...CORE_VERB_KEYS,+ ...TOUR_VERB_KEYS,+ ...ROADTRIP_VERB_KEYS,+ ...BUDGET_VERB_KEYS,+ ...BOOKING_VERB_KEYS,+ ...COLLAB_VERB_KEYS,+ ...COLLECTION_VERB_KEYS,+ ...ATLAS_VERB_KEYS,+ ...VACAY_VERB_KEYS,+ ...JOURNEY_VERB_KEYS,+ ...PACKING_VERB_KEYS,+] as const;export const assistantChangeVerbKeySchema = z.enum(ASSISTANT_CHANGE_VERB_KEYS);export type AssistantChangeVerbKey = z.infer<typeof assistantChangeVerbKeySchema>;@@ -233,6 +274,19 @@ export const assistantAddFoundPlaceRequestSchema = assistantClientCtxSchema.strict();export type AssistantAddFoundPlaceRequest = z.infer<typeof assistantAddFoundPlaceRequestSchema>;+/**+ * POST /threads/:threadId/proposals: take a proposal an answer showed as a+ * card ("Plan this"). `toolCallId` names the read whose card it was; the+ * server holds the matching change like a found place, from what it stored,+ * and answers like the found places route.+ */+export const assistantTakeProposalRequestSchema = assistantClientCtxSchema+ .extend({+ toolCallId: z.string().min(1).max(64),+ })+ .strict();+export type AssistantTakeProposalRequest = z.infer<typeof assistantTakeProposalRequestSchema>;+// ── Change previews ─────────────────────────────────────────────────────────/**@@ -269,8 +323,8 @@ export const assistantChangeRowSchema = z.object({});export type AssistantChangeRow = z.infer<typeof assistantChangeRowSchema>;-/** A held writing call as the user sees it before deciding. */-export const assistantChangePreviewSchema = z.object({+/** A held writing call as the server writes it: every verb and card one this build knows. */+export const assistantChangePreviewWriteSchema = z.object({toolCallId: z.string(),verbKey: assistantChangeVerbKeySchema,// What the change is about: the place, note or item name.@@ -286,28 +340,63 @@ export const assistantChangePreviewSchema = z.object({// The tool behind a card without one of its own, and the part of TREK it works in.tool: z.string().max(80).optional(),domain: z.string().max(40).optional(),+ // What the change will do, drawn as a card; absent on older rows and on cards without one.+ card: trekCardSchema.nullable().optional(),+});++/**+ * A held writing call as the user sees it before deciding, and as it is read+ * back: a verb a later build added reads as a plain update and a card this+ * build cannot draw as none, so an older client or a rolled back server still+ * shows the change instead of dropping it.+ */+export const assistantChangePreviewSchema = assistantChangePreviewWriteSchema.extend({+ verbKey: assistantChangeVerbKeySchema.catch('genericUpdate'),+ card: storedTrekCardSchema.optional(),});export type AssistantChangePreview = z.infer<typeof assistantChangePreviewSchema>;-/** An applied change: what it touched, and until when it can be undone. */-export const assistantAppliedSchema = z.object({+/** What an applied change can touch in the core; each part of TREK adds its own in its cards contract. */+export const CORE_APPLIED_ENTITIES = [+ 'place',+ 'assignment',+ 'day_note',+ 'packing',+ 'todo',+ 'budget',+ 'reservation',+ 'memory',+ 'tour',+ 'other',+] as const;++const assistantAppliedEntitySchema = z.enum([+ ...CORE_APPLIED_ENTITIES,+ ...TOUR_APPLIED_ENTITIES,+ ...ROADTRIP_APPLIED_ENTITIES,+ ...BUDGET_APPLIED_ENTITIES,+ ...BOOKING_APPLIED_ENTITIES,+ ...COLLAB_APPLIED_ENTITIES,+ ...COLLECTION_APPLIED_ENTITIES,+ ...ATLAS_APPLIED_ENTITIES,+ ...VACAY_APPLIED_ENTITIES,+ ...JOURNEY_APPLIED_ENTITIES,+ ...PACKING_APPLIED_ENTITIES,+]);++/** An applied change as the server writes it: what it touched, and until when it can be undone. */+const assistantAppliedWriteSchema = z.object({toolCallId: z.string(),- entity: z.enum([- 'place',- 'assignment',- 'day_note',- 'packing',- 'todo',- 'budget',- 'reservation',- 'memory',- 'tour',- 'other',- ]),+ entity: assistantAppliedEntitySchema,ids: z.array(idSchema),dayId: idSchema.nullable(),undoUntil: z.string().nullable(),});++/** An applied change as it is read back: an entity a later build added reads as `other`, with nothing to open. */+export const assistantAppliedSchema = assistantAppliedWriteSchema.extend({+ entity: assistantAppliedEntitySchema.catch('other'),+});export type AssistantApplied = z.infer<typeof assistantAppliedSchema>;// ── Cards in an answer ──────────────────────────────────────────────────────@@ -453,34 +542,73 @@ export const assistantToolApprovalSchema = z.object({});export type AssistantToolApproval = z.infer<typeof assistantToolApprovalSchema>;-/** One stored part of a message, in the order the model produced it. */-export const assistantMessagePartSchema = z.discriminatedUnion('type', [- z.object({ type: z.literal('text'), text: z.string() }),- // A file the user handed the assistant. Only its description is kept, never its content.- z.object({- type: z.literal('attachment'),- name: z.string(),- mime: z.string(),- size: z.number().int().nonnegative(),- }),- z.object({- type: z.literal('tool-call'),- toolCallId: z.string(),- toolName: z.string(),- args: z.record(z.string(), z.unknown()),- result: z.unknown().optional(),- isError: z.boolean().optional(),- approval: assistantToolApprovalSchema.optional(),- }),- z.object({ type: z.literal('data-trek-change'), data: assistantChangePreviewSchema }),- z.object({ type: z.literal('data-trek-applied'), data: assistantAppliedSchema }),- z.object({ type: z.literal('data-trek-places'), data: assistantPlacesSchema }),- z.object({ type: z.literal('data-trek-weather'), data: assistantWeatherSchema }),- // Only on a user message.- z.object({ type: z.literal('data-trek-mentions'), data: assistantMentionsSchema }),-]);+/** The parts of a message, with the change, receipt and card parts read or written as given. */+function messagePartSchema(+ change: z.ZodType<AssistantChangePreview>,+ applied: z.ZodType<AssistantApplied>,+ card: z.ZodType<AssistantCard>,+) {+ return z.discriminatedUnion('type', [+ z.object({ type: z.literal('text'), text: z.string() }),+ // A file the user handed the assistant. Only its description is kept, never its content.+ z.object({+ type: z.literal('attachment'),+ name: z.string(),+ mime: z.string(),+ size: z.number().int().nonnegative(),+ }),+ z.object({+ type: z.literal('tool-call'),+ toolCallId: z.string(),+ toolName: z.string(),+ args: z.record(z.string(), z.unknown()),+ result: z.unknown().optional(),+ isError: z.boolean().optional(),+ approval: assistantToolApprovalSchema.optional(),+ }),+ z.object({ type: z.literal('data-trek-change'), data: change }),+ z.object({ type: z.literal('data-trek-applied'), data: applied }),+ z.object({ type: z.literal('data-trek-places'), data: assistantPlacesSchema }),+ z.object({ type: z.literal('data-trek-weather'), data: assistantWeatherSchema }),+ // The card of one tool call: a read's beside the answer, an applied write's on the message that proposed it.+ z.object({ type: z.literal('data-trek-card'), data: card }),+ // Only on a user message.+ z.object({ type: z.literal('data-trek-mentions'), data: assistantMentionsSchema }),+ ]);+}++/** One stored part of a message, in the order the model produced it, as a reader takes it. */+export const assistantMessagePartSchema = messagePartSchema(+ assistantChangePreviewSchema,+ assistantAppliedSchema,+ assistantCardSchema,+);export type AssistantMessagePart = z.infer<typeof assistantMessagePartSchema>;+/** The parts as the server writes them: a verb, entity or card this build cannot name is a bug in the writer. */+export const assistantMessagePartWriteSchema = messagePartSchema(+ assistantChangePreviewWriteSchema,+ assistantAppliedWriteSchema,+ assistantCardWriteSchema,+);++/**+ * A message's parts as they are read back: a `data-trek-*` part this build+ * does not know, or one that no longer reads, is dropped, so a part a later+ * build added never blanks the message around it. Any other broken part+ * still fails the whole list. A known part reads through its tolerant fields+ * (a later verb, entity or card kind); parts are written strictly, with+ * `assistantMessagePartWriteSchema`.+ */+export const assistantStoredPartsSchema = z+ .array(+ z.union([+ assistantMessagePartSchema,+ z.object({ type: z.string().startsWith('data-trek-') }).transform(() => null),+ ]),+ )+ .transform((parts) => parts.filter((part): part is AssistantMessagePart => part !== null));+export const assistantMessageSchema = z.object({id: z.string(),role: z.enum(['user', 'assistant']),@@ -539,6 +667,7 @@ export const uiStreamChunkSchema = z.discriminatedUnion('type', [z.object({ type: z.literal('data-trek-applied'), data: assistantAppliedSchema }),z.object({ type: z.literal('data-trek-places'), data: assistantPlacesSchema }),z.object({ type: z.literal('data-trek-weather'), data: assistantWeatherSchema }),+ z.object({ type: z.literal('data-trek-card'), data: assistantCardSchema }),// Live progress of a running step; the message never keeps it.z.object({type: z.literal('data-trek-activity'),diff --git a/shared/src/assistant/cards/atlas-bucket.card.ts b/shared/src/assistant/cards/atlas-bucket.card.tsnew file mode 100644index 000000000..f95487a3b--- /dev/null+++ b/shared/src/assistant/cards/atlas-bucket.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** Entries of the bucket list. Only its kind so far; the atlas cards give it its fields. */+export const atlasBucketCardSchema = z.object({ kind: z.literal('atlasBucket') });+export type AtlasBucketCard = z.infer<typeof atlasBucketCardSchema>;diff --git a/shared/src/assistant/cards/atlas-country.card.ts b/shared/src/assistant/cards/atlas-country.card.tsnew file mode 100644index 000000000..048bd97a7--- /dev/null+++ b/shared/src/assistant/cards/atlas-country.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** One country of the atlas. Only its kind so far; the atlas cards give it its fields. */+export const atlasCountryCardSchema = z.object({ kind: z.literal('atlasCountry') });+export type AtlasCountryCard = z.infer<typeof atlasCountryCardSchema>;diff --git a/shared/src/assistant/cards/atlas-passport.card.ts b/shared/src/assistant/cards/atlas-passport.card.tsnew file mode 100644index 000000000..9ad77750a--- /dev/null+++ b/shared/src/assistant/cards/atlas-passport.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * The countries and regions a user has been to. Only its kind so far; the atlas cards give it its+ * fields.+ */+export const atlasPassportCardSchema = z.object({ kind: z.literal('atlasPassport') });+export type AtlasPassportCard = z.infer<typeof atlasPassportCardSchema>;diff --git a/shared/src/assistant/cards/atlas.contract.ts b/shared/src/assistant/cards/atlas.contract.tsnew file mode 100644index 000000000..3ac0678ba--- /dev/null+++ b/shared/src/assistant/cards/atlas.contract.ts@@ -0,0 +1,18 @@+import { atlasBucketCardSchema } from './atlas-bucket.card';+import { atlasCountryCardSchema } from './atlas-country.card';+import { atlasPassportCardSchema } from './atlas-passport.card';++export * from './atlas-bucket.card';+export * from './atlas-country.card';+export * from './atlas-passport.card';++/**+ * What the atlas brings to the assistant chat: the kinds of card it draws,+ * the verbs of its change cards and what an applied change of its+ * touches, beyond the core ones. cards/index.ts and assistant.schema.ts+ * spread these into the card union and the shared enums, so a new kind, verb+ * or entity is added here and nowhere else.+ */+export const ATLAS_CARD_SCHEMAS = [atlasPassportCardSchema, atlasCountryCardSchema, atlasBucketCardSchema] as const;+export const ATLAS_VERB_KEYS = [] as const;+export const ATLAS_APPLIED_ENTITIES = [] as const;diff --git a/shared/src/assistant/cards/booking.card.ts b/shared/src/assistant/cards/booking.card.tsnew file mode 100644index 000000000..1e7bdd919--- /dev/null+++ b/shared/src/assistant/cards/booking.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * Bookings: flights, trains, stays and other reservations. Only its kind so far; the booking cards+ * give it its fields.+ */+export const bookingCardSchema = z.object({ kind: z.literal('booking') });+export type BookingCard = z.infer<typeof bookingCardSchema>;diff --git a/shared/src/assistant/cards/booking.contract.ts b/shared/src/assistant/cards/booking.contract.tsnew file mode 100644index 000000000..2c0ceb3ca--- /dev/null+++ b/shared/src/assistant/cards/booking.contract.ts@@ -0,0 +1,14 @@+import { bookingCardSchema } from './booking.card';++export * from './booking.card';++/**+ * What the bookings bring to the assistant chat: the kinds of card they draw,+ * the verbs of their change cards and what an applied change of theirs+ * touches, beyond the core ones. cards/index.ts and assistant.schema.ts+ * spread these into the card union and the shared enums, so a new kind, verb+ * or entity is added here and nowhere else.+ */+export const BOOKING_CARD_SCHEMAS = [bookingCardSchema] as const;+export const BOOKING_VERB_KEYS = [] as const;+export const BOOKING_APPLIED_ENTITIES = [] as const;diff --git a/shared/src/assistant/cards/budget.contract.ts b/shared/src/assistant/cards/budget.contract.tsnew file mode 100644index 000000000..0b80379e5--- /dev/null+++ b/shared/src/assistant/cards/budget.contract.ts@@ -0,0 +1,25 @@+import { costPerPersonCardSchema } from './cost-per-person.card';+import { expensesCardSchema } from './expenses.card';+import { paymentsCardSchema } from './payments.card';+import { settlementCardSchema } from './settlement.card';++export * from './cost-per-person.card';+export * from './expenses.card';+export * from './payments.card';+export * from './settlement.card';++/**+ * What the budget brings to the assistant chat: the kinds of card it draws,+ * the verbs of its change cards and what an applied change of its+ * touches, beyond the core ones. cards/index.ts and assistant.schema.ts+ * spread these into the card union and the shared enums, so a new kind, verb+ * or entity is added here and nowhere else.+ */+export const BUDGET_CARD_SCHEMAS = [+ expensesCardSchema,+ paymentsCardSchema,+ settlementCardSchema,+ costPerPersonCardSchema,+] as const;+export const BUDGET_VERB_KEYS = [] as const;+export const BUDGET_APPLIED_ENTITIES = [] as const;diff --git a/shared/src/assistant/cards/card-parts.ts b/shared/src/assistant/cards/card-parts.tsnew file mode 100644index 000000000..e701eeba6--- /dev/null+++ b/shared/src/assistant/cards/card-parts.ts@@ -0,0 +1,58 @@+import { idSchema } from '../../common/primitives.schema';++import { z } from 'zod';++/**+ * The pieces every card of the assistant chat is built from. A kind uses+ * these, `idSchema` and its domain's own enums, nothing else, so every card+ * bounds its text the same way and none of them carries a URL or a path: a+ * picture travels as a key the client turns into TREK's own address.+ */++/** One line of text, clipped and masked by the server before it is sent. */+export const cardText = (max: number) => z.string().min(1).max(max);++export const cardLatSchema = z.number().min(-90).max(90);+export const cardLngSchema = z.number().min(-180).max(180);++/** A point of a line to draw, `[lat, lng]` at five decimals; single points are `{ lat, lng }` objects. */+export const cardPointSchema = z.tuple([cardLatSchema, cardLngSchema]);++export const cardDateSchema = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);+export const cardClockSchema = z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/);+export const cardInstantSchema = z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/);++/** A colour the data carries (a member's, a category's); the client draws it through safeHexColor. */+export const cardHexColorSchema = z.string().regex(/^#[0-9a-fA-F]{6}$/);++export const cardCurrencySchema = z.string().regex(/^[A-Z]{3}$/);+export const cardMoneySchema = z.object({ amount: z.number().min(-1e9).max(1e9), currency: cardCurrencySchema });+export const cardCountSchema = z.number().int().min(0).max(1_000_000);++/** A stored file name (an avatar, a place image): the client builds TREK's own path. Never a URL, never a path. */+export const cardFileKeySchema = z.string().regex(/^(?!.*\.\.)[A-Za-z0-9][\w.-]{0,199}$/);++/** A Google place id for TREK's photo proxy, like a found place's photo key without `coords:`. */+export const cardPhotoKeySchema = z.string().regex(/^[\w-]{1,200}$/);++/** A traveller as a card shows them: the client compares `id` with the signed-in user, so no card says "me". */+export const cardPersonSchema = z.object({+ id: idSchema,+ name: cardText(80),+ avatarKey: cardFileKeySchema.nullable(),+});++/** A trip day: its id for links, its number or date for words. */+export const cardDaySchema = z.object({+ id: idSchema.nullable(),+ number: z.number().int().min(1).max(999).nullable(),+ date: cardDateSchema.nullable(),+});++/** The most one card may weigh, as JSON text; a heavier one is not sent at all. */+export const MAX_CARD_CHARS = 24_000;++export type CardPoint = z.infer<typeof cardPointSchema>;+export type CardMoney = z.infer<typeof cardMoneySchema>;+export type CardPerson = z.infer<typeof cardPersonSchema>;+export type CardDay = z.infer<typeof cardDaySchema>;diff --git a/shared/src/assistant/cards/charging.card.ts b/shared/src/assistant/cards/charging.card.tsnew file mode 100644index 000000000..4af3f9ad3--- /dev/null+++ b/shared/src/assistant/cards/charging.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * Charging stops for an electric car along a drive. Only its kind so far; the road trip cards give it+ * its fields.+ */+export const chargingCardSchema = z.object({ kind: z.literal('charging') });+export type ChargingCard = z.infer<typeof chargingCardSchema>;diff --git a/shared/src/assistant/cards/collab-chat.card.ts b/shared/src/assistant/cards/collab-chat.card.tsnew file mode 100644index 000000000..daf38a90d--- /dev/null+++ b/shared/src/assistant/cards/collab-chat.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * Messages of the trip chat, as the chat shows them. Only its kind so far; the trip chat cards give it+ * its fields.+ */+export const collabChatCardSchema = z.object({ kind: z.literal('collabChat') });+export type CollabChatCard = z.infer<typeof collabChatCardSchema>;diff --git a/shared/src/assistant/cards/collab-notes.card.ts b/shared/src/assistant/cards/collab-notes.card.tsnew file mode 100644index 000000000..f593fea70--- /dev/null+++ b/shared/src/assistant/cards/collab-notes.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** Shared notes of the trip. Only its kind so far; the trip chat cards give it its fields. */+export const collabNotesCardSchema = z.object({ kind: z.literal('collabNotes') });+export type CollabNotesCard = z.infer<typeof collabNotesCardSchema>;diff --git a/shared/src/assistant/cards/collab-polls.card.ts b/shared/src/assistant/cards/collab-polls.card.tsnew file mode 100644index 000000000..d8789012b--- /dev/null+++ b/shared/src/assistant/cards/collab-polls.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * Polls of the trip chat with their options. Only its kind so far; the trip chat cards give it its+ * fields.+ */+export const collabPollsCardSchema = z.object({ kind: z.literal('collabPolls') });+export type CollabPollsCard = z.infer<typeof collabPollsCardSchema>;diff --git a/shared/src/assistant/cards/collab.contract.ts b/shared/src/assistant/cards/collab.contract.tsnew file mode 100644index 000000000..f16111156--- /dev/null+++ b/shared/src/assistant/cards/collab.contract.ts@@ -0,0 +1,18 @@+import { collabChatCardSchema } from './collab-chat.card';+import { collabNotesCardSchema } from './collab-notes.card';+import { collabPollsCardSchema } from './collab-polls.card';++export * from './collab-chat.card';+export * from './collab-notes.card';+export * from './collab-polls.card';++/**+ * What the trip chat brings to the assistant chat: the kinds of card it draws,+ * the verbs of its change cards and what an applied change of its+ * touches, beyond the core ones. cards/index.ts and assistant.schema.ts+ * spread these into the card union and the shared enums, so a new kind, verb+ * or entity is added here and nowhere else.+ */+export const COLLAB_CARD_SCHEMAS = [collabChatCardSchema, collabPollsCardSchema, collabNotesCardSchema] as const;+export const COLLAB_VERB_KEYS = [] as const;+export const COLLAB_APPLIED_ENTITIES = [] as const;diff --git a/shared/src/assistant/cards/collection-lists.card.ts b/shared/src/assistant/cards/collection-lists.card.tsnew file mode 100644index 000000000..8a376636d--- /dev/null+++ b/shared/src/assistant/cards/collection-lists.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** The collections a user keeps. Only its kind so far; the collections cards give it its fields. */+export const collectionListsCardSchema = z.object({ kind: z.literal('collectionLists') });+export type CollectionListsCard = z.infer<typeof collectionListsCardSchema>;diff --git a/shared/src/assistant/cards/collection-places.card.ts b/shared/src/assistant/cards/collection-places.card.tsnew file mode 100644index 000000000..3e7512017--- /dev/null+++ b/shared/src/assistant/cards/collection-places.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** Places of a collection. Only its kind so far; the collections cards give it its fields. */+export const collectionPlacesCardSchema = z.object({ kind: z.literal('collectionPlaces') });+export type CollectionPlacesCard = z.infer<typeof collectionPlacesCardSchema>;diff --git a/shared/src/assistant/cards/collection.contract.ts b/shared/src/assistant/cards/collection.contract.tsnew file mode 100644index 000000000..2d940f0ee--- /dev/null+++ b/shared/src/assistant/cards/collection.contract.ts@@ -0,0 +1,16 @@+import { collectionListsCardSchema } from './collection-lists.card';+import { collectionPlacesCardSchema } from './collection-places.card';++export * from './collection-lists.card';+export * from './collection-places.card';++/**+ * What the collections bring to the assistant chat: the kinds of card they draw,+ * the verbs of their change cards and what an applied change of theirs+ * touches, beyond the core ones. cards/index.ts and assistant.schema.ts+ * spread these into the card union and the shared enums, so a new kind, verb+ * or entity is added here and nowhere else.+ */+export const COLLECTION_CARD_SCHEMAS = [collectionPlacesCardSchema, collectionListsCardSchema] as const;+export const COLLECTION_VERB_KEYS = [] as const;+export const COLLECTION_APPLIED_ENTITIES = [] as const;diff --git a/shared/src/assistant/cards/corridor.card.ts b/shared/src/assistant/cards/corridor.card.tsnew file mode 100644index 000000000..82f9ccd65--- /dev/null+++ b/shared/src/assistant/cards/corridor.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * What lies along a drive, within reach of its route. Only its kind so far; the road trip cards give+ * it its fields.+ */+export const corridorCardSchema = z.object({ kind: z.literal('corridor') });+export type CorridorCard = z.infer<typeof corridorCardSchema>;diff --git a/shared/src/assistant/cards/cost-per-person.card.ts b/shared/src/assistant/cards/cost-per-person.card.tsnew file mode 100644index 000000000..19385bbdb--- /dev/null+++ b/shared/src/assistant/cards/cost-per-person.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** What the trip costs each traveller. Only its kind so far; the budget cards give it its fields. */+export const costPerPersonCardSchema = z.object({ kind: z.literal('costPerPerson') });+export type CostPerPersonCard = z.infer<typeof costPerPersonCardSchema>;diff --git a/shared/src/assistant/cards/day-route.card.ts b/shared/src/assistant/cards/day-route.card.tsnew file mode 100644index 000000000..c4bbb22a9--- /dev/null+++ b/shared/src/assistant/cards/day-route.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** One day's route between its places. Only its kind so far; the road trip cards give it its fields. */+export const dayRouteCardSchema = z.object({ kind: z.literal('dayRoute') });+export type DayRouteCard = z.infer<typeof dayRouteCardSchema>;diff --git a/shared/src/assistant/cards/expenses.card.ts b/shared/src/assistant/cards/expenses.card.tsnew file mode 100644index 000000000..1ad3820a1--- /dev/null+++ b/shared/src/assistant/cards/expenses.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * Expenses of the trip, with who paid and who shares them. Only its kind so far; the budget cards give+ * it its fields.+ */+export const expensesCardSchema = z.object({ kind: z.literal('expenses') });+export type ExpensesCard = z.infer<typeof expensesCardSchema>;diff --git a/shared/src/assistant/cards/index.spec.ts b/shared/src/assistant/cards/index.spec.tsnew file mode 100644index 000000000..3baa22400--- /dev/null+++ b/shared/src/assistant/cards/index.spec.ts@@ -0,0 +1,209 @@+import {+ ASSISTANT_CHANGE_VERB_KEYS,+ assistantAppliedSchema,+ assistantChangePreviewSchema,+ assistantMessagePartSchema,+ assistantMessagePartWriteSchema,+ assistantStoredPartsSchema,+ assistantTakeProposalRequestSchema,+ CORE_APPLIED_ENTITIES,+ CORE_VERB_KEYS,+ uiStreamChunkSchema,+ UI_STREAM_DONE,+} from '../assistant.schema';+import { cardFileKeySchema, cardPersonSchema, cardText, MAX_CARD_CHARS } from './card-parts';+import { assistantCardSchema, storedTrekCardSchema, trekCardSchema } from './index';++import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import { describe, expect, it } from 'vitest';+import { z } from 'zod';++const CALL = 'call_1';+const preview = {+ toolCallId: CALL,+ verbKey: 'addTour',+ subject: 'Lake loop',+ rows: [],+ dayId: null,+ placeIds: [],+ undoable: true,+};++/** Every kind as its package declares it today, built from its own literal. */+const KINDS = trekCardSchema.options.map((option) => option.shape.kind.value);++/**+ * A kind as the packages build theirs, from the card parts, with bounds to+ * cross: the read tolerance is the same for every kind, so these cases hold+ * whatever fields the packages give their own.+ */+const probeSchema = z+ .discriminatedUnion('kind', [+ z.object({ kind: z.literal('probe'), title: cardText(8), people: z.array(cardPersonSchema).max(2) }),+ ])+ .nullable()+ .catch(null);++describe('the card union', () => {+ it('CARDS-001: holds every kind once, each read as itself', () => {+ expect(new Set(KINDS).size).toBe(KINDS.length);+ expect(KINDS).toEqual(expect.arrayContaining(['tourRoute', 'tourList', 'packingList', 'todoList']));+ for (const kind of KINDS) {+ const read = storedTrekCardSchema.parse({ kind });+ if (read !== null) expect(read.kind).toBe(kind);+ }+ });++ it('CARDS-002: reads an unknown kind, a missing kind or no card at all as null', () => {+ for (const card of [{ kind: 'bookPage' }, {}, null, undefined, 'tourRoute', 7]) {+ expect(storedTrekCardSchema.parse(card)).toBeNull();+ }+ });++ it('CARDS-003: reads a field past its bound as null, and drops keys a kind does not declare', () => {+ expect(probeSchema.parse({ kind: 'probe', title: 'Far too long a title', people: [] })).toBeNull();+ const four = [1, 2, 3, 4].map((id) => ({ id, name: `P${id}`, avatarKey: null }));+ expect(probeSchema.parse({ kind: 'probe', title: 'Walk', people: four })).toBeNull();+ expect(probeSchema.parse({ kind: 'probe', title: 'Walk', people: [], url: 'https://x.test' })).toEqual({+ kind: 'probe',+ title: 'Walk',+ people: [],+ });+ });++ it('CARDS-004: a stored file key is a file name, never a path, a URL or a way up', () => {+ expect(cardFileKeySchema.safeParse('a1b2c3.jpg').success).toBe(true);+ for (const key of ['../secret', 'avatars/a.jpg', 'https://x.test/a.jpg', '.hidden', 'a..b', '']) {+ expect(cardFileKeySchema.safeParse(key).success).toBe(false);+ }+ expect(MAX_CARD_CHARS).toBe(24_000);+ });+});++describe('cards in parts, chunks and previews', () => {+ it('CARDS-010: a card part reads an unknown, a kindless or a broken card as null and keeps the part', () => {+ for (const card of [{ kind: 'bookPage', page: 3 }, { title: 'x' }, 'nope']) {+ const part = assistantMessagePartSchema.parse({ type: 'data-trek-card', data: { toolCallId: CALL, card } });+ expect(part).toEqual({ type: 'data-trek-card', data: { toolCallId: CALL, card: null } });+ }+ });++ it('CARDS-011: a card chunk reads the same way, and a known card comes through with extra keys dropped', () => {+ const unknown = uiStreamChunkSchema.parse({+ type: 'data-trek-card',+ data: { toolCallId: CALL, card: { kind: 'x' } },+ });+ expect(unknown).toEqual({ type: 'data-trek-card', data: { toolCallId: CALL, card: null } });+ const known = assistantCardSchema.parse({ toolCallId: CALL, card: { kind: KINDS[0], later: 1 }, extra: true });+ expect(known).not.toHaveProperty('extra');+ if (known.card !== null) expect(known.card).not.toHaveProperty('later');+ });++ it('CARDS-012: a change preview reads without a card, and with a broken one as null', () => {+ expect(assistantChangePreviewSchema.parse(preview)).not.toHaveProperty('card');+ expect(assistantChangePreviewSchema.parse({ ...preview, card: { kind: 'nope' } }).card).toBeNull();+ expect(assistantChangePreviewSchema.parse({ ...preview, card: { title: 'no kind' } }).card).toBeNull();+ });++ it('CARDS-014: a verb or an entity a later build added reads as a plain update and as other', () => {+ const later = { ...preview, verbKey: 'laterVerb' };+ expect(assistantChangePreviewSchema.parse(later).verbKey).toBe('genericUpdate');+ const receipt = { toolCallId: CALL, entity: 'later_entity', ids: [4], dayId: null, undoUntil: null };+ expect(assistantAppliedSchema.parse(receipt).entity).toBe('other');+ const parts = assistantStoredPartsSchema.parse([+ { type: 'data-trek-change', data: later },+ { type: 'data-trek-applied', data: receipt },+ ]);+ expect(parts.map((part) => part.type)).toEqual(['data-trek-change', 'data-trek-applied']);+ });++ it('CARDS-013: a card is always under its call, whose id is 1 to 64 characters', () => {+ expect(assistantCardSchema.safeParse({ toolCallId: '', card: null }).success).toBe(false);+ expect(assistantCardSchema.safeParse({ toolCallId: 'x'.repeat(65), card: null }).success).toBe(false);+ });+});++describe('stored parts', () => {+ it('CARDS-020: drop a data part this build does not know, or one that no longer reads, and keep the rest', () => {+ const parts = assistantStoredPartsSchema.parse([+ { type: 'text', text: 'Here is the walk.' },+ { type: 'data-trek-book-page', data: { page: 3 } },+ { type: 'data-trek-places', data: { toolCallId: CALL } },+ { type: 'data-trek-card', data: { toolCallId: CALL, card: { kind: 'future' } } },+ { type: 'data-trek-change', data: preview },+ ]);+ expect(parts.map((part) => part.type)).toEqual(['text', 'data-trek-card', 'data-trek-change']);+ });++ it('CARDS-021: still refuse a broken part that is not a data part', () => {+ expect(assistantStoredPartsSchema.safeParse([{ type: 'text', text: 5 }]).success).toBe(false);+ expect(assistantStoredPartsSchema.safeParse([{ type: 'tool-call' }]).success).toBe(false);+ });++ it('CARDS-022: are written strictly: an unknown part is no part', () => {+ expect(assistantMessagePartSchema.safeParse({ type: 'data-trek-book-page', data: {} }).success).toBe(false);+ expect(assistantMessagePartWriteSchema.safeParse({ type: 'data-trek-book-page', data: {} }).success).toBe(false);+ });++ it('CARDS-023: are written strictly: no verb, entity or card kind this build does not know', () => {+ const write = (part: unknown) => assistantMessagePartWriteSchema.safeParse(part).success;+ expect(write({ type: 'data-trek-change', data: preview })).toBe(true);+ expect(write({ type: 'data-trek-change', data: { ...preview, verbKey: 'laterVerb' } })).toBe(false);+ expect(write({ type: 'data-trek-change', data: { ...preview, card: { kind: 'nope' } } })).toBe(false);+ const receipt = { toolCallId: CALL, entity: 'later_entity', ids: [4], dayId: null, undoUntil: null };+ expect(write({ type: 'data-trek-applied', data: receipt })).toBe(false);+ expect(write({ type: 'data-trek-card', data: { toolCallId: CALL, card: { kind: 'nope' } } })).toBe(false);+ expect(write({ type: 'data-trek-card', data: { toolCallId: CALL, card: null } })).toBe(true);+ });+});++describe('the enums the packages extend', () => {+ it('CARDS-030: keep every core verb and entity, the hike verbs among them', () => {+ expect(ASSISTANT_CHANGE_VERB_KEYS).toEqual(expect.arrayContaining([...CORE_VERB_KEYS]));+ expect(ASSISTANT_CHANGE_VERB_KEYS).toEqual(expect.arrayContaining(['addTour', 'updateTour', 'importTour']));+ expect(new Set(ASSISTANT_CHANGE_VERB_KEYS).size).toBe(ASSISTANT_CHANGE_VERB_KEYS.length);+ for (const entity of CORE_APPLIED_ENTITIES) {+ expect(assistantAppliedSchema.shape.entity.safeParse(entity).success).toBe(true);+ }+ });+});++describe('assistantTakeProposalRequestSchema', () => {+ it('CARDS-040: names the read whose proposal is taken, with the turn context and nothing else', () => {+ const ctx = { locale: 'en', timeZone: 'Europe/Berlin' };+ expect(assistantTakeProposalRequestSchema.parse({ ...ctx, toolCallId: CALL })).toEqual({+ ...ctx,+ toolCallId: CALL,+ });+ expect(assistantTakeProposalRequestSchema.safeParse({ ...ctx, toolCallId: '' }).success).toBe(false);+ expect(assistantTakeProposalRequestSchema.safeParse({ ...ctx, toolCallId: CALL, args: {} }).success).toBe(false);+ expect(assistantTakeProposalRequestSchema.safeParse({ toolCallId: CALL }).success).toBe(false);+ });+});++describe('ui-stream.cards.v1 fixture', () => {+ const text = readFileSync(resolve(__dirname, '../__fixtures__/ui-stream.cards.v1.txt'), 'utf8');+ const events = text+ .split('\n\n')+ .filter(Boolean)+ .map((event) => event.slice('data: '.length));+ const chunks = events.slice(0, -1).map((event) => uiStreamChunkSchema.parse(JSON.parse(event)));++ it('CARDS-050: is a stream of valid chunks closed by [DONE]', () => {+ expect(events.at(-1)).toBe(UI_STREAM_DONE);+ expect(chunks.length).toBeGreaterThan(10);+ });++ it('CARDS-051: carries an applied write card after its receipt, a read card after its answer, a held one in its preview', () => {+ const types = chunks.map((chunk) => chunk.type);+ const cards = chunks.flatMap((chunk) => (chunk.type === 'data-trek-card' ? [chunk.data.toolCallId] : []));+ const applied = chunks.find((chunk) => chunk.type === 'data-trek-applied');+ const read = chunks.find((chunk) => chunk.type === 'tool-input-start' && chunk.toolName === 'list_tours');+ expect(applied?.type === 'data-trek-applied' && applied.data.toolCallId).toBe(cards[0]);+ expect(read?.type === 'tool-input-start' && read.toolCallId).toBe(cards[1]);+ expect(types.indexOf('data-trek-applied')).toBeLessThan(types.indexOf('data-trek-card'));+ const change = chunks.find((chunk) => chunk.type === 'data-trek-change');+ expect(change?.type === 'data-trek-change' && 'card' in change.data).toBe(true);+ });+});diff --git a/shared/src/assistant/cards/index.ts b/shared/src/assistant/cards/index.tsnew file mode 100644index 000000000..fd0082294--- /dev/null+++ b/shared/src/assistant/cards/index.ts@@ -0,0 +1,66 @@+import { ATLAS_CARD_SCHEMAS } from './atlas.contract';+import { BOOKING_CARD_SCHEMAS } from './booking.contract';+import { BUDGET_CARD_SCHEMAS } from './budget.contract';+import { COLLAB_CARD_SCHEMAS } from './collab.contract';+import { COLLECTION_CARD_SCHEMAS } from './collection.contract';+import { JOURNEY_CARD_SCHEMAS } from './journey.contract';+import { PACKING_CARD_SCHEMAS } from './packing.contract';+import { ROADTRIP_CARD_SCHEMAS } from './roadtrip.contract';+import { TOUR_CARD_SCHEMAS } from './tour.contract';+import { VACAY_CARD_SCHEMAS } from './vacay.contract';++import { z } from 'zod';++export * from './card-parts';+export * from './atlas.contract';+export * from './booking.contract';+export * from './budget.contract';+export * from './collab.contract';+export * from './collection.contract';+export * from './journey.contract';+export * from './packing.contract';+export * from './roadtrip.contract';+export * from './tour.contract';+export * from './vacay.contract';++/**+ * The cards of the assistant chat: one per tool call, drawn beside an answer+ * (a read's result) or inside a change card (what a held write will do, and+ * what it did once applied). Each part of TREK owns its kinds in its+ * `<pkg>.contract.ts`; the server builds every card from the tool's own+ * answer and checks it against this union before it is sent.+ */+export const trekCardSchema = z.discriminatedUnion('kind', [+ ...TOUR_CARD_SCHEMAS,+ ...ROADTRIP_CARD_SCHEMAS,+ ...BUDGET_CARD_SCHEMAS,+ ...BOOKING_CARD_SCHEMAS,+ ...COLLAB_CARD_SCHEMAS,+ ...COLLECTION_CARD_SCHEMAS,+ ...ATLAS_CARD_SCHEMAS,+ ...VACAY_CARD_SCHEMAS,+ ...JOURNEY_CARD_SCHEMAS,+ ...PACKING_CARD_SCHEMAS,+]);+export type TrekCard = z.infer<typeof trekCardSchema>;+export type TrekCardKind = TrekCard['kind'];+export type TrekCardOf<K extends TrekCardKind> = Extract<TrekCard, { kind: K }>;++/**+ * How a stored or streamed card is read. A kind this build does not know, a+ * missing field or a value past a bound reads as null and the card is left+ * out, never the message around it: a newer server may write kinds an older+ * client or a rolled back server has not heard of (verified with zod 4.6.5).+ * Keys a kind does not declare are dropped, so a field added later reads too.+ */+export const storedTrekCardSchema = trekCardSchema.nullable().catch(null);++/** The card of one tool call, under that call's id: a read's, or a held or applied write's. */+export const assistantCardSchema = z.object({+ toolCallId: z.string().min(1).max(64),+ card: storedTrekCardSchema,+});+export type AssistantCard = z.infer<typeof assistantCardSchema>;++/** The same as the server writes it: a card the union refuses is a bug in its builder, never a silent null. */+export const assistantCardWriteSchema = assistantCardSchema.extend({ card: trekCardSchema.nullable() });diff --git a/shared/src/assistant/cards/journey-entries.card.ts b/shared/src/assistant/cards/journey-entries.card.tsnew file mode 100644index 000000000..1e316719a--- /dev/null+++ b/shared/src/assistant/cards/journey-entries.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** Entries of a travel journal. Only its kind so far; the travel journal cards give it its fields. */+export const journeyEntriesCardSchema = z.object({ kind: z.literal('journeyEntries') });+export type JourneyEntriesCard = z.infer<typeof journeyEntriesCardSchema>;diff --git a/shared/src/assistant/cards/journey.contract.ts b/shared/src/assistant/cards/journey.contract.tsnew file mode 100644index 000000000..83cda21a8--- /dev/null+++ b/shared/src/assistant/cards/journey.contract.ts@@ -0,0 +1,14 @@+import { journeyEntriesCardSchema } from './journey-entries.card';++export * from './journey-entries.card';++/**+ * What the travel journal brings to the assistant chat: the kinds of card it draws,+ * the verbs of its change cards and what an applied change of its+ * touches, beyond the core ones. cards/index.ts and assistant.schema.ts+ * spread these into the card union and the shared enums, so a new kind, verb+ * or entity is added here and nowhere else.+ */+export const JOURNEY_CARD_SCHEMAS = [journeyEntriesCardSchema] as const;+export const JOURNEY_VERB_KEYS = [] as const;+export const JOURNEY_APPLIED_ENTITIES = [] as const;diff --git a/shared/src/assistant/cards/packing-list.card.ts b/shared/src/assistant/cards/packing-list.card.tsnew file mode 100644index 000000000..9be9351ab--- /dev/null+++ b/shared/src/assistant/cards/packing-list.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * A packing list: the trip's, a tour's or a template's. Only its kind so far; the packing and to-do+ * cards give it its fields.+ */+export const packingListCardSchema = z.object({ kind: z.literal('packingList') });+export type PackingListCard = z.infer<typeof packingListCardSchema>;diff --git a/shared/src/assistant/cards/packing.contract.ts b/shared/src/assistant/cards/packing.contract.tsnew file mode 100644index 000000000..58a55632e--- /dev/null+++ b/shared/src/assistant/cards/packing.contract.ts@@ -0,0 +1,16 @@+import { packingListCardSchema } from './packing-list.card';+import { todoListCardSchema } from './todo-list.card';++export * from './packing-list.card';+export * from './todo-list.card';++/**+ * What the packing and to-do lists bring to the assistant chat: the kinds of card they draw,+ * the verbs of their change cards and what an applied change of theirs+ * touches, beyond the core ones. cards/index.ts and assistant.schema.ts+ * spread these into the card union and the shared enums, so a new kind, verb+ * or entity is added here and nowhere else.+ */+export const PACKING_CARD_SCHEMAS = [packingListCardSchema, todoListCardSchema] as const;+export const PACKING_VERB_KEYS = [] as const;+export const PACKING_APPLIED_ENTITIES = [] as const;diff --git a/shared/src/assistant/cards/payments.card.ts b/shared/src/assistant/cards/payments.card.tsnew file mode 100644index 000000000..d69936197--- /dev/null+++ b/shared/src/assistant/cards/payments.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** Payments between the travellers. Only its kind so far; the budget cards give it its fields. */+export const paymentsCardSchema = z.object({ kind: z.literal('payments') });+export type PaymentsCard = z.infer<typeof paymentsCardSchema>;diff --git a/shared/src/assistant/cards/roadtrip.card.ts b/shared/src/assistant/cards/roadtrip.card.tsnew file mode 100644index 000000000..c88efed2c--- /dev/null+++ b/shared/src/assistant/cards/roadtrip.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * A road trip's drive with its days and stops. Only its kind so far; the road trip cards give it its+ * fields.+ */+export const roadtripCardSchema = z.object({ kind: z.literal('roadtrip') });+export type RoadtripCard = z.infer<typeof roadtripCardSchema>;diff --git a/shared/src/assistant/cards/roadtrip.contract.ts b/shared/src/assistant/cards/roadtrip.contract.tsnew file mode 100644index 000000000..436781b28--- /dev/null+++ b/shared/src/assistant/cards/roadtrip.contract.ts@@ -0,0 +1,28 @@+import { chargingCardSchema } from './charging.card';+import { corridorCardSchema } from './corridor.card';+import { dayRouteCardSchema } from './day-route.card';+import { roadtripCardSchema } from './roadtrip.card';+import { transitCardSchema } from './transit.card';++export * from './charging.card';+export * from './corridor.card';+export * from './day-route.card';+export * from './roadtrip.card';+export * from './transit.card';++/**+ * What the road trip brings to the assistant chat: the kinds of card it draws,+ * the verbs of its change cards and what an applied change of its+ * touches, beyond the core ones. cards/index.ts and assistant.schema.ts+ * spread these into the card union and the shared enums, so a new kind, verb+ * or entity is added here and nowhere else.+ */+export const ROADTRIP_CARD_SCHEMAS = [+ roadtripCardSchema,+ corridorCardSchema,+ chargingCardSchema,+ transitCardSchema,+ dayRouteCardSchema,+] as const;+export const ROADTRIP_VERB_KEYS = [] as const;+export const ROADTRIP_APPLIED_ENTITIES = [] as const;diff --git a/shared/src/assistant/cards/settlement.card.ts b/shared/src/assistant/cards/settlement.card.tsnew file mode 100644index 000000000..f7c0d6097--- /dev/null+++ b/shared/src/assistant/cards/settlement.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** Who pays whom to settle up. Only its kind so far; the budget cards give it its fields. */+export const settlementCardSchema = z.object({ kind: z.literal('settlement') });+export type SettlementCard = z.infer<typeof settlementCardSchema>;diff --git a/shared/src/assistant/cards/todo-list.card.ts b/shared/src/assistant/cards/todo-list.card.tsnew file mode 100644index 000000000..b8d460f99--- /dev/null+++ b/shared/src/assistant/cards/todo-list.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** To-dos of the trip. Only its kind so far; the packing and to-do cards give it its fields. */+export const todoListCardSchema = z.object({ kind: z.literal('todoList') });+export type TodoListCard = z.infer<typeof todoListCardSchema>;diff --git a/shared/src/assistant/cards/tour-list.card.ts b/shared/src/assistant/cards/tour-list.card.tsnew file mode 100644index 000000000..4ff0ec8f3--- /dev/null+++ b/shared/src/assistant/cards/tour-list.card.ts@@ -0,0 +1,5 @@+import { z } from 'zod';++/** The tours of a trip or of one of its days. Only its kind so far; the tours cards give it its fields. */+export const tourListCardSchema = z.object({ kind: z.literal('tourList') });+export type TourListCard = z.infer<typeof tourListCardSchema>;diff --git a/shared/src/assistant/cards/tour-route.card.ts b/shared/src/assistant/cards/tour-route.card.tsnew file mode 100644index 000000000..6e7c66e44--- /dev/null+++ b/shared/src/assistant/cards/tour-route.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * A tour's route: a hike, a city walk, a paddle or a ski plan the assistant proposed, or a saved tour+ * it read. Only its kind so far; the tours cards give it its fields.+ */+export const tourRouteCardSchema = z.object({ kind: z.literal('tourRoute') });+export type TourRouteCard = z.infer<typeof tourRouteCardSchema>;diff --git a/shared/src/assistant/cards/tour.contract.ts b/shared/src/assistant/cards/tour.contract.tsnew file mode 100644index 000000000..90b3d3d30--- /dev/null+++ b/shared/src/assistant/cards/tour.contract.ts@@ -0,0 +1,18 @@+import { tourListCardSchema } from './tour-list.card';+import { tourRouteCardSchema } from './tour-route.card';++export * from './tour-list.card';+export * from './tour-route.card';++/**+ * What the tours bring to the assistant chat: the kinds of card they draw,+ * the verbs of their change cards and what an applied change of theirs+ * touches, beyond the core ones. cards/index.ts and assistant.schema.ts+ * spread these into the card union and the shared enums, so a new kind, verb+ * or entity is added here and nowhere else.+ */+export const TOUR_CARD_SCHEMAS = [tourRouteCardSchema, tourListCardSchema] as const;+/** addTour, updateTour and importTour sit in the core list already. */+export const TOUR_VERB_KEYS = [] as const;+/** 'tour' is a core entity already. */+export const TOUR_APPLIED_ENTITIES = [] as const;diff --git a/shared/src/assistant/cards/transit.card.ts b/shared/src/assistant/cards/transit.card.tsnew file mode 100644index 000000000..2929c9617--- /dev/null+++ b/shared/src/assistant/cards/transit.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * A public transport journey with its legs and times. Only its kind so far; the road trip cards give+ * it its fields.+ */+export const transitCardSchema = z.object({ kind: z.literal('transit') });+export type TransitCard = z.infer<typeof transitCardSchema>;diff --git a/shared/src/assistant/cards/vacay.card.ts b/shared/src/assistant/cards/vacay.card.tsnew file mode 100644index 000000000..425b3f1aa--- /dev/null+++ b/shared/src/assistant/cards/vacay.card.ts@@ -0,0 +1,8 @@+import { z } from 'zod';++/**+ * Vacation days on a month calendar, with the days left. Only its kind so far; the vacation planner+ * cards give it its fields.+ */+export const vacayCardSchema = z.object({ kind: z.literal('vacay') });+export type VacayCard = z.infer<typeof vacayCardSchema>;diff --git a/shared/src/assistant/cards/vacay.contract.ts b/shared/src/assistant/cards/vacay.contract.tsnew file mode 100644index 000000000..b6a65fa7a--- /dev/null+++ b/shared/src/assistant/cards/vacay.contract.ts@@ -0,0 +1,14 @@+import { vacayCardSchema } from './vacay.card';++export * from './vacay.card';++/**+ * What the vacation planner brings to the assistant chat: the kinds of card it draws,+ * the verbs of its change cards and what an applied change of its+ * touches, beyond the core ones. cards/index.ts and assistant.schema.ts+ * spread these into the card union and the shared enums, so a new kind, verb+ * or entity is added here and nowhere else.+ */+export const VACAY_CARD_SCHEMAS = [vacayCardSchema] as const;+export const VACAY_VERB_KEYS = [] as const;+export const VACAY_APPLIED_ENTITIES = [] as const;diff --git a/shared/src/i18n/ar/assistantAtlas.ts b/shared/src/i18n/ar/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/ar/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/ar/assistantBooking.ts b/shared/src/i18n/ar/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/ar/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/ar/assistantBudget.ts b/shared/src/i18n/ar/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/ar/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/ar/assistantCard.ts b/shared/src/i18n/ar/assistantCard.tsnew file mode 100644index 000000000..6e0634265--- /dev/null+++ b/shared/src/i18n/ar/assistantCard.ts@@ -0,0 +1,19 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'فتح',+ 'assistant.card.common.more': '{count} أخرى',+ 'assistant.card.common.more.zero': '{count} أخرى',+ 'assistant.card.common.more.one': '{count} أخرى',+ 'assistant.card.common.more.two': '{count} أخرى',+ 'assistant.card.common.more.few': '{count} أخرى',+ 'assistant.card.common.more.many': '{count} أخرى',+ 'assistant.card.common.new': 'جديد',+ 'assistant.card.common.removed': 'أُزيل',+ 'assistant.card.common.changed': 'تغيّر',+ 'assistant.card.common.willDelete': 'سيُحذف',+ 'assistant.card.common.noLonger': 'لم يعد: {names}',+ 'assistant.card.common.you': 'أنت',+ 'assistant.card.common.showDay': 'عرض هذا اليوم في الخطة',+};+export default assistantCard;diff --git a/shared/src/i18n/ar/assistantCollab.ts b/shared/src/i18n/ar/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/ar/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/ar/assistantCollection.ts b/shared/src/i18n/ar/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/ar/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/ar/assistantJourney.ts b/shared/src/i18n/ar/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/ar/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/ar/assistantPacking.ts b/shared/src/i18n/ar/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/ar/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/ar/assistantRoadtrip.ts b/shared/src/i18n/ar/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/ar/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/ar/assistantTour.ts b/shared/src/i18n/ar/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/ar/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/ar/assistantVacay.ts b/shared/src/i18n/ar/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/ar/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/ar/index.ts b/shared/src/i18n/ar/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/ar/index.ts+++ b/shared/src/i18n/ar/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/az/assistantAtlas.ts b/shared/src/i18n/az/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/az/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/az/assistantBooking.ts b/shared/src/i18n/az/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/az/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/az/assistantBudget.ts b/shared/src/i18n/az/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/az/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/az/assistantCard.ts b/shared/src/i18n/az/assistantCard.tsnew file mode 100644index 000000000..6a0a30c47--- /dev/null+++ b/shared/src/i18n/az/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Aç',+ 'assistant.card.common.more': 'daha {count}',+ 'assistant.card.common.more.one': 'daha {count}',+ 'assistant.card.common.new': 'Yeni',+ 'assistant.card.common.removed': 'Çıxarıldı',+ 'assistant.card.common.changed': 'Dəyişdi',+ 'assistant.card.common.willDelete': 'Silinəcək',+ 'assistant.card.common.noLonger': 'Artıq yoxdur: {names}',+ 'assistant.card.common.you': 'Siz',+ 'assistant.card.common.showDay': 'Bu günü planda göstər',+};+export default assistantCard;diff --git a/shared/src/i18n/az/assistantCollab.ts b/shared/src/i18n/az/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/az/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/az/assistantCollection.ts b/shared/src/i18n/az/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/az/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/az/assistantJourney.ts b/shared/src/i18n/az/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/az/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/az/assistantPacking.ts b/shared/src/i18n/az/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/az/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/az/assistantRoadtrip.ts b/shared/src/i18n/az/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/az/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/az/assistantTour.ts b/shared/src/i18n/az/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/az/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/az/assistantVacay.ts b/shared/src/i18n/az/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/az/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/az/index.ts b/shared/src/i18n/az/index.tsindex 6b9d2525e..d7e6e9c6a 100644--- a/shared/src/i18n/az/index.ts+++ b/shared/src/i18n/az/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/br/assistantAtlas.ts b/shared/src/i18n/br/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/br/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/br/assistantBooking.ts b/shared/src/i18n/br/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/br/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/br/assistantBudget.ts b/shared/src/i18n/br/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/br/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/br/assistantCard.ts b/shared/src/i18n/br/assistantCard.tsnew file mode 100644index 000000000..a8c115eeb--- /dev/null+++ b/shared/src/i18n/br/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Abrir',+ 'assistant.card.common.more': 'mais {count}',+ 'assistant.card.common.more.one': 'mais {count}',+ 'assistant.card.common.new': 'Novo',+ 'assistant.card.common.removed': 'Removido',+ 'assistant.card.common.changed': 'Alterado',+ 'assistant.card.common.willDelete': 'Será excluído',+ 'assistant.card.common.noLonger': 'Não mais: {names}',+ 'assistant.card.common.you': 'Você',+ 'assistant.card.common.showDay': 'Mostrar este dia no plano',+};+export default assistantCard;diff --git a/shared/src/i18n/br/assistantCollab.ts b/shared/src/i18n/br/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/br/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/br/assistantCollection.ts b/shared/src/i18n/br/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/br/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/br/assistantJourney.ts b/shared/src/i18n/br/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/br/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/br/assistantPacking.ts b/shared/src/i18n/br/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/br/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/br/assistantRoadtrip.ts b/shared/src/i18n/br/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/br/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/br/assistantTour.ts b/shared/src/i18n/br/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/br/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/br/assistantVacay.ts b/shared/src/i18n/br/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/br/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/br/index.ts b/shared/src/i18n/br/index.tsindex f56535825..44a9f0441 100644--- a/shared/src/i18n/br/index.ts+++ b/shared/src/i18n/br/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/ca/assistantAtlas.ts b/shared/src/i18n/ca/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/ca/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/ca/assistantBooking.ts b/shared/src/i18n/ca/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/ca/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/ca/assistantBudget.ts b/shared/src/i18n/ca/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/ca/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/ca/assistantCard.ts b/shared/src/i18n/ca/assistantCard.tsnew file mode 100644index 000000000..9278ae66a--- /dev/null+++ b/shared/src/i18n/ca/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Obrir',+ 'assistant.card.common.more': '{count} més',+ 'assistant.card.common.more.one': '{count} més',+ 'assistant.card.common.new': 'Nou',+ 'assistant.card.common.removed': 'Tret',+ 'assistant.card.common.changed': 'Canviat',+ 'assistant.card.common.willDelete': "S'eliminarà",+ 'assistant.card.common.noLonger': 'Ja no: {names}',+ 'assistant.card.common.you': 'Tu',+ 'assistant.card.common.showDay': 'Mostra aquest dia al pla',+};+export default assistantCard;diff --git a/shared/src/i18n/ca/assistantCollab.ts b/shared/src/i18n/ca/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/ca/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/ca/assistantCollection.ts b/shared/src/i18n/ca/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/ca/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/ca/assistantJourney.ts b/shared/src/i18n/ca/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/ca/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/ca/assistantPacking.ts b/shared/src/i18n/ca/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/ca/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/ca/assistantRoadtrip.ts b/shared/src/i18n/ca/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/ca/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/ca/assistantTour.ts b/shared/src/i18n/ca/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/ca/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/ca/assistantVacay.ts b/shared/src/i18n/ca/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/ca/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/ca/index.ts b/shared/src/i18n/ca/index.tsindex 2d3aabe44..ecfa11329 100644--- a/shared/src/i18n/ca/index.ts+++ b/shared/src/i18n/ca/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/cs/assistantAtlas.ts b/shared/src/i18n/cs/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/cs/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/cs/assistantBooking.ts b/shared/src/i18n/cs/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/cs/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/cs/assistantBudget.ts b/shared/src/i18n/cs/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/cs/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/cs/assistantCard.ts b/shared/src/i18n/cs/assistantCard.tsnew file mode 100644index 000000000..ec0b8d5a7--- /dev/null+++ b/shared/src/i18n/cs/assistantCard.ts@@ -0,0 +1,16 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Otevřít',+ 'assistant.card.common.more': '{count} dalších',+ 'assistant.card.common.more.one': '{count} další',+ 'assistant.card.common.more.few': '{count} další',+ 'assistant.card.common.new': 'Nové',+ 'assistant.card.common.removed': 'Odebráno',+ 'assistant.card.common.changed': 'Změněno',+ 'assistant.card.common.willDelete': 'Bude smazáno',+ 'assistant.card.common.noLonger': 'Už ne: {names}',+ 'assistant.card.common.you': 'Vy',+ 'assistant.card.common.showDay': 'Zobrazit tento den v plánu',+};+export default assistantCard;diff --git a/shared/src/i18n/cs/assistantCollab.ts b/shared/src/i18n/cs/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/cs/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/cs/assistantCollection.ts b/shared/src/i18n/cs/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/cs/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/cs/assistantJourney.ts b/shared/src/i18n/cs/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/cs/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/cs/assistantPacking.ts b/shared/src/i18n/cs/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/cs/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/cs/assistantRoadtrip.ts b/shared/src/i18n/cs/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/cs/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/cs/assistantTour.ts b/shared/src/i18n/cs/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/cs/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/cs/assistantVacay.ts b/shared/src/i18n/cs/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/cs/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/cs/index.ts b/shared/src/i18n/cs/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/cs/index.ts+++ b/shared/src/i18n/cs/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/de/assistantAtlas.ts b/shared/src/i18n/de/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/de/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/de/assistantBooking.ts b/shared/src/i18n/de/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/de/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/de/assistantBudget.ts b/shared/src/i18n/de/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/de/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/de/assistantCard.ts b/shared/src/i18n/de/assistantCard.tsnew file mode 100644index 000000000..3457ec99a--- /dev/null+++ b/shared/src/i18n/de/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Öffnen',+ 'assistant.card.common.more': '{count} weitere',+ 'assistant.card.common.more.one': '{count} weiteres',+ 'assistant.card.common.new': 'Neu',+ 'assistant.card.common.removed': 'Entfernt',+ 'assistant.card.common.changed': 'Geändert',+ 'assistant.card.common.willDelete': 'Wird gelöscht',+ 'assistant.card.common.noLonger': 'Nicht mehr: {names}',+ 'assistant.card.common.you': 'Du',+ 'assistant.card.common.showDay': 'Diesen Tag im Plan zeigen',+};+export default assistantCard;diff --git a/shared/src/i18n/de/assistantCollab.ts b/shared/src/i18n/de/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/de/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/de/assistantCollection.ts b/shared/src/i18n/de/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/de/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/de/assistantJourney.ts b/shared/src/i18n/de/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/de/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/de/assistantPacking.ts b/shared/src/i18n/de/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/de/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/de/assistantRoadtrip.ts b/shared/src/i18n/de/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/de/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/de/assistantTour.ts b/shared/src/i18n/de/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/de/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/de/assistantVacay.ts b/shared/src/i18n/de/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/de/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/de/index.ts b/shared/src/i18n/de/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/de/index.ts+++ b/shared/src/i18n/de/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/en/assistantAtlas.ts b/shared/src/i18n/en/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/en/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/en/assistantBooking.ts b/shared/src/i18n/en/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/en/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/en/assistantBudget.ts b/shared/src/i18n/en/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/en/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/en/assistantCard.ts b/shared/src/i18n/en/assistantCard.tsnew file mode 100644index 000000000..c30baa372--- /dev/null+++ b/shared/src/i18n/en/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Open',+ 'assistant.card.common.more': '{count} more',+ 'assistant.card.common.more.one': '{count} more',+ 'assistant.card.common.new': 'New',+ 'assistant.card.common.removed': 'Removed',+ 'assistant.card.common.changed': 'Changed',+ 'assistant.card.common.willDelete': 'Will be deleted',+ 'assistant.card.common.noLonger': 'No longer: {names}',+ 'assistant.card.common.you': 'You',+ 'assistant.card.common.showDay': 'Show this day in the plan',+};+export default assistantCard;diff --git a/shared/src/i18n/en/assistantCollab.ts b/shared/src/i18n/en/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/en/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/en/assistantCollection.ts b/shared/src/i18n/en/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/en/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/en/assistantJourney.ts b/shared/src/i18n/en/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/en/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/en/assistantPacking.ts b/shared/src/i18n/en/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/en/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/en/assistantRoadtrip.ts b/shared/src/i18n/en/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/en/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/en/assistantTour.ts b/shared/src/i18n/en/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/en/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/en/assistantVacay.ts b/shared/src/i18n/en/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/en/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/en/index.ts b/shared/src/i18n/en/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/en/index.ts+++ b/shared/src/i18n/en/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/es/assistantAtlas.ts b/shared/src/i18n/es/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/es/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/es/assistantBooking.ts b/shared/src/i18n/es/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/es/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/es/assistantBudget.ts b/shared/src/i18n/es/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/es/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/es/assistantCard.ts b/shared/src/i18n/es/assistantCard.tsnew file mode 100644index 000000000..e737320b2--- /dev/null+++ b/shared/src/i18n/es/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Abrir',+ 'assistant.card.common.more': '{count} más',+ 'assistant.card.common.more.one': '{count} más',+ 'assistant.card.common.new': 'Nuevo',+ 'assistant.card.common.removed': 'Quitado',+ 'assistant.card.common.changed': 'Cambiado',+ 'assistant.card.common.willDelete': 'Se eliminará',+ 'assistant.card.common.noLonger': 'Ya no: {names}',+ 'assistant.card.common.you': 'Tú',+ 'assistant.card.common.showDay': 'Mostrar este día en el plan',+};+export default assistantCard;diff --git a/shared/src/i18n/es/assistantCollab.ts b/shared/src/i18n/es/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/es/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/es/assistantCollection.ts b/shared/src/i18n/es/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/es/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/es/assistantJourney.ts b/shared/src/i18n/es/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/es/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/es/assistantPacking.ts b/shared/src/i18n/es/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/es/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/es/assistantRoadtrip.ts b/shared/src/i18n/es/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/es/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/es/assistantTour.ts b/shared/src/i18n/es/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/es/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/es/assistantVacay.ts b/shared/src/i18n/es/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/es/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/es/index.ts b/shared/src/i18n/es/index.tsindex 4ac98c8af..a789191c8 100644--- a/shared/src/i18n/es/index.ts+++ b/shared/src/i18n/es/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/et/assistantAtlas.ts b/shared/src/i18n/et/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/et/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/et/assistantBooking.ts b/shared/src/i18n/et/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/et/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/et/assistantBudget.ts b/shared/src/i18n/et/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/et/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/et/assistantCard.ts b/shared/src/i18n/et/assistantCard.tsnew file mode 100644index 000000000..51577bcfa--- /dev/null+++ b/shared/src/i18n/et/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Ava',+ 'assistant.card.common.more': 'veel {count}',+ 'assistant.card.common.more.one': 'veel {count}',+ 'assistant.card.common.new': 'Uus',+ 'assistant.card.common.removed': 'Eemaldatud',+ 'assistant.card.common.changed': 'Muudetud',+ 'assistant.card.common.willDelete': 'Kustutatakse',+ 'assistant.card.common.noLonger': 'Enam mitte: {names}',+ 'assistant.card.common.you': 'Sina',+ 'assistant.card.common.showDay': 'Näita seda päeva plaanis',+};+export default assistantCard;diff --git a/shared/src/i18n/et/assistantCollab.ts b/shared/src/i18n/et/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/et/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/et/assistantCollection.ts b/shared/src/i18n/et/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/et/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/et/assistantJourney.ts b/shared/src/i18n/et/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/et/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/et/assistantPacking.ts b/shared/src/i18n/et/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/et/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/et/assistantRoadtrip.ts b/shared/src/i18n/et/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/et/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/et/assistantTour.ts b/shared/src/i18n/et/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/et/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/et/assistantVacay.ts b/shared/src/i18n/et/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/et/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/et/index.ts b/shared/src/i18n/et/index.tsindex 6b9d2525e..d7e6e9c6a 100644--- a/shared/src/i18n/et/index.ts+++ b/shared/src/i18n/et/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/fr/assistantAtlas.ts b/shared/src/i18n/fr/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/fr/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/fr/assistantBooking.ts b/shared/src/i18n/fr/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/fr/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/fr/assistantBudget.ts b/shared/src/i18n/fr/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/fr/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/fr/assistantCard.ts b/shared/src/i18n/fr/assistantCard.tsnew file mode 100644index 000000000..34b6871cc--- /dev/null+++ b/shared/src/i18n/fr/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Ouvrir',+ 'assistant.card.common.more': '{count} autres',+ 'assistant.card.common.more.one': '{count} autre',+ 'assistant.card.common.new': 'Nouveau',+ 'assistant.card.common.removed': 'Retiré',+ 'assistant.card.common.changed': 'Modifié',+ 'assistant.card.common.willDelete': 'Sera supprimé',+ 'assistant.card.common.noLonger': 'Plus inclus : {names}',+ 'assistant.card.common.you': 'Vous',+ 'assistant.card.common.showDay': 'Afficher ce jour dans le plan',+};+export default assistantCard;diff --git a/shared/src/i18n/fr/assistantCollab.ts b/shared/src/i18n/fr/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/fr/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/fr/assistantCollection.ts b/shared/src/i18n/fr/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/fr/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/fr/assistantJourney.ts b/shared/src/i18n/fr/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/fr/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/fr/assistantPacking.ts b/shared/src/i18n/fr/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/fr/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/fr/assistantRoadtrip.ts b/shared/src/i18n/fr/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/fr/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/fr/assistantTour.ts b/shared/src/i18n/fr/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/fr/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/fr/assistantVacay.ts b/shared/src/i18n/fr/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/fr/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/fr/index.ts b/shared/src/i18n/fr/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/fr/index.ts+++ b/shared/src/i18n/fr/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/gr/assistantAtlas.ts b/shared/src/i18n/gr/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/gr/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/gr/assistantBooking.ts b/shared/src/i18n/gr/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/gr/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/gr/assistantBudget.ts b/shared/src/i18n/gr/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/gr/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/gr/assistantCard.ts b/shared/src/i18n/gr/assistantCard.tsnew file mode 100644index 000000000..342ca4f36--- /dev/null+++ b/shared/src/i18n/gr/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Άνοιγμα',+ 'assistant.card.common.more': 'ακόμη {count}',+ 'assistant.card.common.more.one': 'ακόμη {count}',+ 'assistant.card.common.new': 'Νέο',+ 'assistant.card.common.removed': 'Αφαιρέθηκε',+ 'assistant.card.common.changed': 'Άλλαξε',+ 'assistant.card.common.willDelete': 'Θα διαγραφεί',+ 'assistant.card.common.noLonger': 'Όχι πια: {names}',+ 'assistant.card.common.you': 'Εσείς',+ 'assistant.card.common.showDay': 'Εμφάνιση αυτής της ημέρας στο πλάνο',+};+export default assistantCard;diff --git a/shared/src/i18n/gr/assistantCollab.ts b/shared/src/i18n/gr/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/gr/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/gr/assistantCollection.ts b/shared/src/i18n/gr/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/gr/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/gr/assistantJourney.ts b/shared/src/i18n/gr/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/gr/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/gr/assistantPacking.ts b/shared/src/i18n/gr/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/gr/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/gr/assistantRoadtrip.ts b/shared/src/i18n/gr/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/gr/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/gr/assistantTour.ts b/shared/src/i18n/gr/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/gr/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/gr/assistantVacay.ts b/shared/src/i18n/gr/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/gr/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/gr/index.ts b/shared/src/i18n/gr/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/gr/index.ts+++ b/shared/src/i18n/gr/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/hu/assistantAtlas.ts b/shared/src/i18n/hu/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/hu/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/hu/assistantBooking.ts b/shared/src/i18n/hu/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/hu/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/hu/assistantBudget.ts b/shared/src/i18n/hu/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/hu/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/hu/assistantCard.ts b/shared/src/i18n/hu/assistantCard.tsnew file mode 100644index 000000000..7f1fd87b8--- /dev/null+++ b/shared/src/i18n/hu/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Megnyitás',+ 'assistant.card.common.more': 'további {count}',+ 'assistant.card.common.more.one': 'további {count}',+ 'assistant.card.common.new': 'Új',+ 'assistant.card.common.removed': 'Eltávolítva',+ 'assistant.card.common.changed': 'Módosítva',+ 'assistant.card.common.willDelete': 'Törlődik',+ 'assistant.card.common.noLonger': 'Már nem: {names}',+ 'assistant.card.common.you': 'Te',+ 'assistant.card.common.showDay': 'A nap megjelenítése a tervben',+};+export default assistantCard;diff --git a/shared/src/i18n/hu/assistantCollab.ts b/shared/src/i18n/hu/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/hu/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/hu/assistantCollection.ts b/shared/src/i18n/hu/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/hu/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/hu/assistantJourney.ts b/shared/src/i18n/hu/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/hu/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/hu/assistantPacking.ts b/shared/src/i18n/hu/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/hu/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/hu/assistantRoadtrip.ts b/shared/src/i18n/hu/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/hu/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/hu/assistantTour.ts b/shared/src/i18n/hu/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/hu/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/hu/assistantVacay.ts b/shared/src/i18n/hu/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/hu/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/hu/index.ts b/shared/src/i18n/hu/index.tsindex f56535825..44a9f0441 100644--- a/shared/src/i18n/hu/index.ts+++ b/shared/src/i18n/hu/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/id/assistantAtlas.ts b/shared/src/i18n/id/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/id/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/id/assistantBooking.ts b/shared/src/i18n/id/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/id/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/id/assistantBudget.ts b/shared/src/i18n/id/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/id/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/id/assistantCard.ts b/shared/src/i18n/id/assistantCard.tsnew file mode 100644index 000000000..d2efded8f--- /dev/null+++ b/shared/src/i18n/id/assistantCard.ts@@ -0,0 +1,14 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Buka',+ 'assistant.card.common.more': '{count} lagi',+ 'assistant.card.common.new': 'Baru',+ 'assistant.card.common.removed': 'Dikeluarkan',+ 'assistant.card.common.changed': 'Diubah',+ 'assistant.card.common.willDelete': 'Akan dihapus',+ 'assistant.card.common.noLonger': 'Tidak lagi: {names}',+ 'assistant.card.common.you': 'Kamu',+ 'assistant.card.common.showDay': 'Tampilkan hari tersebut di rencana',+};+export default assistantCard;diff --git a/shared/src/i18n/id/assistantCollab.ts b/shared/src/i18n/id/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/id/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/id/assistantCollection.ts b/shared/src/i18n/id/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/id/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/id/assistantJourney.ts b/shared/src/i18n/id/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/id/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/id/assistantPacking.ts b/shared/src/i18n/id/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/id/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/id/assistantRoadtrip.ts b/shared/src/i18n/id/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/id/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/id/assistantTour.ts b/shared/src/i18n/id/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/id/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/id/assistantVacay.ts b/shared/src/i18n/id/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/id/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/id/index.ts b/shared/src/i18n/id/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/id/index.ts+++ b/shared/src/i18n/id/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/it/assistantAtlas.ts b/shared/src/i18n/it/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/it/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/it/assistantBooking.ts b/shared/src/i18n/it/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/it/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/it/assistantBudget.ts b/shared/src/i18n/it/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/it/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/it/assistantCard.ts b/shared/src/i18n/it/assistantCard.tsnew file mode 100644index 000000000..aa503a4ee--- /dev/null+++ b/shared/src/i18n/it/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Apri',+ 'assistant.card.common.more': '{count} altri',+ 'assistant.card.common.more.one': '{count} altro',+ 'assistant.card.common.new': 'Nuovo',+ 'assistant.card.common.removed': 'Rimosso',+ 'assistant.card.common.changed': 'Modificato',+ 'assistant.card.common.willDelete': 'Verrà eliminato',+ 'assistant.card.common.noLonger': 'Non più: {names}',+ 'assistant.card.common.you': 'Tu',+ 'assistant.card.common.showDay': 'Mostra questo giorno nel piano',+};+export default assistantCard;diff --git a/shared/src/i18n/it/assistantCollab.ts b/shared/src/i18n/it/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/it/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/it/assistantCollection.ts b/shared/src/i18n/it/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/it/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/it/assistantJourney.ts b/shared/src/i18n/it/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/it/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/it/assistantPacking.ts b/shared/src/i18n/it/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/it/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/it/assistantRoadtrip.ts b/shared/src/i18n/it/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/it/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/it/assistantTour.ts b/shared/src/i18n/it/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/it/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/it/assistantVacay.ts b/shared/src/i18n/it/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/it/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/it/index.ts b/shared/src/i18n/it/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/it/index.ts+++ b/shared/src/i18n/it/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/ja/assistantAtlas.ts b/shared/src/i18n/ja/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/ja/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/ja/assistantBooking.ts b/shared/src/i18n/ja/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/ja/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/ja/assistantBudget.ts b/shared/src/i18n/ja/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/ja/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/ja/assistantCard.ts b/shared/src/i18n/ja/assistantCard.tsnew file mode 100644index 000000000..d53ff48d1--- /dev/null+++ b/shared/src/i18n/ja/assistantCard.ts@@ -0,0 +1,14 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': '開く',+ 'assistant.card.common.more': 'ほか {count} 件',+ 'assistant.card.common.new': '新規',+ 'assistant.card.common.removed': '除外',+ 'assistant.card.common.changed': '変更',+ 'assistant.card.common.willDelete': '削除されます',+ 'assistant.card.common.noLonger': 'もう含まれない: {names}',+ 'assistant.card.common.you': '自分',+ 'assistant.card.common.showDay': 'この日をプランで表示',+};+export default assistantCard;diff --git a/shared/src/i18n/ja/assistantCollab.ts b/shared/src/i18n/ja/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/ja/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/ja/assistantCollection.ts b/shared/src/i18n/ja/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/ja/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/ja/assistantJourney.ts b/shared/src/i18n/ja/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/ja/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/ja/assistantPacking.ts b/shared/src/i18n/ja/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/ja/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/ja/assistantRoadtrip.ts b/shared/src/i18n/ja/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/ja/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/ja/assistantTour.ts b/shared/src/i18n/ja/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/ja/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/ja/assistantVacay.ts b/shared/src/i18n/ja/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/ja/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/ja/index.ts b/shared/src/i18n/ja/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/ja/index.ts+++ b/shared/src/i18n/ja/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/ko/assistantAtlas.ts b/shared/src/i18n/ko/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/ko/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/ko/assistantBooking.ts b/shared/src/i18n/ko/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/ko/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/ko/assistantBudget.ts b/shared/src/i18n/ko/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/ko/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/ko/assistantCard.ts b/shared/src/i18n/ko/assistantCard.tsnew file mode 100644index 000000000..f4c732074--- /dev/null+++ b/shared/src/i18n/ko/assistantCard.ts@@ -0,0 +1,14 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': '열기',+ 'assistant.card.common.more': '{count}개 더',+ 'assistant.card.common.new': '새 항목',+ 'assistant.card.common.removed': '제외됨',+ 'assistant.card.common.changed': '변경됨',+ 'assistant.card.common.willDelete': '삭제 예정',+ 'assistant.card.common.noLonger': '더 이상 없음: {names}',+ 'assistant.card.common.you': '나',+ 'assistant.card.common.showDay': '이 날을 일정에서 보기',+};+export default assistantCard;diff --git a/shared/src/i18n/ko/assistantCollab.ts b/shared/src/i18n/ko/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/ko/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/ko/assistantCollection.ts b/shared/src/i18n/ko/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/ko/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/ko/assistantJourney.ts b/shared/src/i18n/ko/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/ko/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/ko/assistantPacking.ts b/shared/src/i18n/ko/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/ko/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/ko/assistantRoadtrip.ts b/shared/src/i18n/ko/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/ko/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/ko/assistantTour.ts b/shared/src/i18n/ko/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/ko/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/ko/assistantVacay.ts b/shared/src/i18n/ko/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/ko/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/ko/index.ts b/shared/src/i18n/ko/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/ko/index.ts+++ b/shared/src/i18n/ko/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/nl/assistantAtlas.ts b/shared/src/i18n/nl/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/nl/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/nl/assistantBooking.ts b/shared/src/i18n/nl/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/nl/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/nl/assistantBudget.ts b/shared/src/i18n/nl/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/nl/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/nl/assistantCard.ts b/shared/src/i18n/nl/assistantCard.tsnew file mode 100644index 000000000..8d4cc5981--- /dev/null+++ b/shared/src/i18n/nl/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Openen',+ 'assistant.card.common.more': 'nog {count}',+ 'assistant.card.common.more.one': 'nog {count}',+ 'assistant.card.common.new': 'Nieuw',+ 'assistant.card.common.removed': 'Verwijderd',+ 'assistant.card.common.changed': 'Gewijzigd',+ 'assistant.card.common.willDelete': 'Wordt verwijderd',+ 'assistant.card.common.noLonger': 'Niet meer: {names}',+ 'assistant.card.common.you': 'Jij',+ 'assistant.card.common.showDay': 'Deze dag in het plan tonen',+};+export default assistantCard;diff --git a/shared/src/i18n/nl/assistantCollab.ts b/shared/src/i18n/nl/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/nl/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/nl/assistantCollection.ts b/shared/src/i18n/nl/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/nl/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/nl/assistantJourney.ts b/shared/src/i18n/nl/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/nl/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/nl/assistantPacking.ts b/shared/src/i18n/nl/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/nl/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/nl/assistantRoadtrip.ts b/shared/src/i18n/nl/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/nl/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/nl/assistantTour.ts b/shared/src/i18n/nl/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/nl/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/nl/assistantVacay.ts b/shared/src/i18n/nl/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/nl/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/nl/index.ts b/shared/src/i18n/nl/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/nl/index.ts+++ b/shared/src/i18n/nl/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/pl/assistantAtlas.ts b/shared/src/i18n/pl/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/pl/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/pl/assistantBooking.ts b/shared/src/i18n/pl/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/pl/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/pl/assistantBudget.ts b/shared/src/i18n/pl/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/pl/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/pl/assistantCard.ts b/shared/src/i18n/pl/assistantCard.tsnew file mode 100644index 000000000..2c2d147b3--- /dev/null+++ b/shared/src/i18n/pl/assistantCard.ts@@ -0,0 +1,17 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Otwórz',+ 'assistant.card.common.more': 'jeszcze {count}',+ 'assistant.card.common.more.one': 'jeszcze {count}',+ 'assistant.card.common.more.few': 'jeszcze {count}',+ 'assistant.card.common.more.many': 'jeszcze {count}',+ 'assistant.card.common.new': 'Nowe',+ 'assistant.card.common.removed': 'Usunięte',+ 'assistant.card.common.changed': 'Zmienione',+ 'assistant.card.common.willDelete': 'Zostanie usunięte',+ 'assistant.card.common.noLonger': 'Już nie: {names}',+ 'assistant.card.common.you': 'Ty',+ 'assistant.card.common.showDay': 'Pokaż ten dzień w planie',+};+export default assistantCard;diff --git a/shared/src/i18n/pl/assistantCollab.ts b/shared/src/i18n/pl/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/pl/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/pl/assistantCollection.ts b/shared/src/i18n/pl/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/pl/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/pl/assistantJourney.ts b/shared/src/i18n/pl/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/pl/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/pl/assistantPacking.ts b/shared/src/i18n/pl/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/pl/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/pl/assistantRoadtrip.ts b/shared/src/i18n/pl/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/pl/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/pl/assistantTour.ts b/shared/src/i18n/pl/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/pl/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/pl/assistantVacay.ts b/shared/src/i18n/pl/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/pl/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/pl/index.ts b/shared/src/i18n/pl/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/pl/index.ts+++ b/shared/src/i18n/pl/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/ru/assistantAtlas.ts b/shared/src/i18n/ru/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/ru/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/ru/assistantBooking.ts b/shared/src/i18n/ru/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/ru/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/ru/assistantBudget.ts b/shared/src/i18n/ru/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/ru/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/ru/assistantCard.ts b/shared/src/i18n/ru/assistantCard.tsnew file mode 100644index 000000000..45126c696--- /dev/null+++ b/shared/src/i18n/ru/assistantCard.ts@@ -0,0 +1,17 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Открыть',+ 'assistant.card.common.more': 'ещё {count}',+ 'assistant.card.common.more.one': 'ещё {count}',+ 'assistant.card.common.more.few': 'ещё {count}',+ 'assistant.card.common.more.many': 'ещё {count}',+ 'assistant.card.common.new': 'Новое',+ 'assistant.card.common.removed': 'Убрано',+ 'assistant.card.common.changed': 'Изменено',+ 'assistant.card.common.willDelete': 'Будет удалено',+ 'assistant.card.common.noLonger': 'Больше нет: {names}',+ 'assistant.card.common.you': 'Вы',+ 'assistant.card.common.showDay': 'Показать этот день в плане',+};+export default assistantCard;diff --git a/shared/src/i18n/ru/assistantCollab.ts b/shared/src/i18n/ru/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/ru/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/ru/assistantCollection.ts b/shared/src/i18n/ru/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/ru/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/ru/assistantJourney.ts b/shared/src/i18n/ru/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/ru/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/ru/assistantPacking.ts b/shared/src/i18n/ru/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/ru/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/ru/assistantRoadtrip.ts b/shared/src/i18n/ru/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/ru/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/ru/assistantTour.ts b/shared/src/i18n/ru/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/ru/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/ru/assistantVacay.ts b/shared/src/i18n/ru/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/ru/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/ru/index.ts b/shared/src/i18n/ru/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/ru/index.ts+++ b/shared/src/i18n/ru/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/sk/assistantAtlas.ts b/shared/src/i18n/sk/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/sk/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/sk/assistantBooking.ts b/shared/src/i18n/sk/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/sk/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/sk/assistantBudget.ts b/shared/src/i18n/sk/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/sk/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/sk/assistantCard.ts b/shared/src/i18n/sk/assistantCard.tsnew file mode 100644index 000000000..10cf2ad23--- /dev/null+++ b/shared/src/i18n/sk/assistantCard.ts@@ -0,0 +1,16 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Otvoriť',+ 'assistant.card.common.more': '{count} ďalších',+ 'assistant.card.common.more.one': '{count} ďalšia',+ 'assistant.card.common.more.few': '{count} ďalšie',+ 'assistant.card.common.new': 'Nové',+ 'assistant.card.common.removed': 'Odstránené',+ 'assistant.card.common.changed': 'Zmenené',+ 'assistant.card.common.willDelete': 'Bude zmazané',+ 'assistant.card.common.noLonger': 'Už nie: {names}',+ 'assistant.card.common.you': 'Vy',+ 'assistant.card.common.showDay': 'Zobraziť tento deň v pláne',+};+export default assistantCard;diff --git a/shared/src/i18n/sk/assistantCollab.ts b/shared/src/i18n/sk/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/sk/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/sk/assistantCollection.ts b/shared/src/i18n/sk/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/sk/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/sk/assistantJourney.ts b/shared/src/i18n/sk/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/sk/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/sk/assistantPacking.ts b/shared/src/i18n/sk/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/sk/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/sk/assistantRoadtrip.ts b/shared/src/i18n/sk/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/sk/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/sk/assistantTour.ts b/shared/src/i18n/sk/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/sk/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/sk/assistantVacay.ts b/shared/src/i18n/sk/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/sk/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/sk/index.ts b/shared/src/i18n/sk/index.tsindex 6b9d2525e..d7e6e9c6a 100644--- a/shared/src/i18n/sk/index.ts+++ b/shared/src/i18n/sk/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/sv/assistantAtlas.ts b/shared/src/i18n/sv/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/sv/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/sv/assistantBooking.ts b/shared/src/i18n/sv/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/sv/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/sv/assistantBudget.ts b/shared/src/i18n/sv/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/sv/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/sv/assistantCard.ts b/shared/src/i18n/sv/assistantCard.tsnew file mode 100644index 000000000..9ffa1790f--- /dev/null+++ b/shared/src/i18n/sv/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Öppna',+ 'assistant.card.common.more': '{count} till',+ 'assistant.card.common.more.one': '{count} till',+ 'assistant.card.common.new': 'Ny',+ 'assistant.card.common.removed': 'Borttagen',+ 'assistant.card.common.changed': 'Ändrad',+ 'assistant.card.common.willDelete': 'Tas bort',+ 'assistant.card.common.noLonger': 'Inte längre: {names}',+ 'assistant.card.common.you': 'Du',+ 'assistant.card.common.showDay': 'Visa dagen i planen',+};+export default assistantCard;diff --git a/shared/src/i18n/sv/assistantCollab.ts b/shared/src/i18n/sv/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/sv/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/sv/assistantCollection.ts b/shared/src/i18n/sv/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/sv/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/sv/assistantJourney.ts b/shared/src/i18n/sv/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/sv/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/sv/assistantPacking.ts b/shared/src/i18n/sv/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/sv/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/sv/assistantRoadtrip.ts b/shared/src/i18n/sv/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/sv/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/sv/assistantTour.ts b/shared/src/i18n/sv/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/sv/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/sv/assistantVacay.ts b/shared/src/i18n/sv/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/sv/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/sv/index.ts b/shared/src/i18n/sv/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/sv/index.ts+++ b/shared/src/i18n/sv/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/th/assistantAtlas.ts b/shared/src/i18n/th/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/th/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/th/assistantBooking.ts b/shared/src/i18n/th/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/th/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/th/assistantBudget.ts b/shared/src/i18n/th/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/th/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/th/assistantCard.ts b/shared/src/i18n/th/assistantCard.tsnew file mode 100644index 000000000..fc64c3467--- /dev/null+++ b/shared/src/i18n/th/assistantCard.ts@@ -0,0 +1,14 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'เปิด',+ 'assistant.card.common.more': 'อีก {count} รายการ',+ 'assistant.card.common.new': 'ใหม่',+ 'assistant.card.common.removed': 'นำออกแล้ว',+ 'assistant.card.common.changed': 'เปลี่ยนแล้ว',+ 'assistant.card.common.willDelete': 'จะถูกลบ',+ 'assistant.card.common.noLonger': 'ไม่มีแล้ว: {names}',+ 'assistant.card.common.you': 'คุณ',+ 'assistant.card.common.showDay': 'แสดงวันนั้นในแผน',+};+export default assistantCard;diff --git a/shared/src/i18n/th/assistantCollab.ts b/shared/src/i18n/th/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/th/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/th/assistantCollection.ts b/shared/src/i18n/th/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/th/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/th/assistantJourney.ts b/shared/src/i18n/th/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/th/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/th/assistantPacking.ts b/shared/src/i18n/th/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/th/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/th/assistantRoadtrip.ts b/shared/src/i18n/th/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/th/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/th/assistantTour.ts b/shared/src/i18n/th/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/th/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/th/assistantVacay.ts b/shared/src/i18n/th/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/th/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/th/index.ts b/shared/src/i18n/th/index.tsindex 6b9d2525e..d7e6e9c6a 100644--- a/shared/src/i18n/th/index.ts+++ b/shared/src/i18n/th/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/tr/assistantAtlas.ts b/shared/src/i18n/tr/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/tr/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/tr/assistantBooking.ts b/shared/src/i18n/tr/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/tr/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/tr/assistantBudget.ts b/shared/src/i18n/tr/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/tr/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/tr/assistantCard.ts b/shared/src/i18n/tr/assistantCard.tsnew file mode 100644index 000000000..10c80a33c--- /dev/null+++ b/shared/src/i18n/tr/assistantCard.ts@@ -0,0 +1,15 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Aç',+ 'assistant.card.common.more': '{count} tane daha',+ 'assistant.card.common.more.one': '{count} tane daha',+ 'assistant.card.common.new': 'Yeni',+ 'assistant.card.common.removed': 'Kaldırıldı',+ 'assistant.card.common.changed': 'Değişti',+ 'assistant.card.common.willDelete': 'Silinecek',+ 'assistant.card.common.noLonger': 'Artık yok: {names}',+ 'assistant.card.common.you': 'Siz',+ 'assistant.card.common.showDay': 'Bu günü planda göster',+};+export default assistantCard;diff --git a/shared/src/i18n/tr/assistantCollab.ts b/shared/src/i18n/tr/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/tr/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/tr/assistantCollection.ts b/shared/src/i18n/tr/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/tr/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/tr/assistantJourney.ts b/shared/src/i18n/tr/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/tr/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/tr/assistantPacking.ts b/shared/src/i18n/tr/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/tr/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/tr/assistantRoadtrip.ts b/shared/src/i18n/tr/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/tr/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/tr/assistantTour.ts b/shared/src/i18n/tr/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/tr/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/tr/assistantVacay.ts b/shared/src/i18n/tr/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/tr/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/tr/index.ts b/shared/src/i18n/tr/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/tr/index.ts+++ b/shared/src/i18n/tr/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/uk/assistantAtlas.ts b/shared/src/i18n/uk/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/uk/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/uk/assistantBooking.ts b/shared/src/i18n/uk/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/uk/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/uk/assistantBudget.ts b/shared/src/i18n/uk/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/uk/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/uk/assistantCard.ts b/shared/src/i18n/uk/assistantCard.tsnew file mode 100644index 000000000..329181b37--- /dev/null+++ b/shared/src/i18n/uk/assistantCard.ts@@ -0,0 +1,17 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Відкрити',+ 'assistant.card.common.more': 'ще {count}',+ 'assistant.card.common.more.one': 'ще {count}',+ 'assistant.card.common.more.few': 'ще {count}',+ 'assistant.card.common.more.many': 'ще {count}',+ 'assistant.card.common.new': 'Нове',+ 'assistant.card.common.removed': 'Прибрано',+ 'assistant.card.common.changed': 'Змінено',+ 'assistant.card.common.willDelete': 'Буде видалено',+ 'assistant.card.common.noLonger': 'Більше немає: {names}',+ 'assistant.card.common.you': 'Ви',+ 'assistant.card.common.showDay': 'Показати цей день у плані',+};+export default assistantCard;diff --git a/shared/src/i18n/uk/assistantCollab.ts b/shared/src/i18n/uk/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/uk/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/uk/assistantCollection.ts b/shared/src/i18n/uk/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/uk/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/uk/assistantJourney.ts b/shared/src/i18n/uk/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/uk/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/uk/assistantPacking.ts b/shared/src/i18n/uk/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/uk/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/uk/assistantRoadtrip.ts b/shared/src/i18n/uk/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/uk/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/uk/assistantTour.ts b/shared/src/i18n/uk/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/uk/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/uk/assistantVacay.ts b/shared/src/i18n/uk/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/uk/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/uk/index.ts b/shared/src/i18n/uk/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/uk/index.ts+++ b/shared/src/i18n/uk/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/vi/assistantAtlas.ts b/shared/src/i18n/vi/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/vi/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/vi/assistantBooking.ts b/shared/src/i18n/vi/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/vi/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/vi/assistantBudget.ts b/shared/src/i18n/vi/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/vi/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/vi/assistantCard.ts b/shared/src/i18n/vi/assistantCard.tsnew file mode 100644index 000000000..ed5abbc9a--- /dev/null+++ b/shared/src/i18n/vi/assistantCard.ts@@ -0,0 +1,14 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': 'Mở',+ 'assistant.card.common.more': 'thêm {count}',+ 'assistant.card.common.new': 'Mới',+ 'assistant.card.common.removed': 'Đã bỏ',+ 'assistant.card.common.changed': 'Đã đổi',+ 'assistant.card.common.willDelete': 'Sẽ bị xóa',+ 'assistant.card.common.noLonger': 'Không còn: {names}',+ 'assistant.card.common.you': 'Bạn',+ 'assistant.card.common.showDay': 'Hiện ngày này trong kế hoạch',+};+export default assistantCard;diff --git a/shared/src/i18n/vi/assistantCollab.ts b/shared/src/i18n/vi/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/vi/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/vi/assistantCollection.ts b/shared/src/i18n/vi/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/vi/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/vi/assistantJourney.ts b/shared/src/i18n/vi/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/vi/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/vi/assistantPacking.ts b/shared/src/i18n/vi/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/vi/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/vi/assistantRoadtrip.ts b/shared/src/i18n/vi/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/vi/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/vi/assistantTour.ts b/shared/src/i18n/vi/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/vi/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/vi/assistantVacay.ts b/shared/src/i18n/vi/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/vi/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/vi/index.ts b/shared/src/i18n/vi/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/vi/index.ts+++ b/shared/src/i18n/vi/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/zh-TW/assistantAtlas.ts b/shared/src/i18n/zh-TW/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/zh-TW/assistantBooking.ts b/shared/src/i18n/zh-TW/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/zh-TW/assistantBudget.ts b/shared/src/i18n/zh-TW/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/zh-TW/assistantCard.ts b/shared/src/i18n/zh-TW/assistantCard.tsnew file mode 100644index 000000000..c49013f63--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantCard.ts@@ -0,0 +1,14 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': '開啟',+ 'assistant.card.common.more': '還有 {count} 項',+ 'assistant.card.common.new': '新增',+ 'assistant.card.common.removed': '已移除',+ 'assistant.card.common.changed': '已變更',+ 'assistant.card.common.willDelete': '將被刪除',+ 'assistant.card.common.noLonger': '不再包括:{names}',+ 'assistant.card.common.you': '你',+ 'assistant.card.common.showDay': '在計畫中顯示這一天',+};+export default assistantCard;diff --git a/shared/src/i18n/zh-TW/assistantCollab.ts b/shared/src/i18n/zh-TW/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/zh-TW/assistantCollection.ts b/shared/src/i18n/zh-TW/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/zh-TW/assistantJourney.ts b/shared/src/i18n/zh-TW/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/zh-TW/assistantPacking.ts b/shared/src/i18n/zh-TW/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/zh-TW/assistantRoadtrip.ts b/shared/src/i18n/zh-TW/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/zh-TW/assistantTour.ts b/shared/src/i18n/zh-TW/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/zh-TW/assistantVacay.ts b/shared/src/i18n/zh-TW/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/zh-TW/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/zh-TW/index.ts b/shared/src/i18n/zh-TW/index.tsindex 6b99b1095..467792e71 100644--- a/shared/src/i18n/zh-TW/index.ts+++ b/shared/src/i18n/zh-TW/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/i18n/zh/assistantAtlas.ts b/shared/src/i18n/zh/assistantAtlas.tsnew file mode 100644index 000000000..3d8e7daa8--- /dev/null+++ b/shared/src/i18n/zh/assistantAtlas.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantAtlas: TranslationStrings = {};+export default assistantAtlas;diff --git a/shared/src/i18n/zh/assistantBooking.ts b/shared/src/i18n/zh/assistantBooking.tsnew file mode 100644index 000000000..0c637cab3--- /dev/null+++ b/shared/src/i18n/zh/assistantBooking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBooking: TranslationStrings = {};+export default assistantBooking;diff --git a/shared/src/i18n/zh/assistantBudget.ts b/shared/src/i18n/zh/assistantBudget.tsnew file mode 100644index 000000000..838ca0be1--- /dev/null+++ b/shared/src/i18n/zh/assistantBudget.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantBudget: TranslationStrings = {};+export default assistantBudget;diff --git a/shared/src/i18n/zh/assistantCard.ts b/shared/src/i18n/zh/assistantCard.tsnew file mode 100644index 000000000..61453c717--- /dev/null+++ b/shared/src/i18n/zh/assistantCard.ts@@ -0,0 +1,14 @@+import type { TranslationStrings } from '../types';++const assistantCard: TranslationStrings = {+ 'assistant.card.common.open': '打开',+ 'assistant.card.common.more': '还有 {count} 项',+ 'assistant.card.common.new': '新增',+ 'assistant.card.common.removed': '已移除',+ 'assistant.card.common.changed': '已更改',+ 'assistant.card.common.willDelete': '将被删除',+ 'assistant.card.common.noLonger': '不再包括:{names}',+ 'assistant.card.common.you': '你',+ 'assistant.card.common.showDay': '在计划中显示这一天',+};+export default assistantCard;diff --git a/shared/src/i18n/zh/assistantCollab.ts b/shared/src/i18n/zh/assistantCollab.tsnew file mode 100644index 000000000..7c6b29aa8--- /dev/null+++ b/shared/src/i18n/zh/assistantCollab.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollab: TranslationStrings = {};+export default assistantCollab;diff --git a/shared/src/i18n/zh/assistantCollection.ts b/shared/src/i18n/zh/assistantCollection.tsnew file mode 100644index 000000000..2c7b637f5--- /dev/null+++ b/shared/src/i18n/zh/assistantCollection.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantCollection: TranslationStrings = {};+export default assistantCollection;diff --git a/shared/src/i18n/zh/assistantJourney.ts b/shared/src/i18n/zh/assistantJourney.tsnew file mode 100644index 000000000..dc8d923a4--- /dev/null+++ b/shared/src/i18n/zh/assistantJourney.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantJourney: TranslationStrings = {};+export default assistantJourney;diff --git a/shared/src/i18n/zh/assistantPacking.ts b/shared/src/i18n/zh/assistantPacking.tsnew file mode 100644index 000000000..269292a52--- /dev/null+++ b/shared/src/i18n/zh/assistantPacking.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantPacking: TranslationStrings = {};+export default assistantPacking;diff --git a/shared/src/i18n/zh/assistantRoadtrip.ts b/shared/src/i18n/zh/assistantRoadtrip.tsnew file mode 100644index 000000000..7d35155c1--- /dev/null+++ b/shared/src/i18n/zh/assistantRoadtrip.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantRoadtrip: TranslationStrings = {};+export default assistantRoadtrip;diff --git a/shared/src/i18n/zh/assistantTour.ts b/shared/src/i18n/zh/assistantTour.tsnew file mode 100644index 000000000..5acd3a57e--- /dev/null+++ b/shared/src/i18n/zh/assistantTour.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantTour: TranslationStrings = {};+export default assistantTour;diff --git a/shared/src/i18n/zh/assistantVacay.ts b/shared/src/i18n/zh/assistantVacay.tsnew file mode 100644index 000000000..0a509629a--- /dev/null+++ b/shared/src/i18n/zh/assistantVacay.ts@@ -0,0 +1,4 @@+import type { TranslationStrings } from '../types';++const assistantVacay: TranslationStrings = {};+export default assistantVacay;diff --git a/shared/src/i18n/zh/index.ts b/shared/src/i18n/zh/index.tsindex 06a488395..ac45f1ade 100644--- a/shared/src/i18n/zh/index.ts+++ b/shared/src/i18n/zh/index.ts@@ -1,6 +1,17 @@import admin from './admin';import airport from './airport';import assistant from './assistant';+import assistantAtlas from './assistantAtlas';+import assistantBooking from './assistantBooking';+import assistantBudget from './assistantBudget';+import assistantCard from './assistantCard';+import assistantCollab from './assistantCollab';+import assistantCollection from './assistantCollection';+import assistantJourney from './assistantJourney';+import assistantPacking from './assistantPacking';+import assistantRoadtrip from './assistantRoadtrip';+import assistantTour from './assistantTour';+import assistantVacay from './assistantVacay';import atlas from './atlas';import backup from './backup';import budget from './budget';@@ -118,5 +129,16 @@ const locale = {...docsync,...ferratas,...assistant,+ ...assistantCard,+ ...assistantTour,+ ...assistantRoadtrip,+ ...assistantBudget,+ ...assistantBooking,+ ...assistantCollab,+ ...assistantCollection,+ ...assistantAtlas,+ ...assistantVacay,+ ...assistantJourney,+ ...assistantPacking,};export default locale;diff --git a/shared/src/index.ts b/shared/src/index.tsindex f971ba175..52b2ab01d 100644--- a/shared/src/index.ts+++ b/shared/src/index.ts@@ -84,6 +84,9 @@ export * from './tours/tours.metrics';export * from './tours/hiking-costing';export * from './tours/hike-plan.schema';export * from './tours/tour-hike.schema';+export * from './tours/tour-display.schema';+export * from './tours/line-along';+export * from './tours/hike-schedule';export * from './tours/tour-gpx-import.schema';export * from './tours/paddle-plan.schema';export * from './tours/paddle-plan';@@ -113,6 +116,25 @@ export * from './journey/trip-journal-link.schema';export * from './book/book.schema';export * from './book/journey-stats.schema';export * from './book/book-store.schema';+export * from './book/book-ids';+export * from './book/book-layouts';+export * from './book/book-grids';+export * from './book/book-saved-layouts';+export * from './book/book-pages';+export * from './book/book-ops.schema';+export {+ BOOK_OP_ERROR_CODES,+ type BookEditResult,+ type BookJourneyWords,+ type BookOpError,+ type BookOpErrorCode,+ type BookOpsContext,+ type BookPhotoInfo,+} from './book/book-ops-core';+export * from './book/book-ops';+export * from './book/book-page-ops';+export * from './book/book-findings';+export * from './book/describe-spread';export * from './share/share.schema';export * from './storage/storage.schema';export * from './settings/settings.schema';@@ -126,6 +148,7 @@ export * from './oauth/oauth.schema';export * from './admin/admin.schema';export * from './ai/ai-connections.schema';export * from './assistant/assistant.schema';+export * from './assistant/cards';export * from './assistant/assistant-share.schema';// Realtime WS event contract registry (event names + payload schemas)