@pinecall/dot 0.0.0-stage → 0.11.21
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/LICENSE +202 -0
- package/README.md +316 -2
- package/dist/agent/index.d.ts +4 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +3 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/tutor.d.ts +67 -0
- package/dist/agent/tutor.d.ts.map +1 -0
- package/dist/agent/tutor.js +351 -0
- package/dist/agent/tutor.js.map +1 -0
- package/dist/face/draw.d.ts +43 -0
- package/dist/face/draw.d.ts.map +1 -0
- package/dist/face/draw.js +74 -0
- package/dist/face/draw.js.map +1 -0
- package/dist/face/ear.d.ts +23 -0
- package/dist/face/ear.d.ts.map +1 -0
- package/dist/face/ear.js +111 -0
- package/dist/face/ear.js.map +1 -0
- package/dist/face/index.d.ts +23 -0
- package/dist/face/index.d.ts.map +1 -0
- package/dist/face/index.js +138 -0
- package/dist/face/index.js.map +1 -0
- package/dist/face/motion.d.ts +25 -0
- package/dist/face/motion.d.ts.map +1 -0
- package/dist/face/motion.js +58 -0
- package/dist/face/motion.js.map +1 -0
- package/dist/face/mouth.d.ts +45 -0
- package/dist/face/mouth.d.ts.map +1 -0
- package/dist/face/mouth.js +61 -0
- package/dist/face/mouth.js.map +1 -0
- package/dist/face/shape.d.ts +15 -0
- package/dist/face/shape.d.ts.map +1 -0
- package/dist/face/shape.js +50 -0
- package/dist/face/shape.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/page/page.d.ts +34 -0
- package/dist/page/page.d.ts.map +1 -0
- package/dist/page/page.js +218 -0
- package/dist/page/page.js.map +1 -0
- package/dist/page/roles.d.ts +10 -0
- package/dist/page/roles.d.ts.map +1 -0
- package/dist/page/roles.js +87 -0
- package/dist/page/roles.js.map +1 -0
- package/dist/pointer/card.d.ts +13 -0
- package/dist/pointer/card.d.ts.map +1 -0
- package/dist/pointer/card.js +75 -0
- package/dist/pointer/card.js.map +1 -0
- package/dist/pointer/code.d.ts +21 -0
- package/dist/pointer/code.d.ts.map +1 -0
- package/dist/pointer/code.js +147 -0
- package/dist/pointer/code.js.map +1 -0
- package/dist/pointer/flight.d.ts +21 -0
- package/dist/pointer/flight.d.ts.map +1 -0
- package/dist/pointer/flight.js +80 -0
- package/dist/pointer/flight.js.map +1 -0
- package/dist/pointer/hover.d.ts +20 -0
- package/dist/pointer/hover.d.ts.map +1 -0
- package/dist/pointer/hover.js +96 -0
- package/dist/pointer/hover.js.map +1 -0
- package/dist/pointer/menu.d.ts +48 -0
- package/dist/pointer/menu.d.ts.map +1 -0
- package/dist/pointer/menu.js +252 -0
- package/dist/pointer/menu.js.map +1 -0
- package/dist/pointer/person.d.ts +91 -0
- package/dist/pointer/person.d.ts.map +1 -0
- package/dist/pointer/person.js +345 -0
- package/dist/pointer/person.js.map +1 -0
- package/dist/pointer/sections.d.ts +24 -0
- package/dist/pointer/sections.d.ts.map +1 -0
- package/dist/pointer/sections.js +64 -0
- package/dist/pointer/sections.js.map +1 -0
- package/dist/pointer/syntax.d.ts +10 -0
- package/dist/pointer/syntax.d.ts.map +1 -0
- package/dist/pointer/syntax.js +61 -0
- package/dist/pointer/syntax.js.map +1 -0
- package/dist/pointer/typing.d.ts +6 -0
- package/dist/pointer/typing.d.ts.map +1 -0
- package/dist/pointer/typing.js +62 -0
- package/dist/pointer/typing.js.map +1 -0
- package/dist/tutor/captions.d.ts +22 -0
- package/dist/tutor/captions.d.ts.map +1 -0
- package/dist/tutor/captions.js +62 -0
- package/dist/tutor/captions.js.map +1 -0
- package/dist/tutor/macro.d.ts +19 -0
- package/dist/tutor/macro.d.ts.map +1 -0
- package/dist/tutor/macro.js +67 -0
- package/dist/tutor/macro.js.map +1 -0
- package/dist/tutor/options.d.ts +42 -0
- package/dist/tutor/options.d.ts.map +1 -0
- package/dist/tutor/options.js +3 -0
- package/dist/tutor/options.js.map +1 -0
- package/dist/tutor/tutor.d.ts +14 -0
- package/dist/tutor/tutor.d.ts.map +1 -0
- package/dist/tutor/tutor.js +388 -0
- package/dist/tutor/tutor.js.map +1 -0
- package/dist/tutor/views.d.ts +27 -0
- package/dist/tutor/views.d.ts.map +1 -0
- package/dist/tutor/views.js +63 -0
- package/dist/tutor/views.js.map +1 -0
- package/dist/tutor/walking.d.ts +44 -0
- package/dist/tutor/walking.d.ts.map +1 -0
- package/dist/tutor/walking.js +142 -0
- package/dist/tutor/walking.js.map +1 -0
- package/dist/tutor/walks.d.ts +46 -0
- package/dist/tutor/walks.d.ts.map +1 -0
- package/dist/tutor/walks.js +112 -0
- package/dist/tutor/walks.js.map +1 -0
- package/dist/wire/index.d.ts +133 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +204 -0
- package/dist/wire/index.js.map +1 -0
- package/package.json +53 -3
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/** The tutor on a page: the person with its pointer and face, what it sends of the page, and every move the agent asks for. */
|
|
2
|
+
//
|
|
3
|
+
// Up, as events on the call: the page as it is now (`page.seen`, when it changed, and when a move
|
|
4
|
+
// onto an element ended, with the ref it moved to), what the visitor clicked, a ref that is gone.
|
|
5
|
+
// Down, from `pinecall.ui`: a cursor move, run at once, or a macro's step, whose moves run on their
|
|
6
|
+
// words. Moves run one after another, so a scroll ends before the point that follows it. In words,
|
|
7
|
+
// one side at a time: the visitor's as they say them, else the agent's as its voice says them.
|
|
8
|
+
// With no call, the walks the agent published play from a button beside the face (`walks`).
|
|
9
|
+
import { litAt, sayingOf } from "@pinecall/room";
|
|
10
|
+
import { face } from "../face/index.js";
|
|
11
|
+
import { Page } from "../page/page.js";
|
|
12
|
+
import { aimOf, along, animate, flightMs, scrollOnto } from "../pointer/flight.js";
|
|
13
|
+
import { Card } from "../pointer/card.js";
|
|
14
|
+
import { Hover } from "../pointer/hover.js";
|
|
15
|
+
import { Person, sideOf } from "../pointer/person.js";
|
|
16
|
+
import { fill } from "../pointer/typing.js";
|
|
17
|
+
import { A_REF, CLICKED, EXPLAIN, MISSING, MOVED, SEEN, WALKED, tutoring } from "../wire/index.js";
|
|
18
|
+
import { Hearing, captionsOf, keepVisitorChoice, shows, visitorWantsCaptions } from "./captions.js";
|
|
19
|
+
import { Player } from "./macro.js";
|
|
20
|
+
import { Screen } from "./views.js";
|
|
21
|
+
import { Walks } from "./walks.js";
|
|
22
|
+
/** What makes the page worth looking at again, and how long to wait for it to settle, in ms. */
|
|
23
|
+
const SETTLE = { scroll: 250, resize: 250, dom: 400, toggle: 150 };
|
|
24
|
+
/** Put the tutor on the page, moving with `call`. Nothing is sent until the call is live. */
|
|
25
|
+
export function tutor(call, options = {}) {
|
|
26
|
+
const document = globalThis.document;
|
|
27
|
+
const view = document.defaultView ?? globalThis.window;
|
|
28
|
+
const still = view.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
29
|
+
const page = new Page(document);
|
|
30
|
+
const hover = new Hover(document);
|
|
31
|
+
const captions = captionsOf(options.captions);
|
|
32
|
+
const storage = () => view.localStorage;
|
|
33
|
+
let captioned = visitorWantsCaptions(storage);
|
|
34
|
+
const person = new Person(document, {
|
|
35
|
+
dock: options.dock ?? "right",
|
|
36
|
+
label: options.label ?? "Talk to the assistant",
|
|
37
|
+
color: options.color,
|
|
38
|
+
onClick: () => (walks.playing ? walks.stop() : options.onClick?.()),
|
|
39
|
+
hangUp: { label: options.words?.hangUp ?? "Hang up", onClick: () => void call.leave() },
|
|
40
|
+
stop: { label: options.words?.stop ?? "Stop", onClick: () => walks.stop() },
|
|
41
|
+
pause: { label: options.words?.pause ?? "Pause", onClick: () => walks.pause() },
|
|
42
|
+
captions: captions === "none"
|
|
43
|
+
? null
|
|
44
|
+
: {
|
|
45
|
+
label: options.words?.captions ?? "Captions",
|
|
46
|
+
onClick: () => {
|
|
47
|
+
captioned = !captioned;
|
|
48
|
+
keepVisitorChoice(storage, captioned);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
explain: { label: options.words?.explain ?? "Explain this", onClick: (element) => send(EXPLAIN, { at: page.refOf(element) }) },
|
|
52
|
+
});
|
|
53
|
+
const drawn = face(person.face, call, { shape: options.shape });
|
|
54
|
+
const inCall = () => call.state.phase === "opening" || call.state.phase === "live";
|
|
55
|
+
const walks = new Walks(document, person, drawn, {
|
|
56
|
+
dock: options.dock ?? "right",
|
|
57
|
+
label: options.words?.walks ?? "Walks",
|
|
58
|
+
more: options.words?.more ?? "More walks",
|
|
59
|
+
url: options.walks,
|
|
60
|
+
inCall,
|
|
61
|
+
home: () => queue(() => run("home", null)),
|
|
62
|
+
point: (element) => queue(() => run("point", element)),
|
|
63
|
+
onWalk: options.onWalk,
|
|
64
|
+
still,
|
|
65
|
+
});
|
|
66
|
+
const screen = new Screen(call, new Card(document, (part) => person.add(part), options.words?.close ?? "Close"), () => options.views);
|
|
67
|
+
const player = new Player();
|
|
68
|
+
const linger = options.linger ?? 2600;
|
|
69
|
+
const hearing = new Hearing(linger);
|
|
70
|
+
let anchor = null;
|
|
71
|
+
let lit = null;
|
|
72
|
+
let flying = false;
|
|
73
|
+
let moves = Promise.resolve();
|
|
74
|
+
let sent = "";
|
|
75
|
+
let following = null;
|
|
76
|
+
/** The element with a line under the visitor's mouse, its ▶ shown, while a call is on. */
|
|
77
|
+
let offered = null;
|
|
78
|
+
let leaving;
|
|
79
|
+
let speech = null;
|
|
80
|
+
let last = { text: "", at: 0 };
|
|
81
|
+
let frame = 0;
|
|
82
|
+
let closed = false;
|
|
83
|
+
const live = () => call.state.phase === "live";
|
|
84
|
+
const send = (name, data) => {
|
|
85
|
+
if (live())
|
|
86
|
+
void call.event(name, data).catch(() => undefined);
|
|
87
|
+
};
|
|
88
|
+
/** Look at the page again: the refs are fresh, and the agent hears of it when it changed. */
|
|
89
|
+
const look = (why) => {
|
|
90
|
+
const seen = page.seen();
|
|
91
|
+
if (!live() || seen.text === sent)
|
|
92
|
+
return;
|
|
93
|
+
sent = seen.text;
|
|
94
|
+
send(SEEN, { text: seen.text, why, lines: page.lines() });
|
|
95
|
+
person.face.dataset["pcSeen"] = String(Number(person.face.dataset["pcSeen"] ?? "0") + 1);
|
|
96
|
+
};
|
|
97
|
+
const timers = new Map();
|
|
98
|
+
const soon = (why) => {
|
|
99
|
+
clearTimeout(timers.get(why));
|
|
100
|
+
timers.set(why, setTimeout(() => look(why), SETTLE[why]));
|
|
101
|
+
};
|
|
102
|
+
// The side the face stands on is the destination's, chosen before the flight: chosen on the way, it
|
|
103
|
+
// covered the thing and then jumped clear of it on landing.
|
|
104
|
+
const fly = async (to, side) => {
|
|
105
|
+
const from = person.at;
|
|
106
|
+
flying = true;
|
|
107
|
+
await animate(still ? 0 : flightMs(Math.hypot(to.x - from.x, to.y - from.y), view.innerWidth), (u) => {
|
|
108
|
+
person.place(along(from, to, u), null, side);
|
|
109
|
+
if (person.touring)
|
|
110
|
+
person.kind(hover.at(person.at.x, person.at.y));
|
|
111
|
+
});
|
|
112
|
+
flying = false;
|
|
113
|
+
};
|
|
114
|
+
/** What the face must not cover while the pointer is on `element`: on a window of code, the lines lit. */
|
|
115
|
+
const clearOf = (element) => (element.closest(".pc-code") === null ? null : walks.code.litBox());
|
|
116
|
+
const onScreen = (element) => {
|
|
117
|
+
const box = element.getBoundingClientRect();
|
|
118
|
+
return box.bottom > 0 && box.top < view.innerHeight;
|
|
119
|
+
};
|
|
120
|
+
const run = async (action, element) => {
|
|
121
|
+
switch (action) {
|
|
122
|
+
case "type":
|
|
123
|
+
// Typing takes the visitor's words: typeInto, from a cursor move; a macro's beat never types.
|
|
124
|
+
return;
|
|
125
|
+
case "point": {
|
|
126
|
+
if (element === null)
|
|
127
|
+
return;
|
|
128
|
+
person.tour(true);
|
|
129
|
+
if (!onScreen(element))
|
|
130
|
+
await scrollOnto(element, 0.42, still);
|
|
131
|
+
const aim = aimOf(element);
|
|
132
|
+
anchor = null;
|
|
133
|
+
await fly(aim, sideOf(aim, clearOf(element), view.innerWidth, view.innerHeight));
|
|
134
|
+
const box = element.getBoundingClientRect();
|
|
135
|
+
anchor = { element, dx: aim.x - box.left, dy: aim.y - box.top };
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
case "scroll_to":
|
|
139
|
+
if (element === null)
|
|
140
|
+
return;
|
|
141
|
+
anchor = null;
|
|
142
|
+
await scrollOnto(element, 0.3, still);
|
|
143
|
+
return;
|
|
144
|
+
case "highlight":
|
|
145
|
+
lit = element;
|
|
146
|
+
return;
|
|
147
|
+
case "unhighlight":
|
|
148
|
+
lit = null;
|
|
149
|
+
person.spot(null);
|
|
150
|
+
return;
|
|
151
|
+
case "here":
|
|
152
|
+
person.ring();
|
|
153
|
+
return;
|
|
154
|
+
case "home":
|
|
155
|
+
anchor = null;
|
|
156
|
+
lit = null;
|
|
157
|
+
person.spot(null);
|
|
158
|
+
await fly(person.dock());
|
|
159
|
+
person.tour(false);
|
|
160
|
+
person.kind("arrow");
|
|
161
|
+
hover.clear();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
/** The pointer onto a field, then the visitor's words typed into it; why it could not, or null. */
|
|
166
|
+
const typeInto = async (element, text) => {
|
|
167
|
+
if (element === null)
|
|
168
|
+
return null;
|
|
169
|
+
await run("point", element);
|
|
170
|
+
return fill(element, text, still);
|
|
171
|
+
};
|
|
172
|
+
const needsElement = (action) => action === "point" || action === "scroll_to" || action === "highlight" || action === "type";
|
|
173
|
+
/** The ref a target names, a ref or a name, looked at fresh; one not on the page is said, and a fresh look follows. */
|
|
174
|
+
const resolve = (target) => {
|
|
175
|
+
look("step");
|
|
176
|
+
const ref = A_REF.test(target) ? target : page.named(target);
|
|
177
|
+
if (ref === null || page.element(ref) === null) {
|
|
178
|
+
send(MISSING, { target });
|
|
179
|
+
sent = "";
|
|
180
|
+
look("missing");
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
return ref;
|
|
184
|
+
};
|
|
185
|
+
const elementOf = (ref) => (ref === null ? null : page.element(ref));
|
|
186
|
+
/** A move onto an element, answered once it ends: the page as it is now, the ref it moved to, and why a field was not filled. */
|
|
187
|
+
const moveOnto = async (action, target, text) => {
|
|
188
|
+
const ref = resolve(target);
|
|
189
|
+
const element = elementOf(ref);
|
|
190
|
+
let refused = null;
|
|
191
|
+
if (action === "type")
|
|
192
|
+
refused = await typeInto(element, text);
|
|
193
|
+
else
|
|
194
|
+
await run(action, element);
|
|
195
|
+
const seen = page.seen();
|
|
196
|
+
sent = seen.text;
|
|
197
|
+
send(SEEN, { text: seen.text, why: MOVED, lines: page.lines(), ...(ref === null ? {} : { at: ref }), ...(refused === null ? {} : { refused }) });
|
|
198
|
+
};
|
|
199
|
+
const queue = (move) => {
|
|
200
|
+
moves = moves.then(move).catch(() => undefined);
|
|
201
|
+
};
|
|
202
|
+
const beat = (one) => {
|
|
203
|
+
if (one.find === undefined)
|
|
204
|
+
return run(one.do, null);
|
|
205
|
+
look("step");
|
|
206
|
+
const ref = page.find(...one.find);
|
|
207
|
+
return run(one.do, ref === null ? null : elementOf(resolve(ref)));
|
|
208
|
+
};
|
|
209
|
+
const tick = (now) => {
|
|
210
|
+
if (closed)
|
|
211
|
+
return;
|
|
212
|
+
const walk = walks.frame();
|
|
213
|
+
if (walk !== null) {
|
|
214
|
+
person.say(shows(captions, captioned, "agent", walks.code.open || screen.shown) ? walk.lit : null, walk.coming);
|
|
215
|
+
person.heard(null);
|
|
216
|
+
person.progress(walk.fraction);
|
|
217
|
+
for (const one of walk.beats)
|
|
218
|
+
queue(() => beat(one));
|
|
219
|
+
}
|
|
220
|
+
else
|
|
221
|
+
spoken(now);
|
|
222
|
+
person.buttons(inCall(), walks.playing, captioned, walks.paused);
|
|
223
|
+
walks.place();
|
|
224
|
+
// Resting it keeps to its corner; pointing it keeps to its element, which the visitor may scroll.
|
|
225
|
+
if (!flying && !person.touring)
|
|
226
|
+
person.place(person.dock());
|
|
227
|
+
// An element gone, or hidden (a closed window of code), is let go of where the pointer stands.
|
|
228
|
+
if (anchor !== null && (!anchor.element.isConnected || anchor.element.closest("[hidden]") !== null))
|
|
229
|
+
anchor = null;
|
|
230
|
+
if (!flying && anchor !== null) {
|
|
231
|
+
const box = anchor.element.getBoundingClientRect();
|
|
232
|
+
person.place({ x: box.left + anchor.dx, y: box.top + anchor.dy }, clearOf(anchor.element));
|
|
233
|
+
person.kind(hover.on(anchor.element));
|
|
234
|
+
}
|
|
235
|
+
if (lit !== null && !lit.isConnected)
|
|
236
|
+
lit = null;
|
|
237
|
+
person.spot(lit);
|
|
238
|
+
person.offer(live() && offered?.isConnected === true ? offered : null);
|
|
239
|
+
frame = requestAnimationFrame(tick);
|
|
240
|
+
};
|
|
241
|
+
/** A call's words: the agent's as its voice says them, the visitor's as they say theirs, and the call's macro beats. */
|
|
242
|
+
const spoken = (now) => {
|
|
243
|
+
const saying = sayingOf(call.state.entries);
|
|
244
|
+
if (saying !== null && speech?.id !== saying.speech)
|
|
245
|
+
speech = { id: saying.speech, at: now };
|
|
246
|
+
let said = "";
|
|
247
|
+
let words = null;
|
|
248
|
+
if (saying !== null && saying.words.length > 0 && speech !== null) {
|
|
249
|
+
const split = litAt(saying, now - speech.at);
|
|
250
|
+
said = split.lit;
|
|
251
|
+
last = { text: split.lit + split.coming, at: now };
|
|
252
|
+
words = [split.lit, split.coming];
|
|
253
|
+
}
|
|
254
|
+
const heard = hearing.at(call.state.log, now);
|
|
255
|
+
if (words === null && heard !== null)
|
|
256
|
+
last = { text: "", at: 0 };
|
|
257
|
+
else if (words === null && last.text !== "" && now - last.at < linger)
|
|
258
|
+
words = [last.text, ""];
|
|
259
|
+
const agent = shows(captions, captioned, "agent", walks.code.open || screen.shown) ? words : null;
|
|
260
|
+
person.say(agent?.[0] ?? null, agent?.[1] ?? "");
|
|
261
|
+
person.heard(words === null && shows(captions, captioned, "caller", walks.code.open || screen.shown) ? heard : null);
|
|
262
|
+
for (const one of player.due(saying?.speech ?? null, said))
|
|
263
|
+
queue(() => beat(one));
|
|
264
|
+
};
|
|
265
|
+
// A page that joins a call tells the agent what it sees, for an agent already in the room (a
|
|
266
|
+
// reload); an agent that arrives after it asks (`look`), since LiveKit keeps no data for whoever
|
|
267
|
+
// joins after it was sent. A call that ends sends the tutor home.
|
|
268
|
+
const unsubscribe = call.subscribe((state) => {
|
|
269
|
+
screen.update(state);
|
|
270
|
+
// A call takes over from a walk; the walks come back when it ends.
|
|
271
|
+
if (inCall())
|
|
272
|
+
walks.stop();
|
|
273
|
+
walks.available(!inCall());
|
|
274
|
+
if (state.phase === "live" && state.call !== following) {
|
|
275
|
+
following = state.call;
|
|
276
|
+
sent = "";
|
|
277
|
+
look("joined");
|
|
278
|
+
const played = walks.taken();
|
|
279
|
+
if (played !== null)
|
|
280
|
+
send(WALKED, { ...played });
|
|
281
|
+
}
|
|
282
|
+
if (state.phase !== "live" && state.phase !== "opening" && (person.touring || player.armed)) {
|
|
283
|
+
player.drop();
|
|
284
|
+
queue(() => run("home", null));
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
const onScroll = () => soon("scroll");
|
|
288
|
+
const onResize = () => soon("resize");
|
|
289
|
+
const onToggle = () => soon("toggle");
|
|
290
|
+
// What the visitor types reaches the agent as the page's next look, as their scroll does.
|
|
291
|
+
const onInput = (event) => {
|
|
292
|
+
if (event.target instanceof Element && event.target.closest("[data-pinecall-skip]") === null)
|
|
293
|
+
soon("dom");
|
|
294
|
+
};
|
|
295
|
+
// Over the ▶ itself (the tutor's own layer) it stays; off an element with a line it goes a moment later.
|
|
296
|
+
const onOver = (event) => {
|
|
297
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
298
|
+
clearTimeout(leaving);
|
|
299
|
+
if (target?.closest("[data-pinecall-skip]") != null)
|
|
300
|
+
return;
|
|
301
|
+
const marked = target?.closest("[data-pinecall-say]") ?? null;
|
|
302
|
+
if (marked !== null)
|
|
303
|
+
offered = marked;
|
|
304
|
+
else
|
|
305
|
+
leaving = setTimeout(() => (offered = null), 400);
|
|
306
|
+
};
|
|
307
|
+
const onClick = (event) => {
|
|
308
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
309
|
+
if (target === null || target.closest("[data-pinecall-skip]") !== null)
|
|
310
|
+
return;
|
|
311
|
+
const clicked = target.closest("a, button, summary, input, select, textarea, [role=button], [role=link]");
|
|
312
|
+
if (clicked === null)
|
|
313
|
+
return;
|
|
314
|
+
look("click");
|
|
315
|
+
send(CLICKED, { role: clicked.getAttribute("role") ?? clicked.tagName.toLowerCase(), name: (clicked.textContent ?? "").replace(/\s+/g, " ").trim().slice(0, 80) });
|
|
316
|
+
};
|
|
317
|
+
const changes = new MutationObserver((records) => {
|
|
318
|
+
const ours = (node) => (node instanceof Element ? node : node.parentElement)?.closest("[data-pinecall-skip]") != null;
|
|
319
|
+
if (records.every((record) => ours(record.target)))
|
|
320
|
+
return;
|
|
321
|
+
soon("dom");
|
|
322
|
+
});
|
|
323
|
+
view.addEventListener("scroll", onScroll, { passive: true });
|
|
324
|
+
view.addEventListener("resize", onResize);
|
|
325
|
+
document.addEventListener("toggle", onToggle, true);
|
|
326
|
+
document.addEventListener("click", onClick, true);
|
|
327
|
+
document.addEventListener("input", onInput, true);
|
|
328
|
+
document.addEventListener("pointerover", onOver, true);
|
|
329
|
+
changes.observe(document.body, { subtree: true, childList: true, characterData: true, attributes: true, attributeFilter: ["open", "hidden", "aria-expanded", "aria-selected", "class"] });
|
|
330
|
+
frame = requestAnimationFrame(tick);
|
|
331
|
+
return {
|
|
332
|
+
take(data) {
|
|
333
|
+
const message = tutoring(data);
|
|
334
|
+
if (message === null)
|
|
335
|
+
return false;
|
|
336
|
+
if (message.type === "macro.step") {
|
|
337
|
+
player.arm(message, sayingOf(call.state.entries)?.speech ?? null);
|
|
338
|
+
const lit = walks.code.show(message.code, message.lines);
|
|
339
|
+
if (lit !== null)
|
|
340
|
+
queue(() => run("point", lit));
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
if (message.type === "macro.done") {
|
|
344
|
+
walks.code.hide();
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
if (message.type === "look") {
|
|
348
|
+
sent = "";
|
|
349
|
+
look("asked");
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
const { action, target, text } = message;
|
|
353
|
+
queue(async () => {
|
|
354
|
+
if (needsElement(action) && target !== undefined)
|
|
355
|
+
await moveOnto(action, target, text ?? "");
|
|
356
|
+
else
|
|
357
|
+
await run(action, null);
|
|
358
|
+
});
|
|
359
|
+
return true;
|
|
360
|
+
},
|
|
361
|
+
wake() {
|
|
362
|
+
drawn.wake();
|
|
363
|
+
},
|
|
364
|
+
close() {
|
|
365
|
+
if (closed)
|
|
366
|
+
return;
|
|
367
|
+
closed = true;
|
|
368
|
+
cancelAnimationFrame(frame);
|
|
369
|
+
for (const timer of timers.values())
|
|
370
|
+
clearTimeout(timer);
|
|
371
|
+
walks.close();
|
|
372
|
+
screen.close();
|
|
373
|
+
clearTimeout(leaving);
|
|
374
|
+
unsubscribe();
|
|
375
|
+
changes.disconnect();
|
|
376
|
+
view.removeEventListener("scroll", onScroll);
|
|
377
|
+
view.removeEventListener("resize", onResize);
|
|
378
|
+
document.removeEventListener("toggle", onToggle, true);
|
|
379
|
+
document.removeEventListener("click", onClick, true);
|
|
380
|
+
document.removeEventListener("input", onInput, true);
|
|
381
|
+
document.removeEventListener("pointerover", onOver, true);
|
|
382
|
+
drawn.close();
|
|
383
|
+
hover.close();
|
|
384
|
+
person.close();
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
//# sourceMappingURL=tutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tutor.js","sourceRoot":"","sources":["../../src/tutor/tutor.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAC/H,EAAE;AACF,kGAAkG;AAClG,kGAAkG;AAClG,oGAAoG;AACpG,mGAAmG;AACnG,+FAA+F;AAC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YACd,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,WAAW,EAAE,CAAC;YACd,OAAO,CAAC,UAAU,EAAE,CAAC;YACrB,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC7C,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC7C,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;YACvD,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YACrD,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YACrD,QAAQ,CAAC,mBAAmB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;YAC1D,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** What the page draws for the agent's own tools: a card beside the face each time one of them finishes. */
|
|
2
|
+
import type { RoomState, RoomStore } from "@pinecall/room";
|
|
3
|
+
import { Card } from "../pointer/card.js";
|
|
4
|
+
/** What a view may do. */
|
|
5
|
+
export interface ViewTools {
|
|
6
|
+
/** Say something to the agent in writing, as the visitor: a time picked, a name and an email typed. */
|
|
7
|
+
send(text: string): void;
|
|
8
|
+
/** Put the card away. */
|
|
9
|
+
hide(): void;
|
|
10
|
+
/** The call as it is now, for a view that marks what the agent chose. */
|
|
11
|
+
state(): RoomState;
|
|
12
|
+
}
|
|
13
|
+
/** Draw a tool's result into `host`; answer how to take it down, if there is anything to. */
|
|
14
|
+
export type ViewRenderer = (host: HTMLElement, result: unknown, tools: ViewTools) => void | (() => void);
|
|
15
|
+
/** The page's views, by the name of the agent's tool. */
|
|
16
|
+
export type Views = Record<string, ViewRenderer | undefined>;
|
|
17
|
+
export declare class Screen {
|
|
18
|
+
#private;
|
|
19
|
+
/** `views` is read each time a tool finishes; `card` is where they are drawn. */
|
|
20
|
+
constructor(call: RoomStore, card: Card, views: () => Views | undefined);
|
|
21
|
+
/** Follow the call: draw the last finished tool a view names, hide the card when the call is over. */
|
|
22
|
+
update(state: RoomState): void;
|
|
23
|
+
/** Whether the card is on the screen. */
|
|
24
|
+
get shown(): boolean;
|
|
25
|
+
close(): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=views.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../../src/tutor/views.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAQ5G,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,0BAA0B;AAC1B,MAAM,WAAW,SAAS;IACxB,uGAAuG;IACvG,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,yBAAyB;IACzB,IAAI,IAAI,IAAI,CAAC;IACb,yEAAyE;IACzE,KAAK,IAAI,SAAS,CAAC;CACpB;AAED,6FAA6F;AAC7F,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAEzG,yDAAyD;AACzD,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC,CAAC;AAE7D,qBAAa,MAAM;;IAOjB,iFAAiF;IACjF,YAAY,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,SAAS,EAItE;IAED,sGAAsG;IACtG,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CA6B7B;IAED,yCAAyC;IACzC,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,KAAK,IAAI,IAAI,CAEZ;CACF"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** What the page draws for the agent's own tools: a card beside the face each time one of them finishes. */
|
|
2
|
+
//
|
|
3
|
+
// A project's agent has tools of its own: free times, a booking, a piece of code. Their results are
|
|
4
|
+
// already on the call's log; the page says, by tool name, how to draw one, and the tutor puts it on a
|
|
5
|
+
// card when the tool finishes. A page that joins a call under way shows none of what ran before. The
|
|
6
|
+
// visitor answers on the card in words the agent hears (`send`), never by a click the agent did not
|
|
7
|
+
// ask for: the card is a way to say it, not a door round the agent.
|
|
8
|
+
import { Card } from "../pointer/card.js";
|
|
9
|
+
export class Screen {
|
|
10
|
+
#call;
|
|
11
|
+
#card;
|
|
12
|
+
#views;
|
|
13
|
+
#on = null;
|
|
14
|
+
#seen = new Set();
|
|
15
|
+
/** `views` is read each time a tool finishes; `card` is where they are drawn. */
|
|
16
|
+
constructor(call, card, views) {
|
|
17
|
+
this.#call = call;
|
|
18
|
+
this.#card = card;
|
|
19
|
+
this.#views = views;
|
|
20
|
+
}
|
|
21
|
+
/** Follow the call: draw the last finished tool a view names, hide the card when the call is over. */
|
|
22
|
+
update(state) {
|
|
23
|
+
if (state.phase !== "live") {
|
|
24
|
+
this.#on = null;
|
|
25
|
+
this.#card.hide();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const finished = state.log.tools.filter((run) => run.status === "done");
|
|
29
|
+
if (state.call !== this.#on) {
|
|
30
|
+
this.#on = state.call;
|
|
31
|
+
this.#seen = new Set(finished.map((run) => run.call_id));
|
|
32
|
+
this.#card.hide();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const views = this.#views();
|
|
36
|
+
let latest = null;
|
|
37
|
+
for (const run of finished) {
|
|
38
|
+
if (this.#seen.has(run.call_id))
|
|
39
|
+
continue;
|
|
40
|
+
this.#seen.add(run.call_id);
|
|
41
|
+
const render = views?.[run.name];
|
|
42
|
+
if (render !== undefined)
|
|
43
|
+
latest = { render, result: run.output };
|
|
44
|
+
}
|
|
45
|
+
if (latest === null)
|
|
46
|
+
return;
|
|
47
|
+
const { render, result } = latest;
|
|
48
|
+
const tools = {
|
|
49
|
+
send: (text) => void this.#call.send(text).catch(() => undefined),
|
|
50
|
+
hide: () => this.#card.hide(),
|
|
51
|
+
state: () => this.#call.state,
|
|
52
|
+
};
|
|
53
|
+
this.#card.show((body) => render(body, result, tools));
|
|
54
|
+
}
|
|
55
|
+
/** Whether the card is on the screen. */
|
|
56
|
+
get shown() {
|
|
57
|
+
return this.#card.shown;
|
|
58
|
+
}
|
|
59
|
+
close() {
|
|
60
|
+
this.#card.close();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=views.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views.js","sourceRoot":"","sources":["../../src/tutor/views.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,EAAE;AACF,oGAAoG;AACpG,sGAAsG;AACtG,qGAAqG;AACrG,oGAAoG;AACpG,oEAAoE;AAIpE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAkB1C,MAAM,OAAO,MAAM;IACR,KAAK,CAAY;IACjB,KAAK,CAAO;IACZ,MAAM,CAA0B;IACzC,GAAG,GAAkB,IAAI,CAAC;IAC1B,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAE1B,iFAAiF;IACjF,YAAY,IAAe,EAAE,IAAU,EAAE,KAA8B;QACrE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,sGAAsG;IACtG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,MAAM,EAAE,GAAG,MAAM,CAAC;QAClC,MAAM,KAAK,GAAc;YACvB,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;YACjE,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YAC7B,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK;SAC9B,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,yCAAyC;IACzC,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** A recorded walk played on the page with no call: its sentences in the agent's voice, their words lit as said, the beats on their words. */
|
|
2
|
+
import { type Beat, type RecordedStep, type RecordedWalk } from "../wire/index.js";
|
|
3
|
+
/** How far the visitor got: the walk, the sentence reached (from 1), how many it has, and whether it ended. */
|
|
4
|
+
export interface Walked {
|
|
5
|
+
walk: string;
|
|
6
|
+
step: number;
|
|
7
|
+
of: number;
|
|
8
|
+
done: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** One frame of a walk: the sentence's words said and to come, the beats due, how far the whole walk is. */
|
|
11
|
+
export interface WalkFrame {
|
|
12
|
+
lit: string;
|
|
13
|
+
coming: string;
|
|
14
|
+
beats: Beat[];
|
|
15
|
+
fraction: number;
|
|
16
|
+
}
|
|
17
|
+
/** The walks an agent published, read with no key; none where the page cannot read them. */
|
|
18
|
+
export declare function publishedWalks(url: string): Promise<RecordedWalk[]>;
|
|
19
|
+
/** A walk's length, in ms. */
|
|
20
|
+
export declare function lengthOf(walk: RecordedWalk): number;
|
|
21
|
+
export declare class Walking {
|
|
22
|
+
#private;
|
|
23
|
+
readonly audio: HTMLAudioElement;
|
|
24
|
+
/**
|
|
25
|
+
* Play through `audio`; `ended` hears a walk that played to its end, or failed to play; `shows`
|
|
26
|
+
* hears each sentence as it starts, for what it shows beside the page, and null as the walk stops.
|
|
27
|
+
*/
|
|
28
|
+
constructor(audio: HTMLAudioElement, ended: (walked: Walked) => void, shows?: (step: RecordedStep | null) => void);
|
|
29
|
+
/** The walk playing, or null. */
|
|
30
|
+
get playing(): RecordedWalk | null;
|
|
31
|
+
/** Whether the walk playing is paused. */
|
|
32
|
+
get paused(): boolean;
|
|
33
|
+
/** Hold the walk where it is: the voice, and the words and beats that follow it. */
|
|
34
|
+
pause(): void;
|
|
35
|
+
/** Go on from where it was held. Call it from the visitor's click, as `start`. */
|
|
36
|
+
resume(): void;
|
|
37
|
+
/** Play a walk from its first sentence. Call it from the visitor's click: a browser starts audio only inside one. */
|
|
38
|
+
start(walk: RecordedWalk): void;
|
|
39
|
+
/** Where the walk is now; null while none plays. */
|
|
40
|
+
frame(): WalkFrame | null;
|
|
41
|
+
/** Stop where it is: how far the visitor got, or null when nothing played. */
|
|
42
|
+
stop(): Walked | null;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=walking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walking.d.ts","sourceRoot":"","sources":["../../src/tutor/walking.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAM9I,OAAO,EAAW,KAAK,IAAI,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAa,MAAM,kBAAkB,CAAC;AAGvG,+GAA+G;AAC/G,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,M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