iobroker.javascript 10.4.2 → 10.4.4
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/README.md +4 -2
- package/admin/assets/{AiChatPanel-Bh1UgzLN.js → AiChatPanel-DDMXsfSt.js} +2 -2
- package/admin/assets/{AiChatService-h1EHSXaR.js → AiChatService-DwMHP0xt.js} +1 -1
- package/admin/assets/AiDiffView-Bk-37CNd.js +1 -0
- package/admin/assets/{AiInlineProvider-CslJGmO0.js → AiInlineProvider-CXlH1WK8.js} +1 -1
- package/admin/assets/{BlocklyEditor-DD7PWWnm.js → BlocklyEditor-DY4OoiFv.js} +10 -10
- package/admin/assets/Compile-DUNqNndk.js +165 -0
- package/admin/assets/{Debugger-DcFTsY_u.js → Debugger-B5PuUkp6.js} +1 -1
- package/admin/assets/Diff-CumYKon3.js +1 -0
- package/admin/assets/{Documentation-DmTfviYr.js → Documentation-DDu-zfNv.js} +1 -1
- package/admin/assets/ExpandMore-CivgfFOr.js +1 -0
- package/admin/assets/{FbEditor-BCD6eDj-.js → FbEditor-D1m29HMt.js} +1 -1
- package/admin/assets/History-jUbe5GP0.js +1 -0
- package/admin/assets/Import-iMDY2N5I.js +1 -0
- package/admin/assets/MonacoDiff-D24nsTu6.js +1 -0
- package/admin/assets/NotificationsActive-DaZ6l1oz.js +1 -0
- package/admin/assets/RulesEditor-qd1dXeG0.js +1 -0
- package/admin/assets/{ScriptEditor-sb_g6vXT.js → ScriptEditor-DfX-VuXG.js} +1 -1
- package/admin/assets/ScriptEditorVanillaMonaco-DDf9Xgnp.js +3 -0
- package/admin/assets/Send-BggvRgCd.js +1 -0
- package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-DCbVrrFZ.js +1 -0
- package/admin/assets/{_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__57338878793567__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-8WiAnp-r.js → _virtual_mf___mfe_internal__iobroker_javascript__mf_owner__244278364413149__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-Lnn-CkVR.js} +53 -53
- package/admin/assets/{_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__57338878793567__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-BCLgOrQh.js → _virtual_mf___mfe_internal__iobroker_javascript__mf_owner__244278364413149__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-z1D20r27.js} +1 -1
- package/admin/assets/aiPromptBuilder-BlIDJp0X.js +1 -0
- package/admin/assets/{blockly-B0t_IRJQ.js → blockly-C3YM75rJ.js} +48 -44
- package/admin/assets/blocklyTheme-DT7bwtSS.js +1 -0
- package/admin/assets/{blocks_action-CM4AAMF1.js → blocks_action-DpPxKVI7.js} +1 -1
- package/admin/assets/{blocks_convert-DIBthcQF.js → blocks_convert-BZem2yRU.js} +1 -1
- package/admin/assets/{blocks_logic-CJBNXoP3.js → blocks_logic-vMLrt5md.js} +1 -1
- package/admin/assets/{blocks_number-GuNZ4kQO.js → blocks_number-ImO9YZku.js} +1 -1
- package/admin/assets/{blocks_object-BFR1ocL_.js → blocks_object-Cfw-t61W.js} +1 -1
- package/admin/assets/{blocks_procedures-CQxCN9F8.js → blocks_procedures-Df_jKvkW.js} +1 -1
- package/admin/assets/{blocks_sendto-DSfpmOb2.js → blocks_sendto-BePXoq3l.js} +1 -1
- package/admin/assets/{blocks_switch-CzWnVKX-.js → blocks_switch-Cf1Ly48W.js} +1 -1
- package/admin/assets/{blocks_system-DVfA31Hy.js → blocks_system-D_7Ev6nN.js} +1 -1
- package/admin/assets/{blocks_text-CgO-seeL.js → blocks_text-CM4ZTMkn.js} +1 -1
- package/admin/assets/{blocks_time-DNQPTg92.js → blocks_time-CovNiZ5E.js} +1 -1
- package/admin/assets/{blocks_timeout-BXypxY7F.js → blocks_timeout-WxihPUYn.js} +1 -1
- package/admin/assets/{blocks_trigger-elp6XrND.js → blocks_trigger-cu2p03ud.js} +1 -1
- package/admin/assets/cronHoverProvider-CeC4ghkd.js +2 -0
- package/admin/assets/field_cron-CTSbO0Sj.js +1 -0
- package/admin/assets/field_oid-yf2RKHSk.js +1 -0
- package/admin/assets/field_script-WzNnU0JL.js +1 -0
- package/admin/assets/{helpers-Ch3tewpw.js → helpers-DLkZXmzA.js} +1 -1
- package/admin/assets/{hostInit-CflF0J5w.js → hostInit-DHGIvBts.js} +1 -1
- package/admin/assets/{index-_7Mh4AxK.js → index-BAjPlTzo.js} +6 -6
- package/admin/assets/inlineChatWidget-DvAKhg6g.js +2 -0
- package/admin/assets/{inlineDiffController-VazWO1wi.js → inlineDiffController-DOhV-sbU.js} +1 -1
- package/admin/assets/{loadBlocks-CGEGNJcd.js → loadBlocks-zPpF1gDy.js} +1 -1
- package/admin/assets/{mf-entry-bootstrap-0-536f3328.js → mf-entry-bootstrap-0-757148b7.js} +3 -3
- package/admin/assets/{pendingShares-WHCuAHKo.js → pendingShares-TGMPCf23.js} +1 -1
- package/admin/assets/reactour.esm-Q4nnZoim.js +137 -0
- package/admin/assets/{stateHoverProvider-BfhQov29.js → stateHoverProvider-GWaLOu7S.js} +1 -1
- package/admin/custom/assets/Components-2p8wiA9W.js +1 -0
- package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-LoDUiIZH.js +1 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-D2tgwrcS.js +1 -0
- package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-nQIzP_1l.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-D27wqFWN.js} +89 -89
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__loadShare___mf_0_mui_mf_1_x_mf_2_date_mf_2_pickers__loadShare__.js-CAjPWACG.js +1 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__loadShare__date_mf_2_fns__loadShare__.js-B2r0vvPY.js +1 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__loadShare__shared-CdAm7fPH.js +2 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-DAE9qWf5.js +122 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__prebuild__leaflet__prebuild__--WMuxzd-.js +1 -0
- package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__prebuild__react_mf_2_dom_mf_1_client__prebuild__--phH3reL.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__prebuild__react_mf_2_dom_mf_1_client__prebuild__-DEIPBEui.js} +1 -1
- package/admin/custom/assets/{hostInit-CuGqkIzY.js → hostInit-CgdfLZgR.js} +1 -1
- package/admin/custom/assets/index-BqWkNbeU.js +1 -0
- package/admin/custom/assets/{lib-WawTWipl.js → lib-5TzGpBXO.js} +1 -1
- package/admin/custom/assets/{mf-entry-bootstrap-0-81b08d9c.js → mf-entry-bootstrap-0-3bac0bf3.js} +3 -3
- package/admin/custom/assets/pendingShares-fPzqQeON.js +2 -0
- package/admin/custom/customComponents.js +2 -2
- package/admin/mf-manifest.json +1 -1
- package/admin/mf-stats.json +1 -1
- package/admin/remoteEntry.js +2 -2
- package/admin/tab.html +2 -2
- package/build/lib/sandbox.js +50 -4
- package/build/lib/sandbox.js.map +1 -1
- package/build/main.js +26 -5
- package/build/main.js.map +1 -1
- package/io-package.json +13 -13
- package/package.json +3 -3
- package/admin/assets/AiDiffView-pmbNE43A.js +0 -1
- package/admin/assets/Compile-CHnsUZ3H.js +0 -165
- package/admin/assets/Diff-BMtToKAY.js +0 -1
- package/admin/assets/ExpandMore-BjBfK8y_.js +0 -1
- package/admin/assets/History-DM03Cwv-.js +0 -1
- package/admin/assets/Import-Bh_K9cpx.js +0 -1
- package/admin/assets/MonacoDiff-yYWwyqpx.js +0 -1
- package/admin/assets/NotificationsActive-B7pgt1LW.js +0 -1
- package/admin/assets/RulesEditor-CV-5poRY.js +0 -1
- package/admin/assets/ScriptEditorVanillaMonaco-DbOlv3vi.js +0 -3
- package/admin/assets/Send-Bo4QPFhQ.js +0 -1
- package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-B7myBQHF.js +0 -1
- package/admin/assets/aiPromptBuilder-jeMwCFvL.js +0 -1
- package/admin/assets/blocklyTheme-B0abPSuE.js +0 -1
- package/admin/assets/cronHoverProvider-CZrYrB2m.js +0 -2
- package/admin/assets/field_cron-m1xxzKf2.js +0 -1
- package/admin/assets/field_oid-BLNfi7lh.js +0 -1
- package/admin/assets/field_script-CGDpmlGL.js +0 -1
- package/admin/assets/inlineChatWidget-BfjarD99.js +0 -2
- package/admin/assets/reactour.esm-CETRUaME.js +0 -137
- package/admin/custom/assets/Components-C6UfjQAS.js +0 -1
- package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-B1DaT32e.js +0 -1
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-BRo2TJu1.js +0 -1
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__loadShare___mf_0_mui_mf_1_x_mf_2_date_mf_2_pickers__loadShare__.js-DQfhTnYi.js +0 -1
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__loadShare__date_mf_2_fns__loadShare__.js-BrsJpRn9.js +0 -1
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__loadShare__shared-Bm5cq4Wz.js +0 -2
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-Bv9I6S4D.js +0 -122
- package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__prebuild__leaflet__prebuild__-R1ziirob.js +0 -1
- package/admin/custom/assets/index-CgBEPuXx.js +0 -1
- package/admin/custom/assets/pendingShares-5RvH3v48.js +0 -2
- /package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-DbKT6Hsb.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-DbKT6Hsb.js} +0 -0
- /package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__loadShare__leaflet__loadShare__.js-D9EyCd42.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__loadShare__leaflet__loadShare__.js-D9EyCd42.js} +0 -0
- /package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__18840520564161__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__-CXpyx8Vy.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__211401881746328__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__-CXpyx8Vy.js} +0 -0
package/README.md
CHANGED
|
@@ -30,8 +30,10 @@ Executes JavaScript, TypeScript Scripts.
|
|
|
30
30
|
-->
|
|
31
31
|
|
|
32
32
|
## Changelog
|
|
33
|
-
### 10.4.
|
|
34
|
-
* (@GermanBluefox) Fixed:
|
|
33
|
+
### 10.4.4 (2026-10-16)
|
|
34
|
+
* (@GermanBluefox) Fixed: a script that did not handle a rejected `setStateAsync` (e.g. of a missing state) or another asynchronous function terminated the adapter
|
|
35
|
+
* (@GermanBluefox) Fixed: instances of different versions
|
|
36
|
+
* (@GermanBluefox) Fixed: the AI chat stopped with "m.default is not a constructor"
|
|
35
37
|
|
|
36
38
|
### 10.4.1 (2026-10-09)
|
|
37
39
|
* (@GermanBluefox) Changed: the AI assistant uses the shared libraries `@iobroker/ai-core` and `@iobroker/ai-gui`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$n as e,Bn as t,Cr as n,Dt as r,Er as i,Et as a,Gt as o,In as s,Ir as c,Jt as l,Mr as u,Nn as d,Ot as f,Rn as p,Sn as m,Vn as h,Xn as g,Xt as _,Yt as v,Zt as y,_t as b,an as x,in as S,jn as C,jr as w,kn as T,kr as E,lr as D,m as O,qt as k,ur as A,xn as ee}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__57338878793567__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-8WiAnp-r.js";import{t as j}from"./Send-Bo4QPFhQ.js";import{t as te}from"./vite-preload-helper-BbbETgeG.js";import{c as ne,o as M,s as N}from"./index-_7Mh4AxK.js";import{_ as P,a as F,c as I,d as L,f as R,g as z,h as B,i as V,l as H,m as U,n as W,o as G,p as K,s as q,t as J,u as Y}from"./AiChatService-h1EHSXaR.js";import{t as X}from"./blocklyTheme-B0abPSuE.js";var Z=g(D(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m5 11h-4v4h-2v-4H7v-2h4V7h2v4h4z`}),`AddCircleOutlined`),re=g(D(`path`,{d:`M21.99 4c0-1.1-.89-2-1.99-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14l4 4zM17 11h-4v4h-2v-4H7V9h4V5h2v4h4z`}),`AddComment`),ie=g(D(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10h5v-2h-5c-4.34 0-8-3.66-8-8s3.66-8 8-8 8 3.66 8 8v1.43c0 .79-.71 1.57-1.5 1.57s-1.5-.78-1.5-1.57V12c0-2.76-2.24-5-5-5s-5 2.24-5 5 2.24 5 5 5c1.38 0 2.64-.56 3.54-1.47.65.89 1.77 1.47 2.96 1.47 1.97 0 3.5-1.6 3.5-3.57V12c0-5.52-4.48-10-10-10m0 13c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3`}),`AlternateEmail`),ae=g(D(`path`,{d:`M9.01 14H2v2h7.01v3L13 15l-3.99-4zm5.98-1v-3H22V8h-7.01V5L11 9z`}),`CompareArrows`),oe=g(D(`path`,{d:`M7 14H5v5h5v-2H7zm-2-4h2V7h3V5H5zm12 7h-3v2h5v-5h-2zM14 5v2h3v3h2V5z`}),`Fullscreen`),se=g(D(`path`,{d:`M5 16h3v3h2v-5H5zm3-8H5v2h5V5H8zm6 11h2v-3h3v-2h-5zm2-11V5h-2v5h5V8z`}),`FullscreenExit`),ce=g(D(`path`,{d:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4`}),`Person`),le=g(D(`path`,{d:`M3 10h11v2H3zm0-4h11v2H3zm0 8h7v2H3zm17.59-2.07-4.25 4.24-2.12-2.12-1.41 1.41L16.34 19 22 13.34z`}),`PlaylistAddCheck`),ue=g(D(`path`,{d:`M20 9V7c0-1.1-.9-2-2-2h-3c0-1.66-1.34-3-3-3S9 3.34 9 5H6c-1.1 0-2 .9-2 2v2c-1.66 0-3 1.34-3 3s1.34 3 3 3v4c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-4c1.66 0 3-1.34 3-3s-1.34-3-3-3M7.5 11.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5S9.83 13 9 13s-1.5-.67-1.5-1.5M16 17H8v-2h8zm-1-4c-.83 0-1.5-.67-1.5-1.5S14.17 10 15 10s1.5.67 1.5 1.5S15.83 13 15 13`}),`SmartToy`);c();var de=[{type:`function`,function:{name:`search_datapoints`,description:`Search ALL ioBroker objects by ID, name, or role — includes states, channels, devices, folders, enums (rooms/functions), adapters, instances, scripts, meta, etc. Returns matching IDs with object type, name, role, unit, and a hasChildren hint for containers. IMPORTANT: Aliases and physical device groupings are usually CHANNELS containing multiple state children (e.g. a motion sensor is often a channel alias.0.Floor.Room.MotionSensor with states ACTUAL, BATTERY, STATE under it). If a channel/device/folder matches your query, call get_object_info on its ID to list its state children. Role-based queries work too: "sensor.motion", "switch.light", "value.temperature".`,parameters:{type:`object`,properties:{query:{type:`string`,description:`Search pattern (case-insensitive substring) - matches against object ID, name, and role. Examples: "bewegungsmelder", "temperature", "sensor.motion", "alias.0", "küche", "zigbee2mqtt.0.lamp".`},max_results:{type:`number`,description:`Maximum number of results to return (default: 20).`},object_type:{type:`string`,description:`Optional filter by object type: "state", "channel", "device", "folder", "enum", "adapter", "instance", "script", "meta", etc. Omit to search every type.`}},required:[`query`]}}},{type:`function`,function:{name:`get_state_value`,description:`Get the current value of an ioBroker state/datapoint. Returns value, timestamp, and acknowledgment flag.`,parameters:{type:`object`,properties:{id:{type:`string`,description:`The full state ID, e.g. "zigbee2mqtt.0.sensor.temperature"`}},required:[`id`]}}},{type:`function`,function:{name:`get_object_info`,description:`Get detailed info about ANY ioBroker object + its full parent hierarchy + direct children. Works for every object type: state, channel, device, folder, adapter, instance, enum, meta, script. Returns: the object itself, parent chain (all non-state ancestors up to the adapter), and — if the object is a container (channel/device/folder/enum/instance/adapter/meta) — the list of direct children with their types, names, roles and units. Use this to navigate the object tree: start from a channel found by search_datapoints, read its children to see the actual state IDs underneath.`,parameters:{type:`object`,properties:{id:{type:`string`,description:`The full object ID, e.g. "zigbee2mqtt.0.0x1234.state", "alias.0.Room.MotionSensor", or "enum.rooms.kitchen".`}},required:[`id`]}}},{type:`function`,function:{name:`search_scripts`,description:`Search through all ioBroker JavaScript/Blockly/Rules scripts. Can search by script name/path OR by content (e.g. find all scripts that use a specific datapoint ID). Returns matching script names, paths, and matching lines.`,parameters:{type:`object`,properties:{query:{type:`string`,description:`Search term - matches against script name, path, AND source code content. Examples: "carport", "zigbee2mqtt.0.lamp.state", "telegram"`},max_results:{type:`number`,description:`Maximum number of scripts to return (default: 10)`}},required:[`query`]}}},{type:`function`,function:{name:`read_script`,description:`Read the full source code of a specific ioBroker script by its ID or path. Use search_scripts first to find the script ID, then read_script to see its complete code.`,parameters:{type:`object`,properties:{id:{type:`string`,description:`The script ID (e.g. "script.js.common.Licht.Carport") or path (e.g. "common/Licht/Carport")`}},required:[`id`]}}},{type:`function`,function:{name:`list_scripts`,description:`List ALL available ioBroker scripts with their names, paths, types (JavaScript/Blockly/TypeScript), and enabled status. Use this to get an overview of all scripts before searching or reading specific ones.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`run_script`,description:"Execute a JavaScript or TypeScript snippet in the live ioBroker javascript engine and get back everything it logged. The code runs with the full script API (log, console.*, setState, getState, on, schedule, $, exec, httpGet, …) in VERBOSE mode, so internal operations (setState/getState/subscribe/…) are logged too — ideal for diagnosing behaviour or inspecting values. The snippet runs for a short window and is then automatically STOPPED and fully cleaned up (timers, subscriptions, schedules removed); it does NOT create a persistent script. Use `log(...)` or `console.log(...)` in the code to surface the values you want to inspect. WARNING: side effects are real (e.g. setState changes actual devices) — prefer read-only diagnostics unless the user explicitly asked to change something.",parameters:{type:`object`,properties:{source:{type:`string`,description:`The JavaScript (or TypeScript) source to execute. Log the values you want to inspect via log(...) / console.log(...). Top-level await is supported.`},engineType:{type:`string`,description:`Optional. "TypeScript/ts" to run the code as TypeScript. Defaults to JavaScript.`},timeout:{type:`number`,description:`Optional. Milliseconds to keep the script alive to collect asynchronous logs before it is stopped (default 5000, max 60000). Increase when waiting for timers, subscriptions or HTTP responses.`},logLevel:{type:`string`,description:`Optional minimum severity to return: silly, debug, info, warn, error. Default silly (everything).`}},required:[`source`]}}},{type:`function`,function:{name:`get_editor_selection`,description:`Read what the user has currently selected in the script editor. Returns the selected text and its line/column range, or a message if nothing is selected. Use this when the user refers to "this", "das hier", "the selection", or asks about a specific piece of code they highlighted.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`get_editor_content`,description:`Read the full current content of the script editor (may differ from the initial script version if the user has made edits). Use this when you need the live editor state rather than the saved script.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`get_cursor_position`,description:`Read the current cursor position (line and column, 1-based) in the script editor.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`highlight_text_in_editor`,description:`Search for a literal text in the script editor and select + scroll to it. Returns how many occurrences were found. Use this to draw the user's attention to a specific snippet you are discussing.`,parameters:{type:`object`,properties:{text:{type:`string`,description:`Exact substring to search for (case-sensitive).`}},required:[`text`]}}},{type:`function`,function:{name:`highlight_line_range`,description:`Select and scroll to a range of lines in the editor. Both line numbers are 1-based and inclusive. Use this to show the user which block of code you are referring to.`,parameters:{type:`object`,properties:{start_line:{type:`number`,description:`First line (1-based, inclusive).`},end_line:{type:`number`,description:`Last line (1-based, inclusive).`}},required:[`start_line`,`end_line`]}}},{type:`function`,function:{name:`go_to_line`,description:`Move the cursor to a specific line (and optional column) and scroll that line into view. Use this to navigate the user to a relevant spot.`,parameters:{type:`object`,properties:{line:{type:`number`,description:`1-based line number.`},column:{type:`number`,description:`1-based column (optional, default 1).`}},required:[`line`]}}},{type:`function`,function:{name:`insert_text_at_cursor`,description:`Insert text at the current cursor position in the editor (or replace the current selection if one exists). Use sparingly — prefer returning code in a fenced markdown block so the user can review and smart-apply it. Only use direct insertion when the user explicitly asked you to write something into the editor.`,parameters:{type:`object`,properties:{text:{type:`string`,description:`Text to insert.`}},required:[`text`]}}},{type:`function`,function:{name:`replace_selection`,description:`Replace the currently selected text in the editor with new text. Fails if nothing is selected. Use this to refactor or rewrite a specific highlighted snippet.`,parameters:{type:`object`,properties:{text:{type:`string`,description:`Replacement text.`}},required:[`text`]}}},{type:`function`,function:{name:`get_diagnostics`,description:`Read all active Monaco diagnostics (errors, warnings, info, hints) from the current editor model — this is what shows up as red/yellow squiggles. Use this to find syntax errors, unused variables, missing types, or other editor-reported issues the user might be asking about.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`get_document_symbols`,description:`Get the document outline of the current script: all top-level functions, classes, constants, and variables with their line numbers. Use this to understand the structure of a long script or to find where a specific function is defined.`,parameters:{type:`object`,properties:{}}}}];function fe(e){return e&&typeof e==`object`?e.en||e.de||``:e||``}function pe(e,t,n){let r=(n||``).toLowerCase();if(!r)return!1;if(e.toLowerCase().includes(r))return!0;let i=t==null?void 0:t.common;if(!i)return!1;let a=fe(i.name).toLowerCase();if(a&&a.includes(r))return!0;let o=(i.role||``).toLowerCase();return!!(o&&o.includes(r))}async function me(e,t,n=20,r){let i=await q(e),a=r==null?void 0:r.toLowerCase(),o=[],s=Object.keys(i),c=new Set;for(let e of s){let t=e.lastIndexOf(`.`);t>0&&c.add(e.substring(0,t))}for(let e of s){let r=i[e],s=r==null?void 0:r.type;if(!s||a&&s!==a||!pe(e,r,t))continue;let l=r.common,u={id:e,type:s,name:fe(l==null?void 0:l.name)};if(l!=null&&l.role&&(u.role=l.role),s===`state`?(u.stateType=(l==null?void 0:l.type)||``,l!=null&&l.unit&&(u.unit=l.unit)):c.has(e)&&(u.hasChildren=!0),o.push(u),o.length>=n)break}return o.length===0?JSON.stringify({message:`No objects found matching "${t}". Hint: try a role like "sensor.motion" or a partial path.`}):JSON.stringify(o)}async function he(e,t){try{let n=await e.getState(t);return JSON.stringify(n?{val:n.val,ts:n.ts?new Date(n.ts).toISOString():null,ack:n.ack,from:n.from}:{error:`State '${t}' not found`})}catch{return JSON.stringify({error:`Failed to read state '${t}'`})}}var ge=new Set([`channel`,`device`,`folder`,`adapter`,`instance`,`enum`,`meta`]),_e=50;async function ve(e,t){try{let r=await e.getObject(t);if(!r)return JSON.stringify({error:`Object '${t}' not found`});let i={id:r._id,type:r.type,common:r.common},a=t.split(`.`),o=[];for(let t=a.length-1;t>=2;t--){let r=a.slice(0,t).join(`.`);try{let t=await e.getObject(r);if(t&&t.type!==`state`){var n;o.push({id:t._id,type:t.type,name:fe((n=t.common)==null?void 0:n.name),common:t.common})}}catch{}}if(o.length>0&&(i.parents=o),ge.has(r.type)){let n=await q(e),r=[],a=`${t}.`,o=!1;for(let e of Object.keys(n))if(e.startsWith(a)&&!e.substring(a.length).includes(`.`)){let t=n[e],i=t==null?void 0:t.common,a={id:e,name:fe(i==null?void 0:i.name),type:(t==null?void 0:t.type)||``};if(i!=null&&i.role&&(a.role=i.role),(t==null?void 0:t.type)===`state`&&i!=null&&i.unit&&(a.unit=i.unit),r.push(a),r.length>=_e){o=!0;break}}r.length>0&&(i.children=r,o&&(i.childrenTruncated=!0,i.childrenHint=`Only the first ${_e} children are shown. Use search_datapoints with a more specific query or the object_type filter to narrow down.`))}return JSON.stringify(i)}catch{return JSON.stringify({error:`Failed to read object '${t}'`})}}function ye(e){return N(e)||e}function be(e,t,n=10){let r=t.toLowerCase(),i=[];for(let t of e){let e=t.id.toLowerCase(),a=t.name.toLowerCase(),o=t.id.replace(/^script\.js\./,``).replace(/\./g,`/`),s=t.engineType===`Blockly`||t.engineType===`Rules`,c=e.includes(r)||a.includes(r),l=s?ye(t.source):t.source,u=l.toLowerCase().includes(r);if(c||u){let e={id:t.id,path:o,name:t.name,type:s?`Blockly`:t.engineType.includes(`TypeScript`)?`TypeScript`:`JavaScript`,enabled:t.enabled};if(u){let t=l.split(`
|
|
1
|
+
import{$n as e,Bn as t,Cr as n,Dt as r,Er as i,Et as a,Gt as o,In as s,Ir as c,Jt as l,Mr as u,Nn as d,Ot as f,Rn as p,Sn as m,Vn as h,Xn as g,Xt as _,Yt as v,Zt as y,_t as b,an as x,in as S,jn as C,jr as w,kn as T,kr as E,lr as D,m as O,qt as k,ur as A,xn as ee}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__244278364413149__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-Lnn-CkVR.js";import{t as j}from"./Send-BggvRgCd.js";import{t as te}from"./vite-preload-helper-BbbETgeG.js";import{c as ne,o as M,s as N}from"./index-BAjPlTzo.js";import{_ as P,a as F,c as I,d as L,f as R,g as z,h as B,i as V,l as H,m as U,n as W,o as G,p as K,s as q,t as J,u as Y}from"./AiChatService-DwMHP0xt.js";import{t as X}from"./blocklyTheme-DT7bwtSS.js";var Z=g(D(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m5 11h-4v4h-2v-4H7v-2h4V7h2v4h4z`}),`AddCircleOutlined`),re=g(D(`path`,{d:`M21.99 4c0-1.1-.89-2-1.99-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14l4 4zM17 11h-4v4h-2v-4H7V9h4V5h2v4h4z`}),`AddComment`),ie=g(D(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10h5v-2h-5c-4.34 0-8-3.66-8-8s3.66-8 8-8 8 3.66 8 8v1.43c0 .79-.71 1.57-1.5 1.57s-1.5-.78-1.5-1.57V12c0-2.76-2.24-5-5-5s-5 2.24-5 5 2.24 5 5 5c1.38 0 2.64-.56 3.54-1.47.65.89 1.77 1.47 2.96 1.47 1.97 0 3.5-1.6 3.5-3.57V12c0-5.52-4.48-10-10-10m0 13c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3`}),`AlternateEmail`),ae=g(D(`path`,{d:`M9.01 14H2v2h7.01v3L13 15l-3.99-4zm5.98-1v-3H22V8h-7.01V5L11 9z`}),`CompareArrows`),oe=g(D(`path`,{d:`M7 14H5v5h5v-2H7zm-2-4h2V7h3V5H5zm12 7h-3v2h5v-5h-2zM14 5v2h3v3h2V5z`}),`Fullscreen`),se=g(D(`path`,{d:`M5 16h3v3h2v-5H5zm3-8H5v2h5V5H8zm6 11h2v-3h3v-2h-5zm2-11V5h-2v5h5V8z`}),`FullscreenExit`),ce=g(D(`path`,{d:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4`}),`Person`),le=g(D(`path`,{d:`M3 10h11v2H3zm0-4h11v2H3zm0 8h7v2H3zm17.59-2.07-4.25 4.24-2.12-2.12-1.41 1.41L16.34 19 22 13.34z`}),`PlaylistAddCheck`),ue=g(D(`path`,{d:`M20 9V7c0-1.1-.9-2-2-2h-3c0-1.66-1.34-3-3-3S9 3.34 9 5H6c-1.1 0-2 .9-2 2v2c-1.66 0-3 1.34-3 3s1.34 3 3 3v4c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-4c1.66 0 3-1.34 3-3s-1.34-3-3-3M7.5 11.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5S9.83 13 9 13s-1.5-.67-1.5-1.5M16 17H8v-2h8zm-1-4c-.83 0-1.5-.67-1.5-1.5S14.17 10 15 10s1.5.67 1.5 1.5S15.83 13 15 13`}),`SmartToy`);c();var de=[{type:`function`,function:{name:`search_datapoints`,description:`Search ALL ioBroker objects by ID, name, or role — includes states, channels, devices, folders, enums (rooms/functions), adapters, instances, scripts, meta, etc. Returns matching IDs with object type, name, role, unit, and a hasChildren hint for containers. IMPORTANT: Aliases and physical device groupings are usually CHANNELS containing multiple state children (e.g. a motion sensor is often a channel alias.0.Floor.Room.MotionSensor with states ACTUAL, BATTERY, STATE under it). If a channel/device/folder matches your query, call get_object_info on its ID to list its state children. Role-based queries work too: "sensor.motion", "switch.light", "value.temperature".`,parameters:{type:`object`,properties:{query:{type:`string`,description:`Search pattern (case-insensitive substring) - matches against object ID, name, and role. Examples: "bewegungsmelder", "temperature", "sensor.motion", "alias.0", "küche", "zigbee2mqtt.0.lamp".`},max_results:{type:`number`,description:`Maximum number of results to return (default: 20).`},object_type:{type:`string`,description:`Optional filter by object type: "state", "channel", "device", "folder", "enum", "adapter", "instance", "script", "meta", etc. Omit to search every type.`}},required:[`query`]}}},{type:`function`,function:{name:`get_state_value`,description:`Get the current value of an ioBroker state/datapoint. Returns value, timestamp, and acknowledgment flag.`,parameters:{type:`object`,properties:{id:{type:`string`,description:`The full state ID, e.g. "zigbee2mqtt.0.sensor.temperature"`}},required:[`id`]}}},{type:`function`,function:{name:`get_object_info`,description:`Get detailed info about ANY ioBroker object + its full parent hierarchy + direct children. Works for every object type: state, channel, device, folder, adapter, instance, enum, meta, script. Returns: the object itself, parent chain (all non-state ancestors up to the adapter), and — if the object is a container (channel/device/folder/enum/instance/adapter/meta) — the list of direct children with their types, names, roles and units. Use this to navigate the object tree: start from a channel found by search_datapoints, read its children to see the actual state IDs underneath.`,parameters:{type:`object`,properties:{id:{type:`string`,description:`The full object ID, e.g. "zigbee2mqtt.0.0x1234.state", "alias.0.Room.MotionSensor", or "enum.rooms.kitchen".`}},required:[`id`]}}},{type:`function`,function:{name:`search_scripts`,description:`Search through all ioBroker JavaScript/Blockly/Rules scripts. Can search by script name/path OR by content (e.g. find all scripts that use a specific datapoint ID). Returns matching script names, paths, and matching lines.`,parameters:{type:`object`,properties:{query:{type:`string`,description:`Search term - matches against script name, path, AND source code content. Examples: "carport", "zigbee2mqtt.0.lamp.state", "telegram"`},max_results:{type:`number`,description:`Maximum number of scripts to return (default: 10)`}},required:[`query`]}}},{type:`function`,function:{name:`read_script`,description:`Read the full source code of a specific ioBroker script by its ID or path. Use search_scripts first to find the script ID, then read_script to see its complete code.`,parameters:{type:`object`,properties:{id:{type:`string`,description:`The script ID (e.g. "script.js.common.Licht.Carport") or path (e.g. "common/Licht/Carport")`}},required:[`id`]}}},{type:`function`,function:{name:`list_scripts`,description:`List ALL available ioBroker scripts with their names, paths, types (JavaScript/Blockly/TypeScript), and enabled status. Use this to get an overview of all scripts before searching or reading specific ones.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`run_script`,description:"Execute a JavaScript or TypeScript snippet in the live ioBroker javascript engine and get back everything it logged. The code runs with the full script API (log, console.*, setState, getState, on, schedule, $, exec, httpGet, …) in VERBOSE mode, so internal operations (setState/getState/subscribe/…) are logged too — ideal for diagnosing behaviour or inspecting values. The snippet runs for a short window and is then automatically STOPPED and fully cleaned up (timers, subscriptions, schedules removed); it does NOT create a persistent script. Use `log(...)` or `console.log(...)` in the code to surface the values you want to inspect. WARNING: side effects are real (e.g. setState changes actual devices) — prefer read-only diagnostics unless the user explicitly asked to change something.",parameters:{type:`object`,properties:{source:{type:`string`,description:`The JavaScript (or TypeScript) source to execute. Log the values you want to inspect via log(...) / console.log(...). Top-level await is supported.`},engineType:{type:`string`,description:`Optional. "TypeScript/ts" to run the code as TypeScript. Defaults to JavaScript.`},timeout:{type:`number`,description:`Optional. Milliseconds to keep the script alive to collect asynchronous logs before it is stopped (default 5000, max 60000). Increase when waiting for timers, subscriptions or HTTP responses.`},logLevel:{type:`string`,description:`Optional minimum severity to return: silly, debug, info, warn, error. Default silly (everything).`}},required:[`source`]}}},{type:`function`,function:{name:`get_editor_selection`,description:`Read what the user has currently selected in the script editor. Returns the selected text and its line/column range, or a message if nothing is selected. Use this when the user refers to "this", "das hier", "the selection", or asks about a specific piece of code they highlighted.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`get_editor_content`,description:`Read the full current content of the script editor (may differ from the initial script version if the user has made edits). Use this when you need the live editor state rather than the saved script.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`get_cursor_position`,description:`Read the current cursor position (line and column, 1-based) in the script editor.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`highlight_text_in_editor`,description:`Search for a literal text in the script editor and select + scroll to it. Returns how many occurrences were found. Use this to draw the user's attention to a specific snippet you are discussing.`,parameters:{type:`object`,properties:{text:{type:`string`,description:`Exact substring to search for (case-sensitive).`}},required:[`text`]}}},{type:`function`,function:{name:`highlight_line_range`,description:`Select and scroll to a range of lines in the editor. Both line numbers are 1-based and inclusive. Use this to show the user which block of code you are referring to.`,parameters:{type:`object`,properties:{start_line:{type:`number`,description:`First line (1-based, inclusive).`},end_line:{type:`number`,description:`Last line (1-based, inclusive).`}},required:[`start_line`,`end_line`]}}},{type:`function`,function:{name:`go_to_line`,description:`Move the cursor to a specific line (and optional column) and scroll that line into view. Use this to navigate the user to a relevant spot.`,parameters:{type:`object`,properties:{line:{type:`number`,description:`1-based line number.`},column:{type:`number`,description:`1-based column (optional, default 1).`}},required:[`line`]}}},{type:`function`,function:{name:`insert_text_at_cursor`,description:`Insert text at the current cursor position in the editor (or replace the current selection if one exists). Use sparingly — prefer returning code in a fenced markdown block so the user can review and smart-apply it. Only use direct insertion when the user explicitly asked you to write something into the editor.`,parameters:{type:`object`,properties:{text:{type:`string`,description:`Text to insert.`}},required:[`text`]}}},{type:`function`,function:{name:`replace_selection`,description:`Replace the currently selected text in the editor with new text. Fails if nothing is selected. Use this to refactor or rewrite a specific highlighted snippet.`,parameters:{type:`object`,properties:{text:{type:`string`,description:`Replacement text.`}},required:[`text`]}}},{type:`function`,function:{name:`get_diagnostics`,description:`Read all active Monaco diagnostics (errors, warnings, info, hints) from the current editor model — this is what shows up as red/yellow squiggles. Use this to find syntax errors, unused variables, missing types, or other editor-reported issues the user might be asking about.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`get_document_symbols`,description:`Get the document outline of the current script: all top-level functions, classes, constants, and variables with their line numbers. Use this to understand the structure of a long script or to find where a specific function is defined.`,parameters:{type:`object`,properties:{}}}}];function fe(e){return e&&typeof e==`object`?e.en||e.de||``:e||``}function pe(e,t,n){let r=(n||``).toLowerCase();if(!r)return!1;if(e.toLowerCase().includes(r))return!0;let i=t==null?void 0:t.common;if(!i)return!1;let a=fe(i.name).toLowerCase();if(a&&a.includes(r))return!0;let o=(i.role||``).toLowerCase();return!!(o&&o.includes(r))}async function me(e,t,n=20,r){let i=await q(e),a=r==null?void 0:r.toLowerCase(),o=[],s=Object.keys(i),c=new Set;for(let e of s){let t=e.lastIndexOf(`.`);t>0&&c.add(e.substring(0,t))}for(let e of s){let r=i[e],s=r==null?void 0:r.type;if(!s||a&&s!==a||!pe(e,r,t))continue;let l=r.common,u={id:e,type:s,name:fe(l==null?void 0:l.name)};if(l!=null&&l.role&&(u.role=l.role),s===`state`?(u.stateType=(l==null?void 0:l.type)||``,l!=null&&l.unit&&(u.unit=l.unit)):c.has(e)&&(u.hasChildren=!0),o.push(u),o.length>=n)break}return o.length===0?JSON.stringify({message:`No objects found matching "${t}". Hint: try a role like "sensor.motion" or a partial path.`}):JSON.stringify(o)}async function he(e,t){try{let n=await e.getState(t);return JSON.stringify(n?{val:n.val,ts:n.ts?new Date(n.ts).toISOString():null,ack:n.ack,from:n.from}:{error:`State '${t}' not found`})}catch{return JSON.stringify({error:`Failed to read state '${t}'`})}}var ge=new Set([`channel`,`device`,`folder`,`adapter`,`instance`,`enum`,`meta`]),_e=50;async function ve(e,t){try{let r=await e.getObject(t);if(!r)return JSON.stringify({error:`Object '${t}' not found`});let i={id:r._id,type:r.type,common:r.common},a=t.split(`.`),o=[];for(let t=a.length-1;t>=2;t--){let r=a.slice(0,t).join(`.`);try{let t=await e.getObject(r);if(t&&t.type!==`state`){var n;o.push({id:t._id,type:t.type,name:fe((n=t.common)==null?void 0:n.name),common:t.common})}}catch{}}if(o.length>0&&(i.parents=o),ge.has(r.type)){let n=await q(e),r=[],a=`${t}.`,o=!1;for(let e of Object.keys(n))if(e.startsWith(a)&&!e.substring(a.length).includes(`.`)){let t=n[e],i=t==null?void 0:t.common,a={id:e,name:fe(i==null?void 0:i.name),type:(t==null?void 0:t.type)||``};if(i!=null&&i.role&&(a.role=i.role),(t==null?void 0:t.type)===`state`&&i!=null&&i.unit&&(a.unit=i.unit),r.push(a),r.length>=_e){o=!0;break}}r.length>0&&(i.children=r,o&&(i.childrenTruncated=!0,i.childrenHint=`Only the first ${_e} children are shown. Use search_datapoints with a more specific query or the object_type filter to narrow down.`))}return JSON.stringify(i)}catch{return JSON.stringify({error:`Failed to read object '${t}'`})}}function ye(e){return N(e)||e}function be(e,t,n=10){let r=t.toLowerCase(),i=[];for(let t of e){let e=t.id.toLowerCase(),a=t.name.toLowerCase(),o=t.id.replace(/^script\.js\./,``).replace(/\./g,`/`),s=t.engineType===`Blockly`||t.engineType===`Rules`,c=e.includes(r)||a.includes(r),l=s?ye(t.source):t.source,u=l.toLowerCase().includes(r);if(c||u){let e={id:t.id,path:o,name:t.name,type:s?`Blockly`:t.engineType.includes(`TypeScript`)?`TypeScript`:`JavaScript`,enabled:t.enabled};if(u){let t=l.split(`
|
|
2
2
|
`),n=[];for(let e=0;e<t.length&&!(t[e].toLowerCase().includes(r)&&(n.push({line:e+1,text:t[e].trim()}),n.length>=5));e++);n.length>0&&(e.matchingLines=n)}if(i.push(e),i.length>=n)break}}return i.length===0?JSON.stringify({message:`No scripts found matching "${t}"`}):JSON.stringify(i)}function xe(e,t){let n=t.replace(/\//g,`.`).toLowerCase(),r=e.find(e=>{let t=e.id.toLowerCase();return t===n||t===`script.js.${n}`||t.endsWith(`.${n}`)});if(!r)return JSON.stringify({error:`Script '${t}' not found. Use search_scripts to find available scripts.`});let i=r.engineType===`Blockly`||r.engineType===`Rules`,a=i?ye(r.source):r.source,o=r.id.replace(/^script\.js\./,``).replace(/\./g,`/`);return JSON.stringify({id:r.id,path:o,name:r.name,type:i?`Blockly`:r.engineType.includes(`TypeScript`)?`TypeScript`:`JavaScript`,enabled:r.enabled,source:a})}function Se(e){let t=e.map(e=>({id:e.id,path:e.id.replace(/^script\.js\./,``).replace(/\./g,`/`),name:e.name,type:e.engineType===`Blockly`||e.engineType===`Rules`?`Blockly`:e.engineType.includes(`TypeScript`)?`TypeScript`:`JavaScript`,enabled:e.enabled}));return JSON.stringify(t)}function Q(){return JSON.stringify({error:`Editor is not available. This tool requires the script editor to be open.`})}async function Ce(e,t,n){if(!t)return JSON.stringify({error:`No running javascript instance found to execute the script.`});let r=n.source;if(!r||typeof r!=`string`)return JSON.stringify({error:`No source code provided.`});try{var i;let a=await e.sendTo(t,`execute`,{source:r,engineType:n.engineType,timeout:n.timeout,logLevel:n.logLevel});return!a||a.ok===!1?JSON.stringify({error:(a==null?void 0:a.error)||`Execution failed`,logs:(a==null?void 0:a.logs)||[]}):JSON.stringify({engineType:a.engineType,runtime:a.runtime,truncated:a.truncated||!1,logCount:((i=a.logs)==null?void 0:i.length)||0,logs:a.logs||[],output:a.output||``})}catch(e){return JSON.stringify({error:`Failed to execute script: ${e instanceof Error?e.message:String(e)}`})}}async function we(e,t,n,r,i){let a;try{a=JSON.parse(t.function.arguments)}catch{return JSON.stringify({error:`Invalid arguments: ${t.function.arguments}`})}switch(t.function.name){case`search_datapoints`:return me(e,a.query,a.max_results||20,a.object_type);case`get_state_value`:return he(e,a.id);case`get_object_info`:return ve(e,a.id);case`search_scripts`:return be(n||[],a.query,a.max_results||10);case`read_script`:return xe(n||[],a.id);case`list_scripts`:return Se(n||[]);case`run_script`:return Ce(e,i,a);case`get_editor_selection`:{if(!(r!=null&&r.getSelection))return Q();let e=r.getSelection();return JSON.stringify(e||{message:`No text is currently selected in the editor.`})}case`get_editor_content`:return r!=null&&r.getContent?JSON.stringify({content:r.getContent()}):Q();case`get_cursor_position`:{if(!(r!=null&&r.getCursorPosition))return Q();let e=r.getCursorPosition();return JSON.stringify(e||{message:`Editor has no cursor position (not focused).`})}case`highlight_text_in_editor`:{if(!(r!=null&&r.highlightText))return Q();let e=r.highlightText(a.text);return JSON.stringify({matches:e,message:e===0?`Text "${a.text}" was not found in the editor.`:`Highlighted ${e} occurrence(s) of "${a.text}".`})}case`highlight_line_range`:{if(!(r!=null&&r.highlightLineRange))return Q();let e=r.highlightLineRange(a.start_line,a.end_line);return JSON.stringify({success:e,message:e?`Selected lines ${a.start_line}-${a.end_line}.`:`Could not select the requested line range.`})}case`go_to_line`:{if(!(r!=null&&r.goToLine))return Q();let e=r.goToLine(a.line,a.column);return JSON.stringify({success:e,message:e?`Cursor moved to line ${a.line}.`:`Could not move the cursor.`})}case`insert_text_at_cursor`:{if(!(r!=null&&r.insertTextAtCursor))return Q();let e=r.insertTextAtCursor(a.text);return JSON.stringify({success:e,message:e?`Text inserted at cursor.`:`Editor rejected the insertion.`})}case`replace_selection`:{if(!(r!=null&&r.replaceSelection))return Q();let e=r.replaceSelection(a.text);return JSON.stringify({success:e,message:e?`Selection replaced.`:`No text was selected to replace.`})}case`get_diagnostics`:{if(!(r!=null&&r.getDiagnostics))return Q();let e=r.getDiagnostics();return JSON.stringify({count:e.length,diagnostics:e})}case`get_document_symbols`:{if(!(r!=null&&r.getSymbols))return Q();let e=await r.getSymbols();return JSON.stringify({count:e.length,symbols:e})}default:return JSON.stringify({error:`Unknown tool: ${t.function.name}`})}}var Te=0;function Ee(){return`msg_${Date.now()}_${++Te}`}function De(e){let{socket:t,runningInstances:r,currentCode:a,currentLanguage:o,allScripts:s,editorApi:c,currentScriptId:l}=e,d=n((e,t,n)=>e===`none`||!n?null:{range:t,scriptId:l||``,scriptVersion:(a||``).length,kind:e,originalText:n},[l,a]),[f,p]=u(()=>{try{let e=window.localStorage.getItem(`Editor.aiChatMessages`);return e?JSON.parse(e):[]}catch{return[]}}),m=n(e=>{p(t=>{let n=typeof e==`function`?e(t):e,r=n.length>100?n.slice(-100):n;try{window.localStorage.setItem(`Editor.aiChatMessages`,JSON.stringify(r))}catch{try{let e=r.slice(-20);window.localStorage.setItem(`Editor.aiChatMessages`,JSON.stringify(e))}catch{}}return r})},[]),[h,g]=u(!1),[_,v]=u(null),[y,b]=u(window.localStorage.getItem(`Editor.aiChatMode`)||`agent`),x=n(e=>{b(e),window.localStorage.setItem(`Editor.aiChatMode`,e)},[]),[S,C]=u(null),[T,E]=u(window.localStorage.getItem(`openai-model`)||``),[D,k]=u([]),[A,ee]=u({}),[j,N]=u(!0),[W,q]=u(null),J=w(null),X=w(null),Z=w(null),re=w(null),ie=n(e=>{E(e),z(e,A[e])},[A]),ae=n(async()=>{N(!0),q(null);try{let e=await U(t,r);if(k(e.models),ee(e.providerMap),e.models.length>0){let t=B().model,n=t&&e.models.includes(t)?t:e.models[0];E(n),z(n,e.providerMap[n])}e.errors.length>0&&q(e.errors.join(`; `))}catch(e){q(String(e))}N(!1)},[t,r]);i(()=>{ae()},[ae]);let oe=n(e=>{let t=!1,n=!1,r=[],i=!1,a=/@([\w/äöüÄÖÜß-]+)/g,o;for(;(o=a.exec(e))!==null;){let e=o[1].toLowerCase();if(e===`alle`||e===`all`)t=!0;else if(e===`geräte`||e===`devices`||e===`geraete`)n=!0;else if(i=!0,s&&s.length>0){let e=o[1].replace(/\//g,`.`).toLowerCase(),t=e.split(`.`),n=s.find(n=>{let r=n.id.toLowerCase(),i=r.replace(/^script\.js\./,``);if(i===e||i.endsWith(`.${e}`)||r===`script.js.${e}`)return!0;let a=0;for(let e of t){let t=i.indexOf(e,a);if(t===-1)return!1;a=t+e.length}return!0});if(n)r.push(n.id);else for(let e of t){if(e.length<3)continue;let t=s.filter(t=>t.id.toLowerCase().includes(`.${e}`)||t.name.toLowerCase().includes(e));for(let e of t)r.includes(e.id)||r.push(e.id)}}}return i&&r.length===0&&(t=!0),{cleanMessage:e.replace(/@[\w/äöüÄÖÜß]+\s*/g,``).trim(),mentionedScriptIds:r,includeAll:t,includeDevices:n}},[s]),se=n(async(e,n,i)=>{re.current||=await L(),J.current||=await I(t,r);let c=R(),l=o===`blockly`,u=e||i.length>0,d=`You are an AI assistant for ioBroker JavaScript adapter scripting. Help the user write, debug, and understand ioBroker scripts. Write comments in ${c}. Use the ioBroker JavaScript API correctly.
|
|
3
3
|
|
|
4
4
|
ioBroker object hierarchy: adapter.instance.device.channel.state
|
|
@@ -15,7 +15,7 @@ ${re.current}`;if(l&&(d+="\n\nThe user is working in the Blockly visual editor.
|
|
|
15
15
|
`)}`)}t.length>0&&(k+=`\n\n[Automatic analysis results]\n${t.join(`
|
|
16
16
|
|
|
17
17
|
`)}`)}}let ee=[...E,...f.filter(e=>e.role!==`system`).map(e=>({role:e.role,content:e.content})),{role:`user`,content:k}],j=y===`agent`;try{let e=[...ee],r=!1;for(let i=0;i<5;i++){let o=await P(t,a,{messages:e,model:T,provider:n,baseUrl:D,...j?{tools:de}:{}});if(o.error){if(j&&i===0&&o.error.toLowerCase().includes(`tool`)){let i=await P(t,a,{messages:e,model:T,provider:n,baseUrl:D});if(i.error)C(i.error),m(e=>e.slice(0,-1));else{let e=(0,K.stripThinkingArtifacts)(i.content||``)||F(i);m(t=>{let n=[...t],r=n[n.length-1];return(r==null?void 0:r.role)===`assistant`&&(n[n.length-1]={...r,content:e}),n})}r=!0;break}C(o.error),m(e=>e.slice(0,-1)),r=!0;break}let l=o.tool_calls;if((!l||l.length===0)&&j&&o.content){let e=o.content.trim();try{let t=JSON.parse(e);t.name&&t.arguments&&(l=[{id:`text_tool_${Date.now()}`,type:`function`,function:{name:t.name,arguments:JSON.stringify(t.arguments)}}])}catch{}}if(!l||l.length===0){let e=(0,K.stripThinkingArtifacts)(o.content||``);e&&(0,K.isTruncatedAnswer)(o)&&(e+=`\n\n⚠️ ${O.t(`The answer is incomplete: the model hit its output limit. Raise "Maximum answer length" in the adapter settings, or ask for a smaller part.`)}`),e||(e=F(o),console.warn(`[AiChat] no usable content in the answer`,{instanceId:a,model:T,provider:n,round:i,rawLength:(o.content||``).length,result:o})),m(t=>{let n=[...t],r=n[n.length-1];return(r==null?void 0:r.role)===`assistant`&&(n[n.length-1]={...r,content:e}),n}),r=!0;break}o.tool_calls=l;let u=o.tool_calls.map(e=>{let t={};try{t=JSON.parse(e.function.arguments)}catch{}switch(e.function.name){case`search_datapoints`:return`🔍 ${O.t(`Searching datapoints`)}: "${String(t.query||``)}"`;case`get_state_value`:return`📊 ${O.t(`Reading value`)}: ${String(t.id||``)}`;case`get_object_info`:return`📋 ${O.t(`Loading object info`)}: ${String(t.id||``)}`;case`search_scripts`:return`🔍 ${O.t(`Searching scripts`)}: "${String(t.query||``)}"`;case`read_script`:return`📖 ${O.t(`Reading script`)}: ${String(t.id||``)}`;case`list_scripts`:return`📂 ${O.t(`Loading script list`)}`;default:return`⚙️ ${e.function.name}`}});m(e=>{let t=[...e],n=t[t.length-1];return(n==null?void 0:n.role)===`assistant`&&(t[t.length-1]={...n,content:u.join(`
|
|
18
|
-
`)}),t}),e.push({role:`assistant`,content:o.content||``,tool_calls:o.tool_calls});for(let n of o.tool_calls){let r=await we(t,n,s,c,a);e.push({role:`tool`,tool_call_id:n.id,content:r})}}if(!r){let e=O.t(`No final answer after %s tool rounds`,`5`);C(e),m(t=>{let n=[...t],r=n[n.length-1];return(r==null?void 0:r.role)===`assistant`&&(n[n.length-1]={...r,content:`${r.content?`${r.content}\n\n`:``}⚠️ ${e}`}),n})}}catch(e){C(String(e)),m(e=>e.slice(0,-1))}g(!1)},[T,A,f,h,t,r,se,oe,s,y,ce,m,d,c]),ue=n(()=>{m([]),C(null),g(!1),v(null),V(),window.localStorage.removeItem(`Editor.aiChatHistory`)},[m]),fe=n(async(e,n)=>{let i=A[T];if(!i)return`Error: ${O.t(`Please select a valid model`)}`;let a=J.current||await I(t,r);if(J.current=a,!a)return`Error: ${O.t(`No API keys configured`)}`;let s=Object.keys(r)[0];if(!s)return`Error: ${O.t(`No running javascript instance found`)}`;let c=i===`custom`&&a.gptBaseUrl||``,l=o||`javascript`,u=`You are an assistant for writing ioBroker ${l} scripts. The user will ask a question about a snippet of their code. Match your answer to the question: \n- If they ask for an explanation, description, or "what does this do?", reply with clear prose (a few sentences). Do NOT repeat the code unchanged. \n- If they explicitly ask for a change, refactor, fix, or rewrite, reply with a single fenced \`\`\`${l===`blockly`?`xml`:l}\`\`\` code block containing the full replacement for the selection. You may add one short sentence before or after the block. \n- If they ask something ambiguous or meta (e.g. "is this correct?"), reply in prose first and only include code if proposing a change. \nioBroker globals available in scripts: on, setState, getState, schedule, sendTo, log, createState, setStateDelayed, existsState, httpGet, httpPost.`,d=n?`Code from my editor:\n\n\`\`\`${l===`blockly`?`xml`:l}\n${n}\n\`\`\`\n\n${e}`:e;try{let e=await P(t,s,{messages:[{role:`system`,content:u},{role:`user`,content:d}],model:T,provider:i,baseUrl:c});return e.error?`Error: ${e.error}`:e.content||``}catch(e){return`Error: ${e.message||String(e)}`}},[T,A,r,t,o]);return{messages:f,isLoading:h,error:S,model:T,availableModels:D,modelProviderMap:A,modelsLoading:j,modelsError:W,lastContextInfo:_,mode:y,setMode:x,setModel:ie,sendMessage:le,triggerAiAction:n(e=>{e.range&&e.code?X.current=d(e.kind||`codelens`,e.range,e.code):X.current=null,te(async()=>{let{buildActionPrompt:e}=await import(`./aiPromptBuilder-
|
|
18
|
+
`)}),t}),e.push({role:`assistant`,content:o.content||``,tool_calls:o.tool_calls});for(let n of o.tool_calls){let r=await we(t,n,s,c,a);e.push({role:`tool`,tool_call_id:n.id,content:r})}}if(!r){let e=O.t(`No final answer after %s tool rounds`,`5`);C(e),m(t=>{let n=[...t],r=n[n.length-1];return(r==null?void 0:r.role)===`assistant`&&(n[n.length-1]={...r,content:`${r.content?`${r.content}\n\n`:``}⚠️ ${e}`}),n})}}catch(e){C(String(e)),m(e=>e.slice(0,-1))}g(!1)},[T,A,f,h,t,r,se,oe,s,y,ce,m,d,c]),ue=n(()=>{m([]),C(null),g(!1),v(null),V(),window.localStorage.removeItem(`Editor.aiChatHistory`)},[m]),fe=n(async(e,n)=>{let i=A[T];if(!i)return`Error: ${O.t(`Please select a valid model`)}`;let a=J.current||await I(t,r);if(J.current=a,!a)return`Error: ${O.t(`No API keys configured`)}`;let s=Object.keys(r)[0];if(!s)return`Error: ${O.t(`No running javascript instance found`)}`;let c=i===`custom`&&a.gptBaseUrl||``,l=o||`javascript`,u=`You are an assistant for writing ioBroker ${l} scripts. The user will ask a question about a snippet of their code. Match your answer to the question: \n- If they ask for an explanation, description, or "what does this do?", reply with clear prose (a few sentences). Do NOT repeat the code unchanged. \n- If they explicitly ask for a change, refactor, fix, or rewrite, reply with a single fenced \`\`\`${l===`blockly`?`xml`:l}\`\`\` code block containing the full replacement for the selection. You may add one short sentence before or after the block. \n- If they ask something ambiguous or meta (e.g. "is this correct?"), reply in prose first and only include code if proposing a change. \nioBroker globals available in scripts: on, setState, getState, schedule, sendTo, log, createState, setStateDelayed, existsState, httpGet, httpPost.`,d=n?`Code from my editor:\n\n\`\`\`${l===`blockly`?`xml`:l}\n${n}\n\`\`\`\n\n${e}`:e;try{let e=await P(t,s,{messages:[{role:`system`,content:u},{role:`user`,content:d}],model:T,provider:i,baseUrl:c});return e.error?`Error: ${e.error}`:e.content||``}catch(e){return`Error: ${e.message||String(e)}`}},[T,A,r,t,o]);return{messages:f,isLoading:h,error:S,model:T,availableModels:D,modelProviderMap:A,modelsLoading:j,modelsError:W,lastContextInfo:_,mode:y,setMode:x,setModel:ie,sendMessage:le,triggerAiAction:n(e=>{e.range&&e.code?X.current=d(e.kind||`codelens`,e.range,e.code):X.current=null,te(async()=>{let{buildActionPrompt:e}=await import(`./aiPromptBuilder-BlIDJp0X.js`);return{buildActionPrompt:e}},[],import.meta.url).then(({buildActionPrompt:t})=>{let n=t({action:e.action,code:e.code,language:o||`javascript`,diagnostic:e.diagnostic,question:e.question,rangeLabel:e.rangeLabel});n?le(n):X.current=null}).catch(()=>{X.current=null,C(O.t(`Failed to build AI action prompt`))})},[le,o,d]),askInline:fe,clearChat:ue,retryLoadModels:ae}}c();var Oe=({code:e,language:t,themeType:r,onInsertCode:o,onShowDiff:s,sourceRange:c})=>{let l=w(null);i(()=>{var n;let i=window.monaco;if(!l.current||!(i!=null&&(n=i.editor)!=null&&n.colorize))return;let a=t===`ts`||t===`typescript`?`typescript`:t||`javascript`;i.editor.colorize(e,a,{theme:r===`dark`?`vs-dark`:`vs`}).then(e=>{l.current&&(l.current.innerHTML=e)})},[e,t,r]);let u=n(()=>{navigator.clipboard.writeText(e)},[e]);return A(v,{sx:{position:`relative`,my:1,borderRadius:1,overflow:`hidden`,border:`1px solid`,borderColor:`divider`},children:[A(v,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,px:1,py:.5,bgcolor:`action.hover`,borderBottom:`1px solid`,borderColor:`divider`},children:[D(v,{sx:{fontSize:`0.75rem`,color:`text.secondary`,textTransform:`uppercase`},children:t||`javascript`}),A(v,{children:[D(k,{title:O.t(`Copy`),children:D(m,{size:`small`,onClick:u,children:D(a,{sx:{fontSize:16}})})}),o&&D(k,{title:O.t(`Insert into editor`),children:D(m,{size:`small`,onClick:()=>o(e),children:D(Z,{sx:{fontSize:16}})})}),s&&D(k,{title:O.t(`Show as diff`),children:D(m,{size:`small`,onClick:()=>s(e,c),children:D(ae,{sx:{fontSize:16}})})})]})]}),D(`pre`,{ref:l,style:{margin:0,padding:`8px 12px`,overflow:`auto`,maxHeight:400,fontSize:`13px`,fontFamily:`'Cascadia Code', 'Fira Code', 'Consolas', monospace`,backgroundColor:r===`dark`?`#1e1e1e`:`#f8f8f8`,color:r===`dark`?`#d4d4d4`:`#333`},children:e})]})};c();var ke=({xml:t})=>{let n=e(),r=w(null),a=w(null),[o,s]=u(60),c=w(!1);return i(()=>{c.current&&(c.current=!1,requestAnimationFrame(()=>{let e=window.Blockly,t=a.current;e&&t&&(e.svgResize(t),t.scrollCenter())}))},[o]),i(()=>{let e=window.Blockly;if(e&&r.current){a.current&&=(a.current.dispose(),null);try{let i=e.inject(r.current,{readOnly:!0,toolbox:null,trashcan:!1,zoom:{controls:!1,wheel:!1,startScale:1},move:{scrollbars:!1,drag:!1,wheel:!1},sounds:!1,renderer:`thrasos`,theme:X(n),media:`google-blockly/media/`});a.current=i;let o=t.trim();o.startsWith(`<xml`)||(o=`<xml xmlns="https://developers.google.com/blockly/xml">${o}</xml>`);let l=e.utils.xml.textToDom(o),u=10,d=Array.from(l.querySelectorAll(`:scope > block`));for(let e of d)e.setAttribute(`x`,`10`),e.setAttribute(`y`,String(u)),u+=200;e.Xml.domToWorkspace(l,i);let f=i.getTopBlocks(!1);if(f.length>1){let e=10;for(let t of f){let n=t.getRelativeToSurfaceXY();t.moveBy(10-n.x,e-n.y),e+=t.getHeightWidth().height+20}}let p=i.getBlocksBoundingBox();if(p){let e=p.bottom-p.top+20,t=Math.max(60,Math.ceil(e));c.current=!0,s(t)}}catch{}return()=>{a.current&&=(a.current.dispose(),null)}}},[t,n]),D(v,{ref:r,sx:{width:`100%`,height:o,minHeight:60,borderRadius:1,overflow:`hidden`,border:`1px solid`,borderColor:`divider`}})};c();function Ae(e){let t=[],n=/```(\w*)\n?([\s\S]*?)```/g,r=0,i;for(;(i=n.exec(e))!==null;){if(i.index>r){let n=e.substring(r,i.index).trim();n&&t.push({type:`text`,content:n})}t.push({type:`code`,content:i[2].trim(),language:i[1]||`javascript`}),r=i.index+i[0].length}if(r<e.length){let n=e.substring(r).trim();n&&t.push({type:`text`,content:n})}return t.length===0&&t.push({type:`text`,content:e}),t}function $(e){let t=[],n=/(\*\*(.+?)\*\*|\*(.+?)\*|`(.+?)`)/g,r=0,i,a=0;for(;(i=n.exec(e))!==null;)i.index>r&&t.push(e.substring(r,i.index)),i[2]?t.push(D(`strong`,{children:i[2]},a++)):i[3]?t.push(D(`em`,{children:i[3]},a++)):i[4]&&t.push(D(`code`,{className:`ai-chat-inline-code`,style:{padding:`2px 6px`,borderRadius:4,fontSize:`0.85em`,fontFamily:`'Cascadia Code', 'Fira Code', 'Consolas', monospace`},children:i[4]},a++)),r=i.index+i[0].length;return r<e.length&&t.push(e.substring(r)),t}function je(e){return e.trim().startsWith(`|`)&&e.trim().endsWith(`|`)}function Me(e){return/^\|[\s:]*-+[\s:|-]*\|$/.test(e.trim())}function Ne(e,t,n){let r=t.palette.mode===`dark`,i=e=>e.trim().replace(/^\||\|$/g,``).split(`|`).map(e=>e.trim()),a=i(e[0]),o=e.slice(2).map(i);return D(v,{sx:{overflowX:`auto`,my:1},children:A(`table`,{style:{borderCollapse:`collapse`,width:`100%`,fontSize:`0.8rem`,color:t.palette.text.primary},children:[D(`thead`,{children:D(`tr`,{children:a.map((e,n)=>D(`th`,{style:{border:`1px solid ${t.palette.divider}`,padding:`6px 10px`,backgroundColor:r?t.palette.grey[800]:t.palette.grey[100],color:t.palette.text.primary,fontWeight:600,textAlign:`left`},children:$(e)},n))})}),D(`tbody`,{children:o.map((e,n)=>D(`tr`,{style:{backgroundColor:n%2==1?r?t.palette.grey[900]:t.palette.grey[50]:void 0},children:e.map((e,n)=>D(`td`,{style:{border:`1px solid ${t.palette.divider}`,padding:`6px 10px`,color:t.palette.text.primary},children:$(e)},n))},n))})]})},n)}function Pe(e,t){let n=e.split(`
|
|
19
19
|
`),r=[],i=0,a=0;for(;a<n.length;){let e=n[a].trim();if(e===``){a++;continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(e)){r.push(D(`hr`,{style:{border:`none`,borderTop:`1px solid ${t.palette.divider}`,margin:`8px 0`}},i++)),a++;continue}let o=e.match(/^(#{1,4})\s+(.+)$/);if(o){let e=o[1].length;r.push(D(`div`,{style:{fontWeight:600,fontSize:[`1.2em`,`1.1em`,`1em`,`0.95em`][e-1],margin:`8px 0 4px`},children:$(o[2])},i++)),a++;continue}if(je(e)&&a+1<n.length&&Me(n[a+1].trim())&&a+2<n.length){let e=[n[a],n[a+1]],o=a+2;for(;o<n.length&&je(n[o]);)e.push(n[o]),o++;r.push(Ne(e,t,i++)),a=o;continue}if(/^[-*+]\s/.test(e)){let e=[];for(;a<n.length&&/^\s*[-*+]\s/.test(n[a]);)e.push(n[a].replace(/^\s*[-*+]\s/,``).trim()),a++;r.push(D(`ul`,{style:{margin:`4px 0`,paddingLeft:20},children:e.map((e,t)=>D(`li`,{children:$(e)},t))},i++));continue}if(/^\d+[.)]\s/.test(e)){let e=[];for(;a<n.length&&/^\s*\d+[.)]\s/.test(n[a]);)e.push(n[a].replace(/^\s*\d+[.)]\s/,``).trim()),a++;r.push(D(`ol`,{style:{margin:`4px 0`,paddingLeft:20},children:e.map((e,t)=>D(`li`,{children:$(e)},t))},i++));continue}r.push(D(`div`,{children:$(e)},i++)),a++}return r}var Fe=({message:e,themeType:t,currentLanguage:n,onInsertCode:r,onShowDiff:i,onApplyCode:a})=>{let o=e.role===`user`,s=_(),c=o?t===`dark`?s.palette.primary.dark:s.palette.primary.main:t===`dark`?s.palette.secondary.dark:s.palette.secondary.main,l=s.palette.getContrastText(c),u=E(()=>Ae(e.content),[e.content]),d=(e,t)=>!!(e===`xml`||e===`blockly`||n===`blockly`&&t&&/<block\s+type=/.test(t));return A(v,{sx:{display:`flex`,gap:1,px:1.5,py:1,mx:.75,my:.5,bgcolor:o?t===`dark`?`rgba(144, 202, 249, 0.10)`:`rgba(25, 118, 210, 0.07)`:t===`dark`?`rgba(206, 147, 216, 0.10)`:`rgba(156, 39, 176, 0.06)`,borderRadius:1.5,borderLeft:`3px solid`,borderLeftColor:c,transition:`background-color 120ms`,"&:hover":{bgcolor:o?t===`dark`?`rgba(144, 202, 249, 0.16)`:`rgba(25, 118, 210, 0.12)`:t===`dark`?`rgba(206, 147, 216, 0.16)`:`rgba(156, 39, 176, 0.10)`}},children:[D(h,{sx:{width:28,height:28,bgcolor:c,color:l,flexShrink:0,mt:.5},children:D(o?ce:ue,{sx:{fontSize:18}})}),D(v,{sx:{flex:1,minWidth:0,fontSize:`0.875rem`,lineHeight:1.6},children:u.map((n,o)=>n.type===`code`?d(n.language,n.content)?A(v,{sx:{my:1},children:[D(ke,{xml:n.content}),A(v,{sx:{display:`flex`,gap:.5,mt:.5},children:[a&&D(y,{size:`small`,variant:`contained`,color:`primary`,startIcon:D(le,{sx:{fontSize:14}}),onClick:()=>a(n.content),sx:{textTransform:`none`,fontSize:`0.75rem`},children:O.t(`Apply blocks`)}),r&&D(y,{size:`small`,variant:`outlined`,startIcon:D(Z,{sx:{fontSize:14}}),onClick:()=>r(n.content),sx:{textTransform:`none`,fontSize:`0.75rem`},children:O.t(`Insert blocks`)})]})]},o):D(Oe,{code:n.content,language:n.language||`javascript`,themeType:t,onInsertCode:r,onShowDiff:i,sourceRange:e.sourceRange||null},o):D(v,{sx:{wordBreak:`break-word`,color:s.palette.text.primary},children:Pe(n.content,s)},o))})]})};function Ie(e){let t=(e||``).toLowerCase();return t.includes(`blockly`)||t.includes(`rules`)?`blockly`:t.includes(`typescript`)?`typescript`:`javascript`}function Le(e,t){return`\`\`\`${t===`blockly`?`xml`:t}\n${e}\n\`\`\``}function Re(e){let t=(e.code||``).trim(),n=Ie(e.language),r=e.rangeLabel?` (${e.rangeLabel})`:``;switch(e.action){case`explain`:return t?[`Please explain what this ioBroker ${n} code does${r}.`,`Focus on: which datapoints it reads/writes, which triggers fire it, and any side-effects.`,``,Le(t,n)].join(`
|
|
20
20
|
`):null;case`refactor`:return t?[`Refactor this ioBroker ${n} code${r} to be cleaner and more idiomatic.`,`Preserve behavior exactly. Keep ioBroker APIs (on, setState, getState, schedule, sendTo, log).`,`Return the full refactored block inside a \`\`\`${n===`blockly`?`xml`:n}\`\`\` code block so it can be smart-applied.`,``,Le(t,n)].join(`
|
|
21
21
|
`):null;case`comment`:return t?[`Add clear, concise inline comments to this ioBroker ${n} code${r}.`,`Only add comments where they add real value (non-obvious logic, tricky edge cases, business rules).`,`Do not over-comment trivial lines. Return the commented version in a code block.`,``,Le(t,n)].join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-C0FnF6B9.js";import{dt as t,m as n,sr as r,ut as i}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__57338878793567__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-8WiAnp-r.js";import{t as a}from"./vite-preload-helper-BbbETgeG.js";var o=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AI_PUSH_MESSAGE_TYPE=e.AI_COMMANDS=void 0,e.AI_COMMANDS={providers:`ai:providers`,models:`ai:models`,chat:`ai:chat`},e.AI_PUSH_MESSAGE_TYPE=`aiChatAnswer`})),s=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isChatModel=n,e.stripThinkingArtifacts=r,e.isTruncatedAnswer=i;var t=`embedding.text-embedding.textembedding.embeddinggemma.embed-.-embed.bge-.mxbai-embed.nomic-embed.arctic-embed.snowflake-arctic-embed.all-minilm.multilingual-e5.jina-embed.voyage-.gecko.paraphrase-multilingual.dall-e.gpt-image.image-edit.-image-preview.-image-latest.flash-image.nano-banana.stable-diffusion.sdxl.midjourney.flux-.imagen.sora.veo-.cogvideo.runway-.lumiere.lyria.whisper.tts-.-tts.speech-.audio-preview.mini-tts.mini-transcribe.-transcribe.native-audio.flash-live.gpt-audio.realtime.bark-.xtts.voicebox.moderation.omni-moderation.llama-guard.shieldgemma.prompt-guard.-guardian.safeguard.rerank.reranker.babbage-.davinci-.curie-.text-ada-.text-davinci.text-curie.text-babbage.instructgpt.code-davinci.code-cushman.-turbo-instruct.-search-preview.-search-api.code-search.text-search.similarity-.computer-use-preview.deep-research.robotics.aqa.reader-lm.-nsql.minicheck`.split(`.`);function n(e){let n=e.toLowerCase();return!(t.some(e=>n.includes(e))||n.startsWith(`claude-1`)||n.startsWith(`claude-instant`))}function r(e){let t=e;return t=t.replace(/<think>[\s\S]*?<\/think>/gi,``),t=t.replace(/<\|endoftext\|>/g,``),t=t.replace(/<\|im_start\|>[\s\S]*?<\|im_end\|>/g,``),t=t.replace(/<\|im_start\|>[\s\S]*/g,``),t.trim()}function i(e){return e.finishReason===`max_tokens`||e.finishReason===`length`}})),c=o(),l=s(),u={anthropic:[`claude-sonnet-4`,`claude-opus-4`,`claude-3-7-sonnet`],openai:[`gpt-5`,`gpt-4.1`,`gpt-4o`],gemini:[`gemini-2.5-pro`,`gemini-2.5-flash`,`gemini-2.0-flash`],deepseek:[`deepseek-chat`],custom:[]};function d(e){return e instanceof Error?e.message:String(e)}function f(e,t){let n;return Promise.race([e,new Promise(e=>{n=setTimeout(()=>e(null),t)})]).finally(()=>clearTimeout(n))}var p=class{constructor(e,t,n={}){r(this,`socket`,void 0),r(this,`instance`,void 0),r(this,`commands`,void 0),r(this,`storageKey`,void 0),r(this,`answerTimeout`,void 0),r(this,`askTimeout`,void 0),r(this,`modelCache`,new Map),r(this,`pushChannel`,null),r(this,`pushChannelPromise`,null),r(this,`requestCounter`,0),this.socket=e,this.instance=t,this.commands={...c.AI_COMMANDS,...n.commands},this.storageKey=n.storageKey||`ai.model`,this.answerTimeout=n.answerTimeout||8e3,this.askTimeout=n.askTimeout||6e5}async getProviders(){try{let e=await f(this.socket.sendTo(this.instance,this.commands.providers,{}),this.answerTimeout);return e===null?null:(e==null?void 0:e.providers)||[]}catch{return null}}async getModels(e){let t=this.modelCache.get(e);if(t)return{models:t};try{let t=await f(this.socket.sendTo(this.instance,this.commands.models,{provider:e}),Math.max(this.answerTimeout,3e4));if(t===null)return{models:[],error:`timeout`};if(t!=null&&t.error)return{models:[],error:t.error};let n=((t==null?void 0:t.models)||[]).filter(l.isChatModel);return n.length&&this.modelCache.set(e,n),{models:n}}catch(e){return{models:[],error:d(e)}}}clearModelCache(){this.modelCache.clear()}preferredModel(e,t){let n=``;try{n=window.localStorage.getItem(this.storageKey)||``}catch{}if(n&&e.includes(n))return n;for(let n of u[t]||[]){let t=e.find(e=>e.startsWith(n));if(t)return t}return e[0]||``}rememberModel(e){try{e&&window.localStorage.setItem(this.storageKey,e)}catch{}}resetPushChannel(){this.pushChannel=null,this.pushChannelPromise=null}ensurePushChannel(){return this.pushChannel?Promise.resolve(this.pushChannel):(this.pushChannelPromise||=(async()=>{let e={sessionToken:`ai-${Date.now().toString(36)}-${Math.random().toString(36).substring(2,10)}`,pending:new Map};try{let t=await f(this.socket.subscribeOnInstance(this.instance,c.AI_PUSH_MESSAGE_TYPE,{sessionToken:e.sessionToken},t=>{let n=t,r=n==null?void 0:n.requestId,i=r?e.pending.get(r):void 0;r&&i&&(e.pending.delete(r),i(n))}),this.answerTimeout);if(!(t!=null&&t.accepted))return null;e.sessionToken=t.session||e.sessionToken;let n=e=>{e||(this.socket.unregisterConnectionHandler(n),this.resetPushChannel())};return this.socket.registerConnectionHandler(n),this.pushChannel=e,e}catch{return null}finally{this.pushChannelPromise=null}})(),this.pushChannelPromise)}async ask(e){let t=e.timeout||this.askTimeout,n=await this.ensurePushChannel(),r=n?`req-${++this.requestCounter}-${Date.now().toString(36)}`:``,i;try{var a;i=await this.socket.sendTo(this.instance,this.commands.chat,{provider:e.provider,model:e.model,messages:e.messages,...(a=e.tools)!=null&&a.length?{tools:e.tools}:{},timeout:t,...n?{uiSession:n.sessionToken,requestId:r}:{}})}catch(e){return{error:d(e)}}return!n||!(i!=null&&i.accepted)?i?typeof i==`string`?{error:i}:i:{error:`The adapter answered with nothing`}:new Promise(e=>{let i=setTimeout(()=>{n.pending.delete(r),this.resetPushChannel(),e({error:`No answer within ${Math.round(t/1e3)}s`})},t);n.pending.set(r,t=>{clearTimeout(i),e(t)})})}},m=i(),h=t(),g=a(()=>import(`./docs-compact-D7rpMc7r.js`),[],import.meta.url),_={openai:`img/openai.svg`,anthropic:`img/anthropic.svg`,gemini:`img/gemini.svg`,deepseek:`img/deepseek.svg`,custom:`img/custom.svg`},v={width:16,height:16,flexShrink:0,opacity:.7},y={ru:`Russian`,en:`English`,de:`German`,es:`Spanish`,fr:`French`,it:`Italian`,pl:`Polish`,nl:`Dutch`,pt:`Portuguese`,uk:`Ukrainian`,"zh-cn":`Chinese`},b=null,x=null,S=null,C=null,w=null;function T(){b=null,x=null,S=null,C=null,w=null}function E(e,t){return(!b||b.socket!==e||b.instance!==t)&&(b=new p(e,t)),b}async function D(e,t){if(x)return x;let n=Object.keys(t)[0];if(!n)return null;let r=await E(e,n).getProviders()||[],i=r.map(e=>e.provider),a=r.find(e=>e.provider===`custom`);return i.length?(x={providers:i,gptBaseUrl:a==null?void 0:a.baseUrl},x):null}var O=`openai-model`,k=`openai-model-provider`;function A(e,t){window.localStorage.setItem(O,e),t?window.localStorage.setItem(k,t):window.localStorage.removeItem(k)}function j(){return{model:window.localStorage.getItem(O)||``,provider:window.localStorage.getItem(k)||``}}async function M(e,t){let r=await D(e,t);if(!r)return{models:[],providerMap:{},errors:[`No API keys configured`]};let i=Object.keys(t)[0];if(!i)return{models:[],providerMap:{},errors:[n.t(`No running javascript instance found`)]};let a=[],o={},s=[],c={},l=E(e,i),u=[],d=(e,t)=>{u.push(l.getModels(e).then(n=>{n.error?s.push(`${t||e}: ${n.error}`):c[e]=n.models}))},f={openai:`OpenAI`,anthropic:`Anthropic`,gemini:`Gemini`,deepseek:`DeepSeek`,custom:`Custom`};for(let e of r.providers)d(e,f[e]);await Promise.all(u);for(let e of r.providers)for(let t of c[e]||[])o[t]||(a.push(t),o[t]=e);return a.sort(),{models:a,providerMap:o,errors:s}}async function N(e,t,n){return await E(e,t).ask({provider:n.provider,model:n.model,messages:n.messages,tools:n.tools,timeout:n.timeout})}async function P(e){if(w)return w;let t=await e.getObjectViewSystem(`state`,``,`香`),n=await e.getObjectViewSystem(`channel`,``,`香`),r=await e.getObjectViewSystem(`device`,``,`香`),i=await e.getObjectViewSystem(`folder`,``,`香`),a=await e.getObjectViewSystem(`enum`,``,`香`);return w=Object.assign(t,n,r,i,a),w}async function F(e){return P(e)}function I(e,t){return e&&typeof e==`object`?e[t]||e.en:e||``}async function L(e){if(S)return S;let t=n.getLanguage(),r=await P(e),i=Object.keys(r).sort(),a=new h.ChannelDetector,o=[],s=[`UNREACH_STICKY`],c=[m.Types.info],l=[],u=[],d=[],f=[];i.forEach(e=>{var t,n;((t=r[e])==null?void 0:t.type)===`enum`?l.push(e):(n=r[e])!=null&&(n=n.common)!=null&&n.smartName&&f.push(e)}),l.forEach(e=>{e.startsWith(`enum.rooms.`)?u.push(e):e.startsWith(`enum.functions.`)&&d.push(e);let t=r[e].common.members;t!=null&&t.length&&t.forEach(e=>{r[e]&&!f.includes(e)&&f.push(e)})});let p={id:``,objects:r,_keysOptional:i,_usedIdsOptional:o,ignoreIndicators:s,excludedTypes:c},g=[];f.forEach(e=>{p.id=e;let n=a.detect(p);n&&n.forEach(e=>{var n;let i=(n=e.states.find(e=>e.id))==null?void 0:n.id;if(!i||g.find(e=>e.id===i))return;let a=r[i],o={id:i,name:I(a.common.name,t),type:a.type,deviceType:e.type,states:e.states.filter(e=>e.id).map(e=>({id:e.id,name:e.name,role:e.defaultRole,type:r[e.id].common.type,unit:r[e.id].common.unit,read:r[e.id].common.read??!0,write:r[e.id].common.write??!0}))},s=i.split(`.`),c,l;(a.type===`channel`||a.type===`state`)&&(s.pop(),c=s.join(`.`),r[c]&&(r[c].type===`channel`||r[c].type===`folder`)?(s.pop(),l=s.join(`.`),(!r[l]||r[l].type!==`device`&&r[c].type!==`folder`)&&(l=void 0)):c=void 0);let f=u.find(e=>{var t,n,a;return(t=r[e].common.members)!=null&&t.includes(i)||c&&(n=r[e].common.members)!=null&&n.includes(c)?!0:l&&((a=r[e].common.members)==null?void 0:a.includes(l))});f&&(o.room=I(r[f].common.name,t));let p=d.find(e=>{var t,n,a;return(t=r[e].common.members)!=null&&t.includes(i)||c&&(n=r[e].common.members)!=null&&n.includes(c)?!0:l&&((a=r[e].common.members)==null?void 0:a.includes(l))});p&&(o.function=I(r[p].common.name,t)),g.push(o)})});for(let e=0;e<g.length;e++){let n=g[e];if(n.type===`state`||n.type===`channel`){let e=n.id.split(`.`);e.pop();let i=r[e.join(`.`)];if(i&&(i.type===`channel`||i.type===`device`||i.type===`folder`)){var _,v;n.name=I(((_=i.common)==null?void 0:_.name)||n.name,t),e.pop();let a=r[e.join(`.`)];if((a==null?void 0:a.type)===`device`&&(v=a.common)!=null&&v.icon){var y;n.name=I(((y=a.common)==null?void 0:y.name)||n.name,t)}}else{var b;n.name=I((i==null||(b=i.common)==null?void 0:b.name)||n.name,t)}}}return S=g,g}async function R(){return C||(C=(await g).default,C)}function z(){return y[n.getLanguage()]||`English`}function B(e){return`You write ioBroker JavaScript adapter scripts.
|
|
1
|
+
import{t as e}from"./rolldown-runtime-C0FnF6B9.js";import{dt as t,m as n,sr as r,ut as i}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__244278364413149__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-Lnn-CkVR.js";import{t as a}from"./vite-preload-helper-BbbETgeG.js";var o=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AI_PUSH_MESSAGE_TYPE=e.AI_COMMANDS=void 0,e.AI_COMMANDS={providers:`ai:providers`,models:`ai:models`,chat:`ai:chat`},e.AI_PUSH_MESSAGE_TYPE=`aiChatAnswer`})),s=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isChatModel=n,e.stripThinkingArtifacts=r,e.isTruncatedAnswer=i;var t=`embedding.text-embedding.textembedding.embeddinggemma.embed-.-embed.bge-.mxbai-embed.nomic-embed.arctic-embed.snowflake-arctic-embed.all-minilm.multilingual-e5.jina-embed.voyage-.gecko.paraphrase-multilingual.dall-e.gpt-image.image-edit.-image-preview.-image-latest.flash-image.nano-banana.stable-diffusion.sdxl.midjourney.flux-.imagen.sora.veo-.cogvideo.runway-.lumiere.lyria.whisper.tts-.-tts.speech-.audio-preview.mini-tts.mini-transcribe.-transcribe.native-audio.flash-live.gpt-audio.realtime.bark-.xtts.voicebox.moderation.omni-moderation.llama-guard.shieldgemma.prompt-guard.-guardian.safeguard.rerank.reranker.babbage-.davinci-.curie-.text-ada-.text-davinci.text-curie.text-babbage.instructgpt.code-davinci.code-cushman.-turbo-instruct.-search-preview.-search-api.code-search.text-search.similarity-.computer-use-preview.deep-research.robotics.aqa.reader-lm.-nsql.minicheck`.split(`.`);function n(e){let n=e.toLowerCase();return!(t.some(e=>n.includes(e))||n.startsWith(`claude-1`)||n.startsWith(`claude-instant`))}function r(e){let t=e;return t=t.replace(/<think>[\s\S]*?<\/think>/gi,``),t=t.replace(/<\|endoftext\|>/g,``),t=t.replace(/<\|im_start\|>[\s\S]*?<\|im_end\|>/g,``),t=t.replace(/<\|im_start\|>[\s\S]*/g,``),t.trim()}function i(e){return e.finishReason===`max_tokens`||e.finishReason===`length`}})),c=o(),l=s(),u={anthropic:[`claude-sonnet-4`,`claude-opus-4`,`claude-3-7-sonnet`],openai:[`gpt-5`,`gpt-4.1`,`gpt-4o`],gemini:[`gemini-2.5-pro`,`gemini-2.5-flash`,`gemini-2.0-flash`],deepseek:[`deepseek-chat`],custom:[]};function d(e){return e instanceof Error?e.message:String(e)}function f(e,t){let n;return Promise.race([e,new Promise(e=>{n=setTimeout(()=>e(null),t)})]).finally(()=>clearTimeout(n))}var p=class{constructor(e,t,n={}){r(this,`socket`,void 0),r(this,`instance`,void 0),r(this,`commands`,void 0),r(this,`storageKey`,void 0),r(this,`answerTimeout`,void 0),r(this,`askTimeout`,void 0),r(this,`modelCache`,new Map),r(this,`pushChannel`,null),r(this,`pushChannelPromise`,null),r(this,`requestCounter`,0),this.socket=e,this.instance=t,this.commands={...c.AI_COMMANDS,...n.commands},this.storageKey=n.storageKey||`ai.model`,this.answerTimeout=n.answerTimeout||8e3,this.askTimeout=n.askTimeout||6e5}async getProviders(){try{let e=await f(this.socket.sendTo(this.instance,this.commands.providers,{}),this.answerTimeout);return e===null?null:(e==null?void 0:e.providers)||[]}catch{return null}}async getModels(e){let t=this.modelCache.get(e);if(t)return{models:t};try{let t=await f(this.socket.sendTo(this.instance,this.commands.models,{provider:e}),Math.max(this.answerTimeout,3e4));if(t===null)return{models:[],error:`timeout`};if(t!=null&&t.error)return{models:[],error:t.error};let n=((t==null?void 0:t.models)||[]).filter(l.isChatModel);return n.length&&this.modelCache.set(e,n),{models:n}}catch(e){return{models:[],error:d(e)}}}clearModelCache(){this.modelCache.clear()}preferredModel(e,t){let n=``;try{n=window.localStorage.getItem(this.storageKey)||``}catch{}if(n&&e.includes(n))return n;for(let n of u[t]||[]){let t=e.find(e=>e.startsWith(n));if(t)return t}return e[0]||``}rememberModel(e){try{e&&window.localStorage.setItem(this.storageKey,e)}catch{}}resetPushChannel(){this.pushChannel=null,this.pushChannelPromise=null}ensurePushChannel(){return this.pushChannel?Promise.resolve(this.pushChannel):(this.pushChannelPromise||=(async()=>{let e={sessionToken:`ai-${Date.now().toString(36)}-${Math.random().toString(36).substring(2,10)}`,pending:new Map};try{let t=await f(this.socket.subscribeOnInstance(this.instance,c.AI_PUSH_MESSAGE_TYPE,{sessionToken:e.sessionToken},t=>{let n=t,r=n==null?void 0:n.requestId,i=r?e.pending.get(r):void 0;r&&i&&(e.pending.delete(r),i(n))}),this.answerTimeout);if(!(t!=null&&t.accepted))return null;e.sessionToken=t.session||e.sessionToken;let n=e=>{e||(this.socket.unregisterConnectionHandler(n),this.resetPushChannel())};return this.socket.registerConnectionHandler(n),this.pushChannel=e,e}catch{return null}finally{this.pushChannelPromise=null}})(),this.pushChannelPromise)}async ask(e){let t=e.timeout||this.askTimeout,n=await this.ensurePushChannel(),r=n?`req-${++this.requestCounter}-${Date.now().toString(36)}`:``,i;try{var a;i=await this.socket.sendTo(this.instance,this.commands.chat,{provider:e.provider,model:e.model,messages:e.messages,...(a=e.tools)!=null&&a.length?{tools:e.tools}:{},timeout:t,...n?{uiSession:n.sessionToken,requestId:r}:{}})}catch(e){return{error:d(e)}}return!n||!(i!=null&&i.accepted)?i?typeof i==`string`?{error:i}:i:{error:`The adapter answered with nothing`}:new Promise(e=>{let i=setTimeout(()=>{n.pending.delete(r),this.resetPushChannel(),e({error:`No answer within ${Math.round(t/1e3)}s`})},t);n.pending.set(r,t=>{clearTimeout(i),e(t)})})}},m=i(),h=t(),g=a(()=>import(`./docs-compact-D7rpMc7r.js`),[],import.meta.url),_={openai:`img/openai.svg`,anthropic:`img/anthropic.svg`,gemini:`img/gemini.svg`,deepseek:`img/deepseek.svg`,custom:`img/custom.svg`},v={width:16,height:16,flexShrink:0,opacity:.7},y={ru:`Russian`,en:`English`,de:`German`,es:`Spanish`,fr:`French`,it:`Italian`,pl:`Polish`,nl:`Dutch`,pt:`Portuguese`,uk:`Ukrainian`,"zh-cn":`Chinese`},b=null,x=null,S=null,C=null,w=null;function T(){b=null,x=null,S=null,C=null,w=null}function E(e,t){return(!b||b.socket!==e||b.instance!==t)&&(b=new p(e,t)),b}async function D(e,t){if(x)return x;let n=Object.keys(t)[0];if(!n)return null;let r=await E(e,n).getProviders()||[],i=r.map(e=>e.provider),a=r.find(e=>e.provider===`custom`);return i.length?(x={providers:i,gptBaseUrl:a==null?void 0:a.baseUrl},x):null}var O=`openai-model`,k=`openai-model-provider`;function A(e,t){window.localStorage.setItem(O,e),t?window.localStorage.setItem(k,t):window.localStorage.removeItem(k)}function j(){return{model:window.localStorage.getItem(O)||``,provider:window.localStorage.getItem(k)||``}}async function M(e,t){let r=await D(e,t);if(!r)return{models:[],providerMap:{},errors:[`No API keys configured`]};let i=Object.keys(t)[0];if(!i)return{models:[],providerMap:{},errors:[n.t(`No running javascript instance found`)]};let a=[],o={},s=[],c={},l=E(e,i),u=[],d=(e,t)=>{u.push(l.getModels(e).then(n=>{n.error?s.push(`${t||e}: ${n.error}`):c[e]=n.models}))},f={openai:`OpenAI`,anthropic:`Anthropic`,gemini:`Gemini`,deepseek:`DeepSeek`,custom:`Custom`};for(let e of r.providers)d(e,f[e]);await Promise.all(u);for(let e of r.providers)for(let t of c[e]||[])o[t]||(a.push(t),o[t]=e);return a.sort(),{models:a,providerMap:o,errors:s}}async function N(e,t,n){return await E(e,t).ask({provider:n.provider,model:n.model,messages:n.messages,tools:n.tools,timeout:n.timeout})}async function P(e){if(w)return w;let t=await e.getObjectViewSystem(`state`,``,`香`),n=await e.getObjectViewSystem(`channel`,``,`香`),r=await e.getObjectViewSystem(`device`,``,`香`),i=await e.getObjectViewSystem(`folder`,``,`香`),a=await e.getObjectViewSystem(`enum`,``,`香`);return w=Object.assign(t,n,r,i,a),w}async function F(e){return P(e)}function I(e,t){return e&&typeof e==`object`?e[t]||e.en:e||``}async function L(e){if(S)return S;let t=n.getLanguage(),r=await P(e),i=Object.keys(r).sort(),a=new h.ChannelDetector,o=[],s=[`UNREACH_STICKY`],c=[m.Types.info],l=[],u=[],d=[],f=[];i.forEach(e=>{var t,n;((t=r[e])==null?void 0:t.type)===`enum`?l.push(e):(n=r[e])!=null&&(n=n.common)!=null&&n.smartName&&f.push(e)}),l.forEach(e=>{e.startsWith(`enum.rooms.`)?u.push(e):e.startsWith(`enum.functions.`)&&d.push(e);let t=r[e].common.members;t!=null&&t.length&&t.forEach(e=>{r[e]&&!f.includes(e)&&f.push(e)})});let p={id:``,objects:r,_keysOptional:i,_usedIdsOptional:o,ignoreIndicators:s,excludedTypes:c},g=[];f.forEach(e=>{p.id=e;let n=a.detect(p);n&&n.forEach(e=>{var n;let i=(n=e.states.find(e=>e.id))==null?void 0:n.id;if(!i||g.find(e=>e.id===i))return;let a=r[i],o={id:i,name:I(a.common.name,t),type:a.type,deviceType:e.type,states:e.states.filter(e=>e.id).map(e=>({id:e.id,name:e.name,role:e.defaultRole,type:r[e.id].common.type,unit:r[e.id].common.unit,read:r[e.id].common.read??!0,write:r[e.id].common.write??!0}))},s=i.split(`.`),c,l;(a.type===`channel`||a.type===`state`)&&(s.pop(),c=s.join(`.`),r[c]&&(r[c].type===`channel`||r[c].type===`folder`)?(s.pop(),l=s.join(`.`),(!r[l]||r[l].type!==`device`&&r[c].type!==`folder`)&&(l=void 0)):c=void 0);let f=u.find(e=>{var t,n,a;return(t=r[e].common.members)!=null&&t.includes(i)||c&&(n=r[e].common.members)!=null&&n.includes(c)?!0:l&&((a=r[e].common.members)==null?void 0:a.includes(l))});f&&(o.room=I(r[f].common.name,t));let p=d.find(e=>{var t,n,a;return(t=r[e].common.members)!=null&&t.includes(i)||c&&(n=r[e].common.members)!=null&&n.includes(c)?!0:l&&((a=r[e].common.members)==null?void 0:a.includes(l))});p&&(o.function=I(r[p].common.name,t)),g.push(o)})});for(let e=0;e<g.length;e++){let n=g[e];if(n.type===`state`||n.type===`channel`){let e=n.id.split(`.`);e.pop();let i=r[e.join(`.`)];if(i&&(i.type===`channel`||i.type===`device`||i.type===`folder`)){var _,v;n.name=I(((_=i.common)==null?void 0:_.name)||n.name,t),e.pop();let a=r[e.join(`.`)];if((a==null?void 0:a.type)===`device`&&(v=a.common)!=null&&v.icon){var y;n.name=I(((y=a.common)==null?void 0:y.name)||n.name,t)}}else{var b;n.name=I((i==null||(b=i.common)==null?void 0:b.name)||n.name,t)}}}return S=g,g}async function R(){return C||(C=(await g).default,C)}function z(){return y[n.getLanguage()]||`English`}function B(e){return`You write ioBroker JavaScript adapter scripts.
|
|
2
2
|
Copy EXACTLY this syntax. Do NOT change the callback signature.
|
|
3
3
|
IMPORTANT: Write all code at top level. NEVER use console.log (use log instead). NEVER define functions with the function keyword.
|
|
4
4
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{At as e,Cr as t,Ir as n,Jt as r,Kt as i,Ot as a,Yt as o,Zt as s,jr as c,lr as l,m as u,ur as d}from"./_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__244278364413149__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-Lnn-CkVR.js";import{t as f}from"./MonacoDiff-D24nsTu6.js";n();var p=({originalCode:n,modifiedCode:p,language:m,themeType:h,onAccept:g,onReject:_})=>{let v=c(null),y=t(()=>{var e;g(((e=v.current)==null?void 0:e.getModifiedValue())??p)},[p,g]);return d(o,{sx:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`},children:[d(i,{variant:`dense`,sx:{minHeight:36,bgcolor:`background.paper`,borderBottom:`1px solid`,borderColor:`divider`,gap:1,flexShrink:0},children:[l(r,{variant:`subtitle2`,sx:{flex:1},children:u.t(`AI suggested changes`)}),l(s,{variant:`contained`,color:`success`,size:`small`,startIcon:l(e,{}),onClick:y,children:u.t(`Accept`)}),l(s,{variant:`outlined`,color:`error`,size:`small`,startIcon:l(a,{}),onClick:_,children:u.t(`Reject`)})]}),l(o,{sx:{flex:1,overflow:`hidden`},children:l(f,{ref:v,originalCode:n,modifiedCode:p,language:m,themeType:h})})]})};export{p as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as e,r as t}from"./AiChatService-
|
|
1
|
+
import{h as e,r as t}from"./AiChatService-DwMHP0xt.js";var n=800,r=`You are a code completion engine for ioBroker JavaScript adapter scripts.
|
|
2
2
|
Complete the code at the cursor position marked with <CURSOR>.
|
|
3
3
|
Return ONLY the completion text, no explanation, no markdown fences, no comments about what you did.
|
|
4
4
|
If you cannot complete, return an empty string.
|