Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(scheduling): attach a Macro call from booking links (#7995)
juliawest46ac287f74d0
diff --git a/Cargo.lock b/Cargo.lockindex c3d21c5a51..292e17e153 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3607,6 +3607,7 @@ dependencies = ["tokio","tracing","uuid",+ "wiremock","workspace-hack",]@@ -16546,9 +16547,9 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"[[package]]name = "ruzstd"-version = "0.8.3"+version = "0.9.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a7c1c839d570d835527c9a5e4db7cb2198683a988cb9d7293fc8674e6bd58fc8"+checksum = "69e4ce4a039f42bf25920b95667e4d789e98749ab11bbb8d2c2936f788421bb5"[[package]]name = "ryu"diff --git a/Cargo.toml b/Cargo.tomlindex 2cf2fff4a7..5bd6f1aa6e 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -338,7 +338,7 @@ rustix = { version = "1", default-features = false, features = ["process", "std"rootcause-tracing = "0.12.1"schemars = { version = "1.0.4", features = ["chrono04", "uuid1"] }semver = { version = "1", features = ["serde"] }-ruzstd = { version = "0.8", default-features = false, features = ["std"] }+ruzstd = { version = "0.9", default-features = false, features = ["std"] }serde = { version = "1.0.214", features = ["derive"] }serde-wasm-bindgen = "0.6"serde_dynamo = { version = "4", features = ["aws-sdk-dynamodb+1"] }diff --git a/apps/docs/AI/mcp/tools/create-booking-link.mdx b/apps/docs/AI/mcp/tools/create-booking-link.mdxindex 1a2258bbaa..603d17d92c 100644--- a/apps/docs/AI/mcp/tools/create-booking-link.mdx+++ b/apps/docs/AI/mcp/tools/create-booking-link.mdx@@ -6,7 +6,7 @@ description: >-# CreateBookingLink-Create a reusable booking page, not a calendar meeting. First use ListBookingLinks to discover a suitable existing link or reuse availability. Supply a full draft with all seven weekdays (Sunday=0), IANA time zone, and real host IDs; personal links use the authenticated user and individual mode. For a team use a real team ID and collective or roundRobin mode. Set enabled only when the user wants to accept bookings. No invitations are sent by creating a link. Repeating an identical draft with the same slug reuses the saved link; a different draft at that slug conflicts. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar.+Create a reusable booking page, not a calendar meeting. First use ListBookingLinks to discover a suitable existing link or reuse availability. Supply a full draft with all seven weekdays (Sunday=0), IANA time zone, and real host IDs; personal links use the authenticated user and individual mode. For a team use a real team ID and collective or roundRobin mode. Set enabled only when the user wants to accept bookings. No invitations are sent by creating a link. Repeating an identical draft with the same slug reuses the saved link; a different draft at that slug conflicts. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location, Macro call, or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar. For video, set macroCall (preferred) or googleMeet, never both. Booking a macroCall link creates the call and attaches its join link to the invitation.## Parametersdiff --git a/apps/docs/AI/mcp/tools/edit-booking-link.mdx b/apps/docs/AI/mcp/tools/edit-booking-link.mdxindex ab9ca122cb..0b106a46dd 100644--- a/apps/docs/AI/mcp/tools/edit-booking-link.mdx+++ b/apps/docs/AI/mcp/tools/edit-booking-link.mdx@@ -6,7 +6,7 @@ description: >-# EditBookingLink-Edit exactly one existing booking link. First read it with ListBookingLinks, preserve all settings the user did not request changing, and pass its revision and full edited draft. Changed availability applies only to this link; other links and personal default hours remain unchanged. A stale revision fails: read again and confirm the updated proposal in conversation instead of overwriting concurrent edits. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar.+Edit exactly one existing booking link. First read it with ListBookingLinks, preserve all settings the user did not request changing, and pass its revision and full edited draft. Changed availability applies only to this link; other links and personal default hours remain unchanged. A stale revision fails: read again and confirm the updated proposal in conversation instead of overwriting concurrent edits. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location, Macro call, or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar. For video, set macroCall (preferred) or googleMeet, never both. Booking a macroCall link creates the call and attaches its join link to the invitation.## Parametersdiff --git a/apps/web/src/features/block-form/views/builder-view.test.tsx b/apps/web/src/features/block-form/views/builder-view.test.tsxindex af9f8a2cc1..ea5bf785a1 100644--- a/apps/web/src/features/block-form/views/builder-view.test.tsx+++ b/apps/web/src/features/block-form/views/builder-view.test.tsx@@ -865,6 +865,7 @@ describe('BuilderView', () => {description: '',durationMinutes: 30,location: '',+ macroCall: false,googleMeet: true,questions: [],requiresConfirmation: false,@@ -1029,6 +1030,7 @@ describe('BuilderView', () => {description: '',durationMinutes: 60,location: '',+ macroCall: false,googleMeet: true,questions: [],requiresConfirmation: false,diff --git a/apps/web/src/features/block-form/views/respond-view.test.tsx b/apps/web/src/features/block-form/views/respond-view.test.tsxindex 67680d2259..3fbc786655 100644--- a/apps/web/src/features/block-form/views/respond-view.test.tsx+++ b/apps/web/src/features/block-form/views/respond-view.test.tsx@@ -452,6 +452,7 @@ describe('RespondView', () => {description: 'A short hello.',durationMinutes: 30,location: '',+ macroCall: false,googleMeet: true,questions: [],requiresConfirmation: false,diff --git a/apps/web/src/features/scheduling/browser-test/fixture.tsx b/apps/web/src/features/scheduling/browser-test/fixture.tsxindex 6fcd3e64a1..5b8f979d7a 100644--- a/apps/web/src/features/scheduling/browser-test/fixture.tsx+++ b/apps/web/src/features/scheduling/browser-test/fixture.tsx@@ -420,7 +420,11 @@ function Fixture() {timeZone: r.timeZone,hosts: e.hosts,status: e.requiresConfirmation ? 'pending' : 'confirmed',- location: 'Google Meet',+ location: e.macroCall+ ? 'https://macro.com/app/meet/join/0123456789abcdef0123456789abcdef'+ : e.googleMeet+ ? 'Google Meet'+ : e.location,answers: r.answers,};setBookings([...bookings(), booking]);diff --git a/apps/web/src/features/scheduling/components/booking-picker.test.tsx b/apps/web/src/features/scheduling/components/booking-picker.test.tsxindex c5b0871463..b537dfbce6 100644--- a/apps/web/src/features/scheduling/components/booking-picker.test.tsx+++ b/apps/web/src/features/scheduling/components/booking-picker.test.tsx@@ -32,6 +32,7 @@ const intro: PublicEvent = {description: 'A short hello.',durationMinutes: 30,location: '',+ macroCall: false,googleMeet: true,questions: [{ id: 'question-topic', label: 'What should we cover?', required: true },@@ -47,6 +48,7 @@ const review: PublicEvent = {description: 'An hour on your designs.',durationMinutes: 60,location: 'Studio 4',+ macroCall: false,googleMeet: false,questions: [],requiresConfirmation: true,@@ -111,6 +113,19 @@ async function fillDetails(user: ReturnType<typeof userEvent.setup>) {}describe('BookingPicker', () => {+ it('names a Macro call on the booking page', () => {+ render(() => (+ <BookingPicker+ profile={profile}+ event={{ ...intro, macroCall: true, googleMeet: false }}+ source={{ slots: vi.fn(), book: vi.fn() }}+ onReceipt={vi.fn()}+ />+ ));+ expect(screen.getByText('Macro call')).toBeTruthy();+ expect(screen.queryByText('Google Meet')).toBeNull();+ });+it('books the chosen time with the attendee details and hands back the receipt', async () => {const user = userEvent.setup();const source: BookingSource = {diff --git a/apps/web/src/features/scheduling/components/booking-picker.tsx b/apps/web/src/features/scheduling/components/booking-picker.tsxindex ba4bf58dd0..dbbe905e25 100644--- a/apps/web/src/features/scheduling/components/booking-picker.tsx+++ b/apps/web/src/features/scheduling/components/booking-picker.tsx@@ -7,7 +7,12 @@ import {on,Show,} from 'solid-js';-import type { BookingReceipt, PublicEvent, PublicProfile } from '../core/types';+import {+ type BookingReceipt,+ meetingPlaceLabel,+ type PublicEvent,+ type PublicProfile,+} from '../core/types';import {type BookingSource,createBookingFlow,@@ -113,9 +118,7 @@ export function BookingPicker(props: {<p class="text-sm text-ink-muted">{props.profile.name}</p><h2 class="mt-3 text-2xl font-semibold">{event().title}</h2><p class="mt-5 text-sm">◷ {event().durationMinutes} minutes</p>- <p class="mt-3 text-sm">- {event().googleMeet ? 'Google Meet' : event().location || 'Meeting'}- </p>+ <p class="mt-3 text-sm">{meetingPlaceLabel(event())}</p><p class="mt-5 whitespace-pre-wrap text-sm leading-relaxed text-ink-muted">{event().description}</p>diff --git a/apps/web/src/features/scheduling/components/event-editor.tsx b/apps/web/src/features/scheduling/components/event-editor.tsxindex a378d61ea1..b677ba53f3 100644--- a/apps/web/src/features/scheduling/components/event-editor.tsx+++ b/apps/web/src/features/scheduling/components/event-editor.tsx@@ -145,14 +145,42 @@ export function EventEditor(props: {}/></Field>- <CheckField- checked={draft().googleMeet}- onChange={(v) => update('googleMeet', v)}- label="Create a Google Meet link"- />+ <Field+ label="Video"+ hint={+ draft().macroCall+ ? 'A Macro call is created when someone books and added to the calendar invitation.'+ : draft().googleMeet+ ? 'A Google Meet link is created when someone books.'+ : 'Guests only see the location you enter.'+ }+ >+ <SelectInput+ label="Video"+ value={+ draft().macroCall+ ? 'macro'+ : draft().googleMeet+ ? 'google_meet'+ : 'none'+ }+ options={[+ { value: 'macro', label: 'Macro call' },+ { value: 'google_meet', label: 'Google Meet' },+ { value: 'none', label: 'No video link' },+ ]}+ onChange={(value) =>+ setDraft((current) => ({+ ...current,+ macroCall: value === 'macro',+ googleMeet: value === 'google_meet',+ }))+ }+ />+ </Field><Fieldlabel={- draft().googleMeet+ draft().macroCall || draft().googleMeet? 'Additional location details': 'Location or meeting URL'}diff --git a/apps/web/src/features/scheduling/core/types.test.ts b/apps/web/src/features/scheduling/core/types.test.tsindex c76068b119..d055998517 100644--- a/apps/web/src/features/scheduling/core/types.test.ts+++ b/apps/web/src/features/scheduling/core/types.test.ts@@ -1,5 +1,6 @@import { describe, expect, it } from 'vitest';import {+ meetingPlaceLabel,newEventType,newSchedule,validateEvent,@@ -31,4 +32,21 @@ describe('scheduling form validation', () => {);expect(validateEvent(event, [])).toBeUndefined();});+ it('defaults a new link to a Macro call', () => {+ const event = newEventType('schedule', ['host'], false);+ expect(event.macroCall).toBe(true);+ expect(event.googleMeet).toBe(false);+ expect(meetingPlaceLabel(event)).toBe('Macro call');+ expect(+ meetingPlaceLabel({ ...event, macroCall: false, googleMeet: true })+ ).toBe('Google Meet');+ expect(+ meetingPlaceLabel({+ ...event,+ macroCall: false,+ googleMeet: false,+ location: 'Studio 4',+ })+ ).toBe('Studio 4');+ });});diff --git a/apps/web/src/features/scheduling/core/types.ts b/apps/web/src/features/scheduling/core/types.tsindex ee8ae2a407..81861651e5 100644--- a/apps/web/src/features/scheduling/core/types.ts+++ b/apps/web/src/features/scheduling/core/types.ts@@ -17,6 +17,8 @@ export type EventType = {description: string;durationMinutes: number;location: string;+ /** Create a Macro call and attach its join link when someone books. */+ macroCall: boolean;googleMeet: boolean;enabled: boolean;scheduleId: string;@@ -78,6 +80,7 @@ export type PublicEvent = Pick<| 'description'| 'durationMinutes'| 'location'+ | 'macroCall'| 'googleMeet'| 'questions'| 'requiresConfirmation'@@ -137,7 +140,8 @@ export function newEventType(description: '',durationMinutes: 30,location: '',- googleMeet: true,+ macroCall: true,+ googleMeet: false,enabled: false,scheduleId,mode: team ? 'collective' : 'individual',@@ -167,7 +171,8 @@ export function newDefaultBookingLink(description: `Book a meeting with ${displayName}`,durationMinutes: 30,location: '',- googleMeet: true,+ macroCall: true,+ googleMeet: false,enabled: true,scheduleId,mode: 'individual',@@ -183,6 +188,17 @@ export function newDefaultBookingLink(};}+/** What guests see as the meeting place before a join link exists. */+export function meetingPlaceLabel(event: {+ macroCall?: boolean;+ googleMeet: boolean;+ location: string;+}): string {+ if (event.macroCall) return 'Macro call';+ if (event.googleMeet) return 'Google Meet';+ return event.location || 'Meeting';+}+export function slugify(value: string): string {return value.toLowerCase()diff --git a/apps/web/src/features/scheduling/views/public-booking-view.tsx b/apps/web/src/features/scheduling/views/public-booking-view.tsxindex 4e91b90a4f..1e5b67668a 100644--- a/apps/web/src/features/scheduling/views/public-booking-view.tsx+++ b/apps/web/src/features/scheduling/views/public-booking-view.tsx@@ -1,6 +1,11 @@import { For, Show } from 'solid-js';import { BookingPicker } from '../components/booking-picker';-import type { BookingReceipt, PublicEvent, PublicProfile } from '../core/types';+import {+ type BookingReceipt,+ meetingPlaceLabel,+ type PublicEvent,+ type PublicProfile,+} from '../core/types';import type { BookingSource } from '../primitives/booking-flow';export function PublicBookingView(props: {@@ -50,9 +55,7 @@ export function PublicBookingView(props: {</h2><p class="mt-2 text-sm text-ink-muted">{event.durationMinutes} minutes ·{' '}- {event.googleMeet- ? 'Google Meet'- : event.location || 'Meeting'}+ {meetingPlaceLabel(event)}</p><p class="mt-3 text-sm text-ink-muted">{event.description}diff --git a/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts b/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.tsindex bf98092632..469df2e259 100644--- a/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts+++ b/apps/web/src/lib/service-clients/service-cognition/generated/tools/schemas.ts@@ -1762,6 +1762,7 @@ export const CreateBookingLink = zdescription: z.string(),durationMinutes: z.number().int().gte(0).lte(65535),location: z.string(),+ macroCall: z.boolean().optional(),googleMeet: z.boolean(),enabled: z.boolean(),mode: z.any().superRefine((x, ctx) => {@@ -1847,6 +1848,7 @@ export const BookingLinkResult = z.object({description: z.string(),durationMinutes: z.number().int().gte(0).lte(65535),location: z.string(),+ macroCall: z.boolean().optional(),googleMeet: z.boolean(),enabled: z.boolean(),mode: z.any().superRefine((x, ctx) => {@@ -4493,6 +4495,7 @@ export const EditBookingLink = zdescription: z.string(),durationMinutes: z.number().int().gte(0).lte(65535),location: z.string(),+ macroCall: z.boolean().optional(),googleMeet: z.boolean(),enabled: z.boolean(),mode: z.any().superRefine((x, ctx) => {@@ -8917,6 +8920,7 @@ export const ListBookingLinksResult = z.object({description: z.string(),durationMinutes: z.number().int().gte(0).lte(65535),location: z.string(),+ macroCall: z.boolean().optional(),googleMeet: z.boolean(),enabled: z.boolean(),mode: z.any().superRefine((x, ctx) => {@@ -11003,6 +11007,7 @@ export const BookingSettingsResult = z.object({description: z.string(),durationMinutes: z.number().int().gte(0).lte(65535),location: z.string(),+ macroCall: z.boolean().optional(),googleMeet: z.boolean(),enabled: z.boolean(),scheduleId: z.string().uuid(),@@ -14711,6 +14716,7 @@ export const UpdateBookingSettings = zdescription: z.string(),durationMinutes: z.number().int().gte(0).lte(65535),location: z.string(),+ macroCall: z.boolean().optional(),googleMeet: z.boolean(),enabled: z.boolean(),scheduleId: z.string().uuid(),diff --git a/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts b/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.tsindex fe67238a14..be4061b6b8 100644--- a/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts+++ b/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts@@ -6204,7 +6204,7 @@ export interface SearchGotoAgentSession {author: AgentSessionAuthor;}/**- * Create a reusable booking page, not a calendar meeting. First use ListBookingLinks to discover a suitable existing link or reuse availability. Supply a full draft with all seven weekdays (Sunday=0), IANA time zone, and real host IDs; personal links use the authenticated user and individual mode. For a team use a real team ID and collective or roundRobin mode. Set enabled only when the user wants to accept bookings. No invitations are sent by creating a link. Repeating an identical draft with the same slug reuses the saved link; a different draft at that slug conflicts. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar.+ * Create a reusable booking page, not a calendar meeting. First use ListBookingLinks to discover a suitable existing link or reuse availability. Supply a full draft with all seven weekdays (Sunday=0), IANA time zone, and real host IDs; personal links use the authenticated user and individual mode. For a team use a real team ID and collective or roundRobin mode. Set enabled only when the user wants to accept bookings. No invitations are sent by creating a link. Repeating an identical draft with the same slug reuses the saved link; a different draft at that slug conflicts. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location, Macro call, or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar. For video, set macroCall (preferred) or googleMeet, never both. Booking a macroCall link creates the call and attaches its join link to the invitation.*/export interface CreateBookingLink {/**@@ -6250,7 +6250,15 @@ export interface BookingLinkEvent {*/location: string;/**- * Generate a Google Meet conference.+ * Attach a Macro call when someone books. A join link is created for that+ * booking and written onto the calendar invitation. Mutually exclusive+ * with `googleMeet`. Prefer this for a Macro booking; omit or false when+ * the link should use Google Meet or no video. False is omitted so drafts+ * saved before this field still round-trip unchanged.+ */+ macroCall?: boolean;+ /**+ * Generate a Google Meet conference. Mutually exclusive with `macroCall`.*/googleMeet: boolean;/**@@ -8161,7 +8169,7 @@ export interface DuplicateItemResponse {message: string;}/**- * Edit exactly one existing booking link. First read it with ListBookingLinks, preserve all settings the user did not request changing, and pass its revision and full edited draft. Changed availability applies only to this link; other links and personal default hours remain unchanged. A stale revision fails: read again and confirm the updated proposal in conversation instead of overwriting concurrent edits. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar.+ * Edit exactly one existing booking link. First read it with ListBookingLinks, preserve all settings the user did not request changing, and pass its revision and full edited draft. Changed availability applies only to this link; other links and personal default hours remain unchanged. A stale revision fails: read again and confirm the updated proposal in conversation instead of overwriting concurrent edits. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location, Macro call, or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar. For video, set macroCall (preferred) or googleMeet, never both. Booking a macroCall link creates the call and attaches its join link to the invitation.*/export interface EditBookingLink {/**@@ -11692,7 +11700,13 @@ export interface EventType {*/location: string;/**- * Generate a Google Meet conference.+ * Generate a Macro call and attach its join link when someone books.+ * Mutually exclusive with Google Meet. Omitted on links saved before+ * Macro calls were a booking option, which keep their previous conference.+ */+ macroCall?: boolean;+ /**+ * Generate a Google Meet conference. Mutually exclusive with a Macro call.*/googleMeet: boolean;/**diff --git a/crates/calendar_scheduling/Cargo.toml b/crates/calendar_scheduling/Cargo.tomlindex c09717ae5c..35f983e71c 100644--- a/crates/calendar_scheduling/Cargo.toml+++ b/crates/calendar_scheduling/Cargo.toml@@ -10,7 +10,7 @@ default = []ai_tools = ["dep:ai_toolset", "dep:async-trait", "dep:schemars", "dep:anyhow"]postgres = ["dep:sqlx"]inbound = ["dep:axum", "dep:macro_authorization"]-calendar = ["dep:calendar_events", "dep:teams", "dep:macro_user_id"]+calendar = ["dep:calendar_events", "dep:teams", "dep:macro_user_id", "dep:reqwest"][dependencies]reqwest = { workspace = true, optional = true }@@ -39,3 +39,4 @@ macro_user_id = { path = "../macro_user_id", optional = true }model_user = { path = "../model_user" }reqwest = { workspace = true }tokio = { workspace = true }+wiremock = { workspace = true }diff --git a/crates/calendar_scheduling/src/domain/availability.rs b/crates/calendar_scheduling/src/domain/availability.rsindex 9081d8271c..4847e42767 100644--- a/crates/calendar_scheduling/src/domain/availability.rs+++ b/crates/calendar_scheduling/src/domain/availability.rs@@ -87,6 +87,9 @@ pub fn validate_profile(profile: &Profile, team: bool) -> Result<(), Error> {{return invalid("Scheduling type does not match the profile");}+ if event.macro_call && event.google_meet {+ return invalid("Choose either a Macro call or Google Meet");+ }if event.questions.len() > 20|| event.questionsdiff --git a/crates/calendar_scheduling/src/domain/availability/test.rs b/crates/calendar_scheduling/src/domain/availability/test.rsindex 366412000d..a21ed10164 100644--- a/crates/calendar_scheduling/src/domain/availability/test.rs+++ b/crates/calendar_scheduling/src/domain/availability/test.rs@@ -26,6 +26,7 @@ fn event() -> EventType {description: String::new(),duration_minutes: 30,location: String::new(),+ macro_call: false,google_meet: false,enabled: true,schedule_id: Uuid::nil(),@@ -239,3 +240,48 @@ fn primary_schedule_rejects_slots_that_leave_hours_during_fall_back() {.is_empty());}++#[test]+fn saved_links_without_a_macro_call_keep_google_meet() {+ let event: EventType = serde_json::from_value(serde_json::json!({+ "id": Uuid::nil(),+ "title": "Meeting",+ "slug": "meeting",+ "description": "",+ "durationMinutes": 30,+ "location": "",+ "googleMeet": true,+ "enabled": true,+ "scheduleId": Uuid::nil(),+ "mode": "collective",+ "hosts": ["a", "b"],+ "beforeMinutes": 0,+ "afterMinutes": 0,+ "noticeMinutes": 0,+ "horizonDays": 30,+ "intervalMinutes": 30,+ "dailyLimit": null,+ "requiresConfirmation": false,+ "questions": []+ }))+ .unwrap();+ assert!(event.google_meet);+ assert!(!event.macro_call);+}++#[test]+fn a_link_cannot_request_both_a_macro_call_and_google_meet() {+ let mut profile = Profile {+ id: Uuid::nil(),+ name: "Calendar".into(),+ description: String::new(),+ schedules: vec![schedule()],+ default_schedule_id: None,+ event_types: vec![event()],+ revision: 0,+ };+ profile.event_types[0].macro_call = true;+ assert!(validate_profile(&profile, true).is_ok());+ profile.event_types[0].google_meet = true;+ assert!(validate_profile(&profile, true).is_err());+}diff --git a/crates/calendar_scheduling/src/domain/booking_link_models.rs b/crates/calendar_scheduling/src/domain/booking_link_models.rsindex 374c974422..0ce818ecad 100644--- a/crates/calendar_scheduling/src/domain/booking_link_models.rs+++ b/crates/calendar_scheduling/src/domain/booking_link_models.rs@@ -18,7 +18,14 @@ pub struct BookingLinkEvent {pub duration_minutes: u16,/// Meeting location.pub location: String,- /// Generate a Google Meet conference.+ /// Attach a Macro call when someone books. A join link is created for that+ /// booking and written onto the calendar invitation. Mutually exclusive+ /// with `googleMeet`. Prefer this for a Macro booking; omit or false when+ /// the link should use Google Meet or no video. False is omitted so drafts+ /// saved before this field still round-trip unchanged.+ #[serde(default, skip_serializing_if = "is_false")]+ pub macro_call: bool,+ /// Generate a Google Meet conference. Mutually exclusive with `macroCall`.pub google_meet: bool,/// Whether new bookings are accepted.pub enabled: bool,@@ -105,6 +112,10 @@ pub struct BookingLinkListing {pub links: Vec<BookingLink>,}+fn is_false(value: &bool) -> bool {+ !*value+}+impl BookingLinkDraft {/// Extract a draft without persisted event or schedule identities.pub fn from_parts(event: &EventType, schedule: &Schedule) -> Self {@@ -115,6 +126,7 @@ impl BookingLinkDraft {description: event.description.clone(),duration_minutes: event.duration_minutes,location: event.location.clone(),+ macro_call: event.macro_call,google_meet: event.google_meet,enabled: event.enabled,mode: event.mode,@@ -146,6 +158,7 @@ impl BookingLinkDraft {description: self.event.description,duration_minutes: self.event.duration_minutes,location: self.event.location,+ macro_call: self.event.macro_call,google_meet: self.event.google_meet,enabled: self.event.enabled,mode: self.event.mode,diff --git a/crates/calendar_scheduling/src/domain/models.rs b/crates/calendar_scheduling/src/domain/models.rsindex f9153330ab..613b76974f 100644--- a/crates/calendar_scheduling/src/domain/models.rs+++ b/crates/calendar_scheduling/src/domain/models.rs@@ -89,7 +89,12 @@ pub struct EventType {pub duration_minutes: u16,/// Meeting location.pub location: String,- /// Generate a Google Meet conference.+ /// Generate a Macro call and attach its join link when someone books.+ /// Mutually exclusive with Google Meet. Omitted on links saved before+ /// Macro calls were a booking option, which keep their previous conference.+ #[serde(default)]+ pub macro_call: bool,+ /// Generate a Google Meet conference. Mutually exclusive with a Macro call.pub google_meet: bool,/// Whether new bookings are accepted.pub enabled: bool,@@ -356,6 +361,8 @@ pub struct PublicEvent {pub duration_minutes: u16,/// Location shared by the host.pub location: String,+ /// Whether a Macro call will be created for the booking.+ pub macro_call: bool,/// Whether a Google Meet will be created.pub google_meet: bool,/// Information requested from the booker.diff --git a/crates/calendar_scheduling/src/domain/service.rs b/crates/calendar_scheduling/src/domain/service.rsindex aff7be2603..1cb9d0e226 100644--- a/crates/calendar_scheduling/src/domain/service.rs+++ b/crates/calendar_scheduling/src/domain/service.rs@@ -211,6 +211,7 @@ impl<R: Repository, C: Calendars, D: Directory> Service<R, C, D> {description: e.description,duration_minutes: e.duration_minutes,location: e.location,+ macro_call: e.macro_call,google_meet: e.google_meet,questions: e.questions,requires_confirmation: e.requires_confirmation,diff --git a/crates/calendar_scheduling/src/domain/service/test.rs b/crates/calendar_scheduling/src/domain/service/test.rsindex 52fc964ca2..ee4529dd66 100644--- a/crates/calendar_scheduling/src/domain/service/test.rs+++ b/crates/calendar_scheduling/src/domain/service/test.rs@@ -288,6 +288,7 @@ fn profile(team: Option<Uuid>) -> Profile {description: String::new(),duration_minutes: 30,location: String::new(),+ macro_call: false,google_meet: false,enabled: true,schedule_id: schedule.id,diff --git a/crates/calendar_scheduling/src/inbound/toolset/create_booking_link.rs b/crates/calendar_scheduling/src/inbound/toolset/create_booking_link.rsindex eb72b996b2..ea596de607 100644--- a/crates/calendar_scheduling/src/inbound/toolset/create_booking_link.rs+++ b/crates/calendar_scheduling/src/inbound/toolset/create_booking_link.rs@@ -12,7 +12,7 @@ use uuid::Uuid;#[serde(rename_all = "camelCase", deny_unknown_fields)]#[schemars(title = "CreateBookingLink",- description = "Create a reusable booking page, not a calendar meeting. First use ListBookingLinks to discover a suitable existing link or reuse availability. Supply a full draft with all seven weekdays (Sunday=0), IANA time zone, and real host IDs; personal links use the authenticated user and individual mode. For a team use a real team ID and collective or roundRobin mode. Set enabled only when the user wants to accept bookings. No invitations are sent by creating a link. Repeating an identical draft with the same slug reuses the saved link; a different draft at that slug conflicts. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar."+ description = "Create a reusable booking page, not a calendar meeting. First use ListBookingLinks to discover a suitable existing link or reuse availability. Supply a full draft with all seven weekdays (Sunday=0), IANA time zone, and real host IDs; personal links use the authenticated user and individual mode. For a team use a real team ID and collective or roundRobin mode. Set enabled only when the user wants to accept bookings. No invitations are sent by creating a link. Repeating an identical draft with the same slug reuses the saved link; a different draft at that slug conflicts. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location, Macro call, or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar. For video, set macroCall (preferred) or googleMeet, never both. Booking a macroCall link creates the call and attaches its join link to the invitation.")]pub struct CreateBookingLink {/// Existing Macro team ID discovered through tools, never requested from the user. Use null for a personal booking link.diff --git a/crates/calendar_scheduling/src/inbound/toolset/edit_booking_link.rs b/crates/calendar_scheduling/src/inbound/toolset/edit_booking_link.rsindex 5d76ca8f95..e1c2490711 100644--- a/crates/calendar_scheduling/src/inbound/toolset/edit_booking_link.rs+++ b/crates/calendar_scheduling/src/inbound/toolset/edit_booking_link.rs@@ -12,7 +12,7 @@ use uuid::Uuid;#[serde(rename_all = "camelCase", deny_unknown_fields)]#[schemars(title = "EditBookingLink",- description = "Edit exactly one existing booking link. First read it with ListBookingLinks, preserve all settings the user did not request changing, and pass its revision and full edited draft. Changed availability applies only to this link; other links and personal default hours remain unchanged. A stale revision fails: read again and confirm the updated proposal in conversation instead of overwriting concurrent edits. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar."+ description = "Edit exactly one existing booking link. First read it with ListBookingLinks, preserve all settings the user did not request changing, and pass its revision and full edited draft. Changed availability applies only to this link; other links and personal default hours remain unchanged. A stale revision fails: read again and confirm the updated proposal in conversation instead of overwriting concurrent edits. Create or edit booking links only after conversational confirmation, with no review card or interactive form. First explain all proposed details clearly in your reply: personal or team ownership, named hosts and who attends, meeting name, description, duration, location, Macro call, or Google Meet, time zone, weekly hours and date exceptions, link name, buffers, minimum notice, booking window, slot interval, daily limit, guest questions and whether bookings are enabled. Ask whether to proceed and stop. Only in a later turn after the user approves that specific proposal, call this tool with their approving reply quoted verbatim in userConfirmation. The original request is not confirmation; never invent or paraphrase approval. Never ask the user for teamId, host IDs, schedule IDs, revisions or JSON: discover IDs with ListBookingLinks and ListTeamMembers. Default to personal ownership unless a team is requested, and clarify ambiguous choices by name. Return the saved URL after execution. Returns actual saved IDs, revision, full draft and shareable URL. Manual approval must be false; guest booking requires a connected, synced writable calendar. For video, set macroCall (preferred) or googleMeet, never both. Booking a macroCall link creates the call and attaches its join link to the invitation.")]pub struct EditBookingLink {/// Existing Macro team ID discovered through tools, never requested from the user. Use null for a personal booking link.diff --git a/crates/calendar_scheduling/src/outbound.rs b/crates/calendar_scheduling/src/outbound.rsindex fd7912894e..906853a808 100644--- a/crates/calendar_scheduling/src/outbound.rs+++ b/crates/calendar_scheduling/src/outbound.rs@@ -1,6 +1,8 @@//! Persistence adapters for scheduling-owned data.#[cfg(feature = "calendar")]pub mod macro_services;+#[cfg(feature = "calendar")]+pub mod meeting_links;#[cfg(feature = "postgres")]pub mod postgres;diff --git a/crates/calendar_scheduling/src/outbound/macro_services.rs b/crates/calendar_scheduling/src/outbound/macro_services.rsindex 29db8e2e37..07db68aabc 100644--- a/crates/calendar_scheduling/src/outbound/macro_services.rs+++ b/crates/calendar_scheduling/src/outbound/macro_services.rs@@ -4,11 +4,15 @@ use crate::domain::{ports::{Calendars, Directory},};use calendar_events::domain::{+ meeting_links::create_event_with_macro_call,models::{CalendarAttendeeInput, CalendarEventDraft, CalendarSyncStatus, ConferenceChange, EventTime,EventTransparency, OccurrenceRange,},- ports::{CalendarCreationRecoveryService, CalendarDeletionScope, CalendarOccurrenceService},+ ports::{+ CalendarCreationRecoveryService, CalendarDeletionScope, CalendarOccurrenceService,+ MeetingLinkProvider, UnavailableMeetingLinks,+ },};use chrono::{DateTime, Duration, Utc};use std::sync::Arc;@@ -16,23 +20,97 @@ use teams::domain::{model::TeamRole, team_repo::TeamRepository};use uuid::Uuid;/// Adapter composed from existing domain services, never their outbound implementations.-pub struct MacroCalendars<O, M> {+pub struct MacroCalendars<O, M, L = UnavailableMeetingLinks> {occurrences: Arc<O>,mutations: Arc<M>,+ meeting_links: Arc<L>,management_origin: Option<String>,}-impl<O, M> MacroCalendars<O, M> {- /// Wire the host's calendar domain capabilities.+impl<O, M> MacroCalendars<O, M, UnavailableMeetingLinks> {+ /// Wire the host's calendar domain capabilities without Macro call creation.pub fn new(occurrences: Arc<O>, mutations: Arc<M>, management_origin: Option<String>) -> Self {+ Self::with_meeting_links(+ occurrences,+ mutations,+ Arc::new(UnavailableMeetingLinks),+ management_origin,+ )+ }+}+impl<O, M, L> MacroCalendars<O, M, L> {+ /// Wire calendar capabilities and the meeting service that mints Macro calls.+ pub fn with_meeting_links(+ occurrences: Arc<O>,+ mutations: Arc<M>,+ meeting_links: Arc<L>,+ management_origin: Option<String>,+ ) -> Self {Self {occurrences,mutations,+ meeting_links,management_origin,}}}-impl<O: CalendarOccurrenceService, M: CalendarCreationRecoveryService> Calendars- for MacroCalendars<O, M>+impl<O, M, L> MacroCalendars<O, M, L>+where+ O: CalendarOccurrenceService,+ M: CalendarCreationRecoveryService,+ L: MeetingLinkProvider,+{+ async fn create_macro_call(+ &self,+ organizer: &str,+ calendar_id: Option<Uuid>,+ draft: CalendarEventDraft,+ ) -> Result<(Uuid, String), Error> {+ let created = create_event_with_macro_call(+ &*self.mutations,+ &*self.meeting_links,+ organizer,+ None,+ calendar_id,+ draft,+ )+ .await+ .map_err(|error| {+ tracing::error!(error = ?error, "scheduling macro call creation failed");+ Error::CalendarUnavailable+ })?;+ let minted = created.meeting_link.url;+ if carries_url(+ created.event.location.as_deref(),+ created.event.description.as_deref(),+ &minted,+ ) {+ return Ok((created.event.id, minted));+ }+ // An idempotent replay returned the event written earlier. Drop the+ // meeting minted for this attempt and keep the link already on it.+ if let Err(error) = self+ .meeting_links+ .cancel_meeting_link(organizer, created.meeting_link.id)+ .await+ {+ tracing::warn!(+ error = ?error,+ meeting_id = %created.meeting_link.id,+ "failed to cancel a macro call minted for an existing booking event"+ );+ }+ let url = first_macro_call_url(+ created.event.location.as_deref(),+ created.event.description.as_deref(),+ )+ .or(created.event.conference_url)+ .or(created.event.location)+ .unwrap_or_default();+ Ok((created.event.id, url))+ }+}+impl<O: CalendarOccurrenceService, M: CalendarCreationRecoveryService, L: MeetingLinkProvider>+ Calendars for MacroCalendars<O, M, L>{async fn creation_calendar(&self, host: &str) -> Result<Uuid, Error> {self.mutations@@ -211,9 +289,19 @@ impl<O: CalendarOccurrenceService, M: CalendarCreationRecoveryService> Calendarsvisibility: None,transparency: None,reminders: None,- conference: event.google_meet.then_some(ConferenceChange::GoogleMeet),+ conference: (!event.macro_call && event.google_meet)+ .then_some(ConferenceChange::GoogleMeet),out_of_office: None,};+ if event.macro_call {+ if event.google_meet {+ tracing::error!("booking link requested both a Macro call and Google Meet");+ return Err(Error::CalendarUnavailable);+ }+ return self+ .create_macro_call(organizer, record.calendar_id, draft)+ .await;+ }let result = self.mutations.create_event(organizer, None, record.calendar_id, draft)@@ -324,8 +412,11 @@ impl<T: TeamRepository> Directory for MacroDirectory<T> {}}-impl<O: CalendarOccurrenceService, M: calendar_events::domain::ports::CalendarMutationService>- crate::domain::ports::AttachmentReadiness for MacroCalendars<O, M>+impl<O, M, L> crate::domain::ports::AttachmentReadiness for MacroCalendars<O, M, L>+where+ O: CalendarOccurrenceService,+ M: calendar_events::domain::ports::CalendarMutationService,+ L: Send + Sync + 'static,{async fn ready(&self, host: &str) -> Result<(), Error> {let calendars = self@@ -347,3 +438,29 @@ impl<O: CalendarOccurrenceService, M: calendar_events::domain::ports::CalendarMuOk(())}}++fn carries_url(location: Option<&str>, description: Option<&str>, url: &str) -> bool {+ location.is_some_and(|value| value.contains(url))+ || description.is_some_and(|value| value.contains(url))+}++/// The join link already written into an event, including inside the+/// generated HTML paragraph.+fn first_macro_call_url(location: Option<&str>, description: Option<&str>) -> Option<String> {+ for text in [location, description].into_iter().flatten() {+ for token in text.split(|character: char| {+ character.is_whitespace() || matches!(character, '"' | '\'' | '<' | '>' | '&')+ }) {+ let token = token.trim_end_matches(|character: char| {+ matches!(character, '.' | ',' | ')' | ']' | ';')+ });+ if token.starts_with("http") && token.contains("/meet/join/") {+ return Some(token.to_string());+ }+ }+ }+ None+}++#[cfg(test)]+mod test;diff --git a/crates/calendar_scheduling/src/outbound/macro_services/test.rs b/crates/calendar_scheduling/src/outbound/macro_services/test.rsnew file mode 100644index 0000000000..bb18ec1055--- /dev/null+++ b/crates/calendar_scheduling/src/outbound/macro_services/test.rs@@ -0,0 +1,14 @@+use super::*;++const URL: &str = "https://macro.com/app/meet/join/0123456789abcdef0123456789abcdef";++#[test]+fn an_idempotent_replay_keeps_the_link_already_on_the_event() {+ let description = format!(r#"<p>Join Macro call: <a href="{URL}">{URL}</a></p>"#);+ assert!(carries_url(None, Some(&description), URL));+ assert_eq!(+ first_macro_call_url(Some("Office"), Some(&description)).as_deref(),+ Some(URL)+ );+ assert!(!carries_url(Some("Office"), Some("notes"), URL));+}diff --git a/crates/calendar_scheduling/src/outbound/meeting_links.rs b/crates/calendar_scheduling/src/outbound/meeting_links.rsnew file mode 100644index 0000000000..03b2bc14cd--- /dev/null+++ b/crates/calendar_scheduling/src/outbound/meeting_links.rs@@ -0,0 +1,177 @@+//! Meeting-link adapter that asks the call service for a Macro call.+//!+//! Booking runs in the calendar service, which does not host calls. This+//! client creates the meeting through document storage on behalf of the+//! organizer and builds the same join URL the calendar UI recognizes.++use std::time::Duration;++use calendar_events::domain::{+ meeting_links::{MeetingLink, MeetingLinkError, MeetingLinkRequest},+ ports::MeetingLinkProvider,+};+use uuid::Uuid;++/// Header carrying the shared key for internal service authorization.+const INTERNAL_API_KEY_HEADER: &str = "x-internal-auth-key";+/// Header carrying the acting Macro user for internal authorization.+const INTERNAL_MACRO_USER_ID_HEADER: &str = "x-internal-macro-user-id";+/// Router path of meeting management, relative to the document storage origin.+const MEETINGS_PATH: &str = "/call/meetings";+/// Router path of the meeting setup page, relative to the app origin.+const MEETING_JOIN_PATH: &str = "/app/meet/join/";+/// Longest meeting title the call service accepts.+const MAX_MEETING_TITLE_CHARS: usize = 200;++/// [`MeetingLinkProvider`] that calls the document storage meeting routes.+pub struct HttpMeetingLinks {+ document_storage_url: String,+ app_origin: String,+ internal_api_key: String,+ http: reqwest::Client,+}++impl HttpMeetingLinks {+ /// `document_storage_url` is the document storage origin, including a+ /// gateway prefix such as `/dss`. `app_origin` is the browser origin+ /// join links are built on, for example `https://macro.com`.+ pub fn new(+ document_storage_url: impl Into<String>,+ app_origin: impl Into<String>,+ internal_api_key: impl Into<String>,+ ) -> Self {+ Self {+ document_storage_url: document_storage_url+ .into()+ .trim_end_matches('/')+ .to_string(),+ app_origin: app_origin.into().trim_end_matches('/').to_string(),+ internal_api_key: internal_api_key.into(),+ http: reqwest::Client::builder()+ .timeout(Duration::from_secs(30))+ .build()+ .expect("static reqwest client configuration is valid"),+ }+ }++ fn request(+ &self,+ method: reqwest::Method,+ path: &str,+ requester_id: &str,+ ) -> reqwest::RequestBuilder {+ self.http+ .request(method, format!("{}{path}", self.document_storage_url))+ .header(INTERNAL_API_KEY_HEADER, &self.internal_api_key)+ .header(INTERNAL_MACRO_USER_ID_HEADER, requester_id)+ }+}++fn meeting_title(title: &str) -> Option<String> {+ let title: String = title+ .chars()+ .map(|character| {+ if character.is_control() {+ ' '+ } else {+ character+ }+ })+ .collect::<String>()+ .trim()+ .chars()+ .take(MAX_MEETING_TITLE_CHARS)+ .collect();+ let title = title.trim().to_string();+ (!title.is_empty()).then_some(title)+}++fn join_url(app_origin: &str, share_token: &str) -> Result<String, MeetingLinkError> {+ if share_token.len() != 64 || !share_token.bytes().all(|byte| byte.is_ascii_hexdigit()) {+ return Err(MeetingLinkError::Failed(+ "meeting service returned an unusable join token".to_string(),+ ));+ }+ Ok(format!("{app_origin}{MEETING_JOIN_PATH}{share_token}"))+}++fn failure(status: reqwest::StatusCode, body: String) -> MeetingLinkError {+ let body: String = body.chars().take(200).collect();+ if status == reqwest::StatusCode::BAD_REQUEST {+ MeetingLinkError::InvalidInput(body)+ } else {+ MeetingLinkError::Failed(format!("meeting service returned {status}: {body}"))+ }+}++impl MeetingLinkProvider for HttpMeetingLinks {+ #[tracing::instrument(skip_all, err)]+ async fn create_meeting_link(+ &self,+ requester_id: &str,+ request: MeetingLinkRequest,+ ) -> Result<MeetingLink, MeetingLinkError> {+ let response = self+ .request(reqwest::Method::POST, MEETINGS_PATH, requester_id)+ .json(&serde_json::json!({+ "preparationId": null,+ "title": meeting_title(&request.title),+ "scheduledStart": request.scheduled_start,+ "scheduledEnd": request.scheduled_end,+ }))+ .send()+ .await+ .map_err(|error| {+ MeetingLinkError::Failed(format!("meeting service was unreachable: {error}"))+ })?;+ let status = response.status();+ if !status.is_success() {+ let body = response.text().await.unwrap_or_default();+ return Err(failure(status, body));+ }+ let created: CreatedMeeting = response.json().await.map_err(|error| {+ MeetingLinkError::Failed(format!(+ "meeting service returned an unreadable meeting: {error}"+ ))+ })?;+ Ok(MeetingLink {+ id: created.id,+ url: join_url(&self.app_origin, &created.share_token)?,+ })+ }++ #[tracing::instrument(skip_all, err, fields(meeting_id = %meeting_id))]+ async fn cancel_meeting_link(+ &self,+ requester_id: &str,+ meeting_id: Uuid,+ ) -> Result<(), MeetingLinkError> {+ let response = self+ .request(+ reqwest::Method::DELETE,+ &format!("{MEETINGS_PATH}/{meeting_id}"),+ requester_id,+ )+ .send()+ .await+ .map_err(|error| {+ MeetingLinkError::Failed(format!("meeting service was unreachable: {error}"))+ })?;+ let status = response.status();+ if status.is_success() {+ return Ok(());+ }+ let body = response.text().await.unwrap_or_default();+ Err(failure(status, body))+ }+}++#[derive(serde::Deserialize)]+#[serde(rename_all = "camelCase")]+struct CreatedMeeting {+ id: Uuid,+ share_token: String,+}++#[cfg(test)]+mod test;diff --git a/crates/calendar_scheduling/src/outbound/meeting_links/test.rs b/crates/calendar_scheduling/src/outbound/meeting_links/test.rsnew file mode 100644index 0000000000..8f811b7929--- /dev/null+++ b/crates/calendar_scheduling/src/outbound/meeting_links/test.rs@@ -0,0 +1,80 @@+use super::*;+use chrono::TimeZone;+use wiremock::matchers::{body_json, header, method, path};+use wiremock::{Mock, MockServer, ResponseTemplate};++const TOKEN: &str = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";++fn request() -> MeetingLinkRequest {+ MeetingLinkRequest {+ title: "Intro — Ada".into(),+ scheduled_start: Some(+ chrono::Utc+ .with_ymd_and_hms(2026, 10, 20, 15, 0, 0)+ .unwrap(),+ ),+ scheduled_end: Some(+ chrono::Utc+ .with_ymd_and_hms(2026, 10, 20, 15, 30, 0)+ .unwrap(),+ ),+ }+}++#[tokio::test]+async fn create_mints_a_meeting_and_returns_its_join_link() {+ let server = MockServer::start().await;+ let meeting_id = Uuid::from_u128(7);+ Mock::given(method("POST"))+ .and(path("/call/meetings"))+ .and(header(INTERNAL_API_KEY_HEADER, "secret"))+ .and(header(INTERNAL_MACRO_USER_ID_HEADER, "macro|[email protected]"))+ .and(body_json(serde_json::json!({+ "preparationId": null,+ "title": "Intro — Ada",+ "scheduledStart": "2026-10-20T15:00:00Z",+ "scheduledEnd": "2026-10-20T15:30:00Z",+ })))+ .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({+ "id": meeting_id,+ "shareToken": TOKEN,+ "title": "Intro — Ada",+ })))+ .expect(1)+ .mount(&server)+ .await;+ let links = HttpMeetingLinks::new(server.uri(), "https://macro.com", "secret");+ let created = links+ .create_meeting_link("macro|[email protected]", request())+ .await+ .unwrap();+ assert_eq!(created.id, meeting_id);+ assert_eq!(+ created.url,+ format!("https://macro.com/app/meet/join/{TOKEN}")+ );+}++#[tokio::test]+async fn cancel_deletes_the_meeting_for_the_organizer() {+ let server = MockServer::start().await;+ let meeting_id = Uuid::from_u128(9);+ Mock::given(method("DELETE"))+ .and(path(format!("/call/meetings/{meeting_id}")))+ .and(header(INTERNAL_MACRO_USER_ID_HEADER, "macro|[email protected]"))+ .respond_with(ResponseTemplate::new(204))+ .expect(1)+ .mount(&server)+ .await;+ let links = HttpMeetingLinks::new(server.uri(), "https://macro.com/", "secret");+ links+ .cancel_meeting_link("macro|[email protected]", meeting_id)+ .await+ .unwrap();+}++#[test]+fn a_blank_title_lets_the_meeting_service_choose_one() {+ assert_eq!(meeting_title(" \n"), None);+ assert_eq!(meeting_title("Hello"), Some("Hello".into()));+}diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.mdindex 4f108a950e..dab43a85d9 100644--- a/docs/AGENT_GUIDE/surfaces.md+++ b/docs/AGENT_GUIDE/surfaces.md@@ -1370,7 +1370,10 @@ Links and availability use flat rows, with actions beside each item.Booking pages, bookings, and insights show only the selected owner. Search filtersthat owner’s links and clears when switching owners. Team owners/admins can editteam links; ordinary members can view them. `Links` creates, edits, pauses,-duplicates, previews, and copies booking links. Event settings include+duplicates, previews, and copies booking links. Event settings include a+video choice. New links default to a Macro call, which is created when+someone books and attached to the calendar invitation. Google Meet and no+video link remain available. Event settings also includeweekly availability, collective/all-host or round-robin/one-host assignment,notice, buffers, booking horizon, daily limits, and custom questions. New eventtypes stay paused until `Accept bookings` is selected and changes are saved.diff --git a/services/calendar_service/src/api/context.rs b/services/calendar_service/src/api/context.rsindex 08d1a4fe97..061768e35d 100644--- a/services/calendar_service/src/api/context.rs+++ b/services/calendar_service/src/api/context.rs@@ -29,6 +29,7 @@ pub type SchedulingService = calendar_scheduling::domain::service::Service<calendar_scheduling::outbound::macro_services::MacroCalendars<CalendarGrantService,CalendarMutationSvc,+ calendar_scheduling::outbound::meeting_links::HttpMeetingLinks,>,calendar_scheduling::outbound::macro_services::MacroDirectory<teams::outbound::team_repo::TeamRepositoryImpl,diff --git a/services/calendar_service/src/main.rs b/services/calendar_service/src/main.rsindex b29b440f12..dfa60939ee 100644--- a/services/calendar_service/src/main.rs+++ b/services/calendar_service/src/main.rs@@ -24,7 +24,9 @@ use macro_authorization::{use macro_entrypoint::MacroEntrypoint;use macro_env::Environment;use macro_event_broker::{KafkaEventPublisher, MacroEventBrokerService};-use macro_service_urls::{AuthServiceUrl, ConnectionGatewayUrl};+use macro_service_urls::{+ AppServiceUrl, AuthServiceUrl, ConnectionGatewayUrl, DocumentStorageServiceUrl,+};use sqlx::postgres::PgPoolOptions;use tokio_util::{sync::CancellationToken, task::TaskTracker};@@ -214,9 +216,16 @@ async fn main() -> anyhow::Result<()> {let scheduling_service = Arc::new(calendar_scheduling::domain::service::Service::new(calendar_scheduling::outbound::postgres::PostgresRepository::new(db.clone()),- calendar_scheduling::outbound::macro_services::MacroCalendars::new(+ calendar_scheduling::outbound::macro_services::MacroCalendars::with_meeting_links(calendar_service.clone(),calendar_mutation_service.clone(),+ Arc::new(+ calendar_scheduling::outbound::meeting_links::HttpMeetingLinks::new(+ DocumentStorageServiceUrl::new()?.as_str(),+ AppServiceUrl::new()?.as_str(),+ config.internal_api_key.to_string(),+ ),+ ),match config.environment {Environment::Production => Some("https://macro.com".into()),Environment::Develop => Some("https://dev.macro.com".into()),