@@ -3,13 +3,8 @@ import { transformScriptMessagesForLLM } from "./modelMessageTransform";
33import type { MuxMessage } from "@/common/types/message" ;
44
55describe ( "transformScriptMessagesForLLM" , ( ) => {
6- it ( "should remove script execution messages that have no promptFile content " , ( ) => {
6+ it ( "should include stdout/stderr in script execution messages" , ( ) => {
77 const messages : MuxMessage [ ] = [
8- {
9- id : "1" ,
10- role : "user" ,
11- parts : [ { type : "text" , text : "Execute script" } ] ,
12- } ,
138 {
149 id : "script-1" ,
1510 role : "user" ,
@@ -36,30 +31,37 @@ describe("transformScriptMessagesForLLM", () => {
3631
3732 const result = transformScriptMessagesForLLM ( messages ) ;
3833 expect ( result ) . toHaveLength ( 1 ) ;
39- expect ( result [ 0 ] . id ) . toBe ( "1" ) ;
34+ const textPart = result [ 0 ] . parts [ 0 ] ;
35+ expect ( textPart . type ) . toBe ( "text" ) ;
36+ if ( textPart . type === "text" ) {
37+ expect ( textPart . text ) . toContain ( "Script 'test.sh' executed" ) ;
38+ expect ( textPart . text ) . toContain ( "Stdout/Stderr:" ) ;
39+ expect ( textPart . text ) . toContain ( "some stdout output" ) ;
40+ }
4041 } ) ;
4142
42- it ( "should include script execution messages that HAVE promptFile content " , ( ) => {
43+ it ( "should include all fields (stdout, output, prompt) if present " , ( ) => {
4344 const messages : MuxMessage [ ] = [
4445 {
45- id : "script-1 " ,
46+ id : "script-all " ,
4647 role : "user" ,
47- parts : [ { type : "text" , text : "Executed script: /script test " } ] ,
48+ parts : [ { type : "text" , text : "Executed script: /script all " } ] ,
4849 metadata : {
4950 muxMetadata : {
5051 type : "script-execution" ,
51- id : "script-1 " ,
52+ id : "script-all " ,
5253 historySequence : 0 ,
5354 timestamp : 123 ,
54- command : "/script test " ,
55- scriptName : "test .sh" ,
55+ command : "/script all " ,
56+ scriptName : "all .sh" ,
5657 args : [ ] ,
5758 result : {
5859 success : true ,
59- output : "some stdout output " ,
60+ output : "stdout stuff " ,
6061 exitCode : 0 ,
6162 wall_duration_ms : 100 ,
62- promptFile : "This is relevant for the LLM" ,
63+ outputFile : "User toast" ,
64+ promptFile : "Model prompt" ,
6365 } as any ,
6466 } ,
6567 } ,
@@ -71,10 +73,9 @@ describe("transformScriptMessagesForLLM", () => {
7173 const textPart = result [ 0 ] . parts [ 0 ] ;
7274 expect ( textPart . type ) . toBe ( "text" ) ;
7375 if ( textPart . type === "text" ) {
74- expect ( textPart . text ) . toContain ( "Script 'test.sh' executed" ) ;
75- expect ( textPart . text ) . toContain ( "Output:" ) ;
76- expect ( textPart . text ) . toContain ( "This is relevant for the LLM" ) ;
77- expect ( textPart . text ) . not . toContain ( "some stdout output" ) ;
76+ expect ( textPart . text ) . toContain ( "Stdout/Stderr:\nstdout stuff" ) ;
77+ expect ( textPart . text ) . toContain ( "MUX_OUTPUT:\nUser toast" ) ;
78+ expect ( textPart . text ) . toContain ( "MUX_PROMPT:\nModel prompt" ) ;
7879 }
7980 } ) ;
8081} ) ;
0 commit comments