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