slotlock 0.5.1 → 0.5.3
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 +122 -0
- package/README.md +152 -19
- package/SPEC.md +10 -7
- package/agent-server.d.ts +52 -4
- package/agent-server.js +479 -145
- package/agent-store-backend.d.ts +9 -0
- package/agent-store-backend.js +83 -15
- package/api-keys.d.ts +12 -2
- package/api-keys.js +36 -7
- package/application-api.d.ts +7 -1
- package/application-api.js +67 -7
- package/assistant.d.ts +263 -0
- package/assistant.js +772 -0
- package/booking-rules.d.ts +61 -9
- package/booking-rules.js +106 -16
- package/change-watch.d.ts +56 -0
- package/change-watch.js +213 -0
- package/config.d.ts +10 -0
- package/config.js +11 -0
- package/dashboard.d.ts +64 -1
- package/dashboard.js +687 -26
- package/ddl.d.ts +5 -5
- package/ddl.js +594 -6
- package/event-feed.d.ts +37 -4
- package/event-feed.js +74 -6
- package/index.d.ts +11 -8
- package/index.js +7 -5
- package/maintenance.d.ts +2 -1
- package/maintenance.js +33 -9
- package/openapi.json +1284 -82
- package/package.json +1 -1
- package/rate-limit.d.ts +8 -0
- package/rate-limit.js +20 -0
- package/self-host.d.ts +2 -2
- package/self-host.js +42 -7
- package/slotlock.manifest.json +1 -1
- package/store.d.ts +132 -3
- package/store.js +482 -124
- package/types.d.ts +14 -1
- package/webhooks.d.ts +33 -2
- package/webhooks.js +102 -20
package/dashboard.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { SlotlockApiKeyStore } from './api-keys.js';
|
|
2
|
+
import { type SlotlockAgentCalendarBackend, type SlotlockAgentOperation, type SlotlockAgentOperationDispatchOptions, type SlotlockAgentPrincipal } from './agent-server.js';
|
|
3
|
+
import { type SlotlockAssistantStore } from './assistant.js';
|
|
4
|
+
import { type SlotlockRate } from './config.js';
|
|
2
5
|
import { type SlotlockBookingRules } from './booking-rules.js';
|
|
3
6
|
import { type CreateWebhookEndpointResult, type SlotlockChange, type SlotlockWebhookEndpoint } from './event-feed.js';
|
|
4
7
|
import type { SlotlockSql, SlotlockStore, SlotlockWaitlistEntry } from './store.js';
|
|
5
|
-
import type { Interval, SlotlockAgendaEntry, SlotlockResource, WeeklyAvailabilityRule } from './types.js';
|
|
8
|
+
import type { Interval, SlotlockAgendaEntry, SlotlockResource, SlotlockBookingRuleDefaults, WeeklyAvailabilityRule } from './types.js';
|
|
6
9
|
/** Resources one dashboard tenant may hold. */
|
|
7
10
|
export declare const SLOTLOCK_DASHBOARD_MAX_RESOURCES = 100;
|
|
8
11
|
/**
|
|
@@ -34,6 +37,8 @@ export interface SlotlockDashboardResources {
|
|
|
34
37
|
* null when it is not the tenant's. Invalid rules throw with `code: 'invalid_booking_rules'`.
|
|
35
38
|
*/
|
|
36
39
|
setRules?(tenantRef: string, id: string, rules: SlotlockBookingRules | null, actor?: string): Promise<SlotlockResource | null>;
|
|
40
|
+
/** The tenant's default booking rules and its pools', which a resource's own rules overlay. */
|
|
41
|
+
ruleDefaults?(tenantRef: string): Promise<SlotlockBookingRuleDefaults>;
|
|
37
42
|
/** Put one of the tenant's resources in a pool, or none: as setRules; `code: 'invalid_pool'`. */
|
|
38
43
|
setPool?(tenantRef: string, id: string, pool: string | null, actor?: string): Promise<SlotlockResource | null>;
|
|
39
44
|
/** The tenant's waitlist, oldest first, and leaving it (false when the entry is not the tenant's). */
|
|
@@ -41,6 +46,8 @@ export interface SlotlockDashboardResources {
|
|
|
41
46
|
list(tenantRef: string, limit: number): Promise<SlotlockWaitlistEntry[]>;
|
|
42
47
|
leave(tenantRef: string, id: string, actor?: string): Promise<boolean>;
|
|
43
48
|
};
|
|
49
|
+
/** The tenant's assistant settings and its members' conversations (assistant.ts). */
|
|
50
|
+
assistant?: SlotlockAssistantStore;
|
|
44
51
|
/** The tenant's webhook endpoints, as the event feed keeps them. */
|
|
45
52
|
webhooks?: {
|
|
46
53
|
list(tenantRef: string): Promise<SlotlockWebhookEndpoint[]>;
|
|
@@ -74,6 +81,60 @@ export interface SlotlockDashboardState {
|
|
|
74
81
|
*/
|
|
75
82
|
sessionEnded(sid: string, expiresAt: number): Promise<boolean>;
|
|
76
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* The chat assistant (assistant.ts): each tenant's admins connect a model of their own in Settings,
|
|
86
|
+
* and every member may chat with it. Its reads and approved writes run through the agent operation
|
|
87
|
+
* boundary with `backend`, as the principal `dashboard-assistant:<GitHub login>` of the member's
|
|
88
|
+
* tenant, with `authorize` and `consumeRateLimit` as an agent's are. Needs the resources adapter's
|
|
89
|
+
* `assistant` too.
|
|
90
|
+
*/
|
|
91
|
+
export interface SlotlockDashboardAssistantOptions {
|
|
92
|
+
/** Seals each tenant's API key (SLOTLOCK_ASSISTANT_SECRET): 32+ random characters. */
|
|
93
|
+
secret: string;
|
|
94
|
+
backend: SlotlockAgentCalendarBackend;
|
|
95
|
+
/**
|
|
96
|
+
* As the agent server's: false refuses an operation. Every offered operation by default. It also
|
|
97
|
+
* checks a write the model proposes, so it must hold nothing: limits that hold a slot go in
|
|
98
|
+
* `admit`.
|
|
99
|
+
*/
|
|
100
|
+
authorize?: SlotlockAgentOperationDispatchOptions['authorize'];
|
|
101
|
+
/**
|
|
102
|
+
* Taken when a read runs and when an approved write runs, never for a proposal: the agent
|
|
103
|
+
* request limits' `admit` (serve's series-write slots), which may hold a slot until the request
|
|
104
|
+
* is answered, or throw a SlotlockAgentOperationError to refuse.
|
|
105
|
+
*/
|
|
106
|
+
admit?: (args: {
|
|
107
|
+
principal: SlotlockAgentPrincipal;
|
|
108
|
+
operation: SlotlockAgentOperation;
|
|
109
|
+
input: Record<string, unknown>;
|
|
110
|
+
}) => Promise<void>;
|
|
111
|
+
/** As the agent server's; charged for each read and each approved write, never for a proposal. */
|
|
112
|
+
consumeRateLimit?: SlotlockAgentOperationDispatchOptions['consumeRateLimit'];
|
|
113
|
+
/**
|
|
114
|
+
* Allow a model at a local or private network address (SLOTLOCK_ASSISTANT_PRIVATE_URLS): a
|
|
115
|
+
* base URL whose host is, or resolves to, a loopback, private, link-local, shared, unique-local
|
|
116
|
+
* or metadata address. Off by default: such URLs are refused when saved and at each call.
|
|
117
|
+
*/
|
|
118
|
+
privateUrls?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Reaches the model providers. By default Node.js's http client, which checks every address a
|
|
121
|
+
* host resolves to as the connection is made (createSlotlockGuardedFetch), so a name rebound to
|
|
122
|
+
* a private address is refused too. A replacement must make that check itself, or reach no
|
|
123
|
+
* private network (a Cloudflare Worker's fetch).
|
|
124
|
+
*/
|
|
125
|
+
fetch?: typeof fetch;
|
|
126
|
+
/** The addresses a host resolves to, to refuse a private one when saved: dns.lookup by default. */
|
|
127
|
+
resolve?: (hostname: string) => Promise<string[]>;
|
|
128
|
+
/** Messages and connection tests one member may send: 10 a minute, 10 at once, by default. */
|
|
129
|
+
rate?: SlotlockRate;
|
|
130
|
+
/** One model call's limit (30 s by default) and one message's (90 s). */
|
|
131
|
+
timeoutMs?: number;
|
|
132
|
+
turnTimeoutMs?: number;
|
|
133
|
+
/** Model calls one message may make (8 by default, at most 20). */
|
|
134
|
+
maxSteps?: number;
|
|
135
|
+
/** How long a conversation is kept after its last message: 2 hours by default. */
|
|
136
|
+
conversationTtlMs?: number;
|
|
137
|
+
}
|
|
77
138
|
export interface SlotlockDashboardOptions {
|
|
78
139
|
/** Where people reach the server; the dashboard lives at `<publicUrl>/dashboard`. */
|
|
79
140
|
publicUrl: string;
|
|
@@ -118,6 +179,8 @@ export interface SlotlockDashboardOptions {
|
|
|
118
179
|
state: SlotlockDashboardState;
|
|
119
180
|
/** The server's bookable hours: shown, not edited, and used by resources without their own. */
|
|
120
181
|
availability?: readonly WeeklyAvailabilityRule[];
|
|
182
|
+
/** The chat assistant; off unless set. */
|
|
183
|
+
assistant?: SlotlockDashboardAssistantOptions;
|
|
121
184
|
fetch?: typeof fetch;
|
|
122
185
|
now?: () => number;
|
|
123
186
|
/**
|