@sentry/junior-google 0.277.0 → 0.278.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +191 -50
- package/dist/tools/find-meeting-times.d.ts +32 -6
- package/dist/tools/shared.d.ts +17 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -915,6 +915,18 @@ function attendeeResults(attendees) {
|
|
|
915
915
|
} : void 0
|
|
916
916
|
}));
|
|
917
917
|
}
|
|
918
|
+
var CONSUMER_DOMAINS = /* @__PURE__ */ new Set(["gmail.com", "googlemail.com"]);
|
|
919
|
+
var ACCOUNT_CHOOSER_URL = "https://accounts.google.com/AccountChooser";
|
|
920
|
+
function accountChooserLink(url, accountEmail) {
|
|
921
|
+
const domain = emailDomain(accountEmail);
|
|
922
|
+
if (!domain || CONSUMER_DOMAINS.has(domain) || !URL.parse(url)?.searchParams.has("eid")) {
|
|
923
|
+
return url;
|
|
924
|
+
}
|
|
925
|
+
const chooser = new URL(ACCOUNT_CHOOSER_URL);
|
|
926
|
+
chooser.searchParams.set("hd", domain);
|
|
927
|
+
chooser.searchParams.set("continue", url);
|
|
928
|
+
return chooser.toString();
|
|
929
|
+
}
|
|
918
930
|
var ownEventSchema = z2.object({
|
|
919
931
|
attendees: z2.array(googleAttendeeSchema).optional(),
|
|
920
932
|
description: z2.string().optional(),
|
|
@@ -930,7 +942,8 @@ var ownEventSchema = z2.object({
|
|
|
930
942
|
summary: z2.string().optional(),
|
|
931
943
|
updated: z2.string().optional()
|
|
932
944
|
});
|
|
933
|
-
function ownEventResult(event, timeZone) {
|
|
945
|
+
function ownEventResult(event, timeZone, accountEmail) {
|
|
946
|
+
const url = event.htmlLink && accountChooserLink(event.htmlLink, accountEmail);
|
|
934
947
|
const startMs = Date.parse(event.start.dateTime);
|
|
935
948
|
const when = formatInterval(
|
|
936
949
|
startMs,
|
|
@@ -949,7 +962,7 @@ function ownEventResult(event, timeZone) {
|
|
|
949
962
|
// People can edit the event in Calendar. Shorten long values so a
|
|
950
963
|
// completed change never fails on the annotation schema.
|
|
951
964
|
title: (event.summary?.trim() || "Untitled event").slice(0, 512),
|
|
952
|
-
url:
|
|
965
|
+
url: url || null,
|
|
953
966
|
description: event.description?.trim().slice(0, 4e3) || void 0,
|
|
954
967
|
sourceUpdatedAt: event.updated,
|
|
955
968
|
facts: {
|
|
@@ -971,7 +984,7 @@ function ownEventResult(event, timeZone) {
|
|
|
971
984
|
...event.location ? { location: event.location } : void 0,
|
|
972
985
|
...event.recurrence ? { repeats: true } : void 0,
|
|
973
986
|
...event.recurringEventId ? { series_event_id: event.recurringEventId } : void 0,
|
|
974
|
-
...
|
|
987
|
+
...url ? { url } : void 0,
|
|
975
988
|
...event.hangoutLink ? { video_call_url: event.hangoutLink } : void 0
|
|
976
989
|
};
|
|
977
990
|
}
|
|
@@ -997,7 +1010,9 @@ var EVENT_ID_PATTERN = /^[A-Za-z0-9_]{5,1024}$/;
|
|
|
997
1010
|
function parseEventId(value) {
|
|
998
1011
|
let eventId = value;
|
|
999
1012
|
if (/^https?:\/\//.test(value)) {
|
|
1000
|
-
const
|
|
1013
|
+
const link = URL.parse(value);
|
|
1014
|
+
const target = link?.searchParams.get("continue");
|
|
1015
|
+
const eid = (target ? URL.parse(target) : link)?.searchParams.get("eid");
|
|
1001
1016
|
eventId = eid ? Buffer.from(eid, "base64").toString("utf8").split(" ")[0] ?? "" : "";
|
|
1002
1017
|
}
|
|
1003
1018
|
if (!EVENT_ID_PATTERN.test(eventId)) {
|
|
@@ -1091,7 +1106,7 @@ function createCancelCalendarEventTool(ctx) {
|
|
|
1091
1106
|
const { event, path } = read;
|
|
1092
1107
|
const result = {
|
|
1093
1108
|
target: "cancelCalendarEvent",
|
|
1094
|
-
...ownEventResult(event, timeZone)
|
|
1109
|
+
...ownEventResult(event, timeZone, ctx.accountEmail)
|
|
1095
1110
|
};
|
|
1096
1111
|
const response = await googleApiRequest(ctx, {
|
|
1097
1112
|
operation: "google.calendar.event.delete",
|
|
@@ -1248,7 +1263,11 @@ function createCreateCalendarEventTool(ctx) {
|
|
|
1248
1263
|
return {
|
|
1249
1264
|
target: "createCalendarEvent",
|
|
1250
1265
|
created,
|
|
1251
|
-
...ownEventResult(
|
|
1266
|
+
...ownEventResult(
|
|
1267
|
+
ownEventSchema.parse(event.body),
|
|
1268
|
+
timeZone,
|
|
1269
|
+
ctx.accountEmail
|
|
1270
|
+
)
|
|
1252
1271
|
};
|
|
1253
1272
|
}
|
|
1254
1273
|
});
|
|
@@ -1266,6 +1285,10 @@ var MAX_WINDOW_MS = 14 * DAY_MS;
|
|
|
1266
1285
|
var DEFAULT_WINDOW_MS = 7 * DAY_MS;
|
|
1267
1286
|
var clockTimeSchema = z5.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "Use 24-hour HH:MM");
|
|
1268
1287
|
var WEEKDAYS = ["Mon", "Tue", "Wed", "Thu", "Fri"];
|
|
1288
|
+
var BACK_TO_BACK_GAP_MS = 15 * 6e4;
|
|
1289
|
+
var FOCUS_BLOCK_MS = 2 * 60 * 6e4;
|
|
1290
|
+
var SHORT_FOCUS_BLOCK_MS = 60 * 6e4;
|
|
1291
|
+
var OPTIONAL_WEIGHT = 0.5;
|
|
1269
1292
|
var inputSchema3 = z5.object({
|
|
1270
1293
|
attendees: emailListSchema(20).min(1).describe(
|
|
1271
1294
|
"Work emails of the people who must attend. Resolve names with userLookup. The runtime adds the requester as required when it knows their email. To make the requester optional, put their email in optional_attendees."
|
|
@@ -1289,6 +1312,16 @@ var inputSchema3 = z5.object({
|
|
|
1289
1312
|
workday_end: clockTimeSchema.default("17:00").describe(
|
|
1290
1313
|
"Latest local end, 24-hour HH:MM, in each attendee's own calendar time zone."
|
|
1291
1314
|
),
|
|
1315
|
+
lunch_start: clockTimeSchema.default("11:30").describe(
|
|
1316
|
+
"Start of the lunch window, 24-hour HH:MM, in each attendee's own calendar time zone."
|
|
1317
|
+
),
|
|
1318
|
+
lunch_end: clockTimeSchema.default("14:00").describe("End of the lunch window, 24-hour HH:MM."),
|
|
1319
|
+
lunch_minutes: z5.number().int().min(0).max(180).default(60).describe(
|
|
1320
|
+
"Free time each attendee keeps for lunch inside the lunch window. Set 0 for a requested lunch meeting."
|
|
1321
|
+
),
|
|
1322
|
+
max_back_to_back_minutes: z5.number().int().min(60).max(600).default(180).describe(
|
|
1323
|
+
"Longest run of back-to-back meetings a slot may create for an attendee. Gaps under 15 minutes count as back to back."
|
|
1324
|
+
),
|
|
1292
1325
|
weekdays: z5.array(z5.enum(WEEKDAYS)).min(1).optional().describe(
|
|
1293
1326
|
"Only return slots on these days, in the time_zone of the slot labels. Omit to search every weekday."
|
|
1294
1327
|
),
|
|
@@ -1362,15 +1395,51 @@ function wallClockMs(startMs, endMs, timeZone) {
|
|
|
1362
1395
|
function overlaps(busy, startMs, endMs) {
|
|
1363
1396
|
return busy.endMs > startMs && busy.startMs < endMs;
|
|
1364
1397
|
}
|
|
1365
|
-
function
|
|
1366
|
-
|
|
1398
|
+
function byCost(a, b) {
|
|
1399
|
+
return b.meetingDays - a.meetingDays || a.focusLostMs - b.focusLostMs || a.runsAdded - b.runsAdded;
|
|
1400
|
+
}
|
|
1401
|
+
function byTier(a, b) {
|
|
1402
|
+
return Number(a.optionalConflicts.length > 0) - Number(b.optionalConflicts.length > 0) || b.cost.meetingDays - a.cost.meetingDays;
|
|
1403
|
+
}
|
|
1404
|
+
function meetingRuns(busy) {
|
|
1405
|
+
const runs = [];
|
|
1406
|
+
for (const interval of [...busy].sort((a, b) => a.startMs - b.startMs)) {
|
|
1407
|
+
const last = runs.at(-1);
|
|
1408
|
+
if (last && interval.startMs - last.endMs < BACK_TO_BACK_GAP_MS) {
|
|
1409
|
+
last.endMs = Math.max(last.endMs, interval.endMs);
|
|
1410
|
+
} else {
|
|
1411
|
+
runs.push({ ...interval });
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
return runs;
|
|
1415
|
+
}
|
|
1416
|
+
function freeGaps(runs, window) {
|
|
1417
|
+
const gaps = [];
|
|
1418
|
+
let cursor = window.startMs;
|
|
1419
|
+
for (const run of runs) {
|
|
1420
|
+
if (!overlaps(run, window.startMs, window.endMs)) continue;
|
|
1421
|
+
if (run.startMs > cursor) {
|
|
1422
|
+
gaps.push({ endMs: run.startMs, startMs: cursor });
|
|
1423
|
+
}
|
|
1424
|
+
cursor = Math.max(cursor, run.endMs);
|
|
1425
|
+
}
|
|
1426
|
+
if (cursor < window.endMs) {
|
|
1427
|
+
gaps.push({ endMs: window.endMs, startMs: cursor });
|
|
1428
|
+
}
|
|
1429
|
+
return gaps;
|
|
1430
|
+
}
|
|
1431
|
+
function length(interval) {
|
|
1432
|
+
return interval.endMs - interval.startMs;
|
|
1433
|
+
}
|
|
1434
|
+
function bestOption(options, chosen) {
|
|
1367
1435
|
let best;
|
|
1368
1436
|
let bestGap = -1;
|
|
1369
1437
|
for (const option of options) {
|
|
1370
|
-
const gap = Math.min(
|
|
1438
|
+
const gap = chosen.length ? Math.min(
|
|
1371
1439
|
...chosen.map((slot) => Math.abs(slot.startMs - option.startMs))
|
|
1372
|
-
);
|
|
1373
|
-
|
|
1440
|
+
) : 0;
|
|
1441
|
+
const order = best ? byCost(option.cost, best.cost) : -1;
|
|
1442
|
+
if (order < 0 || order === 0 && gap > bestGap) {
|
|
1374
1443
|
best = option;
|
|
1375
1444
|
bestGap = gap;
|
|
1376
1445
|
}
|
|
@@ -1387,14 +1456,19 @@ function spreadAcrossDays(candidates, max) {
|
|
|
1387
1456
|
let progress = true;
|
|
1388
1457
|
while (result.length < max && progress) {
|
|
1389
1458
|
progress = false;
|
|
1390
|
-
|
|
1459
|
+
const round = [...days].flatMap(([date, options]) => {
|
|
1460
|
+
const next = bestOption(options, chosen.get(date) ?? []);
|
|
1461
|
+
return next ? [{ date, next, options }] : [];
|
|
1462
|
+
}).sort((a, b) => byCost(a.next.cost, b.next.cost));
|
|
1463
|
+
for (const { date, next, options } of round) {
|
|
1391
1464
|
if (result.length >= max) break;
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1465
|
+
days.set(
|
|
1466
|
+
date,
|
|
1467
|
+
options.filter(
|
|
1468
|
+
(option) => !overlaps(next, option.startMs, option.endMs)
|
|
1469
|
+
)
|
|
1470
|
+
);
|
|
1471
|
+
chosen.set(date, [...chosen.get(date) ?? [], next]);
|
|
1398
1472
|
result.push(next);
|
|
1399
1473
|
progress = true;
|
|
1400
1474
|
}
|
|
@@ -1406,6 +1480,10 @@ function findFreeSlots(input) {
|
|
|
1406
1480
|
const stepMs = (input.durationMinutes < 30 ? 15 : 30) * 6e4;
|
|
1407
1481
|
const dayStart = clockMinutes(input.workdayStart);
|
|
1408
1482
|
const dayEnd = clockMinutes(input.workdayEnd);
|
|
1483
|
+
const lunchStart = clockMinutes(input.lunchStart);
|
|
1484
|
+
const lunchEnd = clockMinutes(input.lunchEnd);
|
|
1485
|
+
const lunchMs = input.lunchMinutes * 6e4;
|
|
1486
|
+
const maxRunMs = Math.max(input.maxBackToBackMinutes * 6e4, durationMs);
|
|
1409
1487
|
const formats = /* @__PURE__ */ new Map();
|
|
1410
1488
|
const partsIn = (ms, timeZone) => {
|
|
1411
1489
|
let format = formats.get(timeZone);
|
|
@@ -1415,44 +1493,94 @@ function findFreeSlots(input) {
|
|
|
1415
1493
|
}
|
|
1416
1494
|
return localParts(ms, format);
|
|
1417
1495
|
};
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1496
|
+
const runsByEmail = new Map(
|
|
1497
|
+
input.attendees.map((attendee) => [
|
|
1498
|
+
attendee.email,
|
|
1499
|
+
meetingRuns(attendee.busy)
|
|
1500
|
+
])
|
|
1501
|
+
);
|
|
1502
|
+
const assess = (attendee, slot) => {
|
|
1503
|
+
const start = partsIn(slot.startMs, attendee.timeZone);
|
|
1504
|
+
const end = partsIn(slot.endMs, attendee.timeZone);
|
|
1505
|
+
if (start.weekday === "Sat" || start.weekday === "Sun" || start.date !== end.date || start.minutes < dayStart || end.minutes > dayEnd || attendee.busy.some((busy) => overlaps(busy, slot.startMs, slot.endMs))) {
|
|
1506
|
+
return void 0;
|
|
1507
|
+
}
|
|
1508
|
+
const before = runsByEmail.get(attendee.email) ?? [];
|
|
1509
|
+
const after = meetingRuns([...before, slot]);
|
|
1510
|
+
const run = after.find(
|
|
1511
|
+
(run2) => run2.startMs <= slot.startMs && run2.endMs >= slot.endMs
|
|
1512
|
+
);
|
|
1513
|
+
if (run && length(run) > maxRunMs) {
|
|
1514
|
+
return void 0;
|
|
1515
|
+
}
|
|
1516
|
+
const midnightMs = slot.startMs - start.minutes * 6e4;
|
|
1517
|
+
const at = (minutes) => midnightMs + minutes * 6e4;
|
|
1518
|
+
const lunch = { endMs: at(lunchEnd), startMs: at(lunchStart) };
|
|
1519
|
+
const hasLunch = (runs) => freeGaps(runs, lunch).some((gap) => length(gap) >= lunchMs);
|
|
1520
|
+
if (lunchMs > 0 && hasLunch(before) && !hasLunch(after)) {
|
|
1521
|
+
return void 0;
|
|
1522
|
+
}
|
|
1523
|
+
const workday = { endMs: at(dayEnd), startMs: at(dayStart) };
|
|
1524
|
+
const meetingDay = before.some(
|
|
1525
|
+
(run2) => overlaps(run2, workday.startMs, workday.endMs)
|
|
1526
|
+
);
|
|
1527
|
+
const blockMs = freeGaps(before, workday).some(
|
|
1528
|
+
(gap) => length(gap) >= FOCUS_BLOCK_MS
|
|
1529
|
+
) ? FOCUS_BLOCK_MS : SHORT_FOCUS_BLOCK_MS;
|
|
1530
|
+
const focusMs = (runs) => freeGaps(runs, workday).filter((gap) => length(gap) >= blockMs).reduce((total, gap) => total + length(gap), 0);
|
|
1531
|
+
const runsInDay = (runs) => runs.filter((run2) => overlaps(run2, workday.startMs, workday.endMs)).length;
|
|
1532
|
+
return {
|
|
1533
|
+
focusLostMs: focusMs(before) - focusMs(after),
|
|
1534
|
+
meetingDays: Number(meetingDay),
|
|
1535
|
+
runsAdded: runsInDay(after) - runsInDay(before)
|
|
1536
|
+
};
|
|
1422
1537
|
};
|
|
1423
1538
|
const required = input.attendees.filter((attendee) => attendee.required);
|
|
1424
1539
|
const optional = input.attendees.filter((attendee) => !attendee.required);
|
|
1425
1540
|
const candidates = [];
|
|
1426
|
-
let startMs = Math.ceil(input.timeMinMs / stepMs) * stepMs;
|
|
1427
|
-
|
|
1428
|
-
const endMs = startMs + durationMs;
|
|
1541
|
+
for (let startMs = Math.ceil(input.timeMinMs / stepMs) * stepMs; startMs + durationMs <= input.timeMaxMs; startMs += stepMs) {
|
|
1542
|
+
const slot = { endMs: startMs + durationMs, startMs };
|
|
1429
1543
|
const local = partsIn(startMs, input.timeZone);
|
|
1430
|
-
if (
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1544
|
+
if (input.weekdays && !input.weekdays.includes(local.weekday)) continue;
|
|
1545
|
+
const cost = { focusLostMs: 0, meetingDays: 0, runsAdded: 0 };
|
|
1546
|
+
const add = (part, weight) => {
|
|
1547
|
+
cost.focusLostMs += part.focusLostMs * weight;
|
|
1548
|
+
cost.meetingDays += part.meetingDays * weight;
|
|
1549
|
+
cost.runsAdded += part.runsAdded * weight;
|
|
1550
|
+
};
|
|
1551
|
+
const requiredCosts = required.map((attendee) => assess(attendee, slot));
|
|
1552
|
+
if (!requiredCosts.every((part) => part !== void 0)) continue;
|
|
1553
|
+
for (const part of requiredCosts) add(part, 1);
|
|
1554
|
+
const optionalConflicts = [];
|
|
1555
|
+
for (const attendee of optional) {
|
|
1556
|
+
const part = assess(attendee, slot);
|
|
1557
|
+
if (part) add(part, OPTIONAL_WEIGHT);
|
|
1558
|
+
else optionalConflicts.push(attendee.email);
|
|
1440
1559
|
}
|
|
1560
|
+
candidates.push({ ...slot, cost, date: local.date, optionalConflicts });
|
|
1561
|
+
}
|
|
1562
|
+
const sorted = [...candidates].sort(byTier);
|
|
1563
|
+
const picked = [];
|
|
1564
|
+
let first = 0;
|
|
1565
|
+
while (first < sorted.length && picked.length < input.maxResults) {
|
|
1566
|
+
let end = first + 1;
|
|
1567
|
+
while (end < sorted.length && byTier(sorted[first], sorted[end]) === 0) {
|
|
1568
|
+
end += 1;
|
|
1569
|
+
}
|
|
1570
|
+
picked.push(
|
|
1571
|
+
...spreadAcrossDays(
|
|
1572
|
+
sorted.slice(first, end),
|
|
1573
|
+
input.maxResults - picked.length
|
|
1574
|
+
)
|
|
1575
|
+
);
|
|
1576
|
+
first = end;
|
|
1441
1577
|
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
);
|
|
1446
|
-
picked.push(
|
|
1447
|
-
...spreadAcrossDays(
|
|
1448
|
-
candidates.filter((slot) => slot.optionalConflicts.length > 0),
|
|
1449
|
-
input.maxResults - picked.length
|
|
1450
|
-
)
|
|
1451
|
-
);
|
|
1452
|
-
return picked.sort((a, b) => a.startMs - b.startMs).map(({ endMs, optionalConflicts, startMs: startMs2 }) => ({
|
|
1578
|
+
return picked.sort(
|
|
1579
|
+
(a, b) => byTier(a, b) || byCost(a.cost, b.cost) || a.startMs - b.startMs
|
|
1580
|
+
).map(({ endMs, optionalConflicts, startMs }) => ({
|
|
1453
1581
|
endMs,
|
|
1454
1582
|
optionalConflicts,
|
|
1455
|
-
startMs
|
|
1583
|
+
startMs
|
|
1456
1584
|
}));
|
|
1457
1585
|
}
|
|
1458
1586
|
async function calendarTimeZone(ctx, email) {
|
|
@@ -1479,7 +1607,7 @@ function createFindMeetingTimesTool(ctx) {
|
|
|
1479
1607
|
openWorldHint: true,
|
|
1480
1608
|
readOnlyHint: true
|
|
1481
1609
|
},
|
|
1482
|
-
description: "Find meeting times when every required attendee is free and inside working hours in their own calendar time zone, using Google Calendar free/busy data from your own Google account. Returns open slots only, never event details. Slots
|
|
1610
|
+
description: "Find meeting times when every required attendee is free and inside working hours in their own calendar time zone, using Google Calendar free/busy data from your own Google account. Returns open slots only, never event details. Slots come best first: first days on which the attendees already have meetings, so days without meetings stay free; then the slots that keep the most focus time (free blocks of 2 hours, or 1 hour on days without a 2-hour block) for the attendees, then the ones that join existing meetings instead of adding an interruption. Slots also leave each attendee a lunch break inside their lunch window and do not make a run of back-to-back meetings longer than max_back_to_back_minutes. Offer them as a short list in that order; when the requester leaves the choice to you, take the first. Only people in the company's Google Workspace domains can be checked. People in `unavailable` were not checked: say so instead of treating them as free. If no slot is free, widen the window or shorten the meeting once, then offer the closest option.",
|
|
1483
1611
|
inputSchema: inputSchema3,
|
|
1484
1612
|
outputSchema: outputSchema3,
|
|
1485
1613
|
async execute(input) {
|
|
@@ -1502,6 +1630,11 @@ function createFindMeetingTimesTool(ctx) {
|
|
|
1502
1630
|
"workday_end must be after workday_start."
|
|
1503
1631
|
);
|
|
1504
1632
|
}
|
|
1633
|
+
if (input.lunch_minutes > clockMinutes(input.lunch_end) - clockMinutes(input.lunch_start)) {
|
|
1634
|
+
throw new PluginToolInputError3(
|
|
1635
|
+
"lunch_minutes must fit between lunch_start and lunch_end."
|
|
1636
|
+
);
|
|
1637
|
+
}
|
|
1505
1638
|
const optionalEmails = new Set(input.optional_attendees);
|
|
1506
1639
|
const attendees = (await withRequester(ctx, input.attendees)).filter(
|
|
1507
1640
|
(email) => input.attendees.includes(email) || !optionalEmails.has(email)
|
|
@@ -1556,6 +1689,10 @@ function createFindMeetingTimesTool(ctx) {
|
|
|
1556
1689
|
const slots = !slotAttendees.some((attendee) => attendee.required) ? [] : findFreeSlots({
|
|
1557
1690
|
attendees: slotAttendees,
|
|
1558
1691
|
durationMinutes: input.duration_minutes,
|
|
1692
|
+
lunchEnd: input.lunch_end,
|
|
1693
|
+
lunchMinutes: input.lunch_minutes,
|
|
1694
|
+
lunchStart: input.lunch_start,
|
|
1695
|
+
maxBackToBackMinutes: input.max_back_to_back_minutes,
|
|
1559
1696
|
maxResults: input.max_results,
|
|
1560
1697
|
timeMaxMs,
|
|
1561
1698
|
timeMinMs,
|
|
@@ -1940,7 +2077,7 @@ function createListCalendarEventsTool(ctx) {
|
|
|
1940
2077
|
organized_by_junior: event.organizer?.email?.toLowerCase() === ctx.accountEmail,
|
|
1941
2078
|
...event.recurringEventId ? { series_event_id: event.recurringEventId } : void 0,
|
|
1942
2079
|
...event.attendees ? { attendees: attendeeResults(event.attendees) } : void 0,
|
|
1943
|
-
...event.htmlLink ? { url: event.htmlLink } : void 0,
|
|
2080
|
+
...event.htmlLink ? { url: accountChooserLink(event.htmlLink, ctx.accountEmail) } : void 0,
|
|
1944
2081
|
...event.hangoutLink ? { video_call_url: event.hangoutLink } : void 0
|
|
1945
2082
|
})),
|
|
1946
2083
|
truncated: nextPageToken !== void 0,
|
|
@@ -2707,7 +2844,11 @@ function createUpdateCalendarEventTool(ctx) {
|
|
|
2707
2844
|
}
|
|
2708
2845
|
return {
|
|
2709
2846
|
target: "updateCalendarEvent",
|
|
2710
|
-
...ownEventResult(
|
|
2847
|
+
...ownEventResult(
|
|
2848
|
+
ownEventSchema.parse(response.body),
|
|
2849
|
+
timeZone,
|
|
2850
|
+
ctx.accountEmail
|
|
2851
|
+
)
|
|
2711
2852
|
};
|
|
2712
2853
|
}
|
|
2713
2854
|
});
|
|
@@ -12,13 +12,31 @@ export interface SlotAttendee {
|
|
|
12
12
|
timeZone: string;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Find slots
|
|
16
|
-
* time zone,
|
|
15
|
+
* Find slots when every required attendee is free, inside their working
|
|
16
|
+
* hours in their own time zone, and rank them by how little they disturb
|
|
17
|
+
* those days.
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Days on which more attendees already have a meeting come first, so days
|
|
20
|
+
* without meetings stay free. A day without meetings is used only when busy
|
|
21
|
+
* days have too few slots. The requester chose this over pure focus time.
|
|
22
|
+
*
|
|
23
|
+
* Then the rules follow Clockwise's public docs, not its code:
|
|
24
|
+
* - Focus time is the free time in blocks of at least 2 hours, or 1 hour on
|
|
25
|
+
* a day without a 2-hour block. Slots that remove the least focus time,
|
|
26
|
+
* summed over attendees, come first. Optional attendees count half.
|
|
27
|
+
* - Among equal slots, the one that adds the fewest new runs of meetings
|
|
28
|
+
* comes first, so a slot next to a meeting beats an isolated one.
|
|
29
|
+
* - A slot must leave each attendee a free gap of `lunchMinutes` inside
|
|
30
|
+
* their lunch window, if they had one. Set `lunchMinutes` to 0 to allow
|
|
31
|
+
* lunch meetings.
|
|
32
|
+
* - A slot must not make a run of back-to-back meetings longer than
|
|
33
|
+
* `maxBackToBackMinutes`. Gaps under 15 minutes count as back to back.
|
|
34
|
+
*
|
|
35
|
+
* Optional attendees who are busy or break these rules do not block a slot.
|
|
36
|
+
* Slots without such conflicts come first. Inside each group of equal
|
|
37
|
+
* conflicts and meeting days, options are spread across the days of
|
|
38
|
+
* `timeZone`. Results come best first. With `weekdays`, only those
|
|
39
|
+
* days of `timeZone` are searched.
|
|
22
40
|
*
|
|
23
41
|
* Exported for tests. Busy intervals come from Google free/busy only, so
|
|
24
42
|
* Junior never sees event titles or details.
|
|
@@ -26,6 +44,10 @@ export interface SlotAttendee {
|
|
|
26
44
|
export declare function findFreeSlots(input: {
|
|
27
45
|
attendees: SlotAttendee[];
|
|
28
46
|
durationMinutes: number;
|
|
47
|
+
lunchEnd: string;
|
|
48
|
+
lunchMinutes: number;
|
|
49
|
+
lunchStart: string;
|
|
50
|
+
maxBackToBackMinutes: number;
|
|
29
51
|
maxResults: number;
|
|
30
52
|
timeMaxMs: number;
|
|
31
53
|
timeMinMs: number;
|
|
@@ -50,6 +72,10 @@ export declare function createFindMeetingTimesTool(ctx: GoogleToolContext): impo
|
|
|
50
72
|
time_zone?: string | undefined;
|
|
51
73
|
workday_start: string;
|
|
52
74
|
workday_end: string;
|
|
75
|
+
lunch_start: string;
|
|
76
|
+
lunch_end: string;
|
|
77
|
+
lunch_minutes: number;
|
|
78
|
+
max_back_to_back_minutes: number;
|
|
53
79
|
weekdays?: ("Fri" | "Mon" | "Thu" | "Tue" | "Wed")[] | undefined;
|
|
54
80
|
max_results: number;
|
|
55
81
|
}, {
|
package/dist/tools/shared.d.ts
CHANGED
|
@@ -76,6 +76,20 @@ export declare const attendeeOutputSchema: z.ZodObject<{
|
|
|
76
76
|
}, z.core.$strip>;
|
|
77
77
|
/** Shape Google attendees for a tool result. Room resources are left out. */
|
|
78
78
|
export declare function attendeeResults(attendees: Array<z.infer<typeof googleAttendeeSchema>> | undefined): Array<z.infer<typeof attendeeOutputSchema>>;
|
|
79
|
+
/**
|
|
80
|
+
* Make a Google Calendar event link open in the viewer's Workspace account.
|
|
81
|
+
*
|
|
82
|
+
* Google opens a plain event link in the browser's default account, which is
|
|
83
|
+
* often a personal one. AccountChooser picks the signed-in account of the
|
|
84
|
+
* Workspace domain, then continues to the event. Everyone in a Slack thread
|
|
85
|
+
* sees the same link, so the domain comes from Junior's own account, not the
|
|
86
|
+
* requester. `authuser`, `authdomain`, `login_hint`, `hd` on the event link,
|
|
87
|
+
* and `/u/<email>/` do not work for every viewer.
|
|
88
|
+
*
|
|
89
|
+
* Returns the link unchanged for a consumer domain, a link that is not an
|
|
90
|
+
* event link, or a link that already goes through AccountChooser.
|
|
91
|
+
*/
|
|
92
|
+
export declare function accountChooserLink(url: string, accountEmail: string): string;
|
|
79
93
|
/** Event fields that Junior reads back from its own calendar. */
|
|
80
94
|
export declare const ownEventSchema: z.ZodObject<{
|
|
81
95
|
attendees: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -112,7 +126,7 @@ export type OwnEvent = z.infer<typeof ownEventSchema>;
|
|
|
112
126
|
* reply. The event id is the key, so a change replaces the saved card. The
|
|
113
127
|
* label is the short date for the sidebar; the card shows the full time.
|
|
114
128
|
*/
|
|
115
|
-
export declare function ownEventResult(event: OwnEvent, timeZone: string): {
|
|
129
|
+
export declare function ownEventResult(event: OwnEvent, timeZone: string, accountEmail: string): {
|
|
116
130
|
objectAnnotations: {
|
|
117
131
|
kind: "object";
|
|
118
132
|
key: string;
|
|
@@ -206,7 +220,8 @@ export declare const ownEventIdSchema: z.ZodString;
|
|
|
206
220
|
/**
|
|
207
221
|
* Return the event id from an id or a Google Calendar event link.
|
|
208
222
|
*
|
|
209
|
-
* A link's `eid` value is base64 for `<eventId> <calendar email>`.
|
|
223
|
+
* A link's `eid` value is base64 for `<eventId> <calendar email>`. An
|
|
224
|
+
* AccountChooser link holds the event link in `continue`.
|
|
210
225
|
*/
|
|
211
226
|
export declare function parseEventId(value: string): string;
|
|
212
227
|
/** Result of reading an event that Junior organizes. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-google",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.278.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"commander": "^14.0.3",
|
|
26
26
|
"drizzle-orm": "^0.45.2",
|
|
27
27
|
"zod": "^4.5.4",
|
|
28
|
-
"@sentry/junior-plugin-api": "0.
|
|
28
|
+
"@sentry/junior-plugin-api": "0.278.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@oxlint/plugins": "1.79.0",
|