@genesislcap/ai-assistant 14.488.2-GENC-1351.8 → 14.488.2
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 +2024 -5141
- package/dist/ai-assistant.d.ts +176 -791
- package/dist/custom-elements.json +297 -1327
- package/dist/dts/components/ai-driver/ai-driver.d.ts +8 -32
- package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts +29 -13
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts +7 -0
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts.map +1 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +4 -15
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
- package/dist/dts/components/popout-manager/popout-manager.d.ts +9 -37
- package/dist/dts/components/popout-manager/popout-manager.d.ts.map +1 -1
- 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 +0 -70
- package/dist/dts/config/config.d.ts.map +1 -1
- package/dist/dts/config/define-stateful-agent.d.ts +1 -73
- package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
- package/dist/dts/index.d.ts +0 -1
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +87 -249
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/main/main.styles.d.ts.map +1 -1
- package/dist/dts/main/main.template.d.ts.map +1 -1
- package/dist/dts/main/main.types.d.ts +0 -55
- package/dist/dts/main/main.types.d.ts.map +1 -1
- package/dist/dts/state/ai-assistant-slice.d.ts +0 -66
- package/dist/dts/state/ai-assistant-slice.d.ts.map +1 -1
- package/dist/dts/state/debug-event-log.d.ts +1 -1
- package/dist/dts/state/debug-event-log.d.ts.map +1 -1
- package/dist/dts/state/session-store.d.ts +0 -6
- package/dist/dts/state/session-store.d.ts.map +1 -1
- package/dist/dts/utils/history-transform.d.ts +0 -38
- package/dist/dts/utils/history-transform.d.ts.map +1 -1
- package/dist/dts/utils/message-partition.d.ts +0 -27
- package/dist/dts/utils/message-partition.d.ts.map +1 -1
- package/dist/esm/components/chat-driver/chat-driver.js +64 -90
- package/dist/esm/components/chat-driver/chat-driver.test.js +45 -0
- package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.js +35 -5
- package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.test.js +62 -0
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +14 -32
- package/dist/esm/components/popout-manager/popout-manager.js +27 -76
- package/dist/esm/components/settings-modal/settings-modal.styles.js +0 -24
- package/dist/esm/components/settings-modal/settings-modal.template.js +1 -14
- package/dist/esm/config/define-stateful-agent.js +0 -81
- package/dist/esm/index.js +0 -1
- package/dist/esm/main/main.js +200 -755
- package/dist/esm/main/main.styles.js +0 -55
- package/dist/esm/main/main.template.js +10 -94
- package/dist/esm/main/main.types.js +0 -27
- package/dist/esm/state/ai-assistant-slice.js +25 -71
- package/dist/esm/state/debug-event-log.js +0 -9
- package/dist/esm/utils/history-transform.js +0 -101
- package/dist/esm/utils/message-partition.js +2 -30
- package/dist/esm/utils/message-partition.test.js +1 -20
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/components/ai-driver/ai-driver.ts +17 -36
- package/src/components/chat-driver/chat-driver.test.ts +71 -0
- package/src/components/chat-driver/chat-driver.ts +69 -92
- package/src/components/chat-interaction-wrapper/chat-interaction-wrapper.test.ts +81 -0
- package/src/components/chat-interaction-wrapper/chat-interaction-wrapper.ts +40 -5
- package/src/components/orchestrating-driver/orchestrating-driver.ts +18 -36
- package/src/components/popout-manager/popout-manager.ts +28 -82
- package/src/components/settings-modal/settings-modal.styles.ts +0 -24
- package/src/components/settings-modal/settings-modal.template.ts +1 -27
- package/src/config/config.ts +0 -71
- package/src/config/define-stateful-agent.ts +0 -134
- package/src/index.ts +0 -1
- package/src/main/main.styles.ts +0 -55
- package/src/main/main.template.ts +11 -121
- package/src/main/main.ts +179 -738
- package/src/main/main.types.ts +0 -59
- package/src/state/ai-assistant-slice.ts +25 -120
- package/src/state/debug-event-log.ts +1 -20
- package/src/utils/history-transform.ts +0 -117
- package/src/utils/message-partition.test.ts +1 -27
- package/src/utils/message-partition.ts +2 -41
- package/dist/dts/components/chat-driver/chat-driver.compact.test.d.ts +0 -2
- package/dist/dts/components/chat-driver/chat-driver.compact.test.d.ts.map +0 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.pin.test.d.ts +0 -2
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.pin.test.d.ts.map +0 -1
- package/dist/dts/state/ai-assistant-slice.test.d.ts +0 -2
- package/dist/dts/state/ai-assistant-slice.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/diagnostics-cursors.d.ts +0 -40
- package/dist/dts/state/persistence/diagnostics-cursors.d.ts.map +0 -1
- package/dist/dts/state/persistence/diagnostics.d.ts +0 -58
- package/dist/dts/state/persistence/diagnostics.d.ts.map +0 -1
- package/dist/dts/state/persistence/diagnostics.test.d.ts +0 -2
- package/dist/dts/state/persistence/diagnostics.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/index.d.ts +0 -7
- package/dist/dts/state/persistence/index.d.ts.map +0 -1
- package/dist/dts/state/persistence/persister-registry.d.ts +0 -17
- package/dist/dts/state/persistence/persister-registry.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-persistence-provider.d.ts +0 -132
- package/dist/dts/state/persistence/session-persistence-provider.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-persistence-provider.test.d.ts +0 -2
- package/dist/dts/state/persistence/session-persistence-provider.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-persistence.integration.test.d.ts +0 -2
- package/dist/dts/state/persistence/session-persistence.integration.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-persister.d.ts +0 -161
- package/dist/dts/state/persistence/session-persister.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-persister.test.d.ts +0 -2
- package/dist/dts/state/persistence/session-persister.test.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-snapshot.d.ts +0 -209
- package/dist/dts/state/persistence/session-snapshot.d.ts.map +0 -1
- package/dist/dts/state/persistence/session-snapshot.test.d.ts +0 -2
- package/dist/dts/state/persistence/session-snapshot.test.d.ts.map +0 -1
- package/dist/dts/utils/history-transform.test.d.ts +0 -2
- package/dist/dts/utils/history-transform.test.d.ts.map +0 -1
- package/dist/dts/utils/resolve-preference-baseline.d.ts +0 -43
- package/dist/dts/utils/resolve-preference-baseline.d.ts.map +0 -1
- package/dist/dts/utils/resolve-preference-baseline.test.d.ts +0 -2
- package/dist/dts/utils/resolve-preference-baseline.test.d.ts.map +0 -1
- package/dist/dts/utils/with-timeout.d.ts +0 -12
- package/dist/dts/utils/with-timeout.d.ts.map +0 -1
- package/dist/esm/components/chat-driver/chat-driver.compact.test.js +0 -93
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.pin.test.js +0 -48
- package/dist/esm/state/ai-assistant-slice.test.js +0 -65
- package/dist/esm/state/persistence/diagnostics-cursors.js +0 -34
- package/dist/esm/state/persistence/diagnostics.js +0 -81
- package/dist/esm/state/persistence/diagnostics.test.js +0 -72
- package/dist/esm/state/persistence/index.js +0 -3
- package/dist/esm/state/persistence/persister-registry.js +0 -41
- package/dist/esm/state/persistence/session-persistence-provider.js +0 -95
- package/dist/esm/state/persistence/session-persistence-provider.test.js +0 -110
- package/dist/esm/state/persistence/session-persistence.integration.test.js +0 -109
- package/dist/esm/state/persistence/session-persister.js +0 -589
- package/dist/esm/state/persistence/session-persister.test.js +0 -239
- package/dist/esm/state/persistence/session-snapshot.js +0 -231
- package/dist/esm/state/persistence/session-snapshot.test.js +0 -243
- package/dist/esm/utils/history-transform.test.js +0 -137
- package/dist/esm/utils/resolve-preference-baseline.js +0 -53
- package/dist/esm/utils/resolve-preference-baseline.test.js +0 -69
- package/dist/esm/utils/with-timeout.js +0 -28
- package/src/components/chat-driver/chat-driver.compact.test.ts +0 -131
- package/src/components/orchestrating-driver/orchestrating-driver.pin.test.ts +0 -76
- package/src/state/ai-assistant-slice.test.ts +0 -82
- package/src/state/persistence/diagnostics-cursors.ts +0 -66
- package/src/state/persistence/diagnostics.test.ts +0 -95
- package/src/state/persistence/diagnostics.ts +0 -103
- package/src/state/persistence/index.ts +0 -10
- package/src/state/persistence/persister-registry.ts +0 -49
- package/src/state/persistence/session-persistence-provider.test.ts +0 -136
- package/src/state/persistence/session-persistence-provider.ts +0 -202
- package/src/state/persistence/session-persistence.integration.test.ts +0 -134
- package/src/state/persistence/session-persister.test.ts +0 -325
- package/src/state/persistence/session-persister.ts +0 -635
- package/src/state/persistence/session-snapshot.test.ts +0 -339
- package/src/state/persistence/session-snapshot.ts +0 -332
- package/src/utils/history-transform.test.ts +0 -197
- package/src/utils/resolve-preference-baseline.test.ts +0 -84
- package/src/utils/resolve-preference-baseline.ts +0 -80
- package/src/utils/with-timeout.ts +0 -24
|
@@ -83,13 +83,6 @@ export class OrchestratingDriver extends EventTarget {
|
|
|
83
83
|
* choice.
|
|
84
84
|
*/
|
|
85
85
|
this.flowOwnerAgentName = null;
|
|
86
|
-
/**
|
|
87
|
-
* Per-agent restored state for a rehydrated session, keyed by agent name.
|
|
88
|
-
* Primed by the host on restore; each entry is passed to that agent's
|
|
89
|
-
* `onActivate` as `ctx.restored` on its next activation, then deleted so a
|
|
90
|
-
* later re-activation starts fresh.
|
|
91
|
-
*/
|
|
92
|
-
this.restoredAgentStates = {};
|
|
93
86
|
this.sessionKey = (_a = options.sessionKey) !== null && _a !== void 0 ? _a : '';
|
|
94
87
|
this.maxHandoffs = (_b = options.maxHandoffs) !== null && _b !== void 0 ? _b : DEFAULT_MAX_HANDOFFS;
|
|
95
88
|
this.classifierHistoryLength =
|
|
@@ -139,6 +132,20 @@ export class OrchestratingDriver extends EventTarget {
|
|
|
139
132
|
isBusy() {
|
|
140
133
|
return this.chatDriver.isBusy();
|
|
141
134
|
}
|
|
135
|
+
// GENC-1410 (Error 3): forward single-instance / side-effect coordination to the inner driver,
|
|
136
|
+
// which owns the interaction history and pending map.
|
|
137
|
+
registerHost(hostId) {
|
|
138
|
+
this.chatDriver.registerHost(hostId);
|
|
139
|
+
}
|
|
140
|
+
unregisterHost(hostId) {
|
|
141
|
+
this.chatDriver.unregisterHost(hostId);
|
|
142
|
+
}
|
|
143
|
+
setActiveHost(hostId) {
|
|
144
|
+
this.chatDriver.setActiveHost(hostId);
|
|
145
|
+
}
|
|
146
|
+
claimSideEffect(interactionId, hostId) {
|
|
147
|
+
return this.chatDriver.claimSideEffect(interactionId, hostId);
|
|
148
|
+
}
|
|
142
149
|
/** Currently active provider name from the underlying ChatDriver. */
|
|
143
150
|
getActiveProviderName() {
|
|
144
151
|
return this.chatDriver.getActiveProviderName();
|
|
@@ -167,14 +174,6 @@ export class OrchestratingDriver extends EventTarget {
|
|
|
167
174
|
getRawHistory() {
|
|
168
175
|
return this.chatDriver.getHistory();
|
|
169
176
|
}
|
|
170
|
-
/** {@inheritDoc AiDriver.compact} */
|
|
171
|
-
compact() {
|
|
172
|
-
return this.chatDriver.compact();
|
|
173
|
-
}
|
|
174
|
-
/** {@inheritDoc AiDriver.canCompact} */
|
|
175
|
-
canCompact() {
|
|
176
|
-
return this.chatDriver.canCompact();
|
|
177
|
-
}
|
|
178
177
|
/** Delegates to the inner {@link ChatDriver} — turns are captured there. */
|
|
179
178
|
getTurnSnapshots() {
|
|
180
179
|
return this.chatDriver.getTurnSnapshots();
|
|
@@ -268,14 +267,6 @@ export class OrchestratingDriver extends EventTarget {
|
|
|
268
267
|
return this.chatDriver.continueFromHistory(transientPrimer);
|
|
269
268
|
});
|
|
270
269
|
}
|
|
271
|
-
/** {@inheritDoc AiDriver.primeRestoredAgentState} */
|
|
272
|
-
primeRestoredAgentState(snapshots) {
|
|
273
|
-
this.restoredAgentStates = Object.assign({}, snapshots);
|
|
274
|
-
}
|
|
275
|
-
/** {@inheritDoc AiDriver.getActiveAgent} */
|
|
276
|
-
getActiveAgent() {
|
|
277
|
-
return this.activeAgent;
|
|
278
|
-
}
|
|
279
270
|
applyAgent(agent) {
|
|
280
271
|
return __awaiter(this, void 0, void 0, function* () {
|
|
281
272
|
var _a;
|
|
@@ -287,8 +278,6 @@ export class OrchestratingDriver extends EventTarget {
|
|
|
287
278
|
recordMetaEvent(this.sessionKey, 'agent.handoff', {
|
|
288
279
|
from: (_a = previousAgent === null || previousAgent === void 0 ? void 0 : previousAgent.name) !== null && _a !== void 0 ? _a : null,
|
|
289
280
|
to: agent.name,
|
|
290
|
-
// GENC-1351: was a restored snapshot waiting for this agent at activation?
|
|
291
|
-
restored: this.restoredAgentStates[agent.name] !== undefined,
|
|
292
281
|
});
|
|
293
282
|
}
|
|
294
283
|
// Fire lifecycle hooks around the swap — outgoing first, then incoming.
|
|
@@ -307,19 +296,12 @@ export class OrchestratingDriver extends EventTarget {
|
|
|
307
296
|
}
|
|
308
297
|
}
|
|
309
298
|
if (isSwitch && agent.onActivate) {
|
|
310
|
-
// On a session restore, hand this agent its persisted state exactly once
|
|
311
|
-
// (consumed here) so a stateful machine resumes at the right step; a later
|
|
312
|
-
// re-activation of the same agent then starts fresh.
|
|
313
|
-
const restored = this.restoredAgentStates[agent.name];
|
|
314
|
-
if (restored !== undefined)
|
|
315
|
-
delete this.restoredAgentStates[agent.name];
|
|
316
299
|
try {
|
|
317
300
|
yield agent.onActivate({
|
|
318
301
|
agentName: agent.name,
|
|
319
302
|
sessionKey: this.sessionKey,
|
|
320
303
|
previousAgentName: previousAgent === null || previousAgent === void 0 ? void 0 : previousAgent.name,
|
|
321
304
|
signal: this.lifecycleAbortController.signal,
|
|
322
|
-
restored,
|
|
323
305
|
});
|
|
324
306
|
}
|
|
325
307
|
catch (e) {
|
|
@@ -6,14 +6,9 @@ import { agenticActivityBus } from '../../channel/ai-activity-bus';
|
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
8
|
* Place this in the persistent app shell, wrapping a `foundation-ai-chat-bubble` that
|
|
9
|
-
* contains an AI assistant element in the `dialog-content` slot.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* dock, this manager **moves the one real element** between the bubble and the page
|
|
13
|
-
* layout. One connected instance means no dual-view coordination (no shared-driver
|
|
14
|
-
* unwire/rewire, host election, or duplicated side-effects); the session survives the
|
|
15
|
-
* move because the driver/store/persister live in module-level registries keyed by the
|
|
16
|
-
* element's identity.
|
|
9
|
+
* contains an AI assistant element in the `dialog-content` slot. The component will
|
|
10
|
+
* auto-create a matching collapse-mode element for docking into pages, and will
|
|
11
|
+
* control the expand button visibility based on whether a dock provider is registered.
|
|
17
12
|
*
|
|
18
13
|
* Pages that support docking call `aiPopoutManager.registerDockProvider()` on mount
|
|
19
14
|
* and `aiPopoutManager.deregisterDockProvider()` on unmount.
|
|
@@ -34,12 +29,7 @@ let FoundationAiPopoutManager = class FoundationAiPopoutManager extends GenesisE
|
|
|
34
29
|
super(...arguments);
|
|
35
30
|
/** True when a dock provider is registered — controls expand button visibility. */
|
|
36
31
|
this.canDock = false;
|
|
37
|
-
|
|
38
|
-
* The single assistant element. Captured while it's in the bubble slot and held
|
|
39
|
-
* across the move (it's the same instance whether docked or in the bubble), so
|
|
40
|
-
* pop-in can re-home it even though it's no longer a child of this manager.
|
|
41
|
-
*/
|
|
42
|
-
this.assistantEl = null;
|
|
32
|
+
this.collapseEl = null;
|
|
43
33
|
this.dockProvider = null;
|
|
44
34
|
this.isDocked = false;
|
|
45
35
|
}
|
|
@@ -47,47 +37,36 @@ let FoundationAiPopoutManager = class FoundationAiPopoutManager extends GenesisE
|
|
|
47
37
|
super.connectedCallback();
|
|
48
38
|
// oxlint-disable-next-line typescript/no-this-alias -- module-level singleton, not a local alias
|
|
49
39
|
_aiPopoutManager = this;
|
|
50
|
-
|
|
40
|
+
const bubble = this.querySelector('foundation-ai-chat-bubble');
|
|
41
|
+
const assistantEl = bubble === null || bubble === void 0 ? void 0 : bubble.querySelector('[slot="dialog-content"]');
|
|
42
|
+
if (assistantEl) {
|
|
43
|
+
this.collapseEl = document.createElement(assistantEl.tagName.toLowerCase());
|
|
44
|
+
this.collapseEl.setAttribute('popout-mode', 'collapse');
|
|
45
|
+
// Copy identity attributes so the collapse element shares the same session
|
|
46
|
+
// store and driver registry key as the expand-mode element in the bubble.
|
|
47
|
+
const headerTitle = assistantEl.getAttribute('header-title');
|
|
48
|
+
if (headerTitle)
|
|
49
|
+
this.collapseEl.setAttribute('header-title', headerTitle);
|
|
50
|
+
if (assistantEl.id)
|
|
51
|
+
this.collapseEl.id = assistantEl.id;
|
|
52
|
+
}
|
|
51
53
|
const unsubPopout = agenticActivityBus.subscribe('chat-popout', () => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
|
|
53
|
-
if (this.isDocked || !this.dockProvider)
|
|
54
|
-
return;
|
|
55
|
-
const el = ((_a = this.assistantEl) !== null && _a !== void 0 ? _a : (this.assistantEl = this.findAssistant()));
|
|
56
|
-
if (!el)
|
|
54
|
+
if (this.isDocked || !this.dockProvider || !this.collapseEl)
|
|
57
55
|
return;
|
|
58
56
|
this.isDocked = true;
|
|
59
57
|
_aiAssistantDocked = true;
|
|
60
|
-
this.
|
|
61
|
-
// Reflect the new location on the assistant so its header shows the "collapse"
|
|
62
|
-
// affordance. This is now purely cosmetic — the element stays wired across the
|
|
63
|
-
// move, so an async mode-forward by a wrapper element can't break it.
|
|
64
|
-
el.setAttribute('popout-mode', 'collapse');
|
|
65
|
-
// Hand the ONE real element to the page; the provider moves it into its layout.
|
|
66
|
-
yield this.dockProvider.onDock(el);
|
|
58
|
+
yield this.dockProvider.onDock(this.collapseEl);
|
|
67
59
|
}));
|
|
68
|
-
const unsubPopin = agenticActivityBus.subscribe('chat-popin', () =>
|
|
60
|
+
const unsubPopin = agenticActivityBus.subscribe('chat-popin', () => {
|
|
69
61
|
var _a;
|
|
70
|
-
if (!this.isDocked)
|
|
71
|
-
return;
|
|
72
62
|
this.isDocked = false;
|
|
73
63
|
_aiAssistantDocked = false;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// moved element.
|
|
77
|
-
const bubble = this.querySelector('foundation-ai-chat-bubble');
|
|
78
|
-
if (this.assistantEl && bubble) {
|
|
79
|
-
this.assistantEl.setAttribute('popout-mode', 'expand');
|
|
80
|
-
this.assistantEl.setAttribute('slot', 'dialog-content');
|
|
81
|
-
bubble.appendChild(this.assistantEl);
|
|
82
|
-
}
|
|
83
|
-
this.syncBubbleVisibility();
|
|
84
|
-
yield ((_a = this.dockProvider) === null || _a === void 0 ? void 0 : _a.onUndock());
|
|
85
|
-
}));
|
|
64
|
+
(_a = this.dockProvider) === null || _a === void 0 ? void 0 : _a.onUndock();
|
|
65
|
+
});
|
|
86
66
|
this.unsubBus = () => {
|
|
87
67
|
unsubPopout();
|
|
88
68
|
unsubPopin();
|
|
89
69
|
};
|
|
90
|
-
this.syncBubbleVisibility();
|
|
91
70
|
}
|
|
92
71
|
disconnectedCallback() {
|
|
93
72
|
var _a;
|
|
@@ -96,42 +75,14 @@ let FoundationAiPopoutManager = class FoundationAiPopoutManager extends GenesisE
|
|
|
96
75
|
this.unsubBus = undefined;
|
|
97
76
|
_aiPopoutManager = undefined;
|
|
98
77
|
}
|
|
99
|
-
/** Locate the assistant element currently slotted into the bubble. */
|
|
100
|
-
findAssistant() {
|
|
101
|
-
var _a;
|
|
102
|
-
const bubble = this.querySelector('foundation-ai-chat-bubble');
|
|
103
|
-
return (_a = bubble === null || bubble === void 0 ? void 0 : bubble.querySelector('[slot="dialog-content"]')) !== null && _a !== void 0 ? _a : null;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Register an externally-created assistant element and its docked state. For
|
|
107
|
-
* single-element hosts that create the assistant directly in a layout pane (rather
|
|
108
|
-
* than statically in the bubble), so the manager tracks the one element, whether it's
|
|
109
|
-
* currently docked (for pop-in re-homing), reflects the right `popout-mode` on it
|
|
110
|
-
* (drives the header button), and hides the empty bubble.
|
|
111
|
-
*/
|
|
112
|
-
adoptAssistant(el, docked) {
|
|
113
|
-
this.assistantEl = el;
|
|
114
|
-
this.isDocked = docked;
|
|
115
|
-
_aiAssistantDocked = docked;
|
|
116
|
-
el.setAttribute('popout-mode', docked ? 'collapse' : 'expand');
|
|
117
|
-
this.syncBubbleVisibility();
|
|
118
|
-
}
|
|
119
|
-
/** Hide the floating bubble unless it currently contains the assistant. */
|
|
120
|
-
syncBubbleVisibility() {
|
|
121
|
-
const bubble = this.querySelector('foundation-ai-chat-bubble');
|
|
122
|
-
if (!bubble)
|
|
123
|
-
return;
|
|
124
|
-
const hasAssistant = !!bubble.querySelector('[slot="dialog-content"]');
|
|
125
|
-
bubble.style.display = this.isDocked || !hasAssistant ? 'none' : '';
|
|
126
|
-
}
|
|
127
78
|
canDockChanged() {
|
|
128
|
-
|
|
129
|
-
const
|
|
79
|
+
const bubble = this.querySelector('foundation-ai-chat-bubble');
|
|
80
|
+
const assistantEl = bubble === null || bubble === void 0 ? void 0 : bubble.querySelector('[slot="dialog-content"]');
|
|
130
81
|
if (this.canDock) {
|
|
131
|
-
|
|
82
|
+
assistantEl === null || assistantEl === void 0 ? void 0 : assistantEl.setAttribute('popout-mode', 'expand');
|
|
132
83
|
}
|
|
133
84
|
else {
|
|
134
|
-
|
|
85
|
+
assistantEl === null || assistantEl === void 0 ? void 0 : assistantEl.removeAttribute('popout-mode');
|
|
135
86
|
}
|
|
136
87
|
}
|
|
137
88
|
registerDockProvider(provider) {
|
|
@@ -170,7 +121,7 @@ export { FoundationAiPopoutManager };
|
|
|
170
121
|
let _aiPopoutManager;
|
|
171
122
|
/** Whether the assistant is currently docked in the layout panel (vs bubble-only). */
|
|
172
123
|
let _aiAssistantDocked = false;
|
|
173
|
-
/** True when the assistant is active in the layout panel
|
|
124
|
+
/** True when the collapse-mode assistant is active in the layout panel. */
|
|
174
125
|
export function isAiAssistantDocked() {
|
|
175
126
|
return _aiAssistantDocked;
|
|
176
127
|
}
|
|
@@ -509,28 +509,4 @@ export const settingsModalStyles = css `
|
|
|
509
509
|
max-width: 60%;
|
|
510
510
|
line-height: 1.4;
|
|
511
511
|
}
|
|
512
|
-
|
|
513
|
-
/*
|
|
514
|
-
* Inline spinner shown in the "Download agent log" button while the log builds
|
|
515
|
-
* (GENC-1351 §5.8) — the lifetime-stitch path is an async provider round-trip.
|
|
516
|
-
* Sized to the button label and tinted with currentColor so it tracks the
|
|
517
|
-
* button's text colour in every appearance / theme.
|
|
518
|
-
*/
|
|
519
|
-
[part='download-button'] .download-spinner {
|
|
520
|
-
display: inline-block;
|
|
521
|
-
width: 12px;
|
|
522
|
-
height: 12px;
|
|
523
|
-
margin-right: calc(var(--design-unit) * 1px);
|
|
524
|
-
vertical-align: -1px;
|
|
525
|
-
border: 2px solid currentColor;
|
|
526
|
-
border-right-color: transparent;
|
|
527
|
-
border-radius: 50%;
|
|
528
|
-
animation: download-spin 0.6s linear infinite;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
@keyframes download-spin {
|
|
532
|
-
to {
|
|
533
|
-
transform: rotate(360deg);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
512
|
`;
|
|
@@ -121,9 +121,6 @@ const chatBotSettingsTemplate = (switchTag, buttonTag) => html `
|
|
|
121
121
|
}))}
|
|
122
122
|
${when((x) => { var _a; return ((_a = x.chatConfig.ui) === null || _a === void 0 ? void 0 : _a.showAgentSwitchIndicator) != null; }, chatBotToggleRow('Show delegation', 'Show in the chat window when tasks are delegated to different agents.', switchTag, 'toggle-agent-switch', (x) => x.showAgentSwitchIndicator, (x, c) => {
|
|
123
123
|
x.showAgentSwitchIndicator = readSwitchChecked(c.event);
|
|
124
|
-
}))}
|
|
125
|
-
${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) => {
|
|
126
|
-
x.setPersistenceEnabled(readSwitchChecked(c.event));
|
|
127
124
|
}))}
|
|
128
125
|
${when((x) => { var _a, _b; return ((_b = (_a = x.chatConfig.ui) === null || _a === void 0 ? void 0 : _a.animations) === null || _b === void 0 ? void 0 : _b.userConfigurable) === true; }, settingsToggleRow('Animations', 'Choose which loading and activity indicators appear while the assistant is working.', 'toggle-animations', animationsPickerTemplate(switchTag), 'column'))}
|
|
129
126
|
`;
|
|
@@ -322,18 +319,8 @@ export const SettingsModalTemplate = (designSystemPrefix) => {
|
|
|
322
319
|
<${buttonTag}
|
|
323
320
|
part="download-button"
|
|
324
321
|
appearance="outline"
|
|
325
|
-
?disabled=${(x) => x.downloadingDebugLog}
|
|
326
322
|
@click=${(x) => x.downloadDebugLog()}
|
|
327
|
-
>
|
|
328
|
-
${when((x) => x.downloadingDebugLog, html `
|
|
329
|
-
<span
|
|
330
|
-
class="download-spinner"
|
|
331
|
-
part="download-spinner"
|
|
332
|
-
aria-hidden="true"
|
|
333
|
-
></span>
|
|
334
|
-
`)}
|
|
335
|
-
${(x) => (x.downloadingDebugLog ? 'Downloading…' : 'Download')}
|
|
336
|
-
</${buttonTag}>
|
|
323
|
+
>Download</${buttonTag}>
|
|
337
324
|
`)}
|
|
338
325
|
</div>
|
|
339
326
|
</section>
|
|
@@ -32,61 +32,6 @@ function defaultStatefulDebugSnapshot(state) {
|
|
|
32
32
|
? result
|
|
33
33
|
: '<no auto-snapshot — state has no machine-shaped properties; provide getDebugSnapshot>';
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Build a restore-ready snapshot of agent state. Each property exposing a
|
|
37
|
-
* `getPersistedSnapshot()` method (a foundation-state-machine `AbstractMachine`)
|
|
38
|
-
* is replaced by its persisted snapshot — the lossless, JSON-safe image
|
|
39
|
-
* {@link restoreMachine} feeds back via `start({ state })`. Every other property
|
|
40
|
-
* is kept as-is, so plain serializable state (e.g. a planner's `{ plan, cursor }`)
|
|
41
|
-
* round-trips directly with no per-agent `serialize`.
|
|
42
|
-
*
|
|
43
|
-
* Distinct from `defaultStatefulDebugSnapshot`, which abbreviates for the debug
|
|
44
|
-
* log and is not guaranteed lossless.
|
|
45
|
-
*/
|
|
46
|
-
function defaultStatefulSerialize(state) {
|
|
47
|
-
if (!state || typeof state !== 'object')
|
|
48
|
-
return state;
|
|
49
|
-
const result = {};
|
|
50
|
-
for (const [key, val] of Object.entries(state)) {
|
|
51
|
-
result[key] =
|
|
52
|
-
val &&
|
|
53
|
-
typeof val === 'object' &&
|
|
54
|
-
typeof val.getPersistedSnapshot === 'function'
|
|
55
|
-
? val.getPersistedSnapshot()
|
|
56
|
-
: val;
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Restore a foundation-state-machine instance from a snapshot produced by the
|
|
62
|
-
* default serializer (or `machine.getPersistedSnapshot()`). Call inside a
|
|
63
|
-
* stateful agent's `init` to resume the machine in its exact prior place:
|
|
64
|
-
*
|
|
65
|
-
* ```ts
|
|
66
|
-
* init: ({ restored }) => {
|
|
67
|
-
* const machine = new MyMachine();
|
|
68
|
-
* restoreMachine(machine, restored); // resume, or no-op on a fresh start
|
|
69
|
-
* return { machine };
|
|
70
|
-
* }
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* No-ops when there is nothing to restore (a fresh session), leaving the
|
|
74
|
-
* freshly-constructed machine in its initial state.
|
|
75
|
-
*
|
|
76
|
-
* @param machine - the machine to restore (already constructed/started).
|
|
77
|
-
* @param restored - the agent's serialized image (`ctx.restored` in `init`).
|
|
78
|
-
* @param key - the property the machine occupies in the snapshot; defaults to
|
|
79
|
-
* `'machine'` to match the conventional `{ machine }` state bag.
|
|
80
|
-
* @beta
|
|
81
|
-
*/
|
|
82
|
-
export function restoreMachine(machine, restored, key = 'machine') {
|
|
83
|
-
const snapshot = restored === null || restored === void 0 ? void 0 : restored[key];
|
|
84
|
-
if (snapshot === undefined || snapshot === null) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
machine.stop();
|
|
88
|
-
machine.start({ state: snapshot });
|
|
89
|
-
}
|
|
90
35
|
/**
|
|
91
36
|
* Build an `AgentConfig` whose `systemPrompt`, `toolDefinitions`, and tool
|
|
92
37
|
* handlers all close over a long-lived state object created on activation.
|
|
@@ -219,23 +164,6 @@ export function defineStatefulAgent(opts) {
|
|
|
219
164
|
return opts.onUnresolvedTool(Object.assign(Object.assign({}, ctx), { state }));
|
|
220
165
|
})
|
|
221
166
|
: opts.onUnresolvedTool;
|
|
222
|
-
// `resumable` threads the LIVE state bag in (like the resolvers above) rather
|
|
223
|
-
// than the serialized image the raw `AgentConfig` form receives — so a machine
|
|
224
|
-
// agent gates on `state.machine.state` directly. Consulted only while active
|
|
225
|
-
// (state is set); a pre-init call degrades to `true` (resumable, fail-safe).
|
|
226
|
-
const wrappedResumable = opts.resumable
|
|
227
|
-
? (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
228
|
-
if (state === undefined)
|
|
229
|
-
return true;
|
|
230
|
-
return opts.resumable({
|
|
231
|
-
agentName: ctx.agentName,
|
|
232
|
-
sessionKey: ctx.sessionKey,
|
|
233
|
-
messages: ctx.messages,
|
|
234
|
-
isFlowOwner: ctx.isFlowOwner,
|
|
235
|
-
state,
|
|
236
|
-
});
|
|
237
|
-
})
|
|
238
|
-
: undefined;
|
|
239
167
|
const base = {
|
|
240
168
|
name: opts.name,
|
|
241
169
|
displayName: wrappedDisplayName,
|
|
@@ -251,8 +179,6 @@ export function defineStatefulAgent(opts) {
|
|
|
251
179
|
cachePolicy: wrappedCachePolicy,
|
|
252
180
|
tailContext: wrappedTailContext,
|
|
253
181
|
onUnresolvedTool: wrappedOnUnresolvedTool,
|
|
254
|
-
resumable: wrappedResumable,
|
|
255
|
-
notResumableMessage: opts.notResumableMessage,
|
|
256
182
|
onActivate: (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
257
183
|
state = yield opts.init(ctx);
|
|
258
184
|
// Sample once with the init state to fail loud on fold misuse at the
|
|
@@ -293,13 +219,6 @@ export function defineStatefulAgent(opts) {
|
|
|
293
219
|
? opts.getDebugSnapshot(state)
|
|
294
220
|
: defaultStatefulDebugSnapshot(state);
|
|
295
221
|
},
|
|
296
|
-
// Lossless restore image for session persistence (see `serialize` on the
|
|
297
|
-
// config). Returns undefined before activation / after disposal.
|
|
298
|
-
serialize: () => {
|
|
299
|
-
if (state === undefined)
|
|
300
|
-
return undefined;
|
|
301
|
-
return opts.serialize ? opts.serialize(state) : defaultStatefulSerialize(state);
|
|
302
|
-
},
|
|
303
222
|
};
|
|
304
223
|
return Object.assign(Object.assign({}, base), { description: opts.description, excludeFromClassifier: opts.excludeFromClassifier });
|
|
305
224
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -11,7 +11,6 @@ export * from './channel/ai-activity-bus';
|
|
|
11
11
|
export * from './config/config';
|
|
12
12
|
export * from './config/define-stateful-agent';
|
|
13
13
|
export * from './config/fallback-agents';
|
|
14
|
-
export * from './state/persistence';
|
|
15
14
|
export * from './provider/ai-provider-switcher';
|
|
16
15
|
export * from './provider/assistant-app-settings';
|
|
17
16
|
export * from './utils/tool-fold';
|