@saar-ai/web-widget 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/card-aspect.d.ts +58 -0
- package/dist/card-aspect.d.ts.map +1 -0
- package/dist/chunks/{host-widget-B0SkhMIs.js → host-widget-C0XT9lHX.js} +4301 -5756
- package/dist/chunks/{telemetry-Bw-3F_Zk.js → telemetry-BI_SEWTb.js} +104 -2
- package/dist/dock/dock-caption.d.ts +67 -0
- package/dist/dock/dock-caption.d.ts.map +1 -0
- package/dist/dock/dock-motion.d.ts +155 -0
- package/dist/dock/dock-motion.d.ts.map +1 -0
- package/dist/dock/dock-pill.d.ts +38 -0
- package/dist/dock/dock-pill.d.ts.map +1 -0
- package/dist/dock/dock-row.d.ts +120 -0
- package/dist/dock/dock-row.d.ts.map +1 -0
- package/dist/dock/dock-sheet.d.ts +89 -0
- package/dist/dock/dock-sheet.d.ts.map +1 -0
- package/dist/dock/dock-shelf.d.ts +38 -0
- package/dist/dock/dock-shelf.d.ts.map +1 -0
- package/dist/dock/dock-state.d.ts +221 -0
- package/dist/dock/dock-state.d.ts.map +1 -0
- package/dist/dock/dock.d.ts +344 -0
- package/dist/dock/dock.d.ts.map +1 -0
- package/dist/dock/geometry.d.ts +161 -0
- package/dist/dock/geometry.d.ts.map +1 -0
- package/dist/generated/widget-css.d.ts.map +1 -1
- package/dist/host-widget.d.ts +94 -16
- package/dist/host-widget.d.ts.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4029 -7
- package/dist/messages.d.ts +69 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/session-log.d.ts +7 -0
- package/dist/session-log.d.ts.map +1 -1
- package/dist/session-panel.d.ts +13 -3
- package/dist/session-panel.d.ts.map +1 -1
- package/dist/theme/color.d.ts +114 -0
- package/dist/theme/color.d.ts.map +1 -0
- package/dist/theme/derive.d.ts +92 -0
- package/dist/theme/derive.d.ts.map +1 -0
- package/dist/theme/index.d.ts +10 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/use-chat-session.d.ts +18 -16
- package/dist/use-chat-session.d.ts.map +1 -1
- package/dist/use-voice-session.d.ts +79 -3
- package/dist/use-voice-session.d.ts.map +1 -1
- package/dist/voice-widget.d.ts +49 -19
- package/dist/voice-widget.d.ts.map +1 -1
- package/dist/widget-cards.d.ts +28 -1
- package/dist/widget-cards.d.ts.map +1 -1
- package/dist/widget.css +1 -1
- package/package.json +4 -4
- package/src/styles/concierge.css +758 -28
- package/src/styles/tokens.css +67 -0
- package/dist/concierge-launcher.d.ts +0 -53
- package/dist/concierge-launcher.d.ts.map +0 -1
- package/dist/concierge-shell.d.ts +0 -256
- package/dist/concierge-shell.d.ts.map +0 -1
- package/dist/position.d.ts +0 -65
- package/dist/position.d.ts.map +0 -1
- package/dist/transcript-geometry.d.ts +0 -220
- package/dist/transcript-geometry.d.ts.map +0 -1
package/dist/messages.d.ts
CHANGED
|
@@ -45,6 +45,75 @@ export interface WidgetMessages {
|
|
|
45
45
|
readonly send: string;
|
|
46
46
|
readonly move: string;
|
|
47
47
|
readonly call_end: string;
|
|
48
|
+
/**
|
|
49
|
+
* DOCK_SPEC §3.2 — the dock pill's default label, when the tenant published
|
|
50
|
+
* no `copy[locale].minimisedLabel`. `dock_pill_hold` is the touch-with-voice
|
|
51
|
+
* default ("Hold to ask" names the actual gesture, §5.2); `dock_pill_ask`
|
|
52
|
+
* carries `{name}` and is the fallback everywhere the microphone is not
|
|
53
|
+
* available — a desktop pointer, `modalities.voice: false`, or an embedded
|
|
54
|
+
* webview (§8.4). A label promising a microphone that is not on screen is
|
|
55
|
+
* worse than no label at all.
|
|
56
|
+
*
|
|
57
|
+
* OPTIONAL, like every key added after 0.2.0 — see `handoff_event` below
|
|
58
|
+
* for the compatibility contract that makes that mandatory rather than
|
|
59
|
+
* stylistic.
|
|
60
|
+
*/
|
|
61
|
+
readonly dock_pill_hold?: string;
|
|
62
|
+
readonly dock_pill_ask?: string;
|
|
63
|
+
/**
|
|
64
|
+
* DOCK_SPEC §5.1 and §3.2 — every **spec** string the dock's caption, its
|
|
65
|
+
* controls and its sheet header render. "Spec" means ours, localised by us,
|
|
66
|
+
* as distinct from the **tenant** strings (`greeting`, `offlineMessage`,
|
|
67
|
+
* `minimisedLabel`) that come from `copy[locale]` and are authored per
|
|
68
|
+
* tenant.
|
|
69
|
+
*
|
|
70
|
+
* All OPTIONAL, like every key added after 0.2.0 — see `handoff_event`
|
|
71
|
+
* below for the published-interface compatibility contract that makes that
|
|
72
|
+
* mandatory rather than stylistic. A host with a complete catalogue of its
|
|
73
|
+
* own keeps compiling, and a missing key resolves against
|
|
74
|
+
* `defaultWidgetMessages` at the point of use, so an older catalogue
|
|
75
|
+
* renders shipped English rather than an empty row.
|
|
76
|
+
*
|
|
77
|
+
* | Key | State (§5.1) |
|
|
78
|
+
* | ------------------------ | --------------------------------------------------------------- |
|
|
79
|
+
* | `dock_connecting` | `connecting` — the only state allowed to block |
|
|
80
|
+
* | `dock_use_text` | `connecting`'s keyboard control: the text escape it must carry |
|
|
81
|
+
* | `dock_listening` | `listening`, until the recognizer produces words |
|
|
82
|
+
* | `dock_thinking` | `thinking`, only when no `preamble` arrived within `raceMs` |
|
|
83
|
+
* | `dock_interrupt` | `speaking` — labelled the first two times per visitor, icon after |
|
|
84
|
+
* | `dock_ducked` | `ducked` — a real pause, resumed by speech or a tap, never a timer |
|
|
85
|
+
* | `dock_still_here` | `reconnecting` — the most-seen state on a navigating storefront |
|
|
86
|
+
* | `dock_still_here_resume` | `reconnecting` after a lock/app-switch that dropped the room |
|
|
87
|
+
* | `dock_muted` | `muted` — a privacy control, not a convenience |
|
|
88
|
+
* | `dock_mic_blocked` | `mic_blocked` — degrades to text, never re-prompts |
|
|
89
|
+
* | `dock_fix_browser` | `mic_blocked`'s second control, offered once |
|
|
90
|
+
* | `dock_cards` | `cards` — carries `{count}` |
|
|
91
|
+
* | `dock_voice_failed` | a voice CONNECT that failed — the one line a shopper can act on |
|
|
92
|
+
* | `dock_show_transcript` | §3.4 — the sheet's header, voice sessions only |
|
|
93
|
+
* | `dock_earbuds` | §8.7 — offered once per session on a headset connect |
|
|
94
|
+
*/
|
|
95
|
+
readonly dock_connecting?: string;
|
|
96
|
+
readonly dock_use_text?: string;
|
|
97
|
+
readonly dock_listening?: string;
|
|
98
|
+
readonly dock_thinking?: string;
|
|
99
|
+
readonly dock_interrupt?: string;
|
|
100
|
+
readonly dock_ducked?: string;
|
|
101
|
+
readonly dock_still_here?: string;
|
|
102
|
+
readonly dock_still_here_resume?: string;
|
|
103
|
+
readonly dock_muted?: string;
|
|
104
|
+
readonly dock_mic_blocked?: string;
|
|
105
|
+
readonly dock_fix_browser?: string;
|
|
106
|
+
readonly dock_cards?: string;
|
|
107
|
+
/**
|
|
108
|
+
* §5.1 — shown INSTEAD of the transport error when the call could not be
|
|
109
|
+
* established at all ("could not establish signal connection: Failed to
|
|
110
|
+
* fetch" is what a blocked LiveKit host produces). The raw text still
|
|
111
|
+
* reaches `onError` and the console; the shopper gets the one sentence they
|
|
112
|
+
* can act on, next to the keyboard control that acts on it.
|
|
113
|
+
*/
|
|
114
|
+
readonly dock_voice_failed?: string;
|
|
115
|
+
readonly dock_show_transcript?: string;
|
|
116
|
+
readonly dock_earbuds?: string;
|
|
48
117
|
/**
|
|
49
118
|
* The handoff MARKER — the quiet inline divider in the transcript at the
|
|
50
119
|
* point the conversation was handed to a person. Past tense on purpose: it
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAA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MAAM,CAAC;IACjC;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;;;;OAMG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,2BAA2B,CAAC,EAAE,MAAM,CAAC;CAC/C;AAED;;;;;GAKG;AACH;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,cAAc,CA6D1D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAM9F;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAOzF;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,CAGhG"}
|
package/dist/next/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as detectPage, t as ConciergeWidget } from "../chunks/host-widget-
|
|
1
|
+
import { p as detectPage, t as ConciergeWidget } from "../chunks/host-widget-C0XT9lHX.js";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { usePathname, useRouter } from "next/navigation";
|
|
4
4
|
//#region src/next/use-next-bridge.ts
|
package/dist/session-log.d.ts
CHANGED
|
@@ -28,6 +28,13 @@ export declare const SESSION_EVENTS: readonly ['token_requested', 'token_receive
|
|
|
28
28
|
'session_config',
|
|
29
29
|
/** The caller typed a turn instead of speaking it. */
|
|
30
30
|
'text_sent',
|
|
31
|
+
/**
|
|
32
|
+
* The BROWSER told the worker something about the turn in flight —
|
|
33
|
+
* DOCK_SPEC §5.1/§5.2's control channel: an end-of-utterance hint on a
|
|
34
|
+
* hold-to-talk release, or a client-initiated interrupt carrying its
|
|
35
|
+
* reason. The detail is the frame's `type`, or the interrupt's reason.
|
|
36
|
+
*/
|
|
37
|
+
'control_sent',
|
|
31
38
|
/** A speech vendor refused — the call is up but a leg of it is silent. */
|
|
32
39
|
'vendor_error',
|
|
33
40
|
/** A tool rendered something on screen — product cards, a checkout control. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-log.d.ts","sourceRoot":"","sources":["../src/session-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,yDAAyD;AACzD,eAAO,MAAM,cAAc,YACzB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,YAAY;AACZ,0DAA0D;AAC1D,cAAc;AACd,2EAA2E;AAC3E,gBAAgB;AAChB,sDAAsD;AACtD,WAAW;AACX,0EAA0E;AAC1E,cAAc;AACd,+EAA+E;AAC/E,cAAc;AACd,iFAAiF;AACjF,sBAAsB,EACtB,cAAc,EACd,SAAS,EACT,OAAO,EAQP,eAAe,EAKf,oBAAoB,CACZ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EAGrC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAa/D;IAED,oBAAoB;IACpB,IAAI,IAAI,SAAS,eAAe,EAAE,CAEjC;IAED,yEAAyE;IACzE,KAAK,IAAI,IAAI,CAEZ;CACF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,IAAI,EAAE,gBAAgB,EACtB,EAAE,EAAE,gBAAgB,GACnB,MAAM,GAAG,IAAI,CAKf;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAG3C"}
|
package/dist/session-panel.d.ts
CHANGED
|
@@ -2,8 +2,18 @@ import type { TranscriptPayload, TurnLatencyPayload } from '@saar-ai/widget-prot
|
|
|
2
2
|
import { type SessionLogEntry } from './session-log.js';
|
|
3
3
|
export interface SessionPanelProps {
|
|
4
4
|
readonly events: readonly SessionLogEntry[];
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* 0..1 RMS of the agent's incoming audio, as a LIVE REF (§7.1 rule 5).
|
|
7
|
+
*
|
|
8
|
+
* `useVoiceSession` hands this straight over. It changes on every animation
|
|
9
|
+
* frame, so the meter below reads it inside its own `requestAnimationFrame`
|
|
10
|
+
* and writes the transform to the DOM; a number prop would re-render this
|
|
11
|
+
* panel — and everything else holding the value — sixty times a second.
|
|
12
|
+
* A static caller (a story, a screenshot) passes `{ current: 0.42 }`.
|
|
13
|
+
*/
|
|
14
|
+
readonly agentLevelRef: {
|
|
15
|
+
readonly current: number;
|
|
16
|
+
};
|
|
7
17
|
readonly phase: string;
|
|
8
18
|
readonly micOpen: boolean;
|
|
9
19
|
readonly error: string | null;
|
|
@@ -11,5 +21,5 @@ export interface SessionPanelProps {
|
|
|
11
21
|
readonly turns: readonly TurnLatencyPayload[];
|
|
12
22
|
readonly transcript: readonly TranscriptPayload[];
|
|
13
23
|
}
|
|
14
|
-
export declare function SessionPanel({ events,
|
|
24
|
+
export declare function SessionPanel({ events, agentLevelRef, phase, micOpen, error, turns, transcript, }: SessionPanelProps): import("react").JSX.Element;
|
|
15
25
|
//# sourceMappingURL=session-panel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-panel.d.ts","sourceRoot":"","sources":["../src/session-panel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-panel.d.ts","sourceRoot":"","sources":["../src/session-panel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAEhG,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAwBlF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAC5C;;;;;;;;OAQG;IACH,QAAQ,CAAC,aAAa,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAC9C,QAAQ,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACnD;AAWD,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,aAAa,EACb,KAAK,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,UAAU,GACX,EAAE,iBAAiB,+BAsKnB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COLOUR MATHS for the dock's derived theme (docs/DOCK_SPEC.md §9.2).
|
|
3
|
+
*
|
|
4
|
+
* Pure functions, zero dependencies, no DOM. That is a hard requirement, not
|
|
5
|
+
* a preference: `deriveTheme` runs in three places with three different
|
|
6
|
+
* budgets — the console's live preview (Node/browser, React), the CDN `core`
|
|
7
|
+
* stage (inlined into a ~20 KB min+gz artefact that must paint the resting
|
|
8
|
+
* row before any framework loads), and the React dock (adopted stylesheet).
|
|
9
|
+
* A colour library, a `color-mix()` call, or anything that needs a live
|
|
10
|
+
* CSSOM would each break at least one of those three.
|
|
11
|
+
*
|
|
12
|
+
* WHY WE COMPUTE INSTEAD OF LETTING CSS DO IT. `color-mix(in oklch, ...)` and
|
|
13
|
+
* relative colour syntax express every derivation here in one line, and both
|
|
14
|
+
* are unusable for us: the `core` stage writes tokens as an INLINE `style`
|
|
15
|
+
* attribute on the shadow host before any stylesheet exists, so the values it
|
|
16
|
+
* writes have to already be plain colours; and the publish-time validator
|
|
17
|
+
* (§9.3) has to ASSERT the contrast of the derived text, which means the
|
|
18
|
+
* numbers must exist in JavaScript, not only in a browser's style resolver.
|
|
19
|
+
*
|
|
20
|
+
* Colour space is Björn Ottosson's OKLab/OKLCH throughout, because hue
|
|
21
|
+
* rotation (`--wgt-accent`) and mixing (`--wgt-surface-2`) both have to be
|
|
22
|
+
* perceptually even — an HSL rotation off a brand teal lands somewhere a
|
|
23
|
+
* designer would reject, and a naive sRGB channel mix darkens far too fast.
|
|
24
|
+
* Contrast, by contrast (sorry), is WCAG 2.x relative luminance, because that
|
|
25
|
+
* — not any perceptual metric — is what §9.3 promises and what an auditor
|
|
26
|
+
* measures.
|
|
27
|
+
*/
|
|
28
|
+
/** sRGB in 0..1 per channel, plus alpha. The parsed form of a hex string. */
|
|
29
|
+
export interface Rgb {
|
|
30
|
+
r: number;
|
|
31
|
+
g: number;
|
|
32
|
+
b: number;
|
|
33
|
+
a: number;
|
|
34
|
+
}
|
|
35
|
+
/** OKLab. `L` 0..1, `a`/`b` roughly -0.4..0.4. */
|
|
36
|
+
export interface Oklab {
|
|
37
|
+
L: number;
|
|
38
|
+
a: number;
|
|
39
|
+
b: number;
|
|
40
|
+
}
|
|
41
|
+
/** OKLCH. `L` 0..1, `C` 0..~0.37 in sRGB, `h` degrees 0..360. */
|
|
42
|
+
export interface Oklch {
|
|
43
|
+
L: number;
|
|
44
|
+
C: number;
|
|
45
|
+
h: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa` (leading `#` optional) into
|
|
49
|
+
* 0..1 channels.
|
|
50
|
+
*
|
|
51
|
+
* @throws {TypeError} on anything else — a tenant's published config is
|
|
52
|
+
* validated at publish (§9.3), so an unparsable hex reaching here is a bug in
|
|
53
|
+
* the caller, and returning a fallback colour would hide it behind a widget
|
|
54
|
+
* that merely looks wrong on someone else's storefront.
|
|
55
|
+
*/
|
|
56
|
+
export declare function parseHex(hex: string): Rgb;
|
|
57
|
+
/** `#rrggbb`, lowercase. Alpha is dropped — every `--wgt-*` colour token that
|
|
58
|
+
* needs transparency goes through {@link withAlpha} instead. */
|
|
59
|
+
export declare function formatHex(rgb: Rgb | {
|
|
60
|
+
r: number;
|
|
61
|
+
g: number;
|
|
62
|
+
b: number;
|
|
63
|
+
}): string;
|
|
64
|
+
/** sRGB transfer function, inverse (encoded → linear-light). */
|
|
65
|
+
export declare function srgbToLinear(c: number): number;
|
|
66
|
+
/** sRGB transfer function (linear-light → encoded). */
|
|
67
|
+
export declare function linearToSrgb(c: number): number;
|
|
68
|
+
/** Linear-light sRGB → OKLab (Ottosson's M1/M2 matrices). */
|
|
69
|
+
export declare function linearRgbToOklab(r: number, g: number, b: number): Oklab;
|
|
70
|
+
/** OKLab → linear-light sRGB. May land OUTSIDE 0..1 (out of gamut). */
|
|
71
|
+
export declare function oklabToLinearRgb(lab: Oklab): {
|
|
72
|
+
r: number;
|
|
73
|
+
g: number;
|
|
74
|
+
b: number;
|
|
75
|
+
};
|
|
76
|
+
export declare function oklabToOklch(lab: Oklab): Oklch;
|
|
77
|
+
export declare function oklchToOklab(lch: Oklch): Oklab;
|
|
78
|
+
/** Hex → OKLab. */
|
|
79
|
+
export declare function hexToOklab(hex: string): Oklab;
|
|
80
|
+
/** Hex → OKLCH. */
|
|
81
|
+
export declare function hexToOklch(hex: string): Oklch;
|
|
82
|
+
/**
|
|
83
|
+
* OKLab → `#rrggbb`, gamut-mapped by REDUCING CHROMA at constant L and h.
|
|
84
|
+
*
|
|
85
|
+
* The naive alternative — clamp each channel into 0..1 — is what makes a hue
|
|
86
|
+
* rotation lie: clipping a channel moves the colour sideways in hue, so
|
|
87
|
+
* `--wgt-accent` derived as "primary + 30°" comes back as anything from +18°
|
|
88
|
+
* to +45° depending on which channel blew out. `derive.test.ts` asserts the
|
|
89
|
+
* accent's hue to within 1°, and this binary search is what makes that
|
|
90
|
+
* assertion satisfiable at all. 24 halvings resolves chroma far finer than
|
|
91
|
+
* the 8-bit output can represent, so the loop is a fixed, tiny cost.
|
|
92
|
+
*/
|
|
93
|
+
export declare function oklabToHex(lab: Oklab): string;
|
|
94
|
+
/** OKLCH → `#rrggbb`, gamut-mapped as {@link oklabToHex} describes. */
|
|
95
|
+
export declare function oklchToHex(lch: Oklch): string;
|
|
96
|
+
/** WCAG 2.x relative luminance (0 = black, 1 = white). */
|
|
97
|
+
export declare function relativeLuminance(hex: string): number;
|
|
98
|
+
/** WCAG 2.x contrast ratio, 1..21. Symmetric in its arguments. */
|
|
99
|
+
export declare function contrastRatio(a: string, b: string): number;
|
|
100
|
+
/**
|
|
101
|
+
* `rgb(r g b / a)` — the CSS Color 4 space-separated form.
|
|
102
|
+
*
|
|
103
|
+
* Not `#rrggbbaa`: the alpha tokens (`--wgt-text-muted`, `--wgt-border`,
|
|
104
|
+
* `--wgt-ring`) are read back by the console preview and by tests, and a
|
|
105
|
+
* decimal alpha stays legible there instead of becoming a byte nobody can
|
|
106
|
+
* eyeball. Both forms have identical browser support inside our floor.
|
|
107
|
+
*/
|
|
108
|
+
export declare function withAlpha(hex: string, alpha: number): string;
|
|
109
|
+
/** Rotate a colour's OKLCH hue by `deg`, holding L and C (chroma may be
|
|
110
|
+
* gamut-reduced by the conversion back — hue never is). */
|
|
111
|
+
export declare function rotateHue(hex: string, deg: number): string;
|
|
112
|
+
/** Linearly interpolate `hex` toward `towardHex` by `t` (0..1) in OKLab. */
|
|
113
|
+
export declare function mixToward(hex: string, towardHex: string, t: number): string;
|
|
114
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/theme/color.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,kDAAkD;AAClD,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,iEAAiE;AACjE,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAID;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAkBzC;AAKD;gEACgE;AAChE,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEhF;AAED,gEAAgE;AAChE,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,uDAAuD;AACvD,wBAAgB,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MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAW3E"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export type WidgetTone = 'light' | 'dark' | 'auto';
|
|
2
|
+
export type WidgetFont = 'inherit' | 'system';
|
|
3
|
+
export type WidgetRadius = 'square' | 'soft' | 'round' | 'pill';
|
|
4
|
+
export type WidgetCaps = 'none' | 'buttons';
|
|
5
|
+
/** §9.1's `color` group. */
|
|
6
|
+
export interface WidgetColorConfig {
|
|
7
|
+
primary: string;
|
|
8
|
+
accent?: string;
|
|
9
|
+
surface?: string;
|
|
10
|
+
tone: WidgetTone;
|
|
11
|
+
}
|
|
12
|
+
/** §9.1's `type` group. */
|
|
13
|
+
export interface WidgetTypeConfig {
|
|
14
|
+
font: WidgetFont;
|
|
15
|
+
radius: WidgetRadius;
|
|
16
|
+
caps: WidgetCaps;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Every token §9.2 defines, in the order they are emitted. Declaration order
|
|
20
|
+
* is part of the contract: `themeToCss`'s output is snapshotted, and a reader
|
|
21
|
+
* comparing a rendered block against the spec table should not have to sort.
|
|
22
|
+
*/
|
|
23
|
+
export declare const WIDGET_THEME_TOKENS: readonly ['--wgt-primary', '--wgt-on-primary', '--wgt-accent', '--wgt-surface', '--wgt-surface-2', '--wgt-text', '--wgt-text-muted', '--wgt-border', '--wgt-ring', '--wgt-radius', '--wgt-sheet-radius', '--wgt-card-radius', '--wgt-font', '--wgt-caps'];
|
|
24
|
+
export type WidgetThemeVar = (typeof WIDGET_THEME_TOKENS)[number];
|
|
25
|
+
export type WidgetThemeVars = Record<WidgetThemeVar, string>;
|
|
26
|
+
/**
|
|
27
|
+
* `light` is the UNCONDITIONAL block — the one written straight onto the
|
|
28
|
+
* selector — not "the light appearance". For `tone: 'dark'` it carries the
|
|
29
|
+
* dark derivation and `dark` is absent; `dark` exists only for `tone: 'auto'`,
|
|
30
|
+
* where it is the block that goes behind `@media (prefers-color-scheme:
|
|
31
|
+
* dark)`. Naming the fields after their CSS position rather than their
|
|
32
|
+
* colours is what keeps {@link themeToCss} trivial.
|
|
33
|
+
*/
|
|
34
|
+
export interface DerivedWidgetTheme {
|
|
35
|
+
light: WidgetThemeVars;
|
|
36
|
+
dark?: WidgetThemeVars;
|
|
37
|
+
}
|
|
38
|
+
/** §9.1 `type.font: 'system'`. Deliberately a plain stack — no webfont, no
|
|
39
|
+
* network request on a merchant's page. */
|
|
40
|
+
export declare const SYSTEM_FONT_STACK = "system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
|
|
41
|
+
/**
|
|
42
|
+
* §3.3 — the ceilings the SHEET and the cards inside it put on the tenant's
|
|
43
|
+
* radius.
|
|
44
|
+
*
|
|
45
|
+
* `type.radius: 'pill'` is 9999px, and that is what the row and the pill are
|
|
46
|
+
* FOR: a fully rounded 48 px bar. The same value on the sheet's top corners
|
|
47
|
+
* is not a rounded sheet, it is an ellipse the width of the viewport, and it
|
|
48
|
+
* turns the shelf's 64 px thumbnails into circles. The cap belongs to the
|
|
49
|
+
* SURFACE rather than to the tenant, so a pill tenant still gets its pill row
|
|
50
|
+
* and its pill controls.
|
|
51
|
+
*
|
|
52
|
+
* Resolved to a number here rather than emitted as a CSS `min()`: the `core`
|
|
53
|
+
* stage writes these tokens as an inline `style` attribute before any
|
|
54
|
+
* stylesheet exists ({@link themeToInlineStyle}), and §9.3's publish-time
|
|
55
|
+
* validator reads the values in JavaScript — the same two reasons no other
|
|
56
|
+
* token here is a CSS function.
|
|
57
|
+
*/
|
|
58
|
+
export declare const SHEET_RADIUS_MAX_PX = 20;
|
|
59
|
+
export declare const CARD_RADIUS_MAX_PX = 12;
|
|
60
|
+
/**
|
|
61
|
+
* Derive every `--wgt-*` token from the published `color` + `type` groups.
|
|
62
|
+
*
|
|
63
|
+
* Deterministic and side-effect free: the same inputs always produce the same
|
|
64
|
+
* strings, which is what lets the console preview, the `core` stage and the
|
|
65
|
+
* React dock render the same theme without sharing state.
|
|
66
|
+
*
|
|
67
|
+
* @throws {TypeError} on an unparsable hex or an unknown enum value. A
|
|
68
|
+
* published config is validated at §9.3, so either is a caller bug — and a
|
|
69
|
+
* fallback colour here would ship a wrong-looking widget on a merchant's site
|
|
70
|
+
* instead of failing where someone can see it.
|
|
71
|
+
*/
|
|
72
|
+
export declare function deriveTheme(color: WidgetColorConfig, type: WidgetTypeConfig): DerivedWidgetTheme;
|
|
73
|
+
/**
|
|
74
|
+
* The theme as a CSS text block: the unconditional rule, plus — for
|
|
75
|
+
* `tone: 'auto'` — a `prefers-color-scheme: dark` override on the same
|
|
76
|
+
* selector, exactly as §9.2 requires ("both defined on `:host`").
|
|
77
|
+
*
|
|
78
|
+
* `:host` is the default because the dock lives in a shadow root; pass a class
|
|
79
|
+
* or `:root` for the console preview, which renders in light DOM.
|
|
80
|
+
*/
|
|
81
|
+
export declare function themeToCss(theme: DerivedWidgetTheme, selector?: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* The theme as a `style` attribute value, for the `core` stage — which paints
|
|
84
|
+
* the resting row before any stylesheet, adopted or otherwise, exists.
|
|
85
|
+
*
|
|
86
|
+
* `tone: 'auto'`'s dark block has no inline equivalent (an attribute cannot
|
|
87
|
+
* carry a media query); `core` passes whichever block matches the page's
|
|
88
|
+
* current `prefers-color-scheme` and the adopted stylesheet takes over the
|
|
89
|
+
* responsiveness at the React handover.
|
|
90
|
+
*/
|
|
91
|
+
export declare function themeToInlineStyle(vars: WidgetThemeVars): string;
|
|
92
|
+
//# sourceMappingURL=derive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../src/theme/derive.ts"],"names":[],"mappings":"AA0CA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AACnD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC9C,M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D;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,kBAAkB,EAAE,QAAQ,SAAU,GAAG,MAAM,CAMhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAEhE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@saar-ai/web-widget`'s theme derivation (docs/DOCK_SPEC.md §9.2).
|
|
3
|
+
*
|
|
4
|
+
* Two modules, both pure and dependency-free so the CDN `core` stage can
|
|
5
|
+
* inline them inside its budget: `color.ts` (sRGB/OKLab/OKLCH conversion and
|
|
6
|
+
* WCAG contrast) and `derive.ts` (the config → `--wgt-*` token derivation).
|
|
7
|
+
*/
|
|
8
|
+
export * from './color.js';
|
|
9
|
+
export * from './derive.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { VisitorEventCollector } from '@saar-ai/widget-bridge';
|
|
2
2
|
import type { WidgetChatCart, WidgetChatReport } from '@saar-ai/widget-protocol/chat';
|
|
3
|
-
import { type ConciergePosition } from './position.js';
|
|
4
3
|
/**
|
|
5
4
|
* Text chat transport for the end-user widget: boots a session, sends typed
|
|
6
5
|
* turns over `POST /widget/chat` (SSE), and receives a human desk reply over
|
|
@@ -325,11 +324,6 @@ export interface WidgetEventInput {
|
|
|
325
324
|
}
|
|
326
325
|
export interface UseChatSessionResult {
|
|
327
326
|
readonly turns: readonly ChatTurn[];
|
|
328
|
-
/**
|
|
329
|
-
* How the tenant configured the COLLAPSED widget — label and starting
|
|
330
|
-
* anchor. Empty until the session boots; see `WidgetLauncherConfig`.
|
|
331
|
-
*/
|
|
332
|
-
readonly launcher: WidgetLauncherConfig;
|
|
333
327
|
/** Every `cards` event received this session, oldest first. */
|
|
334
328
|
readonly cards: readonly ChatCards[];
|
|
335
329
|
/** Every `checkout` event received this session, oldest first — see `checkout_handoff` (the concierge tool). */
|
|
@@ -352,6 +346,24 @@ export interface UseChatSessionResult {
|
|
|
352
346
|
readonly error?: string;
|
|
353
347
|
/** `true` once `POST /widget/session` has resolved (success or failure). */
|
|
354
348
|
readonly ready: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* The widget is picking a conversation back up, rather than starting one —
|
|
351
|
+
* DOCK_SPEC §8.6's `dock_still_here`.
|
|
352
|
+
*
|
|
353
|
+
* `true` only while the FIRST boot is in flight AND this browser already
|
|
354
|
+
* held a visitor identity, which is what makes the distinction honest: a
|
|
355
|
+
* shopper who has never spoken to this concierge is not "still here", and
|
|
356
|
+
* telling them so would be a claim about a conversation that does not
|
|
357
|
+
* exist. A returning one — the second page of the same visit, the most-seen
|
|
358
|
+
* case on a conventionally navigating storefront — gets a row that says the
|
|
359
|
+
* concierge is still there for the length of one round trip, instead of a
|
|
360
|
+
* spinner or an empty greeting that reads as having been forgotten.
|
|
361
|
+
*
|
|
362
|
+
* It is deliberately NOT the boot response's own `resumed` flag: that only
|
|
363
|
+
* arrives once the boot has resolved, which is exactly when this state is
|
|
364
|
+
* over.
|
|
365
|
+
*/
|
|
366
|
+
readonly resuming: boolean;
|
|
355
367
|
/**
|
|
356
368
|
* The widget socket's live state — see `ChatConnectionState`'s doc
|
|
357
369
|
* comment. Stays `'idle'` for the lifetime of the session when no
|
|
@@ -598,15 +610,5 @@ export interface UseChatSessionResult {
|
|
|
598
610
|
*/
|
|
599
611
|
readonly markHandoffToHuman: () => void;
|
|
600
612
|
}
|
|
601
|
-
/** What the collapsed widget shows, as the tenant configured it. */
|
|
602
|
-
export interface WidgetLauncherConfig {
|
|
603
|
-
readonly label?: string;
|
|
604
|
-
readonly position?: ConciergePosition;
|
|
605
|
-
/**
|
|
606
|
-
* May a visitor move it? Resolved by the control tier, so `undefined` here
|
|
607
|
-
* means only "the session has not booted yet" — never "we could not decide".
|
|
608
|
-
*/
|
|
609
|
-
readonly draggable?: boolean;
|
|
610
|
-
}
|
|
611
613
|
export declare function useChatSession(options: UseChatSessionOptions): UseChatSessionResult;
|
|
612
614
|
//# sourceMappingURL=use-chat-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chat-session.d.ts","sourceRoot":"","sources":["../src/use-chat-session.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAQpE,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-chat-session.d.ts","sourceRoot":"","sources":["../src/use-chat-session.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAQpE,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAUtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC;AAEtE;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,CAAC;AAEvF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,qKAAqK;IACrK,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CA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AE,EACzD,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,KAC1B,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACzC;;;;;;;;;OASG;IACH,QAAQ,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5E;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,kBAAkB,EAAE,MAAM,IAAI,CAAC;CACzC;AAgVD,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,oBAAoB,CA0vDnF"}
|
|
@@ -3,7 +3,7 @@ import type { SessionConfigPayload, TranscriptPayload, TurnCostPayload, TurnLate
|
|
|
3
3
|
import type { SessionTuning } from '@saar-ai/widget-protocol/tuning';
|
|
4
4
|
import type { WidgetToolEvent } from '@saar-ai/widget-protocol/chat';
|
|
5
5
|
import { type SessionLogEntry } from './session-log.js';
|
|
6
|
-
import { type VoicePhase } from './voice-session-state.js';
|
|
6
|
+
import { type VoicePhase, type VoiceSessionSnapshot } from './voice-session-state.js';
|
|
7
7
|
/**
|
|
8
8
|
* The widget's live call: token → room → microphone → the avatar's state.
|
|
9
9
|
*
|
|
@@ -122,6 +122,8 @@ declare function loadVoiceProtocol(): Promise<{
|
|
|
122
122
|
decodeTelemetry: typeof import("@saar-ai/widget-protocol/telemetry").decodeTelemetry;
|
|
123
123
|
encodeCallerText: typeof import("@saar-ai/widget-protocol/telemetry").encodeCallerText;
|
|
124
124
|
VOICE_CALLER_TEXT_TOPIC: string;
|
|
125
|
+
encodeCallerControl: typeof import("@saar-ai/widget-protocol/telemetry").encodeCallerControl;
|
|
126
|
+
VOICE_CALLER_CONTROL_TOPIC: string;
|
|
125
127
|
WidgetToolEventSchema: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
126
128
|
type: import("zod").ZodLiteral<"cards">;
|
|
127
129
|
curationId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -161,6 +163,16 @@ declare function loadVoiceProtocol(): Promise<{
|
|
|
161
163
|
}, import("zod/v4/core").$strip>], "type">;
|
|
162
164
|
}>;
|
|
163
165
|
export type VoiceProtocol = Awaited<ReturnType<typeof loadVoiceProtocol>>;
|
|
166
|
+
/**
|
|
167
|
+
* Why the shopper cut the agent off, when they did it without speaking.
|
|
168
|
+
*
|
|
169
|
+
* The same three `@saar-ai/widget-protocol/telemetry`'s
|
|
170
|
+
* `CALLER_INTERRUPT_REASONS` names, and `apps/voice`'s `handleCallerControl`
|
|
171
|
+
* records on the turn: `'look'` is §5.1's duck (the shopper turned to the
|
|
172
|
+
* page), `'tap'` the explicit interrupt control, `'keyboard'` a switch to
|
|
173
|
+
* text mid-reply.
|
|
174
|
+
*/
|
|
175
|
+
export type CallerInterruptReason = 'look' | 'tap' | 'keyboard';
|
|
164
176
|
/**
|
|
165
177
|
* `RoomEvent` values, as literals.
|
|
166
178
|
*
|
|
@@ -221,6 +233,19 @@ export interface VoiceSession {
|
|
|
221
233
|
readonly widgetEvents: readonly VoiceWidgetEvent[];
|
|
222
234
|
/** What the avatar should render. */
|
|
223
235
|
readonly state: BotState;
|
|
236
|
+
/**
|
|
237
|
+
* The raw call snapshot `state` is collapsed FROM — see
|
|
238
|
+
* `voice-session-state.ts`.
|
|
239
|
+
*
|
|
240
|
+
* Published because `BotState`'s four values cannot express DOCK_SPEC
|
|
241
|
+
* §5.1's nine: `botStateFor` returns `listening` both for "the caller is
|
|
242
|
+
* speaking right now" and for "the room is live and quiet", and the dock
|
|
243
|
+
* needs to tell those apart (a duck resumes on SPEECH, so a quiet room that
|
|
244
|
+
* reads as speech would resume the moment it paused). `state` stays the
|
|
245
|
+
* four-value answer every existing consumer reads; this is the fuller one
|
|
246
|
+
* beside it, not a replacement.
|
|
247
|
+
*/
|
|
248
|
+
readonly snapshot: VoiceSessionSnapshot;
|
|
224
249
|
readonly phase: VoicePhase;
|
|
225
250
|
readonly micOpen: boolean;
|
|
226
251
|
/**
|
|
@@ -236,8 +261,21 @@ export interface VoiceSession {
|
|
|
236
261
|
readonly error: string | null;
|
|
237
262
|
/** Timestamped account of the call, oldest first. */
|
|
238
263
|
readonly events: readonly SessionLogEntry[];
|
|
239
|
-
/**
|
|
240
|
-
|
|
264
|
+
/**
|
|
265
|
+
* 0..1 RMS of the agent's incoming audio — proof that sound is arriving.
|
|
266
|
+
*
|
|
267
|
+
* A LIVE REF, not a number, and that is DOCK_SPEC §7.1 rule 5, not a style
|
|
268
|
+
* preference: the analyser produces a new value on every animation frame,
|
|
269
|
+
* and a number here means `setState` sixty times a second, which re-renders
|
|
270
|
+
* every consumer of this hook — the whole dock included — for a value that
|
|
271
|
+
* only ever ends up in a CSS custom property. Read `.current` inside your
|
|
272
|
+
* own `requestAnimationFrame` and write it straight to the DOM; never put it
|
|
273
|
+
* in state, and never list it in a dependency array (the object identity is
|
|
274
|
+
* stable for the life of the hook, so it would never fire anyway).
|
|
275
|
+
*/
|
|
276
|
+
readonly agentLevelRef: {
|
|
277
|
+
readonly current: number;
|
|
278
|
+
};
|
|
241
279
|
/** Per-turn latency, newest last, as the worker measured it. */
|
|
242
280
|
readonly turns: readonly TurnLatencyPayload[];
|
|
243
281
|
/** The conversation as it settles. */
|
|
@@ -258,6 +296,44 @@ export interface VoiceSession {
|
|
|
258
296
|
toggleMic(): Promise<void>;
|
|
259
297
|
/** Send a typed turn. Resolves false when the room cannot carry one. */
|
|
260
298
|
sendText(text: string): Promise<boolean>;
|
|
299
|
+
/**
|
|
300
|
+
* DOCK_SPEC §5.2 — tell the worker the caller's utterance ENDED, because
|
|
301
|
+
* the browser knows: a hold-to-talk press bounds the first utterance by the
|
|
302
|
+
* gesture, so the endpointer does not have to find the boundary itself.
|
|
303
|
+
*
|
|
304
|
+
* Advisory in both directions. Resolves `false` when the room cannot carry
|
|
305
|
+
* it (no call, no data channel), and a worker that has never heard of the
|
|
306
|
+
* topic ignores it — which is exactly the state of the world between this
|
|
307
|
+
* change and PR 5, and is why the dock still mutes on release regardless.
|
|
308
|
+
*/
|
|
309
|
+
sendEouHint(): Promise<boolean>;
|
|
310
|
+
/**
|
|
311
|
+
* DOCK_SPEC §5.1 — the shopper is back after a duck, by speaking or by
|
|
312
|
+
* tapping the microphone. Never a timer, at either end.
|
|
313
|
+
*
|
|
314
|
+
* The other half of `interrupt('look')`: that frame left the worker holding
|
|
315
|
+
* a cancelled turn and deliberately silent, and this is what tells it the
|
|
316
|
+
* shopper is listening again. Same "resolves false rather than throwing"
|
|
317
|
+
* contract as `sendText`.
|
|
318
|
+
*/
|
|
319
|
+
sendResume(): Promise<boolean>;
|
|
320
|
+
/**
|
|
321
|
+
* DOCK_SPEC §5.1/§5.5 — a barge-in the CLIENT initiated, carrying WHY.
|
|
322
|
+
*
|
|
323
|
+
* `'look'` is the shopper turning to the merchant's page (a scroll past
|
|
324
|
+
* 24 px, a tap outside the dock, a bridge page change): §5.1's "Paused
|
|
325
|
+
* while you look" is implemented as this, through the existing cancel path
|
|
326
|
+
* and `AbandonmentTracker`, rather than as a new pause primitive.
|
|
327
|
+
* `'tap'` is a deliberate press on the interrupt control (or on the row
|
|
328
|
+
* while the agent is speaking), `'keyboard'` a switch to text mid-reply.
|
|
329
|
+
*
|
|
330
|
+
* The reason is what lets an operator's console tell a shopper who was
|
|
331
|
+
* READING from one who talked over the agent — see the enum's own comment
|
|
332
|
+
* in `@saar-ai/widget-protocol/telemetry`.
|
|
333
|
+
*
|
|
334
|
+
* Same "resolves false rather than throwing" contract as `sendText`.
|
|
335
|
+
*/
|
|
336
|
+
interrupt(reason: CallerInterruptReason): Promise<boolean>;
|
|
261
337
|
}
|
|
262
338
|
export interface WidgetVoiceTokenFetcherOptions {
|
|
263
339
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-voice-session.d.ts","sourceRoot":"","sources":["../src/use-voice-session.ts"],"names":[],"mappings":"AAIA,OA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