105 lines
5.2 KiB
JavaScript
105 lines
5.2 KiB
JavaScript
import { createRequire } from 'node:module';
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { createRuntimeTools } from '../skills/runtime-tools.js';
|
|
import { assertSdkVersion } from '../daemon/qvac-master.js';
|
|
import { parseHudSidecar, VOICE_SYSTEM_PROMPT } from '../skills/voice-prompt.js';
|
|
import { createPhase2Tools } from '../skills/phase2-tools.js';
|
|
import { createQvacTools } from '../skills/qvac-tools.js';
|
|
import { profile } from '../daemon/model-profiles.js';
|
|
|
|
test('runtime tools expose local QVAC and computer-use status', () => {
|
|
const computer = { status: () => ({ active: true, steps_used: 2, backend: 'portal-ei' }) };
|
|
const tools = createRuntimeTools({ computer });
|
|
const status = tools.find((tool) => tool.name === 'jarvis_status').execute({});
|
|
assert.equal(status.local, true);
|
|
assert.equal(status.computer_use.active, true);
|
|
assert.equal(tools.find((tool) => tool.name === 'cu_status').execute({}).backend, 'portal-ei');
|
|
});
|
|
|
|
test('the copied harness uses the pinned QVAC 0.19.x SDK', () => {
|
|
assert.match(assertSdkVersion(), /^0\.19\./);
|
|
});
|
|
|
|
test('voice sidecars are removed from speech and retained for the HUD', () => {
|
|
const parsed = parseHudSidecar('Done. <jarvis_hud>{"title":"Done","chips":[]}</jarvis_hud>');
|
|
assert.equal(parsed.spoken, 'Done.');
|
|
assert.equal(parsed.hud.title, 'Done');
|
|
});
|
|
|
|
test('web_fetch times out instead of hanging the turn', async () => {
|
|
const require = createRequire(import.meta.url);
|
|
const tools = require('../vendor/agent-harness/agent/tools.js');
|
|
const orig = globalThis.fetch;
|
|
globalThis.fetch = () => new Promise(() => {});
|
|
try {
|
|
const hung = await tools.webFetch('https://example.com/ip', 40);
|
|
assert.match(String(hung.error), /timed out/i);
|
|
assert.equal(hung.url, 'https://example.com/ip');
|
|
} finally {
|
|
globalThis.fetch = orig;
|
|
}
|
|
globalThis.fetch = async (url) => ({
|
|
status: 200,
|
|
url: String(url),
|
|
text: async () => '203.0.113.8',
|
|
});
|
|
try {
|
|
const ok = await tools.webFetch('https://ifconfig.me/ip', 200);
|
|
assert.equal(ok.status, 200);
|
|
assert.equal(ok.url, 'https://ifconfig.me/ip');
|
|
assert.equal(ok.text, '203.0.113.8');
|
|
} finally {
|
|
globalThis.fetch = orig;
|
|
}
|
|
});
|
|
|
|
test('public web search and fetch do not require confirmation', () => {
|
|
const require = createRequire(import.meta.url);
|
|
const policy = require('../vendor/agent-harness/agent/policy.js');
|
|
assert.equal(policy.needsPermission('web_fetch', 'ask'), false);
|
|
assert.equal(policy.needsPermission('web_search', 'ask'), false);
|
|
assert.equal(policy.needsPermission('run_terminal_cmd', 'ask'), true);
|
|
assert.equal(policy.needsPermission('write_file', 'ask'), true);
|
|
});
|
|
|
|
test('voice prompt tells the model not to chain extra terminal commands', () => {
|
|
assert.match(VOICE_SYSTEM_PROMPT, /call run_terminal_cmd once/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /Do not chain extra commands/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /Reply in plain text only/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /Never use markdown/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /Quantum Verse Automatic Computer/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /spell it as Q V A C/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /Internet protocol addresses have no dots/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /Spell them as separate letters/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /web_fetch/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /web_search and web_fetch are unrestricted/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /Never say you will use a tool/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /Do not stop in thoughts/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /ifconfig\.me\/ip/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /This computer can reach the internet/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /HTTP access is not allowed/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /Tool names, tool arguments/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /File tools may read any path they accept/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /Allow now/);
|
|
assert.match(VOICE_SYSTEM_PROMPT, /call cu_observe to see the screen/);
|
|
assert.doesNotMatch(VOICE_SYSTEM_PROMPT, /Never claim cloud access/);
|
|
});
|
|
|
|
test('phase 2 registers safe local tools with permission metadata', async () => {
|
|
const tools = createPhase2Tools({ cwd: process.cwd() });
|
|
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.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' });
|
|
});
|
|
|
|
test('QVAC utility tools are exposed only through the master adapter', () => {
|
|
assert.deepEqual(createQvacTools().map((tool) => tool.name), ['qvac_runtime_state', 'qvac_system_resources', 'qvac_assess_model_fit']);
|
|
});
|
|
|
|
test('model profiles select one master model without creating another runtime', () => {
|
|
assert.equal(profile('desktop-gpu').model, 'qwen3.5-9b');
|
|
assert.throws(() => profile('missing'), /unknown Jarvis model profile/);
|
|
});
|