API 与服务器(后端)7.6k · #13203
slot-engine
它能做什么
这项技能描述计算哪些会议时段开放的函数,以及它始终遵循的规则。适合需要基于它进行开发,或需要找出某个时间缺失原因的开发者。
适用场景
- ✓当预约页面上缺少某个会议时间,你需要找出原因的时候。
- ✓当你修改可用时间的计算方式的时候。
- ✓当你需要知道计算所保证的内容,例如不会出现过去时段的时候。
技能链接
https://github.com/BuilderIO/agent-native/blob/main/packages/scheduling/docs/skills/slot-engine/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
请用这个技能帮我:https://github.com/BuilderIO/agent-native/blob/main/packages/scheduling/docs/skills/slot-engine/SKILL.md
阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
npx skills add BuilderIO/agent-native --skill slot-engine
下载 SKILL.md,放进智能体的技能文件夹。
curl -L https://raw.githubusercontent.com/BuilderIO/agent-native/main/packages/scheduling/docs/skills/slot-engine/SKILL.md -o SKILL.md
可以这样问 AI
“为什么我的预约页面上周二下午 2 点没有显示为可预约?请帮我查明原因。”
每周 5 个新技能,1 分钟读完。
工作原理
该函数接收会议规则、日程、忙碌时段和现有预约数量,并返回一个时段列表。排查时需要检查该日的每周工作时间、日期变更和忙碌时段。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Slot engine
import { computeAvailableSlots } from "@agent-native/scheduling/core"
Inputs
- Event type config (duration, buffers, minimum notice, period, limits, slot interval)
- Schedule (timezone + weekly availability + date overrides)
- Busy intervals (UTC, aggregated from external calendars + existing bookings)
- Booking counts by bucket (day/week/month/year) for limit enforcement
- Time range to compute over
- Optional seats-per-slot + seats-taken map
- Viewer timezone (for limit bucketing, if it differs from the schedule)
Output
- Array of
Slot { start: ISO, end: ISO, available: boolean, seatsRemaining?, hostEmail? }
Invariants
The function guarantees, in order:
- No slot falls in the past (
now + minimumBookingNoticeis the floor). - No slot overlaps a busy interval (with buffers applied).
- No slot falls outside the schedule's available intervals for that day.
- No slot exceeds a booking limit.
- No slot falls outside the event's period (rolling/range).
- DST-safe: we convert to UTC using the schedule's timezone before doing any interval arithmetic.
Debugging
If a slot is unexpectedly missing:
- Check the schedule's weekly availability for that day-of-week in the schedule's timezone (not UTC — weekends can shift across the date line).
- Check date overrides for that local date (empty intervals = fully blocked).
- Check merged busy intervals for overlap, including the before/after buffer expansion.
- Check booking limits: a single existing booking can close a day.
- Check period caps: rolling periods restrict how far in the future slots appear.
If a slot is unexpectedly present:
- Check that
nowis being passed correctly (defaults tonew Date()). - Check that busy intervals from providers are in UTC.
- Confirm slot interval matches what you expect (default = duration).
常见问题
函数会返回过去的时段吗?
不会。早于最短提前通知期限的时间绝不会提供。
夏令时如何处理?
在进行任何计算之前,时间会先按日程的时区进行转换。
时段缺失时我应先检查什么?
该日在日程自身时区中的每周工作时间。
详情
作者的原始描述
The pure `computeAvailableSlots` function — inputs, outputs, invariants, and debugging guide.
repo: BuilderIO/agent-native
热度
- GitHub 星标
- 7.6k
- 排名
- #13203
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …