slotlock 0.2.0 → 0.5.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/CHANGELOG.md +582 -0
- package/CONTRIBUTING.md +35 -8
- package/GOVERNANCE.md +4 -2
- package/MAINTAINERS.md +3 -2
- package/NOTICE +4 -4
- package/README.md +498 -65
- package/SECURITY.md +31 -2
- package/SPEC.md +142 -15
- package/agent-server.d.ts +62 -10
- package/agent-server.js +577 -105
- package/agent-store-backend.d.ts +12 -0
- package/agent-store-backend.js +1115 -55
- package/api-keys.d.ts +11 -3
- package/api-keys.js +29 -6
- package/application-api.d.ts +35 -1
- package/application-api.js +683 -12
- package/booking-rules.d.ts +84 -0
- package/booking-rules.js +149 -0
- package/config.d.ts +112 -0
- package/config.js +225 -0
- package/dashboard.d.ts +67 -5
- package/dashboard.js +1012 -140
- package/ddl.d.ts +45 -3
- package/ddl.js +1124 -13
- package/engine.d.ts +5 -0
- package/engine.js +23 -6
- package/event-feed.d.ts +178 -0
- package/event-feed.js +435 -0
- package/event-schema.d.ts +59 -0
- package/event-schema.js +85 -0
- package/ical-worker-thread.js +4 -2
- package/ical-worker.d.ts +8 -5
- package/ical-worker.js +9 -2
- package/index.d.ts +12 -6
- package/index.js +9 -4
- package/interop.d.ts +117 -0
- package/interop.js +356 -0
- package/maintenance.d.ts +27 -5
- package/maintenance.js +92 -28
- package/mcp-app.d.ts +7 -1
- package/mcp-app.js +259 -40
- package/metrics.d.ts +24 -0
- package/metrics.js +167 -0
- package/node-server.d.ts +9 -1
- package/node-server.js +7 -2
- package/openapi.json +10970 -0
- package/package.json +3 -2
- package/rate-limit.d.ts +80 -0
- package/rate-limit.js +741 -0
- package/rest-api.d.ts +22 -0
- package/rest-api.js +166 -11
- package/rules.js +6 -3
- package/self-host.d.ts +45 -8
- package/self-host.js +616 -46
- package/slotlock-manifest.schema.json +7 -1
- package/slotlock.manifest.json +8 -2
- package/store.d.ts +647 -28
- package/store.js +2982 -327
- package/sync.d.ts +43 -2
- package/sync.js +1515 -323
- package/timezone.d.ts +58 -3
- package/timezone.js +249 -20
- package/types.d.ts +300 -9
- package/types.js +0 -2
- package/webhooks.d.ts +91 -0
- package/webhooks.js +300 -0
package/SECURITY.md
CHANGED
|
@@ -22,6 +22,20 @@ Do not include real customer, credential, calendar, or booking data. We will ack
|
|
|
22
22
|
within three business days and coordinate disclosure after a fix is available. Fixed vulnerabilities
|
|
23
23
|
are published as advisories at <https://github.com/PILOTAAI/slotlock/security/advisories>.
|
|
24
24
|
|
|
25
|
+
## Testing hosted Slotlock
|
|
26
|
+
|
|
27
|
+
Hosted Slotlock (`slotlock-api.pylota.io` and `app.slotlock.pylota.io`, run by TREFT LTD) is in scope,
|
|
28
|
+
under these rules, which its [Terms of Service](TERMS.md) and
|
|
29
|
+
[Acceptable Use Policy](ACCEPTABLE-USE.md) refer to:
|
|
30
|
+
|
|
31
|
+
- Test only against an account of your own, signed in with your own GitHub account.
|
|
32
|
+
- Never read, change or keep another account's data. If a test reaches any, stop and report it at
|
|
33
|
+
once, and delete what you saw.
|
|
34
|
+
- Run no denial of service, load test or automated scanning that sends more than the published
|
|
35
|
+
limits ([hosted service page](docs/hosted/README.md#limits)); run Slotlock yourself for that.
|
|
36
|
+
- Report through private vulnerability reporting as above, and give us the time to fix it before
|
|
37
|
+
you disclose anything.
|
|
38
|
+
|
|
25
39
|
## Security model
|
|
26
40
|
|
|
27
41
|
Slotlock treats all external calendar content as untrusted. The parser has explicit size, component,
|
|
@@ -108,7 +122,20 @@ protected-resource metadata, when configured, only tells clients where to obtain
|
|
|
108
122
|
embedder's `authenticate` must verify every token, including its audience. Embedders must provide
|
|
109
123
|
bearer-token verification, per-principal authorization, distributed rate limiting, TLS termination,
|
|
110
124
|
and a readiness check. Do not place provider credentials or raw calendar content in authentication,
|
|
111
|
-
authorization, rate-limit, or health callbacks.
|
|
125
|
+
authorization, rate-limit, or health callbacks. `slotlock serve`, its own embedder, limits requests
|
|
126
|
+
per client address before any credential is looked up, then per key, per tenant and for the whole
|
|
127
|
+
server, caps writes that expand a recurring series, maintenance runs and live-update streams per
|
|
128
|
+
tenant, answers a full key-lookup queue as busy rather than unauthenticated, and logs counts of
|
|
129
|
+
refusals with each client as a pseudonym (`SLOTLOCK_LIMITS`, `SLOTLOCK_TRUSTED_PROXY_HEADER`). A
|
|
130
|
+
key that authenticated in the last 15 minutes waits in a lookup queue of its own, served first; a
|
|
131
|
+
valid key that has not authenticated in the last 15 minutes (any key, after a restart) waits with
|
|
132
|
+
made-up keys and may be answered busy (503 with `Retry-After`) while a flood of them lasts, never
|
|
133
|
+
401. Its counts are one process's: several instances each limit alone.
|
|
134
|
+
|
|
135
|
+
Write confirmation (MCP 2026-07-28 form elicitation) seals the pending write to the caller, the tool
|
|
136
|
+
and its exact arguments, but the answer comes from the client: Slotlock relies on the MCP client to
|
|
137
|
+
ask its person, and a key holder's own client can answer yes. It keeps an agent from writing unasked;
|
|
138
|
+
it is not an authorization boundary. Scopes and `authorize` decide who may write.
|
|
112
139
|
|
|
113
140
|
## API keys and the application API
|
|
114
141
|
|
|
@@ -118,7 +145,9 @@ bits) and a 6-character checksum, and the database keeps only its SHA-256. A slo
|
|
|
118
145
|
238 random bits, so a fast hash
|
|
119
146
|
loses nothing and lets every request look a key up by its digest in one indexed read. Code scanners
|
|
120
147
|
that treat every secret as a password report this as weak hashing (CodeQL
|
|
121
|
-
`js/insufficient-password-hash`); it is the design, as for GitHub's and Stripe's tokens.
|
|
148
|
+
`js/insufficient-password-hash`); it is the design, as for GitHub's and Stripe's tokens. The
|
|
149
|
+
repository's CodeQL configuration (`.github/codeql/codeql-config.yml`) drops that one query with
|
|
150
|
+
this reason beside it, rather than dismissing its alerts one by one.
|
|
122
151
|
|
|
123
152
|
A key acts only in the tenant it was created for. `read` and `write` cover the agent tools; `admin`
|
|
124
153
|
covers the application API (resources, hours, holds, reservations, coverage, maintenance), which is
|
package/SPEC.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Slotlock agent-calendar specification 1.0
|
|
2
2
|
|
|
3
|
-
This document defines the interoperable scheduling semantics of Slotlock 0.
|
|
4
|
-
different transports or persistence layers, but must preserve these rules
|
|
3
|
+
This document defines the interoperable scheduling semantics of Slotlock 0.2 and later.
|
|
4
|
+
Implementations may use different transports or persistence layers, but must preserve these rules
|
|
5
|
+
when claiming compatibility. Which of them may change between releases is in VERSIONING.md.
|
|
5
6
|
|
|
6
7
|
## Resource model
|
|
7
8
|
|
|
@@ -15,8 +16,71 @@ rule assumes a particular industry.
|
|
|
15
16
|
- Availability rules use local wall time in the resource's IANA timezone.
|
|
16
17
|
- Every interval is half-open `[start, end)`. `end` must be strictly after `start`.
|
|
17
18
|
- Adjacent intervals do not conflict. Overlapping or touching availability windows may be merged.
|
|
18
|
-
-
|
|
19
|
-
|
|
19
|
+
- An event's time zone is an IANA name, kept in its canonical spelling (`europe/london` is stored
|
|
20
|
+
as `Europe/London`). A UTC offset such as `+05:00` is not a zone, and an event in one is refused.
|
|
21
|
+
- An event time in an hour the clocks skip moves forward by the gap, and one in an hour they repeat
|
|
22
|
+
is its first instant (RFC 5545 §3.3.5), except where "Daylight-saving time" below says otherwise.
|
|
23
|
+
- An availability window's edge in an hour the clocks skip stands where that hour ends, so a window
|
|
24
|
+
holds only the wall times it names that exist: in New York on 2027-03-14, [02:30, 03:30) is
|
|
25
|
+
03:00-03:30 EDT and [02:00, 02:30) is nothing. An edge in a repeated hour is its first instant.
|
|
26
|
+
|
|
27
|
+
## Daylight-saving time
|
|
28
|
+
|
|
29
|
+
An occurrence of a timed recurring event starts at its wall time read as above, and ends at the
|
|
30
|
+
later of two readings:
|
|
31
|
+
|
|
32
|
+
- its exact end: its start plus the series' exact length, DTEND − DTSTART as instants (RFC 5545
|
|
33
|
+
§3.8.5.3), or its DURATION, whose days and weeks are calendar days and whose hours, minutes and
|
|
34
|
+
seconds are exact (§3.3.6);
|
|
35
|
+
- its wall-clock end: DTEND's wall time as written, carried to the occurrence's date (one written
|
|
36
|
+
in an hour the clocks skip is carried as written), the later instant where the clocks repeat
|
|
37
|
+
that hour. A stored series keeps its first occurrence as instants, and reads this end from its
|
|
38
|
+
end instant.
|
|
39
|
+
|
|
40
|
+
It occupies `[start, later end)`, so whichever way people read an occurrence that the clocks
|
|
41
|
+
change inside, none of the time they hold is offered as free. A stored series' first occurrence
|
|
42
|
+
starts at the instant stored, which may be the second pass of a repeated hour. One-off events,
|
|
43
|
+
overrides (moved occurrences) and PERIOD RDATEs occupy exactly the times they give. Display and
|
|
44
|
+
export keep each event as written. Feeds, the trusted importer and the store read events this way
|
|
45
|
+
in every zone, including zones whose rules changed in the past and zones a feed defines only by
|
|
46
|
+
its VTIMEZONE.
|
|
47
|
+
|
|
48
|
+
A series' occurrences never overlap each other. Where one ends after the next starts (24 exact
|
|
49
|
+
hours from midnight run to 01:00 the night the clocks go forward, or an occurrence is longer than
|
|
50
|
+
the series' period), it ends where the next starts, and the next ends at the later of the two ends.
|
|
51
|
+
Together they hold the same time, and the store, which keeps each occurrence as a reservation
|
|
52
|
+
under one EXCLUDE constraint, can hold them. Two that start at the same instant are left as they
|
|
53
|
+
are. An all-day series occupies whole local days, from one local midnight to the next (a midnight
|
|
54
|
+
the clocks skip moves forward).
|
|
55
|
+
|
|
56
|
+
| Case | Example | Occupies |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| The clocks go forward inside an occurrence | London, daily 00:00-06:00, 2027-03-28 | six exact hours, 00:00Z-06:00Z |
|
|
59
|
+
| The clocks go back inside an occurrence | London, daily 00:00-06:00, 2026-10-25 | seven wall-clock hours, 2026-10-24 23:00Z-06:00Z |
|
|
60
|
+
| The clocks go back, southern hemisphere | Santiago, daily 22:00-04:00, night of 2027-04-03 | seven hours, 2027-04-04 01:00Z-08:00Z |
|
|
61
|
+
| The clocks go forward, southern hemisphere | Auckland, daily 00:00-06:00, 2027-09-26 | six hours, 2027-09-25 12:00Z-18:00Z |
|
|
62
|
+
| A day long, the clocks go forward | London, daily 00:00-00:00 from 2027-03-26 | on 2027-03-28, 00:00Z-23:00Z, where the next day starts |
|
|
63
|
+
| A week long, the clocks go forward | New York, weekly 00:00 for 168 hours from 2027-03-07 | the second week 2027-03-14 05:00Z to 03-21 04:00Z |
|
|
64
|
+
| An all-day series | Santiago, daily from 2027-09-03 | on 2027-09-05, 04:00Z (01:00, midnight being skipped) to 09-06 03:00Z |
|
|
65
|
+
| An occurrence starts in the skipped hour | Berlin, daily 02:30 for 75 minutes, 2027-03-28 | 75 exact minutes from 01:30Z (03:30 CEST) |
|
|
66
|
+
| A half-hour change | Lord Howe, daily 02:00-02:45, 2027-10-03 | 45 minutes from 2027-10-02 15:30Z |
|
|
67
|
+
| DTEND falls in the repeated hour | New York, daily 23:00-01:30 from 2026-10-31 | 2026-11-01 03:00Z to the later 01:30, 06:30Z |
|
|
68
|
+
| DTEND falls in the skipped hour | New York, daily 01:00-02:30 from 2027-03-14 | the first 06:00Z-07:30Z, as written; later days 90 minutes, to the written 02:30 |
|
|
69
|
+
| The first instance spans the change | Berlin, weekly 01:00-04:00 from 2027-03-28 | as written, 00:00Z-02:00Z; later weeks three hours |
|
|
70
|
+
| An occurrence starts in the repeated hour | London, daily 01:15-01:45 from 2026-10-20 | on 2026-10-25, its first 01:15 (00:15Z) to the later 01:45 (01:45Z) |
|
|
71
|
+
| A stored first occurrence in the repeated hour | London, stored from 2026-10-25 01:15Z | the second 01:15, as stored |
|
|
72
|
+
| A length the clocks reduce to nothing | DTSTART and DTEND both in one skipped hour, the end at its close | refused |
|
|
73
|
+
|
|
74
|
+
A series whose DTSTART the clocks skip is read from a feed (from the offset before the gap) but is
|
|
75
|
+
not stored: no instant reads back as its wall time. The same holds for an all-day series whose
|
|
76
|
+
first day's midnight the clocks skip (Santiago and Havana go forward at midnight). The trusted
|
|
77
|
+
importer stores an all-day series as a timed one from local midnight to local midnight, which the
|
|
78
|
+
union rule holds to its exact length too: where the clocks go forward on one of its days, or at the
|
|
79
|
+
midnight its first occurrence ends, it may also hold the hour after a midnight that the feed's days
|
|
80
|
+
do not, never less. The trusted importer does not store a timed series whose DTEND the clocks skip, or
|
|
81
|
+
whose DURATION counts days or weeks outside UTC: kept as its first occurrence's instants, the first
|
|
82
|
+
would hold an hour the feed does not on every later day, and the second on each day it spans that
|
|
83
|
+
the clocks go forward.
|
|
20
84
|
|
|
21
85
|
## Availability
|
|
22
86
|
|
|
@@ -24,7 +88,7 @@ Availability is the intersection of explicit bookable windows and the complement
|
|
|
24
88
|
No rule means no availability. Unsupported or invalid rules contribute no availability. A next-slot
|
|
25
89
|
answer must fit wholly inside the resulting free set for the requested positive duration.
|
|
26
90
|
|
|
27
|
-
|
|
91
|
+
Weekly availability supports RRULE cadence with explicit `BYDAY`, interval 1, optional absolute
|
|
28
92
|
`UNTIL`, a local start minute, and a positive duration. Rules requiring an authored recurrence anchor
|
|
29
93
|
such as `COUNT` or interval greater than 1 fail closed.
|
|
30
94
|
|
|
@@ -33,7 +97,9 @@ such as `COUNT` or interval greater than 1 fail closed.
|
|
|
33
97
|
- The persistence layer is the final conflict arbiter; an application pre-check is not authority.
|
|
34
98
|
- A live hold occupies the same range as a confirmed reservation until its database-clock expiry.
|
|
35
99
|
- Confirm and release operations are atomic and idempotent for their expected retry cases.
|
|
36
|
-
- A
|
|
100
|
+
- A hold lasts at most 7 days from its creation.
|
|
101
|
+
- A trailing buffer extends occupied time without changing the customer-visible end instant. It is
|
|
102
|
+
at most 30 days, and holds and reservations alike respect it.
|
|
37
103
|
- External commands use `(tenantRef, externalRef)` as stable identity and a strictly increasing
|
|
38
104
|
positive revision. A replay with the same revision and payload is idempotent; drift is rejected.
|
|
39
105
|
- Cancellation leaves a revisioned tombstone so delayed delivery cannot resurrect the identity.
|
|
@@ -58,6 +124,13 @@ the provider, map a connection to one resource, normalize status/transparency/re
|
|
|
58
124
|
durable cursor and coverage window, and reconcile deletions. iCalendar parsing must remain bounded by
|
|
59
125
|
input size, components, exceptions, occurrences, work, and expansion horizon.
|
|
60
126
|
|
|
127
|
+
A feed's overrides occupy what the provider shows: one without DTEND or DURATION lasts its series'
|
|
128
|
+
length, and one whose RECURRENCE-ID names no occurrence, or whose occurrence the series also
|
|
129
|
+
EXDATEs, occupies its own time. The instances of a CalDAV-expanded series are each read, the first
|
|
130
|
+
with or without a RECURRENCE-ID. An event with both DTEND and DURATION is refused (RFC 5545
|
|
131
|
+
§3.6.1). A reader that can name refused series refuses one series at a time and reads the rest of
|
|
132
|
+
the feed; one that cannot refuses the feed, so a refused series is never read as free time.
|
|
133
|
+
|
|
61
134
|
Content not required for conflict decisions should be discarded before reaching an agent. Outbound
|
|
62
135
|
iCalendar updates retain stable UID and monotonic sequence; cancellation is explicit.
|
|
63
136
|
|
|
@@ -71,12 +144,37 @@ the key with drift fails. Cancellation atomically removes derived occupation and
|
|
|
71
144
|
tombstone; delayed create delivery cannot resurrect the UID.
|
|
72
145
|
|
|
73
146
|
Events may carry organizer, attendees, roles, participation status, RSVP requests, display/email
|
|
74
|
-
relative reminders, one RFC 5545 RRULE, and bounded recurrence exceptions. A materialization window
|
|
75
|
-
mandatory for recurring events, must not exceed 367 days, and may produce at most 2,000
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
147
|
+
relative reminders, one RFC 5545 RRULE, and bounded recurrence exceptions. A materialization window
|
|
148
|
+
is mandatory for recurring events, must not exceed 367 days, and may produce at most 2,000
|
|
149
|
+
occurrences. Expansion is bounded by a count of work, never a clock, so an input is accepted or
|
|
150
|
+
refused the same way however loaded the machine: each series may pass 4,000 occurrences from its
|
|
151
|
+
start, and an expansion may take 50,000 steps for an event as it is written and 500,000 for a feed
|
|
152
|
+
or a stored series as maintenance rolls it. A step of ical.js's search costs three, a weekday it
|
|
153
|
+
compares one, a day it walks a fifth, a year it scans three and an eighth for each day that scan
|
|
154
|
+
lists, and a weekday of a year it lists half. Each occurrence passed costs one, each conversion of a
|
|
155
|
+
time in an IANA zone half (one and a half in a zone only a feed defines), and each instant Intl is
|
|
156
|
+
asked for to read a zone's offsets five, charged the first time the expansion reads that day of the
|
|
157
|
+
zone whatever was read before it. Each change listed when a feed's own zone is expanded costs four
|
|
158
|
+
tenths. A zone written the way Outlook writes them, from 1601, costs about 6,000.
|
|
159
|
+
|
|
160
|
+
A stored rule is daily or less frequent, follows RFC 5545 §3.3.10's grammar (every part known and
|
|
161
|
+
given once, `COUNT` at least 1, never `COUNT` with `UNTIL`), and is of a shape the expander reads
|
|
162
|
+
as RFC 5545 does: `BYWEEKNO`, a two-digit `BYDAY` ordinal, `BYSETPOS` other than with
|
|
163
|
+
`FREQ=MONTHLY` and `BYDAY` alone, `BYMONTH` with `FREQ=MONTHLY`, a negative `BYMONTHDAY` other
|
|
164
|
+
than with `FREQ=MONTHLY` and no `BYDAY`, `FREQ=YEARLY` with `BYMONTHDAY` but no `BYMONTH` or with a
|
|
165
|
+
day none of its months has, with `COUNT` or `BYDAY` and a day one of its months can lack, with
|
|
166
|
+
`BYYEARDAY` and `BYMONTH` or `BYMONTHDAY`, or with a numbered `BYDAY` and `BYMONTHDAY`, and time
|
|
167
|
+
parts with `FREQ=MONTHLY` or `YEARLY` are refused, with a reason. A yearly day some years lack (29
|
|
168
|
+
February, or a 31st with April) occurs only in the years that have it (RFC 5545 §3.3.10), so its
|
|
169
|
+
rule must be its series' only source of occurrences, with no RDATE or second RRULE. A DATE `UNTIL`
|
|
170
|
+
on a timed series includes its whole day on the series' clock.
|
|
171
|
+
|
|
172
|
+
A recurrence exception names the occurrence it changes by that occurrence's instant, exported as a
|
|
173
|
+
UTC `RECURRENCE-ID`; one that names no occurrence is refused. Opaque occurrences are reservations
|
|
174
|
+
under the same PostgreSQL EXCLUDE constraint as bookings and holds. Transparent occurrences remain
|
|
175
|
+
queryable but occupy no resource. An event update replaces its materialized set transactionally,
|
|
176
|
+
so an overlap rolls the entire mutation back and preserves the prior event. An exported calendar
|
|
177
|
+
holds a VTIMEZONE (RFC 5545 §3.6.5) for the zone its times name, written from the IANA rules.
|
|
80
178
|
|
|
81
179
|
Full event content is accepted only by the explicit trusted parser. The provider-normalization parser's
|
|
82
180
|
return type contains only identity, recurrence identity, interval, deletion, busy, and revision. A
|
|
@@ -89,7 +187,8 @@ contains the entire window. Any missing, stale, or partial source is returned by
|
|
|
89
187
|
silently treated as free time.
|
|
90
188
|
|
|
91
189
|
An event has a finite, positive duration. A one-off event may last up to 3,660 days and its
|
|
92
|
-
occupation matches the event exactly; a recurring event's occurrences are materialized as above
|
|
190
|
+
occupation matches the event exactly; a recurring event's occurrences are materialized as above,
|
|
191
|
+
each occupying what "Daylight-saving time" says. An
|
|
93
192
|
all-day (`VALUE=DATE`) iCalendar event covers whole local days of the calendar's timezone, from local
|
|
94
193
|
midnight to local midnight, taken from the caller's calendar timezone, else the feed's
|
|
95
194
|
`X-WR-TIMEZONE`; with neither the input is refused, never read in the server's zone. An all-day
|
|
@@ -205,8 +304,10 @@ that span changed, so the passage of time alone announces nothing. It ends a
|
|
|
205
304
|
subscription gracefully, with the listen request's result, at its maximum duration, on shutdown, or
|
|
206
305
|
when a re-read is refused as unauthenticated, unauthorized or not found; it closes the stream without
|
|
207
306
|
a result after three consecutive failed re-reads or when the reader leaves more than 256 events
|
|
208
|
-
unread. Open subscriptions, counted from the moment they start opening, are capped per principal
|
|
209
|
-
per server.
|
|
307
|
+
unread. Open subscriptions, counted from the moment they start opening, are capped per principal,
|
|
308
|
+
per tenant and per server. When the server is full, a listen from a tenant holding fewer than the
|
|
309
|
+
tenant holding most, less one, ends that tenant's oldest open stream gracefully, as at shutdown,
|
|
310
|
+
rather than being refused. A subscription that honors nothing ends right after its acknowledgment.
|
|
210
311
|
|
|
211
312
|
### Discovery and authorization
|
|
212
313
|
|
|
@@ -220,6 +321,32 @@ so each must be a canonical URL without credentials, query or fragment: `https`,
|
|
|
220
321
|
when `allowInsecureLocalhost` is set. Publishing metadata grants nothing: the embedder's
|
|
221
322
|
`authenticate` verifies every token, including its audience.
|
|
222
323
|
|
|
324
|
+
### Scopes, API keys and the application API
|
|
325
|
+
|
|
326
|
+
Every authenticated principal carries a tenant and scopes from `read`, `write` and `admin`. A read
|
|
327
|
+
operation needs `read`; an event write needs `write`. The application API (resources, weekly hours,
|
|
328
|
+
holds, reservations, coverage, every key's events, the tenant itself and maintenance, as REST under
|
|
329
|
+
`/v1` beside the tools) needs `admin`. It is never an MCP tool or an A2A skill and never waits for a
|
|
330
|
+
confirmation. Through it a tenant may cancel any of its events, whichever key wrote it, and, only
|
|
331
|
+
where the server allows it and with its own reference as confirmation, erase itself; it never
|
|
332
|
+
suspends itself or lifts a suspension, which only the deployment role does.
|
|
333
|
+
|
|
334
|
+
An API key is a random secret, stored only as its SHA-256 digest and reached only through
|
|
335
|
+
`SECURITY DEFINER` functions. It acts in the tenant it was created in, with the scopes it was given
|
|
336
|
+
(`read` and `write` by default), until it expires (at most 3,650 days) or is revoked. A tenant holds
|
|
337
|
+
at most 100 active keys and 1,000 in all. The digest of a rotated or erased key is kept, so that key
|
|
338
|
+
is never valid again. A server's own bearer token is never `admin`.
|
|
339
|
+
|
|
340
|
+
A dashboard signs a person in with GitHub, asking for no scope, to the tenant `github:<user id>`,
|
|
341
|
+
and manages that tenant's keys, resources (at most 100) and weekly hours.
|
|
342
|
+
|
|
343
|
+
### Maintenance
|
|
344
|
+
|
|
345
|
+
Recurring events are materialized up to the rolling horizon. Maintenance extends each series to it
|
|
346
|
+
and deletes commands and tombstones past the retention window, in bounded batches; a run that
|
|
347
|
+
reaches its batch limit says so, and the next run continues. `slotlock serve` maintains each tenant
|
|
348
|
+
it serves every hour; `slotlock maintain` and the application API run it on demand.
|
|
349
|
+
|
|
223
350
|
### Principal-scoped events, quotas and retention
|
|
224
351
|
|
|
225
352
|
`createSlotlockStoreAgentBackend` is the canonical binding to the PostgreSQL kernel. It derives an
|
package/agent-server.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare const SLOTLOCK_A2A_TASK_STATES: readonly ["TASK_STATE_UNSPECIFIED
|
|
|
40
40
|
* Operation (MCP tool / A2A skill) names. They use only `[a-z_]`, so they are valid tool names for the
|
|
41
41
|
* Claude Messages API (`^[a-zA-Z0-9_-]{1,128}$`), OpenAI function calling and every MCP host.
|
|
42
42
|
*/
|
|
43
|
-
export type SlotlockAgentOperation = 'slotlock_list_resources' | 'slotlock_get_free_busy' | 'slotlock_find_next_available' | 'slotlock_create_event' | 'slotlock_get_event' | 'slotlock_list_events' | 'slotlock_update_event' | 'slotlock_delete_event';
|
|
43
|
+
export type SlotlockAgentOperation = 'slotlock_list_resources' | 'slotlock_get_free_busy' | 'slotlock_find_next_available' | 'slotlock_find_available_slots' | 'slotlock_hold_slots' | 'slotlock_release_slots' | 'slotlock_book_together' | 'slotlock_book_pool' | 'slotlock_get_pool_availability' | 'slotlock_create_event' | 'slotlock_get_event' | 'slotlock_list_events' | 'slotlock_update_event' | 'slotlock_delete_event';
|
|
44
44
|
/**
|
|
45
45
|
* Names earlier builds published, which every entry point still accepts and dispatches as the same
|
|
46
46
|
* operation; nothing advertises them. The dotted names came first, before tool names had to be
|
|
@@ -79,7 +79,13 @@ export interface SlotlockAgentInvocationContext {
|
|
|
79
79
|
export declare class SlotlockAgentOperationError extends Error {
|
|
80
80
|
readonly code: string;
|
|
81
81
|
readonly status: number;
|
|
82
|
-
|
|
82
|
+
/**
|
|
83
|
+
* What the refusal is about, beside its code (the resource a bundle was refused on, say): at most
|
|
84
|
+
* five snake_case names with text values of up to 200 characters; anything else is dropped. Every
|
|
85
|
+
* protocol carries them next to `code`.
|
|
86
|
+
*/
|
|
87
|
+
readonly details?: Readonly<Record<string, string>>;
|
|
88
|
+
constructor(code: string, status: number, details?: Record<string, string>);
|
|
83
89
|
}
|
|
84
90
|
export interface SlotlockAgentCalendarBackend {
|
|
85
91
|
listResources(context: SlotlockAgentInvocationContext, input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
@@ -101,6 +107,25 @@ export interface SlotlockAgentCalendarBackend {
|
|
|
101
107
|
name: string | null;
|
|
102
108
|
timezone: string | null;
|
|
103
109
|
} | null>;
|
|
110
|
+
/**
|
|
111
|
+
* Optional. Hold up to five candidate slots for this principal, as alternatives in one group
|
|
112
|
+
* (`slotlock_hold_slots`); a tool without it answers `holds_unavailable`.
|
|
113
|
+
*/
|
|
114
|
+
holdSlots?(context: SlotlockAgentInvocationContext, input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
115
|
+
/** Optional. Book any one free member of a pool (`slotlock_book_pool`), else `pools_unavailable`. */
|
|
116
|
+
bookPool?(context: SlotlockAgentInvocationContext, input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
117
|
+
/**
|
|
118
|
+
* Optional. How many of a pool's members are free across a window
|
|
119
|
+
* (`slotlock_get_pool_availability`), else `pools_unavailable`.
|
|
120
|
+
*/
|
|
121
|
+
getPoolAvailability?(context: SlotlockAgentInvocationContext, input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
122
|
+
/**
|
|
123
|
+
* Optional. Book one interval on several resources in one transaction, all or none
|
|
124
|
+
* (`slotlock_book_together`); a tool without it answers `bundles_unavailable`.
|
|
125
|
+
*/
|
|
126
|
+
bookTogether?(context: SlotlockAgentInvocationContext, input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
127
|
+
/** Optional. Release one of this principal's holds with its group (`slotlock_release_slots`). */
|
|
128
|
+
releaseSlots?(context: SlotlockAgentInvocationContext, input: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
104
129
|
}
|
|
105
130
|
/**
|
|
106
131
|
* OAuth 2.0 discovery for the MCP endpoint (MCP 2025-11-25 authorization, RFC 9728). Slotlock only
|
|
@@ -120,13 +145,16 @@ export interface SlotlockAgentServerOAuthOptions {
|
|
|
120
145
|
resourceDocumentation?: string;
|
|
121
146
|
}
|
|
122
147
|
/** The operations that change a calendar; the only ones a confirmation can guard. */
|
|
123
|
-
export type SlotlockAgentWriteOperation = Extract<SlotlockAgentOperation, 'slotlock_create_event' | 'slotlock_update_event' | 'slotlock_delete_event'>;
|
|
148
|
+
export type SlotlockAgentWriteOperation = Extract<SlotlockAgentOperation, 'slotlock_create_event' | 'slotlock_update_event' | 'slotlock_delete_event' | 'slotlock_book_together' | 'slotlock_book_pool'>;
|
|
124
149
|
/**
|
|
125
150
|
* Human confirmation before a write (MCP 2026-07-28 multi round-trip requests + form elicitation).
|
|
126
151
|
* A listed write first answers `input_required` with a yes/no form describing the change; it runs
|
|
127
152
|
* only when the client retries with the person's explicit acceptance and the sealed state it was
|
|
128
153
|
* given. Where no confirmation is possible — the 2025 MCP revisions and A2A — a listed write fails
|
|
129
|
-
* with `confirmation_required`, never silently runs.
|
|
154
|
+
* with `confirmation_required`, never silently runs. The acceptance comes from the client, which a
|
|
155
|
+
* key holder controls: confirmation keeps an agent from writing unasked, and is not an
|
|
156
|
+
* authorization boundary (scopes and `authorize` are). Off unless set; `slotlock serve` sets it only
|
|
157
|
+
* when SLOTLOCK_CONFIRM_WRITES opts in.
|
|
130
158
|
*/
|
|
131
159
|
export interface SlotlockAgentConfirmationOptions {
|
|
132
160
|
operations: readonly SlotlockAgentWriteOperation[];
|
|
@@ -138,6 +166,18 @@ export interface SlotlockAgentConfirmationOptions {
|
|
|
138
166
|
secrets: readonly (string | Uint8Array)[];
|
|
139
167
|
/** How long a confirmation prompt stays answerable, in seconds: 30-3,600, default 600. */
|
|
140
168
|
ttlSeconds?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Optional. Records an accepted confirmation, by the nonce its sealed state carries: true the first
|
|
171
|
+
* time, false for one already recorded, which the server then refuses (`confirmation_invalid`) so
|
|
172
|
+
* an acceptance runs its write once. Keep each nonce until `expiresAt`, across every server that
|
|
173
|
+
* shares the secrets (`createSlotlockAcceptanceRecords` does, in Postgres). Without it an accepted
|
|
174
|
+
* state can be sent again until it expires; it names the same principal, write and arguments, so
|
|
175
|
+
* the write's idempotency key or expected revision then decides.
|
|
176
|
+
*/
|
|
177
|
+
consumeAcceptance?: (acceptance: {
|
|
178
|
+
nonce: string;
|
|
179
|
+
expiresAt: Date;
|
|
180
|
+
}) => Promise<boolean>;
|
|
141
181
|
}
|
|
142
182
|
/**
|
|
143
183
|
* Live calendar updates over MCP 2026-07-28 `subscriptions/listen`. A client subscribes to calendar
|
|
@@ -155,6 +195,12 @@ export interface SlotlockAgentSubscriptionOptions {
|
|
|
155
195
|
keepAliveMs?: number;
|
|
156
196
|
/** Open subscriptions one principal may hold: 1-64, default 4. */
|
|
157
197
|
maxPerPrincipal?: number;
|
|
198
|
+
/**
|
|
199
|
+
* Open subscriptions one tenant may hold across all its principals: 1-10,000, default `maxTotal`.
|
|
200
|
+
* Set it below `maxTotal` on a multi-tenant server, so a tenant with many keys cannot hold every
|
|
201
|
+
* slot.
|
|
202
|
+
*/
|
|
203
|
+
maxPerTenant?: number;
|
|
158
204
|
/** Open subscriptions across the server: 1-10,000, default 256. */
|
|
159
205
|
maxTotal?: number;
|
|
160
206
|
}
|
|
@@ -193,7 +239,7 @@ export type SlotlockAgentServerEvent = {
|
|
|
193
239
|
type: 'subscription';
|
|
194
240
|
outcome: 'opened' | 'closed';
|
|
195
241
|
/** Why a subscription closed. */
|
|
196
|
-
reason?: 'client' | 'duration' | 'shutdown' | 'revoked' | 'failed' | 'empty';
|
|
242
|
+
reason?: 'client' | 'duration' | 'shutdown' | 'revoked' | 'failed' | 'empty' | 'preempted';
|
|
197
243
|
/** How many calendar resources it watched. */
|
|
198
244
|
resources: number;
|
|
199
245
|
};
|
|
@@ -309,6 +355,7 @@ export type SlotlockAgentOperationDispatchResult = {
|
|
|
309
355
|
ok: false;
|
|
310
356
|
status: number;
|
|
311
357
|
code: string;
|
|
358
|
+
details?: Readonly<Record<string, string>>;
|
|
312
359
|
};
|
|
313
360
|
/** Runtime type guard for the current operation names (legacy dotted names are not included). */
|
|
314
361
|
export declare function isSlotlockAgentOperation(name: unknown): name is SlotlockAgentOperation;
|
|
@@ -367,22 +414,27 @@ export declare function slotlockOpenApi(options?: {
|
|
|
367
414
|
application?: boolean;
|
|
368
415
|
}): Record<string, unknown>;
|
|
369
416
|
export declare function slotlockAgentTools(): {
|
|
370
|
-
name: "slotlock_create_event" | "slotlock_delete_event" | "slotlock_find_next_available" | "slotlock_get_event" | "slotlock_get_free_busy" | "slotlock_list_events" | "slotlock_list_resources" | "slotlock_update_event";
|
|
371
|
-
title: "Create resource event" | "Delete resource event" | "Find next available interval" | "Get free-busy" | "Get resource event" | "List calendar resources" | "List resource events" | "Update resource event";
|
|
372
|
-
description: "Apply an expected-revision event patch and rematerialize occupancy atomically." | "Create an event of up to 3,660 days (a booking, lease or long rental); opaque occurrences use the database overlap arbiter." | "Find the earliest certain interval that satisfies the requested duration (up to the 367-day search window, so a multi-month rental slot can be found)." | "List bounded events intersecting a time window." | "List resources visible to the authenticated tenant principal." | "Read one tenant-scoped event by stable identifier." | "Return privacy-minimized busy intervals and explicit coverage certainty." | "Tombstone an event at an expected revision so stale sync cannot resurrect it.";
|
|
417
|
+
name: "slotlock_book_pool" | "slotlock_book_together" | "slotlock_create_event" | "slotlock_delete_event" | "slotlock_find_available_slots" | "slotlock_find_next_available" | "slotlock_get_event" | "slotlock_get_free_busy" | "slotlock_get_pool_availability" | "slotlock_hold_slots" | "slotlock_list_events" | "slotlock_list_resources" | "slotlock_release_slots" | "slotlock_update_event";
|
|
418
|
+
title: "Book from a pool" | "Book resources together" | "Create resource event" | "Delete resource event" | "Find available slots" | "Find next available interval" | "Get free-busy" | "Get pool availability" | "Get resource event" | "Hold candidate slots" | "List calendar resources" | "List resource events" | "Release held slots" | "Update resource event";
|
|
419
|
+
description: "Apply an expected-revision event patch and rematerialize occupancy atomically. With expected_resource_id, the resource you read the event on, an event since moved elsewhere is not found." | "Book any one member of a pool (a vehicle class, a room type) for a time: members are tried in a fixed order and the first that is free and allows the booking is booked, in one transaction, so a class sells out exactly at its number of members. The event names the member booked. 409 pool_full when none is free; 404 pool_not_found when the pool has no member you may book. A retry with the same idempotency_key answers the same event." | "Book the same time on 2-20 resources at once, all or none: a van with its driver, a room with its projector. If any of them is taken, nothing is booked, and the refusal names that resource_id. Find such a time with slotlock_find_available_slots and require_free. A retry with the same idempotency_key answers the same events." | "Create an event of up to 3,660 days (a booking, lease or long rental); opaque occurrences use the database overlap arbiter." | "Find the earliest certain interval that satisfies the requested duration (up to the 367-day search window, so a multi-month rental slot can be found)." | "Hold up to five candidate slots for a short time (30-900 seconds) while a person chooses, as alternatives in one group: each free one is held, the others are listed with why not. Book one by passing its hold_id to slotlock_create_event, which releases the rest; unbooked holds expire on their own. A hold is yours alone, and you may have 20 live at once." | "How many members of a pool (a vehicle class, a room type) are free across a window, each only where its booking rules let a booking start: the window split where that number changes, each part with how many are free, and coverage certainty. Book one with slotlock_book_pool. 404 pool_not_found when the pool has no member you may book." | "List bounded events intersecting a time window." | "List resources visible to the authenticated tenant principal, with the pool each belongs to (a vehicle class, a room type). With pool, only that pool's members, in the order slotlock_book_pool tries them." | "List up to `limit` certain slots of the requested duration, earliest first across the resources, each one free of busy time and inside the resource's hours, to offer a person a choice. With require_free, only times when at least that many of the resources are free together, each slot naming them in resource_ids: every resource for a booking that needs them all (book it with slotlock_book_together), or any n of them. No slot is listed unless every resource's coverage is certain." | "Read one tenant-scoped event by stable identifier." | "Release one of your holds, and the rest of its group, at once instead of letting them expire. `released` is false when it was already gone." | "Return privacy-minimized busy intervals and explicit coverage certainty." | "Tombstone an event at an expected revision so stale sync cannot resurrect it.";
|
|
373
420
|
inputSchema: Readonly<Record<string, unknown>>;
|
|
374
421
|
outputSchema: Readonly<Record<string, unknown>>;
|
|
375
422
|
annotations: {
|
|
376
|
-
title: "Create resource event" | "Delete resource event" | "Find next available interval" | "Get free-busy" | "Get resource event" | "List calendar resources" | "List resource events" | "Update resource event";
|
|
423
|
+
title: "Book from a pool" | "Book resources together" | "Create resource event" | "Delete resource event" | "Find available slots" | "Find next available interval" | "Get free-busy" | "Get pool availability" | "Get resource event" | "Hold candidate slots" | "List calendar resources" | "List resource events" | "Release held slots" | "Update resource event";
|
|
377
424
|
readOnlyHint: boolean;
|
|
378
425
|
destructiveHint: boolean;
|
|
379
426
|
idempotentHint: true;
|
|
380
427
|
openWorldHint: boolean;
|
|
381
428
|
};
|
|
382
|
-
_meta
|
|
429
|
+
_meta: {
|
|
383
430
|
ui: {
|
|
384
431
|
resourceUri: string;
|
|
385
432
|
visibility: readonly ["model", "app"];
|
|
433
|
+
} | {
|
|
434
|
+
resourceUri: string;
|
|
435
|
+
visibility: readonly ["model"];
|
|
436
|
+
} | {
|
|
437
|
+
visibility: readonly ["model"];
|
|
386
438
|
};
|
|
387
439
|
};
|
|
388
440
|
}[];
|