feat: expose image generation to page agents

This commit is contained in:
john
2026-07-19 18:39:46 +08:00
parent 5b88f8ece5
commit 9cf12e3786
10 changed files with 220 additions and 10 deletions
+10 -1
View File
@@ -256,6 +256,7 @@ test('sandboxMcpTools returns correct tool list based on capabilities', () => {
'write_file',
'edit_file',
'create_dir',
'generate_image',
'generate_docx',
'generate_long_image',
'private_data_info',
@@ -328,7 +329,12 @@ test('private_data_space alone exposes private data tools through sandbox MCP',
test('static_publish with sandboxMcp uses stdio sandbox-fs extension instead of developer', () => {
const caps = { ...DEFAULT_USER_CAPABILITIES, static_publish: true };
const sandboxMcp = { serverPath: '/opt/h5/mindspace-sandbox-mcp.mjs', sandboxRoot: '/opt/h5/MindSpace/abc123' };
const sandboxMcp = {
serverPath: '/opt/h5/mindspace-sandbox-mcp.mjs',
sandboxRoot: '/opt/h5/MindSpace/abc123',
agentApiBaseUrl: 'http://host.docker.internal:8081/api',
internalAgentSecret: 'internal-secret',
};
const policy = buildAgentExtensionPolicy(caps, { sandboxMcp });
const sandboxExt = policy.extensionOverrides.find((ext) => ext.name === 'sandbox-fs');
@@ -337,10 +343,13 @@ test('static_publish with sandboxMcp uses stdio sandbox-fs extension instead of
assert.equal(sandboxExt.cmd, process.execPath);
assert.equal(sandboxExt.envs.SANDBOX_ROOT, '/opt/h5/MindSpace/abc123');
assert.equal(sandboxExt.args[1], '/opt/h5/MindSpace/abc123'); // also passed as argv[2]
assert.equal(sandboxExt.envs.MINDSPACE_AGENT_API_BASE_URL, 'http://host.docker.internal:8081/api');
assert.equal(sandboxExt.envs.MINDSPACE_INTERNAL_AGENT_SECRET, 'internal-secret');
assert.ok(sandboxExt.available_tools.includes('write_file'));
assert.ok(sandboxExt.available_tools.includes('read_file'));
assert.ok(sandboxExt.available_tools.includes('generate_docx'));
assert.ok(sandboxExt.available_tools.includes('generate_long_image'));
assert.ok(sandboxExt.available_tools.includes('generate_image'));
// built-in developer extension should only remain for read_image (image_read: true by default)
const developer = policy.extensionOverrides.find((ext) => ext.name === 'developer');