5
5
"os"
6
6
7
7
"github.com/abiosoft/ishell/v2"
8
+ autogen_client "github.com/kagent-dev/kagent/go/autogen/client"
8
9
"github.com/kagent-dev/kagent/go/cli/internal/cli"
9
10
"github.com/kagent-dev/kagent/go/cli/internal/config"
10
11
)
@@ -17,31 +18,60 @@ func main() {
17
18
os .Exit (1 )
18
19
}
19
20
21
+ cfg , err := config .Get ()
22
+ if err != nil {
23
+ fmt .Fprintf (os .Stderr , "Error getting config: %v\n " , err )
24
+ os .Exit (1 )
25
+ }
26
+
27
+ client := autogen_client .New (cfg .APIURL , cfg .WSURL )
28
+
20
29
// create new shell.
21
30
// by default, new shell includes 'exit', 'help' and 'clear' commands.
22
31
shell := ishell .New ()
32
+ cli .SetCfg (shell , cfg )
33
+ cli .SetClient (shell , client )
23
34
24
35
shell .SetPrompt (cli .BoldBlue ("kagent >> " ))
25
- shell .AddCmd (& ishell.Cmd {
36
+
37
+ runCmd := & ishell.Cmd {
38
+ Name : "run" ,
39
+ Aliases : []string {"r" },
40
+ Help : "Run a kagent agent" ,
41
+ LongHelp : `Run a kagent agent.
42
+
43
+ The available run types are:
44
+ - chat: Start a chat with a kagent agent.
45
+
46
+ Examples:
47
+ - run chat [team_name] -s [session_name]
48
+ - run chat
49
+ ` ,
50
+ }
51
+
52
+ runCmd .AddCmd (& ishell.Cmd {
26
53
Name : "chat" ,
27
54
Aliases : []string {"c" },
28
55
Help : "Start a chat with a kagent agent." ,
29
56
LongHelp : `Start a chat with a kagent agent.
30
57
31
- Examples:
32
- chat
33
- chat [team_name]
34
-
35
58
If no team name is provided, then a list of available teams will be provided to select from.
36
- ` ,
37
- Func : func (c * ishell.Context ) {
59
+ If no session name is provided, then a new session will be created and the chat will be associated with it.
38
60
61
+ Examples:
62
+ - chat [team_name] -s [session_name]
63
+ - chat [team_name]
64
+ - chat
65
+ ` ,
66
+ Func : func (c * ishell.Context ) {
39
67
cli .ChatCmd (c )
40
68
c .SetPrompt (cli .BoldBlue ("kagent >> " ))
41
69
},
42
70
})
43
71
44
- shell .AddCmd (& ishell.Cmd {
72
+ shell .AddCmd (runCmd )
73
+
74
+ getCmd := & ishell.Cmd {
45
75
Name : "get" ,
46
76
Aliases : []string {"g" },
47
77
Help : "get kagent resources." ,
@@ -53,12 +83,52 @@ Examples:
53
83
get run
54
84
get agents
55
85
` ,
56
- Func : func (c * ishell.Context ) {
57
- cli .GetCmd (c )
58
- c .SetPrompt (cli .BoldBlue ("kagent >> " ))
59
- },
86
+ }
87
+
88
+ getCmd .AddCmd (& ishell.Cmd {
89
+ Name : "session" ,
90
+ Aliases : []string {"s" },
91
+ Help : "get a session." ,
92
+ LongHelp : `get a session.
93
+
94
+ If no resource name is provided, then a list of available resources will be returned.
95
+ Examples:
96
+ get session [session_name]
97
+ get session
98
+ ` ,
99
+ Func : cli .GetSessionCmd ,
100
+ })
101
+
102
+ getCmd .AddCmd (& ishell.Cmd {
103
+ Name : "run" ,
104
+ Aliases : []string {"r" },
105
+ Help : "get a run." ,
106
+ LongHelp : `get a run.
107
+
108
+ If no resource name is provided, then a list of available resources will be returned.
109
+ Examples:
110
+ get run [run_name]
111
+ get run
112
+ ` ,
113
+ Func : cli .GetRunCmd ,
114
+ })
115
+
116
+ getCmd .AddCmd (& ishell.Cmd {
117
+ Name : "agent" ,
118
+ Aliases : []string {"a" },
119
+ Help : "get an agent." ,
120
+ LongHelp : `get an agent.
121
+
122
+ If no resource name is provided, then a list of available resources will be returned.
123
+ Examples:
124
+ get agent [agent_name]
125
+ get agent
126
+ ` ,
127
+ Func : cli .GetAgentCmd ,
60
128
})
61
129
130
+ shell .AddCmd (getCmd )
131
+
62
132
shell .NotFound (func (c * ishell.Context ) {
63
133
// Hidden create command
64
134
if len (c .Args ) > 0 && c .Args [0 ] == "create" {
0 commit comments