Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

2.1 KB
Raw Blame
import { describe, expect, it } from 'vitest';
import { selectActiveTools } from './tool-exposure.js';

const ALL = ['read_file', 'write_file', 'run_command', 'spotify_play', 'spotify_pause', 'spotify_search'];

describe('selectActiveTools (ROADMAP P1.4)', () => {
  it('drops Spotify tools from an unrelated turn', () => {
    expect(selectActiveTools(ALL, 'fix the failing test in src/app.ts')).toEqual(['read_file', 'write_file', 'run_command']);
  });

  it('keeps everything when the message is about music', () => {
    expect(selectActiveTools(ALL, 'play some lo-fi on spotify')).toBeUndefined();
    expect(selectActiveTools(ALL, 'skip this track')).toBeUndefined();
  });

  it('keeps everything when recent history is about music', () => {
    expect(selectActiveTools(ALL, 'next one please', ['I put on your focus playlist.'])).toBeUndefined();
  });

  it('only looks at the last few history entries', () => {
    const old = ['playlist', 'a', 'b', 'c', 'd', 'e'];
    expect(selectActiveTools(ALL, 'summarise the README', old)).toEqual(['read_file', 'write_file', 'run_command']);
  });

  it('returns undefined when there is nothing to trim', () => {
    expect(selectActiveTools(['read_file', 'run_command'], 'anything')).toBeUndefined();
  });
});

describe('selectActiveTools: draw.io (ADR-039)', () => {
  const WITH_DRAWIO = ['read_file', 'drawio__open_drawio_xml', 'drawio__get_page', 'spotify_play'];
  it('leaves the diagram tools out of an unrelated turn', () => {
    expect(selectActiveTools(WITH_DRAWIO, 'Hi')).toEqual(['read_file']);
  });
  it('keeps them for a diagram request, or one that follows it', () => {
    expect(selectActiveTools(WITH_DRAWIO, 'make me a flowchart of the signup')).toEqual(['read_file', 'drawio__open_drawio_xml', 'drawio__get_page']);
    expect(selectActiveTools(WITH_DRAWIO, 'add a box for billing', ['Here is your architecture diagram in draw.io.'])).toEqual(['read_file', 'drawio__open_drawio_xml', 'drawio__get_page']);
  });
  it('gates each group on its own', () => {
    expect(selectActiveTools(WITH_DRAWIO, 'draw a diagram while the playlist plays')).toBeUndefined();
  });
});