@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.
Files changed (115) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +316 -2
  3. package/dist/agent/index.d.ts +4 -0
  4. package/dist/agent/index.d.ts.map +1 -0
  5. package/dist/agent/index.js +3 -0
  6. package/dist/agent/index.js.map +1 -0
  7. package/dist/agent/tutor.d.ts +67 -0
  8. package/dist/agent/tutor.d.ts.map +1 -0
  9. package/dist/agent/tutor.js +351 -0
  10. package/dist/agent/tutor.js.map +1 -0
  11. package/dist/face/draw.d.ts +43 -0
  12. package/dist/face/draw.d.ts.map +1 -0
  13. package/dist/face/draw.js +74 -0
  14. package/dist/face/draw.js.map +1 -0
  15. package/dist/face/ear.d.ts +23 -0
  16. package/dist/face/ear.d.ts.map +1 -0
  17. package/dist/face/ear.js +111 -0
  18. package/dist/face/ear.js.map +1 -0
  19. package/dist/face/index.d.ts +23 -0
  20. package/dist/face/index.d.ts.map +1 -0
  21. package/dist/face/index.js +138 -0
  22. package/dist/face/index.js.map +1 -0
  23. package/dist/face/motion.d.ts +25 -0
  24. package/dist/face/motion.d.ts.map +1 -0
  25. package/dist/face/motion.js +58 -0
  26. package/dist/face/motion.js.map +1 -0
  27. package/dist/face/mouth.d.ts +45 -0
  28. package/dist/face/mouth.d.ts.map +1 -0
  29. package/dist/face/mouth.js +61 -0
  30. package/dist/face/mouth.js.map +1 -0
  31. package/dist/face/shape.d.ts +15 -0
  32. package/dist/face/shape.d.ts.map +1 -0
  33. package/dist/face/shape.js +50 -0
  34. package/dist/face/shape.js.map +1 -0
  35. package/dist/index.d.ts +8 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +5 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/page/page.d.ts +34 -0
  40. package/dist/page/page.d.ts.map +1 -0
  41. package/dist/page/page.js +218 -0
  42. package/dist/page/page.js.map +1 -0
  43. package/dist/page/roles.d.ts +10 -0
  44. package/dist/page/roles.d.ts.map +1 -0
  45. package/dist/page/roles.js +87 -0
  46. package/dist/page/roles.js.map +1 -0
  47. package/dist/pointer/card.d.ts +13 -0
  48. package/dist/pointer/card.d.ts.map +1 -0
  49. package/dist/pointer/card.js +75 -0
  50. package/dist/pointer/card.js.map +1 -0
  51. package/dist/pointer/code.d.ts +21 -0
  52. package/dist/pointer/code.d.ts.map +1 -0
  53. package/dist/pointer/code.js +147 -0
  54. package/dist/pointer/code.js.map +1 -0
  55. package/dist/pointer/flight.d.ts +21 -0
  56. package/dist/pointer/flight.d.ts.map +1 -0
  57. package/dist/pointer/flight.js +80 -0
  58. package/dist/pointer/flight.js.map +1 -0
  59. package/dist/pointer/hover.d.ts +20 -0
  60. package/dist/pointer/hover.d.ts.map +1 -0
  61. package/dist/pointer/hover.js +96 -0
  62. package/dist/pointer/hover.js.map +1 -0
  63. package/dist/pointer/menu.d.ts +48 -0
  64. package/dist/pointer/menu.d.ts.map +1 -0
  65. package/dist/pointer/menu.js +252 -0
  66. package/dist/pointer/menu.js.map +1 -0
  67. package/dist/pointer/person.d.ts +91 -0
  68. package/dist/pointer/person.d.ts.map +1 -0
  69. package/dist/pointer/person.js +345 -0
  70. package/dist/pointer/person.js.map +1 -0
  71. package/dist/pointer/sections.d.ts +24 -0
  72. package/dist/pointer/sections.d.ts.map +1 -0
  73. package/dist/pointer/sections.js +64 -0
  74. package/dist/pointer/sections.js.map +1 -0
  75. package/dist/pointer/syntax.d.ts +10 -0
  76. package/dist/pointer/syntax.d.ts.map +1 -0
  77. package/dist/pointer/syntax.js +61 -0
  78. package/dist/pointer/syntax.js.map +1 -0
  79. package/dist/pointer/typing.d.ts +6 -0
  80. package/dist/pointer/typing.d.ts.map +1 -0
  81. package/dist/pointer/typing.js +62 -0
  82. package/dist/pointer/typing.js.map +1 -0
  83. package/dist/tutor/captions.d.ts +22 -0
  84. package/dist/tutor/captions.d.ts.map +1 -0
  85. package/dist/tutor/captions.js +62 -0
  86. package/dist/tutor/captions.js.map +1 -0
  87. package/dist/tutor/macro.d.ts +19 -0
  88. package/dist/tutor/macro.d.ts.map +1 -0
  89. package/dist/tutor/macro.js +67 -0
  90. package/dist/tutor/macro.js.map +1 -0
  91. package/dist/tutor/options.d.ts +42 -0
  92. package/dist/tutor/options.d.ts.map +1 -0
  93. package/dist/tutor/options.js +3 -0
  94. package/dist/tutor/options.js.map +1 -0
  95. package/dist/tutor/tutor.d.ts +14 -0
  96. package/dist/tutor/tutor.d.ts.map +1 -0
  97. package/dist/tutor/tutor.js +388 -0
  98. package/dist/tutor/tutor.js.map +1 -0
  99. package/dist/tutor/views.d.ts +27 -0
  100. package/dist/tutor/views.d.ts.map +1 -0
  101. package/dist/tutor/views.js +63 -0
  102. package/dist/tutor/views.js.map +1 -0
  103. package/dist/tutor/walking.d.ts +44 -0
  104. package/dist/tutor/walking.d.ts.map +1 -0
  105. package/dist/tutor/walking.js +142 -0
  106. package/dist/tutor/walking.js.map +1 -0
  107. package/dist/tutor/walks.d.ts +46 -0
  108. package/dist/tutor/walks.d.ts.map +1 -0
  109. package/dist/tutor/walks.js +112 -0
  110. package/dist/tutor/walks.js.map +1 -0
  111. package/dist/wire/index.d.ts +133 -0
  112. package/dist/wire/index.d.ts.map +1 -0
  113. package/dist/wire/index.js +204 -0
  114. package/dist/wire/index.js.map +1 -0
  115. package/package.json +53 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typing.js","sourceRoot":"","sources":["../../src/pointer/typing.ts"],"names":[],"mappings":"AAAA,6HAA6H;AAC7H,EAAE;AACF,kGAAkG;AAClG,iGAAiG;AACjG,gGAAgG;AAChG,gBAAgB;AAEhB,wCAAwC;AACxC,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,2CAA2C;AAC3C,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,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AI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1D,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,6FAA6F;AAC7F,SAAS,GAAG,CAAC,KAA6C,EAAE,KAAa;IACvE,MAAM,SAAS,GAAG,KAAK,YAAY,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,SAAS,CAAC;IACpH,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7E,KAAK,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,22 @@
