@proveanything/smartlinks 2.2.12 → 2.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/aiGuide.js +5 -0
- package/dist/docs/API_SUMMARY.md +1 -1
- package/dist/docs/customer-guide.md +74 -70
- package/dist/index.d.ts +1 -1
- package/dist/live.d.ts +14 -0
- package/dist/live.js +14 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/API_SUMMARY.md +1 -1
- package/docs/customer-guide.md +74 -70
- package/package.json +1 -1
package/dist/api/aiGuide.js
CHANGED
|
@@ -75,6 +75,11 @@ export var guide;
|
|
|
75
75
|
},
|
|
76
76
|
tool: (name, args, sessionId) => post(`${base(collectionId)}/tool`, { name, args, sessionId }),
|
|
77
77
|
event: (event) => { void post(`${base(collectionId)}/event`, event).catch(() => undefined); },
|
|
78
|
+
// What each reply used: the business is charged for it. One retry; a repeat is counted once.
|
|
79
|
+
usage: (report) => {
|
|
80
|
+
const send = () => post(`${base(collectionId)}/usage`, report);
|
|
81
|
+
void send().catch(() => new Promise((r) => setTimeout(r, 3000)).then(send)).catch(() => undefined);
|
|
82
|
+
},
|
|
78
83
|
},
|
|
79
84
|
onToolReply: async (_name, reply) => {
|
|
80
85
|
var _a, _b;
|
package/dist/docs/API_SUMMARY.md
CHANGED
|
@@ -1,70 +1,74 @@
|
|
|
1
|
-
# The customer guide
|
|
2
|
-
|
|
3
|
-
A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
|
|
4
|
-
(a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
|
|
5
|
-
what that screen says, and it can open another app for them. The business switches it on and shapes it in
|
|
6
|
-
Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
|
|
7
|
-
|
|
8
|
-
Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
|
|
9
|
-
conversation starts. A page only says where the visitor is and what is on their screen.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## For a host (Portal, the Hub, a custom site)
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import * as SL from '@proveanything/smartlinks'
|
|
17
|
-
|
|
18
|
-
const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
|
|
19
|
-
if (!info.enabled) return
|
|
20
|
-
|
|
21
|
-
const chat = await SL.ai.guide.start(collectionId, {
|
|
22
|
-
surface: 'portal', // or 'hub'
|
|
23
|
-
mode: info.modes.start, // 'voice' or 'text'
|
|
24
|
-
productId, proofId,
|
|
25
|
-
apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
|
|
26
|
-
where: { appId: 'recipes', path: '/method' }, // where the visitor is now
|
|
27
|
-
screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
|
|
28
|
-
showApp: (appId) => openApp(appId),
|
|
29
|
-
openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
|
|
30
|
-
goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
|
|
31
|
-
onShow: (card) => showFound(card), // what find found, rows with goTo
|
|
32
|
-
offerPerson: (handoff) => showContact(handoff),
|
|
33
|
-
onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
|
|
34
|
-
onCaption: setCaption, // what it is saying or writing, as it goes
|
|
35
|
-
onError: setError,
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
chat.pause(); chat.resume(); chat.stop()
|
|
39
|
-
chat.send('What is it made of?') // text mode (works in voice mode too)
|
|
40
|
-
chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
|
|
44
|
-
manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
|
|
45
|
-
Register your pages there and the guide can open them by name.
|
|
46
|
-
|
|
47
|
-
- Voice needs the microphone; ask for it on a tap (browsers require it).
|
|
48
|
-
- A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
|
|
49
|
-
- The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
|
|
50
|
-
it yourself.
|
|
51
|
-
- Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
# The customer guide
|
|
2
|
+
|
|
3
|
+
A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
|
|
4
|
+
(a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
|
|
5
|
+
what that screen says, and it can open another app for them. The business switches it on and shapes it in
|
|
6
|
+
Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
|
|
7
|
+
|
|
8
|
+
Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
|
|
9
|
+
conversation starts. A page only says where the visitor is and what is on their screen.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## For a host (Portal, the Hub, a custom site)
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import * as SL from '@proveanything/smartlinks'
|
|
17
|
+
|
|
18
|
+
const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
|
|
19
|
+
if (!info.enabled) return
|
|
20
|
+
|
|
21
|
+
const chat = await SL.ai.guide.start(collectionId, {
|
|
22
|
+
surface: 'portal', // or 'hub'
|
|
23
|
+
mode: info.modes.start, // 'voice' or 'text'
|
|
24
|
+
productId, proofId,
|
|
25
|
+
apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
|
|
26
|
+
where: { appId: 'recipes', path: '/method' }, // where the visitor is now
|
|
27
|
+
screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
|
|
28
|
+
showApp: (appId) => openApp(appId),
|
|
29
|
+
openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
|
|
30
|
+
goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
|
|
31
|
+
onShow: (card) => showFound(card), // what find found, rows with goTo
|
|
32
|
+
offerPerson: (handoff) => showContact(handoff),
|
|
33
|
+
onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
|
|
34
|
+
onCaption: setCaption, // what it is saying or writing, as it goes
|
|
35
|
+
onError: setError,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
chat.pause(); chat.resume(); chat.stop()
|
|
39
|
+
chat.send('What is it made of?') // text mode (works in voice mode too)
|
|
40
|
+
chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
|
|
44
|
+
manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
|
|
45
|
+
Register your pages there and the guide can open them by name.
|
|
46
|
+
|
|
47
|
+
- Voice needs the microphone; ask for it on a tap (browsers require it).
|
|
48
|
+
- A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
|
|
49
|
+
- The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
|
|
50
|
+
it yourself.
|
|
51
|
+
- Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
|
|
52
|
+
- Conversations run on the business's AI credits. With none left the guide doesn't start: `GUIDE_PAUSED`
|
|
53
|
+
(402), with a plain message to show. Each reply's usage is passed back to SmartLinks for charging
|
|
54
|
+
automatically (`ai.guide.start` does this; a custom client built on `startLive` should set
|
|
55
|
+
`endpoints.usage`).
|
|
56
|
+
|
|
57
|
+
## For an app: say what your screen shows
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
useEffect(() => SL.ai.content.provide(() => ({
|
|
61
|
+
appId: 'pages',
|
|
62
|
+
title: page.title,
|
|
63
|
+
content: page.text, // plain words: the exhibit, the recipe, what this form is for
|
|
64
|
+
})), [page])
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`provide` works the same in an iframe (the host asks by message) and as a direct component. Return what a
|
|
68
|
+
person reading the screen would take in, not markup. Without it, a host may fall back to the page's text.
|
|
69
|
+
|
|
70
|
+
## Your own live conversation
|
|
71
|
+
|
|
72
|
+
`SL.ai.live.start({ endpoints: { mint, tool, event }, mode, screenTools, … })` is the client the guide and the
|
|
73
|
+
Studio assistant use: WebRTC straight to the realtime service with a key your server minted, tools split
|
|
74
|
+
between the page (`screenTools`) and your server (`endpoints.tool`). See `src/live.ts`.
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { normaliseAdminCardPayload, ADMIN_CARD_MAX_BYTES } from './adminCardPayl
|
|
|
24
24
|
export { SHARED_DEPENDENCY_CONTRACT_VERSION, SHARED_DEPENDENCIES, SHARED_DEPENDENCY_SPECIFIERS, importMapPathFor, getHostSharedDependencies, } from './shared-dependencies.js';
|
|
25
25
|
export type { SharedDependency, HostSharedDependencies } from './shared-dependencies.js';
|
|
26
26
|
export type { GuideSurface, GuideInfo, ScreenContent, GuideWhere, GuideNavigate, GuideCard, GuideStartOptions } from './api/aiGuide.js';
|
|
27
|
-
export type { LiveState, LiveHandle, LiveOptions, LiveEndpoints, LiveEvent, LiveMintReply, LiveToolReply, LiveToolHandler } from './live.js';
|
|
27
|
+
export type { LiveState, LiveHandle, LiveOptions, LiveEndpoints, LiveEvent, LiveMintReply, LiveToolReply, LiveToolHandler, LiveUsageReport } from './live.js';
|
|
28
28
|
export { API_VERSION, SDK_VERSION, API_VERSION_HEADER, SDK_HEADER, APP_HEADER, CLIENT_HEADER_NAMES } from './apiVersion.js';
|
|
29
29
|
export { AI_TOOL_NAMES, BUILTIN_AI_TOOLS, getBuiltinAiTool } from './ai-tools.js';
|
|
30
30
|
export type { BuiltinAiToolDescriptor } from './ai-tools.js';
|
package/dist/live.d.ts
CHANGED
|
@@ -37,6 +37,20 @@ export interface LiveEndpoints {
|
|
|
37
37
|
tool: (name: string, args: Record<string, unknown>, sessionId: string | null) => Promise<LiveToolReply>;
|
|
38
38
|
/** Log what happened here, into SmartLinks' logs. Fire and forget. */
|
|
39
39
|
event?: (event: LiveEvent) => void;
|
|
40
|
+
/**
|
|
41
|
+
* What one reply used, as the provider reported it at the end of the reply (`response.usage`).
|
|
42
|
+
* SmartLinks charges live conversations from these reports, so every client should pass them on.
|
|
43
|
+
* Fire and forget; a repeated report of the same reply is counted once.
|
|
44
|
+
*/
|
|
45
|
+
usage?: (report: LiveUsageReport) => void;
|
|
46
|
+
}
|
|
47
|
+
/** One reply's usage, passed on for charging. */
|
|
48
|
+
export interface LiveUsageReport {
|
|
49
|
+
sessionId: string;
|
|
50
|
+
/** The provider's id for the reply: each is counted once. */
|
|
51
|
+
responseId: string;
|
|
52
|
+
/** The provider's usage numbers for the reply, as given. */
|
|
53
|
+
usage: Record<string, unknown>;
|
|
40
54
|
}
|
|
41
55
|
export interface LiveOptions {
|
|
42
56
|
endpoints: LiveEndpoints;
|
package/dist/live.js
CHANGED
|
@@ -124,12 +124,12 @@ export async function startLive(opts) {
|
|
|
124
124
|
send({ type: 'conversation.item.create', item: { type: 'function_call_output', call_id: call.call_id, output: JSON.stringify(output !== null && output !== void 0 ? output : {}) } });
|
|
125
125
|
}
|
|
126
126
|
dc.onmessage = (e) => {
|
|
127
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
127
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
128
128
|
let ev;
|
|
129
129
|
try {
|
|
130
130
|
ev = JSON.parse(String(e.data));
|
|
131
131
|
}
|
|
132
|
-
catch (
|
|
132
|
+
catch (_o) {
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
const type = String((_a = ev['type']) !== null && _a !== void 0 ? _a : '');
|
|
@@ -161,7 +161,14 @@ export async function startLive(opts) {
|
|
|
161
161
|
log({ kind: 'reply', detail: caption.trim().slice(0, 300) });
|
|
162
162
|
}
|
|
163
163
|
const response = ((_e = ev['response']) !== null && _e !== void 0 ? _e : {});
|
|
164
|
-
|
|
164
|
+
// Every reply (finished or cut short) is charged from what the provider says it used.
|
|
165
|
+
if (sessionId && typeof response.id === 'string' && response.usage && typeof response.usage === 'object') {
|
|
166
|
+
try {
|
|
167
|
+
(_g = (_f = opts.endpoints).usage) === null || _g === void 0 ? void 0 : _g.call(_f, { sessionId, responseId: response.id, usage: response.usage });
|
|
168
|
+
}
|
|
169
|
+
catch ( /* never stops the conversation */_p) { /* never stops the conversation */ }
|
|
170
|
+
}
|
|
171
|
+
const calls = ((_h = response.output) !== null && _h !== void 0 ? _h : []).filter((o) => o['type'] === 'function_call');
|
|
165
172
|
if (calls.length) {
|
|
166
173
|
setState('thinking');
|
|
167
174
|
void Promise.all(calls.map((c) => { var _a, _b, _c; return runTool({ name: String((_a = c['name']) !== null && _a !== void 0 ? _a : ''), call_id: String((_b = c['call_id']) !== null && _b !== void 0 ? _b : ''), arguments: String((_c = c['arguments']) !== null && _c !== void 0 ? _c : '') }); }))
|
|
@@ -174,13 +181,13 @@ export async function startLive(opts) {
|
|
|
174
181
|
setState('listening');
|
|
175
182
|
}
|
|
176
183
|
else if (type === 'error') {
|
|
177
|
-
const err = ((
|
|
178
|
-
const message = String((
|
|
184
|
+
const err = ((_j = ev['error']) !== null && _j !== void 0 ? _j : {});
|
|
185
|
+
const message = String((_k = err['message']) !== null && _k !== void 0 ? _k : 'The assistant hit a problem');
|
|
179
186
|
// "Nothing to cancel" (a pause or a stop between replies) is not a problem: say nothing.
|
|
180
|
-
if (HARMLESS.test(String((
|
|
187
|
+
if (HARMLESS.test(String((_l = err['code']) !== null && _l !== void 0 ? _l : '')) || HARMLESS.test(message))
|
|
181
188
|
return;
|
|
182
189
|
log({ kind: 'error', error: message, detail: 'realtime service' });
|
|
183
|
-
(
|
|
190
|
+
(_m = opts.onError) === null || _m === void 0 ? void 0 : _m.call(opts, message);
|
|
184
191
|
}
|
|
185
192
|
};
|
|
186
193
|
pc.onconnectionstatechange = () => {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.2.
|
|
1
|
+
export declare const SDK_VERSION = "2.2.13";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by scripts/write-version.mjs from package.json. Do not edit.
|
|
2
|
-
export const SDK_VERSION = "2.2.
|
|
2
|
+
export const SDK_VERSION = "2.2.13";
|
package/docs/API_SUMMARY.md
CHANGED
package/docs/customer-guide.md
CHANGED
|
@@ -1,70 +1,74 @@
|
|
|
1
|
-
# The customer guide
|
|
2
|
-
|
|
3
|
-
A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
|
|
4
|
-
(a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
|
|
5
|
-
what that screen says, and it can open another app for them. The business switches it on and shapes it in
|
|
6
|
-
Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
|
|
7
|
-
|
|
8
|
-
Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
|
|
9
|
-
conversation starts. A page only says where the visitor is and what is on their screen.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## For a host (Portal, the Hub, a custom site)
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import * as SL from '@proveanything/smartlinks'
|
|
17
|
-
|
|
18
|
-
const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
|
|
19
|
-
if (!info.enabled) return
|
|
20
|
-
|
|
21
|
-
const chat = await SL.ai.guide.start(collectionId, {
|
|
22
|
-
surface: 'portal', // or 'hub'
|
|
23
|
-
mode: info.modes.start, // 'voice' or 'text'
|
|
24
|
-
productId, proofId,
|
|
25
|
-
apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
|
|
26
|
-
where: { appId: 'recipes', path: '/method' }, // where the visitor is now
|
|
27
|
-
screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
|
|
28
|
-
showApp: (appId) => openApp(appId),
|
|
29
|
-
openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
|
|
30
|
-
goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
|
|
31
|
-
onShow: (card) => showFound(card), // what find found, rows with goTo
|
|
32
|
-
offerPerson: (handoff) => showContact(handoff),
|
|
33
|
-
onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
|
|
34
|
-
onCaption: setCaption, // what it is saying or writing, as it goes
|
|
35
|
-
onError: setError,
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
chat.pause(); chat.resume(); chat.stop()
|
|
39
|
-
chat.send('What is it made of?') // text mode (works in voice mode too)
|
|
40
|
-
chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
|
|
44
|
-
manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
|
|
45
|
-
Register your pages there and the guide can open them by name.
|
|
46
|
-
|
|
47
|
-
- Voice needs the microphone; ask for it on a tap (browsers require it).
|
|
48
|
-
- A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
|
|
49
|
-
- The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
|
|
50
|
-
it yourself.
|
|
51
|
-
- Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
# The customer guide
|
|
2
|
+
|
|
3
|
+
A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
|
|
4
|
+
(a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
|
|
5
|
+
what that screen says, and it can open another app for them. The business switches it on and shapes it in
|
|
6
|
+
Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
|
|
7
|
+
|
|
8
|
+
Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
|
|
9
|
+
conversation starts. A page only says where the visitor is and what is on their screen.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## For a host (Portal, the Hub, a custom site)
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import * as SL from '@proveanything/smartlinks'
|
|
17
|
+
|
|
18
|
+
const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
|
|
19
|
+
if (!info.enabled) return
|
|
20
|
+
|
|
21
|
+
const chat = await SL.ai.guide.start(collectionId, {
|
|
22
|
+
surface: 'portal', // or 'hub'
|
|
23
|
+
mode: info.modes.start, // 'voice' or 'text'
|
|
24
|
+
productId, proofId,
|
|
25
|
+
apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
|
|
26
|
+
where: { appId: 'recipes', path: '/method' }, // where the visitor is now
|
|
27
|
+
screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
|
|
28
|
+
showApp: (appId) => openApp(appId),
|
|
29
|
+
openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
|
|
30
|
+
goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
|
|
31
|
+
onShow: (card) => showFound(card), // what find found, rows with goTo
|
|
32
|
+
offerPerson: (handoff) => showContact(handoff),
|
|
33
|
+
onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
|
|
34
|
+
onCaption: setCaption, // what it is saying or writing, as it goes
|
|
35
|
+
onError: setError,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
chat.pause(); chat.resume(); chat.stop()
|
|
39
|
+
chat.send('What is it made of?') // text mode (works in voice mode too)
|
|
40
|
+
chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
|
|
44
|
+
manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
|
|
45
|
+
Register your pages there and the guide can open them by name.
|
|
46
|
+
|
|
47
|
+
- Voice needs the microphone; ask for it on a tap (browsers require it).
|
|
48
|
+
- A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
|
|
49
|
+
- The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
|
|
50
|
+
it yourself.
|
|
51
|
+
- Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
|
|
52
|
+
- Conversations run on the business's AI credits. With none left the guide doesn't start: `GUIDE_PAUSED`
|
|
53
|
+
(402), with a plain message to show. Each reply's usage is passed back to SmartLinks for charging
|
|
54
|
+
automatically (`ai.guide.start` does this; a custom client built on `startLive` should set
|
|
55
|
+
`endpoints.usage`).
|
|
56
|
+
|
|
57
|
+
## For an app: say what your screen shows
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
useEffect(() => SL.ai.content.provide(() => ({
|
|
61
|
+
appId: 'pages',
|
|
62
|
+
title: page.title,
|
|
63
|
+
content: page.text, // plain words: the exhibit, the recipe, what this form is for
|
|
64
|
+
})), [page])
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`provide` works the same in an iframe (the host asks by message) and as a direct component. Return what a
|
|
68
|
+
person reading the screen would take in, not markup. Without it, a host may fall back to the page's text.
|
|
69
|
+
|
|
70
|
+
## Your own live conversation
|
|
71
|
+
|
|
72
|
+
`SL.ai.live.start({ endpoints: { mint, tool, event }, mode, screenTools, … })` is the client the guide and the
|
|
73
|
+
Studio assistant use: WebRTC straight to the realtime service with a key your server minted, tools split
|
|
74
|
+
between the page (`screenTools`) and your server (`endpoints.tool`). See `src/live.ts`.
|