2025-12-02 10:59:09 +00:00
|
|
|
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
|
|
|
|
import * as smartagent from '../ts/index.js';
|
|
|
|
|
|
|
|
|
|
// Test exports
|
|
|
|
|
tap.test('should export DualAgentOrchestrator class', async () => {
|
|
|
|
|
expect(smartagent.DualAgentOrchestrator).toBeTypeOf('function');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('should export DriverAgent class', async () => {
|
|
|
|
|
expect(smartagent.DriverAgent).toBeTypeOf('function');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('should export GuardianAgent class', async () => {
|
|
|
|
|
expect(smartagent.GuardianAgent).toBeTypeOf('function');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('should export BaseToolWrapper class', async () => {
|
|
|
|
|
expect(smartagent.BaseToolWrapper).toBeTypeOf('function');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Test standard tools exports
|
|
|
|
|
tap.test('should export FilesystemTool class', async () => {
|
|
|
|
|
expect(smartagent.FilesystemTool).toBeTypeOf('function');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('should export HttpTool class', async () => {
|
|
|
|
|
expect(smartagent.HttpTool).toBeTypeOf('function');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('should export ShellTool class', async () => {
|
|
|
|
|
expect(smartagent.ShellTool).toBeTypeOf('function');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('should export BrowserTool class', async () => {
|
|
|
|
|
expect(smartagent.BrowserTool).toBeTypeOf('function');
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-02 12:11:31 +00:00
|
|
|
tap.test('should export DenoTool class', async () => {
|
|
|
|
|
expect(smartagent.DenoTool).toBeTypeOf('function');
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-02 10:59:09 +00:00
|
|
|
// Test tool instantiation
|
|
|
|
|
tap.test('should be able to instantiate FilesystemTool', async () => {
|
|
|
|
|
const fsTool = new smartagent.FilesystemTool();
|
|
|
|
|
expect(fsTool.name).toEqual('filesystem');
|
|
|
|
|
expect(fsTool.actions).toBeTypeOf('object');
|
|
|
|
|
expect(fsTool.actions.length).toBeGreaterThan(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('should be able to instantiate HttpTool', async () => {
|
|
|
|
|
const httpTool = new smartagent.HttpTool();
|
|
|
|
|
expect(httpTool.name).toEqual('http');
|
|
|
|
|
expect(httpTool.actions).toBeTypeOf('object');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('should be able to instantiate ShellTool', async () => {
|
|
|
|
|
const shellTool = new smartagent.ShellTool();
|
|
|
|
|
expect(shellTool.name).toEqual('shell');
|
|
|
|
|
expect(shellTool.actions).toBeTypeOf('object');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('should be able to instantiate BrowserTool', async () => {
|
|
|
|
|
const browserTool = new smartagent.BrowserTool();
|
|
|
|
|
expect(browserTool.name).toEqual('browser');
|
|
|
|
|
expect(browserTool.actions).toBeTypeOf('object');
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-02 12:11:31 +00:00
|
|
|
tap.test('should be able to instantiate DenoTool', async () => {
|
|
|
|
|
const denoTool = new smartagent.DenoTool();
|
|
|
|
|
expect(denoTool.name).toEqual('deno');
|
|
|
|
|
expect(denoTool.actions).toBeTypeOf('object');
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-02 10:59:09 +00:00
|
|
|
// Test tool descriptions
|
|
|
|
|
tap.test('FilesystemTool should have required actions', async () => {
|
|
|
|
|
const fsTool = new smartagent.FilesystemTool();
|
|
|
|
|
const actionNames = fsTool.actions.map((a) => a.name);
|
|
|
|
|
expect(actionNames).toContain('read');
|
|
|
|
|
expect(actionNames).toContain('write');
|
|
|
|
|
expect(actionNames).toContain('list');
|
|
|
|
|
expect(actionNames).toContain('delete');
|
|
|
|
|
expect(actionNames).toContain('exists');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('HttpTool should have required actions', async () => {
|
|
|
|
|
const httpTool = new smartagent.HttpTool();
|
|
|
|
|
const actionNames = httpTool.actions.map((a) => a.name);
|
|
|
|
|
expect(actionNames).toContain('get');
|
|
|
|
|
expect(actionNames).toContain('post');
|
|
|
|
|
expect(actionNames).toContain('put');
|
|
|
|
|
expect(actionNames).toContain('delete');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('ShellTool should have required actions', async () => {
|
|
|
|
|
const shellTool = new smartagent.ShellTool();
|
|
|
|
|
const actionNames = shellTool.actions.map((a) => a.name);
|
|
|
|
|
expect(actionNames).toContain('execute');
|
|
|
|
|
expect(actionNames).toContain('which');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('BrowserTool should have required actions', async () => {
|
|
|
|
|
const browserTool = new smartagent.BrowserTool();
|
|
|
|
|
const actionNames = browserTool.actions.map((a) => a.name);
|
|
|
|
|
expect(actionNames).toContain('screenshot');
|
|
|
|
|
expect(actionNames).toContain('pdf');
|
|
|
|
|
expect(actionNames).toContain('evaluate');
|
|
|
|
|
expect(actionNames).toContain('getPageContent');
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-02 12:11:31 +00:00
|
|
|
tap.test('DenoTool should have required actions', async () => {
|
|
|
|
|
const denoTool = new smartagent.DenoTool();
|
|
|
|
|
const actionNames = denoTool.actions.map((a) => a.name);
|
|
|
|
|
expect(actionNames).toContain('execute');
|
|
|
|
|
expect(actionNames).toContain('executeWithResult');
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-02 10:59:09 +00:00
|
|
|
// Test getCallSummary
|
|
|
|
|
tap.test('FilesystemTool should generate call summaries', async () => {
|
|
|
|
|
const fsTool = new smartagent.FilesystemTool();
|
|
|
|
|
const summary = fsTool.getCallSummary('read', { path: '/tmp/test.txt' });
|
|
|
|
|
expect(summary).toBeTypeOf('string');
|
|
|
|
|
expect(summary).toInclude('/tmp/test.txt');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('HttpTool should generate call summaries', async () => {
|
|
|
|
|
const httpTool = new smartagent.HttpTool();
|
|
|
|
|
const summary = httpTool.getCallSummary('get', { url: 'https://example.com' });
|
|
|
|
|
expect(summary).toBeTypeOf('string');
|
|
|
|
|
expect(summary).toInclude('example.com');
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-02 12:11:31 +00:00
|
|
|
tap.test('DenoTool should generate call summaries', async () => {
|
|
|
|
|
const denoTool = new smartagent.DenoTool();
|
|
|
|
|
const summary = denoTool.getCallSummary('execute', { code: 'console.log("hello");' });
|
|
|
|
|
expect(summary).toBeTypeOf('string');
|
|
|
|
|
expect(summary).toInclude('sandboxed');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tap.test('DenoTool should show permissions in call summary', async () => {
|
|
|
|
|
const denoTool = new smartagent.DenoTool();
|
|
|
|
|
const summary = denoTool.getCallSummary('execute', {
|
|
|
|
|
code: 'console.log("hello");',
|
|
|
|
|
permissions: ['net', 'read']
|
|
|
|
|
});
|
|
|
|
|
expect(summary).toBeTypeOf('string');
|
|
|
|
|
expect(summary).toInclude('permissions');
|
|
|
|
|
expect(summary).toInclude('net');
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-02 10:59:09 +00:00
|
|
|
export default tap.start();
|