smart-home-engine 1.14.4 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/assets/{index-BXB4YlVH.css → index-LTpStzqg.css} +1 -1
- package/dist/web/assets/index-Vw4M_nL7.js +232 -0
- package/dist/web/assets/{tsMode-DU5RTuIh.js → tsMode-acXHtETC.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/src/index.js +24 -0
- package/src/lib/storage.js +3 -1
- package/src/web/scripts-api.js +1 -1
- package/src/web/server.js +25 -0
- package/dist/web/assets/index-BPKYEBmN.js +0 -232
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as O}from"./monaco-langs-Dt8a9eeo.js";import{t as I}from"./index-
|
|
1
|
+
import{m as O}from"./monaco-langs-Dt8a9eeo.js";import{t as I}from"./index-Vw4M_nL7.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|
package/dist/web/index.html
CHANGED
|
@@ -172,10 +172,10 @@
|
|
|
172
172
|
}
|
|
173
173
|
})();
|
|
174
174
|
</script>
|
|
175
|
-
<script type="module" crossorigin src="/assets/index-
|
|
175
|
+
<script type="module" crossorigin src="/assets/index-Vw4M_nL7.js"></script>
|
|
176
176
|
<link rel="modulepreload" crossorigin href="/assets/monaco-langs-Dt8a9eeo.js">
|
|
177
177
|
<link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
|
|
178
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
178
|
+
<link rel="stylesheet" crossorigin href="/assets/index-LTpStzqg.css">
|
|
179
179
|
</head>
|
|
180
180
|
<body>
|
|
181
181
|
<div id="app"></div>
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -37,6 +37,26 @@ if (process.argv.includes('--install')) {
|
|
|
37
37
|
// Ensure the data directory exists before anything else runs
|
|
38
38
|
require('./lib/storage').ensureRoot();
|
|
39
39
|
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Persistent JSON-Lines log file — written alongside the pino-pretty stream.
|
|
42
|
+
// On each daemon start: rotate she.jsonl → she.jsonl.1, then open fresh.
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
const _fs = require('fs');
|
|
45
|
+
const _path = require('path');
|
|
46
|
+
const { LOGS_DIR } = require('./lib/storage');
|
|
47
|
+
const _logFileCurrent = _path.join(LOGS_DIR, 'she.jsonl');
|
|
48
|
+
const _logFilePrev = _path.join(LOGS_DIR, 'she.jsonl.1');
|
|
49
|
+
try {
|
|
50
|
+
_fs.renameSync(_logFileCurrent, _logFilePrev);
|
|
51
|
+
} catch {
|
|
52
|
+
/* no previous file — ignore */
|
|
53
|
+
}
|
|
54
|
+
const _logFileStream = _fs.createWriteStream(_logFileCurrent, { flags: 'w' });
|
|
55
|
+
function _writeLogLine(level, msg) {
|
|
56
|
+
_logFileStream.write(JSON.stringify({ level, msg, ts: Date.now() }) + '\n');
|
|
57
|
+
}
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
|
|
40
60
|
const config = require('./config');
|
|
41
61
|
|
|
42
62
|
// Apply configured timezone before any Date/scheduler usage
|
|
@@ -60,18 +80,22 @@ const log = {
|
|
|
60
80
|
debug: (...args) => {
|
|
61
81
|
_pino.debug(args.join(' '));
|
|
62
82
|
broadcastLog({ level: 'debug', msg: args.join(' '), ts: Date.now() });
|
|
83
|
+
_writeLogLine('debug', args.join(' '));
|
|
63
84
|
},
|
|
64
85
|
info: (...args) => {
|
|
65
86
|
_pino.info(args.join(' '));
|
|
66
87
|
broadcastLog({ level: 'info', msg: args.join(' '), ts: Date.now() });
|
|
88
|
+
_writeLogLine('info', args.join(' '));
|
|
67
89
|
},
|
|
68
90
|
warn: (...args) => {
|
|
69
91
|
_pino.warn(args.join(' '));
|
|
70
92
|
broadcastLog({ level: 'warn', msg: args.join(' '), ts: Date.now() });
|
|
93
|
+
_writeLogLine('warn', args.join(' '));
|
|
71
94
|
},
|
|
72
95
|
error: (...args) => {
|
|
73
96
|
_pino.error(args.join(' '));
|
|
74
97
|
broadcastLog({ level: 'error', msg: args.join(' '), ts: Date.now() });
|
|
98
|
+
_writeLogLine('error', args.join(' '));
|
|
75
99
|
},
|
|
76
100
|
setLevel: (level) => {
|
|
77
101
|
_pino.level = level;
|
package/src/lib/storage.js
CHANGED
|
@@ -8,6 +8,7 @@ const STORAGE_ROOT = process.env.SHE_DATA_DIR || path.join(os.homedir(), '.she')
|
|
|
8
8
|
const CONFIG_ROOT = path.join(STORAGE_ROOT, 'config');
|
|
9
9
|
const SCRIPTS_ROOT = path.join(STORAGE_ROOT, 'scripts');
|
|
10
10
|
const DB_ROOT = path.join(STORAGE_ROOT, 'db');
|
|
11
|
+
const LOGS_DIR = path.join(STORAGE_ROOT, 'logs');
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Return the absolute path for a named sub-directory of ~/.she/.
|
|
@@ -43,6 +44,7 @@ function ensureRoot() {
|
|
|
43
44
|
fs.mkdirSync(CONFIG_ROOT, { recursive: true });
|
|
44
45
|
fs.mkdirSync(SCRIPTS_ROOT, { recursive: true });
|
|
45
46
|
fs.mkdirSync(DB_ROOT, { recursive: true });
|
|
47
|
+
fs.mkdirSync(LOGS_DIR, { recursive: true });
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
/**
|
|
@@ -71,4 +73,4 @@ function ensureUserPackageJson() {
|
|
|
71
73
|
return pkgPath;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
module.exports = { STORAGE_ROOT, CONFIG_ROOT, SCRIPTS_ROOT, DB_ROOT, getStoragePath, getConfigPath, ensureStorageDir, ensureRoot, ensureUserPackageJson };
|
|
76
|
+
module.exports = { STORAGE_ROOT, CONFIG_ROOT, SCRIPTS_ROOT, DB_ROOT, LOGS_DIR, getStoragePath, getConfigPath, ensureStorageDir, ensureRoot, ensureUserPackageJson };
|
package/src/web/scripts-api.js
CHANGED
package/src/web/server.js
CHANGED
|
@@ -124,6 +124,31 @@ app.get('/she/status', (req, res) => {
|
|
|
124
124
|
res.json(s);
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
+
// Log history from the current daemon run's she.jsonl file.
|
|
128
|
+
// ?since=<ts> filters to entries with ts >= that timestamp (default: 0 = all).
|
|
129
|
+
app.get('/she/logs/history', (req, res) => {
|
|
130
|
+
const since = req.query.since ? parseInt(req.query.since, 10) : 0;
|
|
131
|
+
const { LOGS_DIR } = require('../lib/storage');
|
|
132
|
+
const logFile = require('path').join(LOGS_DIR, 'she.jsonl');
|
|
133
|
+
try {
|
|
134
|
+
const raw = require('fs').readFileSync(logFile, 'utf8');
|
|
135
|
+
const entries = raw
|
|
136
|
+
.split('\n')
|
|
137
|
+
.filter((l) => l.trim())
|
|
138
|
+
.map((l) => {
|
|
139
|
+
try {
|
|
140
|
+
return JSON.parse(l);
|
|
141
|
+
} catch {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
.filter((e) => e && typeof e.ts === 'number' && e.ts >= since);
|
|
146
|
+
res.json(entries);
|
|
147
|
+
} catch {
|
|
148
|
+
res.json([]);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
127
152
|
// Serve the built Svelte SPA from dist/web/
|
|
128
153
|
// Hashed assets (JS/CSS) are immutable; index.html must never be cached so
|
|
129
154
|
// browsers always pick up a freshly deployed version.
|