fluxy-bot 0.2.6 → 0.2.8
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/package.json +1 -1
- package/supervisor/index.ts +13 -5
package/package.json
CHANGED
package/supervisor/index.ts
CHANGED
|
@@ -125,9 +125,17 @@ export async function startSupervisor() {
|
|
|
125
125
|
if (!content) return;
|
|
126
126
|
if (data.conversationId) convId = data.conversationId;
|
|
127
127
|
|
|
128
|
+
// Re-read config on each message so post-onboard changes are picked up
|
|
129
|
+
const freshConfig = loadConfig();
|
|
130
|
+
const freshAi = (freshConfig.ai.provider && (freshConfig.ai.apiKey || freshConfig.ai.provider === 'ollama'))
|
|
131
|
+
? createProvider(freshConfig.ai.provider, freshConfig.ai.apiKey, freshConfig.ai.baseUrl)
|
|
132
|
+
: null;
|
|
133
|
+
|
|
134
|
+
log.info(`[fluxy] provider=${freshConfig.ai.provider}, model=${freshConfig.ai.model}, hasApiKey=${!!freshConfig.ai.apiKey}`);
|
|
135
|
+
|
|
128
136
|
// Route Anthropic through Agent SDK (uses OAuth token, not API key)
|
|
129
|
-
if (
|
|
130
|
-
startFluxyAgentQuery(convId, content,
|
|
137
|
+
if (freshConfig.ai.provider === 'anthropic') {
|
|
138
|
+
startFluxyAgentQuery(convId, content, freshConfig.ai.model, (type, eventData) => {
|
|
131
139
|
// Intercept bot:done to trigger rebuild if file tools were used
|
|
132
140
|
if (type === 'bot:done') {
|
|
133
141
|
if (eventData.usedFileTools) {
|
|
@@ -158,16 +166,16 @@ export async function startSupervisor() {
|
|
|
158
166
|
const history = conversations.get(ws) || [];
|
|
159
167
|
history.push({ role: 'user', content });
|
|
160
168
|
|
|
161
|
-
if (!
|
|
169
|
+
if (!freshAi) {
|
|
162
170
|
ws.send(JSON.stringify({ type: 'bot:error', data: { error: 'AI not configured. Set up your provider first.' } }));
|
|
163
171
|
return;
|
|
164
172
|
}
|
|
165
173
|
|
|
166
174
|
ws.send(JSON.stringify({ type: 'bot:typing', data: { conversationId: convId } }));
|
|
167
175
|
|
|
168
|
-
|
|
176
|
+
freshAi.chat(
|
|
169
177
|
[{ role: 'system', content: 'You are Fluxy, a helpful AI assistant. You help users manage and customize their self-hosted bot.' }, ...history],
|
|
170
|
-
|
|
178
|
+
freshConfig.ai.model,
|
|
171
179
|
(token) => ws.send(JSON.stringify({ type: 'bot:token', data: { token, conversationId: convId } })),
|
|
172
180
|
(full) => {
|
|
173
181
|
history.push({ role: 'assistant', content: full });
|