@genesislcap/ai-assistant 14.409.0-FUI-2495.2 → 14.409.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 +1110 -2791
- package/dist/ai-assistant.d.ts +45 -267
- package/dist/dts/channel/ai-activity-channel.d.ts +0 -1
- package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts +7 -25
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/halo-overlay.d.ts +1 -13
- package/dist/dts/components/halo-overlay.d.ts.map +1 -1
- package/dist/dts/config/config.d.ts +15 -43
- package/dist/dts/config/config.d.ts.map +1 -1
- package/dist/dts/config/index.d.ts +0 -1
- package/dist/dts/config/index.d.ts.map +1 -1
- package/dist/dts/index.d.ts +0 -4
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +7 -16
- 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/esm/components/chat-driver/chat-driver.js +31 -86
- package/dist/esm/components/halo-overlay.js +7 -53
- package/dist/esm/config/index.js +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/main/main.js +45 -103
- package/dist/esm/main/main.styles.js +4 -145
- package/dist/esm/main/main.template.js +61 -97
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
- package/src/channel/ai-activity-channel.ts +0 -1
- package/src/components/chat-driver/chat-driver.ts +35 -116
- package/src/components/halo-overlay.ts +7 -45
- package/src/config/config.ts +15 -45
- package/src/config/index.ts +0 -1
- package/src/index.ts +0 -4
- package/src/main/main.styles.ts +4 -145
- package/src/main/main.template.ts +78 -116
- package/src/main/main.ts +50 -105
- package/dist/dts/components/ai-driver/ai-driver.d.ts +0 -38
- package/dist/dts/components/ai-driver/ai-driver.d.ts.map +0 -1
- package/dist/dts/components/ai-driver/index.d.ts +0 -2
- package/dist/dts/components/ai-driver/index.d.ts.map +0 -1
- package/dist/dts/components/orchestrating-driver/index.d.ts +0 -2
- package/dist/dts/components/orchestrating-driver/index.d.ts.map +0 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +0 -36
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +0 -1
- package/dist/dts/components/popout-manager/index.d.ts +0 -2
- package/dist/dts/components/popout-manager/index.d.ts.map +0 -1
- package/dist/dts/components/popout-manager/popout-manager.d.ts +0 -74
- package/dist/dts/components/popout-manager/popout-manager.d.ts.map +0 -1
- package/dist/dts/config/fallback-agents.d.ts +0 -20
- package/dist/dts/config/fallback-agents.d.ts.map +0 -1
- package/dist/esm/components/ai-driver/ai-driver.js +0 -1
- package/dist/esm/components/ai-driver/index.js +0 -1
- package/dist/esm/components/orchestrating-driver/index.js +0 -1
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +0 -229
- package/dist/esm/components/popout-manager/index.js +0 -1
- package/dist/esm/components/popout-manager/popout-manager.js +0 -119
- package/dist/esm/config/fallback-agents.js +0 -26
- package/src/components/ai-driver/ai-driver.ts +0 -42
- package/src/components/ai-driver/index.ts +0 -1
- package/src/components/orchestrating-driver/index.ts +0 -1
- package/src/components/orchestrating-driver/orchestrating-driver.ts +0 -300
- package/src/components/popout-manager/index.ts +0 -1
- package/src/components/popout-manager/popout-manager.ts +0 -144
- package/src/config/fallback-agents.ts +0 -29
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { logger } from '../../utils/logger';
|
|
3
|
-
import { ChatDriver, REQUEST_CONTINUATION_TOOL } from '../chat-driver/chat-driver';
|
|
4
|
-
const DEFAULT_MAX_HANDOFFS = 3;
|
|
5
|
-
const DEFAULT_CLASSIFIER_HISTORY_LENGTH = 4;
|
|
6
|
-
const DEFAULT_CLASSIFIER_RETRIES = 2;
|
|
7
|
-
const REQUEST_CONTINUATION_DEFINITION = {
|
|
8
|
-
name: REQUEST_CONTINUATION_TOOL,
|
|
9
|
-
description: "Call this when you have completed your part of the task but fulfilling the user's full request requires capabilities outside your domain. Do not call this if you can complete the request yourself. Pass a plain-language description of what still needs to be done — another specialist will be selected automatically.",
|
|
10
|
-
parameters: {
|
|
11
|
-
type: 'object',
|
|
12
|
-
required: ['summary', 'remaining_task'],
|
|
13
|
-
properties: {
|
|
14
|
-
summary: {
|
|
15
|
-
type: 'string',
|
|
16
|
-
description: 'What you found or did — passed as context to the next specialist.',
|
|
17
|
-
},
|
|
18
|
-
remaining_task: {
|
|
19
|
-
type: 'string',
|
|
20
|
-
description: 'What still needs to be done, in plain language. Used to route to the right specialist.',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
function isSpecialist(agent) {
|
|
26
|
-
return !agent.fallback;
|
|
27
|
-
}
|
|
28
|
-
function isFallback(agent) {
|
|
29
|
-
return agent.fallback === true;
|
|
30
|
-
}
|
|
31
|
-
function buildFallbackSystemPrompt(fallback, specialists) {
|
|
32
|
-
const agentList = specialists.map((s) => `- ${s.name}: ${s.description}`).join('\n');
|
|
33
|
-
if (fallback.systemPrompt) {
|
|
34
|
-
return fallback.systemPrompt.replace('{{agents}}', agentList);
|
|
35
|
-
}
|
|
36
|
-
return `You are a helpful assistant. You cannot directly help with the user's request, but the following specialists are available:\n\n${agentList}\n\nPolitely let the user know what you can help with and invite them to rephrase their request.`;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Prepares the history for a given agent by masking tool call args and results
|
|
40
|
-
* produced by other agents — preserving conversation structure without leaking
|
|
41
|
-
* irrelevant domain data into the active agent's context.
|
|
42
|
-
*/
|
|
43
|
-
function transformHistoryForAgent(history, agentName) {
|
|
44
|
-
return history.map((msg) => {
|
|
45
|
-
var _a;
|
|
46
|
-
if (!msg.agentName || msg.agentName === agentName)
|
|
47
|
-
return msg;
|
|
48
|
-
if ((_a = msg.toolCalls) === null || _a === void 0 ? void 0 : _a.length) {
|
|
49
|
-
return Object.assign(Object.assign({}, msg), { toolCalls: msg.toolCalls.map((tc) => (Object.assign(Object.assign({}, tc), { args: {} }))) });
|
|
50
|
-
}
|
|
51
|
-
if (msg.toolResult) {
|
|
52
|
-
return Object.assign(Object.assign({}, msg), { content: "[other agent's tool result omitted]" });
|
|
53
|
-
}
|
|
54
|
-
return msg;
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Orchestrates multiple specialist agents. Sits between `FoundationAiAssistant`
|
|
59
|
-
* and `ChatDriver`, classifying each user message and routing it to the right
|
|
60
|
-
* specialist — each with its own focused system prompt, tools, and primer.
|
|
61
|
-
*
|
|
62
|
-
* @beta
|
|
63
|
-
*/
|
|
64
|
-
export class OrchestratingDriver extends EventTarget {
|
|
65
|
-
constructor(aiProvider, agents, options = {}) {
|
|
66
|
-
var _a, _b, _c;
|
|
67
|
-
super();
|
|
68
|
-
this.aiProvider = aiProvider;
|
|
69
|
-
this.agents = agents;
|
|
70
|
-
this.maxHandoffs = (_a = options.maxHandoffs) !== null && _a !== void 0 ? _a : DEFAULT_MAX_HANDOFFS;
|
|
71
|
-
this.classifierHistoryLength =
|
|
72
|
-
(_b = options.classifierHistoryLength) !== null && _b !== void 0 ? _b : DEFAULT_CLASSIFIER_HISTORY_LENGTH;
|
|
73
|
-
this.classifierRetries = (_c = options.classifierRetries) !== null && _c !== void 0 ? _c : DEFAULT_CLASSIFIER_RETRIES;
|
|
74
|
-
this.specialists = agents.filter(isSpecialist);
|
|
75
|
-
const fallbacks = agents.filter(isFallback);
|
|
76
|
-
if (fallbacks.length > 1) {
|
|
77
|
-
logger.warn('OrchestratingDriver: multiple fallback agents found — only the first will be used.');
|
|
78
|
-
}
|
|
79
|
-
const rawFallback = fallbacks[0];
|
|
80
|
-
this.fallback = rawFallback
|
|
81
|
-
? Object.assign(Object.assign({}, rawFallback), { systemPrompt: buildFallbackSystemPrompt(rawFallback, this.specialists) }) : undefined;
|
|
82
|
-
this.chatDriver = new ChatDriver(aiProvider, {}, [], undefined, undefined, options.maxToolIterations);
|
|
83
|
-
// Proxy history-updated events from the shared driver
|
|
84
|
-
this.chatDriver.addEventListener('history-updated', (e) => {
|
|
85
|
-
this.dispatchEvent(new CustomEvent('history-updated', { detail: e.detail }));
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
resolveInteraction(interactionId, result) {
|
|
89
|
-
this.chatDriver.resolveInteraction(interactionId, result);
|
|
90
|
-
}
|
|
91
|
-
loadHistory(messages) {
|
|
92
|
-
this.chatDriver.loadHistory(messages);
|
|
93
|
-
}
|
|
94
|
-
getRawHistory() {
|
|
95
|
-
return this.chatDriver.getHistory();
|
|
96
|
-
}
|
|
97
|
-
sendMessage(input, attachments) {
|
|
98
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
const history = this.chatDriver.getHistory();
|
|
100
|
-
this.dispatchEvent(new CustomEvent('orchestrating-start'));
|
|
101
|
-
let currentAgent = yield this.classify(input, history);
|
|
102
|
-
let isHandoff = false;
|
|
103
|
-
let handoffs = 0;
|
|
104
|
-
let handoffSummary = '';
|
|
105
|
-
let remainingTask = '';
|
|
106
|
-
while (true) {
|
|
107
|
-
this.applyAgent(currentAgent);
|
|
108
|
-
let result;
|
|
109
|
-
if (isHandoff) {
|
|
110
|
-
const contextPrimer = handoffSummary
|
|
111
|
-
? [{ role: 'user', content: `[Context from previous agent]: ${handoffSummary}` }]
|
|
112
|
-
: [];
|
|
113
|
-
// eslint-disable-next-line no-await-in-loop
|
|
114
|
-
result = yield this.chatDriver.continueFromHistory(contextPrimer);
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
// eslint-disable-next-line no-await-in-loop
|
|
118
|
-
result = yield this.chatDriver.sendMessage(input, attachments);
|
|
119
|
-
}
|
|
120
|
-
if (result.reason !== 'agent-handoff' || isFallback(currentAgent)) {
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
handoffs += 1;
|
|
124
|
-
if (handoffs > this.maxHandoffs) {
|
|
125
|
-
this.appendInlineMessage(`I wasn't able to fully complete your request — the task required more hand-offs between specialists than allowed (max: ${this.maxHandoffs}). Please try breaking your request into smaller steps.`);
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
handoffSummary = result.summary;
|
|
129
|
-
remainingTask = result.remainingTask;
|
|
130
|
-
isHandoff = true;
|
|
131
|
-
const updatedHistory = this.chatDriver.getHistory();
|
|
132
|
-
this.dispatchEvent(new CustomEvent('orchestrating-start'));
|
|
133
|
-
// eslint-disable-next-line no-await-in-loop
|
|
134
|
-
currentAgent = yield this.classify(remainingTask, updatedHistory);
|
|
135
|
-
}
|
|
136
|
-
return { reason: 'done' };
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
continueFromHistory(transientPrimer) {
|
|
140
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
return this.chatDriver.continueFromHistory(transientPrimer);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
applyAgent(agent) {
|
|
145
|
-
var _a;
|
|
146
|
-
// Fallback agents are terminal and should not hand off to other specialists
|
|
147
|
-
const agentToApply = isFallback(agent)
|
|
148
|
-
? agent
|
|
149
|
-
: Object.assign(Object.assign({}, agent), { toolDefinitions: [...((_a = agent.toolDefinitions) !== null && _a !== void 0 ? _a : []), REQUEST_CONTINUATION_DEFINITION] });
|
|
150
|
-
// Mask history from other agents before handing context to this specialist
|
|
151
|
-
const rawHistory = this.chatDriver.getHistory();
|
|
152
|
-
const maskedHistory = transformHistoryForAgent(rawHistory, agent.name);
|
|
153
|
-
// Inject an agent switch indicator when the active specialist changes
|
|
154
|
-
const previousAgent = this.activeAgent;
|
|
155
|
-
if (previousAgent && previousAgent.name !== agent.name) {
|
|
156
|
-
maskedHistory.push({ role: 'system-event', content: agent.name });
|
|
157
|
-
}
|
|
158
|
-
this.chatDriver.loadHistory(maskedHistory);
|
|
159
|
-
this.chatDriver.applyAgent(agentToApply);
|
|
160
|
-
this.activeAgent = agent;
|
|
161
|
-
this.dispatchEvent(new CustomEvent('orchestrating-stop'));
|
|
162
|
-
this.dispatchEvent(new CustomEvent('agent-changed', { detail: agent }));
|
|
163
|
-
}
|
|
164
|
-
classify(input, history) {
|
|
165
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
var _a, _b;
|
|
167
|
-
if (this.specialists.length === 0) {
|
|
168
|
-
return (_a = this.fallback) !== null && _a !== void 0 ? _a : { name: 'Assistant', fallback: true };
|
|
169
|
-
}
|
|
170
|
-
const agentList = this.specialists
|
|
171
|
-
.map((a, i) => `${i}: ${a.name} — ${a.description}`)
|
|
172
|
-
.join('\n');
|
|
173
|
-
const recentMessages = history
|
|
174
|
-
.filter((m) => m.role === 'user' || m.role === 'assistant')
|
|
175
|
-
.slice(-this.classifierHistoryLength)
|
|
176
|
-
.map((m) => `${m.role === 'user' ? 'User' : 'Assistant'}: ${m.content}`)
|
|
177
|
-
.join('\n');
|
|
178
|
-
const classifierPrompt = `You are a routing classifier. Call select_agent with the index of the best matching agent for the user message. Use -1 only if the request is entirely unrelated to every agent listed — prefer the closest match when in doubt. If the request spans multiple agents, pick the one that should act first; I will re-classify and route again once that agent is done.\n\nAgents:\n${agentList}${recentMessages ? `\n\nRecent conversation:\n${recentMessages}` : ''}`;
|
|
179
|
-
const routingTool = {
|
|
180
|
-
name: 'select_agent',
|
|
181
|
-
description: 'Select the most appropriate agent for the user message.',
|
|
182
|
-
parameters: {
|
|
183
|
-
type: 'object',
|
|
184
|
-
required: ['agent_index'],
|
|
185
|
-
properties: {
|
|
186
|
-
agent_index: {
|
|
187
|
-
type: 'integer',
|
|
188
|
-
description: 'Zero-based index of the matching agent, or -1 if no agent matches.',
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
for (let attempt = 0; attempt <= this.classifierRetries; attempt += 1) {
|
|
194
|
-
try {
|
|
195
|
-
const options = {
|
|
196
|
-
systemPrompt: classifierPrompt,
|
|
197
|
-
tools: [routingTool],
|
|
198
|
-
};
|
|
199
|
-
// eslint-disable-next-line no-await-in-loop
|
|
200
|
-
const response = yield this.aiProvider.chat([], input, options);
|
|
201
|
-
const tc = (_b = response.toolCalls) === null || _b === void 0 ? void 0 : _b[0];
|
|
202
|
-
const index = (tc === null || tc === void 0 ? void 0 : tc.name) === 'select_agent' ? tc.args.agent_index : -1;
|
|
203
|
-
if (index >= 0 && index < this.specialists.length) {
|
|
204
|
-
return this.specialists[index];
|
|
205
|
-
}
|
|
206
|
-
// index === -1 — fall through to fallback
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
catch (e) {
|
|
210
|
-
logger.warn(`OrchestratingDriver: classifier attempt ${attempt + 1} failed:`, e);
|
|
211
|
-
if (attempt === this.classifierRetries) {
|
|
212
|
-
logger.error('OrchestratingDriver: classifier failed after all retries, using fallback');
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
if (this.fallback)
|
|
217
|
-
return this.fallback;
|
|
218
|
-
// No fallback configured — emit an inline response and return first specialist as no-op
|
|
219
|
-
const specialistNames = this.specialists.map((s) => s.name).join(', ');
|
|
220
|
-
this.appendInlineMessage(`I'm not sure how to help with that. I can assist with: ${specialistNames}.`);
|
|
221
|
-
return this.specialists[0];
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
appendInlineMessage(content) {
|
|
225
|
-
const history = this.chatDriver.getHistory();
|
|
226
|
-
this.chatDriver.loadHistory([...history, { role: 'assistant', content }]);
|
|
227
|
-
this.dispatchEvent(new CustomEvent('history-updated', { detail: this.chatDriver.getHistory() }));
|
|
228
|
-
}
|
|
229
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './popout-manager';
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { __awaiter, __decorate } from "tslib";
|
|
2
|
-
import { customElement, GenesisElement, html, observable } from '@genesislcap/web-core';
|
|
3
|
-
import { agenticActivityBus } from '../../channel/ai-activity-bus';
|
|
4
|
-
/**
|
|
5
|
-
* App-shell component that owns the pop-out/pop-in lifecycle for the AI assistant bubble.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
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. 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.
|
|
12
|
-
*
|
|
13
|
-
* Pages that support docking call `aiPopoutManager.registerDockProvider()` on mount
|
|
14
|
-
* and `aiPopoutManager.deregisterDockProvider()` on unmount.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```html
|
|
18
|
-
* <foundation-ai-popout-manager>
|
|
19
|
-
* <foundation-ai-chat-bubble title="My Assistant">
|
|
20
|
-
* <my-assistant slot="dialog-content"></my-assistant>
|
|
21
|
-
* </foundation-ai-chat-bubble>
|
|
22
|
-
* </foundation-ai-popout-manager>
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @beta
|
|
26
|
-
*/
|
|
27
|
-
let FoundationAiPopoutManager = class FoundationAiPopoutManager extends GenesisElement {
|
|
28
|
-
constructor() {
|
|
29
|
-
super(...arguments);
|
|
30
|
-
/** True when a dock provider is registered — controls expand button visibility. */
|
|
31
|
-
this.canDock = false;
|
|
32
|
-
this.collapseEl = null;
|
|
33
|
-
this.dockProvider = null;
|
|
34
|
-
this.isDocked = false;
|
|
35
|
-
}
|
|
36
|
-
connectedCallback() {
|
|
37
|
-
super.connectedCallback();
|
|
38
|
-
_aiPopoutManager = this;
|
|
39
|
-
const bubble = this.querySelector('foundation-ai-chat-bubble');
|
|
40
|
-
const assistantEl = bubble === null || bubble === void 0 ? void 0 : bubble.querySelector('[slot="dialog-content"]');
|
|
41
|
-
if (assistantEl) {
|
|
42
|
-
this.collapseEl = document.createElement(assistantEl.tagName.toLowerCase());
|
|
43
|
-
this.collapseEl.setAttribute('popout-mode', 'collapse');
|
|
44
|
-
}
|
|
45
|
-
const unsubPopout = agenticActivityBus.subscribe('chat-popout', (_a) => __awaiter(this, [_a], void 0, function* ({ state }) {
|
|
46
|
-
if (this.isDocked || !this.dockProvider || !this.collapseEl)
|
|
47
|
-
return;
|
|
48
|
-
this.isDocked = true;
|
|
49
|
-
yield this.dockProvider.onDock(this.collapseEl, state);
|
|
50
|
-
}));
|
|
51
|
-
const unsubPopin = agenticActivityBus.subscribe('chat-popin', () => {
|
|
52
|
-
var _a;
|
|
53
|
-
this.isDocked = false;
|
|
54
|
-
(_a = this.dockProvider) === null || _a === void 0 ? void 0 : _a.onUndock();
|
|
55
|
-
});
|
|
56
|
-
this.unsubBus = () => {
|
|
57
|
-
unsubPopout();
|
|
58
|
-
unsubPopin();
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
disconnectedCallback() {
|
|
62
|
-
var _a;
|
|
63
|
-
super.disconnectedCallback();
|
|
64
|
-
(_a = this.unsubBus) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
65
|
-
this.unsubBus = undefined;
|
|
66
|
-
_aiPopoutManager = undefined;
|
|
67
|
-
}
|
|
68
|
-
canDockChanged() {
|
|
69
|
-
const bubble = this.querySelector('foundation-ai-chat-bubble');
|
|
70
|
-
const assistantEl = bubble === null || bubble === void 0 ? void 0 : bubble.querySelector('[slot="dialog-content"]');
|
|
71
|
-
if (this.canDock) {
|
|
72
|
-
assistantEl === null || assistantEl === void 0 ? void 0 : assistantEl.setAttribute('popout-mode', 'expand');
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
assistantEl === null || assistantEl === void 0 ? void 0 : assistantEl.removeAttribute('popout-mode');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
registerDockProvider(provider) {
|
|
79
|
-
this.dockProvider = provider;
|
|
80
|
-
this.canDock = true;
|
|
81
|
-
}
|
|
82
|
-
deregisterDockProvider() {
|
|
83
|
-
this.isDocked = false;
|
|
84
|
-
this.dockProvider = null;
|
|
85
|
-
this.canDock = false;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* If the assistant is currently docked, collapses it back into the bubble.
|
|
89
|
-
* Await this in `onBeforeNavButtonClick` to ensure cleanup before navigation.
|
|
90
|
-
*/
|
|
91
|
-
collapseIfDocked() {
|
|
92
|
-
if (!this.isDocked || !this.dockProvider)
|
|
93
|
-
return Promise.resolve();
|
|
94
|
-
this.dockProvider.initiateCollapse();
|
|
95
|
-
return Promise.resolve();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
__decorate([
|
|
99
|
-
observable
|
|
100
|
-
], FoundationAiPopoutManager.prototype, "canDock", void 0);
|
|
101
|
-
FoundationAiPopoutManager = __decorate([
|
|
102
|
-
customElement({
|
|
103
|
-
name: 'foundation-ai-popout-manager',
|
|
104
|
-
template: html `
|
|
105
|
-
<slot></slot>
|
|
106
|
-
`,
|
|
107
|
-
})
|
|
108
|
-
], FoundationAiPopoutManager);
|
|
109
|
-
export { FoundationAiPopoutManager };
|
|
110
|
-
let _aiPopoutManager;
|
|
111
|
-
/**
|
|
112
|
-
* Returns the active `FoundationAiPopoutManager` instance, or `undefined` if none is mounted.
|
|
113
|
-
* Import this in pages to call `registerDockProvider` / `deregisterDockProvider`.
|
|
114
|
-
*
|
|
115
|
-
* @beta
|
|
116
|
-
*/
|
|
117
|
-
export function getAiPopoutManager() {
|
|
118
|
-
return _aiPopoutManager;
|
|
119
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A warm, conversational fallback agent. Acknowledges it can't help directly,
|
|
3
|
-
* explains what the available specialists can do, and invites the user to retry.
|
|
4
|
-
*
|
|
5
|
-
* The system prompt is generated at runtime by `OrchestratingDriver` from the
|
|
6
|
-
* specialist list — no manual authoring required.
|
|
7
|
-
*
|
|
8
|
-
* @beta
|
|
9
|
-
*/
|
|
10
|
-
export const friendlyFallbackAgent = {
|
|
11
|
-
name: 'Assistant',
|
|
12
|
-
fallback: true,
|
|
13
|
-
systemPrompt: `You are a warm, friendly assistant. For general conversation like "Hi" or "How are you", you can have a friendly chat. For anything more complex, you cannot directly help, but you can explain what specialists are available. The available specialists are:\n\n{{agents}}\n\nPolitely let the user know what you can help with and invite them to rephrase their request if it is outside your scope.`,
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* A brief, professional fallback agent. States what is available without
|
|
17
|
-
* elaboration. The `{{agents}}` placeholder is replaced at runtime by
|
|
18
|
-
* `OrchestratingDriver` with the generated specialist list.
|
|
19
|
-
*
|
|
20
|
-
* @beta
|
|
21
|
-
*/
|
|
22
|
-
export const strictFallbackAgent = {
|
|
23
|
-
name: 'Assistant',
|
|
24
|
-
fallback: true,
|
|
25
|
-
systemPrompt: `You are a concise assistant. The user's request is outside your scope. Respond with a single short sentence stating what you can assist with. Do not elaborate. The available specialists are: {{agents}}.`,
|
|
26
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { ChatAttachment, ChatDriverResult, ChatMessage } from '@genesislcap/foundation-ai';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Common interface implemented by both `ChatDriver` (single-agent) and
|
|
5
|
-
* `OrchestratingDriver` (multi-agent). `FoundationAiAssistant` depends only
|
|
6
|
-
* on this interface — the concrete class is chosen at startup based on how
|
|
7
|
-
* many agents are configured.
|
|
8
|
-
*
|
|
9
|
-
* Extends `EventTarget` so consumers can subscribe to `history-updated` events
|
|
10
|
-
* without knowing the concrete implementation.
|
|
11
|
-
*
|
|
12
|
-
* @beta
|
|
13
|
-
*/
|
|
14
|
-
export interface AiDriver extends EventTarget {
|
|
15
|
-
/**
|
|
16
|
-
* Send a user message and run the tool loop to completion.
|
|
17
|
-
*/
|
|
18
|
-
sendMessage(input: string, attachments?: ChatAttachment[]): Promise<ChatDriverResult>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Continue the tool loop from the current history without appending a new
|
|
22
|
-
* user message. Used by `OrchestratingDriver` on agent handoffs — the
|
|
23
|
-
* handoff context is already in history; `transientPrimer` is injected as
|
|
24
|
-
* an invisible one-shot message for this call only.
|
|
25
|
-
*/
|
|
26
|
-
continueFromHistory(transientPrimer?: ChatMessage[]): Promise<ChatDriverResult>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Resolve a pending blocking interaction with the given result.
|
|
30
|
-
*/
|
|
31
|
-
resolveInteraction(interactionId: string, result: unknown): void;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Seed the driver's message history (called on state restore / pop-in).
|
|
35
|
-
*/
|
|
36
|
-
loadHistory(messages: ChatMessage[]): void;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Return the full, unredacted conversation history.
|
|
40
|
-
*/
|
|
41
|
-
getRawHistory?(): readonly ChatMessage[];
|
|
42
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { AiDriver } from './ai-driver';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { OrchestratingDriver } from './orchestrating-driver';
|