Skip to content

Commit 85a5a4f

Browse files
committed
Create commander agent! (wraps terminal commands with grok-4-fast relaying output)
1 parent 9ac87ff commit 85a5a4f

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.agents/commander.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { publisher } from './constants'
2+
import type {
3+
AgentDefinition,
4+
AgentStepContext,
5+
} from './types/agent-definition'
6+
7+
const commander: AgentDefinition = {
8+
id: 'commander',
9+
publisher,
10+
model: 'x-ai/grok-4-fast',
11+
displayName: 'Commander',
12+
spawnerPrompt:
13+
'Runs a single terminal command and describes its output based on what information is requested.',
14+
inputSchema: {
15+
prompt: {
16+
type: 'string',
17+
description:
18+
'What information from the command output is desired. Be specific about what to look for or extract.',
19+
},
20+
params: {
21+
type: 'object',
22+
properties: {
23+
command: {
24+
type: 'string',
25+
description: 'Terminal command to run',
26+
},
27+
},
28+
required: ['command'],
29+
},
30+
},
31+
outputMode: 'last_message',
32+
includeMessageHistory: false,
33+
toolNames: ['run_terminal_command'],
34+
systemPrompt: `You are an expert at running terminal commands and analyzing their output.
35+
36+
Your job is to:
37+
1. Run the terminal commands provided
38+
2. Analyze the output based on what the user requested
39+
3. Provide a clear, concise description of the relevant information
40+
41+
When describing command output:
42+
- Use excerpts from the actual output when possible (especially for errors, key values, or specific data)
43+
- Focus on the information the user requested
44+
- Be concise but thorough
45+
- If the output is very long, summarize the key points rather than reproducing everything`,
46+
instructionsPrompt: `The user has provided a command to run and specified what information they want from the output.
47+
48+
Run the command and then describe the relevant information from the output, following the user's instructions about what to focus on.`,
49+
handleSteps: function* ({
50+
agentState,
51+
prompt,
52+
params,
53+
logger,
54+
}: AgentStepContext) {
55+
const command = params?.command as string | undefined
56+
if (!command) {
57+
return
58+
}
59+
60+
// Run the command
61+
yield {
62+
toolName: 'run_terminal_command',
63+
input: { command },
64+
}
65+
66+
// Let the model analyze and describe the output
67+
yield 'STEP_ALL'
68+
},
69+
}
70+
71+
export default commander

0 commit comments

Comments
 (0)