neoagent 1.4.9 → 1.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -588,7 +588,7 @@ function getAvailableTools(app, options = {}) {
|
|
|
588
588
|
parameters: {
|
|
589
589
|
type: 'object',
|
|
590
590
|
properties: {
|
|
591
|
-
metric_type: { type: 'string', description: 'The specific metric to query, e.g. "
|
|
591
|
+
metric_type: { type: 'string', description: 'The specific metric to query, e.g. "steps", "heart_rate", "sleep_session", "exercise_session", "weight". Use the summary (no metric_type) first to see what\'s available. Optional.' },
|
|
592
592
|
limit: { type: 'number', description: 'Maximum number of recent records to return if metric_type is specified (default 50, max 200).' }
|
|
593
593
|
}
|
|
594
594
|
}
|
|
@@ -169,6 +169,15 @@ function getHealthSyncStatus(userId) {
|
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
function normalizeMetricType(raw) {
|
|
173
|
+
// Accept any casing/spacing: "HeartRate" → "heart_rate", "Steps" → "steps", etc.
|
|
174
|
+
return String(raw || '')
|
|
175
|
+
.trim()
|
|
176
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2') // camelCase/PascalCase → snake_case
|
|
177
|
+
.replace(/[\s-]+/g, '_') // spaces/dashes → underscore
|
|
178
|
+
.toLowerCase();
|
|
179
|
+
}
|
|
180
|
+
|
|
172
181
|
function readHealthData(userId, metricType, limit = 50) {
|
|
173
182
|
if (!metricType) {
|
|
174
183
|
const metrics = db.prepare(`
|
|
@@ -181,6 +190,8 @@ function readHealthData(userId, metricType, limit = 50) {
|
|
|
181
190
|
return { metrics };
|
|
182
191
|
}
|
|
183
192
|
|
|
193
|
+
const normalizedType = normalizeMetricType(metricType);
|
|
194
|
+
|
|
184
195
|
const samples = db.prepare(`
|
|
185
196
|
SELECT
|
|
186
197
|
start_time, end_time, recorded_at,
|
|
@@ -191,10 +202,10 @@ function readHealthData(userId, metricType, limit = 50) {
|
|
|
191
202
|
WHERE user_id = ? AND metric_type = ?
|
|
192
203
|
ORDER BY COALESCE(end_time, recorded_at, start_time) DESC
|
|
193
204
|
LIMIT ?
|
|
194
|
-
`).all(userId,
|
|
205
|
+
`).all(userId, normalizedType, limit);
|
|
195
206
|
|
|
196
207
|
return {
|
|
197
|
-
metricType,
|
|
208
|
+
metricType: normalizedType,
|
|
198
209
|
samples: samples.map(s => ({
|
|
199
210
|
...s,
|
|
200
211
|
payload: s.payload_json ? JSON.parse(s.payload_json) : null,
|