@framers/agentos 0.13.62 → 0.13.64
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/api/types.d.ts +111 -81
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js.map +1 -1
- package/dist/io/channels/meetings/IMeetingBotProvider.d.ts +128 -0
- package/dist/io/channels/meetings/IMeetingBotProvider.d.ts.map +1 -0
- package/dist/io/channels/meetings/IMeetingBotProvider.js +2 -0
- package/dist/io/channels/meetings/IMeetingBotProvider.js.map +1 -0
- package/dist/io/channels/meetings/providers/mock.d.ts +46 -0
- package/dist/io/channels/meetings/providers/mock.d.ts.map +1 -0
- package/dist/io/channels/meetings/providers/mock.js +101 -0
- package/dist/io/channels/meetings/providers/mock.js.map +1 -0
- package/dist/io/channels/meetings/signing.d.ts +102 -0
- package/dist/io/channels/meetings/signing.d.ts.map +1 -0
- package/dist/io/channels/meetings/signing.js +141 -0
- package/dist/io/channels/meetings/signing.js.map +1 -0
- package/dist/io/channels/meetings/stores/memory.d.ts +88 -0
- package/dist/io/channels/meetings/stores/memory.d.ts.map +1 -0
- package/dist/io/channels/meetings/stores/memory.js +273 -0
- package/dist/io/channels/meetings/stores/memory.js.map +1 -0
- package/dist/io/channels/meetings/stores/types.d.ts +224 -0
- package/dist/io/channels/meetings/stores/types.d.ts.map +1 -0
- package/dist/io/channels/meetings/stores/types.js +35 -0
- package/dist/io/channels/meetings/stores/types.js.map +1 -0
- package/dist/io/channels/meetings/types.d.ts +200 -0
- package/dist/io/channels/meetings/types.d.ts.map +1 -0
- package/dist/io/channels/meetings/types.js +89 -0
- package/dist/io/channels/meetings/types.js.map +1 -0
- package/dist/io/media/images/blobPart.d.ts +11 -0
- package/dist/io/media/images/blobPart.d.ts.map +1 -1
- package/dist/io/media/images/blobPart.js +14 -0
- package/dist/io/media/images/blobPart.js.map +1 -1
- package/dist/io/media/images/providers/FalImageProvider.d.ts.map +1 -1
- package/dist/io/media/images/providers/FalImageProvider.js +13 -7
- package/dist/io/media/images/providers/FalImageProvider.js.map +1 -1
- package/dist/io/media/images/providers/OpenAIImageProvider.js +2 -2
- package/dist/io/media/images/providers/OpenAIImageProvider.js.map +1 -1
- package/dist/io/media/images/providers/StabilityImageProvider.d.ts.map +1 -1
- package/dist/io/media/images/providers/StabilityImageProvider.js +9 -5
- package/dist/io/media/images/providers/StabilityImageProvider.js.map +1 -1
- package/dist/io/voice-pipeline/types.d.ts +30 -0
- package/dist/io/voice-pipeline/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { CONTENT_EVENT_TYPES } from '../types.js';
|
|
2
|
+
import { DuplicateIdempotencyKeyError, FencedError, nextAttemptAt, OUTBOX_GIVE_UP_MS, } from './types.js';
|
|
3
|
+
/** The wall clock. */
|
|
4
|
+
export class SystemClock {
|
|
5
|
+
now() {
|
|
6
|
+
return Date.now();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/** A clock a test sets and moves by hand. */
|
|
10
|
+
export class FakeClock {
|
|
11
|
+
/** @param t - The starting time, in milliseconds. */
|
|
12
|
+
constructor(t) {
|
|
13
|
+
this.t = t;
|
|
14
|
+
}
|
|
15
|
+
now() {
|
|
16
|
+
return this.t;
|
|
17
|
+
}
|
|
18
|
+
/** Moves the clock forward by `ms`. */
|
|
19
|
+
advance(ms) {
|
|
20
|
+
this.t += ms;
|
|
21
|
+
}
|
|
22
|
+
/** Sets the clock to `t`. */
|
|
23
|
+
set(t) {
|
|
24
|
+
this.t = t;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Runs in memory, for tests and single-process hosts. Rows are copied in and out, so a caller never holds the stored row. */
|
|
28
|
+
export class InMemoryRunStore {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.runs = new Map();
|
|
31
|
+
}
|
|
32
|
+
async insert(run) {
|
|
33
|
+
if (this.runs.has(run.runId))
|
|
34
|
+
throw new Error(`run ${run.runId} exists`);
|
|
35
|
+
// one run per owner and key, with no await between the check and the write: of two sends racing with one key, the second insert fails and the sender finds the first
|
|
36
|
+
const key = run.idempotencyKey;
|
|
37
|
+
if (key !== undefined && [...this.runs.values()].some((r) => r.ownerRef === run.ownerRef && r.idempotencyKey === key)) {
|
|
38
|
+
throw new DuplicateIdempotencyKeyError(run.ownerRef, key);
|
|
39
|
+
}
|
|
40
|
+
this.runs.set(run.runId, structuredClone(run));
|
|
41
|
+
}
|
|
42
|
+
async get(runId) {
|
|
43
|
+
const r = this.runs.get(runId);
|
|
44
|
+
return r ? structuredClone(r) : undefined;
|
|
45
|
+
}
|
|
46
|
+
async update(runId, patch, expectState) {
|
|
47
|
+
const r = this.runs.get(runId);
|
|
48
|
+
if (!r)
|
|
49
|
+
return undefined;
|
|
50
|
+
if (expectState !== undefined) {
|
|
51
|
+
const allowed = Array.isArray(expectState) ? expectState : [expectState];
|
|
52
|
+
if (!allowed.includes(r.state))
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
Object.assign(r, structuredClone(patch));
|
|
56
|
+
return structuredClone(r);
|
|
57
|
+
}
|
|
58
|
+
async replace(run) {
|
|
59
|
+
this.runs.set(run.runId, structuredClone(run));
|
|
60
|
+
}
|
|
61
|
+
async list(filter) {
|
|
62
|
+
const out = [];
|
|
63
|
+
for (const r of this.runs.values()) {
|
|
64
|
+
if (filter.ownerRef !== undefined && r.ownerRef !== filter.ownerRef)
|
|
65
|
+
continue;
|
|
66
|
+
if (filter.states && !filter.states.includes(r.state))
|
|
67
|
+
continue;
|
|
68
|
+
if (filter.since !== undefined && r.requestedAt < filter.since)
|
|
69
|
+
continue;
|
|
70
|
+
out.push(structuredClone(r));
|
|
71
|
+
}
|
|
72
|
+
out.sort((a, b) => b.requestedAt - a.requestedAt);
|
|
73
|
+
return filter.limit ? out.slice(0, filter.limit) : out;
|
|
74
|
+
}
|
|
75
|
+
async findByIdempotencyKey(ownerRef, key) {
|
|
76
|
+
for (const r of this.runs.values())
|
|
77
|
+
if (r.ownerRef === ownerRef && r.idempotencyKey === key)
|
|
78
|
+
return structuredClone(r);
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Dispatch jobs in memory, for tests and single-process hosts: its leases hold within one process. */
|
|
83
|
+
export class InMemoryJobStore {
|
|
84
|
+
constructor() {
|
|
85
|
+
this.jobs = new Map();
|
|
86
|
+
}
|
|
87
|
+
async schedule(job) {
|
|
88
|
+
this.jobs.set(job.runId, { runId: job.runId, dispatchAt: job.dispatchAt, dispatched: false, cancelled: false });
|
|
89
|
+
}
|
|
90
|
+
async lease(holder, now, ttlMs) {
|
|
91
|
+
// no await between the read and the write below, so two takers in one process never hold one job
|
|
92
|
+
const due = [...this.jobs.values()]
|
|
93
|
+
.filter((j) => !j.cancelled && !j.dispatched && j.dispatchAt <= now && (j.leaseExpiresAt === undefined || j.leaseExpiresAt <= now))
|
|
94
|
+
.sort((a, b) => a.dispatchAt - b.dispatchAt);
|
|
95
|
+
const job = due[0];
|
|
96
|
+
if (!job)
|
|
97
|
+
return undefined;
|
|
98
|
+
job.leaseHolder = holder;
|
|
99
|
+
job.leaseExpiresAt = now + ttlMs;
|
|
100
|
+
return { ...job };
|
|
101
|
+
}
|
|
102
|
+
async renew(runId, holder, now, ttlMs) {
|
|
103
|
+
const job = this.jobs.get(runId);
|
|
104
|
+
if (!job || job.leaseHolder !== holder || job.leaseExpiresAt === undefined || job.leaseExpiresAt <= now)
|
|
105
|
+
return false;
|
|
106
|
+
job.leaseExpiresAt = now + ttlMs;
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
async markDispatched(runId, holder, workerId) {
|
|
110
|
+
const job = this.jobs.get(runId);
|
|
111
|
+
if (!job)
|
|
112
|
+
return { recorded: false, cancelled: false };
|
|
113
|
+
// a holder whose lease another holder took changes nothing: the new holder's dispatch is the job's
|
|
114
|
+
if (job.leaseHolder !== holder)
|
|
115
|
+
return { recorded: false, cancelled: job.cancelled };
|
|
116
|
+
job.dispatched = true;
|
|
117
|
+
job.workerId = workerId;
|
|
118
|
+
return { recorded: true, cancelled: job.cancelled };
|
|
119
|
+
}
|
|
120
|
+
async release(runId, holder, retryAt) {
|
|
121
|
+
const job = this.jobs.get(runId);
|
|
122
|
+
if (!job || job.leaseHolder !== holder)
|
|
123
|
+
return false;
|
|
124
|
+
job.leaseHolder = undefined;
|
|
125
|
+
job.leaseExpiresAt = undefined;
|
|
126
|
+
job.dispatchAt = retryAt;
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
async cancel(runId) {
|
|
130
|
+
const job = this.jobs.get(runId);
|
|
131
|
+
if (!job)
|
|
132
|
+
return 'missing';
|
|
133
|
+
if (job.dispatched)
|
|
134
|
+
return 'already_dispatched';
|
|
135
|
+
job.cancelled = true;
|
|
136
|
+
return 'cancelled';
|
|
137
|
+
}
|
|
138
|
+
async get(runId) {
|
|
139
|
+
const j = this.jobs.get(runId);
|
|
140
|
+
return j ? { ...j } : undefined;
|
|
141
|
+
}
|
|
142
|
+
async listDispatched() {
|
|
143
|
+
return [...this.jobs.values()].filter((j) => j.dispatched).map((j) => ({ ...j }));
|
|
144
|
+
}
|
|
145
|
+
async remove(runId) {
|
|
146
|
+
this.jobs.delete(runId);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/** Transcript turns in memory: for tests, single-process hosts and runs that are not kept. */
|
|
150
|
+
export class InMemoryTranscriptStore {
|
|
151
|
+
constructor() {
|
|
152
|
+
this.turns = new Map();
|
|
153
|
+
this.fenced = new Set();
|
|
154
|
+
}
|
|
155
|
+
async append(turn) {
|
|
156
|
+
if (this.fenced.has(turn.runId))
|
|
157
|
+
throw new FencedError(turn.runId);
|
|
158
|
+
const list = this.turns.get(turn.runId) ?? [];
|
|
159
|
+
list.push({ ...turn });
|
|
160
|
+
this.turns.set(turn.runId, list);
|
|
161
|
+
}
|
|
162
|
+
async read(runId, fromSeq, limit = 500) {
|
|
163
|
+
return (this.turns.get(runId) ?? []).filter((t) => t.seq > fromSeq).slice(0, limit).map((t) => ({ ...t }));
|
|
164
|
+
}
|
|
165
|
+
async fence(runId) {
|
|
166
|
+
this.fenced.add(runId);
|
|
167
|
+
}
|
|
168
|
+
async isFenced(runId) {
|
|
169
|
+
return this.fenced.has(runId);
|
|
170
|
+
}
|
|
171
|
+
async purge(runId) {
|
|
172
|
+
this.turns.delete(runId);
|
|
173
|
+
}
|
|
174
|
+
/** Forgets a run whole, its turns and its fence, to free the memory of a run that is over. The manager does not call it: it removes a run's turns with `purge`, which keeps the fence. */
|
|
175
|
+
async drop(runId) {
|
|
176
|
+
this.turns.delete(runId);
|
|
177
|
+
this.fenced.delete(runId);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Events in memory, numbered per run and deduplicated by id: for tests, single-process hosts and runs that are not kept.
|
|
182
|
+
* Events are copied in and out, payloads included, so a caller never holds a stored event.
|
|
183
|
+
*/
|
|
184
|
+
export class InMemoryEventStore {
|
|
185
|
+
constructor() {
|
|
186
|
+
this.byRun = new Map();
|
|
187
|
+
this.byId = new Map();
|
|
188
|
+
this.fenced = new Set();
|
|
189
|
+
}
|
|
190
|
+
async append(event) {
|
|
191
|
+
const existing = this.byId.get(event.eventId);
|
|
192
|
+
if (existing)
|
|
193
|
+
return { inserted: false, seq: existing.seq };
|
|
194
|
+
const list = this.byRun.get(event.runId) ?? [];
|
|
195
|
+
const behindFence = this.fenced.has(event.runId) && CONTENT_EVENT_TYPES.has(event.type);
|
|
196
|
+
const stored = behindFence ? { ...event, data: undefined, purged: true, seq: list.length + 1 } : { ...structuredClone(event), seq: list.length + 1 };
|
|
197
|
+
list.push(stored);
|
|
198
|
+
this.byRun.set(event.runId, list);
|
|
199
|
+
this.byId.set(event.eventId, stored);
|
|
200
|
+
return { inserted: true, seq: stored.seq };
|
|
201
|
+
}
|
|
202
|
+
async fence(runId) {
|
|
203
|
+
this.fenced.add(runId);
|
|
204
|
+
}
|
|
205
|
+
async read(runId, fromSeq, limit = 500) {
|
|
206
|
+
return (this.byRun.get(runId) ?? []).filter((e) => e.seq > fromSeq).slice(0, limit).map((e) => structuredClone(e));
|
|
207
|
+
}
|
|
208
|
+
async purgePayloads(runId) {
|
|
209
|
+
for (const e of this.byRun.get(runId) ?? []) {
|
|
210
|
+
if (CONTENT_EVENT_TYPES.has(e.type)) {
|
|
211
|
+
delete e.data;
|
|
212
|
+
e.purged = true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/** Outbound deliveries in memory, for tests and single-process hosts. */
|
|
218
|
+
export class InMemoryOutbox {
|
|
219
|
+
constructor() {
|
|
220
|
+
this.deliveries = new Map();
|
|
221
|
+
/** The runs whose content was purged: the outbox's fence. */
|
|
222
|
+
this.purgedRuns = new Set();
|
|
223
|
+
}
|
|
224
|
+
async enqueue(d, now) {
|
|
225
|
+
// behind the purge nothing a person said or did is taken for delivery
|
|
226
|
+
if (this.purgedRuns.has(d.runId) && CONTENT_EVENT_TYPES.has(d.type))
|
|
227
|
+
return;
|
|
228
|
+
this.deliveries.set(d.id, { ...d, attempts: 0, nextAt: now, state: 'pending', purged: false });
|
|
229
|
+
}
|
|
230
|
+
async due(now, limit = 100) {
|
|
231
|
+
return [...this.deliveries.values()].filter((d) => d.state === 'pending' && d.nextAt <= now).slice(0, limit).map((d) => ({ ...d }));
|
|
232
|
+
}
|
|
233
|
+
async markDelivered(id) {
|
|
234
|
+
const d = this.deliveries.get(id);
|
|
235
|
+
if (d)
|
|
236
|
+
d.state = 'delivered';
|
|
237
|
+
}
|
|
238
|
+
async markFailed(id, now) {
|
|
239
|
+
const d = this.deliveries.get(id);
|
|
240
|
+
if (!d)
|
|
241
|
+
return;
|
|
242
|
+
d.attempts += 1;
|
|
243
|
+
d.firstAttemptAt ?? (d.firstAttemptAt = now);
|
|
244
|
+
if (now - d.firstAttemptAt >= OUTBOX_GIVE_UP_MS)
|
|
245
|
+
d.state = 'dead';
|
|
246
|
+
else
|
|
247
|
+
d.nextAt = nextAttemptAt(d.attempts, now);
|
|
248
|
+
}
|
|
249
|
+
async replay(id, now) {
|
|
250
|
+
const d = this.deliveries.get(id);
|
|
251
|
+
if (!d)
|
|
252
|
+
return;
|
|
253
|
+
d.state = 'pending';
|
|
254
|
+
d.attempts = 0;
|
|
255
|
+
d.firstAttemptAt = undefined;
|
|
256
|
+
d.nextAt = now;
|
|
257
|
+
}
|
|
258
|
+
async purgeContent(runId) {
|
|
259
|
+
this.purgedRuns.add(runId);
|
|
260
|
+
for (const d of this.deliveries.values()) {
|
|
261
|
+
// delivered rows too: a replay after the purge must send nothing of the content; a content-free delivery (`bot:done`) stays as it is
|
|
262
|
+
if (d.runId !== runId || !CONTENT_EVENT_TYPES.has(d.type))
|
|
263
|
+
continue;
|
|
264
|
+
d.payload = '';
|
|
265
|
+
d.type = 'bot:purged';
|
|
266
|
+
d.purged = true;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
async listByRun(runId) {
|
|
270
|
+
return [...this.deliveries.values()].filter((d) => d.runId === runId).map((d) => ({ ...d }));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../../../src/io/channels/meetings/stores/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAuF,MAAM,aAAa,CAAC;AACvI,OAAO,EACL,4BAA4B,EAC5B,WAAW,EACX,aAAa,EACb,iBAAiB,GAUlB,MAAM,YAAY,CAAC;AAEpB,sBAAsB;AACtB,MAAM,OAAO,WAAW;IACtB,GAAG;QACD,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;IACpB,CAAC;CACF;AAED,6CAA6C;AAC7C,MAAM,OAAO,SAAS;IACpB,qDAAqD;IACrD,YAAoB,CAAS;QAAT,MAAC,GAAD,CAAC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,CAAC,CAAC,CAAC,IAAI,CAAC;gBAAE,SAAS;YACpE,CAAC,CAAC,OAAO,GAAG,EAAE,CAAC;YACf,CAAC,CAAC,IAAI,GAAG,YAAY,CAAC;YACtB,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;IACH,CAAC;IACD,KAAK,CAAC,SAAS,CAAC,KAAa;QAC3B,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/F,CAAC;CACF"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import type { MeetingEvent, MeetingEventType, MeetingPlatform, MeetingRunRecord, MeetingRunState, TranscriptTurn } from '../types.js';
|
|
2
|
+
/** Thrown by a store that refuses content for a run behind the fence. */
|
|
3
|
+
export declare class FencedError extends Error {
|
|
4
|
+
readonly runId: string;
|
|
5
|
+
/** @param runId - The run whose content was refused. */
|
|
6
|
+
constructor(runId: string);
|
|
7
|
+
}
|
|
8
|
+
/** Thrown by {@link IRunStore.insert} when the owner already has a run with the idempotency key: a send that loses that race answers the run the key has ({@link IRunStore.findByIdempotencyKey}). */
|
|
9
|
+
export declare class DuplicateIdempotencyKeyError extends Error {
|
|
10
|
+
readonly ownerRef: string;
|
|
11
|
+
readonly idempotencyKey: string;
|
|
12
|
+
/**
|
|
13
|
+
* @param ownerRef - The owner the key belongs to.
|
|
14
|
+
* @param idempotencyKey - The key the owner already has a run with.
|
|
15
|
+
*/
|
|
16
|
+
constructor(ownerRef: string, idempotencyKey: string);
|
|
17
|
+
}
|
|
18
|
+
/** Which runs {@link IRunStore.list} returns: every condition given holds. */
|
|
19
|
+
export interface RunFilter {
|
|
20
|
+
/** Only this owner's runs. */
|
|
21
|
+
ownerRef?: string;
|
|
22
|
+
/** Only runs in one of these states. */
|
|
23
|
+
states?: readonly MeetingRunState[];
|
|
24
|
+
/** Only runs requested at or after this time, in milliseconds. */
|
|
25
|
+
since?: number;
|
|
26
|
+
/** At most this many runs. */
|
|
27
|
+
limit?: number;
|
|
28
|
+
}
|
|
29
|
+
/** The run's row. An implementation seals `meetingUrl` at rest. */
|
|
30
|
+
export interface IRunStore {
|
|
31
|
+
/**
|
|
32
|
+
* Adds a new run. A run id that exists is an error, and so is an idempotency key the owner already used: that insert
|
|
33
|
+
* stores nothing and rejects with {@link DuplicateIdempotencyKeyError}, so of two sends racing with one key only one run
|
|
34
|
+
* is made, and the other finds it with `findByIdempotencyKey`.
|
|
35
|
+
*/
|
|
36
|
+
insert(run: MeetingRunRecord): Promise<void>;
|
|
37
|
+
/** The run, or undefined when there is none. */
|
|
38
|
+
get(runId: string): Promise<MeetingRunRecord | undefined>;
|
|
39
|
+
/** Applies the patch when the run is in one of `expectState` (any state when absent); returns the row after, or undefined when the state did not match. */
|
|
40
|
+
update(runId: string, patch: Partial<MeetingRunRecord>, expectState?: MeetingRunState | readonly MeetingRunState[]): Promise<MeetingRunRecord | undefined>;
|
|
41
|
+
/** Rewrites the whole row (the content-free form at the end of a purge). */
|
|
42
|
+
replace(run: MeetingRunRecord): Promise<void>;
|
|
43
|
+
/** The runs the filter selects, newest first. */
|
|
44
|
+
list(filter: RunFilter): Promise<MeetingRunRecord[]>;
|
|
45
|
+
/** The run an owner sent with this idempotency key, if there is one (there is at most one: see `insert`). */
|
|
46
|
+
findByIdempotencyKey(ownerRef: string, key: string): Promise<MeetingRunRecord | undefined>;
|
|
47
|
+
}
|
|
48
|
+
/** A run's dispatch job: when it is due, who holds its lease, and whether it was dispatched or cancelled. */
|
|
49
|
+
export interface MeetingJob {
|
|
50
|
+
/** The run the job dispatches. */
|
|
51
|
+
runId: string;
|
|
52
|
+
/** When the job is due, in milliseconds. */
|
|
53
|
+
dispatchAt: number;
|
|
54
|
+
/** The manager instance holding the dispatch lease. */
|
|
55
|
+
leaseHolder?: string;
|
|
56
|
+
/** When the lease runs out, in milliseconds. */
|
|
57
|
+
leaseExpiresAt?: number;
|
|
58
|
+
/** The worker the provider dispatched to. */
|
|
59
|
+
workerId?: string;
|
|
60
|
+
/** Set when the dispatch was recorded. */
|
|
61
|
+
dispatched: boolean;
|
|
62
|
+
/** Set by a cancel. A cancelled job is never leased. */
|
|
63
|
+
cancelled: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** Delayed dispatch with leases. `lease` is atomic: two takers never hold one job. */
|
|
66
|
+
export interface IJobStore {
|
|
67
|
+
/** Adds the run's job, due at `dispatchAt`. */
|
|
68
|
+
schedule(job: {
|
|
69
|
+
runId: string;
|
|
70
|
+
dispatchAt: number;
|
|
71
|
+
}): Promise<void>;
|
|
72
|
+
/** The next due, uncancelled, undispatched job whose lease is absent or expired, leased to `holder` until `now + ttlMs`. */
|
|
73
|
+
lease(holder: string, now: number, ttlMs: number): Promise<MeetingJob | undefined>;
|
|
74
|
+
/** Extends a lease the holder still holds; false when it expired or another holder took it, and then the holder must stop. */
|
|
75
|
+
renew(runId: string, holder: string, now: number, ttlMs: number): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Records the dispatch for the lease's holder and answers whether a cancel arrived meanwhile (then the dispatcher tells
|
|
78
|
+
* the bot to leave at once). A dispatch can outlive its lease and another holder can take the job: when `holder` no
|
|
79
|
+
* longer holds the lease, or the job is gone, nothing is recorded and `recorded` is false.
|
|
80
|
+
*/
|
|
81
|
+
markDispatched(runId: string, holder: string, workerId: string | undefined): Promise<{
|
|
82
|
+
recorded: boolean;
|
|
83
|
+
cancelled: boolean;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Releases the holder's lease without dispatching (the dispatch failed and will be retried), moving the job's due time
|
|
87
|
+
* to `retryAt`. False, and nothing changes, when `holder` no longer holds the lease or the job is gone.
|
|
88
|
+
*/
|
|
89
|
+
release(runId: string, holder: string, retryAt: number): Promise<boolean>;
|
|
90
|
+
/** Marks the job cancelled. `already_dispatched` when the bot is out: the caller tells it to leave instead. A job under a live lease is cancelled too, and its dispatcher learns it from `markDispatched`. */
|
|
91
|
+
cancel(runId: string): Promise<'cancelled' | 'already_dispatched' | 'missing'>;
|
|
92
|
+
/** The run's job, or undefined when there is none. */
|
|
93
|
+
get(runId: string): Promise<MeetingJob | undefined>;
|
|
94
|
+
/** Every dispatched job: what reconciliation compares with the providers' usage. */
|
|
95
|
+
listDispatched(): Promise<MeetingJob[]>;
|
|
96
|
+
/** Deletes the run's job. */
|
|
97
|
+
remove(runId: string): Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
/** A run's transcript turns. Behind the fence it refuses new turns; a purge removes the turns and keeps the fence. */
|
|
100
|
+
export interface ITranscriptStore {
|
|
101
|
+
/** Adds a turn; rejects with {@link FencedError} once the run is fenced. */
|
|
102
|
+
append(turn: TranscriptTurn): Promise<void>;
|
|
103
|
+
/** The run's turns after `fromSeq`, in order, at most `limit` of them. */
|
|
104
|
+
read(runId: string, fromSeq: number, limit?: number): Promise<TranscriptTurn[]>;
|
|
105
|
+
/** The fence: from now on the run takes no new turn. */
|
|
106
|
+
fence(runId: string): Promise<void>;
|
|
107
|
+
/** Whether the run is fenced. */
|
|
108
|
+
isFenced(runId: string): Promise<boolean>;
|
|
109
|
+
/** Removes the run's turns; the fence stays. */
|
|
110
|
+
purge(runId: string): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
/** A run's events: stable ids, a sequence number per run, and payloads a purge removes. */
|
|
113
|
+
export interface IEventStore {
|
|
114
|
+
/** Inserts with the next sequence number of the run; a repeated `eventId` is not inserted and answers the existing sequence. Behind the fence a content event is stored without its payload, marked `purged`. */
|
|
115
|
+
append(event: Omit<MeetingEvent, 'seq'>): Promise<{
|
|
116
|
+
inserted: boolean;
|
|
117
|
+
seq: number;
|
|
118
|
+
}>;
|
|
119
|
+
/** The run's events after `fromSeq`, in sequence order, at most `limit` of them. */
|
|
120
|
+
read(runId: string, fromSeq: number, limit?: number): Promise<MeetingEvent[]>;
|
|
121
|
+
/** The fence: from now on no payload of a content event is stored for the run. */
|
|
122
|
+
fence(runId: string): Promise<void>;
|
|
123
|
+
/** Removes the payload of every content event of the run; type, time and sequence stay. */
|
|
124
|
+
purgePayloads(runId: string): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
/** One event's delivery to one destination. */
|
|
127
|
+
export interface OutboxDelivery {
|
|
128
|
+
/** The delivery's id. */
|
|
129
|
+
id: string;
|
|
130
|
+
/** The run the event belongs to. */
|
|
131
|
+
runId: string;
|
|
132
|
+
/** The product's reference for where it goes (a webhook registration). */
|
|
133
|
+
destinationRef: string;
|
|
134
|
+
/** The event the delivery carries. */
|
|
135
|
+
eventId: string;
|
|
136
|
+
/** The event's type; `bot:purged` once a purge emptied the delivery. */
|
|
137
|
+
type: MeetingEventType;
|
|
138
|
+
/** The body to send; empty once a purge emptied the delivery. */
|
|
139
|
+
payload: string;
|
|
140
|
+
/** The failed attempts so far. */
|
|
141
|
+
attempts: number;
|
|
142
|
+
/** When the first failed attempt was recorded; a delivery still failing a day later is given up. */
|
|
143
|
+
firstAttemptAt?: number;
|
|
144
|
+
/** When the next attempt is due. */
|
|
145
|
+
nextAt: number;
|
|
146
|
+
/** `pending` until the destination takes it, or until it is given up as `dead`. */
|
|
147
|
+
state: 'pending' | 'delivered' | 'dead';
|
|
148
|
+
/** Set when a purge emptied the delivery. */
|
|
149
|
+
purged: boolean;
|
|
150
|
+
}
|
|
151
|
+
/** Outbound deliveries: retried with backoff for a day, replayable, content-free after a purge. */
|
|
152
|
+
export interface IOutbox {
|
|
153
|
+
/**
|
|
154
|
+
* Adds a pending delivery, due at `now`. After `purgeContent` for the run, a delivery of a content event (a type in
|
|
155
|
+
* `CONTENT_EVENT_TYPES`) is not stored: the purge is the outbox's fence. A delivery of any other type (`bot:left`,
|
|
156
|
+
* `bot:purged`, `bot:done` and the rest) is stored.
|
|
157
|
+
*/
|
|
158
|
+
enqueue(delivery: Pick<OutboxDelivery, 'id' | 'runId' | 'destinationRef' | 'eventId' | 'type' | 'payload'>, now: number): Promise<void>;
|
|
159
|
+
/** The pending deliveries due at `now`, at most `limit` of them. */
|
|
160
|
+
due(now: number, limit?: number): Promise<OutboxDelivery[]>;
|
|
161
|
+
/** Records that the destination took the delivery. */
|
|
162
|
+
markDelivered(id: string): Promise<void>;
|
|
163
|
+
/** Records a failed attempt: due again after the backoff of {@link nextAttemptAt}, or `dead` a day after the first failed attempt. */
|
|
164
|
+
markFailed(id: string, now: number): Promise<void>;
|
|
165
|
+
/** Makes a delivery pending again, due at `now`, with its attempts counted afresh (a manual replay). */
|
|
166
|
+
replay(id: string, now: number): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Empties every content delivery of the run (a type in `CONTENT_EVENT_TYPES`), delivered ones included, so a replay
|
|
169
|
+
* after a purge sends the content-free `bot:purged` in its place. A delivery of any other type (`bot:done`,
|
|
170
|
+
* `bot:left` and the rest) carries no content and keeps its type and payload. From then on the run takes no content
|
|
171
|
+
* delivery (see `enqueue`).
|
|
172
|
+
*/
|
|
173
|
+
purgeContent(runId: string): Promise<void>;
|
|
174
|
+
/** Every delivery of the run, whatever its state. */
|
|
175
|
+
listByRun(runId: string): Promise<OutboxDelivery[]>;
|
|
176
|
+
}
|
|
177
|
+
/** A reservation's answer: its id and the seconds it covers, or why it was refused. */
|
|
178
|
+
export type ReserveResult = {
|
|
179
|
+
ok: true;
|
|
180
|
+
reservationId: string;
|
|
181
|
+
maxSeconds: number;
|
|
182
|
+
} | {
|
|
183
|
+
ok: false;
|
|
184
|
+
reason: 'allowance' | 'permission_denied';
|
|
185
|
+
message: string;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* The product's billing. The library reserves before a run exists, meters every minute, settles at the end, releases an
|
|
189
|
+
* unbilled run. `settle` and `release` are idempotent per reservation: the manager retries them until they resolve, and a
|
|
190
|
+
* repeated call after a success changes nothing.
|
|
191
|
+
*/
|
|
192
|
+
export interface IEntitlementHook {
|
|
193
|
+
/** Reserves at most `maxSeconds` for a run about to be made; the answer's `maxSeconds` is what it covers, and the run's limit is cut to it. A refusal sends no bot. */
|
|
194
|
+
reserve(input: {
|
|
195
|
+
ownerRef: string;
|
|
196
|
+
runId: string;
|
|
197
|
+
platform: MeetingPlatform;
|
|
198
|
+
maxSeconds: number;
|
|
199
|
+
}): Promise<ReserveResult>;
|
|
200
|
+
/** A scheduled run, at dispatch: still paid, still has the hours. */
|
|
201
|
+
revalidate(reservationId: string): Promise<boolean>;
|
|
202
|
+
/** The seconds the run has used so far, every minute: a running total, not an increment. */
|
|
203
|
+
meter(reservationId: string, seconds: number): Promise<void>;
|
|
204
|
+
/** Settles the run at the seconds it is billed. */
|
|
205
|
+
settle(reservationId: string, billedSeconds: number): Promise<void>;
|
|
206
|
+
/** Frees a reservation nothing is billed against: a run that ends unbilled, or a send refused after its reservation. */
|
|
207
|
+
release(reservationId: string): Promise<void>;
|
|
208
|
+
}
|
|
209
|
+
/** The manager's clock; a test passes a fake. */
|
|
210
|
+
export interface IClock {
|
|
211
|
+
/** The current time, in milliseconds. */
|
|
212
|
+
now(): number;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Backoff: 5 s, 10 s, 20 s ... up to an hour between attempts, dead a day after the first attempt.
|
|
216
|
+
*
|
|
217
|
+
* @param attempts - The failed attempts so far, the one just recorded included.
|
|
218
|
+
* @param now - When that failure was recorded, in milliseconds.
|
|
219
|
+
* @returns When the next attempt is due.
|
|
220
|
+
*/
|
|
221
|
+
export declare function nextAttemptAt(attempts: number, now: number): number;
|
|
222
|
+
/** How long after its first failed attempt a delivery is given up as `dead`: a day. */
|
|
223
|
+
export declare const OUTBOX_GIVE_UP_MS = 86400000;
|
|
224
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"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E;IACrE,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,4FAA4F;IAC5F,KAAK,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,mDAAmD;IACnD,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,wHAAwH;IACxH,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED,iDAAiD;AACjD,MAAM,WAAW,MAAM;IACrB,yCAAyC;IACzC,GAAG,IAAI,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnE;AACD,uFAAuF;AACvF,eAAO,MAAM,iBAAiB,WAAa,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Thrown by a store that refuses content for a run behind the fence. */
|
|
2
|
+
export class FencedError extends Error {
|
|
3
|
+
/** @param runId - The run whose content was refused. */
|
|
4
|
+
constructor(runId) {
|
|
5
|
+
super(`run ${runId} is being purged; no content is accepted`);
|
|
6
|
+
this.runId = runId;
|
|
7
|
+
this.name = 'FencedError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Thrown by {@link IRunStore.insert} when the owner already has a run with the idempotency key: a send that loses that race answers the run the key has ({@link IRunStore.findByIdempotencyKey}). */
|
|
11
|
+
export class DuplicateIdempotencyKeyError extends Error {
|
|
12
|
+
/**
|
|
13
|
+
* @param ownerRef - The owner the key belongs to.
|
|
14
|
+
* @param idempotencyKey - The key the owner already has a run with.
|
|
15
|
+
*/
|
|
16
|
+
constructor(ownerRef, idempotencyKey) {
|
|
17
|
+
super(`the owner already has a run with idempotency key ${idempotencyKey}`);
|
|
18
|
+
this.ownerRef = ownerRef;
|
|
19
|
+
this.idempotencyKey = idempotencyKey;
|
|
20
|
+
this.name = 'DuplicateIdempotencyKeyError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Backoff: 5 s, 10 s, 20 s ... up to an hour between attempts, dead a day after the first attempt.
|
|
25
|
+
*
|
|
26
|
+
* @param attempts - The failed attempts so far, the one just recorded included.
|
|
27
|
+
* @param now - When that failure was recorded, in milliseconds.
|
|
28
|
+
* @returns When the next attempt is due.
|
|
29
|
+
*/
|
|
30
|
+
export function nextAttemptAt(attempts, now) {
|
|
31
|
+
return now + Math.min(5000 * 2 ** Math.max(0, attempts - 1), 3600000);
|
|
32
|
+
}
|
|
33
|
+
/** How long after its first failed attempt a delivery is given up as `dead`: a day. */
|
|
34
|
+
export const OUTBOX_GIVE_UP_MS = 86400000;
|
|
35
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/io/channels/meetings/stores/types.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,wDAAwD;IACxD,YAAqB,KAAa;QAChC,KAAK,CAAC,OAAO,KAAK,0CAA0C,CAAC,CAAC;QAD3C,UAAK,GAAL,KAAK,CAAQ;QAEhC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,sMAAsM;AACtM,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IACrD;;;OAGG;IACH,YAAqB,QAAgB,EAAW,cAAsB;QACpE,KAAK,CAAC,oDAAoD,cAAc,EAAE,CAAC,CAAC;QADzD,aAAQ,GAAR,QAAQ,CAAQ;QAAW,mBAAc,GAAd,cAAc,CAAQ;QAEpE,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AA6LD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,GAAW;IACzD,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAK,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,EAAE,OAAS,CAAC,CAAC;AAC3E,CAAC;AACD,uFAAuF;AACvF,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAU,CAAC"}
|