11import { describe , it , expect } from "@jest/globals" ;
22import { transformScriptMessagesForLLM } from "./modelMessageTransform" ;
33import type { MuxMessage } from "@/common/types/message" ;
4+ import type { BashToolResult } from "@/common/types/tools" ;
45
56describe ( "transformScriptMessagesForLLM" , ( ) => {
67 it ( "should include stdout/stderr in script execution messages" , ( ) => {
8+ const scriptResult : BashToolResult = {
9+ success : true ,
10+ output : "some stdout output" ,
11+ exitCode : 0 ,
12+ wall_duration_ms : 100 ,
13+ } ;
14+
715 const messages : MuxMessage [ ] = [
816 {
917 id : "script-1" ,
@@ -18,12 +26,7 @@ describe("transformScriptMessagesForLLM", () => {
1826 command : "/script test" ,
1927 scriptName : "test.sh" ,
2028 args : [ ] ,
21- result : {
22- success : true ,
23- output : "some stdout output" ,
24- exitCode : 0 ,
25- wall_duration_ms : 100 ,
26- } as any ,
29+ result : scriptResult ,
2730 } ,
2831 } ,
2932 } ,
@@ -34,13 +37,22 @@ describe("transformScriptMessagesForLLM", () => {
3437 const textPart = result [ 0 ] . parts [ 0 ] ;
3538 expect ( textPart . type ) . toBe ( "text" ) ;
3639 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+ expect ( textPart . text ) . toContain ( "Script 'test.sh' executed" ) ;
41+ expect ( textPart . text ) . toContain ( "Stdout/Stderr:" ) ;
42+ expect ( textPart . text ) . toContain ( "some stdout output" ) ;
4043 }
4144 } ) ;
4245
4346 it ( "should include all fields (stdout, output, prompt) if present" , ( ) => {
47+ const scriptResult : BashToolResult = {
48+ success : true ,
49+ output : "stdout stuff" ,
50+ exitCode : 0 ,
51+ wall_duration_ms : 100 ,
52+ outputFile : "User toast" ,
53+ promptFile : "Model prompt" ,
54+ } ;
55+
4456 const messages : MuxMessage [ ] = [
4557 {
4658 id : "script-all" ,
@@ -55,14 +67,7 @@ describe("transformScriptMessagesForLLM", () => {
5567 command : "/script all" ,
5668 scriptName : "all.sh" ,
5769 args : [ ] ,
58- result : {
59- success : true ,
60- output : "stdout stuff" ,
61- exitCode : 0 ,
62- wall_duration_ms : 100 ,
63- outputFile : "User toast" ,
64- promptFile : "Model prompt" ,
65- } as any ,
70+ result : scriptResult ,
6671 } ,
6772 } ,
6873 } ,
@@ -73,9 +78,9 @@ describe("transformScriptMessagesForLLM", () => {
7378 const textPart = result [ 0 ] . parts [ 0 ] ;
7479 expect ( textPart . type ) . toBe ( "text" ) ;
7580 if ( textPart . type === "text" ) {
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" ) ;
81+ expect ( textPart . text ) . toContain ( "Stdout/Stderr:\nstdout stuff" ) ;
82+ expect ( textPart . text ) . toContain ( "MUX_OUTPUT:\nUser toast" ) ;
83+ expect ( textPart . text ) . toContain ( "MUX_PROMPT:\nModel prompt" ) ;
7984 }
8085 } ) ;
8186} ) ;
0 commit comments