@genesislcap/ai-assistant 15.77.0 → 15.78.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/ai-assistant.api.json +753 -24
- package/dist/ai-assistant.d.ts +273 -3
- package/dist/chat-driver.cjs +28 -1
- package/dist/chat-driver.cjs.map +2 -2
- package/dist/chat-driver.mjs +28 -1
- package/dist/chat-driver.mjs.map +2 -2
- package/dist/custom-elements.json +636 -2
- package/dist/dts/autopilot/autopilot-driver.d.ts +28 -0
- package/dist/dts/autopilot/autopilot-driver.d.ts.map +1 -1
- package/dist/dts/channel/ai-activity-channel.d.ts +20 -2
- package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
- package/dist/dts/components/chat-bubble/chat-bubble.d.ts +2 -0
- package/dist/dts/components/chat-bubble/chat-bubble.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
- package/dist/dts/components/notification-level/index.d.ts +2 -0
- package/dist/dts/components/notification-level/index.d.ts.map +1 -0
- package/dist/dts/components/notification-level/notification-level.d.ts +51 -0
- package/dist/dts/components/notification-level/notification-level.d.ts.map +1 -0
- package/dist/dts/components/notification-level/notification-level.styles.d.ts +3 -0
- package/dist/dts/components/notification-level/notification-level.styles.d.ts.map +1 -0
- package/dist/dts/components/notification-level/notification-level.template.d.ts +5 -0
- package/dist/dts/components/notification-level/notification-level.template.d.ts.map +1 -0
- package/dist/dts/components/settings-modal/settings-modal.styles.d.ts.map +1 -1
- package/dist/dts/components/settings-modal/settings-modal.template.d.ts.map +1 -1
- package/dist/dts/index.d.ts +2 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +56 -1
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/notifications/agent-notifications.d.ts +139 -0
- package/dist/dts/notifications/agent-notifications.d.ts.map +1 -0
- package/dist/dts/notifications/agent-notifier.d.ts +58 -0
- package/dist/dts/notifications/agent-notifier.d.ts.map +1 -0
- package/dist/dts/notifications/index.d.ts +2 -0
- package/dist/dts/notifications/index.d.ts.map +1 -0
- package/dist/dts/notifications/notification-level-picker.template.d.ts +31 -0
- package/dist/dts/notifications/notification-level-picker.template.d.ts.map +1 -0
- package/dist/dts/notifications/notification-settings.d.ts +42 -0
- package/dist/dts/notifications/notification-settings.d.ts.map +1 -0
- package/dist/dts/react.d.ts +10 -0
- package/dist/dts/state/ai-assistant-slice.d.ts +8 -0
- package/dist/dts/state/ai-assistant-slice.d.ts.map +1 -1
- package/dist/dts/state/interaction-context.d.ts +13 -0
- package/dist/dts/state/interaction-context.d.ts.map +1 -1
- package/dist/dts/state/persistence/session-persistence-provider.d.ts +5 -0
- package/dist/dts/state/persistence/session-persistence-provider.d.ts.map +1 -1
- package/dist/dts/state/session-store.d.ts +1 -0
- package/dist/dts/state/session-store.d.ts.map +1 -1
- package/dist/dts/types/interaction-context.d.ts +23 -0
- package/dist/dts/types/interaction-context.d.ts.map +1 -1
- package/dist/dts/utils/resolve-preference-baseline.d.ts +3 -0
- package/dist/dts/utils/resolve-preference-baseline.d.ts.map +1 -1
- package/dist/esm/autopilot/autopilot-driver.js +66 -3
- package/dist/esm/components/chat-bubble/chat-bubble.js +17 -3
- package/dist/esm/components/chat-driver/interaction-controller.js +5 -0
- package/dist/esm/components/notification-level/index.js +1 -0
- package/dist/esm/components/notification-level/notification-level.js +124 -0
- package/dist/esm/components/notification-level/notification-level.styles.js +20 -0
- package/dist/esm/components/notification-level/notification-level.template.js +11 -0
- package/dist/esm/components/settings-modal/settings-modal.styles.js +6 -0
- package/dist/esm/components/settings-modal/settings-modal.template.js +10 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/main/main.js +159 -12
- package/dist/esm/notifications/agent-notifications.js +172 -0
- package/dist/esm/notifications/agent-notifier.js +86 -0
- package/dist/esm/notifications/index.js +1 -0
- package/dist/esm/notifications/notification-level-picker.template.js +49 -0
- package/dist/esm/notifications/notification-settings.js +42 -0
- package/dist/esm/state/ai-assistant-slice.js +5 -0
- package/dist/esm/state/interaction-context.js +27 -0
- package/dist/esm/utils/resolve-preference-baseline.js +9 -0
- package/dist/react.cjs +7 -0
- package/dist/react.mjs +6 -0
- package/docs/notifications.md +169 -0
- package/package.json +17 -17
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Agent notifications
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
When the assistant needs the person and they are not looking at the page, it can show a browser notification. This matters most with an autopilot, which can run for a long time with nobody watching.
|
|
6
|
+
|
|
7
|
+
Notifications are **off by default, always**. The browser makes the person grant permission, so only they can opt in: in the settings modal, or through an invitation the app builds itself.
|
|
8
|
+
|
|
9
|
+
Nothing is shown while the person is looking at the page (the tab is visible and focused). The in-page UI, such as the "needs you" badge on the chat bubble, covers that case.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Levels
|
|
14
|
+
|
|
15
|
+
The person picks one level. Each includes the one before it.
|
|
16
|
+
|
|
17
|
+
| Level | Settings label | Notifies when |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `'off'` | Off | Never. The default. |
|
|
20
|
+
| `'autopilot'` | Autopilot | The autopilot hands something back to the person, or stops working. |
|
|
21
|
+
| `'needs-input'` | Always (On, without the autopilot level) | Every `'autopilot'` case, plus any widget that asks for the person's attention. |
|
|
22
|
+
|
|
23
|
+
"Stops working" means anything that leaves the autopilot idle without the person having paused it: its flow ending, a turn ending with nothing left for it to answer, or a wall such as the budget. A pause the person makes themselves never notifies.
|
|
24
|
+
|
|
25
|
+
The type is `AgentNotificationLevel`.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## App configuration
|
|
30
|
+
|
|
31
|
+
In `chatConfig.ui.notifications` (`ChatNotificationsConfig`):
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
chatConfig = {
|
|
35
|
+
ui: {
|
|
36
|
+
notifications: {
|
|
37
|
+
// false: no settings row, nothing fires, and the level cannot be set. Default true.
|
|
38
|
+
enabled: true,
|
|
39
|
+
// Offer the 'autopilot' level. Turn on only in apps with an autopilot. Default false.
|
|
40
|
+
autopilot: true,
|
|
41
|
+
// Replace the default text, "The assistant is ready for your next input".
|
|
42
|
+
message: 'Your assistant needs you',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
None of these switch notifications on. They control whether the setting is offered, which levels it offers, and the text.
|
|
49
|
+
|
|
50
|
+
Without `autopilot`, the settings row is a plain Off / On, where On is `'needs-input'`.
|
|
51
|
+
|
|
52
|
+
If the person's saved level is one the app no longer offers (for example `'autopilot'` after the app removed that option), it applies as `'off'`. The saved choice is kept, so offering the level again restores it.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Asking for the person's attention from a widget
|
|
57
|
+
|
|
58
|
+
Showing a widget does not notify by itself, because some widgets only show information. A widget that waits on the person says so, explicitly, through its `InteractionContext`:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
registerInteraction('pick-template', {
|
|
62
|
+
controller: (data, ctx) => {
|
|
63
|
+
// A widget that asks straight away can call it here.
|
|
64
|
+
ctx.requestAttention('Pick a template to continue');
|
|
65
|
+
return new PickTemplateController(data, ctx);
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Call it at the moment the widget starts waiting on the person. A widget that has work to do first (loading data, running steps) calls it when its question is ready, not when it opens.
|
|
71
|
+
|
|
72
|
+
The widget never has to check who holds the interaction. The platform handles that:
|
|
73
|
+
|
|
74
|
+
- The call is reported only once the platform has decided who holds the interaction, so calling it from the controller's constructor is safe, even though the autopilot has not been offered the interaction yet.
|
|
75
|
+
- If the autopilot holds the interaction, at that point or when the widget calls, nothing is reported. If the autopilot hands it back, the hand-back notifies instead, so the person gets one notification.
|
|
76
|
+
- Only the first call counts, whatever happened to it. A widget gets at most one notification for its whole life.
|
|
77
|
+
|
|
78
|
+
The text is the first of: the argument, `chatConfig.ui.notifications.message`, the default. Only the `'needs-input'` level shows these.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Inviting the person to switch notifications on
|
|
83
|
+
|
|
84
|
+
The assistant has no built-in invitation. An app or a widget that wants one has two ways to let the person switch notifications on.
|
|
85
|
+
|
|
86
|
+
### The picker element
|
|
87
|
+
|
|
88
|
+
`<foundation-ai-notification-level>` is the same picker as the settings row, on its own. Put it wherever the invitation is:
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<p>Want a notification when the assistant needs you?</p>
|
|
92
|
+
<foundation-ai-notification-level session-key="my-session"></foundation-ai-notification-level>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
In a widget's view, pass the interaction's session, which is on its `InteractionContext`:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
html<MyWidget>`
|
|
99
|
+
<foundation-ai-notification-level
|
|
100
|
+
session-key="${(x) => x.interactionContext.sessionKey}"
|
|
101
|
+
></foundation-ai-notification-level>
|
|
102
|
+
`;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The element works through the connected assistant that holds that session, so the level is checked against what the app offers and saved, as a settings change is. It handles permission itself:
|
|
106
|
+
|
|
107
|
+
- Picking a level other than Off asks the browser for permission, inside the click. If the person refuses, it snaps back.
|
|
108
|
+
- A hint shows whenever the browser blocks notifications, and when a level is on but the browser has not been asked yet.
|
|
109
|
+
- It follows permission changes the person makes in the browser's site settings while the page is open.
|
|
110
|
+
- It shows Autopilot only when the app offers that level.
|
|
111
|
+
- It renders nothing when no connected assistant holds the session, when the app turns notifications off, or when the browser has no notifications.
|
|
112
|
+
|
|
113
|
+
It keeps in step with the settings row: a change in either shows in both.
|
|
114
|
+
|
|
115
|
+
Optional attribute: `design-system-prefix` (default `rapid`).
|
|
116
|
+
|
|
117
|
+
### Your own UI
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import {
|
|
121
|
+
agentNotificationPermission,
|
|
122
|
+
requestAgentNotificationPermission,
|
|
123
|
+
} from '@genesislcap/ai-assistant';
|
|
124
|
+
|
|
125
|
+
// 'unsupported' | 'default' | 'granted' | 'denied'
|
|
126
|
+
agentNotificationPermission();
|
|
127
|
+
|
|
128
|
+
notifyMeButton.addEventListener('click', async () => {
|
|
129
|
+
// Must run inside the person's click or key press: browsers refuse a request that does not.
|
|
130
|
+
const permission = await requestAgentNotificationPermission();
|
|
131
|
+
if (permission === 'granted') assistant.notificationLevel = 'autopilot';
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`notificationLevel` on the `foundation-ai-assistant` element is saved like a change made in settings. It is ignored when the app does not offer that level, and before the assistant has a session. Setting it does not ask for permission, so ask first. Your UI has to handle the permission states itself; the element above does it for you.
|
|
136
|
+
|
|
137
|
+
A browser that has denied permission will not ask again: the person has to allow it in the browser's site settings.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Saving
|
|
142
|
+
|
|
143
|
+
The level is saved with the other settings, in `SessionPreferences.notificationLevel`, through the session persistence provider. Without a provider, it lasts until the page reloads, like every other setting.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Activity bus
|
|
148
|
+
|
|
149
|
+
Every report is published as `agent-attention` on the activity bus, whatever the person's level:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
agenticActivityBus.subscribe('agent-attention', (detail) => {
|
|
153
|
+
// detail: { sessionKey, kind, interactionId?, message? }
|
|
154
|
+
// kind: 'widget-needs-input' | 'autopilot-handed-back' | 'autopilot-stopped'
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The assistant for that session decides whether to show a notification. An app can listen to the same event to drive its own UI. The event is tab-local: it comes from the window that owns the session's driver.
|
|
159
|
+
|
|
160
|
+
Clicking a notification focuses the window and publishes `autopilot-show-waiting` for the session: a closed chat bubble holding that assistant opens, and the assistant brings what waits on the person into view.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Duplicates
|
|
165
|
+
|
|
166
|
+
- Each notification carries a tag. The browser replaces a notification with the same tag rather than stacking copies.
|
|
167
|
+
- One interaction gets one tag, whichever report it came from: the autopilot handing it back, or the widget asking for attention.
|
|
168
|
+
- The autopilot's other reports share one tag per session.
|
|
169
|
+
- The same tag is not shown again within a few seconds.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/ai-assistant",
|
|
3
3
|
"description": "Genesis AI Assistant micro-frontend",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.78.0",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/ai-assistant.d.ts",
|
|
@@ -92,31 +92,31 @@
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@genesislcap/foundation-comms": "15.
|
|
96
|
-
"@genesislcap/foundation-testing": "15.
|
|
97
|
-
"@genesislcap/genx": "15.
|
|
98
|
-
"@genesislcap/ts-builder": "15.
|
|
99
|
-
"@genesislcap/uvu-playwright-builder": "15.
|
|
100
|
-
"@genesislcap/vite-builder": "15.
|
|
101
|
-
"@genesislcap/webpack-builder": "15.
|
|
95
|
+
"@genesislcap/foundation-comms": "15.78.0",
|
|
96
|
+
"@genesislcap/foundation-testing": "15.78.0",
|
|
97
|
+
"@genesislcap/genx": "15.78.0",
|
|
98
|
+
"@genesislcap/ts-builder": "15.78.0",
|
|
99
|
+
"@genesislcap/uvu-playwright-builder": "15.78.0",
|
|
100
|
+
"@genesislcap/vite-builder": "15.78.0",
|
|
101
|
+
"@genesislcap/webpack-builder": "15.78.0",
|
|
102
102
|
"@types/dompurify": "^3.0.5",
|
|
103
103
|
"@types/marked": "^5.0.2",
|
|
104
104
|
"esbuild": "0.25.12"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@genesislcap/foundation-ai": "15.
|
|
108
|
-
"@genesislcap/foundation-logger": "15.
|
|
109
|
-
"@genesislcap/foundation-notifications": "15.
|
|
110
|
-
"@genesislcap/foundation-redux": "15.
|
|
111
|
-
"@genesislcap/foundation-ui": "15.
|
|
112
|
-
"@genesislcap/foundation-utils": "15.
|
|
113
|
-
"@genesislcap/rapid-design-system": "15.
|
|
114
|
-
"@genesislcap/web-core": "15.
|
|
107
|
+
"@genesislcap/foundation-ai": "15.78.0",
|
|
108
|
+
"@genesislcap/foundation-logger": "15.78.0",
|
|
109
|
+
"@genesislcap/foundation-notifications": "15.78.0",
|
|
110
|
+
"@genesislcap/foundation-redux": "15.78.0",
|
|
111
|
+
"@genesislcap/foundation-ui": "15.78.0",
|
|
112
|
+
"@genesislcap/foundation-utils": "15.78.0",
|
|
113
|
+
"@genesislcap/rapid-design-system": "15.78.0",
|
|
114
|
+
"@genesislcap/web-core": "15.78.0",
|
|
115
115
|
"dompurify": "^3.3.1",
|
|
116
116
|
"marked": "^17.0.3"
|
|
117
117
|
},
|
|
118
118
|
"peerDependencies": {
|
|
119
|
-
"@genesislcap/foundation-comms": "^15.
|
|
119
|
+
"@genesislcap/foundation-comms": "^15.78.0"
|
|
120
120
|
},
|
|
121
121
|
"peerDependenciesMeta": {
|
|
122
122
|
"@genesislcap/foundation-comms": {
|