08feae8bef
落地 H5 Session 架构 Patch 1–5(Broker 收口、Router decision、SSE taxonomy、goosed 边界检查), 并新增可选 MEMIND_RUN_STREAM_REPLAY run 事件回放与 H5 假交付 guard;修复 Finish 先于 agent-run gate 导致 UI 永久 loading 的竞态,接入 verify:h5-session-patches 回归脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
57 lines
2.0 KiB
JavaScript
57 lines
2.0 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import test from 'node:test';
|
|
import {
|
|
checkGoosedProxyBoundary,
|
|
GOOSED_DIRECT_ALLOWLIST,
|
|
GOOSED_PROXY_ADAPTER_FILE,
|
|
GOOSED_PROXY_GUARDED_FILES,
|
|
} from './goosed-proxy-boundary.mjs';
|
|
|
|
const repoRoot = path.resolve(new URL('.', import.meta.url).pathname, '.');
|
|
|
|
test('current repository passes goosed proxy boundary check', () => {
|
|
const violations = checkGoosedProxyBoundary(repoRoot);
|
|
assert.equal(
|
|
violations.length,
|
|
0,
|
|
violations.map((item) => `${item.file}:${item.line} ${item.rule}`).join('\n'),
|
|
);
|
|
});
|
|
|
|
test('guard detects createApiFetch outside allowlist', () => {
|
|
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'goosed-boundary-'));
|
|
try {
|
|
fs.writeFileSync(
|
|
path.join(tempRoot, 'agent-run-gateway.mjs'),
|
|
'export async function run() {}\n',
|
|
);
|
|
fs.writeFileSync(
|
|
path.join(tempRoot, 'rogue-module.mjs'),
|
|
'function createApiFetch() {}\nexport const apiFetch = createApiFetch("https://127.0.0.1:18006");\n',
|
|
);
|
|
const violations = checkGoosedProxyBoundary(tempRoot, {
|
|
extraGuarded: [],
|
|
scanRepo: true,
|
|
});
|
|
assert.ok(violations.some((item) => item.file === 'rogue-module.mjs' && item.rule === 'create-api-fetch'));
|
|
} finally {
|
|
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test('allowlist permits MindSpace direct adapters', () => {
|
|
assert.ok(GOOSED_DIRECT_ALLOWLIST.includes('mindspace-agent-runner.mjs'));
|
|
assert.ok(GOOSED_DIRECT_ALLOWLIST.includes('mindspace-page-edit-session.mjs'));
|
|
assert.equal(GOOSED_PROXY_ADAPTER_FILE, 'tkmind-proxy.mjs');
|
|
assert.ok(GOOSED_PROXY_GUARDED_FILES.includes('server.mjs'));
|
|
});
|
|
|
|
test('tkmind proxy keeps legacy reply path at 410 AGENT_RUNS_REQUIRED', () => {
|
|
const content = fs.readFileSync(path.join(repoRoot, 'tkmind-proxy.mjs'), 'utf8');
|
|
assert.match(content, /AGENT_RUNS_REQUIRED/);
|
|
assert.match(content, /isReplyPath/);
|
|
});
|