smart-home-engine 0.23.0 → 0.23.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.
@@ -1,4 +1,4 @@
1
- import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-BWPgohd9.js";/*!-----------------------------------------------------------------------------
1
+ import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-CI4cnkU8.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -155,7 +155,7 @@
155
155
  }
156
156
  })();
157
157
  </script>
158
- <script type="module" crossorigin src="/assets/index-BWPgohd9.js"></script>
158
+ <script type="module" crossorigin src="/assets/index-CI4cnkU8.js"></script>
159
159
  <link rel="modulepreload" crossorigin href="/assets/monaco-langs-BW2J83t5.js">
160
160
  <link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
161
161
  <link rel="stylesheet" crossorigin href="/assets/index-BPk8Jr3B.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-home-engine",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "description": "Node.js based script runner for use in MQTT based Smart Home environments",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/web/ai-api.js CHANGED
@@ -441,14 +441,15 @@ router.post('/prompt', (req, res) => {
441
441
  // POST /she/ai/chat — non-streaming
442
442
  router.post('/chat', async (req, res) => {
443
443
  const ai = readAiConfig(req.app.locals.configPath);
444
- if (!ai?.provider || !ai?.model) {
444
+ const { messages = [], currentScript, currentView, currentDoc, context = {}, modelOverride, extraFiles } = req.body || {};
445
+ const effectiveModel = (modelOverride && typeof modelOverride === 'string') ? modelOverride : ai?.model;
446
+ if (!ai?.provider || !effectiveModel) {
445
447
  return res.status(400).json({ error: 'AI provider not configured. Set ai.provider and ai.model in Config.' });
446
448
  }
447
449
 
448
- const { messages = [], currentScript, currentView, currentDoc, context = {}, modelOverride, extraFiles } = req.body || {};
449
450
  if (!Array.isArray(messages)) return res.status(400).json({ error: 'messages must be an array' });
450
451
 
451
- const aiWithModel = modelOverride && typeof modelOverride === 'string' ? { ...ai, model: modelOverride } : ai;
452
+ const aiWithModel = { ...ai, model: effectiveModel };
452
453
  const systemPrompt = buildSystemPrompt(context, currentScript ?? null, currentView ?? null, currentDoc ?? null, _store, extraFiles || []);
453
454
  const fullMessages = [{ role: 'system', content: systemPrompt }, ...messages];
454
455
 
@@ -471,14 +472,15 @@ router.post('/chat', async (req, res) => {
471
472
  // POST /she/ai/chat/stream — SSE streaming
472
473
  router.post('/chat/stream', async (req, res) => {
473
474
  const ai = readAiConfig(req.app.locals.configPath);
474
- if (!ai?.provider || !ai?.model) {
475
+ const { messages = [], currentScript, currentView, currentDoc, context = {}, modelOverride, extraFiles } = req.body || {};
476
+ const effectiveModel = (modelOverride && typeof modelOverride === 'string') ? modelOverride : ai?.model;
477
+ if (!ai?.provider || !effectiveModel) {
475
478
  return res.status(400).json({ error: 'AI provider not configured. Set ai.provider and ai.model in Config.' });
476
479
  }
477
480
 
478
- const { messages = [], currentScript, currentView, currentDoc, context = {}, modelOverride, extraFiles } = req.body || {};
479
481
  if (!Array.isArray(messages)) return res.status(400).json({ error: 'messages must be an array' });
480
482
 
481
- const aiWithModel = modelOverride && typeof modelOverride === 'string' ? { ...ai, model: modelOverride } : ai;
483
+ const aiWithModel = { ...ai, model: effectiveModel };
482
484
 
483
485
  // Build system prompt BEFORE flushing headers so errors can still return a proper HTTP status
484
486
  let systemPrompt;