This commit is contained in:
@@ -75,10 +75,10 @@ export function createPhase2Tools({ cwd = process.cwd(), computer } = {}) {
|
|||||||
execute: async () => { const dir = path.join(os.homedir(), '.local/share/jarvis/memory'); try { return (await readdir(dir)).slice(0, 200); } catch { return []; } },
|
execute: async () => { const dir = path.join(os.homedir(), '.local/share/jarvis/memory'); try { return (await readdir(dir)).slice(0, 200); } catch { return []; } },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'memory_write', permission: PERMISSIONS.write,
|
name: 'memory_remember', permission: PERMISSIONS.write,
|
||||||
description: 'Write a local Jarvis memory note only after explicit confirmation.',
|
description: 'Write a local Jarvis memory note only after explicit confirmation.',
|
||||||
parameters: { type: 'object', properties: { name: { type: 'string' }, text: { type: 'string' }, confirmed: { type: 'boolean' } }, required: ['name', 'text', 'confirmed'] },
|
parameters: { type: 'object', properties: { name: { type: 'string' }, text: { type: 'string' }, confirmed: { type: 'boolean' } }, required: ['name', 'text', 'confirmed'] },
|
||||||
execute: async ({ name, text, confirmed }) => { if (confirmed !== true) return { confirmation_required: true, action: 'memory_write', name }; const dir = path.join(os.homedir(), '.local/share/jarvis/memory'); const safe = String(name).replace(/[^a-zA-Z0-9._-]/g, '_'); await (await import('node:fs/promises')).mkdir(dir, { recursive: true }); await writeFile(path.join(dir, safe), String(text), 'utf8'); return { ok: true, name: safe }; },
|
execute: async ({ name, text, confirmed }) => { if (confirmed !== true) return { confirmation_required: true, action: 'memory_remember', name }; const dir = path.join(os.homedir(), '.local/share/jarvis/memory'); const safe = String(name).replace(/[^a-zA-Z0-9._-]/g, '_'); await (await import('node:fs/promises')).mkdir(dir, { recursive: true }); await writeFile(path.join(dir, safe), String(text), 'utf8'); return { ok: true, name: safe }; },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'rag_workspaces', permission: PERMISSIONS.read,
|
name: 'rag_workspaces', permission: PERMISSIONS.read,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ test('voice sidecars are removed from speech and retained for the HUD', () => {
|
|||||||
|
|
||||||
test('phase 2 registers safe local tools with permission metadata', async () => {
|
test('phase 2 registers safe local tools with permission metadata', async () => {
|
||||||
const tools = createPhase2Tools({ cwd: process.cwd() });
|
const tools = createPhase2Tools({ cwd: process.cwd() });
|
||||||
assert.deepEqual(tools.map((tool) => tool.name), ['app_list', 'fs_search', 'fs_read', 'fs_write', 'memory_recall', 'memory_write', 'rag_workspaces', 'capability_status']);
|
assert.deepEqual(tools.map((tool) => tool.name), ['app_list', 'fs_search', 'fs_read', 'fs_write', 'memory_recall', 'memory_remember', 'rag_workspaces', 'capability_status']);
|
||||||
assert.equal(tools.find((tool) => tool.name === 'fs_search').permission, 'read');
|
assert.equal(tools.find((tool) => tool.name === 'fs_search').permission, 'read');
|
||||||
assert.ok((await tools.find((tool) => tool.name === 'fs_search').execute({ query: 'ROADMAP' })).some((x) => x.endsWith('ROADMAP.md')));
|
assert.ok((await tools.find((tool) => tool.name === 'fs_search').execute({ query: 'ROADMAP' })).some((x) => x.endsWith('ROADMAP.md')));
|
||||||
assert.deepEqual(await tools.find((tool) => tool.name === 'fs_write').execute({ file: 'nope.txt', contents: 'x', confirmed: false }), { confirmation_required: true, action: 'write', file: 'nope.txt' });
|
assert.deepEqual(await tools.find((tool) => tool.name === 'fs_write').execute({ file: 'nope.txt', contents: 'x', confirmed: false }), { confirmation_required: true, action: 'write', file: 'nope.txt' });
|
||||||
|
|||||||
Reference in New Issue
Block a user