1
+ /** What the tutor shows of the conversation in words: whose, as the site chose and the visitor turned on or off, and the visitor's own words as they say them. */
2
+ import type { RoomStore } from "@pinecall/room";
3
+ /** Whose words the tutor may show: both sides, one, or none. */
4
+ export type Captions = "both" | "agent" | "caller" | "none";
5
+ export declare const CAPTIONS: readonly Captions[];
6
+ /** What of the call's log the visitor's words are read from. */
7
+ export type Heard = Pick<RoomStore["state"]["log"], "live" | "turns">;
8
+ /** `value` when it names a choice, else both sides. */
9
+ export declare function captionsOf(value: string | null | undefined): Captions;
10
+ /** Whether `side`'s words show, under the site's choice and the visitor's; none while a window of code or a card is open, as they would cover it. */
11
+ export declare function shows(captions: Captions, visitorOn: boolean, side: "agent" | "caller", coding?: boolean): boolean;
12
+ /** Whether the visitor turned the captions on: off unless they turned them on on this site. */
13
+ export declare function visitorWantsCaptions(storage: () => Storage): boolean;
14
+ /** Keep the visitor's choice for their next visit. */
15
+ export declare function keepVisitorChoice(storage: () => Storage, on: boolean): void;
16
+ /** The visitor's words to show now: what they are saying, else their last turn for `linger` ms after it ended. */
17
+ export declare class Hearing {
18
+ #private;
19
+ constructor(linger: number);
20
+ at(log: Heard, now: number): string | null;
21
+ }
22
+ //# sourceMappingURL=captions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captions.d.ts","sourceRoot":"","sources":["../../src/tutor/captions.ts"],"names":[],"mappings":"AAAA,kKAAkK;AAOlK,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,gEAAgE;AAChE,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC5D,eAAO,MAAM,QAAQ,EAAE,SAAS,QAAQ,EAAwC,CAAC;AAKjF,gEAAgE;AAChE,MAAM,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;AAEtE,uDAAuD;AACvD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,CAErE;AAED,qJAAqJ;AACrJ,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,QAAQ,EAAE,MAAM,UAAQ,GAAG,OAAO,CAE/G;AAGD,+FAA+F;AAC/F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,OAAO,GAAG,OAAO,CAMpE;AAED,sDAAsD;AACtD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,OAAO,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAM3E;AAED,kHAAkH;AAClH,qBAAa,OAAO;;IAMlB,YAAY,MAAM,EAAE,MAAM,EAEzB;IAED,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAazC;CACF"}
@@ -0,0 +1,62 @@
1
+ /** What the tutor shows of the conversation in words: whose, as the site chose and the visitor turned on or off, and the visitor's own words as they say them. */
2
+ //
3
+ // The agent's words are lit as its voice says them (the bubble beside the face); the visitor's are
4
+ // what the ears hear, interim and then final, held a moment after their turn ends. The site picks
5
+ // which sides may show; they start off, and the visitor's CC button turns them on and off, kept in
6
+ // their browser.
7
+ export const CAPTIONS = ["both", "agent", "caller", "none"];
8
+ /** Where the visitor's choice is kept, per site. */
9
+ const KEPT = "pinecall.captions";
10
+ /** `value` when it names a choice, else both sides. */
11
+ export function captionsOf(value) {
12
+ return CAPTIONS.find((one) => one === value) ?? "both";
13
+ }
14
+ /** Whether `side`'s words show, under the site's choice and the visitor's; none while a window of code or a card is open, as they would cover it. */
15
+ export function shows(captions, visitorOn, side, coding = false) {
16
+ return visitorOn && !coding && (captions === "both" || captions === side);
17
+ }
18
+ // Storage throws in a private window or with site data blocked: the captions then start off.
19
+ /** Whether the visitor turned the captions on: off unless they turned them on on this site. */
20
+ export function visitorWantsCaptions(storage) {
21
+ try {
22
+ return storage().getItem(KEPT) === "on";
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ }
28
+ /** Keep the visitor's choice for their next visit. */
29
+ export function keepVisitorChoice(storage, on) {
30
+ try {
31
+ storage().setItem(KEPT, on ? "on" : "off");
32
+ }
33
+ catch {
34
+ // Not kept: it holds for this page.
35
+ }
36
+ }
37
+ /** The visitor's words to show now: what they are saying, else their last turn for `linger` ms after it ended. */
38
+ export class Hearing {
39
+ #linger;
40
+ #last = { text: "", at: Number.NEGATIVE_INFINITY };
41
+ /** The visitor's turns already seen; null until the first look, so a page that joins late shows none of the past. */
42
+ #turns = null;
43
+ constructor(linger) {
44
+ this.#linger = linger;
45
+ }
46
+ at(log, now) {
47
+ const turns = log.turns.filter((turn) => turn.role === "user");
48
+ if (this.#turns === null)
49
+ this.#turns = turns.length;
50
+ const saying = log.live.user;
51
+ if (saying !== null && saying !== "") {
52
+ this.#last = { text: saying, at: now };
53
+ return saying;
54
+ }
55
+ if (turns.length > this.#turns) {
56
+ this.#turns = turns.length;
57
+ this.#last = { text: turns.at(-1)?.text ?? "", at: now };
58
+ }
59
+ return this.#last.text !== "" && now - this.#last.at < this.#linger ? this.#last.text : null;
60
+ }
61
+ }
62
+ //# sourceMappingURL=captions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captions.js","sourceRoot":"","sources":["../../src/tutor/captions.ts"],"names":[],"mappings":"AAAA,kKAAkK;AAClK,EAAE;AACF,mGAAmG;AACnG,kGAAkG;AAClG,mGAAmG;AACnG,iBAAiB;AAMjB,MAAM,CAAC,MAAM,QAAQ,GAAwB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEjF,oDAAoD;AACpD,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAKjC,uDAAuD;AACvD,MAAM,UAAU,UAAU,CAAC,KAAgC;IACzD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK,CAAC,IAAI,MAAM,CAAC;AACzD,CAAC;AAED,qJAAqJ;AACrJ,MAAM,UAAU,KAAK,CAAC,QAAkB,EAAE,SAAkB,EAAE,IAAwB,EAAE,MAAM,GAAG,KAAK;IACpG,OAAO,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,6FAA6F;AAC7F,+FAA+F;AAC/F,MAAM,UAAU,oBAAoB,CAAC,OAAsB;IACzD,IAAI,CAAC;QACH,OAAO,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,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AC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/F,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ /** A macro's step on the page: its beats armed when the step arrives, each run as its word is said. */
2
+ import type { Beat, Step } from "../wire/index.js";
3
+ /** Where each beat sits in its step: the index of the word it hangs on, or -1 when the step never says it. */
4
+ export declare function placesOf(step: Pick<Step, "say" | "beats">): number[];
5
+ /** One step at a time: a new one replaces the one before, whose beats are left. */
6
+ export declare class Player {
7
+ #private;
8
+ /** A step arrived. `speaking` is the reply under way now, if any. */
9
+ arm(step: Step, speaking: string | null): void;
10
+ get armed(): boolean;
11
+ /**
12
+ * The beats due now, each once: `speech` is the reply being said (null when none is) and `lit`
13
+ * the words of it said so far. A step whose reply has ended is done.
14
+ */
15
+ due(speech: string | null, lit: string): Beat[];
16
+ /** Leave the step: the visitor spoke, or the tutor stopped. */
17
+ drop(): void;
18
+ }
19
+ //# sourceMappingURL=macro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"macro.d.ts","sourceRoot":"","sources":["../../src/tutor/macro.ts"],"names":[],"mappings":"AAAA,uGAAuG;AAOvG,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGnD,8GAA8G;AAC9G,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,GAAG,MAAM,EAAE,CAYpE;AAYD,mFAAmF;AACnF,qBAAa,MAAM;;IAGjB,qEAAqE;IACrE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE7C;IAED,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED;;;OAGG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,CAoB9C;IAED,+DAA+D;IAC/D,IAAI,IAAI,IAAI,CAEX;CACF"}
@@ -0,0 +1,67 @@
1
+ /** A macro's step on the page: its beats armed when the step arrives, each run as its word is said. */
2
+ //
3
+ // The agent sends a step and then says it. The page binds the step to the next reply it hears, and
4
+ // counts the reply's words as the voice says them (room's karaoke, from the log's word timings):
5
+ // a beat runs when its word starts. So the pointer is in time with the voice to the word, whatever
6
+ // the voice, and nothing has to be timed on the agent's side.
7
+ import { normal, wordsOf } from "../wire/index.js";
8
+ /** Where each beat sits in its step: the index of the word it hangs on, or -1 when the step never says it. */
9
+ export function placesOf(step) {
10
+ const words = wordsOf(step.say);
11
+ return step.beats.map((beat) => {
12
+ const wanted = normal(beat.word);
13
+ let seen = 0;
14
+ for (let at = 0; at < words.length; at += 1) {
15
+ if (words[at] !== wanted)
16
+ continue;
17
+ seen += 1;
18
+ if (seen === (beat.nth ?? 1))
19
+ return at;
20
+ }
21
+ return -1;
22
+ });
23
+ }
24
+ /** One step at a time: a new one replaces the one before, whose beats are left. */
25
+ export class Player {
26
+ #armed = null;
27
+ /** A step arrived. `speaking` is the reply under way now, if any. */
28
+ arm(step, speaking) {
29
+ this.#armed = { step, places: placesOf(step), fired: new Set(), speech: null, before: speaking };
30
+ }
31
+ get armed() {
32
+ return this.#armed !== null;
33
+ }
34
+ /**
35
+ * The beats due now, each once: `speech` is the reply being said (null when none is) and `lit`
36
+ * the words of it said so far. A step whose reply has ended is done.
37
+ */
38
+ due(speech, lit) {
39
+ const armed = this.#armed;
40
+ if (armed === null)
41
+ return [];
42
+ if (armed.speech === null) {
43
+ if (speech === null || speech === armed.before)
44
+ return [];
45
+ armed.speech = speech;
46
+ }
47
+ if (speech !== armed.speech) {
48
+ this.#armed = null;
49
+ return [];
50
+ }
51
+ const said = wordsOf(lit).length;
52
+ const due = [];
53
+ armed.step.beats.forEach((beat, at) => {
54
+ const place = armed.places[at] ?? -1;
55
+ if (place < 0 || place >= said || armed.fired.has(at))
56
+ return;
57
+ armed.fired.add(at);
58
+ due.push(beat);
59
+ });
60
+ return due;
61
+ }
62
+ /** Leave the step: the visitor spoke, or the tutor stopped. */
63
+ drop() {
64
+ this.#armed = null;
65
+ }
66
+ }
67
+ //# sourceMappingURL=macro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"macro.js","sourceRoot":"","sources":["../../src/tutor/macro.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,EAAE;AACF,mGAAmG;AACnG,iGAAiG;AACjG,mGAAmG;AACnG,8DAA8D;AAG9D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEnD,8GAA8G;AAC9G,MAAM,UAAU,QAAQ,CAAC,IAAiC;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;YAC5C,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,MAAM;gBAAE,SAAS;YACnC,IAAI,IAAI,CAAC,CAAC;YACV,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAE,OAAO,EAAE,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,C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C,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;gBAAE,OAAO;YAC9D,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACpB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACb,CAAC;IAED,+DAA+D;IAC/D,IAAI;QACF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,42 @@
1
+ /** What a page gives `tutor()`: where it rests, its colour and shape, whose words show, the walks it plays, and the views of its own tools. */
2
+ import type { Shape } from "../face/shape.js";
3
+ import type { Captions } from "./captions.js";
4
+ import type { Views } from "./views.js";
5
+ import type { Walked } from "./walking.js";
6
+ export interface TutorOptions {
7
+ /** The corner it rests in. Default `right`. */
8
+ dock?: "right" | "left" | undefined;
9
+ /** What the face is called for a screen reader. Default "Talk to the assistant". */
10
+ label?: string | undefined;
11
+ /** The face was clicked: the page starts the call, or ends it. */
12
+ onClick?: (() => void) | undefined;
13
+ /** How long its last words stay beside it after a reply, and the visitor's after theirs, in ms. Default 2600. */
14
+ linger?: number | undefined;
15
+ /** The face's shape: `circle` (the default), `squircle` or `blob`. */
16
+ shape?: Shape | undefined;
17
+ /** The face's and the pointer's colour, any CSS colour; the page's `--pc-face` when left out. */
18
+ color?: string | undefined;
19
+ /** Whose words show: `both` (the default), `agent`, `caller` or `none`. The visitor turns them off and on with CC, unless `none`. */
20
+ captions?: Captions | undefined;
21
+ /** The buttons' names, for a screen reader and a tooltip. Default "Hang up", "Captions", "Explain this", "Walks", "Stop", "Pause", "Close" and "More walks". */
22
+ words?: {
23
+ hangUp?: string | undefined;
24
+ captions?: string | undefined;
25
+ explain?: string | undefined;
26
+ walks?: string | undefined;
27
+ stop?: string | undefined;
28
+ pause?: string | undefined;
29
+ close?: string | undefined;
30
+ more?: string | undefined;
31
+ } | undefined;
32
+ /** Where the agent published its recorded walks (`GET …/v1/agents/{slug}/public/walks`): a button beside the face plays them with no call. */
33
+ walks?: string | undefined;
34
+ /** A walk started, ended, or was stopped: the page's own analytics hear it. */
35
+ onWalk?: ((walked: Walked) => void) | undefined;
36
+ /**
37
+ * What the page draws for the agent's own tools, by tool name: a card beside the face with the free
38
+ * times, the booking form, a piece of code. Read each time a tool finishes, so a page may set it late.
39
+ */
40
+ views?: Views | undefined;
41
+ }
42
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/tutor/options.ts"],"names":[],"mappings":"AAAA,+IAA+I;AAE/I,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,oFAAoF;IACpF,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACnC,iHAAiH;IACjH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,sEAAsE;IACtE,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAC1B,iGAAiG;IACjG,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,qIAAqI;IACrI,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAChC,gKAAgK;IAChK,KAAK,CAAC,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC3B,GAAG,SAAS,CAAC;IACd,8IAA8I;IAC9I,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,+EAA+E;IAC/E,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAChD;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC3B"}
@@ -0,0 +1,3 @@
1
+ /** What a page gives `tutor()`: where it rests, its colour and shape, whose words show, the walks it plays, and the views of its own tools. */
2
+ export {};
3
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/tutor/options.ts"],"names":[],"mappings":"AAAA,+IAA+I"}
@@ -0,0 +1,14 @@
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
+ import { type RoomStore } from "@pinecall/room";
3
+ import type { TutorOptions } from "./options.js";
4
+ export type { TutorOptions } from "./options.js";
5
+ export interface Tutor {
6
+ /** A message the agent sent on `pinecall.ui`: true when it was the tutor's to carry out, false for a card or choices. */
7
+ take(data: unknown): boolean;
8
+ /** Let the face hear the voice: call it from the click that starts the call. */
9
+ wake(): void;
10
+ close(): void;
11
+ }
12
+ /** Put the tutor on the page, moving with `call`. Nothing is sent until the call is live. */
13
+ export declare function tutor(call: RoomStore, options?: TutorOptions): Tutor;
14
+ //# sourceMappingURL=tutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tutor.d.ts","sourceRoot":"","sources":["../../src/tutor/tutor.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAS/H,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAYjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,WAAW,KAAK;IACpB,yHAAyH;IACzH,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7B,gFAAgF;IAChF,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;CACf;AAKD,6FAA6F;AAC7F,wBAAgB,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,CA8UxE"}