@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,124 @@
|
|
|
1
|
+
import { __awaiter, __decorate } from "tslib";
|
|
2
|
+
import { attr, customElement, GenesisElement, html, observable } from '@genesislcap/web-core';
|
|
3
|
+
import { agenticActivityBus } from '../../channel/ai-activity-bus';
|
|
4
|
+
import { agentNotificationPermission, chooseAgentNotificationLevel, notificationPermissionHint, watchAgentNotificationPermission, } from '../../notifications/agent-notifications';
|
|
5
|
+
import { notificationSettingsFor, } from '../../notifications/notification-settings';
|
|
6
|
+
import { styles } from './notification-level.styles';
|
|
7
|
+
import { AiNotificationLevelTemplate } from './notification-level.template';
|
|
8
|
+
/**
|
|
9
|
+
* The agent notification level picker on its own (GENC-1676), for an app or a widget's view to
|
|
10
|
+
* place wherever it invites the person to switch notifications on. The same control as the
|
|
11
|
+
* assistant's settings row, and the same behaviour: picking a level asks the browser for
|
|
12
|
+
* permission inside the click and snaps back if refused, the hint says when the browser blocks
|
|
13
|
+
* notifications, and the Autopilot level shows only when the app offers it.
|
|
14
|
+
*
|
|
15
|
+
* It works on the session in `session-key`, through the connected assistant that holds it, so
|
|
16
|
+
* the level is checked and saved as a settings change is. It renders nothing while no connected
|
|
17
|
+
* assistant holds that session, while the app turns notifications off, or where the browser has
|
|
18
|
+
* no notifications.
|
|
19
|
+
*
|
|
20
|
+
* In a widget, pass the interaction's session:
|
|
21
|
+
*
|
|
22
|
+
* ```html
|
|
23
|
+
* <foundation-ai-notification-level session-key="${(x) => x.interactionContext.sessionKey}">
|
|
24
|
+
* </foundation-ai-notification-level>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
let AiNotificationLevel = class AiNotificationLevel extends GenesisElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.designSystemPrefix = 'rapid';
|
|
33
|
+
/** The browser's notification permission, followed while connected. @internal */
|
|
34
|
+
this.notificationPermission = 'unsupported';
|
|
35
|
+
/** See `NotificationLevelPickerSource`. @internal */
|
|
36
|
+
this.notificationPickerRevision = 0;
|
|
37
|
+
/** Bumped whenever the session's settings may have changed, so the getters re-read. @internal */
|
|
38
|
+
this.settingsRevision = 0;
|
|
39
|
+
}
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
super.connectedCallback();
|
|
42
|
+
this.notificationPermission = agentNotificationPermission();
|
|
43
|
+
const unsubSettings = agenticActivityBus.subscribe('notification-settings-changed', (d) => {
|
|
44
|
+
if (d.sessionKey === this.sessionKey)
|
|
45
|
+
this.settingsRevision += 1;
|
|
46
|
+
});
|
|
47
|
+
const unwatchPermission = watchAgentNotificationPermission((permission) => {
|
|
48
|
+
this.notificationPermission = permission;
|
|
49
|
+
});
|
|
50
|
+
this.unwire = () => {
|
|
51
|
+
unsubSettings();
|
|
52
|
+
unwatchPermission();
|
|
53
|
+
};
|
|
54
|
+
this.settingsRevision += 1;
|
|
55
|
+
}
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
var _a;
|
|
58
|
+
super.disconnectedCallback();
|
|
59
|
+
(_a = this.unwire) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
60
|
+
this.unwire = undefined;
|
|
61
|
+
}
|
|
62
|
+
sessionKeyChanged() {
|
|
63
|
+
this.settingsRevision += 1;
|
|
64
|
+
}
|
|
65
|
+
get host() {
|
|
66
|
+
void this.settingsRevision;
|
|
67
|
+
return notificationSettingsFor(this.sessionKey);
|
|
68
|
+
}
|
|
69
|
+
/** Whether to render: a connected assistant holds the session, offers it, and the browser can. @internal */
|
|
70
|
+
get offered() {
|
|
71
|
+
var _a;
|
|
72
|
+
return !!((_a = this.host) === null || _a === void 0 ? void 0 : _a.offered()) && this.notificationPermission !== 'unsupported';
|
|
73
|
+
}
|
|
74
|
+
/** See `NotificationLevelPickerSource`. @internal */
|
|
75
|
+
get effectiveNotificationLevel() {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
return (_b = (_a = this.host) === null || _a === void 0 ? void 0 : _a.effectiveLevel()) !== null && _b !== void 0 ? _b : 'off';
|
|
78
|
+
}
|
|
79
|
+
/** See `NotificationLevelPickerSource`. @internal */
|
|
80
|
+
get notificationAutopilotOffered() {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
return (_b = (_a = this.host) === null || _a === void 0 ? void 0 : _a.autopilotOffered()) !== null && _b !== void 0 ? _b : false;
|
|
83
|
+
}
|
|
84
|
+
/** The hint under the picker when the browser will not show notifications. @internal */
|
|
85
|
+
get permissionHint() {
|
|
86
|
+
return notificationPermissionHint(this.effectiveNotificationLevel, this.notificationPermission);
|
|
87
|
+
}
|
|
88
|
+
/** See `NotificationLevelPickerSource`. @internal */
|
|
89
|
+
chooseNotificationLevel(level) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const host = this.host;
|
|
92
|
+
if (!host)
|
|
93
|
+
return;
|
|
94
|
+
const outcome = yield chooseAgentNotificationLevel(level, host.effectiveLevel(), (next) => host.setLevel(next));
|
|
95
|
+
if (outcome === 'refused')
|
|
96
|
+
this.notificationPickerRevision += 1;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
__decorate([
|
|
101
|
+
attr({ attribute: 'session-key' })
|
|
102
|
+
], AiNotificationLevel.prototype, "sessionKey", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
attr({ attribute: 'design-system-prefix' })
|
|
105
|
+
], AiNotificationLevel.prototype, "designSystemPrefix", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
observable
|
|
108
|
+
], AiNotificationLevel.prototype, "notificationPermission", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
observable
|
|
111
|
+
], AiNotificationLevel.prototype, "notificationPickerRevision", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
observable
|
|
114
|
+
], AiNotificationLevel.prototype, "settingsRevision", void 0);
|
|
115
|
+
AiNotificationLevel = __decorate([
|
|
116
|
+
customElement({
|
|
117
|
+
name: 'foundation-ai-notification-level',
|
|
118
|
+
template: html `
|
|
119
|
+
${(x) => AiNotificationLevelTemplate(x.designSystemPrefix)}
|
|
120
|
+
`,
|
|
121
|
+
styles,
|
|
122
|
+
})
|
|
123
|
+
], AiNotificationLevel);
|
|
124
|
+
export { AiNotificationLevel };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { css } from '@genesislcap/web-core';
|
|
2
|
+
/** The picker and its hint, laid out like the assistant's own settings row. */
|
|
3
|
+
export const styles = css `
|
|
4
|
+
:host {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: calc(var(--design-unit) * 1px);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:host([hidden]) {
|
|
11
|
+
display: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.hint {
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
color: var(--neutral-foreground-hint);
|
|
17
|
+
line-height: 1.4;
|
|
18
|
+
font-style: italic;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { html, when } from '@genesislcap/web-core';
|
|
2
|
+
import { notificationLevelPickerTemplate } from '../../notifications/notification-level-picker.template';
|
|
3
|
+
/** The shared picker, then the permission hint while there is one. Nothing while not offered. */
|
|
4
|
+
export const AiNotificationLevelTemplate = (designSystemPrefix) => html `
|
|
5
|
+
${when((x) => x.offered, html `
|
|
6
|
+
${notificationLevelPickerTemplate(`${designSystemPrefix}-segmented-control`, `${designSystemPrefix}-segmented-item`)}
|
|
7
|
+
${when((x) => !!x.permissionHint, html `
|
|
8
|
+
<div class="hint" part="hint">${(x) => x.permissionHint}</div>
|
|
9
|
+
`)}
|
|
10
|
+
`)}
|
|
11
|
+
`;
|
|
@@ -274,6 +274,12 @@ export const settingsModalStyles = css `
|
|
|
274
274
|
font-style: italic;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
/* A row's own hint, under its description: lined up with it, not indented. */
|
|
278
|
+
.settings-toggle-text .settings-toggle-hint {
|
|
279
|
+
padding-left: 0;
|
|
280
|
+
margin-top: calc(var(--design-unit) * 1px);
|
|
281
|
+
}
|
|
282
|
+
|
|
277
283
|
/*
|
|
278
284
|
* The budget meter (GENC-1464) is the context indicator's money sibling and
|
|
279
285
|
* shares its row anatomy 1:1, so the budget classes JOIN these rules rather
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { html, ref, repeat, slotted, when } from '@genesislcap/web-core';
|
|
2
2
|
import { ANIMATION_DEFS, } from '../../main/main.types';
|
|
3
|
+
import { notificationLevelPickerTemplate } from '../../notifications/notification-level-picker.template';
|
|
3
4
|
import { formatCostSessionDate, } from '../../utils/cost-session-history';
|
|
4
5
|
import { formatUsd, formatUsdAmount } from '../../utils/format-usd';
|
|
5
6
|
import { formatCompactTokenCountSafe } from '../../utils/sum-tokens';
|
|
@@ -143,11 +144,16 @@ const SETTINGS_ROW_LAYOUT_CLASS = {
|
|
|
143
144
|
column: 'is-stacked',
|
|
144
145
|
};
|
|
145
146
|
/** Shared label + control row used for switches, buttons, and multiselects. */
|
|
146
|
-
const settingsToggleRow = (title, description, part, control, layout = 'row'
|
|
147
|
+
const settingsToggleRow = (title, description, part, control, layout = 'row',
|
|
148
|
+
/** A footnote under the description, shown while it is non-empty: inside the row, above its divider. */
|
|
149
|
+
hint) => html `
|
|
147
150
|
<div class="settings-toggle-row ${SETTINGS_ROW_LAYOUT_CLASS[layout]}" part="${part}-row">
|
|
148
151
|
<div class="settings-toggle-text">
|
|
149
152
|
<div class="settings-toggle-title">${title}</div>
|
|
150
153
|
<div class="settings-toggle-desc">${description}</div>
|
|
154
|
+
${when((x) => !!(hint === null || hint === void 0 ? void 0 : hint(x)), html `
|
|
155
|
+
<div class="settings-toggle-hint" part="${part}-hint">${(x) => { var _a; return (_a = hint === null || hint === void 0 ? void 0 : hint(x)) !== null && _a !== void 0 ? _a : ''; }}</div>
|
|
156
|
+
`)}
|
|
151
157
|
</div>
|
|
152
158
|
<div class="settings-toggle-control">${control}</div>
|
|
153
159
|
</div>
|
|
@@ -332,6 +338,9 @@ const chatBotSettingsTemplate = (switchTag, buttonTag, segmentedControlTag, segm
|
|
|
332
338
|
x.showAgentSwitchIndicator = readSwitchChecked(c.event);
|
|
333
339
|
}))}
|
|
334
340
|
${settingsToggleRow('Show timestamps', 'Show when each message was sent, next to the sender name. Screen readers announce the full date in either visible mode.', 'toggle-timestamps', timestampModePickerTemplate(segmentedControlTag, segmentedItemTag))}
|
|
341
|
+
${when((x) => x.notificationSettingVisible, settingsToggleRow('Notify me when the assistant needs me', (x) => x.notificationAutopilotOffered
|
|
342
|
+
? 'A browser notification while this tab is in the background. Autopilot notifies only when the autopilot hands back to you or stops.'
|
|
343
|
+
: 'A browser notification while this tab is in the background.', 'toggle-notifications', notificationLevelPickerTemplate(segmentedControlTag, segmentedItemTag), 'row', (x) => x.notificationPermissionHint))}
|
|
335
344
|
${when((x) => x.persistenceToggleable, chatBotToggleRow('Remember chat', 'Save this conversation so it can be restored after a page refresh. Turning this off deletes the saved copy.', switchTag, 'toggle-remember-chat', (x) => x.persistenceActive, (x, c) => {
|
|
336
345
|
x.setPersistenceEnabled(readSwitchChecked(c.event));
|
|
337
346
|
}))}
|
package/dist/esm/index.js
CHANGED
|
@@ -8,8 +8,10 @@ export * from './components/ai-driver';
|
|
|
8
8
|
export * from './components/chat-driver';
|
|
9
9
|
export * from './components/orchestrating-driver';
|
|
10
10
|
export * from './components/popout-manager';
|
|
11
|
+
export * from './components/notification-level';
|
|
11
12
|
export * from './channel/ai-activity-channel';
|
|
12
13
|
export * from './channel/ai-activity-bus';
|
|
14
|
+
export * from './notifications';
|
|
13
15
|
export * from './config/config';
|
|
14
16
|
export * from './config/define-stateful-agent';
|
|
15
17
|
export * from './config/fallback-agents';
|
package/dist/esm/main/main.js
CHANGED
|
@@ -40,10 +40,14 @@ import { AiChatMarkdown } from '../components/chat-markdown/chat-markdown';
|
|
|
40
40
|
import { AiFlowingWavesIndicator } from '../components/flowing-waves-indicator';
|
|
41
41
|
import { AiHaloOverlay } from '../components/halo-overlay';
|
|
42
42
|
import { isRateableReply, MessageFeedback, replyKey, } from '../components/message-feedback/message-feedback';
|
|
43
|
+
import { AiNotificationLevel } from '../components/notification-level/notification-level';
|
|
43
44
|
import { asOrchestrator, OrchestratingDriver, } from '../components/orchestrating-driver/orchestrating-driver';
|
|
44
45
|
import { AiPlasmaOrbIndicator } from '../components/plasma-orb-indicator';
|
|
45
46
|
import { SettingsModalController, } from '../components/settings-modal';
|
|
46
47
|
import { AiWavesIndicator } from '../components/waves-indicator';
|
|
48
|
+
import { agentNotificationPermission, asAgentNotificationLevel, belongsToSession, chooseAgentNotificationLevel, effectiveNotificationLevel, levelOffered, notificationPermissionHint, notificationsOffered, watchAgentNotificationPermission, } from '../notifications/agent-notifications';
|
|
49
|
+
import { AgentNotifier } from '../notifications/agent-notifier';
|
|
50
|
+
import { addNotificationSettingsHost, announceNotificationSettings, } from '../notifications/notification-settings';
|
|
47
51
|
import { AssistantAppSettingsProvider, } from '../provider/assistant-app-settings';
|
|
48
52
|
import { recordMetaEvent, getMetaEvents, clearSession as clearMetaSession, DEBUG_LOG_README, } from '../state/debug-event-log';
|
|
49
53
|
import { getOrCreateDriver, getDriver, getDriverAgentsKey, deleteDriver, } from '../state/driver-registry';
|
|
@@ -117,6 +121,11 @@ function settleWithin(outcome, ms, what) {
|
|
|
117
121
|
}
|
|
118
122
|
});
|
|
119
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Shared by every assistant on the page, so two views of one session (docked and popped out) keep
|
|
126
|
+
* one memory of what was just shown (GENC-1676).
|
|
127
|
+
*/
|
|
128
|
+
const agentNotifier = new AgentNotifier();
|
|
120
129
|
/**
|
|
121
130
|
* How long the agent-log Send button shows its 'Sent'/'Failed' outcome before
|
|
122
131
|
* returning to idle — long enough to read, short enough that a retry is never blocked.
|
|
@@ -170,7 +179,7 @@ const TIMESTAMP_CLOCK_INTERVAL_MS = 30000;
|
|
|
170
179
|
*/
|
|
171
180
|
export { budgetPercentOf, formatBlockedReason } from './budget-controller';
|
|
172
181
|
// Register supporting components when the main component module is imported.
|
|
173
|
-
avoidTreeShaking(AiChatMarkdown, AiChatInteractionWrapper, AiHaloOverlay, AiWavesIndicator, AiFlowingWavesIndicator, AiPlasmaOrbIndicator, AiChatBubble, AiActivityHalo, ChatSuggestions, AgentPicker, MessageFeedback);
|
|
182
|
+
avoidTreeShaking(AiChatMarkdown, AiChatInteractionWrapper, AiHaloOverlay, AiWavesIndicator, AiFlowingWavesIndicator, AiPlasmaOrbIndicator, AiChatBubble, AiNotificationLevel, AiActivityHalo, ChatSuggestions, AgentPicker, MessageFeedback);
|
|
174
183
|
/**
|
|
175
184
|
* Foundation AI Assistant component.
|
|
176
185
|
*
|
|
@@ -323,6 +332,13 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
323
332
|
this.persistence = {};
|
|
324
333
|
/** When set, enables Redux DevTools for this instance's session store. */
|
|
325
334
|
this.debugRedux = false;
|
|
335
|
+
/** The browser's notification permission, followed while connected. @internal */
|
|
336
|
+
this.notificationPermission = 'unsupported';
|
|
337
|
+
/**
|
|
338
|
+
* Bumped to make the settings picker re-read its value when a choice did not take (permission
|
|
339
|
+
* refused), since the stored level, and so its binding, did not change. @internal
|
|
340
|
+
*/
|
|
341
|
+
this.notificationPickerRevision = 0;
|
|
326
342
|
/**
|
|
327
343
|
* Epoch ms the transcript's relative timestamps are measured against.
|
|
328
344
|
*
|
|
@@ -778,6 +794,114 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
778
794
|
// The mode decides whether the clock needs to run at all.
|
|
779
795
|
this.syncTimestampClock();
|
|
780
796
|
}
|
|
797
|
+
/**
|
|
798
|
+
* The person's agent notification level (GENC-1676): `'off'` (always the default),
|
|
799
|
+
* `'autopilot'` or `'needs-input'`. Saved with the other settings.
|
|
800
|
+
*
|
|
801
|
+
* An app may set it, e.g. after its own "Notify me" invitation, once the person granted
|
|
802
|
+
* permission through `requestAgentNotificationPermission`. Ignored when the app does not offer
|
|
803
|
+
* the level (`chatConfig.ui.notifications`), and before the assistant has a session.
|
|
804
|
+
*/
|
|
805
|
+
get notificationLevel() {
|
|
806
|
+
var _a, _b;
|
|
807
|
+
return (_b = (_a = this._sessionRef) === null || _a === void 0 ? void 0 : _a.store.aiAssistant.notificationLevel) !== null && _b !== void 0 ? _b : 'off';
|
|
808
|
+
}
|
|
809
|
+
set notificationLevel(value) {
|
|
810
|
+
var _a, _b;
|
|
811
|
+
const level = asAgentNotificationLevel(value);
|
|
812
|
+
if (!level || !levelOffered(level, (_a = this.chatConfig.ui) === null || _a === void 0 ? void 0 : _a.notifications))
|
|
813
|
+
return;
|
|
814
|
+
if (preferenceUnchanged(this.notificationLevel, level))
|
|
815
|
+
return;
|
|
816
|
+
(_b = this._sessionRef) === null || _b === void 0 ? void 0 : _b.actions.aiAssistant.setNotificationLevel(level);
|
|
817
|
+
this.persistPreferences();
|
|
818
|
+
announceNotificationSettings(this.getStateKey());
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* The level that applies: the person's choice, as `'off'` when the app no longer offers it.
|
|
822
|
+
* What the settings picker shows. @internal
|
|
823
|
+
*/
|
|
824
|
+
get effectiveNotificationLevel() {
|
|
825
|
+
var _a;
|
|
826
|
+
return effectiveNotificationLevel(this.notificationLevel, (_a = this.chatConfig.ui) === null || _a === void 0 ? void 0 : _a.notifications);
|
|
827
|
+
}
|
|
828
|
+
/** Whether the settings row shows: offered by the app, and possible in this browser. @internal */
|
|
829
|
+
get notificationSettingVisible() {
|
|
830
|
+
var _a;
|
|
831
|
+
return (notificationsOffered((_a = this.chatConfig.ui) === null || _a === void 0 ? void 0 : _a.notifications) &&
|
|
832
|
+
this.notificationPermission !== 'unsupported');
|
|
833
|
+
}
|
|
834
|
+
/** Whether the settings picker offers the `'autopilot'` level. @internal */
|
|
835
|
+
get notificationAutopilotOffered() {
|
|
836
|
+
var _a;
|
|
837
|
+
return levelOffered('autopilot', (_a = this.chatConfig.ui) === null || _a === void 0 ? void 0 : _a.notifications);
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* The hint under the settings row when the browser will not show notifications. A block shows
|
|
841
|
+
* even at Off: otherwise a person picking a level would see it snap back with no reason given,
|
|
842
|
+
* since a browser that has blocked them never asks again. @internal
|
|
843
|
+
*/
|
|
844
|
+
get notificationPermissionHint() {
|
|
845
|
+
return notificationPermissionHint(this.effectiveNotificationLevel, this.notificationPermission);
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* The person chose a level in settings (GENC-1676). Turning notifications on asks the browser for
|
|
849
|
+
* permission first — this runs inside their click, which the browser requires — and keeps the
|
|
850
|
+
* old level if they refuse. @internal
|
|
851
|
+
*/
|
|
852
|
+
chooseNotificationLevel(level) {
|
|
853
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
854
|
+
const outcome = yield chooseAgentNotificationLevel(level, this.effectiveNotificationLevel, (next) => (this.notificationLevel = next));
|
|
855
|
+
if (outcome === 'refused')
|
|
856
|
+
this.notificationPickerRevision += 1;
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Notifications, for this connect (GENC-1676): turn this session's `agent-attention` into
|
|
861
|
+
* browser notifications, follow the browser's permission, and lend this session's settings to
|
|
862
|
+
* pickers outside this element (`foundation-ai-notification-level`).
|
|
863
|
+
*/
|
|
864
|
+
wireNotifications() {
|
|
865
|
+
var _a;
|
|
866
|
+
(_a = this._unwireNotifications) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
867
|
+
this.notificationPermission = agentNotificationPermission();
|
|
868
|
+
const unsubAttention = agenticActivityBus.subscribe('agent-attention', (d) => this.onAgentAttention(d));
|
|
869
|
+
const unwatchPermission = watchAgentNotificationPermission((permission) => {
|
|
870
|
+
this.notificationPermission = permission;
|
|
871
|
+
});
|
|
872
|
+
const removeHost = addNotificationSettingsHost({
|
|
873
|
+
sessionKey: () => this.getStateKey(),
|
|
874
|
+
effectiveLevel: () => this.effectiveNotificationLevel,
|
|
875
|
+
offered: () => { var _a; return notificationsOffered((_a = this.chatConfig.ui) === null || _a === void 0 ? void 0 : _a.notifications); },
|
|
876
|
+
autopilotOffered: () => this.notificationAutopilotOffered,
|
|
877
|
+
setLevel: (level) => {
|
|
878
|
+
this.notificationLevel = level;
|
|
879
|
+
},
|
|
880
|
+
});
|
|
881
|
+
this._unwireNotifications = () => {
|
|
882
|
+
unsubAttention();
|
|
883
|
+
unwatchPermission();
|
|
884
|
+
removeHost();
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Turn an `agent-attention` event for this session into a browser notification, if the
|
|
889
|
+
* person's level covers it and they are not looking (GENC-1676).
|
|
890
|
+
*/
|
|
891
|
+
onAgentAttention(detail) {
|
|
892
|
+
var _a;
|
|
893
|
+
const sessionKey = this.getStateKey();
|
|
894
|
+
if (sessionKey === undefined || !belongsToSession(detail.sessionKey, sessionKey))
|
|
895
|
+
return;
|
|
896
|
+
const config = (_a = this.chatConfig.ui) === null || _a === void 0 ? void 0 : _a.notifications;
|
|
897
|
+
agentNotifier.notify(detail, {
|
|
898
|
+
level: this.effectiveNotificationLevel,
|
|
899
|
+
title: this.headerTitle,
|
|
900
|
+
message: config === null || config === void 0 ? void 0 : config.message,
|
|
901
|
+
// Opens a closed bubble, and brings what waits on the person into view.
|
|
902
|
+
onClick: () => agenticActivityBus.publish('autopilot-show-waiting', { sessionKey }),
|
|
903
|
+
});
|
|
904
|
+
}
|
|
781
905
|
/**
|
|
782
906
|
* Start or stop the timestamp clock to match the current mode and connection state.
|
|
783
907
|
*
|
|
@@ -1730,7 +1854,10 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
1730
1854
|
if (this.$fastController.isConnected)
|
|
1731
1855
|
this.wireAutopilot();
|
|
1732
1856
|
}
|
|
1733
|
-
/**
|
|
1857
|
+
/**
|
|
1858
|
+
* Follow the autopilot host's state, publishing the "needs you" signal for the bubble, and bring
|
|
1859
|
+
* what waits on the person into view when asked.
|
|
1860
|
+
*/
|
|
1734
1861
|
wireAutopilot() {
|
|
1735
1862
|
var _a, _b;
|
|
1736
1863
|
(_a = this.autopilotCleanup) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
@@ -1743,17 +1870,16 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
1743
1870
|
setAutopilotNeedsUser(sessionKey, !!(host === null || host === void 0 ? void 0 : host.state.needsUser));
|
|
1744
1871
|
};
|
|
1745
1872
|
read();
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
const unsubscribeHost = host.subscribe(read);
|
|
1749
|
-
// Opened from the badge: bring what waits on the person into view.
|
|
1873
|
+
// Opened from the badge, or from a notification (GENC-1676): bring what waits on the person
|
|
1874
|
+
// into view. With or without an autopilot: a notification can come from a widget alone.
|
|
1750
1875
|
const unsubscribeShow = agenticActivityBus.subscribe('autopilot-show-waiting', (detail) => {
|
|
1751
1876
|
if ((detail === null || detail === void 0 ? void 0 : detail.sessionKey) && detail.sessionKey !== sessionKey)
|
|
1752
1877
|
return;
|
|
1753
1878
|
this.showWaiting();
|
|
1754
1879
|
});
|
|
1880
|
+
const unsubscribeHost = host === null || host === void 0 ? void 0 : host.subscribe(read);
|
|
1755
1881
|
this.autopilotCleanup = () => {
|
|
1756
|
-
unsubscribeHost();
|
|
1882
|
+
unsubscribeHost === null || unsubscribeHost === void 0 ? void 0 : unsubscribeHost();
|
|
1757
1883
|
unsubscribeShow();
|
|
1758
1884
|
};
|
|
1759
1885
|
}
|
|
@@ -2057,6 +2183,7 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
2057
2183
|
agents,
|
|
2058
2184
|
providerRegistry: this.providerRegistry,
|
|
2059
2185
|
sessionKey: (_c = this.getStateKey()) !== null && _c !== void 0 ? _c : '',
|
|
2186
|
+
activityBus: agenticActivityBus,
|
|
2060
2187
|
});
|
|
2061
2188
|
}
|
|
2062
2189
|
return new ChatDriver(this.providerRegistry, {
|
|
@@ -2466,6 +2593,7 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
2466
2593
|
});
|
|
2467
2594
|
}
|
|
2468
2595
|
this.settings.wireAppSettingsProvider();
|
|
2596
|
+
this.wireNotifications();
|
|
2469
2597
|
// Latch the backend block off the activity bus (GENC-1464). This is the primary
|
|
2470
2598
|
// seam: it fires for a turn this element did not start, for a sub-agent's
|
|
2471
2599
|
// wall (the child inherits the parent's bus and publishes its own
|
|
@@ -2576,7 +2704,7 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
2576
2704
|
this.switchSession(currentKey !== null && currentKey !== void 0 ? currentKey : targetKey, targetKey);
|
|
2577
2705
|
}
|
|
2578
2706
|
disconnectedCallback() {
|
|
2579
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2707
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2580
2708
|
window.removeEventListener('pagehide', this._handlePageHide);
|
|
2581
2709
|
// Drops the menus' document listeners and finalises any in-flight close
|
|
2582
2710
|
// animation. Ordering matters and is satisfied here: `finalize()` writes the
|
|
@@ -2604,10 +2732,12 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
2604
2732
|
this.unsubBus = undefined;
|
|
2605
2733
|
(_b = this._unsubBudgetLatch) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
2606
2734
|
this._unsubBudgetLatch = undefined;
|
|
2607
|
-
(_c = this.
|
|
2735
|
+
(_c = this._unwireNotifications) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
2736
|
+
this._unwireNotifications = undefined;
|
|
2737
|
+
(_d = this.unsubProviderRegistry) === null || _d === void 0 ? void 0 : _d.call(this);
|
|
2608
2738
|
this.unsubProviderRegistry = undefined;
|
|
2609
2739
|
this.settings.unwireAppSettingsProvider();
|
|
2610
|
-
(
|
|
2740
|
+
(_e = this._executionCompletionUnsub) === null || _e === void 0 ? void 0 : _e.call(this);
|
|
2611
2741
|
this._executionCompletionUnsub = undefined;
|
|
2612
2742
|
// Note: the restore-core autosave AND diagnostics-append timers live on the
|
|
2613
2743
|
// shared per-session persister (GENC-1351 §5.10), not here — they must survive a
|
|
@@ -2621,11 +2751,11 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
2621
2751
|
document.removeEventListener('pointerdown', this._handleGlobalInteraction, true);
|
|
2622
2752
|
document.removeEventListener('focusin', this._handleGlobalInteraction, true);
|
|
2623
2753
|
if (this.settingsOpen) {
|
|
2624
|
-
(
|
|
2754
|
+
(_f = this.settingsModal) === null || _f === void 0 ? void 0 : _f.close();
|
|
2625
2755
|
this.settingsOpen = false;
|
|
2626
2756
|
}
|
|
2627
2757
|
// Capture before clearing — `wasBusy` reads the driver, which is dropped below.
|
|
2628
|
-
this.logMeta('assistant.disconnected', { wasBusy: (
|
|
2758
|
+
this.logMeta('assistant.disconnected', { wasBusy: (_h = (_g = this.driver) === null || _g === void 0 ? void 0 : _g.isBusy()) !== null && _h !== void 0 ? _h : false });
|
|
2629
2759
|
// Clear local references only — driver and store stay in their registries.
|
|
2630
2760
|
this.driver = undefined;
|
|
2631
2761
|
this._sessionRef = undefined;
|
|
@@ -2684,6 +2814,8 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
2684
2814
|
// now that (or in case) the config's UI defaults are available (#2). No-op unless
|
|
2685
2815
|
// the store is fresh and the user hasn't already toggled something.
|
|
2686
2816
|
this.applyPreferenceBaseline();
|
|
2817
|
+
// What the app offers may have changed: pickers outside this element re-read it.
|
|
2818
|
+
announceNotificationSettings(this.getStateKey());
|
|
2687
2819
|
this.syncShowingSplash();
|
|
2688
2820
|
this.costLedger.syncActiveTitle();
|
|
2689
2821
|
this.costLedger.reload();
|
|
@@ -3197,6 +3329,8 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
3197
3329
|
showNarration: this.showNarration,
|
|
3198
3330
|
showAgentSwitchIndicator: this.showAgentSwitchIndicator,
|
|
3199
3331
|
timestampDisplay: this.timestampDisplay,
|
|
3332
|
+
// The choice as made, not as narrowed: a level the app stops offering is kept.
|
|
3333
|
+
notificationLevel: this.notificationLevel,
|
|
3200
3334
|
animations: [...this.enabledAnimations],
|
|
3201
3335
|
};
|
|
3202
3336
|
}
|
|
@@ -3238,6 +3372,7 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
3238
3372
|
* whenever `chatConfig` hadn't bound yet.
|
|
3239
3373
|
*/
|
|
3240
3374
|
applyPreferenceBaseline() {
|
|
3375
|
+
var _a;
|
|
3241
3376
|
// The "user changed a pref" latch and the stored blob live on the shared
|
|
3242
3377
|
// per-session persister (§5.10 Phase 2 / issue #1), so both element views agree —
|
|
3243
3378
|
// otherwise one view could re-apply `chatConfig` defaults over the other's live
|
|
@@ -3258,6 +3393,10 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
3258
3393
|
this.showNarration = resolved.showNarration;
|
|
3259
3394
|
this.showAgentSwitchIndicator = resolved.showAgentSwitchIndicator;
|
|
3260
3395
|
this.timestampDisplay = resolved.timestampDisplay;
|
|
3396
|
+
// Through the store, not the setter: the setter drops a level the app does not offer, and
|
|
3397
|
+
// the stored choice must survive that (GENC-1676).
|
|
3398
|
+
(_a = this._sessionRef) === null || _a === void 0 ? void 0 : _a.actions.aiAssistant.setNotificationLevel(resolved.notificationLevel);
|
|
3399
|
+
announceNotificationSettings(this.getStateKey());
|
|
3261
3400
|
this.enabledAnimations = resolved.enabledAnimations;
|
|
3262
3401
|
}
|
|
3263
3402
|
finally {
|
|
@@ -3685,6 +3824,8 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
|
|
|
3685
3824
|
return this.settings.cogVisible;
|
|
3686
3825
|
}
|
|
3687
3826
|
openSettingsModal() {
|
|
3827
|
+
// Permission can change in the browser's own settings while the page is open.
|
|
3828
|
+
this.notificationPermission = agentNotificationPermission();
|
|
3688
3829
|
this.settings.openModal();
|
|
3689
3830
|
}
|
|
3690
3831
|
closeSettingsModal() {
|
|
@@ -4830,6 +4971,12 @@ __decorate([
|
|
|
4830
4971
|
__decorate([
|
|
4831
4972
|
volatile
|
|
4832
4973
|
], FoundationAiAssistant.prototype, "busy", null);
|
|
4974
|
+
__decorate([
|
|
4975
|
+
observable
|
|
4976
|
+
], FoundationAiAssistant.prototype, "notificationPermission", void 0);
|
|
4977
|
+
__decorate([
|
|
4978
|
+
observable
|
|
4979
|
+
], FoundationAiAssistant.prototype, "notificationPickerRevision", void 0);
|
|
4833
4980
|
__decorate([
|
|
4834
4981
|
observable
|
|
4835
4982
|
], FoundationAiAssistant.prototype, "timestampClock", void 0);
|