@pinecall/room 0.1.2 → 0.1.4
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/README.md +44 -6
- package/dist/code.d.ts +14 -0
- package/dist/code.d.ts.map +1 -0
- package/dist/code.js +46 -0
- package/dist/code.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/karaoke.d.ts +1 -1
- package/dist/karaoke.d.ts.map +1 -1
- package/dist/karaoke.js +2 -1
- package/dist/karaoke.js.map +1 -1
- package/dist/log/backoff.d.ts +11 -0
- package/dist/log/backoff.d.ts.map +1 -0
- package/dist/log/backoff.js +30 -0
- package/dist/log/backoff.js.map +1 -0
- package/dist/log/fold.d.ts +2 -1
- package/dist/log/fold.d.ts.map +1 -1
- package/dist/log/fold.js +4 -1
- package/dist/log/fold.js.map +1 -1
- package/dist/log/follow.d.ts.map +1 -1
- package/dist/log/follow.js +5 -21
- package/dist/log/follow.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +5 -2
- package/dist/react/index.js.map +1 -1
- package/dist/reading.d.ts +11 -0
- package/dist/reading.d.ts.map +1 -0
- package/dist/reading.js +18 -0
- package/dist/reading.js.map +1 -0
- package/dist/room.d.ts +15 -5
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +45 -22
- package/dist/room.js.map +1 -1
- package/dist/rows.d.ts +1 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +1 -0
- package/dist/rows.js.map +1 -1
- package/dist/server/index.d.ts +22 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +15 -1
- package/dist/server/index.js.map +1 -1
- package/dist/wire/codec.d.ts +22 -0
- package/dist/wire/codec.d.ts.map +1 -0
- package/dist/wire/codec.js +23 -0
- package/dist/wire/codec.js.map +1 -0
- package/dist/wire/defs.d.ts +302 -0
- package/dist/wire/defs.d.ts.map +1 -0
- package/dist/wire/defs.js +171 -0
- package/dist/wire/defs.js.map +1 -0
- package/dist/wire/envelope.d.ts +17 -0
- package/dist/wire/envelope.d.ts.map +1 -0
- package/dist/wire/envelope.js +16 -0
- package/dist/wire/envelope.js.map +1 -0
- package/dist/wire/events-call.d.ts +422 -0
- package/dist/wire/events-call.d.ts.map +1 -0
- package/dist/wire/events-call.js +182 -0
- package/dist/wire/events-call.js.map +1 -0
- package/dist/wire/events.d.ts +923 -0
- package/dist/wire/events.d.ts.map +1 -0
- package/dist/wire/events.js +292 -0
- package/dist/wire/events.js.map +1 -0
- package/dist/wire/metrics.d.ts +366 -0
- package/dist/wire/metrics.d.ts.map +1 -0
- package/dist/wire/metrics.js +269 -0
- package/dist/wire/metrics.js.map +1 -0
- package/dist/wire/reduce.d.ts +12 -0
- package/dist/wire/reduce.d.ts.map +1 -0
- package/dist/wire/reduce.js +375 -0
- package/dist/wire/reduce.js.map +1 -0
- package/dist/wire/registry.d.ts +1395 -0
- package/dist/wire/registry.d.ts.map +1 -0
- package/dist/wire/registry.js +81 -0
- package/dist/wire/registry.js.map +1 -0
- package/dist/wire/rest.d.ts +18 -0
- package/dist/wire/rest.d.ts.map +1 -0
- package/dist/wire/rest.js +14 -0
- package/dist/wire/rest.js.map +1 -0
- package/dist/wire/room.d.ts +106 -0
- package/dist/wire/room.d.ts.map +1 -0
- package/dist/wire/room.js +73 -0
- package/dist/wire/room.js.map +1 -0
- package/dist/wire/state.d.ts +915 -0
- package/dist/wire/state.d.ts.map +1 -0
- package/dist/wire/state.js +189 -0
- package/dist/wire/state.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -13,13 +13,13 @@ that change it. The package has three entry points, and each one is for a differ
|
|
|
13
13
|
|---|---|---|
|
|
14
14
|
| `@pinecall/room` | the page | `room()`, the store of one conversation, `rowsOf`, `knownBy`, `brief` to draw it, and the karaoke of what is being said |
|
|
15
15
|
| `@pinecall/room/react` | the page, in React | `useRoom()` and `useStore()` |
|
|
16
|
-
| `@pinecall/room/server` | your server | `mint()`, `dial()` and `GatewayRefused`: the only code that touches the key |
|
|
16
|
+
| `@pinecall/room/server` | your server | `mint()`, `dial()`, `expect()` and `GatewayRefused`: the only code that touches the key |
|
|
17
17
|
|
|
18
18
|
A conversation has two parts, and they are not the same thing. **The seat** is a LiveKit room: it
|
|
19
19
|
carries the audio and the typed lines. **The log** is the call's record on the gateway, read
|
|
20
20
|
straight from it with a token minted for that one call: every turn, every tool the agent called and what came back, the agent's own state, and
|
|
21
21
|
at the end the cost and the score. The store joins the two. What the page draws is the log folded
|
|
22
|
-
by
|
|
22
|
+
by the runtime's own reducer, the same fold the Pinecall console draws from.
|
|
23
23
|
|
|
24
24
|
## Install
|
|
25
25
|
|
|
@@ -101,7 +101,7 @@ export function Visitor() {
|
|
|
101
101
|
`useRoom` makes one room per mounted component and closes it when the component unmounts. The
|
|
102
102
|
options are read when they are used, not when the room is made, so a `tokens` written inline — a
|
|
103
103
|
new function every render — is fine: the one from the last render is the one that runs. It hands
|
|
104
|
-
back the state with the
|
|
104
|
+
back the state with the six verbs beside it.
|
|
105
105
|
|
|
106
106
|
`useStore(store)` is the plain version: any store of this package, read with React's
|
|
107
107
|
`useSyncExternalStore`. `useRoom` is `useStore` over a room it owns.
|
|
@@ -188,6 +188,39 @@ The gateway refuses a dial to a number that has never called or written to the o
|
|
|
188
188
|
dials per minute and per day. Those refusals reach the page as a failed call with the gateway's
|
|
189
189
|
sentence.
|
|
190
190
|
|
|
191
|
+
## Let the visitor call you
|
|
192
|
+
|
|
193
|
+
Give `room()` an `expect`, and the page can show the agent's phone number and a four-digit code
|
|
194
|
+
instead: the visitor calls the number, keys the code on the phone (or says it, and the agent
|
|
195
|
+
claims it), and from that moment the page follows that call. Your server asks for the code:
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
import { expect } from "@pinecall/room/server";
|
|
199
|
+
|
|
200
|
+
app.post("/api/expect", async (c) => expect(KEY, { url, agent, log: "tenant" }).then((code) => c.json(code), refused));
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The page hands the answer to the room as it came, and calls `byPhone()`:
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
const call = room({ tokens, expect: async () => (await fetch("/api/expect", { method: "POST" })).json() });
|
|
207
|
+
|
|
208
|
+
await call.byPhone();
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The phase is `expecting` while the page waits, and `state.code` is `{code, number, expiresAt}`:
|
|
212
|
+
show "call `number` and key `code`", and `expiresAt` (seconds since the epoch) as a countdown if
|
|
213
|
+
you like. The page asks the gateway about the code with the code's own token, which reads that
|
|
214
|
+
code and nothing else; the gateway holds each ask up to 25 seconds, and a network that fails or a
|
|
215
|
+
`5xx` is asked again the way the log is. When a call claims the code the phase goes straight to
|
|
216
|
+
`live` — the caller is on the phone already — and the call is followed like any other: `call`,
|
|
217
|
+
the log, `speaking`, `ended`. A code lives ten minutes unless `ttl_s` says otherwise (60 to 1800
|
|
218
|
+
seconds); an expired one fails with "the code expired: ask for another". `leave()` while
|
|
219
|
+
`expecting` stops the asking at once.
|
|
220
|
+
|
|
221
|
+
The agent must answer at a phone number in the key's world, or `expect()` throws the gateway's
|
|
222
|
+
409 naming the fix.
|
|
223
|
+
|
|
191
224
|
## Relaying the log yourself
|
|
192
225
|
|
|
193
226
|
A page that must not reach the gateway — a network that only lets it talk to your own domain —
|
|
@@ -204,16 +237,17 @@ handed is never changed afterwards, so it can be compared by reference and kept.
|
|
|
204
237
|
|
|
205
238
|
| field | what it is |
|
|
206
239
|
|---|---|
|
|
207
|
-
| `phase` | `idle` · `opening` (minting, joining) · `ringing` (a phone call not yet answered) · `live` · `ended` · `failed` |
|
|
240
|
+
| `phase` | `idle` · `opening` (minting, joining) · `expecting` (a code shown, no call has claimed it yet) · `ringing` (a phone call not yet answered) · `live` · `ended` · `failed` |
|
|
208
241
|
| `mode` | `talk`, `chat`, `phone`, or `null` before anything started |
|
|
209
242
|
| `call` | the call id, once the tokens or the dial answered it; `""` before |
|
|
210
243
|
| `error` | the sentence to show when `phase` is `failed`; `""` otherwise |
|
|
211
244
|
| `recording` | where the call's recording plays from, with its token: an `<audio src>` once the call has ended; `""` when the log is relayed |
|
|
212
|
-
| `log` | the call as
|
|
245
|
+
| `log` | the call as the runtime's reducer folds it: `turns`, `tools`, `app_state`, `status`, `live` (the words being said right now), `cost` |
|
|
213
246
|
| `entries` | every entry of the log read so far, in order |
|
|
214
247
|
| `connection` | the log's stream: `connecting` · `live` · `reconnecting` · `ended` (also before anything opened) |
|
|
215
248
|
| `wantsSound` | `true` when the browser has not let the page play sound yet: show a button that calls `playSound()` |
|
|
216
249
|
| `speaking` | `{agent, user, level}`: who is making a sound right now, and how loud the agent is, 0 to 1 |
|
|
250
|
+
| `code` | `{code, number, expiresAt}` once `byPhone()` has a code to show; `null` otherwise |
|
|
217
251
|
|
|
218
252
|
The phase and everything around it — `error`, `connection`, `wantsSound`, `speaking` — are
|
|
219
253
|
published the moment they change. The log is painted at most ten times a second: a burst of
|
|
@@ -309,6 +343,10 @@ Nothing fails silently. Every refusal is a phase and a sentence, or a rejected p
|
|
|
309
343
|
| `livekit-client` could not be loaded | `failed`, `error` is the loader's message |
|
|
310
344
|
| `callMe` threw | `failed`, `error` is its message |
|
|
311
345
|
| `callMe()` on a room given no `callMe` | `failed`, `error` says so |
|
|
346
|
+
| `expect` threw | `failed`, `error` is its message |
|
|
347
|
+
| `byPhone()` on a room given no `expect` | `failed`, `error` says so |
|
|
348
|
+
| the code expired before a call claimed it | `failed`, "the code expired: ask for another" |
|
|
349
|
+
| the gateway answered a `4xx` about the code | `failed`, "the code answered 403" |
|
|
312
350
|
| the log answered a `4xx` | on the phone: `failed`, "the log answered 401". In a room: `connection` is `ended` and the phase is left to the seat, which is the call |
|
|
313
351
|
| the log answered a `5xx`, or its stream dropped | `connection` is `reconnecting`, and it resumes where it was; nothing ends |
|
|
314
352
|
| `tokens` or `callMe` answered no `log_token`, and there is no `log` to relay it | `failed`, `error` says so |
|
|
@@ -316,7 +354,7 @@ Nothing fails silently. Every refusal is a phase and a sentence, or a rejected p
|
|
|
316
354
|
| an entry of the log this version cannot read | skipped; `onSkipped(why)` is called, and the rest of the call still draws |
|
|
317
355
|
| `send()` outside a live seat | the promise rejects with "not in a call"; an empty line is nothing |
|
|
318
356
|
|
|
319
|
-
On the server, `mint` and `
|
|
357
|
+
On the server, `mint`, `dial` and `expect` throw `GatewayRefused` for a refusal: `status` is the gateway's,
|
|
320
358
|
and `detail` its sentence when it sent one (`null` when the body was not the gateway's JSON). The
|
|
321
359
|
sentence names the fix — a quota, a scope the key does not hold, a number the org cannot call —
|
|
322
360
|
so pass it on rather than rewording it.
|
package/dist/code.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A code the page shows a caller, waited on: the gateway asked with the code's token until a call claims it or it expires. */
|
|
2
|
+
import type { Code } from "./server/index.js";
|
|
3
|
+
/** How the wait came out: the call that claimed the code, or the sentence to show instead. */
|
|
4
|
+
export type Claim = {
|
|
5
|
+
kind: "claimed";
|
|
6
|
+
call: string;
|
|
7
|
+
log_token: string | null;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "failed";
|
|
10
|
+
error: string;
|
|
11
|
+
};
|
|
12
|
+
/** Ask `gateway` about `code` until a call claims it or it expires. Null when `signal` stopped it first. */
|
|
13
|
+
export declare function claimOf(gateway: string, code: Code, fetcher: typeof fetch, signal: AbortSignal): Promise<Claim | null>;
|
|
14
|
+
//# sourceMappingURL=code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../src/code.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAS/H,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,8FAA8F;AAC9F,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAKpH,4GAA4G;AAC5G,wBAAsB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CA4B5H"}
|
package/dist/code.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** A code the page shows a caller, waited on: the gateway asked with the code's token until a call claims it or it expires. */
|
|
2
|
+
//
|
|
3
|
+
// The gateway holds each ask up to 25 s and answers `waiting` when nothing happened, so the page
|
|
4
|
+
// asks again at once. A network that fails or a `5xx` — a gateway restarting under a deploy — is
|
|
5
|
+
// asked again the way the log's stream is, backing off; a `4xx` is the gateway saying no.
|
|
6
|
+
import { CodeStandingSchema } from "./wire/rest.js";
|
|
7
|
+
import { AWAY, Backoff } from "./log/backoff.js";
|
|
8
|
+
const EXPIRED = "the code expired: ask for another";
|
|
9
|
+
const UNKNOWN = "the gateway answered the code with a shape this package does not know";
|
|
10
|
+
/** Ask `gateway` about `code` until a call claims it or it expires. Null when `signal` stopped it first. */
|
|
11
|
+
export async function claimOf(gateway, code, fetcher, signal) {
|
|
12
|
+
const url = `${gateway}/v1/codes/${encodeURIComponent(code.code)}?wait=1&token=${encodeURIComponent(code.code_token)}`;
|
|
13
|
+
const backoff = new Backoff();
|
|
14
|
+
while (!signal.aborted) {
|
|
15
|
+
let body;
|
|
16
|
+
try {
|
|
17
|
+
const answer = await fetcher(url, { signal });
|
|
18
|
+
if (answer.status >= AWAY) {
|
|
19
|
+
await answer.body?.cancel().catch(() => undefined);
|
|
20
|
+
await backoff.wait(signal);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (!answer.ok)
|
|
24
|
+
return { kind: "failed", error: `the code answered ${answer.status}` };
|
|
25
|
+
body = await answer.json();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// The network failed, or the answer broke before it was whole: the same as a 5xx.
|
|
29
|
+
if (signal.aborted)
|
|
30
|
+
return null;
|
|
31
|
+
await backoff.wait(signal);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const standing = CodeStandingSchema.safeParse(body);
|
|
35
|
+
if (!standing.success)
|
|
36
|
+
return { kind: "failed", error: UNKNOWN };
|
|
37
|
+
backoff.reset();
|
|
38
|
+
const { status, call, log_token } = standing.data;
|
|
39
|
+
if (status === "expired")
|
|
40
|
+
return { kind: "failed", error: EXPIRED };
|
|
41
|
+
if (status === "claimed")
|
|
42
|
+
return call === null ? { kind: "failed", error: UNKNOWN } : { kind: "claimed", call, log_token };
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=code.js.map
|
package/dist/code.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.js","sourceRoot":"","sources":["../src/code.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAC/H,EAAE;AACF,iGAAiG;AACjG,iGAAiG;AACjG,0FAA0F;AAE1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMjD,MAAM,OAAO,GAAG,mCAAmC,CAAC;AACpD,MAAM,OAAO,GAAG,uEAAuE,CAAC;AAExF,4GAA4G;AAC5G,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAAe,EAAE,IAAU,EAAE,OAAqB,EAAE,MAAmB;IACnG,MAAM,GAAG,GAAG,GAAG,OAAO,aAAa,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;IACvH,MAAM,OAAO,GAA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KAAK,SAAS;YAAE,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC7H,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @pinecall/room: the caller's side of a Pinecall call in a browser — one store, no framework. */
|
|
2
2
|
export { room } from "./room.js";
|
|
3
|
-
export type { Minted, Mode, Phase, RoomOptions, RoomState, RoomStore } from "./room.js";
|
|
3
|
+
export type { Code, Minted, Mode, Phase, RoomOptions, RoomState, RoomStore } from "./room.js";
|
|
4
4
|
export type { Store } from "./store.js";
|
|
5
5
|
export type { Connection } from "./log/follow.js";
|
|
6
6
|
export type { Speaking } from "./seat/join.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAEnG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAEnG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9F,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE,KAAK,MAAM,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/karaoke.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The agent's reply while it is being said: its words as the log delivers them, and which have sounded. */
|
|
2
|
-
import { type Entry } from "
|
|
2
|
+
import { type Entry } from "./wire/envelope.js";
|
|
3
3
|
/** One delta of the reply: a word (voice) or a token (text), and when it sounds, if it does. */
|
|
4
4
|
export interface Word {
|
|
5
5
|
text: string;
|
package/dist/karaoke.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"karaoke.d.ts","sourceRoot":"","sources":["../src/karaoke.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAQ5G,OAAO,
|
|
1
|
+
{"version":3,"file":"karaoke.d.ts","sourceRoot":"","sources":["../src/karaoke.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAQ5G,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAGhD,gGAAgG;AAChG,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,mEAAmE;AACnE,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,qFAAqF;AACrF,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wHAAwH;AACxH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,MAAM,GAAG,IAAI,CAgBjE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAOzE;AAED,mGAAmG;AACnG,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,CAQrD;AAED,kFAAkF;AAClF,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAG1D"}
|
package/dist/karaoke.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// A word is lit when the clock reaches it, so the words on screen are the words in the ear. A
|
|
6
6
|
// written call's deltas are model tokens with no timing: they are lit the moment they arrive.
|
|
7
7
|
// The visitor's side needs nothing here: `state.log.live.user` is what the ear has heard so far.
|
|
8
|
-
import {
|
|
8
|
+
import {} from "./wire/envelope.js";
|
|
9
|
+
import { AgentTranscriptSchema } from "./wire/events-call.js";
|
|
9
10
|
/** The reply being said now, read back from the newest entry to the last closed turn; null when nobody is mid-reply. */
|
|
10
11
|
export function sayingOf(entries) {
|
|
11
12
|
const words = [];
|
package/dist/karaoke.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"karaoke.js","sourceRoot":"","sources":["../src/karaoke.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,EAAE;AACF,+FAA+F;AAC/F,gGAAgG;AAChG,8FAA8F;AAC9F,8FAA8F;AAC9F,iGAAiG;AAEjG,OAAO,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"karaoke.js","sourceRoot":"","sources":["../src/karaoke.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,EAAE;AACF,+FAA+F;AAC/F,gGAAgG;AAChG,8FAA8F;AAC9F,8FAA8F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is asked again: half a second, doubling to eight, for as long as it takes. */
|
|
2
|
+
/** From here up the gateway, or the proxy in front of it, is away rather than saying no. */
|
|
3
|
+
export declare const AWAY = 500;
|
|
4
|
+
/** One asker's pause between tries. `reset` once the gateway has answered. */
|
|
5
|
+
export declare class Backoff {
|
|
6
|
+
#private;
|
|
7
|
+
/** Sleeps the current pause, cut short by `signal`, and doubles the next one. */
|
|
8
|
+
wait(signal: AbortSignal): Promise<void>;
|
|
9
|
+
reset(): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=backoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backoff.d.ts","sourceRoot":"","sources":["../../src/log/backoff.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAQ5G,4FAA4F;AAC5F,eAAO,MAAM,IAAI,MAAM,CAAC;AAExB,8EAA8E;AAC9E,qBAAa,OAAO;;IAGlB,iFAAiF;IAC3E,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7C;IAED,KAAK,IAAI,IAAI,CAEZ;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** How a gateway that is away is asked again: half a second, doubling to eight, for as long as it takes. */
|
|
2
|
+
// A dropped stream is opened again after this, doubling to the ceiling: a gateway restarting is
|
|
3
|
+
// seconds, and a page hammering it every 100 ms would only make those seconds longer. A 5xx is the
|
|
4
|
+
// same thing seen from a proxy — the gateway behind it is restarting — and is asked again too.
|
|
5
|
+
const FIRST_MS = 500;
|
|
6
|
+
const CEILING_MS = 8_000;
|
|
7
|
+
/** From here up the gateway, or the proxy in front of it, is away rather than saying no. */
|
|
8
|
+
export const AWAY = 500;
|
|
9
|
+
/** One asker's pause between tries. `reset` once the gateway has answered. */
|
|
10
|
+
export class Backoff {
|
|
11
|
+
#ms = FIRST_MS;
|
|
12
|
+
/** Sleeps the current pause, cut short by `signal`, and doubles the next one. */
|
|
13
|
+
async wait(signal) {
|
|
14
|
+
await slept(this.#ms, signal);
|
|
15
|
+
this.#ms = Math.min(this.#ms * 2, CEILING_MS);
|
|
16
|
+
}
|
|
17
|
+
reset() {
|
|
18
|
+
this.#ms = FIRST_MS;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function slept(ms, signal) {
|
|
22
|
+
return new Promise((wake) => {
|
|
23
|
+
const timer = setTimeout(wake, ms);
|
|
24
|
+
signal.addEventListener("abort", () => {
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
wake();
|
|
27
|
+
}, { once: true });
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=backoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backoff.js","sourceRoot":"","sources":["../../src/log/backoff.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAE5G,gGAAgG;AAChG,mGAAmG;AACnG,+FAA+F;AAC/F,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,UAAU,GAAG,KAAK,CAAC;AAEzB,4FAA4F;AAC5F,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAC;AAExB,8EAA8E;AAC9E,MAAM,OAAO,OAAO;IAClB,GAAG,GAAG,QAAQ,CAAC;IAEf,iFAAiF;IACjF,KAAK,CAAC,IAAI,CAAC,MAAmB;QAC5B,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;IAED,KAAK;QACH,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC;IACtB,CAAC;CACF;AAED,SAAS,KAAK,CAAC,EAAU,EAAE,MAAmB;IAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1B,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACnC,MAAM,CAAC,gBAAgB,CACrB,OAAO,EACP,GAAG,EAAE;YACH,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,IAAI,EAAE,CAAC;QACT,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/log/fold.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** The log folded as it arrives: the protocol's own reducer, one entry at a time, every entry kept. */
|
|
2
|
-
import { type Entry
|
|
2
|
+
import { type Entry } from "../wire/envelope.js";
|
|
3
|
+
import { type State } from "../wire/state.js";
|
|
3
4
|
import type { SseMessage } from "./sse.js";
|
|
4
5
|
/** What the page draws from: the call as the protocol folds it, and the entries it was folded from. */
|
|
5
6
|
export interface Folded {
|
package/dist/log/fold.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["../../src/log/fold.ts"],"names":[],"mappings":"AAAA,uGAAuG;
|
|
1
|
+
{"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["../../src/log/fold.ts"],"names":[],"mappings":"AAAA,uGAAuG;AAGvG,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,uGAAuG;AACvG,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,KAAK,EAAE,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,OAAO;;IAKlB,YAAY,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,EAE3C;IAED,gGAAgG;IAChG,IAAI,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,CAEzB;IAED,uGAAuG;IACvG,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,KAAK,GAAG,IAAI,CAatC;IAED,gFAAgF;IAChF,QAAQ,IAAI,MAAM,CAEjB;CACF"}
|
package/dist/log/fold.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/** The log folded as it arrives: the protocol's own reducer, one entry at a time, every entry kept. */
|
|
2
|
-
import {
|
|
2
|
+
import { decodeEntry } from "../wire/codec.js";
|
|
3
|
+
import {} from "../wire/envelope.js";
|
|
4
|
+
import { apply, initialState } from "../wire/reduce.js";
|
|
5
|
+
import {} from "../wire/state.js";
|
|
3
6
|
/**
|
|
4
7
|
* One call's log, folding. The protocol's `apply` mutates the state it is given, so what this
|
|
5
8
|
* holds is a working copy: `snapshot()` is what leaves it, and nothing that left is ever changed.
|
package/dist/log/fold.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fold.js","sourceRoot":"","sources":["../../src/log/fold.ts"],"names":[],"mappings":"AAAA,uGAAuG;AAEvG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fold.js","sourceRoot":"","sources":["../../src/log/fold.ts"],"names":[],"mappings":"AAAA,uGAAuG;AAEvG,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAc,MAAM,kBAAkB,CAAC;AAU9C;;;GAGG;AACH,MAAM,OAAO,OAAO;IAClB,MAAM,GAAU,YAAY,EAAE,CAAC;IAC/B,QAAQ,GAAY,EAAE,CAAC;IACd,UAAU,CAAwB;IAE3C,YAAY,SAAgC;QAC1C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,gGAAgG;IAChG,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,uGAAuG;IACvG,IAAI,CAAC,OAAmB;QACtB,IAAI,OAAO,CAAC,IAAI,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;QACrC,IAAI,KAAY,CAAC;QACjB,IAAI,CAAC;YACH,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC9D,IAAI,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,KAAK,IAAI,WAAW,OAAO,OAAO,CAAC,EAAE,IAAI,OAAO,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YAC/G,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gFAAgF;IAChF,QAAQ;QACN,OAAO,EAAE,GAAG,EAAE,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC5E,CAAC;CACF"}
|
package/dist/log/follow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../../src/log/follow.ts"],"names":[],"mappings":"AAAA,iGAAiG;
|
|
1
|
+
{"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../../src/log/follow.ts"],"names":[],"mappings":"AAAA,iGAAiG;AAKjG,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtD,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC;AAE1E,sGAAsG;AACtG,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnG,kGAAkG;AAClG,MAAM,WAAW,SAAS;IACxB,kGAAkG;IAClG,SAAS,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,YAAY,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACjE,gGAAgG;IAChG,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAKD,8FAA8F;AAC9F,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,KAAK,GAAG,MAAM,IAAI,CA0E3F"}
|
package/dist/log/follow.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
/** Follow a call's log over fetch: from where it was, through a dropped stream, to the score. */
|
|
2
|
-
import { TERMINAL_EVENT } from "
|
|
2
|
+
import { TERMINAL_EVENT } from "../wire/registry.js";
|
|
3
|
+
import { AWAY, Backoff } from "./backoff.js";
|
|
3
4
|
import { SseParser } from "./sse.js";
|
|
4
|
-
// A dropped stream is opened again after this, doubling to the ceiling: a gateway restarting is
|
|
5
|
-
// seconds, and a page hammering it every 100 ms would only make those seconds longer. A 5xx is the
|
|
6
|
-
// same thing seen from a proxy — the gateway behind it is restarting — and is asked again too.
|
|
7
|
-
const RECONNECT_MS = 500;
|
|
8
|
-
const RECONNECT_CEILING_MS = 8_000;
|
|
9
5
|
// The relay answers 204 to a sealed call whose cursor is at the end: nothing more will be said.
|
|
10
6
|
const NOTHING_MORE = 204;
|
|
11
|
-
// From here up the gateway, or the proxy in front of it, is away rather than saying no.
|
|
12
|
-
const AWAY = 500;
|
|
13
7
|
/** Open the log at `url`. Returns the call that stops it; stopping twice is stopping once. */
|
|
14
8
|
export function followLog(url, reader, fetcher) {
|
|
15
9
|
const controller = new AbortController();
|
|
16
10
|
let lastId = null;
|
|
17
|
-
|
|
11
|
+
const backoff = new Backoff();
|
|
18
12
|
let ours = true;
|
|
19
13
|
const stop = () => {
|
|
20
14
|
ours = false;
|
|
@@ -26,8 +20,7 @@ export function followLog(url, reader, fetcher) {
|
|
|
26
20
|
};
|
|
27
21
|
const again = async () => {
|
|
28
22
|
reader.onConnection("reconnecting");
|
|
29
|
-
await
|
|
30
|
-
backoff = Math.min(backoff * 2, RECONNECT_CEILING_MS);
|
|
23
|
+
await backoff.wait(controller.signal);
|
|
31
24
|
};
|
|
32
25
|
const read = async (body) => {
|
|
33
26
|
const parser = new SseParser();
|
|
@@ -75,7 +68,7 @@ export function followLog(url, reader, fetcher) {
|
|
|
75
68
|
if (!answer.ok || answer.body === null)
|
|
76
69
|
return end({ kind: "refused", status: answer.status });
|
|
77
70
|
reader.onConnection("live");
|
|
78
|
-
backoff
|
|
71
|
+
backoff.reset();
|
|
79
72
|
try {
|
|
80
73
|
await read(answer.body);
|
|
81
74
|
}
|
|
@@ -92,13 +85,4 @@ export function followLog(url, reader, fetcher) {
|
|
|
92
85
|
void connect();
|
|
93
86
|
return stop;
|
|
94
87
|
}
|
|
95
|
-
function slept(ms, signal) {
|
|
96
|
-
return new Promise((wake) => {
|
|
97
|
-
const timer = setTimeout(wake, ms);
|
|
98
|
-
signal.addEventListener("abort", () => {
|
|
99
|
-
clearTimeout(timer);
|
|
100
|
-
wake();
|
|
101
|
-
}, { once: true });
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
88
|
//# sourceMappingURL=follow.js.map
|
package/dist/log/follow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"follow.js","sourceRoot":"","sources":["../../src/log/follow.ts"],"names":[],"mappings":"AAAA,iGAAiG;AAEjG,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"follow.js","sourceRoot":"","sources":["../../src/log/follow.ts"],"names":[],"mappings":"AAAA,iGAAiG;AAEjG,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAmB,MAAM,UAAU,CAAC;AAiBtD,gGAAgG;AAChG,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,8FAA8F;AAC9F,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,MAAiB,EAAE,OAAqB;IAC7E,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,IAAI,MAAM,GAAkB,IAAI,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,IAAI,IAAI,GAAG,IAAI,CAAC;IAEhB,MAAM,IAAI,GAAG,GAAS,EAAE;QACtB,IAAI,GAAG,KAAK,CAAC;QACb,UAAU,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC,CAAC;IAEF,MAAM,GAAG,GAAG,CAAC,MAAc,EAAQ,EAAE;QACnC,IAAI,EAAE,CAAC;QACP,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,KAAK,IAAmB,EAAE;QACtC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;QACpC,MAAM,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,KAAK,EAAE,IAAgC,EAAiB,EAAE;QACrE,MAA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AAC;gBACd,SAAS;YACX,CAAC;YACD,IAAI,CAAC,IAAI;gBAAE,OAAO;YAClB,IAAI,MAAM,CAAC,MAAM,KAAK,YAAY;gBAAE,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;YACnE,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;gBAC1B,MAAM,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;gBACnD,MAAM,KAAK,EAAE,CAAC;gBACd,SAAS;YACX,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;gBAAE,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAC/F,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC5B,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;YAAC,MAAM,CAAC;gBACP,iEAAiE;YACnE,CAAC;YACD,IAAI,CAAC,IAAI;gBAAE,OAAO;YAClB,wFAAwF;YACxF,MAAM,KAAK,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAClC,KAAK,OAAO,EAAE,CAAC;IACf,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type Lit, type RoomOptions, type RoomState, type RoomStore, type Store
|
|
|
3
3
|
/** The store's state, re-rendering when it changes. Any store of this package. */
|
|
4
4
|
export declare function useStore<T>(store: Store<T>): T;
|
|
5
5
|
/** What `useRoom` hands a component: the state, and the verbs to change it. */
|
|
6
|
-
export type RoomHandle = RoomState & Pick<RoomStore, "start" | "send" | "callMe" | "leave" | "playSound">;
|
|
6
|
+
export type RoomHandle = RoomState & Pick<RoomStore, "start" | "send" | "callMe" | "byPhone" | "leave" | "playSound">;
|
|
7
7
|
/**
|
|
8
8
|
* One room for as long as the component is mounted, closed when it unmounts. The options are read
|
|
9
9
|
* when they are used, never when the room was made: a `tokens` written inline, new every render,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,sGAAsG;AAItG,OAAO,EAAyB,KAAK,GAAG,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAE5H,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAI9C;AAED,+EAA+E;AAC/E,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,sGAAsG;AAItG,OAAO,EAAyB,KAAK,GAAG,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAE5H,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAI9C;AAED,+EAA+E;AAC/E,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC,CAAC;AAEtH;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAuBxD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,GAAG,GAAG,IAAI,CAqBpE"}
|
package/dist/react/index.js
CHANGED
|
@@ -33,8 +33,8 @@ export function useRoom(options) {
|
|
|
33
33
|
};
|
|
34
34
|
}, [store]);
|
|
35
35
|
const state = useStore(store);
|
|
36
|
-
const { start, send, callMe, leave, playSound } = store;
|
|
37
|
-
return { ...state, start, send, callMe, leave, playSound };
|
|
36
|
+
const { start, send, callMe, byPhone, leave, playSound } = store;
|
|
37
|
+
return { ...state, start, send, callMe, byPhone, leave, playSound };
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* The agent's reply as the voice says it: `lit` has sounded, `coming` has not, or null when nobody
|
|
@@ -77,6 +77,9 @@ function readingLatest(latest) {
|
|
|
77
77
|
get callMe() {
|
|
78
78
|
return latest.current.callMe;
|
|
79
79
|
},
|
|
80
|
+
get expect() {
|
|
81
|
+
return latest.current.expect;
|
|
82
|
+
},
|
|
80
83
|
get linger() {
|
|
81
84
|
return latest.current.linger;
|
|
82
85
|
},
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,sGAAsG;AAEtG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAA0E,MAAM,aAAa,CAAC;AAE5H,kFAAkF;AAClF,MAAM,UAAU,QAAQ,CAAI,KAAe;IACzC,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,OAAmB,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,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enant's relay when it gave one, the gateway with the call's own token otherwise. */
|
|
2
|
+
import type { Minted } from "./server/index.js";
|
|
3
|
+
import type { RoomOptions } from "./room.js";
|
|
4
|
+
/** The gateway the page asks, with no slash at the end. */
|
|
5
|
+
export declare function gatewayOf(options: Pick<RoomOptions, "gateway">): string;
|
|
6
|
+
/** The call's log and its recording. None when neither a relay nor a token is there to read it with. */
|
|
7
|
+
export declare function readingOf(options: Pick<RoomOptions, "gateway" | "log">, call: string, token: string | undefined, minted?: Minted): {
|
|
8
|
+
log: string;
|
|
9
|
+
recording: string;
|
|
10
|
+
} | null;
|
|
11
|
+
//# sourceMappingURL=reading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reading.d.ts","sourceRoot":"","sources":["../src/reading.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAElH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,MAAM,CAEvE;AAED,wGAAwG;AACxG,wBAAgB,SAAS,CACvB,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,KAAK,CAAC,EAC7C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,CAAC,EAAE,MAAM,GACd;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQ3C"}
|
package/dist/reading.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Where a call is read: the tenant's relay when it gave one, the gateway with the call's own token otherwise. */
|
|
2
|
+
const GATEWAY = "https://box.pinecall.io";
|
|
3
|
+
/** The gateway the page asks, with no slash at the end. */
|
|
4
|
+
export function gatewayOf(options) {
|
|
5
|
+
return (options.gateway ?? GATEWAY).replace(/\/+$/, "");
|
|
6
|
+
}
|
|
7
|
+
/** The call's log and its recording. None when neither a relay nor a token is there to read it with. */
|
|
8
|
+
export function readingOf(options, call, token, minted) {
|
|
9
|
+
if (options.log !== undefined) {
|
|
10
|
+
return { log: minted === undefined ? options.log(call) : options.log(call, minted), recording: "" };
|
|
11
|
+
}
|
|
12
|
+
if (typeof token !== "string" || token === "")
|
|
13
|
+
return null;
|
|
14
|
+
const at = `${gatewayOf(options)}/v1/calls/${encodeURIComponent(call)}`;
|
|
15
|
+
const ticket = `?token=${encodeURIComponent(token)}`;
|
|
16
|
+
return { log: `${at}/events${ticket}`, recording: `${at}/recording${ticket}` };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=reading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reading.js","sourceRoot":"","sources":["../src/reading.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAKlH,MAAM,OAAO,GAAG,yBAAyB,CAAC;AAE1C,2DAA2D;AAC3D,MAAM,UAAU,SAAS,CAAC,OAAqC;IAC7D,OAAO,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,SAAS,CACvB,OAA6C,EAC7C,IAAY,EACZ,KAAyB,EACzB,MAAe;IAEf,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IACtG,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,EAAE,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;IACxE,MAAM,MAAM,GAAG,UAAU,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;IACrD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,MAAM,EAAE,EAAE,CAAC;AACjF,CAAC"}
|
package/dist/room.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/** One conversation, as the page sees it: the phases, the verbs, and the seat and the log joined in one store. */
|
|
2
|
-
import { type Entry
|
|
2
|
+
import { type Entry } from "./wire/envelope.js";
|
|
3
|
+
import { type State } from "./wire/state.js";
|
|
3
4
|
import { type Connection } from "./log/follow.js";
|
|
4
5
|
import { type Speaking } from "./seat/join.js";
|
|
5
6
|
import { type LivekitModule } from "./seat/livekit.js";
|
|
6
|
-
import type { Minted } from "./server/index.js";
|
|
7
|
+
import type { Code, Minted } from "./server/index.js";
|
|
7
8
|
import { type Store } from "./store.js";
|
|
8
|
-
export type { Minted };
|
|
9
|
-
/** Where the conversation is. `ringing
|
|
10
|
-
export type Phase = "idle" | "opening" | "ringing" | "live" | "ended" | "failed";
|
|
9
|
+
export type { Code, Minted };
|
|
10
|
+
/** Where the conversation is. `ringing`: a phone call nobody answered yet; `expecting`: a code no call claimed yet. */
|
|
11
|
+
export type Phase = "idle" | "opening" | "expecting" | "ringing" | "live" | "ended" | "failed";
|
|
11
12
|
/** Spoken, written, or on the visitor's own phone. The same agent every way. */
|
|
12
13
|
export type Mode = "talk" | "chat" | "phone";
|
|
13
14
|
/** Everything the page draws from. Every field is the truth at the moment it was published. */
|
|
@@ -26,6 +27,12 @@ export interface RoomState {
|
|
|
26
27
|
/** True when the browser has not been told it may make a sound: ask for a click. */
|
|
27
28
|
wantsSound: boolean;
|
|
28
29
|
speaking: Speaking;
|
|
30
|
+
/** The code to show beside the number to call, from `expecting` on; `expiresAt` in seconds since the epoch. */
|
|
31
|
+
code: {
|
|
32
|
+
code: string;
|
|
33
|
+
number: string;
|
|
34
|
+
expiresAt: number;
|
|
35
|
+
} | null;
|
|
29
36
|
}
|
|
30
37
|
export interface RoomOptions {
|
|
31
38
|
/** A ticket for a seat, from the tenant's own server. The page never holds a key. */
|
|
@@ -40,6 +47,8 @@ export interface RoomOptions {
|
|
|
40
47
|
call: string;
|
|
41
48
|
log_token?: string | undefined;
|
|
42
49
|
}>) | undefined;
|
|
50
|
+
/** Ask the tenant's server for a code the visitor keys when they call the agent's number. */
|
|
51
|
+
expect?: (() => Promise<Code>) | undefined;
|
|
43
52
|
/** How long the log is read after the seat closes, waiting for the score. Default 60 000 ms: a worker
|
|
44
53
|
* notices a caller has gone some twenty seconds after the fact, and the score comes after that. */
|
|
45
54
|
linger?: number | undefined;
|
|
@@ -52,6 +61,7 @@ export interface RoomStore extends Store<RoomState> {
|
|
|
52
61
|
start(mode: "talk" | "chat"): Promise<void>;
|
|
53
62
|
send(text: string): Promise<void>;
|
|
54
63
|
callMe(to: string): Promise<void>;
|
|
64
|
+
byPhone(): Promise<void>;
|
|
55
65
|
leave(): Promise<void>;
|
|
56
66
|
playSound(): void;
|
|
57
67
|
}
|
package/dist/room.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room.d.ts","sourceRoot":"","sources":["../src/room.ts"],"names":[],"mappings":"AAAA,kHAAkH;
|
|
1
|
+
{"version":3,"file":"room.d.ts","sourceRoot":"","sources":["../src/room.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAUlH,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAI7C,OAAO,EAAa,KAAK,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAE1E,OAA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