@genesislcap/ai-assistant 15.77.0 → 15.78.1
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 +796 -7
- package/dist/ai-assistant.d.ts +305 -12
- 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 +1230 -468
- 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/config/config.d.ts +2 -2
- package/dist/dts/config/define-stateful-agent.d.ts +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 +79 -6
- 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 +12 -5
- 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/persistence/session-persister.d.ts.map +1 -1
- package/dist/dts/state/persistence/session-snapshot.d.ts +19 -6
- package/dist/dts/state/persistence/session-snapshot.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/attachment-note.d.ts +18 -0
- package/dist/dts/utils/attachment-note.d.ts.map +1 -0
- 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 +217 -27
- package/dist/esm/main/main.template.js +2 -2
- 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/state/persistence/session-persister.js +24 -21
- package/dist/esm/state/persistence/session-snapshot.js +20 -7
- package/dist/esm/utils/attachment-note.js +19 -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/docs/styling.md +1 -1
- package/package.json +17 -17
- package/sandbox/fixtures.ts +3 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The line naming the files under a message sent with attachments. Built and taken off only
|
|
3
|
+
* here, so the two can't drift.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
type Files = ReadonlyArray<{
|
|
8
|
+
name: string;
|
|
9
|
+
}> | undefined;
|
|
10
|
+
/** What a message sent with `files` is stored and shown as: the typed text, then the line. */
|
|
11
|
+
export declare function withAttachmentNote(typed: string, files: Files): string;
|
|
12
|
+
/**
|
|
13
|
+
* The typed text of a message stored with `files`. Takes off only the line those files add, so
|
|
14
|
+
* nothing the user typed is cut.
|
|
15
|
+
*/
|
|
16
|
+
export declare function withoutAttachmentNote(text: string, files: Files): string;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=attachment-note.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-note.d.ts","sourceRoot":"","sources":["../../../src/utils/attachment-note.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,KAAK,KAAK,GAAG,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,CAAC;AAKzD,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAEtE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAGxE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChatConfig, TimestampDisplay } from '@genesislcap/foundation-ai';
|
|
2
2
|
import { type AiAssistantAnimation } from '../main/main.types';
|
|
3
|
+
import { type AgentNotificationLevel } from '../notifications/agent-notifications';
|
|
3
4
|
import type { SessionPreferences } from '../state/persistence/session-persistence-provider';
|
|
4
5
|
/**
|
|
5
6
|
* Whether a preference write is a no-op, so a setter can bail before touching the store.
|
|
@@ -27,6 +28,8 @@ export interface ResolvedPreferenceBaseline {
|
|
|
27
28
|
showNarration: boolean;
|
|
28
29
|
showAgentSwitchIndicator: boolean;
|
|
29
30
|
timestampDisplay: TimestampDisplay;
|
|
31
|
+
/** Stored only: no config layer, so `'off'` unless the person (or the app) chose otherwise. */
|
|
32
|
+
notificationLevel: AgentNotificationLevel;
|
|
30
33
|
enabledAnimations: AiAssistantAnimation[];
|
|
31
34
|
/**
|
|
32
35
|
* The remembered "remember chat" toggle — present only when stored prefs carried
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-preference-baseline.d.ts","sourceRoot":"","sources":["../../../src/utils/resolve-preference-baseline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAG5F;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAK7E;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,wBAAwB,EAAE,OAAO,CAAC;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,iBAAiB,EAAE,oBAAoB,EAAE,CAAC;IAC1C;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,oFAAoF;AACpF,eAAO,MAAM,yBAAyB,EAAE,gBAA2B,CAAC;AA+BpE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,EACpB,MAAM,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,GAC5C,0BAA0B,
|
|
1
|
+
{"version":3,"file":"resolve-preference-baseline.d.ts","sourceRoot":"","sources":["../../../src/utils/resolve-preference-baseline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAG5F;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAK7E;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,wBAAwB,EAAE,OAAO,CAAC;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,+FAA+F;IAC/F,iBAAiB,EAAE,sBAAsB,CAAC;IAC1C,iBAAiB,EAAE,oBAAoB,EAAE,CAAC;IAC1C;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,oFAAoF;AACpF,eAAO,MAAM,yBAAyB,EAAE,gBAA2B,CAAC;AA+BpE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,EACpB,MAAM,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,GAC5C,0BAA0B,CA+C5B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { NOOP_ACTIVITY_BUS } from '../channel/ai-activity-bus';
|
|
2
3
|
import { BaseDriverDecorator } from '../components/ai-driver/base-driver-decorator';
|
|
3
4
|
import { recordMetaEvent } from '../state/debug-event-log';
|
|
4
5
|
import { getInteractionRegistration, registerInteraction } from '../state/interaction-registry';
|
|
@@ -13,6 +14,20 @@ import { AUTOPILOT_HAND_BACK, HandBackController, handBackAsText, } from './hand
|
|
|
13
14
|
export const AUTOPILOT_CLAIMANT = 'autopilot';
|
|
14
15
|
/** How the working agent is told about a decision when the config gives no phrase. */
|
|
15
16
|
const DEFAULT_DECISION_FRAMING = "Decided on the user's behalf";
|
|
17
|
+
/**
|
|
18
|
+
* Declines that leave an interaction with the person while the autopilot runs for its flow: it
|
|
19
|
+
* may not answer this one, so the person has to. The others (paused, another flow, no autopilot)
|
|
20
|
+
* mean it was never the autopilot's to answer.
|
|
21
|
+
*/
|
|
22
|
+
const HANDED_TO_PERSON = new Set(['policy', 'userOnly', 'no-controller']);
|
|
23
|
+
/**
|
|
24
|
+
* Nothing is happening, and not because the person paused it or has its hand-back: in its flow,
|
|
25
|
+
* or after its flow ended. Whether that is a stop depends on what came before; see `watchForStop`.
|
|
26
|
+
*/
|
|
27
|
+
const isIdle = (state) => (state.mode === 'running' || state.mode === 'unavailable') &&
|
|
28
|
+
!state.working &&
|
|
29
|
+
!state.needsUser &&
|
|
30
|
+
!state.pause;
|
|
16
31
|
/** How a written answer sent on the user's behalf is framed, when the config gives no phrase. */
|
|
17
32
|
const DEFAULT_REPLY_FRAMING = "Answered on the user's behalf.";
|
|
18
33
|
/**
|
|
@@ -73,7 +88,7 @@ const DEFAULT_COPY = {
|
|
|
73
88
|
*/
|
|
74
89
|
export class AutopilotDriver extends BaseDriverDecorator {
|
|
75
90
|
constructor(inner, options) {
|
|
76
|
-
var _a, _b, _c;
|
|
91
|
+
var _a, _b, _c, _d;
|
|
77
92
|
super(inner);
|
|
78
93
|
this.listeners = new Set();
|
|
79
94
|
this.sessions = new Map();
|
|
@@ -94,9 +109,16 @@ export class AutopilotDriver extends BaseDriverDecorator {
|
|
|
94
109
|
this.turnsInFlight = 0;
|
|
95
110
|
/** Written questions being answered right now; see `working`. */
|
|
96
111
|
this.answersInFlight = 0;
|
|
112
|
+
/**
|
|
113
|
+
* Whether the autopilot has been running, and working, since it last stopped or was paused: so
|
|
114
|
+
* going idle now is a stop to report. Outlives its flow ending, so a turn still running then is
|
|
115
|
+
* waited out. See `watchForStop`.
|
|
116
|
+
*/
|
|
117
|
+
this.ranSinceStop = false;
|
|
97
118
|
this.agents = options.agents;
|
|
98
119
|
this.providerRegistry = options.providerRegistry;
|
|
99
120
|
this.sessionKey = (_a = options.sessionKey) !== null && _a !== void 0 ? _a : '';
|
|
121
|
+
this.activityBus = (_b = options.activityBus) !== null && _b !== void 0 ? _b : NOOP_ACTIVITY_BUS;
|
|
100
122
|
// The turn-level hand-back is a widget like any other: registered, so it has a controller and a
|
|
101
123
|
// text form. Once per app, whichever autopilot gets there first.
|
|
102
124
|
if (!getInteractionRegistration(AUTOPILOT_HAND_BACK)) {
|
|
@@ -118,7 +140,7 @@ export class AutopilotDriver extends BaseDriverDecorator {
|
|
|
118
140
|
};
|
|
119
141
|
// Every hook on the inner driver is undone by `detach()`, so this decorator can be dropped
|
|
120
142
|
// while the driver it wrapped lives on.
|
|
121
|
-
const removeInterceptor = (
|
|
143
|
+
const removeInterceptor = (_c = inner.addInteractionInterceptor) === null || _c === void 0 ? void 0 : _c.call(inner, {
|
|
122
144
|
id: AUTOPILOT_CLAIMANT,
|
|
123
145
|
// Read when a claimed interaction settles: the framing of the flow the autopilot serves.
|
|
124
146
|
get decisionFraming() {
|
|
@@ -132,7 +154,7 @@ export class AutopilotDriver extends BaseDriverDecorator {
|
|
|
132
154
|
});
|
|
133
155
|
if (removeInterceptor)
|
|
134
156
|
this.onDetach(removeInterceptor);
|
|
135
|
-
const removeCapability = (
|
|
157
|
+
const removeCapability = (_d = inner.provideHandlerCapability) === null || _d === void 0 ? void 0 : _d.call(inner, AUTOPILOT_CLAIMANT, (scope) => this.capabilityFor(scope));
|
|
136
158
|
if (removeCapability)
|
|
137
159
|
this.onDetach(removeCapability);
|
|
138
160
|
const onFlowOwnerChanged = (e) => this.onFlowOwnerChanged(e.detail);
|
|
@@ -143,6 +165,7 @@ export class AutopilotDriver extends BaseDriverDecorator {
|
|
|
143
165
|
inner.addEventListener('history-updated', onHistoryUpdated);
|
|
144
166
|
this.onDetach(() => {
|
|
145
167
|
this.disarmWatchdog();
|
|
168
|
+
clearTimeout(this.stopCheck);
|
|
146
169
|
inner.removeEventListener('flow-owner-changed', onFlowOwnerChanged);
|
|
147
170
|
inner.removeEventListener('history-updated', onHistoryUpdated);
|
|
148
171
|
this.releaseHeld();
|
|
@@ -522,6 +545,7 @@ export class AutopilotDriver extends BaseDriverDecorator {
|
|
|
522
545
|
this.turnHandBack = { why };
|
|
523
546
|
this.consecutiveReplies = 0;
|
|
524
547
|
this.notify();
|
|
548
|
+
this.attention('autopilot-handed-back');
|
|
525
549
|
let result;
|
|
526
550
|
try {
|
|
527
551
|
result = yield this.inner.presentInteraction(AUTOPILOT_HAND_BACK, data, {
|
|
@@ -594,6 +618,10 @@ export class AutopilotDriver extends BaseDriverDecorator {
|
|
|
594
618
|
component: opened.componentName,
|
|
595
619
|
reason,
|
|
596
620
|
});
|
|
621
|
+
// The run waits on the person now. Its own turn-level hand-back reports itself.
|
|
622
|
+
if (HANDED_TO_PERSON.has(reason) && opened.componentName !== AUTOPILOT_HAND_BACK) {
|
|
623
|
+
this.attention('autopilot-handed-back', opened.interactionId);
|
|
624
|
+
}
|
|
597
625
|
return undefined;
|
|
598
626
|
};
|
|
599
627
|
const owner = this.flowOwner();
|
|
@@ -760,6 +788,7 @@ export class AutopilotDriver extends BaseDriverDecorator {
|
|
|
760
788
|
trigger,
|
|
761
789
|
});
|
|
762
790
|
this.notify();
|
|
791
|
+
this.attention('autopilot-handed-back', held.opened.interactionId);
|
|
763
792
|
}
|
|
764
793
|
/**
|
|
765
794
|
* On detach: hand a claimed interaction the autopilot still holds to the person, stopping its
|
|
@@ -886,7 +915,41 @@ export class AutopilotDriver extends BaseDriverDecorator {
|
|
|
886
915
|
record(type, detail) {
|
|
887
916
|
recordMetaEvent(this.sessionKey, type, detail);
|
|
888
917
|
}
|
|
918
|
+
/** Report that something needs the person, for the assistant to notify them (GENC-1676). */
|
|
919
|
+
attention(kind, interactionId) {
|
|
920
|
+
this.activityBus.publish('agent-attention', Object.assign({ sessionKey: this.sessionKey, kind }, (interactionId ? { interactionId } : {})));
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Report the autopilot stopping work on its own (GENC-1676): after running and working, nothing
|
|
924
|
+
* is happening and nothing waits on the person — the turn ended with nothing for it to answer,
|
|
925
|
+
* hit a wall such as the budget, or its flow ended. A flow that ends mid-turn is reported once
|
|
926
|
+
* the turn ends, not while the assistant is still writing. A pause by the person is not a stop,
|
|
927
|
+
* and a hand-back reports itself.
|
|
928
|
+
*
|
|
929
|
+
* Confirmed a task later, because one state change can briefly look like a stop on the way to
|
|
930
|
+
* something else (a turn ending just before the next starts).
|
|
931
|
+
*/
|
|
932
|
+
watchForStop() {
|
|
933
|
+
const state = this.state;
|
|
934
|
+
if (state.mode === 'paused') {
|
|
935
|
+
// The person paused it (or Stop did): whatever follows is not the autopilot stopping.
|
|
936
|
+
this.ranSinceStop = false;
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
if (state.mode === 'running' && state.working)
|
|
940
|
+
this.ranSinceStop = true;
|
|
941
|
+
if (!this.ranSinceStop || !isIdle(state) || this.stopCheck)
|
|
942
|
+
return;
|
|
943
|
+
this.stopCheck = setTimeout(() => {
|
|
944
|
+
this.stopCheck = undefined;
|
|
945
|
+
if (!this.ranSinceStop || !isIdle(this.state))
|
|
946
|
+
return;
|
|
947
|
+
this.ranSinceStop = false;
|
|
948
|
+
this.attention('autopilot-stopped');
|
|
949
|
+
}, 0);
|
|
950
|
+
}
|
|
889
951
|
notify() {
|
|
952
|
+
this.watchForStop();
|
|
890
953
|
for (const listener of this.listeners) {
|
|
891
954
|
try {
|
|
892
955
|
listener();
|
|
@@ -162,9 +162,7 @@ let AiChatBubble = class AiChatBubble extends GenesisElement {
|
|
|
162
162
|
this.startCloseDialog();
|
|
163
163
|
}
|
|
164
164
|
else {
|
|
165
|
-
this.
|
|
166
|
-
this.dialogTop = Math.max(VIEWPORT_EDGE_MARGIN, this.bubbleTop - DIALOG_OPEN_TOP_OFFSET);
|
|
167
|
-
this.dialogOpen = true;
|
|
165
|
+
this.openDialog();
|
|
168
166
|
this.showWaitingIfBadged();
|
|
169
167
|
}
|
|
170
168
|
}
|
|
@@ -197,10 +195,20 @@ let AiChatBubble = class AiChatBubble extends GenesisElement {
|
|
|
197
195
|
});
|
|
198
196
|
this.refreshNeedsUser();
|
|
199
197
|
const unsubNeedsUser = agenticActivityBus.subscribe('autopilot-needs-user', () => this.refreshNeedsUser());
|
|
198
|
+
// Asked from outside the bubble, e.g. a notification clicked (GENC-1676): open on what waits.
|
|
199
|
+
const unsubShowWaiting = agenticActivityBus.subscribe('autopilot-show-waiting', (detail) => {
|
|
200
|
+
if (this.hidden || this.dialogOpen)
|
|
201
|
+
return;
|
|
202
|
+
if ((detail === null || detail === void 0 ? void 0 : detail.sessionKey) && detail.sessionKey !== this.assistantSessionKey())
|
|
203
|
+
return;
|
|
204
|
+
this.cancelClose();
|
|
205
|
+
this.openDialog();
|
|
206
|
+
});
|
|
200
207
|
this.unsubBus = () => {
|
|
201
208
|
unsubPopout();
|
|
202
209
|
unsubPopin();
|
|
203
210
|
unsubNeedsUser();
|
|
211
|
+
unsubShowWaiting();
|
|
204
212
|
};
|
|
205
213
|
// Measure tooltip width once after first render. The bubble is visible on connect
|
|
206
214
|
// (dialogOpen starts false), so the element is in the DOM by the time rAF fires.
|
|
@@ -292,6 +300,12 @@ let AiChatBubble = class AiChatBubble extends GenesisElement {
|
|
|
292
300
|
const assistant = this.findAssistant([...this.children]);
|
|
293
301
|
return (_a = assistant === null || assistant === void 0 ? void 0 : assistant.stateKey) !== null && _a !== void 0 ? _a : undefined;
|
|
294
302
|
}
|
|
303
|
+
/** Open the dialog beside the orb. */
|
|
304
|
+
openDialog() {
|
|
305
|
+
this.dialogLeft = Math.max(VIEWPORT_EDGE_MARGIN, this.bubbleLeft - DIALOG_BUBBLE_HORIZONTAL_OFFSET);
|
|
306
|
+
this.dialogTop = Math.max(VIEWPORT_EDGE_MARGIN, this.bubbleTop - DIALOG_OPEN_TOP_OFFSET);
|
|
307
|
+
this.dialogOpen = true;
|
|
308
|
+
}
|
|
295
309
|
/** Opened from the badge: take the person to what is waiting on them (GENC-1660). */
|
|
296
310
|
showWaitingIfBadged() {
|
|
297
311
|
if (!this.needsUser)
|
|
@@ -420,9 +420,11 @@ export class InteractionController {
|
|
|
420
420
|
// including a controller resolving in its constructor, before its message is appended,
|
|
421
421
|
// which `resolve` holds back until there is a message to patch.
|
|
422
422
|
const handle = createInteractionContext(interactionId, {
|
|
423
|
+
sessionKey: this.deps.sessionKey,
|
|
423
424
|
resolve: (result) => this.resolve(interactionId, result),
|
|
424
425
|
checkpoint: this.takeOverCheckpoint(componentName, data, interactionId),
|
|
425
426
|
saveCheckpoint: (value) => this.saveCheckpoint(interactionId, componentName, value),
|
|
427
|
+
requestAttention: (message) => this.deps.activityBus.publish('agent-attention', Object.assign({ sessionKey: this.deps.sessionKey, kind: 'widget-needs-input', interactionId }, (message ? { message } : {}))),
|
|
426
428
|
});
|
|
427
429
|
this.contexts.set(interactionId, handle);
|
|
428
430
|
bindStepRecorder(handle.context, (step, outcome) => recordMetaEvent(this.deps.sessionKey, 'interaction.step', {
|
|
@@ -456,6 +458,9 @@ export class InteractionController {
|
|
|
456
458
|
ownerPath,
|
|
457
459
|
userOnly: (options === null || options === void 0 ? void 0 : options.userOnly) === true,
|
|
458
460
|
});
|
|
461
|
+
// Who holds it is decided: a `requestAttention` the controller made while being built can
|
|
462
|
+
// now report, or be dropped if a claimant holds it (GENC-1676).
|
|
463
|
+
handle.markOffered();
|
|
459
464
|
recordMetaEvent(this.deps.sessionKey, 'interaction.requested', Object.assign({ interactionId, component: componentName, agent: this.deps.activeAgentName(), ownerPath,
|
|
460
465
|
heldBy }, ((options === null || options === void 0 ? void 0 : options.userOnly) ? { userOnly: true } : {})));
|
|
461
466
|
// Signal the park boundary on the activity bus so turn-aware UI can tell
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './notification-level';
|
|
@@ -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';
|