Add Rain V0 for MeInput full-range chat analysis and delivery tooling.
Memind CI / Test, build, and release guards (push) Has been cancelled
Memind CI / Test, build, and release guards (push) Has been cancelled
Introduce rain-service orchestration, browser-safe chat skill filtering, MeInput adapter helpers, and verify/deploy scripts so Rain mode can summarize recent input without Memory V2 pollution. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -144,6 +144,65 @@ async function fetchViaDb(ctx) {
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rain 模式:按精确时间区间全量拉取 MeInput 原始记录(不过滤、不排序)。
|
||||
* @param {{ userId: string, range: { start: string, end: string } }} input
|
||||
*/
|
||||
export async function fetchMeinputRangeFull(input) {
|
||||
const userId = String(input.userId ?? '').trim();
|
||||
const start = String(input.range?.start ?? '').trim();
|
||||
const end = String(input.range?.end ?? '').trim();
|
||||
if (!userId || !start || !end) return [];
|
||||
|
||||
const pool = getMeinputPool();
|
||||
if (pool) {
|
||||
const [rows] = await pool.query(
|
||||
`SELECT event_id, text, app_name, app_bundle_id, created_at
|
||||
FROM mi_input_events
|
||||
WHERE user_id = ? AND privacy_level = 'normal'
|
||||
AND created_at >= ? AND created_at < ?
|
||||
ORDER BY created_at ASC`,
|
||||
[userId, start.slice(0, 23).replace('T', ' '), end.slice(0, 23).replace('T', ' ')],
|
||||
);
|
||||
return rows.map((row) => ({
|
||||
event_id: row.event_id,
|
||||
text: row.text,
|
||||
app_name: row.app_name,
|
||||
app_bundle_id: row.app_bundle_id,
|
||||
created_at:
|
||||
row.created_at instanceof Date ? row.created_at.toISOString() : new Date(row.created_at).toISOString(),
|
||||
}));
|
||||
}
|
||||
|
||||
const base = process.env.MEINPUT_BASE_URL ?? 'https://input.tkmind.cn';
|
||||
const username = process.env.MEINPUT_USERNAME ?? 'admin';
|
||||
const password = process.env.MEINPUT_PASSWORD ?? '';
|
||||
if (!password) return [];
|
||||
|
||||
const loginRes = await fetch(`${base}/v1/auth/login`, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ username, password }),
|
||||
});
|
||||
const login = await loginRes.json();
|
||||
if (!loginRes.ok || login.user_id !== userId) return [];
|
||||
|
||||
const url = new URL(`${base}/v1/evidence/export`);
|
||||
url.searchParams.set('limit', '10000');
|
||||
url.searchParams.set('since', start);
|
||||
url.searchParams.set('until', end);
|
||||
const res = await fetch(url, { headers: { authorization: `Bearer ${login.access_token}` } });
|
||||
const data = await res.json();
|
||||
if (!res.ok) return [];
|
||||
return (data.items ?? []).map((item) => ({
|
||||
event_id: item.evidence_id ?? item.event_id,
|
||||
text: item.payload?.text ?? item.text ?? '',
|
||||
app_name: item.payload?.context?.app ?? item.app_name ?? null,
|
||||
app_bundle_id: item.payload?.context?.app_bundle_id ?? item.app_bundle_id ?? null,
|
||||
created_at: item.occurred_at ?? item.created_at,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ userId: string, retrieval: object, time: object, temporalMode: string }} ctx
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user