From 5d832ba5eb72f5aaa9a1026a7c13fec76c411786 Mon Sep 17 00:00:00 2001 From: Curtis Man Date: Mon, 2 Dec 2024 10:48:19 -0800 Subject: [PATCH] Show emoji in agent status table (#444) Also use fully qualified version of the greeting emoji to get the full-width in console. --- .../agents/greeting/src/greetingManifest.json | 2 +- .../dispatcher/src/handlers/configCommandHandlers.ts | 12 ++++++++---- ts/packages/dispatcher/src/utils/exceptions.ts | 12 +----------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/ts/packages/agents/greeting/src/greetingManifest.json b/ts/packages/agents/greeting/src/greetingManifest.json index 98cb86dfc..42a2fd0fd 100644 --- a/ts/packages/agents/greeting/src/greetingManifest.json +++ b/ts/packages/agents/greeting/src/greetingManifest.json @@ -1,5 +1,5 @@ { - "emojiChar": "🖐", + "emojiChar": "🖐️", "description": "Agent to generate greating messages", "schema": { "description": "Greeting agent that created personalized welcome messages.", diff --git a/ts/packages/dispatcher/src/handlers/configCommandHandlers.ts b/ts/packages/dispatcher/src/handlers/configCommandHandlers.ts index a1098a853..88073cf87 100644 --- a/ts/packages/dispatcher/src/handlers/configCommandHandlers.ts +++ b/ts/packages/dispatcher/src/handlers/configCommandHandlers.ts @@ -244,12 +244,13 @@ function showAgentStatus( } const getRow = ( + emoji: string, displayName: string, schemas?: string, actions?: string, commands?: string, ) => { - const displayEntry = [displayName]; + const displayEntry = [emoji, displayName]; if (showSchema) { displayEntry.push(schemas ?? ""); } @@ -263,16 +264,19 @@ function showAgentStatus( }; const table: string[][] = [ - getRow("Agent", "Schemas", "Actions", "Commands"), + getRow("", "Agent", "Schemas", "Actions", "Commands"), ]; for (const [name, { schemas, actions, commands }] of entries) { - const displayName = getAppAgentName(name) !== name ? ` ${name}` : name; - table.push(getRow(displayName, schemas, actions, commands)); + const isAppAgentName = getAppAgentName(name) === name; + const displayName = isAppAgentName ? name : ` ${name}`; + const emoji = isAppAgentName ? agents.getEmojis()[name] : ""; + table.push(getRow(emoji, displayName, schemas, actions, commands)); } displayResult(table, context); } + class AgentToggleCommandHandler implements CommandHandler { public readonly description = `Toggle ${AgentToggleDescription[this.toggle]}`; public readonly parameters = { diff --git a/ts/packages/dispatcher/src/utils/exceptions.ts b/ts/packages/dispatcher/src/utils/exceptions.ts index eab5660b5..c5233b297 100644 --- a/ts/packages/dispatcher/src/utils/exceptions.ts +++ b/ts/packages/dispatcher/src/utils/exceptions.ts @@ -6,17 +6,7 @@ function throwEnsureError(e: any): never { throw new Error(e); } if (typeof e === "object") { - if (e instanceof Error) { - throw e; - } - const mayBeErrorLike = e as any; - if ( - typeof mayBeErrorLike.name === "string" && - typeof mayBeErrorLike.message === "string" && - typeof mayBeErrorLike.stack === "string" - ) { - throw e; - } + throw e; } throw new Error(`Unknown error: ${JSON.stringify(e)}`); }