LibreChat/packages/data-provider/src/agentToolOptions.spec.ts
lia-by-librechat[bot] 385c6f8a1a
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (full suite) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Docker Dev Images Build / publish (push) Waiting to run
Sync Helm Chart Tags / Ignore non-main push (push) Waiting to run
Sync Helm Chart Tags / Sync chart tags (push) Waiting to run
⚗️ refactor: Separate Content, Tool, and Agent Types From the Assistants Module (#15910)
types/assistants.ts held ~60 exports of which only ~11 were Assistants
API types. The rest were core message-content types and the Agent entity
types, so schemas.ts and agents.ts both imported foundational types from
a file named after the Assistants API.

Split into types/tools.ts (tool primitives, action naming) and
types/content.ts (message content parts, annotations, tool calls), moved
the Agent entity types into the existing types/agents.ts, and left a slim
Assistants-only types/assistants.ts.

No behavior change: every symbol keeps its public export from the package
barrel, so no consumer outside data-provider changes.

Co-authored-by: Lia <lia@librechat.ai>
2026-09-15 14:15:24 -04:00

53 lines
1.5 KiB
TypeScript

import type { AgentToolOptions } from './types/tools';
import { normalizeActionToolName, removeCodeExecutionCaller } from './agentToolOptions';
describe('normalizeActionToolName', () => {
it('normalizes only the encoded action domain', () => {
expect(normalizeActionToolName('get_foo---bar_action_swapi---tech')).toBe(
'get_foo---bar_action_swapi_tech',
);
});
it('leaves non-action tool names unchanged', () => {
expect(normalizeActionToolName('search_mcp_docs---server')).toBe('search_mcp_docs---server');
expect(normalizeActionToolName('get_action_data---x_mcp_srv')).toBe(
'get_action_data---x_mcp_srv',
);
});
});
describe('removeCodeExecutionCaller', () => {
it('removes a programmatic-only entry that has no other options', () => {
expect(
removeCodeExecutionCaller({
search: { allowed_callers: ['code_execution'] },
}),
).toEqual({});
});
it('preserves direct calling and unrelated options', () => {
expect(
removeCodeExecutionCaller({
search: {
allowed_callers: ['direct', 'code_execution'],
defer_loading: true,
},
}),
).toEqual({
search: {
allowed_callers: ['direct'],
defer_loading: true,
},
});
});
it('does not mutate its input', () => {
const input: AgentToolOptions = {
search: { allowed_callers: ['code_execution'], run_in_background: true },
};
removeCodeExecutionCaller(input);
expect(input.search.allowed_callers).toEqual(['code_execution']);
});
});