Skip to content

The agent that grows with you

fix(tui): /tools lists the session's tools on the shared gateway

Teknium71ff6c537151
diff --git a/ui-tui/src/__tests__/canonicalSlashCommands.test.ts b/ui-tui/src/__tests__/canonicalSlashCommands.test.ts
index e6cb01a0617..02c8b49b57f 100644
--- a/ui-tui/src/__tests__/canonicalSlashCommands.test.ts
+++ b/ui-tui/src/__tests__/canonicalSlashCommands.test.ts
@@ -55,8 +55,14 @@ function harness() {
return { status: 'terminal', result: { model: 'm', input_tokens: 5, output_tokens: 7, total_tokens: 12, api_calls: 1 } }
}
- if (method === 'session.info') {
- return { launch_request: { toolsets: ['terminal', 'web'] } }
+ if (method === 'tools.show') {
+ return {
+ sections: [
+ { name: 'file', tools: [{ name: 'read_file', description: 'Read a text file.' }] },
+ { name: 'terminal', tools: [{ name: 'terminal', description: 'Run a shell command.' }] }
+ ],
+ total: 2
+ }
}
if (method === 'config.get') {
@@ -133,8 +139,8 @@ it('/title renames and /undo, /retry rewind through session.mutate with the snap
expect(request.mock.calls.some(([method]) => LEGACY.includes(method))).toBe(false)
})
-it("/usage renders main's session totals from session.stats and /tools says what the shared gateway lacks", async () => {
- const { panel, request, slash, sys } = harness()
+it("/usage renders main's session totals from session.stats and /tools lists the owner's tools.show", async () => {
+ const { page, panel, request, slash, sys } = harness()
noteCanonicalCompletion('owner', 'adm-1')
slash('/usage')
@@ -159,8 +165,25 @@ it("/usage renders main's session totals from session.stats and /tools says what
slash('/tools')
await flush()
- expect(sys).toHaveBeenCalledWith('toolsets fixed at session launch: terminal, web')
- expect(sys).toHaveBeenCalledWith('/tools is not available on the shared gateway yet')
+ // Main's /tools listing (cli_info_mixin.show_tools layout) from the owner's tools.show, in the pager.
+ expect(request).toHaveBeenCalledWith('tools.show', { session_id: 'owner' })
+ expect(page).toHaveBeenCalledWith(
+ [
+ '+------------------------------------------------------------------------------+',
+ '| (^_^)/ Available Tools |',
+ '+------------------------------------------------------------------------------+',
+ '',
+ ' [file]',
+ ' * read_file - Read a text file.',
+ '',
+ ' [terminal]',
+ ' * terminal - Run a shell command.',
+ '',
+ ' Total: 2 tools ヽ(^o^)ノ'
+ ].join('\n'),
+ 'Tools'
+ )
+ expect(sys.mock.calls.some(([line]) => /not available on the shared gateway/.test(line))).toBe(false)
expect(sys.mock.calls.some(([line]) => /request_failed|unsupported_command|unknown_method/.test(line))).toBe(false)
expect(request.mock.calls.some(([method]) => LEGACY.includes(method))).toBe(false)
})
diff --git a/ui-tui/src/app/slash/canonicalSessionCommands.ts b/ui-tui/src/app/slash/canonicalSessionCommands.ts
index 2f9839a4282..f344921cd19 100644
--- a/ui-tui/src/app/slash/canonicalSessionCommands.ts
+++ b/ui-tui/src/app/slash/canonicalSessionCommands.ts
@@ -220,25 +220,53 @@ export function canonicalUsage(ctx: SlashRunCtx) {
.catch(ctx.guardedErr)
}
-/** `/tools`: a canonical session's toolsets are frozen at launch (`session.info.launch_request`);
- * listing and toggling them live has no canonical verb yet. */
+interface ToolsShowResult {
+ sections?: { name: string; tools?: { description?: string; name: string }[] }[]
+ total?: number
+}
+
+/** Main's `/tools` text (hermes_cli/cli_info_mixin.py show_tools): kawaii header box, one
+ * `[toolset]` block per section with the first description sentence, then the total. */
+export function renderToolsListing(result: ToolsShowResult): string {
+ const sections = result.sections ?? []
+
+ if (!sections.some(section => section.tools?.length)) {
+ return '(;_;) No tools available'
+ }
+
+ const title = '(^_^)/ Available Tools'
+ const pad = 78 - title.length
+ const rule = `+${'-'.repeat(78)}+`
+ const lines = [rule, `|${' '.repeat(Math.floor(pad / 2))}${title}${' '.repeat(pad - Math.floor(pad / 2))}|`, rule, '']
+
+ for (const section of sections) {
+ lines.push(` [${section.name}]`)
+
+ for (const tool of section.tools ?? []) {
+ lines.push(` * ${tool.name.padEnd(20)} - ${tool.description ?? ''}`)
+ }
+
+ lines.push('')
+ }
+
+ lines.push(` Total: ${result.total ?? 0} tools ヽ(^o^)ノ`)
+
+ return lines.join('\n')
+}
+
+/** `/tools`: the session's catalog from the owner's `tools.show` (its toolsets, MCP and plugin
+ * tools), rendered as main's listing in the pager. */
export function canonicalTools(ctx: SlashRunCtx) {
const sid = ctx.sid!
void ctx.gateway.gw
- .request<{ launch_request?: { toolsets?: unknown } }>('session.info', { session_id: sid })
- .then(info => {
+ .request<ToolsShowResult>('tools.show', { session_id: sid })
+ .then(raw => {
if (ctx.stale()) {
return
}
- const toolsets = info?.launch_request?.toolsets
-
- if (Array.isArray(toolsets) && toolsets.length) {
- ctx.transcript.sys(t('canonical.controls.launchToolsets', toolsets.join(', ')))
- }
-
- ctx.transcript.sys(t('canonical.controls.notAvailable', 'tools'))
+ ctx.transcript.page(renderToolsListing(asRpcResult<ToolsShowResult>(raw) ?? {}), t('slashCmd.ops.slashWorker.toolsTitle'))
})
.catch(ctx.guardedErr)
}