Unify TUI slash commands and harden tool inventory responses
This commit is contained in:
+36
-2
@@ -140,6 +140,24 @@ function parseResearchPrefix(text: string): string | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function shouldForceNativeForCapabilityQuery(text: string): boolean {
|
||||
const normalized = text.trim().toLowerCase();
|
||||
if (!normalized) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
normalized.includes('available tools')
|
||||
|| normalized.includes('what tools')
|
||||
|| normalized.includes('which tools')
|
||||
|| normalized.includes('tool list')
|
||||
|| normalized.includes('list tools')
|
||||
|| normalized.includes('your tools')
|
||||
|| normalized.includes('what can you do')
|
||||
|| normalized.includes('can you do')
|
||||
|| normalized.includes('capabilities')
|
||||
);
|
||||
}
|
||||
|
||||
function isTtsEnabledForChannel(config: Config, channel: string): boolean {
|
||||
if (!config.tts?.enabled) {
|
||||
return false;
|
||||
@@ -649,6 +667,21 @@ export function createMessageRouter(deps: {
|
||||
: 'native';
|
||||
return `Flynn is running. Active model tier: ${agent.getModelTier()}. Backend: ${backend}`;
|
||||
},
|
||||
getTools: () => {
|
||||
const names = new Set(deps.toolRegistry.list().map((tool: Tool) => tool.name));
|
||||
names.add('media.send');
|
||||
if (deps.agentConfigRegistry && deps.agentConfigRegistry.list().length > 0) {
|
||||
names.add('agent.delegate');
|
||||
if (deps.config.councils?.enabled) {
|
||||
names.add('council.run');
|
||||
}
|
||||
}
|
||||
const sorted = [...names].sort();
|
||||
return [
|
||||
`Available tools (${sorted.length}):`,
|
||||
...sorted.map((name) => `- ${name}`),
|
||||
].join('\n');
|
||||
},
|
||||
getUsage: () => {
|
||||
const usage = agent.getUsage();
|
||||
const lines = [
|
||||
@@ -1260,11 +1293,12 @@ export function createMessageRouter(deps: {
|
||||
// buildUserMessage() in the agent will create native audio content parts
|
||||
|
||||
const requestedBackend = agentConfig?.backend ?? deps.defaultName;
|
||||
const forceNativeForCapabilityQuery = shouldForceNativeForCapabilityQuery(messageText);
|
||||
const sessionIdForAudit = `${msg.channel}:${msg.senderId}`;
|
||||
const selectedBackend = requestedBackend && requestedBackend !== 'native'
|
||||
? deps.externalBackends?.[requestedBackend]
|
||||
: undefined;
|
||||
const selectedBackendForAudit: 'native' | ExternalBackendName = selectedBackend && requestedBackend
|
||||
const selectedBackendForAudit: 'native' | ExternalBackendName = selectedBackend && requestedBackend && !forceNativeForCapabilityQuery
|
||||
? requestedBackend
|
||||
: 'native';
|
||||
|
||||
@@ -1280,7 +1314,7 @@ export function createMessageRouter(deps: {
|
||||
: 'native',
|
||||
});
|
||||
|
||||
if (selectedBackend && (!attachments || attachments.length === 0)) {
|
||||
if (selectedBackend && (!attachments || attachments.length === 0) && !forceNativeForCapabilityQuery) {
|
||||
try {
|
||||
const history = toExternalHistory(session.getHistory());
|
||||
session.addMessage({ role: 'user', content: messageText });
|
||||
|
||||
Reference in New Issue
Block a user