feat: integrate pi rust lab runtime

This commit is contained in:
Agent Board
2026-07-10 10:54:34 +08:00
parent c8472bb898
commit 896c94b696
73 changed files with 19852 additions and 1152 deletions
+17 -7
View File
@@ -2,10 +2,11 @@
// Pi Lab API endpoint smoke
// 验证 Pi Lab API 路由在 mnote-web 开发环境下的响应
// 需要 mnote-web 已在运行(npm run desktop:hot 或独立启动)
// 检查:新端点 start/send/abort/events、SSE、disabled builtin tools、receipt、no polling
// 检查:新端点 start/send/abort/events、SSE、permission-system managed builtin tools、receipt、no polling
const BASE = process.env.MNOTE_PI_LAB_BASE || 'http://127.0.0.1:3000';
const AUTH_COOKIE = process.env.MNOTE_PI_LAB_AUTH || '';
const ACTOR_ID = process.env.MNOTE_E2E_ACTOR_ID || 'mnote-e2e';
async function check(description, fn) {
try {
@@ -24,7 +25,12 @@ async function check(description, fn) {
}
async function fetchJson(url, options = {}) {
const headers = { 'Content-Type': 'application/json', ...options.headers };
const headers = {
'Content-Type': 'application/json',
'x-mnote-actor-id': ACTOR_ID,
'x-mnote-actor-type': 'user',
...options.headers,
};
if (AUTH_COOKIE && AUTH_COOKIE.toLowerCase().startsWith('bearer ')) headers.Authorization = AUTH_COOKIE;
else if (AUTH_COOKIE) headers.Cookie = AUTH_COOKIE;
const res = await fetch(url, { ...options, headers });
@@ -59,12 +65,12 @@ async function main() {
return { passed: false, reason: 'missing managedPiSessionDirPolicy' };
}));
// 3. Status response has disabledPiBuiltinTools when enabled
results.push(await check('GET /api/page-ai/pi/status has disabledPiBuiltinTools', async () => {
// 3. Status response has managedPiBuiltinTools when enabled
results.push(await check('GET /api/page-ai/pi/status has managedPiBuiltinTools', async () => {
const { body } = await fetchJson(`${BASE}/api/page-ai/pi/status`);
if (body.enabled === false) return { passed: true }; // skip when disabled
if (body.disabledPiBuiltinTools) return { passed: true };
return { passed: false, reason: 'missing disabledPiBuiltinTools' };
if (Array.isArray(body.managedPiBuiltinTools)) return { passed: true };
return { passed: false, reason: 'missing managedPiBuiltinTools' };
}));
// 4. Start endpoint exists and returns proper schema (may 404 if disabled)
@@ -102,7 +108,11 @@ async function main() {
// 7. Events SSE endpoint returns proper content type
results.push(await check('GET /api/page-ai/pi/events returns SSE stream (disabled may 404)', async () => {
const res = await fetch(`${BASE}/api/page-ai/pi/events`, {
headers: { Accept: 'text/event-stream' },
headers: {
Accept: 'text/event-stream',
'x-mnote-actor-id': ACTOR_ID,
'x-mnote-actor-type': 'user',
},
});
if (res.status === 404 || res.status === 401 || res.status === 403) return { passed: true };
const ct = res.headers.get('Content-Type') || '';